diff --git a/Makefile b/Makefile index e1730741ffa0..e89a5b11c790 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,6 @@ # # $FreeBSD$ # -# Copyright (c) 2014 Kevin Lo. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that 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. -# - -S= ${.CURDIR}/../../.. - -.PATH: $S/dev/usb/misc - -KMOD= uled -SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \ - uled.c - -.include -# -# $FreeBSD$ -# # The user-driven targets are: # # universe - *Really* build *everything* (buildworld and diff --git a/Makefile.inc1 b/Makefile.inc1 index 98362bd5dfae..c3b6d197789a 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -336,11 +336,11 @@ XFLAGS+= -B${CROSS_BINUTILS_PREFIX} .else XFLAGS+= -B${WORLDTMP}/usr/bin .endif -.if ${TARGET} == "arm" && ${MK_ARM_EABI} != "no" -.if ${TARGET_ARCH:M*eb*} == "" -TARGET_ABI= gnueabi -.elif ${TARGET_ARCH} == "armv6hf" +.if ${TARGET} == "arm" +.if ${TARGET_ARCH:M*hf*} != "" TARGET_ABI= gnueabihf +.else +TARGET_ABI= gnueabi .endif .endif TARGET_ABI?= unknown @@ -352,6 +352,7 @@ WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP} .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" # 32 bit world +LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32 .if ${TARGET_ARCH} == "amd64" @@ -387,7 +388,7 @@ LIB32FLAGS+= --sysroot=${WORLDTMP} .endif # Yes, the flags are redundant. -LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ +LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \ _SHLIBDIRPREFIX=${LIB32TMP} \ _LDSCRIPTROOT=${LIB32TMP} \ VERSION="${VERSION}" \ @@ -611,7 +612,7 @@ build32: cd ${.CURDIR}/${_dir}; \ WORLDTMP=${WORLDTMP} \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ - MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \ + MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ build-tools .endfor @@ -910,7 +911,7 @@ packageworld: # and do a 'make reinstall' on the *client* to install new binaries from the # most recent server build. # -reinstall: +reinstall: .MAKE @echo "--------------------------------------------------------------" @echo ">>> Making hierarchy" @echo "--------------------------------------------------------------" @@ -925,7 +926,7 @@ reinstall: ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32 .endif -redistribute: +redistribute: .MAKE @echo "--------------------------------------------------------------" @echo ">>> Distributing everything" @echo "--------------------------------------------------------------" @@ -935,7 +936,7 @@ redistribute: DISTRIBUTION=lib32 .endif -distrib-dirs distribution: +distrib-dirs distribution: .MAKE cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET} @@ -1463,7 +1464,7 @@ native-xtools: .MAKE # # hierarchy - ensure that all the needed directories are present # -hierarchy hier: +hierarchy hier: .MAKE cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs # @@ -1530,7 +1531,9 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \ lib/ncurses/ncurses lib/ncurses/ncursesw \ lib/libopie lib/libpam ${_lib_libthr} \ lib/libradius lib/libsbuf lib/libtacplus \ + lib/libgeom \ ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \ + ${_cddl_lib_libuutil} \ ${_cddl_lib_libavl} \ ${_cddl_lib_libzfs_core} \ lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \ @@ -1542,6 +1545,8 @@ gnu/lib/libstdc++__L: lib/msun__L gnu/lib/libsupc++__L: gnu/lib/libstdc++__L .endif +lib/libgeom__L: lib/libexpat__L + .if defined(WITH_ATF) || ${MK_TESTS} != "no" .if !defined(WITH_ATF) # Ensure that the ATF libraries will be built during make libraries, even @@ -1579,9 +1584,11 @@ lib/libopie__L lib/libtacplus__L: lib/libmd__L _cddl_lib_libumem= cddl/lib/libumem _cddl_lib_libnvpair= cddl/lib/libnvpair _cddl_lib_libavl= cddl/lib/libavl +_cddl_lib_libuutil= cddl/lib/libuutil _cddl_lib_libzfs_core= cddl/lib/libzfs_core _cddl_lib= cddl/lib cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L +cddl/lib/libzfs__L: lib/libgeom__L .endif .if ${MK_CRYPT} != "no" diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index ede94fdd130e..3c4878b587de 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,14 @@ # xargs -n1 | sort | uniq -d; # done +# 20140922: sleepq_calc_signal_retval.9 and sleepq_catch_signals.9 removed +OLD_FILES+=usr/share/man/man9/sleepq_calc_signal_retval.9.gz +OLD_FILES+=usr/share/man/man9/sleepq_catch_signals.9.gz +# 20140917: hv_kvpd rc.d script removed in favor of devd configuration +OLD_FILES+=etc/rc.d/hv_kvpd +# 20140917: libnv was accidentally being installed to /usr/lib instead of /lib +OLD_LIBS+=usr/lib/libnv.a +OLD_LIBS+=usr/lib/libnv.so.0 # 20140814: libopie version bump OLD_LIBS+=usr/lib/libopie.so.7 OLD_LIBS+=usr/lib32/libopie.so.7 @@ -1488,6 +1496,7 @@ OLD_LIBS+=usr/lib/libpanel.so.4 OLD_LIBS+=usr/lib/libpanelw.so.4 OLD_LIBS+=usr/lib/libpmc.so.4 OLD_LIBS+=usr/lib/libproc.so.1 +OLD_LIBS+=usr/lib/libproc.so.2 OLD_LIBS+=usr/lib/libradius.so.3 OLD_LIBS+=usr/lib/librpcsvc.so.4 OLD_LIBS+=usr/lib/libsdp.so.3 diff --git a/UPDATING b/UPDATING index cb00e10d167b..04fe7a66a427 100644 --- a/UPDATING +++ b/UPDATING @@ -31,6 +31,18 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20140923: + pjdfstest has been moved from tools/regression/pjdfstest to + contrib/pjdfstest . + +20140922: + At svn r271982, The default linux compat kernel ABI has been adjusted + to 2.6.18 in support of the linux-c6 compat ports infrastructure + update. If you wish to continue using the linux-f10 compat ports, + add compat.linux.osrelease=2.6.16 to your local sysctl.conf. Users are + encouraged to update their linux-compat packages to linux-c6 during + their next update cycle. + 20140729: The ofwfb driver, used to provide a graphics console on PowerPC when using vt(4), no longer allows mmap() of all of physical memory. This diff --git a/bin/csh/Makefile b/bin/csh/Makefile index 9f305b4f5f04..fd345245eb0b 100644 --- a/bin/csh/Makefile +++ b/bin/csh/Makefile @@ -94,7 +94,7 @@ GENHDRS+= iconv.h SRCS+= iconv_stub.c iconv.h: ${.CURDIR}/iconv_stub.h - cp ${.CURDIR}/iconv_stub.h ${.TARGET} + cp -f ${.CURDIR}/iconv_stub.h ${.TARGET} .endif .endif diff --git a/bin/pkill/tests/pgrep-j_test.sh b/bin/pkill/tests/pgrep-j_test.sh index 6656a9bd789f..6acfb4be35ad 100644 --- a/bin/pkill/tests/pgrep-j_test.sh +++ b/bin/pkill/tests/pgrep-j_test.sh @@ -1,7 +1,23 @@ #!/bin/sh # $FreeBSD$ -base=`basename $0` +jail_name_to_jid() +{ + local check_name="$1" + ( + line="$(jls -n 2> /dev/null | grep name=$check_name )" + for nv in $line; do + local name="${nv%=*}" + if [ "${name}" = "jid" ]; then + eval $nv + echo $jid + break + fi + done + ) +} + +base=pgrep_j_test echo "1..3" @@ -9,21 +25,25 @@ name="pgrep -j " if [ `id -u` -eq 0 ]; then sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep - jail / $base-1 127.0.0.1 $sleep 5 & - chpid=$! - jail / $base-2 127.0.0.1 $sleep 5 & - chpid2=$! - $sleep 5 & - chpid3=$! - sleep 0.5 - jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"` - pid=`pgrep -f -j $jid $sleep` - if [ "$pid" = "$chpid" ]; then + jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_1_1.pid $sleep 5 & + + jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_1_2.pid $sleep 5 & + + jid1=$(jail_name_to_jid ${base}_1_1) + jid2=$(jail_name_to_jid ${base}_1_2) + jid="${jid1},${jid2}" + pid1="$(pgrep -f -x -j $jid "$sleep 5" | sort)" + pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_1_1.pid)" \ + $(cat ${PWD}/${base}_1_2.pid) | sort) + if [ "$pid1" = "$pid2" ]; then echo "ok 1 - $name" else echo "not ok 1 - $name" fi - kill $chpid $chpid2 $chpid3 + [ -f ${PWD}/${base}_1_1.pid ] && kill $(cat ${PWD}/${base}_1_1.pid) + [ -f ${PWD}/${base}_1_2.pid ] && kill $(cat ${PWD}/${base}_1_2.pid) rm -f $sleep else echo "ok 1 - $name # skip Test needs uid 0." @@ -33,21 +53,23 @@ name="pgrep -j any" if [ `id -u` -eq 0 ]; then sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep - jail / $base-1 127.0.0.1 $sleep 5 & - chpid=$! - jail / $base-2 127.0.0.1 $sleep 5 & - chpid2=$! - $sleep 5 & - chpid3=$! - sleep 0.5 - pids=`pgrep -f -j any $sleep | sort` - refpids=`{ echo $chpid; echo $chpid2; } | sort` - if [ "$pids" = "$refpids" ]; then + jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_2_1.pid $sleep 5 & + + jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_2_2.pid $sleep 5 & + + sleep 2 + pid1="$(pgrep -f -x -j any "$sleep 5" | sort)" + pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_2_1.pid)" \ + $(cat ${PWD}/${base}_2_2.pid) | sort) + if [ "$pid1" = "$pid2" ]; then echo "ok 2 - $name" else echo "not ok 2 - $name" fi - kill $chpid $chpid2 $chpid3 + [ -f ${PWD}/${base}_2_1.pid ] && kill $(cat ${PWD}/${base}_2_1.pid) + [ -f ${PWD}/${base}_2_2.pid ] && kill $(cat ${PWD}/${base}_2_2.pid) rm -f $sleep else echo "ok 2 - $name # skip Test needs uid 0." @@ -57,19 +79,19 @@ name="pgrep -j none" if [ `id -u` -eq 0 ]; then sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep - $sleep 5 & - chpid=$! - jail / $base 127.0.0.1 $sleep 5 & - chpid2=$! - sleep 0.5 - pid=`pgrep -f -j none $sleep` - if [ "$pid" = "$chpid" ]; then + daemon -p ${PWD}/${base}_3_1.pid $sleep 5 & + jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_3_2.pid $sleep 5 & + sleep 2 + pid="$(pgrep -f -x -j none "$sleep 5")" + if [ "$pid" = "$(cat ${PWD}/${base}_3_1.pid)" ]; then echo "ok 3 - $name" else echo "not ok 3 - $name" fi - kill $chpid $chpid2 rm -f $sleep + [ -f ${PWD}/${base}_3_1.pid ] && kill $(cat $PWD/${base}_3_1.pid) + [ -f ${PWD}/${base}_3_2.pid ] && kill $(cat $PWD/${base}_3_2.pid) else echo "ok 3 - $name # skip Test needs uid 0." fi diff --git a/bin/pkill/tests/pkill-j_test.sh b/bin/pkill/tests/pkill-j_test.sh index 48e7c721bbec..a844149cedb0 100644 --- a/bin/pkill/tests/pkill-j_test.sh +++ b/bin/pkill/tests/pkill-j_test.sh @@ -1,7 +1,23 @@ #!/bin/sh # $FreeBSD$ -base=`basename $0` +jail_name_to_jid() +{ + local check_name="$1" + ( + line="$(jls -n 2> /dev/null | grep name=$check_name )" + for nv in $line; do + local name="${nv%=*}" + if [ "${name}" = "jid" ]; then + eval $nv + echo $jid + break + fi + done + ) +} + +base=pkill_j_test echo "1..3" @@ -9,21 +25,28 @@ name="pkill -j " if [ `id -u` -eq 0 ]; then sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep - jail / $base-1 127.0.0.1 $sleep 5 & - chpid=$! - jail / $base-2 127.0.0.1 $sleep 5 & - chpid2=$! + jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_1_1.pid $sleep 5 & + + jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_1_2.pid $sleep 5 & + $sleep 5 & - chpid3=$! sleep 0.5 - jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"` - if pkill -f -j $jid $sleep && sleep 0.5 && - ! kill $chpid && kill $chpid2 $chpid3; then + jid1=$(jail_name_to_jid ${base}_1_1) + jid2=$(jail_name_to_jid ${base}_1_2) + jid="${jid1},${jid2}" + if pkill -f -j "$jid" $sleep && sleep 0.5 && + ! -f ${PWD}/${base}_1_1.pid && + ! -f ${PWD}/${base}_1_2.pid ; then echo "ok 1 - $name" else echo "not ok 1 - $name" fi 2>/dev/null rm -f $sleep + [ -f ${PWD}/${base}_1_1.pid ] && kill $(cat ${PWD}/${base}_1_1.pid) + [ -f ${PWD}/${base}_1_2.pid ] && kill $(cat ${PWD}/${base}_1_2.pid) + wait else echo "ok 1 - $name # skip Test needs uid 0." fi @@ -32,20 +55,26 @@ name="pkill -j any" if [ `id -u` -eq 0 ]; then sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep - jail / $base-1 127.0.0.1 $sleep 5 & - chpid=$! - jail / $base-2 127.0.0.1 $sleep 5 & - chpid2=$! + jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_2_1.pid $sleep 5 & + + jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_2_2.pid $sleep 5 & + $sleep 5 & - chpid3=$! sleep 0.5 + chpid3=$! if pkill -f -j any $sleep && sleep 0.5 && - ! kill $chpid && ! kill $chpid2 && kill $chpid3; then + [ ! -f ${PWD}/${base}_2_1.pid -a + ! -f ${PWD}/${base}_2_2.pid ] && kill $chpid3; then echo "ok 2 - $name" else echo "not ok 2 - $name" fi 2>/dev/null rm -f $sleep + [ -f ${PWD}/${base}_2_1.pid ] && kill $(cat ${PWD}/${base}_2_1.pid) + [ -f ${PWD}/${base}_2_2.pid ] && kill $(cat ${PWD}/${base}_2_2.pid) + wait else echo "ok 2 - $name # skip Test needs uid 0." fi @@ -54,18 +83,20 @@ name="pkill -j none" if [ `id -u` -eq 0 ]; then sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep - $sleep 5 & - chpid=$! - jail / $base 127.0.0.1 $sleep 5 & - chpid2=$! - sleep 0.5 - if pkill -f -j none $sleep && sleep 0.5 && - ! kill $chpid && kill $chpid2; then + daemon -p ${PWD}/${base}_3_1.pid $sleep 5 + jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_3_2.pid $sleep 5 & + sleep 1 + if pkill -f -j none "$sleep 5" && sleep 1 && + [ ! -f ${PWD}/${base}_3_1.pid -a -f ${PWD}/${base}_3_2.pid ] ; then echo "ok 3 - $name" else + ls ${PWD}/*.pid echo "not ok 3 - $name" fi 2>/dev/null rm -f $sleep + [ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid) + [ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid) else echo "ok 3 - $name # skip Test needs uid 0." fi diff --git a/bin/sh/input.c b/bin/sh/input.c index 05cc1ebe606f..412f1442b08c 100644 --- a/bin/sh/input.c +++ b/bin/sh/input.c @@ -116,33 +116,6 @@ resetinput(void) } -/* - * Read a line from the script. - */ - -char * -pfgets(char *line, int len) -{ - char *p = line; - int nleft = len; - int c; - - while (--nleft > 0) { - c = pgetc_macro(); - if (c == PEOF) { - if (p == line) - return NULL; - break; - } - *p++ = c; - if (c == '\n') - break; - } - *p = '\0'; - return line; -} - - /* * Read a character from the script, returning PEOF on end of file. @@ -338,7 +311,7 @@ pungetc(void) * We handle aliases this way. */ void -pushstring(char *s, int len, struct alias *ap) +pushstring(const char *s, int len, struct alias *ap) { struct strpush *sp; diff --git a/bin/sh/input.h b/bin/sh/input.h index cc54eedb185a..cb0af77b4bbc 100644 --- a/bin/sh/input.h +++ b/bin/sh/input.h @@ -48,12 +48,11 @@ struct alias; struct parsefile; void resetinput(void); -char *pfgets(char *, int); int pgetc(void); int preadbuffer(void); int preadateof(void); void pungetc(void); -void pushstring(char *, int, struct alias *); +void pushstring(const char *, int, struct alias *); void setinputfile(const char *, int); void setinputfd(int, int); void setinputstring(const char *, int); diff --git a/bin/sh/parser.c b/bin/sh/parser.c index e6e9f82ccfd7..f1f4e0713a88 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$"); * Shell command parser. */ -#define EOFMARKLEN 79 #define PROMPTLEN 128 /* values of checkkwd variable */ @@ -718,7 +717,6 @@ parsefname(void) if (n->type == NHERE) { struct heredoc *here = heredoc; struct heredoc *p; - int i; if (quoteflag == 0) n->type = NXHERE; @@ -727,7 +725,7 @@ parsefname(void) while (*wordtext == '\t') wordtext++; } - if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN) + if (! noexpand(wordtext)) synerror("Illegal eof marker for << redirection"); rmescapes(wordtext); here->eofmark = wordtext; @@ -945,6 +943,41 @@ struct tokenstate }; +/* + * Check to see whether we are at the end of the here document. When this + * is called, c is set to the first character of the next input line. If + * we are at the end of the here document, this routine sets the c to PEOF. + * The new value of c is returned. + */ + +static int +checkend(int c, const char *eofmark, int striptabs) +{ + if (striptabs) { + while (c == '\t') + c = pgetc(); + } + if (c == *eofmark) { + int c2; + const char *q; + + for (q = eofmark + 1; c2 = pgetc(), *q != '\0' && c2 == *q; q++) + ; + if ((c2 == PEOF || c2 == '\n') && *q == '\0') { + c = PEOF; + if (c2 == '\n') { + plinno++; + needprompt = doprompt; + } + } else { + pungetc(); + pushstring(eofmark + 1, q - (eofmark + 1), NULL); + } + } + return (c); +} + + /* * Called to parse command substitutions. */ @@ -1246,6 +1279,13 @@ readcstyleesc(char *out) c = pgetc(); if (c == PEOF) synerror("Unterminated quoted string"); + if (c == '\n') { + plinno++; + if (doprompt) + setprompt(2); + else + setprompt(0); + } } pungetc(); return out; @@ -1269,7 +1309,6 @@ readcstyleesc(char *out) * will run code that appears at the end of readtoken1. */ -#define CHECKEND() {goto checkend; checkend_return:;} #define PARSEREDIR() {goto parseredir; parseredir_return:;} #define PARSESUB() {goto parsesub; parsesub_return:;} #define PARSEARITH() {goto parsearith; parsearith_return:;} @@ -1281,7 +1320,6 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark, int c = firstc; char *out; int len; - char line[EOFMARKLEN + 1]; struct nodelist *bqlist; int quotef; int newvarnest; @@ -1303,7 +1341,9 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark, STARTSTACKSTR(out); loop: { /* for each line, until end of word */ - CHECKEND(); /* set c to PEOF if at end of here document */ + if (eofmark) + /* set c to PEOF if at end of here document */ + c = checkend(c, eofmark, striptabs); for (;;) { /* until end of line or end of word */ CHECKSTRSPACE(4, out); /* permit 4 calls to USTPUTC */ @@ -1483,40 +1523,6 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark, /* end of readtoken routine */ -/* - * Check to see whether we are at the end of the here document. When this - * is called, c is set to the first character of the next input line. If - * we are at the end of the here document, this routine sets the c to PEOF. - */ - -checkend: { - if (eofmark) { - if (striptabs) { - while (c == '\t') - c = pgetc(); - } - if (c == *eofmark) { - if (pfgets(line, sizeof line) != NULL) { - const char *p, *q; - - p = line; - for (q = eofmark + 1 ; *q && *p == *q ; p++, q++); - if ((*p == '\0' || *p == '\n') && *q == '\0') { - c = PEOF; - if (*p == '\n') { - plinno++; - needprompt = doprompt; - } - } else { - pushstring(line, strlen(line), NULL); - } - } - } - } - goto checkend_return; -} - - /* * Parse a redirection operator. The variable "out" points to a string * specifying the fd to be redirected. The variable "c" contains the @@ -1915,7 +1921,7 @@ char * getprompt(void *unused __unused) { static char ps[PROMPTLEN]; - char *fmt; + const char *fmt; const char *pwd; int i, trim; static char internal_error[] = "??"; @@ -2029,7 +2035,7 @@ expandstr(const char *ps) parser_temp = NULL; setinputstring(ps, 1); doprompt = 0; - readtoken1(pgetc(), DQSYNTAX, "\n\n", 0); + readtoken1(pgetc(), DQSYNTAX, "", 0); if (backquotelist != NULL) error("Command substitution not allowed here"); diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 4679d455ec50..47b1b36c59f1 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd September 4, 2014 +.Dd September 21, 2014 .Dt SH 1 .Os .Sh NAME @@ -590,7 +590,8 @@ the following actions: Leading words of the form .Dq Li name=value are stripped off and assigned to the environment of -the simple command. +the simple command +(they do not affect expansions). Redirection operators and their arguments (as described below) are stripped off and saved for processing. diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index 07c8098e22b7..d5d96b58a48c 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -100,6 +100,7 @@ FILES+= jobid2.0 FILES+= kill1.0 kill2.0 FILES+= lineno.0 lineno.0.stdout FILES+= lineno2.0 +FILES+= lineno3.0 lineno3.0.stdout FILES+= local1.0 FILES+= local2.0 FILES+= local3.0 diff --git a/bin/sh/tests/builtins/lineno3.0 b/bin/sh/tests/builtins/lineno3.0 new file mode 100644 index 000000000000..eb8f9ab7db94 --- /dev/null +++ b/bin/sh/tests/builtins/lineno3.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +echo before: $LINENO +dummy=$'a\0 +' +echo after: $LINENO diff --git a/bin/sh/tests/builtins/lineno3.0.stdout b/bin/sh/tests/builtins/lineno3.0.stdout new file mode 100644 index 000000000000..6e0e4ac8ca57 --- /dev/null +++ b/bin/sh/tests/builtins/lineno3.0.stdout @@ -0,0 +1,2 @@ +before: 3 +after: 6 diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile index 4b2e76dce51e..7b77cb8203c8 100644 --- a/bin/sh/tests/parser/Makefile +++ b/bin/sh/tests/parser/Makefile @@ -54,6 +54,7 @@ FILES+= heredoc8.0 FILES+= heredoc9.0 FILES+= heredoc10.0 FILES+= heredoc11.0 +FILES+= heredoc12.0 FILES+= no-space1.0 FILES+= no-space2.0 FILES+= only-redir1.0 diff --git a/bin/sh/tests/parser/heredoc12.0 b/bin/sh/tests/parser/heredoc12.0 new file mode 100644 index 000000000000..964838453237 --- /dev/null +++ b/bin/sh/tests/parser/heredoc12.0 @@ -0,0 +1,47 @@ +# $FreeBSD$ + +failures=0 + +check() { + if ! eval "[ $* ]"; then + echo "Failed: $*" + : $((failures += 1)) + fi +} + +longmark=`printf %01000d 4` +longmarkstripped=`printf %0999d 0` + +check '"$(cat <<'"$longmark +$longmark"' +echo yes)" = "yes"' + +check '"$(cat <<\'"$longmark +$longmark"' +echo yes)" = "yes"' + +check '"$(cat <<'"$longmark +yes +$longmark"' +)" = "yes"' + +check '"$(cat <<\'"$longmark +yes +$longmark"' +)" = "yes"' + +check '"$(cat <<'"$longmark +$longmarkstripped +$longmark. +$longmark"' +)" = "'"$longmarkstripped +$longmark."'"' + +check '"$(cat <<\'"$longmark +$longmarkstripped +$longmark. +$longmark"' +)" = "'"$longmarkstripped +$longmark."'"' + +exit $((failures != 0)) diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 index cc3a3112df7c..2d210a2cde84 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 @@ -277,6 +277,19 @@ Generate a header file containing macros that correspond to probes in the specified provider definitions. This option should be used to generate a header file that is included by other source files for later use with the +.Fl G +option. +If the +.Fl o +option is present, the header file is saved using the pathname specified as the +argument for that option. +If the +.Fl o +option is not present and the DTrace program is contained within a file whose +name is +.Ar filename.d , +then the header file is saved using the name +.Ar filename.h . .It Fl H Print the pathnames of included files when invoking .Xr cpp 1 @@ -289,20 +302,6 @@ option to each .Xr cpp 1 invocation, causing it to display the list of pathnames, one for each line, to standard error. -.Fl G -option. -If the -.Fl o -option -is present, the header file is saved using the pathname specified as the -argument for that option. -If the -.Fl o -option is not present and the DTrace program is contained with a file whose -name is -.Ar filename.d , -then the header file is saved using the name -.Ar filename.h . .It Fl i Ar probe-id Op Oo Ar predicate Oc Ar action Specify probe identifier .Ar ( probe-id ) diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c index 4cbb866cfad7..3a954ed40482 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c @@ -710,6 +710,9 @@ list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg) if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0) print_probe_info(&p); + if (g_intr != 0) + return (1); + return (0); } @@ -1220,11 +1223,34 @@ intr(int signo) g_impatient = 1; } +static void +installsighands(void) +{ + struct sigaction act, oact; + + (void) sigemptyset(&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = intr; + + if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGINT, &act, NULL); + + if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGTERM, &act, NULL); + +#if !defined(sun) + if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGPIPE, &act, NULL); + + if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGUSR1, &act, NULL); +#endif +} + int main(int argc, char *argv[]) { dtrace_bufdesc_t buf; - struct sigaction act, oact; dtrace_status_t status[2]; dtrace_optval_t opt; dtrace_cmd_t *dcp; @@ -1776,6 +1802,8 @@ main(int argc, char *argv[]) if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL) fatal("failed to open output file '%s'", g_ofile); + installsighands(); + oprintf("%5s %10s %17s %33s %s\n", "ID", "PROVIDER", "MODULE", "FUNCTION", "NAME"); @@ -1861,20 +1889,7 @@ main(int argc, char *argv[]) if (opt != DTRACEOPT_UNSET) notice("allowing destructive actions\n"); - (void) sigemptyset(&act.sa_mask); - act.sa_flags = 0; - act.sa_handler = intr; - - if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) - (void) sigaction(SIGINT, &act, NULL); - - if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) - (void) sigaction(SIGTERM, &act, NULL); - -#if !defined(sun) - if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) - (void) sigaction(SIGUSR1, &act, NULL); -#endif + installsighands(); /* * Now that tracing is active and we are ready to consume trace data, diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c index 8dabbe6e33ac..bb571d2ea33e 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c @@ -34,14 +34,14 @@ * leading underscores. */ -#pragma weak _go = go - static int go(int a) { return (a + 1); } +#pragma weak _go = go + static void handle(int sig) { diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh index 978cde3cf0ef..432a9fccb44f 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh @@ -29,6 +29,7 @@ dtrace=$1 t="season_8_mountain_of_madness_t" pid=$$ -rc=`$dtrace -n "BEGIN{ trace(pid$pid`$t)0); }"` +$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }" +rc=$? exit $rc diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh index e64ed526ed37..d1b48769ba6c 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh @@ -30,6 +30,7 @@ dtrace=$1 t="season_8_mountain_of_madness_t" pid=$$ -rc=`$dtrace -n "BEGIN{ trace(pid`$t)0); }"` -p $pid +$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }" -p $pid +rc=$? exit $rc diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh index d987c8da7a47..4eaf169f06dd 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh @@ -31,7 +31,7 @@ dtrace=$1 t="zelda_info_t" exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh index 151a93676d6d..95b26c82d7ab 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh @@ -25,10 +25,10 @@ if [ $# != 1 ]; then fi dtrace=$1 -t="season_7_lisa_the_vegetrian_t *" +t="season_7_lisa_the_vegetarian_t *" exe="tst.aouttype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 @@ -37,7 +37,8 @@ fi ./$exe & pid=$! -rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"` +$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }" +rc=$? kill -9 $pid diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh index 25028460db43..d754c194b4b4 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="zelda_info_t" exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh index af7c6c8fe13a..233616619e7d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="int" exe="tst.libtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -eq 0 ]]; then echo "CTF exists in $exe, that's a bug" >&2 exit 1 @@ -38,7 +38,8 @@ fi ./$exe & pid=$! -rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"` +$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }" +rc=$? kill -9 $pid diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh index febb0159185a..e5902faf2cb2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh @@ -28,7 +28,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh index 7398dc41d9da..5e92cf924c2a 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh index dfc15358290d..a93a3b8722c3 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh @@ -28,7 +28,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh index 025d4a8c02df..fa080a53f3ff 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh index 58811ff6fb5a..54d975f63aff 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="zelda_info_t" exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 @@ -38,7 +38,7 @@ fi ./$exe & pid=$! -$dtrace -32 -qs /dev/stdin <&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 index 437b37413b9a..27e63a9438f4 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 @@ -414,7 +414,7 @@ or smaller can take advantage of this feature. When this feature is enabled, the contents of highly-compressible blocks are stored in the block "pointer" itself .Po a misnomer in this case, as it contains -the compresseed data, rather than a pointer to its location on disk +the compressed data, rather than a pointer to its location on disk .Pc . Thus the space of the block diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c index fe731691d9e1..31340b053a7a 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c @@ -2857,10 +2857,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb) right_justify = B_FALSE; if (pl->pl_prop != ZPROP_INVAL) { - if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ && - zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0) - propstr = "-"; - else if (zpool_get_prop(zhp, pl->pl_prop, property, + if (zpool_get_prop(zhp, pl->pl_prop, property, sizeof (property), NULL, cb->cb_literal) != 0) propstr = "-"; else @@ -2894,21 +2891,37 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb) } static void -print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted) +print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted, + boolean_t valid) { char propval[64]; boolean_t fixed; size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL); - - if (prop == ZPOOL_PROP_EXPANDSZ && value == 0) - (void) strlcpy(propval, "-", sizeof (propval)); - else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID) - (void) strlcpy(propval, "-", sizeof (propval)); - else if (prop == ZPOOL_PROP_FRAGMENTATION) + switch (prop) { + case ZPOOL_PROP_EXPANDSZ: + if (value == 0) + (void) strlcpy(propval, "-", sizeof (propval)); + else + zfs_nicenum(value, propval, sizeof (propval)); + break; + case ZPOOL_PROP_FRAGMENTATION: + if (value == ZFS_FRAG_INVALID) { + (void) strlcpy(propval, "-", sizeof (propval)); + } else { + (void) snprintf(propval, sizeof (propval), "%llu%%", + value); + } + break; + case ZPOOL_PROP_CAPACITY: (void) snprintf(propval, sizeof (propval), "%llu%%", value); - else + break; + default: zfs_nicenum(value, propval, sizeof (propval)); + } + + if (!valid) + (void) strlcpy(propval, "-", sizeof (propval)); if (scripted) (void) printf("\t%s", propval); @@ -2930,6 +2943,9 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, (uint64_t **)&vs, &c) == 0); if (name != NULL) { + boolean_t toplevel = (vs->vs_space != 0); + uint64_t cap; + if (scripted) (void) printf("\t%s", name); else if (strlen(name) + depth > cb->cb_namewidth) @@ -2938,24 +2954,26 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, (void) printf("%*s%s%*s", depth, "", name, (int)(cb->cb_namewidth - strlen(name) - depth), ""); - /* only toplevel vdevs have capacity stats */ - if (vs->vs_space == 0) { - if (scripted) - (void) printf("\t-\t-\t-\t-"); - else - (void) printf(" - - - -"); - } else { - print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, - scripted); - print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc, - scripted); - print_one_column(ZPOOL_PROP_FREE, - vs->vs_space - vs->vs_alloc, scripted); - print_one_column(ZPOOL_PROP_FRAGMENTATION, - vs->vs_fragmentation, scripted); - } - print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, - scripted); + /* + * Print the properties for the individual vdevs. Some + * properties are only applicable to toplevel vdevs. The + * 'toplevel' boolean value is passed to the print_one_column() + * to indicate that the value is valid. + */ + print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, scripted, + toplevel); + print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, scripted, + toplevel); + print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc, + scripted, toplevel); + print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted, + B_TRUE); + print_one_column(ZPOOL_PROP_FRAGMENTATION, + vs->vs_fragmentation, scripted, + (vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel)); + cap = (vs->vs_space == 0) ? 0 : + (vs->vs_alloc * 100 / vs->vs_space); + print_one_column(ZPOOL_PROP_CAPACITY, cap, scripted, toplevel); (void) printf("\n"); } @@ -3024,7 +3042,8 @@ list_callback(zpool_handle_t *zhp, void *data) * -H Scripted mode. Don't display headers, and separate properties * by a single tab. * -o List of properties to display. Defaults to - * "name,size,allocated,free,capacity,health,altroot" + * "name,size,allocated,free,expandsize,fragmentation,capacity," + * "dedupratio,health,altroot" * -p Diplay values in parsable (exact) format. * -T Display a timestamp in date(1) or Unix format * @@ -3038,7 +3057,7 @@ zpool_do_list(int argc, char **argv) int ret; list_cbdata_t cb = { 0 }; static char default_props[] = - "name,size,allocated,free,fragmentation,expandsize,capacity," + "name,size,allocated,free,expandsize,fragmentation,capacity," "dedupratio,health,altroot"; char *props = default_props; unsigned long interval = 0, count = 0; @@ -4524,7 +4543,8 @@ is_root_pool(zpool_handle_t *zhp) } static void -root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size) { +root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size) +{ if (poolname[0] == '\0' && is_root_pool(zhp)) (void) strlcpy(poolname, zpool_get_name(zhp), size); @@ -4623,7 +4643,7 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) #ifdef __FreeBSD__ root_pool_upgrade_check(zhp, cbp->cb_poolname, sizeof(cbp->cb_poolname)); -#endif /* ___FreeBSD__ */ +#endif /* __FreeBSD__ */ printnl = B_TRUE; #ifdef illumos @@ -4647,6 +4667,10 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) if (count > 0) { cbp->cb_first = B_FALSE; printnl = B_TRUE; +#ifdef __FreeBSD__ + root_pool_upgrade_check(zhp, cbp->cb_poolname, + sizeof(cbp->cb_poolname)); +#endif /* __FreeBSD__ */ /* * If they did "zpool upgrade -a", then we could * be doing ioctls to different pools. We need @@ -4788,7 +4812,7 @@ upgrade_one(zpool_handle_t *zhp, void *data) #ifdef __FreeBSD__ root_pool_upgrade_check(zhp, cbp->cb_poolname, sizeof(cbp->cb_poolname)); -#endif /* ___FreeBSD__ */ +#endif /* __FreeBSD__ */ } if (cbp->cb_version >= SPA_VERSION_FEATURES) { diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c index 374798b5e72d..e974b7519b02 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* @@ -652,6 +653,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) dontreport = 0; vdev_size = -1ULL; for (c = 0; c < children; c++) { + boolean_t is_replacing, is_spare; nvlist_t *cnv = child[c]; char *path; struct stat64 statbuf; @@ -668,16 +670,19 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) * If this is a replacing or spare vdev, then * get the real first child of the vdev. */ - if (strcmp(childtype, - VDEV_TYPE_REPLACING) == 0 || - strcmp(childtype, VDEV_TYPE_SPARE) == 0) { + is_replacing = strcmp(childtype, + VDEV_TYPE_REPLACING) == 0; + is_spare = strcmp(childtype, + VDEV_TYPE_SPARE) == 0; + if (is_replacing || is_spare) { nvlist_t **rchild; uint_t rchildren; verify(nvlist_lookup_nvlist_array(cnv, ZPOOL_CONFIG_CHILDREN, &rchild, &rchildren) == 0); - assert(rchildren == 2); + assert((is_replacing && rchildren == 2) + || (is_spare && rchildren >= 2)); cnv = rchild[0]; verify(nvlist_lookup_string(cnv, @@ -1068,8 +1073,8 @@ is_spare(nvlist_t *config, const char *path) * Go through and find any devices that are in use. We rely on libdiskmgt for * the majority of this task. */ -static int -check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, +static boolean_t +is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, boolean_t replacing, boolean_t isspare) { nvlist_t **child; @@ -1078,6 +1083,7 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, int ret; char buf[MAXPATHLEN]; uint64_t wholedisk; + boolean_t anyinuse = B_FALSE; verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0); @@ -1102,38 +1108,37 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, (void) strlcpy(buf, path, sizeof (buf)); if (is_spare(config, buf)) - return (0); + return (B_FALSE); } if (strcmp(type, VDEV_TYPE_DISK) == 0) ret = check_device(path, force, isspare); - - if (strcmp(type, VDEV_TYPE_FILE) == 0) + else if (strcmp(type, VDEV_TYPE_FILE) == 0) ret = check_file(path, force, isspare); - return (ret); + return (ret != 0); } for (c = 0; c < children; c++) - if ((ret = check_in_use(config, child[c], force, - replacing, B_FALSE)) != 0) - return (ret); + if (is_device_in_use(config, child[c], force, replacing, + B_FALSE)) + anyinuse = B_TRUE; if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES, &child, &children) == 0) for (c = 0; c < children; c++) - if ((ret = check_in_use(config, child[c], force, - replacing, B_TRUE)) != 0) - return (ret); + if (is_device_in_use(config, child[c], force, replacing, + B_TRUE)) + anyinuse = B_TRUE; if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE, &child, &children) == 0) for (c = 0; c < children; c++) - if ((ret = check_in_use(config, child[c], force, - replacing, B_FALSE)) != 0) - return (ret); + if (is_device_in_use(config, child[c], force, replacing, + B_FALSE)) + anyinuse = B_TRUE; - return (0); + return (anyinuse); } static const char * @@ -1487,7 +1492,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep, * uses (such as a dedicated dump device) that even '-f' cannot * override. */ - if (check_in_use(poolconfig, newroot, force, replacing, B_FALSE) != 0) { + if (is_device_in_use(poolconfig, newroot, force, replacing, B_FALSE)) { nvlist_free(newroot); return (NULL); } diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c index 0df44cfda938..58222670f4ff 100644 --- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c +++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c @@ -274,7 +274,7 @@ ctf_fdopen(int fd, int *errp) */ if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) && bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) { -#ifdef _BIG_ENDIAN +#if BYTE_ORDER == _BIG_ENDIAN uchar_t order = ELFDATA2MSB; #else uchar_t order = ELFDATA2LSB; diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c index bb02d8cf499a..ccd4f9b7fb8d 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c @@ -90,36 +90,6 @@ dprintf(int debug, const char *fmt, ...) va_end(ap); } -#if !defined(sun) -static void -fixsymbol(Elf *e, Elf_Data *data, size_t idx, int nprobes, char *buf, - dof_sec_t *sec, int *fixedprobes, char *dofstrtab) -{ - GElf_Sym sym; - char *s; - unsigned char *funcname; - dof_probe_t *prb; - int j = 0; - int ndx; - - while (gelf_getsym(data, j++, &sym) != NULL) { - prb = (dof_probe_t *)(void *)(buf + sec->dofs_offset); - - for (ndx = nprobes; ndx; ndx--, prb += 1) { - funcname = dofstrtab + prb->dofpr_func; - s = elf_strptr(e, idx, sym.st_name); - if (strcmp(s, funcname) == 0) { - dprintf(1, "fixing %s() symbol\n", s); - prb->dofpr_addr = sym.st_value; - (*fixedprobes)++; - } - } - if (*fixedprobes == nprobes) - break; - } -} -#endif - #if defined(sun) #pragma init(dtrace_dof_init) #else @@ -145,24 +115,18 @@ dtrace_dof_init(void) Lmid_t lmid; #else u_long lmid = 0; - dof_sec_t *sec, *secstart, *dofstrtab, *dofprobes; - dof_provider_t *dofprovider; - size_t i; #endif int fd; const char *p; #if !defined(sun) Elf *e; Elf_Scn *scn = NULL; - Elf_Data *symtabdata = NULL, *dynsymdata = NULL, *dofdata = NULL; + Elf_Data *dofdata = NULL; dof_hdr_t *dof_next = NULL; GElf_Shdr shdr; - int efd, nprobes; + int efd; char *s; - char *dofstrtabraw; - size_t shstridx, symtabidx = 0, dynsymidx = 0; - unsigned char *buf; - int fixedprobes; + size_t shstridx; #endif if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL) @@ -183,7 +147,6 @@ dtrace_dof_init(void) } #endif - if ((modname = strrchr(lmp->l_name, '/')) == NULL) modname = lmp->l_name; else @@ -203,15 +166,9 @@ dtrace_dof_init(void) dof = NULL; while ((scn = elf_nextscn(e, scn)) != NULL) { gelf_getshdr(scn, &shdr); - if (shdr.sh_type == SHT_SYMTAB) { - symtabidx = shdr.sh_link; - symtabdata = elf_getdata(scn, NULL); - } else if (shdr.sh_type == SHT_DYNSYM) { - dynsymidx = shdr.sh_link; - dynsymdata = elf_getdata(scn, NULL); - } else if (shdr.sh_type == SHT_PROGBITS) { + if (shdr.sh_type == SHT_SUNW_dof) { s = elf_strptr(e, shstridx, shdr.sh_name); - if (s && strcmp(s, ".SUNW_dof") == 0) { + if (s != NULL && strcmp(s, ".SUNW_dof") == 0) { dofdata = elf_getdata(scn, NULL); dof = dofdata->d_buf; } @@ -225,7 +182,6 @@ dtrace_dof_init(void) } while ((char *) dof < (char *) dofdata->d_buf + dofdata->d_size) { - fixedprobes = 0; dof_next = (void *) ((char *) dof + dof->dofh_filesz); #endif @@ -273,76 +229,6 @@ dtrace_dof_init(void) return; #endif } -#if !defined(sun) - /* - * We need to fix the base address of each probe since this wasn't - * done by ld(1). (ld(1) needs to grow support for parsing the - * SUNW_dof section). - * - * The complexity of this is not that great. The first for loop - * iterates over the sections inside the DOF file. There are usually - * 10 sections here. We asume the STRTAB section comes first and the - * PROBES section comes after. Since we are only interested in fixing - * data inside the PROBES section we quit the for loop after processing - * the PROBES section. It's usually the case that the first section - * is the STRTAB section and the second section is the PROBES section, - * so this for loop is not meaningful when doing complexity analysis. - * - * After finding the probes section, we iterate over the symbols - * in the symtab section. When we find a symbol name that matches - * the probe function name, we fix it. If we have fixed all the - * probes, we exit all the loops and we are done. - * The number of probes is given by the variable 'nprobes' and this - * depends entirely on the user, but some optimizations were done. - * - * We are assuming the number of probes is less than the number of - * symbols (libc can have 4k symbols, for example). - */ - secstart = sec = (dof_sec_t *)(dof + 1); - buf = (char *)dof; - for (i = 0; i < dof->dofh_secnum; i++, sec++) { - if (sec->dofs_type != DOF_SECT_PROVIDER) - continue; - - dofprovider = (void *) (buf + sec->dofs_offset); - dofstrtab = secstart + dofprovider->dofpv_strtab; - dofprobes = secstart + dofprovider->dofpv_probes; - - if (dofstrtab->dofs_type != DOF_SECT_STRTAB) { - fprintf(stderr, "WARNING: expected STRTAB section, but got %d\n", - dofstrtab->dofs_type); - break; - } - if (dofprobes->dofs_type != DOF_SECT_PROBES) { - fprintf(stderr, "WARNING: expected PROBES section, but got %d\n", - dofprobes->dofs_type); - break; - } - - dprintf(1, "found provider %p\n", dofprovider); - dofstrtabraw = (char *)(buf + dofstrtab->dofs_offset); - nprobes = dofprobes->dofs_size / dofprobes->dofs_entsize; - fixsymbol(e, symtabdata, symtabidx, nprobes, buf, dofprobes, &fixedprobes, - dofstrtabraw); - if (fixedprobes != nprobes) { - /* - * If we haven't fixed all the probes using the - * symtab section, look inside the dynsym - * section. - */ - fixsymbol(e, dynsymdata, dynsymidx, nprobes, buf, dofprobes, - &fixedprobes, dofstrtabraw); - } - if (fixedprobes != nprobes) { - fprintf(stderr, "WARNING: number of probes " - "fixed does not match the number of " - "defined probes (%d != %d, " - "respectively)\n", fixedprobes, nprobes); - fprintf(stderr, "WARNING: some probes might " - "not fire or your program might crash\n"); - } - } -#endif if ((gen = ioctl(fd, DTRACEHIOC_ADDDOF, &dh)) == -1) dprintf(1, "DTrace ioctl failed for DOF at %p", dof); else { diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 13300b086358..597fef47f982 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -322,7 +322,11 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) char *strtab; int i, j, nrel; size_t strtabsz = 1; +#if defined(sun) uint32_t count = 0; +#else + uint64_t count = 0; +#endif size_t base; Elf64_Sym *sym; Elf64_Rela *rel; @@ -418,7 +422,6 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) s = &dofs[dofrh->dofr_tgtsec]; for (j = 0; j < nrel; j++) { -#ifdef DOODAD #if defined(__arm__) /* XXX */ #elif defined(__mips__) @@ -431,8 +434,13 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) #elif defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; +#if defined(sun) rel->r_info = ELF64_R_INFO(count + dep->de_global, R_AMD64_64); +#else + rel->r_info = ELF64_R_INFO(count + dep->de_global, + R_X86_64_RELATIVE); +#endif #elif defined(__sparc) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; @@ -440,7 +448,6 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) R_SPARC_64); #else #error unknown ISA -#endif #endif sym->st_name = base + dofr[j].dofr_name - 1; @@ -704,7 +711,11 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) shp = &elf_file.shdr[ESHDR_DOF]; shp->sh_name = 11; /* DTRACE_SHSTRTAB64[11] = ".SUNW_dof" */ +#if defined(sun) shp->sh_flags = SHF_ALLOC; +#else + shp->sh_flags = SHF_WRITE | SHF_ALLOC; +#endif shp->sh_type = SHT_SUNW_dof; shp->sh_offset = off; shp->sh_size = dof->dofh_filesz; @@ -1662,19 +1673,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, { #if !defined(sun) char tfile[PATH_MAX]; - Elf *e; - Elf_Scn *scn; - Elf_Data *data; - GElf_Shdr shdr; - int efd; - size_t stridx; - unsigned char *buf; - char *s; - int loc; - GElf_Ehdr ehdr; - Elf_Scn *scn0; - GElf_Shdr shdr0; - uint64_t off, rc; #endif char drti[PATH_MAX]; dof_hdr_t *dof; @@ -1810,21 +1808,21 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, (void) unlink(file); #endif -#if defined(sun) if (dtp->dt_oflags & DTRACE_O_LP64) status = dump_elf64(dtp, dof, fd); else status = dump_elf32(dtp, dof, fd); +#if defined(sun) if (status != 0 || lseek(fd, 0, SEEK_SET) != 0) { return (dt_link_error(dtp, NULL, -1, NULL, "failed to write %s: %s", file, strerror(errno))); } #else - /* We don't write the ELF header, just the DOF section */ - if (dt_write(dtp, fd, dof, dof->dofh_filesz) < dof->dofh_filesz) + if (status != 0) return (dt_link_error(dtp, NULL, -1, NULL, - "failed to write %s: %s", tfile, strerror(errno))); + "failed to write %s: %s", tfile, + strerror(dtrace_errno(dtp)))); #endif if (!dtp->dt_lazyload) { @@ -1846,7 +1844,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti); #else - const char *fmt = "%s -o %s -r %s"; + const char *fmt = "%s -o %s -r %s %s"; #if defined(__amd64__) /* @@ -1868,10 +1866,9 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile, drti) + 1; - len *= 2; cmd = alloca(len); - (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, + (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, tfile, drti); #endif if ((status = system(cmd)) == -1) { @@ -1894,85 +1891,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, file, dtp->dt_ld_path, WEXITSTATUS(status)); goto done; } -#if !defined(sun) - /* - * FreeBSD's ld(1) is not instructed to interpret and add - * correctly the SUNW_dof section present in tfile. - * We use libelf to add this section manually and hope the next - * ld invocation won't remove it. - */ - elf_version(EV_CURRENT); - if ((efd = open(file, O_RDWR, 0)) < 0) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to open file %s: %s", - file, strerror(errno)); - goto done; - } - if ((e = elf_begin(efd, ELF_C_RDWR, NULL)) == NULL) { - close(efd); - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to open elf file: %s", - elf_errmsg(elf_errno())); - goto done; - } - /* - * Add the string '.SUWN_dof' to the shstrtab section. - */ - elf_getshdrstrndx(e, &stridx); - scn = elf_getscn(e, stridx); - gelf_getshdr(scn, &shdr); - data = elf_newdata(scn); - data->d_off = shdr.sh_size; - data->d_buf = ".SUNW_dof"; - data->d_size = 10; - data->d_type = ELF_T_BYTE; - loc = shdr.sh_size; - shdr.sh_size += data->d_size; - gelf_update_shdr(scn, &shdr); - /* - * Construct the .SUNW_dof section. - */ - scn = elf_newscn(e); - data = elf_newdata(scn); - buf = mmap(NULL, dof->dofh_filesz, PROT_READ, MAP_SHARED, - fd, 0); - if (buf == MAP_FAILED) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to mmap buffer %s", strerror(errno)); - elf_end(e); - close(efd); - goto done; - } - data->d_buf = buf; - data->d_align = 4; - data->d_size = dof->dofh_filesz; - data->d_version = EV_CURRENT; - gelf_getshdr(scn, &shdr); - shdr.sh_name = loc; - shdr.sh_flags = SHF_ALLOC; - /* - * Actually this should be SHT_SUNW_dof, but FreeBSD's ld(1) - * will remove this 'unknown' section when we try to create an - * executable using the object we are modifying, so we stop - * playing by the rules and use SHT_PROGBITS. - * Also, note that our drti has modifications to handle this. - */ - shdr.sh_type = SHT_PROGBITS; - shdr.sh_addralign = 4; - gelf_update_shdr(scn, &shdr); - if (elf_update(e, ELF_C_WRITE) < 0) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to add the SUNW_dof section: %s", - elf_errmsg(elf_errno())); - munmap(buf, dof->dofh_filesz); - elf_end(e); - close(efd); - goto done; - } - munmap(buf, dof->dofh_filesz); - elf_end(e); - close(efd); -#endif (void) close(fd); /* release temporary file */ } else { (void) close(fd); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c index c865a2df7702..6c529e5e6033 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c @@ -434,15 +434,10 @@ static const prmap_t * dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P) { char m[MAXPATHLEN]; -#if defined(sun) Lmid_t lmid = PR_LMID_EVERY; -#else - Lmid_t lmid = 0; -#endif const char *obj; const prmap_t *pmp; -#if defined(sun) /* * Pick apart the link map from the library name. */ @@ -463,20 +458,17 @@ dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P) } else { obj = pdp->dtpd_mod; } -#else - obj = pdp->dtpd_mod; -#endif if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL) return (NULL); -#if defined(sun) (void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m)); if ((obj = strrchr(m, '/')) == NULL) obj = &m[0]; else obj++; +#if defined(sun) (void) Plmid(P, pmp->pr_vaddr, &lmid); #endif @@ -571,9 +563,7 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) { struct ps_prochandle *P = data; GElf_Sym sym; -#if defined(sun) prsyminfo_t sip; -#endif dof_helper_t dh; GElf_Half e_type; const char *mname; @@ -852,11 +842,7 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, ctf_funcinfo_t f; ctf_id_t argv[32]; GElf_Sym sym; -#if defined(sun) prsyminfo_t si; -#else - void *si; -#endif struct ps_prochandle *p; int i, args; char buf[DTRACE_ARGTYPELEN]; @@ -941,13 +927,11 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, pdp->dtpd_func, pdp->dtpd_provider, pdp->dtpd_mod); goto out; } -#if defined(sun) if (ctf_func_info(fp, si.prs_id, &f) == CTF_ERR) { dt_dprintf("failed to get ctf information for %s in %s`%s\n", pdp->dtpd_func, pdp->dtpd_provider, pdp->dtpd_mod); goto out; } -#endif (void) snprintf(buf, sizeof (buf), "%s`%s", pdp->dtpd_provider, pdp->dtpd_mod); @@ -977,7 +961,6 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, (void) ctf_type_qname(fp, f.ctc_return, adp->dtargd_native + ret, DTRACE_ARGTYPELEN - ret, buf); *nargs = 2; -#if defined(sun) } else { if (ctf_func_args(fp, si.prs_id, argc, argv) == CTF_ERR) goto out; @@ -993,7 +976,6 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, (void) ctf_type_qname(fp, argv[i], adp->dtargd_native + ret, DTRACE_ARGTYPELEN - ret, buf); } -#endif } out: dt_proc_unlock(dtp, p); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c index fb8ea16289ef..4be0f03d4a43 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c @@ -167,7 +167,7 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep) * to the lowest 'size' bytes in 'value', and we need to shift based on * the offset from the end of the data, not the offset of the start. */ -#ifdef _BIG_ENDIAN +#if BYTE_ORDER == _BIG_ENDIAN buf += sizeof (value) - size; off += ep->cte_bits; #endif @@ -178,7 +178,7 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep) * Offsets are counted from opposite ends on little- and * big-endian machines. */ -#ifdef _BIG_ENDIAN +#if BYTE_ORDER == _BIG_ENDIAN shift = NBBY - shift; #endif diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c index d7126bf77bbe..265038ab1bf9 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c @@ -1457,6 +1457,12 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err, (void) zfs_error(hdl, EZFS_DSREADONLY, errbuf); break; + case E2BIG: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "property value too long")); + (void) zfs_error(hdl, EZFS_BADPROP, errbuf); + break; + case ENOTSUP: zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool and or dataset must be upgraded to set this " diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c index 868961d96d66..49a43855d5fe 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ @@ -1426,21 +1426,15 @@ zpool_find_import_cached(libzfs_handle_t *hdl, const char *cachefile, elem = NULL; while ((elem = nvlist_next_nvpair(raw, elem)) != NULL) { - verify(nvpair_value_nvlist(elem, &src) == 0); + src = fnvpair_value_nvlist(elem); - verify(nvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME, - &name) == 0); + name = fnvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME); if (poolname != NULL && strcmp(poolname, name) != 0) continue; - verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID, - &this_guid) == 0); - if (guid != 0) { - verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID, - &this_guid) == 0); - if (guid != this_guid) - continue; - } + this_guid = fnvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID); + if (guid != 0 && guid != this_guid) + continue; if (pool_active(hdl, name, this_guid, &active) != 0) { nvlist_free(raw); diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index 30b2d87ce66d..e09417aa2dfb 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ @@ -304,7 +304,6 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, case ZPOOL_PROP_FREE: case ZPOOL_PROP_FREEING: case ZPOOL_PROP_LEAKED: - case ZPOOL_PROP_EXPANDSZ: if (literal) { (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); @@ -312,7 +311,16 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, (void) zfs_nicenum(intval, buf, len); } break; - + case ZPOOL_PROP_EXPANDSZ: + if (intval == 0) { + (void) strlcpy(buf, "-", len); + } else if (literal) { + (void) snprintf(buf, len, "%llu", + (u_longlong_t)intval); + } else { + (void) zfs_nicenum(intval, buf, len); + } + break; case ZPOOL_PROP_CAPACITY: if (literal) { (void) snprintf(buf, len, "%llu", @@ -330,13 +338,11 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, (u_longlong_t)intval); } break; - case ZPOOL_PROP_DEDUPRATIO: (void) snprintf(buf, len, "%llu.%02llux", (u_longlong_t)(intval / 100), (u_longlong_t)(intval % 100)); break; - case ZPOOL_PROP_HEALTH: verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c index 1a2c2ac0fd98..ef386968e858 100644 --- a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c +++ b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c @@ -650,6 +650,9 @@ dprintf_setup(int *argc, char **argv) */ if (dprintf_find_string("on")) dprintf_print_all = 1; + + if (dprintf_string != NULL) + zfs_flags |= ZFS_DEBUG_DPRINTF; } int diff --git a/cddl/lib/libdtrace/libproc_compat.h b/cddl/lib/libdtrace/libproc_compat.h index 84433362d0c5..0d99d967553a 100644 --- a/cddl/lib/libdtrace/libproc_compat.h +++ b/cddl/lib/libdtrace/libproc_compat.h @@ -38,7 +38,7 @@ #define Pxlookup_by_addr(p, a, n, s, sym, i) \ proc_addr2sym(p, a, n, s, sym) #define Pxlookup_by_name(p, l, s1, s2, sym, a) \ - proc_name2sym((p), (s1), (s2), (sym)) + proc_name2sym(p, s1, s2, sym, a) #define Paddr_to_map proc_addr2map #define Pcreate_error strerror #define Pdelbkpt proc_bkptdel @@ -46,10 +46,10 @@ #define Plmid(p, a, l) (-1) #define Plmid_to_map(p, l, o) proc_obj2map((p), (o)) #define Plookup_by_addr proc_addr2sym -#define Pname_to_ctf(p, obj) NULL +#define Pname_to_ctf(p, obj) (ctf_file_t *)proc_name2ctf(p, obj) #define Pname_to_map proc_name2map #define Pobject_iter proc_iter_objs -#define Pobject_iter_resolved(p, f, arg) 1 +#define Pobject_iter_resolved(p, f, arg) proc_iter_objs(p, f, arg) #define Pobjname proc_objname #define Pread proc_read #define Prd_agent proc_rdagent diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile index 4010ac177a5e..b2f4352bf915 100644 --- a/cddl/lib/libzfs/Makefile +++ b/cddl/lib/libzfs/Makefile @@ -7,8 +7,11 @@ LIB= zfs DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \ - ${LIBAVL} ${LIBZFS_CORE} -LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -lavl -lzfs_core + ${LIBAVL} ${LIBZFS_CORE} ${LIBUUTIL} ${LIBBSDXML} ${LIBGEOM} \ + ${LIBNVPAIR} + +LDADD= -lmd -lpthread -lumem -lutil -luutil -lm -lnvpair -lavl \ + -lbsdxml -lgeom -lnvpair -lzfs_core SRCS= deviceid.c \ fsshare.c \ diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index 8f60a20a23a7..b80af0448a59 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -56,8 +56,9 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include -DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} -LDADD= -lmd -lpthread -lz +DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} ${LIBNVPAIR} \ + ${LIBAVL} ${LIBUMEM} +LDADD= -lmd -lpthread -lz -lnvpair -lavl -lumem # atomic.S doesn't like profiling. MK_PROFILE= no diff --git a/cddl/usr.sbin/Makefile b/cddl/usr.sbin/Makefile index 537b8e52792f..0d34afd025bb 100644 --- a/cddl/usr.sbin/Makefile +++ b/cddl/usr.sbin/Makefile @@ -5,6 +5,7 @@ SUBDIR= ${_dtrace} \ ${_dtruss} \ ${_lockstat} \ + ${_plockstat} \ ${_tests} \ ${_zdb} \ ${_zhack} @@ -24,6 +25,9 @@ _zhack= zhack _dtrace= dtrace _dtruss= dtruss _lockstat= lockstat +.if defined(WITH_PLOCKSTAT) +_plockstat= plockstat +.endif .endif .if ${MACHINE_CPUARCH} == "mips" diff --git a/contrib/apr-util/CHANGES b/contrib/apr-util/CHANGES index 7626c50b52b1..a0dc3789a89d 100644 --- a/contrib/apr-util/CHANGES +++ b/contrib/apr-util/CHANGES @@ -1,4 +1,30 @@ -*- coding: utf-8 -*- +Changes with APR-util 1.5.4 + + *) MySQL driver: Fix incorrect handling of bad parameter in the + driver support for apr_dbd_transaction_end(). PR 56330. + [Weiqiang Li ] + + *) apr_crypto_get_driver(): Fix invalid storage reference on error path. + [Philip Martin ] + + *) Fix compile failure for Android. PR 56627. [Fredrik Fornwall + , Jeff Trawick] + + *) Fix to let ODBC driver build with MSVC6, which does not have intptr_t + [Tom Donovan] + + *) Windows cmake build: Fix incompatiblities with Visual Studio + generators with all cmake versions, and the NMake Makefile generator + with cmake 2.8.12 and later. PR 56616 and other bugs. [Jeff Trawick, + Bert Huijben] + + *) Fix detection of Berkeley DB 6.0. PR 55277. + [Lars Wendler ] + + *) Improve platform detection for bundled expat by updating + config.guess and config.sub. [Rainer Jung] + Changes with APR-util 1.5.3 *) Cygwin: Use correct file extension when loading APR DSOs. PR 55587. diff --git a/contrib/apr-util/NOTICE b/contrib/apr-util/NOTICE index aaf9cd046c8e..a107139ef37e 100644 --- a/contrib/apr-util/NOTICE +++ b/contrib/apr-util/NOTICE @@ -1,7 +1,7 @@ Apache Portable Runtime Utility Library -Copyright (c) 2011 The Apache Software Foundation. +Copyright (c) 2000-2014 The Apache Software Foundation. -This product includes software developed by +This product includes software developed at The Apache Software Foundation (http://www.apache.org/). Portions of this software were developed at the National Center diff --git a/contrib/apr-util/apr-util.spec b/contrib/apr-util/apr-util.spec index d08400dff4f8..e9dc24b08da7 100644 --- a/contrib/apr-util/apr-util.spec +++ b/contrib/apr-util/apr-util.spec @@ -3,7 +3,7 @@ Summary: Apache Portable Runtime Utility library Name: apr-util -Version: 1.5.3 +Version: 1.5.4 Release: 1 License: Apache Software License Group: System Environment/Libraries diff --git a/contrib/apr-util/configure b/contrib/apr-util/configure index ccfc3e603675..8ddd0e88f058 100755 --- a/contrib/apr-util/configure +++ b/contrib/apr-util/configure @@ -11608,19 +11608,34 @@ fi apu_db_version=0 # Maximum supported version announced in help string. - # Although we search for all versions up to 5.9, + # Although we search for all versions up to 6.9, # we should only include existing versions in our # help string. - db_max_version=53 - db_min_version=41 dbm_list="sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4" + db_max_version=48 + db_min_version=41 + db_version="$db_min_version" + while [ $db_version -le $db_max_version ] + do + dbm_list="$dbm_list, db$db_version" + db_version=`expr $db_version + 1` + done + db_max_version=53 + db_min_version=50 + db_version="$db_min_version" + while [ $db_version -le $db_max_version ] + do + dbm_list="$dbm_list, db$db_version" + db_version=`expr $db_version + 1` + done + db_max_version=60 + db_min_version=60 db_version="$db_min_version" while [ $db_version -le $db_max_version ] do dbm_list="$dbm_list, db$db_version" db_version=`expr $db_version + 1` done - dbm_list="$dbm_list, db60" # Check whether --with-dbm was given. @@ -12093,8 +12108,8 @@ if test "${with_berkeley_db+set}" = set; then : all_places="$check_places" - # Start version search at version 5.9 - db_version=59 + # Start version search at version 6.9 + db_version=69 while [ $db_version -ge 40 ] do db_major=`echo $db_version | sed -e 's/.$//'` @@ -12178,7 +12193,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then + if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -12580,7 +12595,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "3" = "3" -o "3" = "4" -o "3" = "5"; then + if test "3" = "3" -o "3" = "4" -o "3" = "5" -o "3" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -12978,7 +12993,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "2" = "3" -o "2" = "4" -o "2" = "5"; then + if test "2" = "3" -o "2" = "4" -o "2" = "5" -o "2" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -13376,7 +13391,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "1" = "3" -o "1" = "4" -o "1" = "5"; then + if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -13774,7 +13789,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "1" = "3" -o "1" = "4" -o "1" = "5"; then + if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -14186,7 +14201,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "1" = "3" -o "1" = "4" -o "1" = "5"; then + if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -14587,7 +14602,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "1" = "3" -o "1" = "4" -o "1" = "5"; then + if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -14988,7 +15003,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "2" = "3" -o "2" = "4" -o "2" = "5"; then + if test "2" = "3" -o "2" = "4" -o "2" = "5" -o "2" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -15389,7 +15404,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "3" = "3" -o "3" = "4" -o "3" = "5"; then + if test "3" = "3" -o "3" = "4" -o "3" = "5" -o "3" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -15794,7 +15809,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then + if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -16202,7 +16217,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then + if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -16534,8 +16549,8 @@ fi all_places="$check_places" - # Start version search at version 5.9 - db_version=59 + # Start version search at version 6.9 + db_version=69 while [ $db_version -ge 40 ] do db_major=`echo $db_version | sed -e 's/.$//'` @@ -16619,7 +16634,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then + if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -17021,7 +17036,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "3" = "3" -o "3" = "4" -o "3" = "5"; then + if test "3" = "3" -o "3" = "4" -o "3" = "5" -o "3" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -17419,7 +17434,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "2" = "3" -o "2" = "4" -o "2" = "5"; then + if test "2" = "3" -o "2" = "4" -o "2" = "5" -o "2" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -17817,7 +17832,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "1" = "3" -o "1" = "4" -o "1" = "5"; then + if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of @@ -18215,7 +18230,7 @@ $as_echo "" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - if test "1" = "3" -o "1" = "4" -o "1" = "5"; then + if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then # We generate a separate cache variable for each prefix and libname # we search under. That way, we avoid caching information that # changes if the user runs `configure' with a different set of diff --git a/contrib/apr-util/crypto/apr_crypto.c b/contrib/apr-util/crypto/apr_crypto.c index 35ce3752a9b7..fe66582d124f 100644 --- a/contrib/apr-util/crypto/apr_crypto.c +++ b/contrib/apr-util/crypto/apr_crypto.c @@ -204,7 +204,7 @@ APU_DECLARE(apr_status_t) apr_crypto_get_driver( if (err && buffer) { apr_dso_error(dso, buffer, ERROR_SIZE - 1); err->msg = buffer; - err->reason = modname; + err->reason = apr_pstrdup(pool, modname); *result = err; } } diff --git a/contrib/apr-util/crypto/apr_passwd.c b/contrib/apr-util/crypto/apr_passwd.c index 1b4b47bdf314..c961de2b9349 100644 --- a/contrib/apr-util/crypto/apr_passwd.c +++ b/contrib/apr-util/crypto/apr_passwd.c @@ -66,6 +66,12 @@ static void crypt_mutex_unlock(void) #endif #endif +#if defined(WIN32) || defined(BEOS) || defined(NETWARE) || defined(__ANDROID__) +#define CRYPT_MISSING 1 +#else +#define CRYPT_MISSING 0 +#endif + /* * Validate a plaintext password against a smashed one. Uses either * crypt() (if available) or apr_md5_encode() or apr_sha1_base64(), depending @@ -77,7 +83,7 @@ APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd, const char *hash) { char sample[200]; -#if !defined(WIN32) && !defined(BEOS) && !defined(NETWARE) +#if !CRYPT_MISSING char *crypt_pw; #endif if (hash[0] == '$' @@ -100,7 +106,7 @@ APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd, /* * It's not our algorithm, so feed it to crypt() if possible. */ -#if defined(WIN32) || defined(BEOS) || defined(NETWARE) +#if CRYPT_MISSING return (strcmp(passwd, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH; #elif defined(CRYPT_R_CRYPTD) apr_status_t rv; diff --git a/contrib/apr-util/dbd/apr_dbd_mysql.c b/contrib/apr-util/dbd/apr_dbd_mysql.c index 1141c6fd9772..3b8017d85249 100644 --- a/contrib/apr-util/dbd/apr_dbd_mysql.c +++ b/contrib/apr-util/dbd/apr_dbd_mysql.c @@ -1050,9 +1050,9 @@ static int dbd_mysql_end_transaction(apr_dbd_transaction_t *trans) else { ret = mysql_commit(trans->handle->conn); } + ret |= mysql_autocommit(trans->handle->conn, 1); + trans->handle->trans = NULL; } - ret |= mysql_autocommit(trans->handle->conn, 1); - trans->handle->trans = NULL; return ret; } /* Whether or not transactions work depends on whether the diff --git a/contrib/apr-util/dbd/apr_dbd_odbc.c b/contrib/apr-util/dbd/apr_dbd_odbc.c index 6ee8a7d570f0..8a3c0fdce9b1 100644 --- a/contrib/apr-util/dbd/apr_dbd_odbc.c +++ b/contrib/apr-util/dbd/apr_dbd_odbc.c @@ -47,6 +47,21 @@ #include #endif +/* +* MSVC6 does not support intptr_t (C99) +* APR does not have a signed inptr type until 2.0 (r1557720) +*/ +#if defined(_MSC_VER) && _MSC_VER < 1400 +#if APR_SIZEOF_VOIDP == 8 +#define ODBC_INTPTR_T apr_int64_t +#else +#define ODBC_INTPTR_T apr_int32_t +#endif +#else +#define ODBC_INTPTR_T intptr_t +#endif + + /* Driver name is "odbc" and the entry point is 'apr_dbd_odbc_driver' * unless ODBC_DRIVER_NAME is defined and it is linked with another db library which * is ODBC source-compatible. e.g. DB2, Informix, TimesTen, mysql. @@ -114,9 +129,9 @@ struct apr_dbd_t char lastError[MAX_ERROR_STRING]; int defaultBufferSize; /* used for CLOBs in text mode, * and when fld size is indeterminate */ - intptr_t transaction_mode; - intptr_t dboptions; /* driver options re SQLGetData */ - intptr_t default_transaction_mode; + ODBC_INTPTR_T transaction_mode; + ODBC_INTPTR_T dboptions; /* driver options re SQLGetData */ + ODBC_INTPTR_T default_transaction_mode; int can_commit; /* controls end_trans behavior */ }; @@ -359,7 +374,7 @@ static SQLRETURN odbc_set_result_column(int icol, apr_dbd_results_t *res, SQLHANDLE stmt) { SQLRETURN rc; - intptr_t maxsize, textsize, realsize, type, isunsigned = 1; + ODBC_INTPTR_T maxsize, textsize, realsize, type, isunsigned = 1; /* discover the sql type */ rc = SQLColAttribute(stmt, icol + 1, SQL_DESC_UNSIGNED, NULL, 0, NULL, @@ -747,7 +762,7 @@ static void *odbc_get(const apr_dbd_row_t *row, const int col, SQLRETURN rc; SQLLEN indicator; int state = row->res->colstate[col]; - intptr_t options = row->res->apr_dbd->dboptions; + ODBC_INTPTR_T options = row->res->apr_dbd->dboptions; switch (state) { case (COL_UNAVAIL): @@ -817,13 +832,13 @@ static apr_status_t odbc_parse_params(apr_pool_t *pool, const char *params, int *connect, SQLCHAR **datasource, SQLCHAR **user, SQLCHAR **password, int *defaultBufferSize, int *nattrs, - int **attrs, intptr_t **attrvals) + int **attrs, ODBC_INTPTR_T **attrvals) { char *seps, *last, *next, *name[MAX_PARAMS], *val[MAX_PARAMS]; int nparams = 0, i, j; *attrs = apr_pcalloc(pool, MAX_PARAMS * sizeof(char *)); - *attrvals = apr_pcalloc(pool, MAX_PARAMS * sizeof(intptr_t)); + *attrvals = apr_pcalloc(pool, MAX_PARAMS * sizeof(ODBC_INTPTR_T)); *nattrs = 0; seps = DEFAULTSEPS; name[nparams] = apr_strtok(apr_pstrdup(pool, params), seps, &last); @@ -1063,7 +1078,7 @@ static apr_dbd_t *odbc_open(apr_pool_t *pool, const char *params, const char **e SQLCHAR *datasource = (SQLCHAR *)"", *user = (SQLCHAR *)"", *password = (SQLCHAR *)""; int nattrs = 0, *attrs = NULL, connect = 0; - intptr_t *attrvals = NULL; + ODBC_INTPTR_T *attrvals = NULL; err_step = "SQLAllocHandle (SQL_HANDLE_DBC)"; err_htype = SQL_HANDLE_ENV; @@ -1117,10 +1132,10 @@ static apr_dbd_t *odbc_open(apr_pool_t *pool, const char *params, const char **e handle->default_transaction_mode = 0; handle->can_commit = APR_DBD_TRANSACTION_IGNORE_ERRORS; SQLGetInfo(hdbc, SQL_DEFAULT_TXN_ISOLATION, - &(handle->default_transaction_mode), sizeof(intptr_t), NULL); + &(handle->default_transaction_mode), sizeof(ODBC_INTPTR_T), NULL); handle->transaction_mode = handle->default_transaction_mode; SQLGetInfo(hdbc, SQL_GETDATA_EXTENSIONS ,&(handle->dboptions), - sizeof(intptr_t), NULL); + sizeof(ODBC_INTPTR_T), NULL); apr_pool_cleanup_register(pool, handle, odbc_close_cleanup, apr_pool_cleanup_null); return handle; } diff --git a/contrib/apr-util/dbm/NWGNUmakefile b/contrib/apr-util/dbm/NWGNUmakefile index 9307b8450095..7e610fec270a 100644 --- a/contrib/apr-util/dbm/NWGNUmakefile +++ b/contrib/apr-util/dbm/NWGNUmakefile @@ -235,7 +235,7 @@ nlms :: libs $(TARGET_nlm) # correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples) # install :: nlms $(INSTDIRS) FORCE - copy $(OBJDIR)\*.nlm $(INSTALLBASE) + $(call COPY,$(OBJDIR)/*.nlm,$(INSTALLBASE)) # # Any specialized rules here diff --git a/contrib/apr-util/include/apu_version.h b/contrib/apr-util/include/apu_version.h index a7a587876244..8d976291ff6d 100644 --- a/contrib/apr-util/include/apu_version.h +++ b/contrib/apr-util/include/apu_version.h @@ -38,7 +38,7 @@ */ -#define APU_COPYRIGHT "Copyright (c) 2013 The Apache Software " \ +#define APU_COPYRIGHT "Copyright (c) 2000-2014 The Apache Software " \ "Foundation or its licensors, as applicable." /* The numeric compile-time version constants. These constants are the @@ -62,7 +62,7 @@ * The Patch Level never includes API changes, simply bug fixes. * Reset to 0 when upgrading APR_MINOR_VERSION */ -#define APU_PATCH_VERSION 3 +#define APU_PATCH_VERSION 4 /** * The symbol APU_IS_DEV_VERSION is only defined for internal, diff --git a/contrib/apr-util/test/Makefile.win b/contrib/apr-util/test/Makefile.win index 030585009c56..a30f39e2b520 100644 --- a/contrib/apr-util/test/Makefile.win +++ b/contrib/apr-util/test/Makefile.win @@ -88,6 +88,8 @@ APROUTDIR=$(OUTDIR) !IF "$(MODEL)" == "static" PROGRAM_DEPENDENCIES = \ $(APR_PATH)\$(APROUTDIR)\apr-1.lib \ + $(API_PATH)\$(OUTDIR)\apriconv-1.lib \ + ..\xml\expat\lib\$(OUTDIR)\xml.lib \ ..\$(OUTDIR)\aprutil-1.lib STATIC_CFLAGS = /D APR_DECLARE_STATIC /D APU_DECLARE_STATIC STATIC_LIBS = odbc32.lib odbccp32.lib wldap32.lib diff --git a/contrib/atf/FREEBSD-upgrade b/contrib/atf/FREEBSD-upgrade index 1b1970f2e9c7..e9d7a4cb7b4f 100644 --- a/contrib/atf/FREEBSD-upgrade +++ b/contrib/atf/FREEBSD-upgrade @@ -7,10 +7,9 @@ branches and you are supposed to follow those: http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html -The ATF source code is hosted on Google Code as a subcomponent of the -Kyua project: +The ATF source code is hosted on GitHub: - http://code.google.com/p/kyua/downloads/list + https://github.com/jmmv/atf and is imported into the atf vendor branch (see base/vendor/atf/). @@ -42,7 +41,7 @@ the vendor branch as you easily risk committing build products into the tree. Lastly, with the list of old and new files in this import, make sure -to udpate the reachover Makefiles accordingly. +to update the reachover Makefiles accordingly. Test the build (keeping in mind the WITH_TESTS/WITHOUT_TESTS knobs) and, if all looks good, you are ready to commit all the changes in one go. diff --git a/contrib/atf/NEWS b/contrib/atf/NEWS index 709f5941c105..7a7ed2fb9d02 100644 --- a/contrib/atf/NEWS +++ b/contrib/atf/NEWS @@ -14,6 +14,9 @@ the 'tools' directory for your own consumption. * Removed the deprecated tools. This includes atf-config, atf-report, atf-run and atf-version. +* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang + that ships with FreeBSD 11.0-CURRENT. + Changes in version 0.19 *********************** diff --git a/contrib/atf/atf-c++/atf-c++-api.3 b/contrib/atf/atf-c++/atf-c++-api.3 index c086c9096718..da1441ed205a 100644 --- a/contrib/atf/atf-c++/atf-c++-api.3 +++ b/contrib/atf/atf-c++/atf-c++-api.3 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd November 15, 2013 +.Dd March 2, 2014 .Dt ATF-C++-API 3 .Os .Sh NAME @@ -330,9 +330,8 @@ If .Va exitcode is not .Sq -1 , -.Xr atf-run 1 -will validate that the exit code of the test case matches the one provided -in this call. +the runtime engine will validate that the exit code of the test case +matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn expect_fail "reason" Any failure (be it fatal or non-fatal) raised in this mode is recorded. @@ -368,9 +367,8 @@ If .Va signo is not .Sq -1 , -.Xr atf-run 1 -will validate that the signal that terminated the test case matches the one -provided in this call. +the runtime engine will validate that the signal that terminated the test +case matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn expect_timeout "reason" Expects the test case to execute for longer than its timeout. @@ -631,5 +629,4 @@ ATF_INIT_TEST_CASES(tcs) .Ed .Sh SEE ALSO .Xr atf-test-program 1 , -.Xr atf-test-case 4 , -.Xr atf 7 +.Xr atf-test-case 4 diff --git a/contrib/atf/atf-c/atf-c-api.3 b/contrib/atf/atf-c/atf-c-api.3 index 366caec79c8f..b3b308655739 100644 --- a/contrib/atf/atf-c/atf-c-api.3 +++ b/contrib/atf/atf-c/atf-c-api.3 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd November 15, 2013 +.Dd March 2, 2014 .Dt ATF-C-API 3 .Os .Sh NAME @@ -409,9 +409,8 @@ If .Va exitcode is not .Sq -1 , -.Xr atf-run 1 -will validate that the exit code of the test case matches the one provided -in this call. +the runtime engine will validate that the exit code of the test case +matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn atf_tc_expect_fail "reason" "..." Any failure (be it fatal or non-fatal) raised in this mode is recorded. @@ -443,9 +442,8 @@ If .Va signo is not .Sq -1 , -.Xr atf-run 1 -will validate that the signal that terminated the test case matches the one -provided in this call. +the runtime engine will validate that the signal that terminated the test +case matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn atf_tc_expect_timeout "reason" "..." Expects the test case to execute for longer than its timeout. @@ -771,5 +769,4 @@ ATF_TP_ADD_TCS(tp) .Ed .Sh SEE ALSO .Xr atf-test-program 1 , -.Xr atf-test-case 4 , -.Xr atf 7 +.Xr atf-test-case 4 diff --git a/contrib/atf/atf-c/macros_h_test.c b/contrib/atf/atf-c/macros_h_test.c index 3dae471e4dd7..64c6786e477f 100644 --- a/contrib/atf/atf-c/macros_h_test.c +++ b/contrib/atf/atf-c/macros_h_test.c @@ -87,6 +87,7 @@ ATF_TC(TEST_MACRO_1); ATF_TC_HEAD(TEST_MACRO_1, tc) { if (tc != NULL) {} } ATF_TC_BODY(TEST_MACRO_1, tc) { if (tc != NULL) {} } atf_tc_t *test_name_1 = &ATF_TC_NAME(TEST_MACRO_1); +atf_tc_pack_t *test_pack_1 = &ATF_TC_PACK_NAME(TEST_MACRO_1); void (*head_1)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_1); void (*body_1)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_1); ATF_TC_WITH_CLEANUP(TEST_MACRO_2); @@ -94,10 +95,12 @@ ATF_TC_HEAD(TEST_MACRO_2, tc) { if (tc != NULL) {} } ATF_TC_BODY(TEST_MACRO_2, tc) { if (tc != NULL) {} } ATF_TC_CLEANUP(TEST_MACRO_2, tc) { if (tc != NULL) {} } atf_tc_t *test_name_2 = &ATF_TC_NAME(TEST_MACRO_2); +atf_tc_pack_t *test_pack_2 = &ATF_TC_PACK_NAME(TEST_MACRO_2); void (*head_2)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_2); void (*body_2)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_2); void (*cleanup_2)(const atf_tc_t *) = ATF_TC_CLEANUP_NAME(TEST_MACRO_2); ATF_TC_WITHOUT_HEAD(TEST_MACRO_3); ATF_TC_BODY(TEST_MACRO_3, tc) { if (tc != NULL) {} } atf_tc_t *test_name_3 = &ATF_TC_NAME(TEST_MACRO_3); +atf_tc_pack_t *test_pack_3 = &ATF_TC_PACK_NAME(TEST_MACRO_3); void (*body_3)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_3); diff --git a/contrib/atf/atf-sh/atf-check.1 b/contrib/atf/atf-sh/atf-check.1 index 06904bc3ffd3..66f931892501 100644 --- a/contrib/atf/atf-sh/atf-check.1 +++ b/contrib/atf/atf-sh/atf-check.1 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd June 27, 2010 +.Dd March 2, 2014 .Dt ATF-CHECK 1 .Os .Sh NAME @@ -118,15 +118,20 @@ Analyzes standard error (syntax identical to above) Executes .Ar command as a shell command line, executing it with the system shell defined by -.Va ATF_SHELL -in -.Xr atf-config 1 . +.Va ATF_SHELL . You should avoid using this flag if at all possible to prevent shell quoting issues. .El .Sh EXIT STATUS .Nm exits 0 on success, and other (unspecified) value on failure. +.Sh ENVIRONMENT +.Bl -tag -width ATFXSHELLXX -compact +.It Va ATF_SHELL +Path to the system shell to be used when the +.Fl x +is given to run commands. +.El .Sh EXAMPLES .Bd -literal -offset indent # Exit code 0, nothing on stdout/stderr @@ -146,6 +151,3 @@ atf-check -s signal:sigsegv my_program # Combined checks atf-check -o match:foo -o not-match:bar echo foo baz .Ed -.Sh SEE ALSO -.Xr atf-config 1 , -.Xr atf 7 diff --git a/contrib/atf/atf-sh/atf-sh-api.3 b/contrib/atf/atf-sh/atf-sh-api.3 index d63804cd73fe..a30aee76e3d9 100644 --- a/contrib/atf/atf-sh/atf-sh-api.3 +++ b/contrib/atf/atf-sh/atf-sh-api.3 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 13, 2013 +.Dd March 2, 2014 .Dt ATF-SH-API 3 .Os .Sh NAME @@ -224,9 +224,8 @@ If .Va exitcode is not .Sq -1 , -.Xr atf-run 1 -will validate that the exit code of the test case matches the one provided -in this call. +the runtime engine will validate that the exit code of the test case +matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn atf_expect_fail "reason" Any failure raised in this mode is recorded, but such failures do not report @@ -258,9 +257,8 @@ If .Va signo is not .Sq -1 , -.Xr atf-run 1 -will validate that the signal that terminated the test case matches the one -provided in this call. +the runtime engine will validate that the signal that terminated the test +case matches the one provided in this call. Otherwise, the exact value will be ignored. .It Fn atf_expect_timeout "reason" "..." Expects the test case to execute for longer than its timeout. @@ -339,5 +337,4 @@ atf_check -s exit:0 -o match:"^foo$" -e empty 'ls' .Sh SEE ALSO .Xr atf-sh 1 , .Xr atf-test-program 1 , -.Xr atf-test-case 4 , -.Xr atf 7 +.Xr atf-test-case 4 diff --git a/contrib/atf/atf-sh/atf-sh.1 b/contrib/atf/atf-sh/atf-sh.1 index 7578ba0a4da3..ad77f04d3e22 100644 --- a/contrib/atf/atf-sh/atf-sh.1 +++ b/contrib/atf/atf-sh/atf-sh.1 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 15, 2013 +.Dd March 2, 2014 .Dt ATF-SH 1 .Os .Sh NAME @@ -47,10 +47,8 @@ library. .Pp .Nm is not a real interpreter though: it is just a wrapper around -the system-wide shell defined by the -.Sq atf_shell -configuration value in -.Xr atf-config 1 . +the system-wide shell defined by +.Va ATF_SHELL . .Nm executes the interpreter, loads the .Xr atf-sh-api 3 @@ -68,7 +66,10 @@ The following options are available: .It Fl h Shows a short summary of all available options and their purpose. .El +.Sh ENVIRONMENT +.Bl -tag -width ATFXSHELLXX -compact +.It Va ATF_SHELL +Path to the system shell to be used in the generated scripts. +.El .Sh SEE ALSO -.Xr atf-config 1 , -.Xr atf-sh-api 3 , -.Xr atf 7 +.Xr atf-sh-api 3 diff --git a/contrib/atf/doc/atf-test-case.4 b/contrib/atf/doc/atf-test-case.4 index c5e9e662a8e0..7f253ede915e 100644 --- a/contrib/atf/doc/atf-test-case.4 +++ b/contrib/atf/doc/atf-test-case.4 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 13, 2011 +.Dd March 2, 2014 .Dt ATF-TEST-CASE 4 .Os .Sh NAME @@ -171,9 +171,7 @@ Type: boolean. Optional. .Pp If set to true, specifies that the test case has a cleanup routine that has -to be executed by -.Xr atf-run 1 -during the cleanup phase of the execution. +to be executed by the runtime engine during the cleanup phase of the execution. This property is automatically set by the framework when defining a test case with a cleanup routine, so it should never be set by hand. .It ident @@ -251,8 +249,7 @@ the test case is .Pp If the test case is running as root and this property is .Sq unprivileged , -.Xr atf-run 1 -will automatically drop the privileges if the +the runtime engine will automatically drop the privileges if the .Sq unprivileged-user configuration property is set; otherwise the test case is .Em skipped . @@ -314,7 +311,4 @@ Test cases are always executed with a file creation mode mask (umask) of .Sq 0022 . The test case's code is free to change this during execution. .Sh SEE ALSO -.Xr atf-run 1 , -.Xr atf-test-program 1 , -.Xr atf-formats 5 , -.Xr atf 7 +.Xr atf-test-program 1 diff --git a/contrib/atf/doc/atf-test-program.1 b/contrib/atf/doc/atf-test-program.1 index 49ee12ddff25..c2f73261fc4c 100644 --- a/contrib/atf/doc/atf-test-program.1 +++ b/contrib/atf/doc/atf-test-program.1 @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 6, 2011 +.Dd March 2, 2014 .Dt ATF-TEST-PROGRAM 1 .Os .Sh NAME @@ -61,16 +61,17 @@ instead of the test case body; see Note that the test case is .Em executed without isolation , so it can and probably will create and modify files in the current directory. -To execute test cases in a controller manner, refer to -.Xr atf-run 1 , -which is the preferred way to run test cases. +To execute test cases in a controller manner, you need a runtime engine +that understands the ATF interface. +The recommended runtime engine is +.Xr kyua 1 . You should only execute test cases by hand for debugging purposes. .Pp In the second synopsis form, the test program will list all available test cases alongside their meta-data properties in a format that is machine parseable. This list is processed by -.Xr atf-run 1 +.Xr kyua 1 to know how to execute the test cases of a given test program. .Pp The following options are available: @@ -99,5 +100,4 @@ to the value .Ar value . .El .Sh SEE ALSO -.Xr atf-run 1 , -.Xr atf 7 +.Xr kyua 1 diff --git a/contrib/binutils/gas/config/tc-arm.c b/contrib/binutils/gas/config/tc-arm.c index 08dbb6fff888..1d9e27c0e834 100644 --- a/contrib/binutils/gas/config/tc-arm.c +++ b/contrib/binutils/gas/config/tc-arm.c @@ -4688,6 +4688,23 @@ parse_address_main (char **str, int i, int group_relocations, return PARSE_OPERAND_FAIL; } } + else if (skip_past_char (&p, ':') == SUCCESS) + { + /* FIXME: '@' should be used here, but it's filtered out by generic + code before we get to see it here. This may be subject to + change. */ + expressionS exp; + my_get_expression (&exp, &p, GE_NO_PREFIX); + if (exp.X_op != O_constant) + { + inst.error = _("alignment must be constant"); + return PARSE_OPERAND_FAIL; + } + inst.operands[i].imm = exp.X_add_number << 8; + inst.operands[i].immisalign = 1; + /* Alignments are not pre-indexes. */ + inst.operands[i].preind = 0; + } if (skip_past_char (&p, ']') == FAIL) { @@ -6571,6 +6588,7 @@ do_barrier (void) if (inst.operands[0].present) { constraint ((inst.instruction & 0xf0) != 0x40 + && (inst.instruction & 0xf0) != 0x50 && inst.operands[0].imm != 0xf, "bad barrier type"); inst.instruction |= inst.operands[0].imm; @@ -14694,10 +14712,18 @@ static const struct asm_cond conds[] = static struct asm_barrier_opt barrier_opt_names[] = { - { "sy", 0xf }, - { "un", 0x7 }, - { "st", 0xe }, - { "unst", 0x6 } + { "sy", 0xf }, + { "un", 0x7 }, + { "st", 0xe }, + { "unst", 0x6 }, + { "ish", 0xb }, + { "sh", 0xb }, + { "ishst", 0xa }, + { "shst", 0xa }, + { "nsh", 0x7 }, + { "nshst", 0x6 }, + { "osh", 0x3 }, + { "oshst", 0x2 } }; /* Table of ARM-format instructions. */ diff --git a/contrib/hyperv/tools/hv_kvp_daemon.8 b/contrib/hyperv/tools/hv_kvp_daemon.8 new file mode 100644 index 000000000000..af574edef3a0 --- /dev/null +++ b/contrib/hyperv/tools/hv_kvp_daemon.8 @@ -0,0 +1,68 @@ +.\" Copyright (c) 2014 Microsoft Corp. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that 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. +.\" +.Dd September 10, 2013 +.Dt HYPER-V 4 +.Os +.Sh NAME +.Nm hv_kvp_daemon +.Nd Hyper-V Key Value Pair Daemon +.Sh SYNOPSIS +The \fBhv_kvp_daemon\fP daemon provides the ability to store, retrieve, modify and delete +Key Value pairs for FreeBSD guest partitions running on Hyper-V. +.Sh DESCRIPTION +Hyper-V allows administrators to store custom metadata in the form +of Key Value pairs inside the FreeBSD guest partition. Administrators can +use Windows Powershell scripts to add, read, modify and delete such +Key Value pairs. + +The \fBhv_kvp_daemon\fP accepts Key Value pair management requests from the +\fBhv_utils\fP driver and performs the actual metadata management on the file-system. + +The same daemon and driver combination is also used to set and get +IP addresses from a FreeBSD guest. + +The set functionality is particularly +useful when the FreeBSD guest is assigned a static IP address and is failed +over from one Hyper-V host to another. After failover, Hyper-V uses the set IP +functionality to automatically +update the FreeBSD guest's IP address to its original static value. + +On the other hand, the get IP functionality is used to update the guest IP +address in the Hyper-V management console window. +.Sh SEE ALSO +.Xr hv_vmbus 4 , +.Xr hv_utils 4 , +.Xr hv_netvsc 4 , +.Xr hv_storvsc 4 , +.Xr hv_ata_pci_disengage 4 +.Sh HISTORY +Support for Hyper-V in the form of ports was first released in September 2013. +The daemon was developed through a joint effort between Citrix Inc., +Microsoft Corp. and Network Appliance Inc.. +.Sh AUTHORS +.An -nosplit +.Fx +support for \fBhv_kvp_daemon\fP was first added by +.An Microsoft BSD Integration Services Team Aq bsdic@microsoft.com . diff --git a/contrib/hyperv/tools/hv_kvp_daemon.c b/contrib/hyperv/tools/hv_kvp_daemon.c new file mode 100644 index 000000000000..b0a84d411095 --- /dev/null +++ b/contrib/hyperv/tools/hv_kvp_daemon.c @@ -0,0 +1,1517 @@ +/*- + * Copyright (c) 2014 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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 ``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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hv_kvp.h" + +typedef uint8_t __u8; +typedef uint16_t __u16; +typedef uint32_t __u32; +typedef uint64_t __u64; + +/* + * ENUM Data + */ + +enum key_index { + FullyQualifiedDomainName = 0, + IntegrationServicesVersion, /*This key is serviced in the kernel*/ + NetworkAddressIPv4, + NetworkAddressIPv6, + OSBuildNumber, + OSName, + OSMajorVersion, + OSMinorVersion, + OSVersion, + ProcessorArchitecture +}; + + +enum { + IPADDR = 0, + NETMASK, + GATEWAY, + DNS +}; + + +/* Global Variables */ + +/* + * The structure for operation handlers. + */ +struct kvp_op_hdlr { + int kvp_op_key; + void (*kvp_op_init)(void); + int (*kvp_op_exec)(struct hv_kvp_msg *kvp_op_msg, void *data); +}; + +static struct kvp_op_hdlr kvp_op_hdlrs[HV_KVP_OP_COUNT]; + +/* OS information */ + +static const char *os_name = ""; +static const char *os_major = ""; +static const char *os_minor = ""; +static const char *processor_arch; +static const char *os_build; +static const char *lic_version = "BSD Pre-Release version"; +static struct utsname uts_buf; + +/* Global flags */ +static int is_daemon = 1; +static int is_debugging = 0; + +#define KVP_LOG(priority, format, args...) do { \ + if (is_debugging == 1) { \ + if (is_daemon == 1) \ + syslog(priority, format, ## args); \ + else \ + printf(format, ## args); \ + } else { \ + if (priority < LOG_DEBUG) { \ + if (is_daemon == 1) \ + syslog(priority, format, ## args); \ + else \ + printf(format, ## args); \ + } \ + } \ + } while(0) + +/* + * For KVP pool file + */ + +#define MAX_FILE_NAME 100 +#define ENTRIES_PER_BLOCK 50 + +struct kvp_record { + char key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; + char value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; +}; + +struct kvp_pool { + int pool_fd; + int num_blocks; + struct kvp_record *records; + int num_records; + char fname[MAX_FILE_NAME]; +}; + +static struct kvp_pool kvp_pools[HV_KVP_POOL_COUNT]; + + +static void +kvp_acquire_lock(int pool) +{ + struct flock fl = { 0, 0, 0, F_WRLCK, SEEK_SET, 0 }; + + fl.l_pid = getpid(); + + if (fcntl(kvp_pools[pool].pool_fd, F_SETLKW, &fl) == -1) { + KVP_LOG(LOG_ERR, "Failed to acquire the lock pool: %d", pool); + exit(EXIT_FAILURE); + } +} + + +static void +kvp_release_lock(int pool) +{ + struct flock fl = { 0, 0, 0, F_UNLCK, SEEK_SET, 0 }; + + fl.l_pid = getpid(); + + if (fcntl(kvp_pools[pool].pool_fd, F_SETLK, &fl) == -1) { + perror("fcntl"); + KVP_LOG(LOG_ERR, "Failed to release the lock pool: %d\n", pool); + exit(EXIT_FAILURE); + } +} + + +/* + * Write in-memory copy of KVP to pool files + */ +static void +kvp_update_file(int pool) +{ + FILE *filep; + size_t bytes_written; + + kvp_acquire_lock(pool); + + filep = fopen(kvp_pools[pool].fname, "w"); + if (!filep) { + kvp_release_lock(pool); + KVP_LOG(LOG_ERR, "Failed to open file, pool: %d\n", pool); + exit(EXIT_FAILURE); + } + + bytes_written = fwrite(kvp_pools[pool].records, + sizeof(struct kvp_record), + kvp_pools[pool].num_records, filep); + + if (ferror(filep) || fclose(filep)) { + kvp_release_lock(pool); + KVP_LOG(LOG_ERR, "Failed to write file, pool: %d\n", pool); + exit(EXIT_FAILURE); + } + + kvp_release_lock(pool); +} + + +/* + * Read KVPs from pool files and store in memory + */ +static void +kvp_update_mem_state(int pool) +{ + FILE *filep; + size_t records_read = 0; + struct kvp_record *record = kvp_pools[pool].records; + struct kvp_record *readp; + int num_blocks = kvp_pools[pool].num_blocks; + int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; + + kvp_acquire_lock(pool); + + filep = fopen(kvp_pools[pool].fname, "r"); + if (!filep) { + kvp_release_lock(pool); + KVP_LOG(LOG_ERR, "Failed to open file, pool: %d\n", pool); + exit(EXIT_FAILURE); + } + for ( ; ; ) + { + readp = &record[records_read]; + records_read += fread(readp, sizeof(struct kvp_record), + ENTRIES_PER_BLOCK * num_blocks, + filep); + + if (ferror(filep)) { + KVP_LOG(LOG_ERR, "Failed to read file, pool: %d\n", pool); + exit(EXIT_FAILURE); + } + + if (!feof(filep)) { + /* + * Have more data to read. Expand the memory. + */ + num_blocks++; + record = realloc(record, alloc_unit * num_blocks); + + if (record == NULL) { + KVP_LOG(LOG_ERR, "malloc failed\n"); + exit(EXIT_FAILURE); + } + continue; + } + break; + } + + kvp_pools[pool].num_blocks = num_blocks; + kvp_pools[pool].records = record; + kvp_pools[pool].num_records = records_read; + + fclose(filep); + kvp_release_lock(pool); +} + + +static int +kvp_file_init(void) +{ + int fd; + FILE *filep; + size_t records_read; + char *fname; + struct kvp_record *record; + struct kvp_record *readp; + int num_blocks; + int i; + int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; + + if (mkdir("/var/db/hyperv/pool", S_IRUSR | S_IWUSR | S_IROTH) < 0 && + errno != EISDIR) { + KVP_LOG(LOG_ERR, " Failed to create /var/db/hyperv/pool\n"); + exit(EXIT_FAILURE); + } + + for (i = 0; i < HV_KVP_POOL_COUNT; i++) + { + fname = kvp_pools[i].fname; + records_read = 0; + num_blocks = 1; + snprintf(fname, MAX_FILE_NAME, "/var/db/hyperv/pool/.kvp_pool_%d", i); + fd = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH); + + if (fd == -1) { + return (1); + } + + + filep = fopen(fname, "r"); + if (!filep) { + close(fd); + return (1); + } + + record = malloc(alloc_unit * num_blocks); + if (record == NULL) { + close(fd); + fclose(filep); + return (1); + } + for ( ; ; ) + { + readp = &record[records_read]; + records_read += fread(readp, sizeof(struct kvp_record), + ENTRIES_PER_BLOCK, + filep); + + if (ferror(filep)) { + KVP_LOG(LOG_ERR, "Failed to read file, pool: %d\n", + i); + exit(EXIT_FAILURE); + } + + if (!feof(filep)) { + /* + * More data to read. + */ + num_blocks++; + record = realloc(record, alloc_unit * + num_blocks); + if (record == NULL) { + close(fd); + fclose(filep); + return (1); + } + continue; + } + break; + } + kvp_pools[i].pool_fd = fd; + kvp_pools[i].num_blocks = num_blocks; + kvp_pools[i].records = record; + kvp_pools[i].num_records = records_read; + fclose(filep); + } + + return (0); +} + + +static int +kvp_key_delete(int pool, __u8 *key, int key_size) +{ + int i; + int j, k; + int num_records; + struct kvp_record *record; + + KVP_LOG(LOG_DEBUG, "kvp_key_delete: pool = %d, " + "key = %s\n", pool, key); + + /* Update in-memory state */ + kvp_update_mem_state(pool); + + num_records = kvp_pools[pool].num_records; + record = kvp_pools[pool].records; + + for (i = 0; i < num_records; i++) + { + if (memcmp(key, record[i].key, key_size)) { + continue; + } + + KVP_LOG(LOG_DEBUG, "Found delete key in pool %d.\n", + pool); + /* + * We found a match at the end; Just update the number of + * entries and we are done. + */ + if (i == num_records) { + kvp_pools[pool].num_records--; + kvp_update_file(pool); + return (0); + } + + /* + * We found a match in the middle; Move the remaining + * entries up. + */ + j = i; + k = j + 1; + for ( ; k < num_records; k++) + { + strcpy(record[j].key, record[k].key); + strcpy(record[j].value, record[k].value); + j++; + } + kvp_pools[pool].num_records--; + kvp_update_file(pool); + return (0); + } + KVP_LOG(LOG_DEBUG, "Not found delete key in pool %d.\n", + pool); + return (1); +} + + +static int +kvp_key_add_or_modify(int pool, __u8 *key, __u32 key_size, __u8 *value, + __u32 value_size) +{ + int i; + int num_records; + struct kvp_record *record; + int num_blocks; + + KVP_LOG(LOG_DEBUG, "kvp_key_add_or_modify: pool = %d, " + "key = %s, value = %s\n,", pool, key, value); + + if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) || + (value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) { + KVP_LOG(LOG_ERR, "kvp_key_add_or_modify: returning 1\n"); + return (1); + } + + /* Update the in-memory state. */ + kvp_update_mem_state(pool); + + num_records = kvp_pools[pool].num_records; + record = kvp_pools[pool].records; + num_blocks = kvp_pools[pool].num_blocks; + + for (i = 0; i < num_records; i++) + { + if (memcmp(key, record[i].key, key_size)) { + continue; + } + + /* + * Key exists. Just update the value and we are done. + */ + memcpy(record[i].value, value, value_size); + kvp_update_file(pool); + return (0); + } + + /* + * Key doesn't exist; Add a new KVP. + */ + if (num_records == (ENTRIES_PER_BLOCK * num_blocks)) { + /* Increase the size of the recodrd array. */ + record = realloc(record, sizeof(struct kvp_record) * + ENTRIES_PER_BLOCK * (num_blocks + 1)); + + if (record == NULL) { + return (1); + } + kvp_pools[pool].num_blocks++; + } + memcpy(record[i].value, value, value_size); + memcpy(record[i].key, key, key_size); + kvp_pools[pool].records = record; + kvp_pools[pool].num_records++; + kvp_update_file(pool); + return (0); +} + + +static int +kvp_get_value(int pool, __u8 *key, int key_size, __u8 *value, + int value_size) +{ + int i; + int num_records; + struct kvp_record *record; + + KVP_LOG(LOG_DEBUG, "kvp_get_value: pool = %d, key = %s\n,", + pool, key); + + if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) || + (value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) { + return (1); + } + + /* Update the in-memory state first. */ + kvp_update_mem_state(pool); + + num_records = kvp_pools[pool].num_records; + record = kvp_pools[pool].records; + + for (i = 0; i < num_records; i++) + { + if (memcmp(key, record[i].key, key_size)) { + continue; + } + + /* Found the key */ + memcpy(value, record[i].value, value_size); + return (0); + } + + return (1); +} + + +static int +kvp_pool_enumerate(int pool, int index, __u8 *key, int key_size, + __u8 *value, int value_size) +{ + struct kvp_record *record; + + KVP_LOG(LOG_DEBUG, "kvp_pool_enumerate: pool = %d, index = %d\n,", + pool, index); + + /* First update our in-memory state first. */ + kvp_update_mem_state(pool); + record = kvp_pools[pool].records; + + /* Index starts with 0 */ + if (index >= kvp_pools[pool].num_records) { + return (1); + } + + memcpy(key, record[index].key, key_size); + memcpy(value, record[index].value, value_size); + return (0); +} + + +static void +kvp_get_os_info(void) +{ + char *p; + + uname(&uts_buf); + os_build = uts_buf.release; + os_name = uts_buf.sysname; + processor_arch = uts_buf.machine; + + /* + * Win7 host expects the build string to be of the form: x.y.z + * Strip additional information we may have. + */ + p = strchr(os_build, '-'); + if (p) { + *p = '\0'; + } + + /* + * We don't have any other information about the FreeBSD os. + */ + return; +} + +/* + * Given the interface name, return the MAC address. + */ +static char * +kvp_if_name_to_mac(char *if_name) +{ + char *mac_addr = NULL; + struct ifaddrs *ifaddrs_ptr; + struct ifaddrs *head_ifaddrs_ptr; + struct sockaddr_dl *sdl; + int status; + + status = getifaddrs(&ifaddrs_ptr); + + if (status >= 0) { + head_ifaddrs_ptr = ifaddrs_ptr; + do { + sdl = (struct sockaddr_dl *)(uintptr_t)ifaddrs_ptr->ifa_addr; + if ((sdl->sdl_type == IFT_ETHER) && + (strcmp(ifaddrs_ptr->ifa_name, if_name) == 0)) { + mac_addr = strdup(ether_ntoa((struct ether_addr *)(LLADDR(sdl)))); + break; + } + } while ((ifaddrs_ptr = ifaddrs_ptr->ifa_next) != NULL); + freeifaddrs(head_ifaddrs_ptr); + } + + return (mac_addr); +} + + +/* + * Given the MAC address, return the interface name. + */ +static char * +kvp_mac_to_if_name(char *mac) +{ + char *if_name = NULL; + struct ifaddrs *ifaddrs_ptr; + struct ifaddrs *head_ifaddrs_ptr; + struct sockaddr_dl *sdl; + int status; + char *buf_ptr, *p; + + status = getifaddrs(&ifaddrs_ptr); + + if (status >= 0) { + head_ifaddrs_ptr = ifaddrs_ptr; + do { + sdl = (struct sockaddr_dl *)(uintptr_t)ifaddrs_ptr->ifa_addr; + if (sdl->sdl_type == IFT_ETHER) { + buf_ptr = strdup(ether_ntoa((struct ether_addr *)(LLADDR(sdl)))); + if (buf_ptr != NULL) { + for (p = buf_ptr; *p != '\0'; p++) + *p = toupper(*p); + + if (strncmp(buf_ptr, mac, strlen(mac)) == 0) { + /* Caller will free the memory */ + if_name = strdup(ifaddrs_ptr->ifa_name); + free(buf_ptr); + break; + } else + free(buf_ptr); + } + } + } while ((ifaddrs_ptr = ifaddrs_ptr->ifa_next) != NULL); + freeifaddrs(head_ifaddrs_ptr); + } + return (if_name); +} + + +static void +kvp_process_ipconfig_file(char *cmd, + char *config_buf, size_t len, + size_t element_size, int offset) +{ + char buf[256]; + char *p; + char *x; + FILE *file; + + /* + * First execute the command. + */ + file = popen(cmd, "r"); + if (file == NULL) { + return; + } + + if (offset == 0) { + memset(config_buf, 0, len); + } + while ((p = fgets(buf, sizeof(buf), file)) != NULL) { + if ((len - strlen(config_buf)) < (element_size + 1)) { + break; + } + + x = strchr(p, '\n'); + *x = '\0'; + strlcat(config_buf, p, len); + strlcat(config_buf, ";", len); + } + pclose(file); +} + + +static void +kvp_get_ipconfig_info(char *if_name, struct hv_kvp_ipaddr_value *buffer) +{ + char cmd[512]; + char dhcp_info[128]; + char *p; + FILE *file; + + /* + * Retrieve the IPV4 address of default gateway. + */ + snprintf(cmd, sizeof(cmd), "netstat -rn | grep %s | awk '/default/ {print $2 }'", if_name); + + /* + * Execute the command to gather gateway IPV4 info. + */ + kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, + (MAX_GATEWAY_SIZE * 2), INET_ADDRSTRLEN, 0); + + /* + * Retrieve the IPV6 address of default gateway. + */ + snprintf(cmd, sizeof(cmd), "netstat -rn inet6 | grep %s | awk '/default/ {print $2 }", if_name); + + /* + * Execute the command to gather gateway IPV6 info. + */ + kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, + (MAX_GATEWAY_SIZE * 2), INET6_ADDRSTRLEN, 1); + + /* + * we just invoke an external script to get the DNS info. + * + * Following is the expected format of the information from the script: + * + * ipaddr1 (nameserver1) + * ipaddr2 (nameserver2) + * . + * . + */ + /* Scripts are stored in /usr/libexec/hyperv/ directory */ + snprintf(cmd, sizeof(cmd), "%s", "sh /usr/libexec/hyperv/hv_get_dns_info"); + + /* + * Execute the command to get DNS info. + */ + kvp_process_ipconfig_file(cmd, (char *)buffer->dns_addr, + (MAX_IP_ADDR_SIZE * 2), INET_ADDRSTRLEN, 0); + + /* + * Invoke an external script to get the DHCP state info. + * The parameter to the script is the interface name. + * Here is the expected output: + * + * Enabled: DHCP enabled. + */ + + + snprintf(cmd, sizeof(cmd), "%s %s", + "sh /usr/libexec/hyperv/hv_get_dhcp_info", if_name); + + file = popen(cmd, "r"); + if (file == NULL) { + return; + } + + p = fgets(dhcp_info, sizeof(dhcp_info), file); + if (p == NULL) { + pclose(file); + return; + } + + if (!strncmp(p, "Enabled", 7)) { + buffer->dhcp_enabled = 1; + } else{ + buffer->dhcp_enabled = 0; + } + + pclose(file); +} + + +static unsigned int +hweight32(unsigned int *w) +{ + unsigned int res = *w - ((*w >> 1) & 0x55555555); + + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res + (res >> 4)) & 0x0F0F0F0F; + res = res + (res >> 8); + return ((res + (res >> 16)) & 0x000000FF); +} + + +static int +kvp_process_ip_address(void *addrp, + int family, char *buffer, + int length, int *offset) +{ + struct sockaddr_in *addr; + struct sockaddr_in6 *addr6; + int addr_length; + char tmp[50]; + const char *str; + + if (family == AF_INET) { + addr = (struct sockaddr_in *)addrp; + str = inet_ntop(family, &addr->sin_addr, tmp, 50); + addr_length = INET_ADDRSTRLEN; + } else { + addr6 = (struct sockaddr_in6 *)addrp; + str = inet_ntop(family, &addr6->sin6_addr.s6_addr, tmp, 50); + addr_length = INET6_ADDRSTRLEN; + } + + if ((length - *offset) < addr_length + 1) { + return (HV_KVP_E_FAIL); + } + if (str == NULL) { + strlcpy(buffer, "inet_ntop failed\n", length); + return (HV_KVP_E_FAIL); + } + if (*offset == 0) { + strlcpy(buffer, tmp, length); + } else{ + strlcat(buffer, tmp, length); + } + strlcat(buffer, ";", length); + + *offset += strlen(str) + 1; + return (0); +} + + +static int +kvp_get_ip_info(int family, char *if_name, int op, + void *out_buffer, size_t length) +{ + struct ifaddrs *ifap; + struct ifaddrs *curp; + int offset = 0; + int sn_offset = 0; + int error = 0; + char *buffer; + size_t buffer_length; + struct hv_kvp_ipaddr_value *ip_buffer; + char cidr_mask[5]; + int weight; + int i; + unsigned int *w = NULL; + char *sn_str; + size_t sn_str_length; + struct sockaddr_in6 *addr6; + + if (op == HV_KVP_OP_ENUMERATE) { + buffer = out_buffer; + buffer_length = length; + } else { + ip_buffer = out_buffer; + buffer = (char *)ip_buffer->ip_addr; + buffer_length = sizeof(ip_buffer->ip_addr); + ip_buffer->addr_family = 0; + } + + if (getifaddrs(&ifap)) { + strlcpy(buffer, "getifaddrs failed\n", buffer_length); + return (HV_KVP_E_FAIL); + } + + curp = ifap; + while (curp != NULL) { + if (curp->ifa_addr == NULL) { + curp = curp->ifa_next; + continue; + } + + if ((if_name != NULL) && + (strncmp(curp->ifa_name, if_name, strlen(if_name)))) { + /* + * We want info about a specific interface; + * just continue. + */ + curp = curp->ifa_next; + continue; + } + + /* + * We support two address families: AF_INET and AF_INET6. + * If family value is 0, we gather both supported + * address families; if not we gather info on + * the specified address family. + */ + if ((family != 0) && (curp->ifa_addr->sa_family != family)) { + curp = curp->ifa_next; + continue; + } + if ((curp->ifa_addr->sa_family != AF_INET) && + (curp->ifa_addr->sa_family != AF_INET6)) { + curp = curp->ifa_next; + continue; + } + + if (op == HV_KVP_OP_GET_IP_INFO) { + /* + * Get the info other than the IP address. + */ + if (curp->ifa_addr->sa_family == AF_INET) { + ip_buffer->addr_family |= ADDR_FAMILY_IPV4; + + /* + * Get subnet info. + */ + error = kvp_process_ip_address( + curp->ifa_netmask, + AF_INET, + (char *) + ip_buffer->sub_net, + length, + &sn_offset); + if (error) { + goto kvp_get_ip_info_ipaddr; + } + } else { + ip_buffer->addr_family |= ADDR_FAMILY_IPV6; + + /* + * Get subnet info in CIDR format. + */ + weight = 0; + sn_str = (char *)ip_buffer->sub_net; + sn_str_length = sizeof(ip_buffer->sub_net); + addr6 = (struct sockaddr_in6 *)(uintptr_t) + curp->ifa_netmask; + w = (unsigned int *)(uintptr_t)addr6->sin6_addr.s6_addr; + + for (i = 0; i < 4; i++) + { + weight += hweight32(&w[i]); + } + + snprintf(cidr_mask, sizeof(cidr_mask), "/%d", weight); + if ((length - sn_offset) < + (strlen(cidr_mask) + 1)) { + goto kvp_get_ip_info_ipaddr; + } + + if (sn_offset == 0) { + strlcpy(sn_str, cidr_mask, sn_str_length); + } else{ + strlcat(sn_str, cidr_mask, sn_str_length); + } + strlcat((char *)ip_buffer->sub_net, ";", sn_str_length); + sn_offset += strlen(sn_str) + 1; + } + + /* + * Collect other ip configuration info. + */ + + kvp_get_ipconfig_info(if_name, ip_buffer); + } + +kvp_get_ip_info_ipaddr: + error = kvp_process_ip_address(curp->ifa_addr, + curp->ifa_addr->sa_family, + buffer, + length, &offset); + if (error) { + goto kvp_get_ip_info_done; + } + + curp = curp->ifa_next; + } + +kvp_get_ip_info_done: + freeifaddrs(ifap); + return (error); +} + + +static int +kvp_write_file(FILE *f, const char *s1, const char *s2, const char *s3) +{ + int ret; + + ret = fprintf(f, "%s%s%s%s\n", s1, s2, "=", s3); + + if (ret < 0) { + return (HV_KVP_E_FAIL); + } + + return (0); +} + + +static int +kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) +{ + int error = 0; + char if_file[128]; + FILE *file; + char cmd[512]; + char *mac_addr; + + /* + * FreeBSD - Configuration File + */ + snprintf(if_file, sizeof(if_file), "%s%s", "/var/db/hyperv", + "hv_set_ip_data"); + file = fopen(if_file, "w"); + + if (file == NULL) { + KVP_LOG(LOG_ERR, "FreeBSD Failed to open config file\n"); + return (HV_KVP_E_FAIL); + } + + /* + * Write out the MAC address. + */ + + mac_addr = kvp_if_name_to_mac(if_name); + if (mac_addr == NULL) { + error = HV_KVP_E_FAIL; + goto kvp_set_ip_info_error; + } + /* MAC Address */ + error = kvp_write_file(file, "HWADDR", "", mac_addr); + if (error) { + goto kvp_set_ip_info_error; + } + + /* Interface Name */ + error = kvp_write_file(file, "IF_NAME", "", if_name); + if (error) { + goto kvp_set_ip_info_error; + } + + /* IP Address */ + error = kvp_write_file(file, "IP_ADDR", "", + (char *)new_val->ip_addr); + if (error) { + goto kvp_set_ip_info_error; + } + + /* Subnet Mask */ + error = kvp_write_file(file, "SUBNET", "", + (char *)new_val->sub_net); + if (error) { + goto kvp_set_ip_info_error; + } + + + /* Gateway */ + error = kvp_write_file(file, "GATEWAY", "", + (char *)new_val->gate_way); + if (error) { + goto kvp_set_ip_info_error; + } + + /* DNS */ + error = kvp_write_file(file, "DNS", "", (char *)new_val->dns_addr); + if (error) { + goto kvp_set_ip_info_error; + } + + /* DHCP */ + if (new_val->dhcp_enabled) { + error = kvp_write_file(file, "DHCP", "", "1"); + } else{ + error = kvp_write_file(file, "DHCP", "", "0"); + } + + if (error) { + goto kvp_set_ip_info_error; + } + + free(mac_addr); + fclose(file); + + /* + * Invoke the external script with the populated + * configuration file. + */ + + snprintf(cmd, sizeof(cmd), "%s %s", + "sh /usr/libexec/hyperv/hv_set_ifconfig", if_file); + system(cmd); + return (0); + +kvp_set_ip_info_error: + KVP_LOG(LOG_ERR, "Failed to write config file\n"); + free(mac_addr); + fclose(file); + return (error); +} + + +static int +kvp_get_domain_name(char *buffer, int length) +{ + struct addrinfo hints, *info; + int error = 0; + + gethostname(buffer, length); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; /* Get only ipv4 addrinfo. */ + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + + error = getaddrinfo(buffer, NULL, &hints, &info); + if (error != 0) { + strlcpy(buffer, "getaddrinfo failed\n", length); + return (error); + } + strlcpy(buffer, info->ai_canonname, length); + freeaddrinfo(info); + return (error); +} + + +static int +kvp_op_getipinfo(struct hv_kvp_msg *op_msg, void *data __unused) +{ + struct hv_kvp_ipaddr_value *ip_val; + char *if_name; + + assert(op_msg != NULL); + KVP_LOG(LOG_DEBUG, "In kvp_op_getipinfo.\n"); + + ip_val = &op_msg->body.kvp_ip_val; + op_msg->hdr.error = HV_KVP_S_OK; + + if_name = kvp_mac_to_if_name((char *)ip_val->adapter_id); + + if (if_name == NULL) { + /* No interface found with the mac address. */ + op_msg->hdr.error = HV_KVP_E_FAIL; + goto kvp_op_getipinfo_done; + } + + op_msg->hdr.error = kvp_get_ip_info(0, if_name, + HV_KVP_OP_GET_IP_INFO, ip_val, (MAX_IP_ADDR_SIZE * 2)); + + free(if_name); + +kvp_op_getipinfo_done: + return(op_msg->hdr.error); +} + + +static int +kvp_op_setipinfo(struct hv_kvp_msg *op_msg, void *data __unused) +{ + struct hv_kvp_ipaddr_value *ip_val; + char *if_name; + + assert(op_msg != NULL); + KVP_LOG(LOG_DEBUG, "In kvp_op_setipinfo.\n"); + + ip_val = &op_msg->body.kvp_ip_val; + op_msg->hdr.error = HV_KVP_S_OK; + + if_name = (char *)ip_val->adapter_id; + + if (if_name == NULL) { + /* No adapter provided. */ + op_msg->hdr.error = HV_KVP_GUID_NOTFOUND; + goto kvp_op_setipinfo_done; + } + + op_msg->hdr.error = kvp_set_ip_info(if_name, ip_val); + +kvp_op_setipinfo_done: + return(op_msg->hdr.error); +} + + +static int +kvp_op_setgetdel(struct hv_kvp_msg *op_msg, void *data) +{ + struct kvp_op_hdlr *op_hdlr = (struct kvp_op_hdlr *)data; + int error = 0; + int op_pool; + + assert(op_msg != NULL); + assert(op_hdlr != NULL); + + op_pool = op_msg->hdr.kvp_hdr.pool; + op_msg->hdr.error = HV_KVP_S_OK; + + switch(op_hdlr->kvp_op_key) { + case HV_KVP_OP_SET: + if (op_pool == HV_KVP_POOL_AUTO) { + /* Auto Pool is not writeable from host side. */ + error = 1; + KVP_LOG(LOG_ERR, "Ilegal to write to pool %d from host\n", + op_pool); + } else { + error = kvp_key_add_or_modify(op_pool, + op_msg->body.kvp_set.data.key, + op_msg->body.kvp_set.data.key_size, + op_msg->body.kvp_set.data.msg_value.value, + op_msg->body.kvp_set.data.value_size); + } + break; + + case HV_KVP_OP_GET: + error = kvp_get_value(op_pool, + op_msg->body.kvp_get.data.key, + op_msg->body.kvp_get.data.key_size, + op_msg->body.kvp_get.data.msg_value.value, + op_msg->body.kvp_get.data.value_size); + break; + + case HV_KVP_OP_DELETE: + if (op_pool == HV_KVP_POOL_AUTO) { + /* Auto Pool is not writeable from host side. */ + error = 1; + KVP_LOG(LOG_ERR, "Ilegal to change pool %d from host\n", + op_pool); + } else { + error = kvp_key_delete(op_pool, + op_msg->body.kvp_delete.key, + op_msg->body.kvp_delete.key_size); + } + break; + + default: + break; + } + + if (error != 0) + op_msg->hdr.error = HV_KVP_S_CONT; + + return(error); +} + + +static int +kvp_op_enumerate(struct hv_kvp_msg *op_msg, void *data __unused) +{ + char *key_name, *key_value; + int error = 0; + int op_pool; + int op; + + assert(op_msg != NULL); + + op = op_msg->hdr.kvp_hdr.operation; + op_pool = op_msg->hdr.kvp_hdr.pool; + op_msg->hdr.error = HV_KVP_S_OK; + + /* + * If the pool is not HV_KVP_POOL_AUTO, read from the appropriate + * pool and return the KVP according to the index requested. + */ + if (op_pool != HV_KVP_POOL_AUTO) { + if (kvp_pool_enumerate(op_pool, + op_msg->body.kvp_enum_data.index, + op_msg->body.kvp_enum_data.data.key, + HV_KVP_EXCHANGE_MAX_KEY_SIZE, + op_msg->body.kvp_enum_data.data.msg_value.value, + HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) { + op_msg->hdr.error = HV_KVP_S_CONT; + error = -1; + } + goto kvp_op_enumerate_done; + } + + key_name = (char *)op_msg->body.kvp_enum_data.data.key; + key_value = (char *)op_msg->body.kvp_enum_data.data.msg_value.value; + + switch (op_msg->body.kvp_enum_data.index) + { + case FullyQualifiedDomainName: + kvp_get_domain_name(key_value, + HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "FullyQualifiedDomainName"); + break; + + case IntegrationServicesVersion: + strcpy(key_name, "IntegrationServicesVersion"); + strlcpy(key_value, lic_version, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + break; + + case NetworkAddressIPv4: + kvp_get_ip_info(AF_INET, NULL, HV_KVP_OP_ENUMERATE, + key_value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "NetworkAddressIPv4"); + break; + + case NetworkAddressIPv6: + kvp_get_ip_info(AF_INET6, NULL, HV_KVP_OP_ENUMERATE, + key_value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "NetworkAddressIPv6"); + break; + + case OSBuildNumber: + strlcpy(key_value, os_build, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "OSBuildNumber"); + break; + + case OSName: + strlcpy(key_value, os_name, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "OSName"); + break; + + case OSMajorVersion: + strlcpy(key_value, os_major, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "OSMajorVersion"); + break; + + case OSMinorVersion: + strlcpy(key_value, os_minor, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "OSMinorVersion"); + break; + + case OSVersion: + strlcpy(key_value, os_build, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "OSVersion"); + break; + + case ProcessorArchitecture: + strlcpy(key_value, processor_arch, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); + strcpy(key_name, "ProcessorArchitecture"); + break; + + default: +#ifdef DEBUG + KVP_LOG(LOG_ERR, "Auto pool Index %d not found.\n", + op_msg->body.kvp_enum_data.index); +#endif + op_msg->hdr.error = HV_KVP_S_CONT; + error = -1; + break; + } + +kvp_op_enumerate_done: + return(error); +} + + +/* + * Load handler, and call init routine if provided. + */ +static int +kvp_op_load(int key, void (*init)(void), + int (*exec)(struct hv_kvp_msg *, void *)) +{ + int error = 0; + + if (key < 0 || key >= HV_KVP_OP_COUNT) { + KVP_LOG(LOG_ERR, "Operation key out of supported range\n"); + error = -1; + goto kvp_op_load_done; + } + + kvp_op_hdlrs[key].kvp_op_key = key; + kvp_op_hdlrs[key].kvp_op_init = init; + kvp_op_hdlrs[key].kvp_op_exec = exec; + + if (kvp_op_hdlrs[key].kvp_op_init != NULL) + kvp_op_hdlrs[key].kvp_op_init(); + +kvp_op_load_done: + return(error); +} + + +/* + * Initialize the operation hanlders. + */ +static int +kvp_ops_init(void) +{ + int i; + + /* Set the initial values. */ + for (i = 0; i < HV_KVP_OP_COUNT; i++) { + kvp_op_hdlrs[i].kvp_op_key = -1; + kvp_op_hdlrs[i].kvp_op_init = NULL; + kvp_op_hdlrs[i].kvp_op_exec = NULL; + } + + return(kvp_op_load(HV_KVP_OP_GET, NULL, kvp_op_setgetdel) | + kvp_op_load(HV_KVP_OP_SET, NULL, kvp_op_setgetdel) | + kvp_op_load(HV_KVP_OP_DELETE, NULL, kvp_op_setgetdel) | + kvp_op_load(HV_KVP_OP_ENUMERATE, kvp_get_os_info, + kvp_op_enumerate) | + kvp_op_load(HV_KVP_OP_GET_IP_INFO, NULL, kvp_op_getipinfo) | + kvp_op_load(HV_KVP_OP_SET_IP_INFO, NULL, kvp_op_setipinfo)); +} + + +int +main(int argc, char *argv[]) +{ + struct hv_kvp_msg *hv_kvp_dev_buf; + struct hv_kvp_msg *hv_msg; + struct pollfd hv_kvp_poll_fd[1]; + int op, pool; + int hv_kvp_dev_fd, error, len, r; + int ch; + + while ((ch = getopt(argc, argv, "dn")) != -1) { + switch (ch) { + case 'n': + /* Run as regular process for debugging purpose. */ + is_daemon = 0; + break; + case 'd': + /* Generate debugging output */ + is_debugging = 1; + break; + default: + break; + } + } + + openlog("HV_KVP", 0, LOG_USER); + + /* Become daemon first. */ + if (is_daemon == 1) + daemon(1, 0); + else + KVP_LOG(LOG_DEBUG, "Run as regular process.\n"); + + KVP_LOG(LOG_INFO, "HV_KVP starting; pid is: %d\n", getpid()); + + /* Communication buffer hv_kvp_dev_buf */ + hv_kvp_dev_buf = malloc(sizeof(*hv_kvp_dev_buf)); + /* Buffer for daemon internal use */ + hv_msg = malloc(sizeof(*hv_msg)); + + /* Memory allocation failed */ + if (hv_kvp_dev_buf == NULL || hv_msg == NULL) { + KVP_LOG(LOG_ERR, "Failed to allocate memory for hv buffer\n"); + exit(EXIT_FAILURE); + } + + /* Initialize op handlers */ + if (kvp_ops_init() != 0) { + KVP_LOG(LOG_ERR, "Failed to initizlize operation handlers\n"); + exit(EXIT_FAILURE); + } + + if (kvp_file_init()) { + KVP_LOG(LOG_ERR, "Failed to initialize the pools\n"); + exit(EXIT_FAILURE); + } + + /* Open the Character Device */ + hv_kvp_dev_fd = open("/dev/hv_kvp_dev", O_RDWR); + + if (hv_kvp_dev_fd < 0) { + KVP_LOG(LOG_ERR, "open /dev/hv_kvp_dev failed; error: %d %s\n", + errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + /* Initialize the struct for polling the char device */ + hv_kvp_poll_fd[0].fd = hv_kvp_dev_fd; + hv_kvp_poll_fd[0].events = (POLLIN | POLLRDNORM); + + /* Register the daemon to the KVP driver */ + memset(hv_kvp_dev_buf, 0, sizeof(*hv_kvp_dev_buf)); + hv_kvp_dev_buf->hdr.kvp_hdr.operation = HV_KVP_OP_REGISTER; + len = write(hv_kvp_dev_fd, hv_kvp_dev_buf, sizeof(*hv_kvp_dev_buf)); + + + for (;;) { + r = poll (hv_kvp_poll_fd, 1, 100); + + KVP_LOG(LOG_DEBUG, "poll returned r = %d, revent = 0x%x\n", + r, hv_kvp_poll_fd[0].revents); + + if (r == 0 || (r < 0 && errno == EAGAIN) || + (r < 0 && errno == EINTR)) { + /* Nothing to read */ + continue; + } + + if (r < 0) { + /* + * For pread return failure other than EAGAIN, + * we want to exit. + */ + KVP_LOG(LOG_ERR, "Poll failed.\n"); + perror("poll"); + exit(EIO); + } + + /* Read from character device */ + len = pread(hv_kvp_dev_fd, hv_kvp_dev_buf, + sizeof(*hv_kvp_dev_buf), 0); + + if (len < 0) { + KVP_LOG(LOG_ERR, "Read failed.\n"); + perror("pread"); + exit(EIO); + } + + if (len != sizeof(struct hv_kvp_msg)) { + KVP_LOG(LOG_ERR, "read len is: %d\n", len); + continue; + } + + /* Copy hv_kvp_dev_buf to hv_msg */ + memcpy(hv_msg, hv_kvp_dev_buf, sizeof(*hv_msg)); + + /* + * We will use the KVP header information to pass back + * the error from this daemon. So, first save the op + * and pool info to local variables. + */ + + op = hv_msg->hdr.kvp_hdr.operation; + pool = hv_msg->hdr.kvp_hdr.pool; + + if (op < 0 || op >= HV_KVP_OP_COUNT || + kvp_op_hdlrs[op].kvp_op_exec == NULL) { + KVP_LOG(LOG_WARNING, + "Unsupported operation OP = %d\n", op); + hv_msg->hdr.error = HV_ERROR_NOT_SUPPORTED; + } else { + /* + * Call the operateion handler's execution routine. + */ + error = kvp_op_hdlrs[op].kvp_op_exec(hv_msg, + (void *)&kvp_op_hdlrs[op]); + if (error != 0 && hv_msg->hdr.error != HV_KVP_S_CONT) + KVP_LOG(LOG_WARNING, + "Operation failed OP = %d, error = 0x%x\n", + op, error); + } + + /* + * Send the value back to the kernel. The response is + * already in the receive buffer. + */ +hv_kvp_done: + len = pwrite(hv_kvp_dev_fd, hv_msg, sizeof(*hv_kvp_dev_buf), 0); + + if (len != sizeof(struct hv_kvp_msg)) { + KVP_LOG(LOG_ERR, "write len is: %d\n", len); + goto hv_kvp_done; + } + } +} diff --git a/contrib/hyperv/tools/scripts/hv_get_dhcp_info b/contrib/hyperv/tools/scripts/hv_get_dhcp_info new file mode 100644 index 000000000000..b56efd30f4e4 --- /dev/null +++ b/contrib/hyperv/tools/scripts/hv_get_dhcp_info @@ -0,0 +1,24 @@ +#!/bin/sh + +# This is the script retrieves the DHCP state of a given interface. +# The kvp daemon code invokes this external script to gather +# DHCP setting for the specific interface. +# +# Input: Name of the interface +# +# Output: The script prints the string "Enabled" to stdout to indicate +# that DHCP is enabled on the interface. If DHCP is not enabled, +# the script prints the string "Disabled" to stdout. +# + +. /etc/rc.subr +. /etc/network.subr + +load_rc_config netif + +if dhcpif hn0; +then +echo "Enabled" +else +echo "Disabled" +fi diff --git a/contrib/hyperv/tools/scripts/hv_get_dns_info b/contrib/hyperv/tools/scripts/hv_get_dns_info new file mode 100644 index 000000000000..7a34440fd902 --- /dev/null +++ b/contrib/hyperv/tools/scripts/hv_get_dns_info @@ -0,0 +1,12 @@ +#!/bin/sh +# This script parses /etc/resolv.conf to retrive DNS information. +# Khe kvp daemon code invokes this external script to gather +# DNS information. +# This script is expected to print the nameserver values to stdout. + +#if test -r /etc/resolv.conf +#then +# awk -- '/^nameserver/ { print $2 }' /etc/resolv.conf +#fi +cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' + diff --git a/contrib/hyperv/tools/scripts/hv_set_ifconfig b/contrib/hyperv/tools/scripts/hv_set_ifconfig new file mode 100644 index 000000000000..3dc42e7bbf82 --- /dev/null +++ b/contrib/hyperv/tools/scripts/hv_set_ifconfig @@ -0,0 +1,73 @@ +#!/bin/sh + +# This script activates an interface based on the specified +# configuration. The kvp daemon code invokes this external script +# to configure the interface. +# +# The only argument to this script is the configuration file that is to +# be used to configure the interface. +# +# Here is the format of the ip configuration file: +# +# HWADDR=macaddr +# IF_NAME=interface name +# DHCP=yes (This is optional; if yes, DHCP is configured) +# +# IPADDR=ipaddr1 +# IPADDR_1=ipaddr2 +# IPADDR_x=ipaddry (where y = x + 1) +# +# NETMASK=netmask1 +# NETMASK_x=netmasky (where y = x + 1) +# +# GATEWAY=ipaddr1 +# GATEWAY_x=ipaddry (where y = x + 1) +# +# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) +# +# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be +# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as +# IPV6NETMASK. +# +# The host can specify multiple ipv4 and ipv6 addresses to be +# configured for the interface. Furthermore, the configuration +# needs to be persistent. A subsequent GET call on the interface +# is expected to return the configuration that is set via the SET +# call. +# + +. $1 + +sed -i".bak" '/ifconfig_hn0="SYNCDHCP"/d' /etc/rc.conf +sed -i".bak" '/ifconfig_hn0="DHCP"/d' /etc/rc.conf + +# MAC Address +ifconfig $IF_NAME ether $HWADDR + +# IP and Subnet Mask +ifconfig $IF_NAME inet $IP_ADDR netmask $SUBNET + +# DNS +sed -i".bak" '/nameserver/d' /etc/resolv.conf +echo "nameserver" $DNS >> /etc/resolv.conf + +#Gateway +# Need to implment if Gateway is not present +route flush +route add default $GATEWAY +#route change default $GATEWAY + +#/etc/rc.d/netif restart +#/etc/rc.d/routing restart + + +# DHCP +if [ $DHCP -eq 1 ] +then + echo ifconfig_hn0=\"DHCP\" >> /etc/rc.conf + echo Enabled +else + echo Disabled DHCP >> /var/log/messages + echo Disabled +fi +echo "Set IP-Injection Success" diff --git a/contrib/ipfilter/lib/gethost.c b/contrib/ipfilter/lib/gethost.c index a11b09b2e49f..14099e25c372 100644 --- a/contrib/ipfilter/lib/gethost.c +++ b/contrib/ipfilter/lib/gethost.c @@ -19,16 +19,17 @@ int gethost(family, name, hostp) struct netent *n; u_32_t addr; + bzero(hostp, sizeof(*hostp)); if (!strcmp(name, "test.host.dots")) { if (family == AF_INET) { hostp->in4.s_addr = htonl(0xfedcba98); } #ifdef USE_INET6 if (family == AF_INET6) { - hostp->i6[0] = 0xfe80aa55; - hostp->i6[1] = 0x12345678; - hostp->i6[2] = 0x5a5aa5a5; - hostp->i6[3] = 0xfedcba98; + hostp->i6[0] = htonl(0xfe80aa55); + hostp->i6[1] = htonl(0x12345678); + hostp->i6[2] = htonl(0x5a5aa5a5); + hostp->i6[3] = htonl(0xfedcba98); } #endif return 0; diff --git a/contrib/ipfilter/lib/printnat.c b/contrib/ipfilter/lib/printnat.c index 37a7e12d527e..a94d4ee6105e 100644 --- a/contrib/ipfilter/lib/printnat.c +++ b/contrib/ipfilter/lib/printnat.c @@ -153,7 +153,8 @@ printnat(np, opts) } else if (np->in_redir & NAT_REWRITE) { PRINTF(" -> src "); - if (np->in_nsrc.na_type == IPLT_DSTLIST) { + if (np->in_nsrc.na_atype == FRI_LOOKUP && + np->in_nsrc.na_type == IPLT_DSTLIST) { PRINTF("dstlist/"); if (np->in_nsrc.na_subtype == 0) PRINTF("%d", np->in_nsrc.na_num); @@ -174,7 +175,8 @@ printnat(np, opts) } } PRINTF(" dst "); - if (np->in_ndst.na_type == IPLT_DSTLIST) { + if (np->in_ndst.na_atype == FRI_LOOKUP && + np->in_ndst.na_type == IPLT_DSTLIST) { PRINTF("dstlist/"); if (np->in_ndst.na_subtype == 0) PRINTF("%d", np->in_nsrc.na_num); diff --git a/contrib/ipfilter/tools/ipf_y.y b/contrib/ipfilter/tools/ipf_y.y index 822e9a5ab0ca..e0dc847a100e 100644 --- a/contrib/ipfilter/tools/ipf_y.y +++ b/contrib/ipfilter/tools/ipf_y.y @@ -1020,12 +1020,13 @@ addr: pool '/' YY_NUMBER { pooled = 1; yyexpectaddr = 0; } ; -ipaddr: IPFY_ANY { bzero(&($$), sizeof($$)); +ipaddr: IPFY_ANY { memset(&($$), 0, sizeof($$)); $$.type = FRI_NORMAL; $$.ifpos = -1; yyexpectaddr = 0; } - | hostname { $$.a = $1.adr; + | hostname { memset(&($$), 0, sizeof($$)); + $$.a = $1.adr; $$.f = $1.f; if ($1.f == AF_INET6) fill6bits(128, $$.m.i6); @@ -1038,7 +1039,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$)); | hostname { yyresetdict(); } maskspace { yysetdict(maskwords); yyexpectaddr = 2; } - ipmask { ntomask($1.f, $5, $$.m.i6); + ipmask { memset(&($$), 0, sizeof($$)); + ntomask($1.f, $5, $$.m.i6); $$.a = $1.adr; $$.a.i6[0] &= $$.m.i6[0]; $$.a.i6[1] &= $$.m.i6[1]; @@ -1060,7 +1062,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$)); yyresetdict(); yyexpectaddr = 0; } - | '(' YY_STR ')' { $$.type = FRI_DYNAMIC; + | '(' YY_STR ')' { memset(&($$), 0, sizeof($$)); + $$.type = FRI_DYNAMIC; ifpflag = FRI_DYNAMIC; $$.ifpos = addname(&fr, $2); $$.lif = 0; @@ -1068,7 +1071,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$)); | '(' YY_STR ')' '/' { ifpflag = FRI_DYNAMIC; yysetdict(maskwords); } maskopts - { $$.type = ifpflag; + { memset(&($$), 0, sizeof($$)); + $$.type = ifpflag; $$.ifpos = addname(&fr, $2); $$.lif = 0; if (frc->fr_family == AF_UNSPEC) @@ -1083,7 +1087,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$)); | '(' YY_STR ':' YY_NUMBER ')' '/' { ifpflag = FRI_DYNAMIC; yysetdict(maskwords); } maskopts - { $$.type = ifpflag; + { memset(&($$), 0, sizeof($$)); + $$.type = ifpflag; $$.ifpos = addname(&fr, $2); $$.lif = $4; if (frc->fr_family == AF_UNSPEC) @@ -1142,30 +1147,35 @@ maskopts: ; hostname: - ipv4 { $$.adr.in4 = $1; + ipv4 { memset(&($$), 0, sizeof($$)); + $$.adr.in4 = $1; if (frc->fr_family == AF_INET6) YYERROR; $$.f = AF_INET; yyexpectaddr = 2; } - | YY_NUMBER { if (frc->fr_family == AF_INET6) + | YY_NUMBER { memset(&($$), 0, sizeof($$)); + if (frc->fr_family == AF_INET6) YYERROR; $$.adr.in4_addr = $1; $$.f = AF_INET; yyexpectaddr = 2; } - | YY_HEX { if (frc->fr_family == AF_INET6) + | YY_HEX { memset(&($$), 0, sizeof($$)); + if (frc->fr_family == AF_INET6) YYERROR; $$.adr.in4_addr = $1; $$.f = AF_INET; yyexpectaddr = 2; } - | YY_STR { if (lookuphost($1, &$$.adr) == 0) + | YY_STR { memset(&($$), 0, sizeof($$)); + if (lookuphost($1, &$$.adr) == 0) $$.f = AF_INET; free($1); yyexpectaddr = 2; } - | YY_IPV6 { if (frc->fr_family == AF_INET) + | YY_IPV6 { memset(&($$), 0, sizeof($$)); + if (frc->fr_family == AF_INET) YYERROR; $$.adr = $1; $$.f = AF_INET6; diff --git a/contrib/ipfilter/tools/ipnat_y.y b/contrib/ipfilter/tools/ipnat_y.y index 71fb8ee37106..8c23403b3e03 100644 --- a/contrib/ipfilter/tools/ipnat_y.y +++ b/contrib/ipfilter/tools/ipnat_y.y @@ -871,9 +871,9 @@ mapport: } free($2); if ($3.p1 < 0 || $3.p1 > 65535) - yyerror("invalid ICMP Id number"); + yyerror("invalid 1st ICMP Id number"); if ($3.p2 < 0 || $3.p2 > 65535) - yyerror("invalid ICMP Id number"); + yyerror("invalid 2nd ICMP Id number"); if (strcmp($2, "ipv6-icmp") == 0) { nat->in_pr[0] = IPPROTO_ICMPV6; nat->in_pr[1] = IPPROTO_ICMPV6; @@ -1058,7 +1058,7 @@ hash: IPNY_HASH { if (!(nat->in_flags & IPN_FILTER)) { ; portstuff: - compare portspec { $$.pc = $1; $$.p1 = $2; } + compare portspec { $$.pc = $1; $$.p1 = $2; $$.p2 = 0; } | portspec range portspec { $$.pc = $2; $$.p1 = $1; $$.p2 = $3; } ; @@ -1151,7 +1151,7 @@ proto: YY_NUMBER { $$ = $1; | YY_STR { $$ = getproto($1); free($1); if ($$ == -1) - yyerror("unknwon protocol"); + yyerror("unknown protocol"); if ($$ != IPPROTO_TCP && $$ != IPPROTO_UDP) suggest_port = 0; @@ -1164,17 +1164,20 @@ hexnumber: hostname: YY_STR { i6addr_t addr; + int family; - bzero(&$$, sizeof($$)); - if (gethost(AF_INET, $1, +#ifdef USE_INET6 + if (nat->in_v[0] == 6) + family = AF_INET6; + else +#endif + family = AF_INET; + memset(&($$), 0, sizeof($$)); + memset(&addr, 0, sizeof(addr)); + $$.f = family; + if (gethost(family, $1, &addr) == 0) { $$.a = addr; - $$.f = AF_INET; - } else - if (gethost(AF_INET6, $1, - &addr) == 0) { - $$.a = addr; - $$.f = AF_INET6; } else { FPRINTF(stderr, "Unknown host '%s'\n", @@ -1182,17 +1185,17 @@ hostname: } free($1); } - | YY_NUMBER { bzero(&$$, sizeof($$)); + | YY_NUMBER { memset(&($$), 0, sizeof($$)); $$.a.in4.s_addr = htonl($1); if ($$.a.in4.s_addr != 0) $$.f = AF_INET; } | ipv4 { $$ = $1; } - | YY_IPV6 { bzero(&$$, sizeof($$)); + | YY_IPV6 { memset(&($$), 0, sizeof($$)); $$.a = $1; $$.f = AF_INET6; } - | YY_NUMBER YY_IPV6 { bzero(&$$, sizeof($$)); + | YY_NUMBER YY_IPV6 { memset(&($$), 0, sizeof($$)); $$.a = $2; $$.f = AF_INET6; } @@ -1427,6 +1430,9 @@ setnatproto(p) nat->in_flags |= IPN_UDP; nat->in_flags &= ~IPN_TCP; break; +#ifdef USE_INET6 + case IPPROTO_ICMPV6 : +#endif case IPPROTO_ICMP : nat->in_flags &= ~IPN_TCPUDP; if (!(nat->in_flags & IPN_ICMPQUERY) && @@ -1506,7 +1512,7 @@ ipnat_addrule(fd, ioctlfunc, ptr) printnat(ipn, opts); if (opts & OPT_DEBUG) - binprint(ipn, sizeof(*ipn)); + binprint(ipn, ipn->in_size); if ((opts & OPT_ZERORULEST) != 0) { if ((*ioctlfunc)(fd, add, (void *)&obj) == -1) { diff --git a/contrib/libc-vis/vis.c b/contrib/libc-vis/vis.c index 2ba6b5b23d71..4863bbea8596 100644 --- a/contrib/libc-vis/vis.c +++ b/contrib/libc-vis/vis.c @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $ */ +/* $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -57,7 +57,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $"); +__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef __FBSDID __FBSDID("$FreeBSD$"); @@ -357,7 +357,7 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength, ssize_t mbslength, maxolen; _DIAGASSERT(mbdst != NULL); - _DIAGASSERT(mbsrc != NULL); + _DIAGASSERT(mbsrc != NULL || mblength == 0); _DIAGASSERT(mbextra != NULL); /* @@ -375,8 +375,6 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength, /* Allocate space for the wide char strings */ psrc = pdst = extra = NULL; - if (!mblength) - mblength = strlen(mbsrc); if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL) return -1; if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL) @@ -528,6 +526,15 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength, free(psrc); return error; } + +static int +istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc, + int flags, const char *mbextra, int *cerr_ptr) +{ + return istrsenvisx(mbdst, dlen, mbsrc, + mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr); +} + #endif #if !HAVE_SVIS @@ -571,13 +578,13 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra int strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra) { - return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, mbextra, NULL); + return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL); } int strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra) { - return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, mbextra, NULL); + return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL); } int @@ -646,13 +653,13 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc) int strvis(char *mbdst, const char *mbsrc, int flags) { - return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, "", NULL); + return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL); } int strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags) { - return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, "", NULL); + return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL); } /* diff --git a/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp b/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp index 716c146811a1..1f20e29606b3 100644 --- a/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -300,6 +300,8 @@ void X86TargetLowering::resetOperationActions() { setTruncStoreAction(MVT::i32, MVT::i8 , Expand); setTruncStoreAction(MVT::i16, MVT::i8, Expand); + setTruncStoreAction(MVT::f64, MVT::f32, Expand); + // SETOEQ and SETUNE require checking two conditions. setCondCodeAction(ISD::SETOEQ, MVT::f32, Expand); setCondCodeAction(ISD::SETOEQ, MVT::f64, Expand); @@ -1011,8 +1013,6 @@ void X86TargetLowering::resetOperationActions() { AddPromotedToType (ISD::SELECT, VT, MVT::v2i64); } - setTruncStoreAction(MVT::f64, MVT::f32, Expand); - // Custom lower v2i64 and v2f64 selects. setOperationAction(ISD::LOAD, MVT::v2f64, Legal); setOperationAction(ISD::LOAD, MVT::v2i64, Legal); diff --git a/contrib/llvm/patches/patch-r269387-clang-arm-target-cpu.diff b/contrib/llvm/patches/patch-r269387-clang-arm-target-cpu.diff new file mode 100644 index 000000000000..fea76a1cebed --- /dev/null +++ b/contrib/llvm/patches/patch-r269387-clang-arm-target-cpu.diff @@ -0,0 +1,34 @@ +Update the ARMv6 core clang targets to be an arm1176jzf-s. This brings us +in line with gcc in base as this makes llvm generate code for the armv6k +variant of the instruction set. + +Introduced here: http://svnweb.freebsd.org/changeset/base/269387 + +Index: tools/clang/lib/Driver/ToolChain.cpp +=================================================================== +--- tools/clang/lib/Driver/ToolChain.cpp (revision 269386) ++++ tools/clang/lib/Driver/ToolChain.cpp (revision 269387) +@@ -183,7 +183,8 @@ static const char *getARMTargetCPU(const ArgList & + MArch = Triple.getArchName(); + } + +- if (Triple.getOS() == llvm::Triple::NetBSD) { ++ if (Triple.getOS() == llvm::Triple::NetBSD || ++ Triple.getOS() == llvm::Triple::FreeBSD) { + if (MArch == "armv6") + return "arm1176jzf-s"; + } +Index: tools/clang/lib/Driver/Tools.cpp +=================================================================== +--- tools/clang/lib/Driver/Tools.cpp (revision 269386) ++++ tools/clang/lib/Driver/Tools.cpp (revision 269387) +@@ -499,7 +499,8 @@ static std::string getARMTargetCPU(const ArgList & + MArch = Triple.getArchName(); + } + +- if (Triple.getOS() == llvm::Triple::NetBSD) { ++ if (Triple.getOS() == llvm::Triple::NetBSD || ++ Triple.getOS() == llvm::Triple::FreeBSD) { + if (MArch == "armv6") + return "arm1176jzf-s"; + } diff --git a/contrib/llvm/patches/patch-r270147-llvm-r197824-r213427-r213960.diff b/contrib/llvm/patches/patch-r270147-llvm-r197824-r213427-r213960.diff index 4603a0a69dc7..a3bd4c9fb988 100644 --- a/contrib/llvm/patches/patch-r270147-llvm-r197824-r213427-r213960.diff +++ b/contrib/llvm/patches/patch-r270147-llvm-r197824-r213427-r213960.diff @@ -1,7 +1,31 @@ -Index: contrib/llvm/include/llvm/Support/ELF.h +Backport r197824, r213427 and r213960 from LLVM trunk: + + r197824 | rdivacky | 2013-12-20 19:08:54 +0100 (Fri, 20 Dec 2013) | 2 lines + + Implement initial-exec TLS for PPC32. + + r213427 | hfinkel | 2014-07-19 01:29:49 +0200 (Sat, 19 Jul 2014) | 7 lines + + [PowerPC] 32-bit ELF PIC support + + This adds initial support for PPC32 ELF PIC (Position Independent Code; the + -fPIC variety), thus rectifying a long-standing deficiency in the PowerPC + backend. + + Patch by Justin Hibbits! + + r213960 | hfinkel | 2014-07-25 19:47:22 +0200 (Fri, 25 Jul 2014) | 3 lines + + [PowerPC] Support TLS on PPC32/ELF + + Patch by Justin Hibbits! + +Introduced here: http://svnweb.freebsd.org/changeset/base/270147 + +Index: include/llvm/Support/ELF.h =================================================================== ---- contrib/llvm/include/llvm/Support/ELF.h (revision 270019) -+++ contrib/llvm/include/llvm/Support/ELF.h (working copy) +--- include/llvm/Support/ELF.h (revision 270019) ++++ include/llvm/Support/ELF.h (working copy) @@ -437,6 +437,7 @@ R_PPC_GOT16_LO = 15, R_PPC_GOT16_HI = 16, @@ -10,10 +34,10 @@ Index: contrib/llvm/include/llvm/Support/ELF.h R_PPC_REL32 = 26, R_PPC_TLS = 67, R_PPC_DTPMOD32 = 68, -Index: contrib/llvm/lib/Object/ELF.cpp +Index: lib/Object/ELF.cpp =================================================================== ---- contrib/llvm/lib/Object/ELF.cpp (revision 270019) -+++ contrib/llvm/lib/Object/ELF.cpp (working copy) +--- lib/Object/ELF.cpp (revision 270019) ++++ lib/Object/ELF.cpp (working copy) @@ -507,6 +507,7 @@ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_LO); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_HI); @@ -22,10 +46,10 @@ Index: contrib/llvm/lib/Object/ELF.cpp LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL32); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TLS); LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPMOD32); -Index: contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp +Index: lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (working copy) +--- lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (revision 270019) ++++ lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (working copy) @@ -18,6 +18,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" @@ -52,10 +76,10 @@ Index: contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp } -Index: contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp +Index: lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (working copy) +--- lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (revision 270019) ++++ lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (working copy) @@ -64,7 +64,15 @@ llvm_unreachable("Unimplemented"); case PPC::fixup_ppc_br24: @@ -123,10 +147,10 @@ Index: contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp break; } break; -Index: contrib/llvm/lib/Target/PowerPC/PPC.h +Index: lib/Target/PowerPC/PPC.h =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPC.h (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPC.h (working copy) +--- lib/Target/PowerPC/PPC.h (revision 270019) ++++ lib/Target/PowerPC/PPC.h (working copy) @@ -53,10 +53,11 @@ // PPC Specific MachineOperand flags. MO_NO_FLAG, @@ -143,10 +167,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPC.h /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to /// the function's picbase, e.g. lo16(symbol-picbase). -Index: contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +Index: lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (working copy) +--- lib/Target/PowerPC/PPCAsmPrinter.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCAsmPrinter.cpp (working copy) @@ -19,6 +19,7 @@ #define DEBUG_TYPE "asmprinter" #include "PPC.h" @@ -578,10 +602,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp } } -Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +Index: lib/Target/PowerPC/PPCFrameLowering.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp (working copy) +--- lib/Target/PowerPC/PPCFrameLowering.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCFrameLowering.cpp (working copy) @@ -299,7 +299,7 @@ const PPCRegisterInfo *RegInfo = static_cast(MF.getTarget().getRegisterInfo()); @@ -664,10 +688,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp // Allocate the frame index for the base pointer save area. BPSI = MFI->CreateFixedObject(isPPC64? 8 : 4, BPOffset, true); // Save the result. -Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h +Index: lib/Target/PowerPC/PPCFrameLowering.h =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h (working copy) +--- lib/Target/PowerPC/PPCFrameLowering.h (revision 270019) ++++ lib/Target/PowerPC/PPCFrameLowering.h (working copy) @@ -96,12 +96,14 @@ /// getBasePointerSaveOffset - Return the previous frame offset to save the @@ -685,10 +709,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h } /// getLinkageSize - Return the size of the PowerPC ABI linkage area. -Index: contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (working copy) +--- lib/Target/PowerPC/PPCISelDAGToDAG.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp (working copy) @@ -15,6 +15,7 @@ #define DEBUG_TYPE "ppc-codegen" #include "PPC.h" @@ -748,10 +772,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp case PPCISD::VADD_SPLAT: { // This expands into one of three sequences, depending on whether // the first operand is odd or even, positive or negative. -Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp (working copy) +--- lib/Target/PowerPC/PPCISelLowering.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCISelLowering.cpp (working copy) @@ -670,6 +670,7 @@ case PPCISD::ADDIS_TOC_HA: return "PPCISD::ADDIS_TOC_HA"; case PPCISD::LD_TOC_L: return "PPCISD::LD_TOC_L"; @@ -972,10 +996,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp MachineInstrBuilder MIB; -Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h +Index: lib/Target/PowerPC/PPCISelLowering.h =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h (working copy) +--- lib/Target/PowerPC/PPCISelLowering.h (revision 270019) ++++ lib/Target/PowerPC/PPCISelLowering.h (working copy) @@ -177,6 +177,12 @@ CR6SET, CR6UNSET, @@ -989,10 +1013,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h /// G8RC = ADDIS_GOT_TPREL_HA %X2, Symbol - Used by the initial-exec /// TLS model, produces an ADDIS8 instruction that adds the GOT /// base to sym\@got\@tprel\@ha. -Index: contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td +Index: lib/Target/PowerPC/PPCInstr64Bit.td =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td (working copy) +--- lib/Target/PowerPC/PPCInstr64Bit.td (revision 270019) ++++ lib/Target/PowerPC/PPCInstr64Bit.td (working copy) @@ -36,10 +36,6 @@ def tocentry : Operand { let MIOperandInfo = (ops i64imm:$imm); @@ -1004,10 +1028,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td def tlsreg : Operand { let EncoderMethod = "getTLSRegEncoding"; let ParserMatchClass = PPCTLSRegOperand; -Index: contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td +Index: lib/Target/PowerPC/PPCInstrInfo.td =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td (working copy) +--- lib/Target/PowerPC/PPCInstrInfo.td (revision 270019) ++++ lib/Target/PowerPC/PPCInstrInfo.td (working copy) @@ -57,6 +57,9 @@ SDTCisPtrTy<0>, SDTCisVT<1, i32> ]>; @@ -1130,10 +1154,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td // Standard shifts. These are represented separately from the real shifts above // so that we can distinguish between shifts that allow 5-bit and 6-bit shift // amounts. -Index: contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp +Index: lib/Target/PowerPC/PPCMCInstLower.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp (working copy) +--- lib/Target/PowerPC/PPCMCInstLower.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCMCInstLower.cpp (working copy) @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// @@ -1188,10 +1212,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp const MCExpr *Expr = MCSymbolRefExpr::Create(Symbol, RefKind, Ctx); if (!MO.isJTI() && MO.getOffset()) -Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp +Index: lib/Target/PowerPC/PPCMachineFunctionInfo.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (working copy) +--- lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (working copy) @@ -8,8 +8,16 @@ //===----------------------------------------------------------------------===// @@ -1209,10 +1233,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp + return MF.getContext().GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())+ + Twine(MF.getFunctionNumber())+"$poff"); +} -Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h +Index: lib/Target/PowerPC/PPCMachineFunctionInfo.h =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h (working copy) +--- lib/Target/PowerPC/PPCMachineFunctionInfo.h (revision 270019) ++++ lib/Target/PowerPC/PPCMachineFunctionInfo.h (working copy) @@ -92,6 +92,12 @@ /// 64-bit SVR4 ABI. SmallVector MustSaveCRs; @@ -1249,10 +1273,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h }; } // end of namespace llvm -Index: contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp +Index: lib/Target/PowerPC/PPCRegisterInfo.cpp =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp (working copy) +--- lib/Target/PowerPC/PPCRegisterInfo.cpp (revision 270019) ++++ lib/Target/PowerPC/PPCRegisterInfo.cpp (working copy) @@ -199,7 +199,16 @@ if (PPCFI->needsFP(MF)) Reserved.set(PPC::R31); @@ -1287,10 +1311,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp } bool PPCRegisterInfo::hasBasePointer(const MachineFunction &MF) const { -Index: contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h +Index: lib/Target/PowerPC/PPCSubtarget.h =================================================================== ---- contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h (revision 270019) -+++ contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h (working copy) +--- lib/Target/PowerPC/PPCSubtarget.h (revision 270019) ++++ lib/Target/PowerPC/PPCSubtarget.h (working copy) @@ -189,6 +189,9 @@ /// isBGQ - True if this is a BG/Q platform. bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; } diff --git a/contrib/llvm/patches/patch-r271024-llvm-r216989-fix-movm-armv6.diff b/contrib/llvm/patches/patch-r271024-llvm-r216989-fix-movm-armv6.diff deleted file mode 100644 index 30577e7d5658..000000000000 --- a/contrib/llvm/patches/patch-r271024-llvm-r216989-fix-movm-armv6.diff +++ /dev/null @@ -1,14 +0,0 @@ -Index: lib/Target/ARM/ARMInstrInfo.td -=================================================================== ---- lib/Target/ARM/ARMInstrInfo.td (revision 271024) -+++ lib/Target/ARM/ARMInstrInfo.td (revision 271026) -@@ -3248,7 +3248,8 @@ - def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR), - (SBCri GPR:$src, so_imm_not:$imm)>; - def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR), -- (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>; -+ (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>, -+ Requires<[IsARM, HasV6T2]>; - - // Note: These are implemented in C++ code, because they have to generate - // ADD/SUBrs instructions, which use a complex pattern that a xform function diff --git a/contrib/llvm/patches/patch-r271024-llvm-r216989-r216990-fix-movw-armv6.diff b/contrib/llvm/patches/patch-r271024-llvm-r216989-r216990-fix-movw-armv6.diff new file mode 100644 index 000000000000..f477390094dc --- /dev/null +++ b/contrib/llvm/patches/patch-r271024-llvm-r216989-r216990-fix-movw-armv6.diff @@ -0,0 +1,78 @@ +Pull in r216989 from upstream llvm trunk (by Renato Golin): + + MFV: Only emit movw on ARMv6T2+ + +Pull in r216990 from upstream llvm trunk (by Renato Golin): + + Missing test from r216989 + +Building for the FreeBSD default target ARMv6 was emitting movw ASM on certain +test cases (found building qmake4/5 for ARM). Don't do that, moreover, the AS +in base doesn't understand this instruction for this target. One would need +to use --integrated-as to get this to build if desired. + +Introduced here: http://svnweb.freebsd.org/changeset/base/271025 + +Index: lib/Target/ARM/ARMInstrInfo.td +=================================================================== +--- lib/Target/ARM/ARMInstrInfo.td ++++ lib/Target/ARM/ARMInstrInfo.td +@@ -3248,7 +3248,8 @@ + def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR), + (SBCri GPR:$src, so_imm_not:$imm)>; + def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR), +- (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>; ++ (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>, ++ Requires<[IsARM, HasV6T2]>; + + // Note: These are implemented in C++ code, because they have to generate + // ADD/SUBrs instructions, which use a complex pattern that a xform function +Index: test/CodeGen/ARM/carry.ll +=================================================================== +--- test/CodeGen/ARM/carry.ll ++++ test/CodeGen/ARM/carry.ll +@@ -1,4 +1,4 @@ +-; RUN: llc < %s -march=arm | FileCheck %s ++; RUN: llc < %s -mtriple=armv6t2-eabi | FileCheck %s + + define i64 @f1(i64 %a, i64 %b) { + ; CHECK-LABEL: f1: +Index: test/CodeGen/ARM/pr18364-movw.ll +=================================================================== +--- test/CodeGen/ARM/pr18364-movw.ll ++++ test/CodeGen/ARM/pr18364-movw.ll +@@ -0,0 +1,34 @@ ++; RUN: llc < %s -mtriple=armv5te | FileCheck %s --check-prefix=V5 ++; RUN: llc < %s -mtriple=armv6 | FileCheck %s --check-prefix=V6 ++; RUN: llc < %s -mtriple=armv6t2 | FileCheck %s --check-prefix=V6T2 ++; RUN: llc < %s -mtriple=armv7 | FileCheck %s --check-prefix=V7 ++; PR18364 ++ ++define i64 @f() #0 { ++entry: ++; V5-NOT: movw ++; V6-NOT: movw ++; V6T2: movw ++; V7: movw ++ %y = alloca i64, align 8 ++ %z = alloca i64, align 8 ++ store i64 1, i64* %y, align 8 ++ store i64 11579764786944, i64* %z, align 8 ++ %0 = load i64* %y, align 8 ++ %1 = load i64* %z, align 8 ++ %sub = sub i64 %0, %1 ++ ret i64 %sub ++} ++ ++define i64 @g(i64 %a, i32 %b) #0 { ++entry: ++; V5-NOT: movw ++; V6-NOT: movw ++; V6T2: movw ++; V7: movw ++ %0 = mul i64 %a, 86400000 ++ %mul = add i64 %0, -210866803200000 ++ %conv = sext i32 %b to i64 ++ %add = add nsw i64 %mul, %conv ++ ret i64 %add ++} diff --git a/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff b/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff new file mode 100644 index 000000000000..4088dbb6dc7d --- /dev/null +++ b/contrib/llvm/patches/patch-r271282-clang-r200797-r200798-r200805-debug-info-crash.diff @@ -0,0 +1,68 @@ +Pull in r200797 from upstream clang trunk (by Adrian Prantl): + + Debug info: fix a crasher when when emitting debug info for + not-yet-completed templated types. getTypeSize() needs a complete type. + + rdar://problem/15931354 + +Introduced here: http://svnweb.freebsd.org/changeset/base/271282 + +Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp +=================================================================== +--- tools/clang/lib/CodeGen/CGDebugInfo.cpp ++++ tools/clang/lib/CodeGen/CGDebugInfo.cpp +@@ -2251,9 +2251,10 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedTy + if (T && (!T.isForwardDecl() || !RD->getDefinition())) + return T; + +- // If this is just a forward declaration, construct an appropriately +- // marked node and just return it. +- if (!RD->getDefinition()) ++ // If this is just a forward or incomplete declaration, construct an ++ // appropriately marked node and just return it. ++ const RecordDecl *D = RD->getDefinition(); ++ if (!D || !D->isCompleteDefinition()) + return getOrCreateRecordFwdDecl(Ty, RDContext); + + uint64_t Size = CGM.getContext().getTypeSize(Ty); +Index: tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp +=================================================================== +--- tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp ++++ tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp +@@ -0,0 +1,36 @@ ++// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s ++// This test is for a crash when emitting debug info for not-yet-completed types. ++// Test that we don't actually emit a forward decl for the offending class: ++// CHECK: [ DW_TAG_class_type ] [Derived] {{.*}} [def] ++// rdar://problem/15931354 ++typedef const struct __CFString * CFStringRef; ++template class Returner {}; ++typedef const __CFString String; ++ ++template class Derived; ++ ++template ++class Base ++{ ++ static Derived* create(); ++}; ++ ++template ++class Derived : public Base { ++public: ++ static void foo(); ++}; ++ ++class Foo ++{ ++ Foo(); ++ static Returner > all(); ++}; ++ ++Foo::Foo(){} ++ ++Returner > Foo::all() ++{ ++ Derived::foo(); ++ return Foo::all(); ++} diff --git a/contrib/llvm/patches/patch-r271432-clang-r205331-debug-info-crash.diff b/contrib/llvm/patches/patch-r271432-clang-r205331-debug-info-crash.diff new file mode 100644 index 000000000000..a14020699363 --- /dev/null +++ b/contrib/llvm/patches/patch-r271432-clang-r205331-debug-info-crash.diff @@ -0,0 +1,43 @@ +Pull in r205331 from upstream clang trunk (by Adrian Prantl): + + Debug info: fix a crash when emitting IndirectFieldDecls, which were + previously not handled at all. + rdar://problem/16348575 + +Introduced here: http://svnweb.freebsd.org/changeset/base/271432 + +Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp +=================================================================== +--- tools/clang/lib/CodeGen/CGDebugInfo.cpp (revision 205330) ++++ tools/clang/lib/CodeGen/CGDebugInfo.cpp (revision 205331) +@@ -1252,7 +1252,7 @@ CollectTemplateParams(const TemplateParameterList + V = CGM.GetAddrOfFunction(FD); + // Member data pointers have special handling too to compute the fixed + // offset within the object. +- if (isa(D)) { ++ if (isa(D) || isa(D)) { + // These five lines (& possibly the above member function pointer + // handling) might be able to be refactored to use similar code in + // CodeGenModule::getMemberPointerConstant +Index: tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp +=================================================================== +--- tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (revision 0) ++++ tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (revision 205331) +@@ -0,0 +1,17 @@ ++// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s ++// ++// Test that indirect field decls are handled gracefully. ++// rdar://problem/16348575 ++// ++template class Foo { }; ++ ++struct Bar { ++ int i1; ++ // CHECK: [ DW_TAG_member ] [line [[@LINE+1]], size 32, align 32, offset 32] [from _ZTSN3BarUt_E] ++ union { ++ // CHECK: [ DW_TAG_member ] [i2] [line [[@LINE+1]], size 32, align 32, offset 0] [from int] ++ int i2; ++ }; ++}; ++ ++Foo the_foo; diff --git a/contrib/llvm/patches/patch-r271597-clang-r217410-i386-garbage-float.diff b/contrib/llvm/patches/patch-r271597-clang-r217410-i386-garbage-float.diff new file mode 100644 index 000000000000..c16279a6bc06 --- /dev/null +++ b/contrib/llvm/patches/patch-r271597-clang-r217410-i386-garbage-float.diff @@ -0,0 +1,64 @@ +Pull in r217410 from upstream llvm trunk (by Bob Wilson): + + Set trunc store action to Expand for all X86 targets. + + When compiling without SSE2, isTruncStoreLegal(F64, F32) would return + Legal, whereas with SSE2 it would return Expand. And since the Target + doesn't seem to actually handle a truncstore for double -> float, it + would just output a store of a full double in the space for a float + hence overwriting other bits on the stack. + + Patch by Luqman Aden! + +This should fix clang -O0 on i386 assigning garbage to floats, in +certain scenarios. + +Introduced here: http://svnweb.freebsd.org/changeset/base/271597 + +Index: lib/Target/X86/X86ISelLowering.cpp +=================================================================== +--- lib/Target/X86/X86ISelLowering.cpp (revision 208032) ++++ lib/Target/X86/X86ISelLowering.cpp (working copy) +@@ -300,6 +300,8 @@ void X86TargetLowering::resetOperationActions() { + setTruncStoreAction(MVT::i32, MVT::i8 , Expand); + setTruncStoreAction(MVT::i16, MVT::i8, Expand); + ++ setTruncStoreAction(MVT::f64, MVT::f32, Expand); ++ + // SETOEQ and SETUNE require checking two conditions. + setCondCodeAction(ISD::SETOEQ, MVT::f32, Expand); + setCondCodeAction(ISD::SETOEQ, MVT::f64, Expand); +@@ -1011,8 +1013,6 @@ void X86TargetLowering::resetOperationActions() { + AddPromotedToType (ISD::SELECT, VT, MVT::v2i64); + } + +- setTruncStoreAction(MVT::f64, MVT::f32, Expand); +- + // Custom lower v2i64 and v2f64 selects. + setOperationAction(ISD::LOAD, MVT::v2f64, Legal); + setOperationAction(ISD::LOAD, MVT::v2i64, Legal); +Index: test/CodeGen/X86/dont-trunc-store-double-to-float.ll +=================================================================== +--- test/CodeGen/X86/dont-trunc-store-double-to-float.ll (revision 0) ++++ test/CodeGen/X86/dont-trunc-store-double-to-float.ll (working copy) +@@ -0,0 +1,20 @@ ++; RUN: llc -march=x86 < %s | FileCheck %s ++ ++; CHECK-LABEL: @bar ++; CHECK: movl $1074339512, ++; CHECK: movl $1374389535, ++; CHECK: movl $1078523331, ++define void @bar() unnamed_addr { ++entry-block: ++ %a = alloca double ++ %b = alloca float ++ ++ store double 3.140000e+00, double* %a ++ %0 = load double* %a ++ ++ %1 = fptrunc double %0 to float ++ ++ store float %1, float* %b ++ ++ ret void ++} diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp index 8be351ead4ac..b7b9d8c6a3d9 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1241,7 +1241,7 @@ CollectTemplateParams(const TemplateParameterList *TPList, V = CGM.GetAddrOfFunction(FD); // Member data pointers have special handling too to compute the fixed // offset within the object. - if (isa(D)) { + if (isa(D) || isa(D)) { // These five lines (& possibly the above member function pointer // handling) might be able to be refactored to use similar code in // CodeGenModule::getMemberPointerConstant @@ -2235,9 +2235,10 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { if (T && (!T.isForwardDecl() || !RD->getDefinition())) return T; - // If this is just a forward declaration, construct an appropriately - // marked node and just return it. - if (!RD->getDefinition()) + // If this is just a forward or incomplete declaration, construct an + // appropriately marked node and just return it. + const RecordDecl *D = RD->getDefinition(); + if (!D || !D->isCompleteDefinition()) return getOrCreateRecordFwdDecl(Ty, RDContext); uint64_t Size = CGM.getContext().getTypeSize(Ty); diff --git a/contrib/netbsd-tests/FREEBSD-upgrade b/contrib/netbsd-tests/FREEBSD-upgrade new file mode 100644 index 000000000000..edeba708cb18 --- /dev/null +++ b/contrib/netbsd-tests/FREEBSD-upgrade @@ -0,0 +1,38 @@ +$FreeBSD$ + +This document contains a collection of notes specific to the import +of the NetBSD test suite into head. These notes are built on the instructions +in the FreeBSD Subversion Primer that detail how to deal with vendor +branches and you are supposed to follow those: + + http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html + +The NetBSD test source code was originally obtained via NetBSD anoncvs as +described in the NetBSD handbook: + + http://www.netbsd.org/docs/guide/en/chap-fetch.html#chap-fetch-cvs + +and is imported into the NetBSD/tests vendor branch (see +base/vendor/NetBSD/tests/). + +The process used to bootstrap the vendor tree was similar to the following: + + /bin/sh + export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot" + cvs -z9 co -D "09/30/2014 20:45" -P src/tests + mv src/tests/* tests/dist/. + +Please adjust the checkout date spec (the argument passed via -D) to match +the desired checkout time. + +To merge the vendor branch into head do something like this: + + cd .../base/head/contrib/netbsd-tests + svn merge --accept=postpone \ + svn+ssh://svn.freebsd.org/base/vendor/NetBSD/tests/dist . + find . -name Makefile\* | xargs svn rm --force + +and resolve any conflicts that may arise at this point. + +Lastly, with the list of old and new files in this import, make sure +to update the reachover Makefiles accordingly. diff --git a/contrib/netbsd-tests/bin/cat/d_align.in b/contrib/netbsd-tests/bin/cat/d_align.in new file mode 100644 index 000000000000..31bf4a7a143f --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/d_align.in @@ -0,0 +1,3 @@ +a b c +1 2 3 +x y z diff --git a/contrib/netbsd-tests/bin/cat/d_align.out b/contrib/netbsd-tests/bin/cat/d_align.out new file mode 100644 index 000000000000..fd324697185b --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/d_align.out @@ -0,0 +1,3 @@ + 1 a b c$ + 2 1 2 3$ + 3 x y z$ diff --git a/contrib/netbsd-tests/bin/cat/t_cat.sh b/contrib/netbsd-tests/bin/cat/t_cat.sh new file mode 100755 index 000000000000..1b7a9307eeeb --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/t_cat.sh @@ -0,0 +1,59 @@ +# $NetBSD: t_cat.sh,v 1.2 2012/03/27 17:57:02 jruoho Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case align +align_head() { + atf_set "descr" "Test that cat(1) aligns the output " \ + "right with options '-be' (PR bin/4841)" +} + +align_body() { + + atf_check -s ignore -o file:$(atf_get_srcdir)/d_align.out \ + -x "cat -be $(atf_get_srcdir)/d_align.in" +} + +atf_test_case nonexistent +nonexistent_head() { + atf_set "descr" "Test that cat(1) doesn't return zero exit " \ + "status for a nonexistent file (PR bin/3538)" +} + +nonexistent_body() { + + atf_check -s not-exit:0 -o empty -e not-empty \ + -x "cat /some/name/that/does/not/exist" +} + +atf_init_test_cases() +{ + atf_add_test_case align + atf_add_test_case nonexistent +} diff --git a/contrib/netbsd-tests/bin/cp/t_cp.sh b/contrib/netbsd-tests/bin/cp/t_cp.sh new file mode 100755 index 000000000000..be55c7cb0ef3 --- /dev/null +++ b/contrib/netbsd-tests/bin/cp/t_cp.sh @@ -0,0 +1,294 @@ +# $NetBSD: t_cp.sh,v 1.1 2012/03/17 16:33:10 jruoho Exp $ +# +# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +FILES="file file2 file3 link dir dir2 dirlink target" + +cleanup() { + rm -fr ${FILES} +} + +cp_compare() { + echo "Ensuring that $2 and $3 are identical" + cmp -s $2 $3 || atf_fail "$2 and $3 are different" +} + +reset() { + cleanup + echo "I'm a file" > file + echo "I'm a file, 2" > file2 + echo "I'm a file, 3" > file3 + ln -s file link + mkdir dir + ln -s dir dirlink +} + +atf_test_case file_to_file +file_to_file_head() { + atf_set "descr" "Checks the copy of a file to a file" +} +file_to_file_body() { + reset + + file_to_file_simple + file_to_file_preserve + file_to_file_noflags +} + +file_to_file_simple() { + rm -f file2 + umask 022 + chmod 777 file + atf_check -s eq:0 -o empty -e empty cp file file2 + cp_compare file_to_file_simple file file2 + if [ `stat -f "%Lp" file2` != "755" ]; then + atf_fail "new file not created with umask" + fi + + chmod 644 file + chmod 777 file2 + cp_compare file_to_file_simple file file2 + if [ `stat -f "%Lp" file2` != "777" ]; then + atf_fail "existing files permissions not retained" + fi +} + +file_to_file_preserve() { + rm file3 + chmod 644 file + chflags nodump file + atf_check -s eq:0 -o empty -e empty cp -p file file3 + finfo=`stat -f "%p%u%g%m%z%f" file` + f3info=`stat -f "%p%u%g%m%z%f" file3` + if [ $finfo != $f3info ]; then + atf_fail "attributes not preserved" + fi +} + +file_to_file_noflags() { + rm file3 + chmod 644 file + chflags nodump file + atf_check -s eq:0 -o empty -e empty cp -p -N file file3 + finfo=`stat -f "%f" file` + f3info=`stat -f "%f" file3` + if [ $finfo = $f3info ]; then + atf_fail "-p -N preserved file flags" + fi +} + +atf_test_case file_to_link +file_to_link_head() { + atf_set "descr" "Checks the copy of a file to a symbolic link" +} +file_to_link_body() { + reset + atf_check -s eq:0 -o empty -e empty cp file2 link + cp_compare file_to_link file file2 +} + +atf_test_case link_to_file +link_to_file_head() { + atf_set "descr" "Checks the copy of a symbolic link to a file" +} +link_to_file_body() { + reset + # file and link are identical (not copied). + atf_check -s eq:1 -o empty -e ignore cp link file + atf_check -s eq:0 -o empty -e empty cp link file2 + cp_compare link_to_file file file2 +} + +atf_test_case file_over_link +file_over_link_head() { + atf_set "descr" "Checks the copy of a file to a symbolic link" \ + "without following it" +} +file_over_link_body() { + reset + atf_check -s eq:0 -o empty -e empty cp -P file link + cp_compare file_over_link file link +} + +atf_test_case link_over_file +link_over_file_head() { + atf_set "descr" "Checks the copy of a symbolic link to a file" \ + "without following the former" +} +link_over_file_body() { + reset + atf_check -s eq:0 -o empty -e empty cp -P link file + if [ `readlink link` != `readlink file` ]; then + atf_fail "readlink link != readlink file" + fi +} + +atf_test_case files_to_dir +files_to_dir_head() { + atf_set "descr" "Checks the copy of multiple files into a directory" +} +files_to_dir_body() { + reset + # can't copy multiple files to a file + atf_check -s eq:1 -o empty -e ignore cp file file2 file3 + atf_check -s eq:0 -o empty -e empty cp file file2 link dir + cp_compare files_to_dir file "dir/file" +} + +atf_test_case dir_to_file +dir_to_file_head() { + atf_set "descr" "Checks the copy of a directory onto a file, which" \ + "should not work" +} +dir_to_file_body() { + reset + # can't copy a dir onto a file + atf_check -s eq:1 -o empty -e ignore cp dir file + atf_check -s eq:1 -o empty -e ignore cp -R dir file +} + +atf_test_case file_to_linkdir +file_to_linkdir_head() { + atf_set "descr" "Checks the copy of a file to a symbolic link that" \ + "points to a directory" +} +file_to_linkdir_body() { + reset + atf_check -s eq:0 -o empty -e empty cp file dirlink + cp_compare file_to_linkdir file "dir/file" + + # overwrite the link + atf_check -s eq:0 -o empty -e empty cp -P file dirlink + atf_check -s eq:1 -o empty -e empty readlink dirlink + cp_compare file_to_linkdir file dirlink +} + +atf_test_case linkdir_to_file +linkdir_to_file_head() { + atf_set "descr" "Checks the copy of a symbolic link that points to" \ + "a directory onto a file" +} +linkdir_to_file_body() { + reset + # cannot copy a dir onto a file + atf_check -s eq:1 -o empty -e ignore cp dirlink file + + # overwrite the link + atf_check -s eq:0 -o empty -e empty cp -P dirlink file + if [ `readlink file` != `readlink dirlink` ]; then + atf_fail "readlink link != readlink file" + fi +} + +dir_to_dne_no_R() { + atf_check -s eq:1 -o empty -e ignore cp dir dir2 +} + +dir_to_dne() { + atf_check -s eq:0 -o empty -e empty cp -R dir dir2 + cp_compare dir_to_dne "dir/file" "dir2/file" + readlink dir2/link >/dev/null + if [ $? -gt 0 ]; then + atf_fail "-R didn't copy a link as a link" + fi +} + +dir_to_dir_H() { + dir_to_dir_setup + atf_check -s eq:0 -o empty -e empty cp -R dir dir2 + + chmod 777 dir + + # copy a dir into a dir, only command-line links are followed + atf_check -s eq:0 -o empty -e empty cp -R -H dirlink dir2 + cp_compare dir_to_dir_H "dir/file" "dir2/dirlink/file" + readlink dir2/dirlink/link >/dev/null + if [ $? -gt 0 ]; then + atf_fail "didn't copy a link as a link" + fi + + # Created directories have the same mode as the corresponding + # source directory, unmodified by the process's umask. + if [ `stat -f "%Lp" dir2/dirlink` != "777" ]; then + atf_fail "-R modified dir perms with umask" + fi +} + +dir_to_dir_L() { + dir_to_dir_setup + atf_check -s eq:0 -o empty -e empty cp -R dir dir2 + atf_check -s eq:0 -o empty -e empty cp -R -H dirlink dir2 + + # copy a dir into a dir, following all links + atf_check -s eq:0 -o empty -e empty cp -R -H -L dirlink dir2/dirlink + cp_compare dir_to_dir_L "dir/file" "dir2/dirlink/dirlink/file" + # fail if -R -L copied a link as a link + atf_check -s eq:1 -o ignore -e empty readlink dir2/dirlink/dirlink/link +} + +dir_to_dir_subdir_exists() { + # recursively copy a dir into another dir, with some subdirs already + # existing + cleanup + + mkdir -p dir/1 dir/2 dir/3 target/2 + echo "file" > dir/2/file + atf_check -s eq:0 -o empty -e empty cp -R dir/* target + cp_compare dir_to_dir_subdir_exists "dir/2/file" "target/2/file" +} + +dir_to_dir_setup() { + reset + umask 077 + cp -P file file2 file3 link dir +} + +atf_test_case dir_to_dir +dir_to_dir_head() { + atf_set "descr" "Checks the copy of a directory onto another directory" +} +dir_to_dir_body() { + dir_to_dir_setup + dir_to_dne_no_R + dir_to_dne + dir_to_dir_H + dir_to_dir_L + dir_to_dir_subdir_exists +} + +atf_init_test_cases() +{ + atf_add_test_case file_to_file + atf_add_test_case file_to_link + atf_add_test_case link_to_file + atf_add_test_case file_over_link + atf_add_test_case link_over_file + atf_add_test_case files_to_dir + atf_add_test_case file_to_linkdir + atf_add_test_case linkdir_to_file + atf_add_test_case dir_to_file + atf_add_test_case dir_to_dir +} diff --git a/contrib/netbsd-tests/bin/dd/t_dd.sh b/contrib/netbsd-tests/bin/dd/t_dd.sh new file mode 100755 index 000000000000..d713ad9cb246 --- /dev/null +++ b/contrib/netbsd-tests/bin/dd/t_dd.sh @@ -0,0 +1,130 @@ +# $NetBSD: t_dd.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +test_dd_length() { + result=$1 + cmd=$2 + set -- x `eval $cmd | wc -c` + res=$2 + if [ x"$res" != x"$result" ]; then + atf_fail "Expected $result bytes of output, got $res: $cmd" + fi +} + +atf_test_case length +length_head() { + # XXX The PR should be stored in a tag. + atf_set "descr" "Test for result messages accidentally pumped into" \ + "the output file if the standard IO descriptors are" \ + "closed. The last of the three following tests is" \ + "the one expected to fail. (NetBSD PR bin/8521)" +} +length_body() { + test_dd_length 512 \ + "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >/dev/null 2>/dev/null" + test_dd_length 512 \ + "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >&- 2>/dev/null" + test_dd_length 512 \ + "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >&- 2>&-" +} + +test_dd_io() { + res="`echo -n "$2" | eval $1`" + if [ x"$res" != x"$3" ]; then + atf_fail "Expected \"$3\", got \"$res\": $1" + fi +} + +allbits1="\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" + +ebcdicbits1="\000\001\002\003\067\055\056\057\026\005\045\013\014\015\016\017\020\021\022\023\074\075\062\046\030\031\077\047\034\035\036\037\100\132\177\173\133\154\120\175\115\135\134\116\153\140\113\141\360\361\362\363\364\365\366\367\370\371\172\136\114\176\156\157\174\301\302\303\304\305\306\307\310\311\321\322\323\324\325\326\327\330\331\342\343\344\345\346\347\350\351\255\340\275\232\155\171\201\202\203\204\205\206\207\210\211\221\222\223\224\225\226\227\230\231\242\243\244\245\246\247\250\251\300\117\320\137\007\040\041\042\043\044\025\006\027\050\051\052\053\054\011\012\033\060\061\032\063\064\065\066\010\070\071\072\073\004\024\076\341\101\102\103\104\105\106\107\110\111\121\122\123\124\125\126\127\130\131\142\143\144\145\146\147\150\151\160\161\162\163\164\165\166\167\170\200\212\213\214\215\216\217\220\152\233\234\235\236\237\240\252\253\254\112\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\241\276\277\312\313\314\315\316\317\332\333\334\335\336\337\352\353\354\355\356\357\372\373\374\375\376\377" + +allvisbits=`echo -n "$allbits1" | unvis | vis` +ebcdicvisbits=`echo -n "$ebcdicbits1" | unvis | vis` + +atf_test_case io +io_head() { + atf_set "descr" "This checks the combination of bs= with" \ + "conv=ebcdic. Prior to revision 1.24 of dd's" \ + "args.c, the conv option would be ignored." +} +io_body() { + test_dd_io "unvis | dd 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + test_dd_io "unvis | dd ibs=1 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + test_dd_io "unvis | dd obs=1 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + test_dd_io "unvis | dd bs=1 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + + test_dd_io "unvis | dd conv=ebcdic 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic ibs=512 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic obs=512 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic bs=512 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + + test_dd_io "unvis | dd conv=ebcdic 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic ibs=1 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic obs=1 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic bs=1 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" +} + +atf_test_case seek +seek_head() { + atf_set "descr" "Tests output file seeking" +} + +seek_body() { + echo TEST1234 > testfile + atf_check -s exit:0 -e ignore \ + dd if=/dev/zero of=testfile seek=1 bs=8k count=1 + atf_check -s exit:0 -e ignore -o match:'^TEST1234$' dd if=testfile + eval $(stat -s testfile) + atf_check_equal $st_size $((2*8192)) + + echo -n TEST1234 > tf2 + atf_check -s exit:0 -e ignore -x \ + 'dd bs=4 if=/dev/zero count=1 | tr \\0 \\n | dd of=tf2 bs=4 seek=1' + atf_check -s exit:0 -e ignore -o match:'^TEST$' dd if=tf2 + eval $(stat -s tf2) + atf_check_equal $st_size 8 +} + +atf_init_test_cases() +{ + atf_add_test_case length + atf_add_test_case io + atf_add_test_case seek +} diff --git a/contrib/netbsd-tests/bin/df/getmntinfo.c b/contrib/netbsd-tests/bin/df/getmntinfo.c new file mode 100644 index 000000000000..4ad1f40ce6be --- /dev/null +++ b/contrib/netbsd-tests/bin/df/getmntinfo.c @@ -0,0 +1,218 @@ +/* $NetBSD: getmntinfo.c,v 1.1 2012/03/17 16:33:11 jruoho Exp $ */ +/* + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include + +#include +#include +#include + +#define KB * 1024 +#define MB * 1024 KB +#define GB * 1024 MB + +static struct statvfs *getnewstatvfs(void); +static void other_variants(const struct statvfs *, const int *, int, + const int *, int); +static void setup_filer(void); +static void setup_ld0g(void); +static void setup_strpct(void); + +static struct statvfs *allstatvfs; +static int sftotal, sfused; + +struct statvfs * +getnewstatvfs(void) +{ + + if (sftotal == sfused) { + sftotal = sftotal ? sftotal * 2 : 1; + allstatvfs = realloc(allstatvfs, + sftotal * sizeof(struct statvfs)); + if (allstatvfs == NULL) + err(EXIT_FAILURE, "realloc"); + } + + return (&allstatvfs[sfused++]); +} + +void +other_variants(const struct statvfs *tmpl, const int *minfree, int minfreecnt, + const int *consumed, int consumedcnt) +{ + int64_t total, used; + struct statvfs *sf; + int i, j; + + for (i = 0; i < minfreecnt; i++) + for (j = 0; j < consumedcnt; j++) { + sf = getnewstatvfs(); + *sf = *tmpl; + total = (int64_t)(u_long)sf->f_blocks * sf->f_bsize; + used = total * consumed[j] / 100; + sf->f_bfree = (total - used) / sf->f_bsize; + sf->f_bavail = (total * (100 - minfree[i]) / 100 - + used) / (int)sf->f_bsize; + sf->f_bresvd = sf->f_bfree - sf->f_bavail; + } +} + +/* + * Parameter taken from: + * http://mail-index.NetBSD.org/tech-userlevel/2004/03/24/0001.html + */ +void +setup_filer(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 512 +#define TOTAL 1147ULL GB +#define USED 132ULL MB + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL / BSIZE, + .f_bfree = (TOTAL - USED) / BSIZE, + .f_bavail = (TOTAL - USED) / BSIZE, + .f_bresvd = 0, + .f_mntfromname = "filer:/", + .f_mntonname = "/filer", +#undef USED +#undef TOTAL +#undef BSIZE + }; + static const int minfree[] = { 0, 5, 10, 15, }; + static const int consumed[] = { 0, 20, 60, 95, 100 }; + + *getnewstatvfs() = tmpl; + other_variants(&tmpl, minfree, sizeof(minfree) / sizeof(minfree[0]), + consumed, sizeof(consumed) / sizeof(consumed[0])); +} + +/* + * Parameter taken from: + * http://mail-index.NetBSD.org/current-users/2004/03/01/0038.html + */ +void +setup_ld0g(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 4096 /* Guess */ +#define TOTAL 1308726116ULL KB +#define USED 17901268ULL KB +#define AVAIL 1225388540ULL KB + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL / BSIZE, + .f_bfree = (TOTAL - USED) / BSIZE, + .f_bavail = AVAIL / BSIZE, + .f_bresvd = (TOTAL - USED) / BSIZE - AVAIL / BSIZE, + .f_mntfromname = "/dev/ld0g", + .f_mntonname = "/anon-root", +#undef AVAIL +#undef USED +#undef TOTAL +#undef BSIZE + }; + static const int minfree[] = { 0, 5, 10, 15, }; + static const int consumed[] = { 0, 20, 60, 95, 100 }; + + *getnewstatvfs() = tmpl; + other_variants(&tmpl, minfree, sizeof(minfree) / sizeof(minfree[0]), + consumed, sizeof(consumed) / sizeof(consumed[0])); +} + +/* + * Test of strpct() with huge number. + */ +void +setup_strpct(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 4096 /* Guess */ +#define TOTAL 0x4ffffffffULL KB +#define USED (TOTAL / 2) +#define AVAIL (TOTAL / 2) + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL / BSIZE, + .f_bfree = (TOTAL - USED) / BSIZE, + .f_bavail = AVAIL / BSIZE, + .f_bresvd = (TOTAL - USED) / BSIZE - AVAIL / BSIZE, + .f_mntfromname = "/dev/strpct", + .f_mntonname = "/strpct", +#undef AVAIL +#undef USED +#undef TOTAL +#undef BSIZE + }; + + *getnewstatvfs() = tmpl; +} + +/* + * Parameter taken from: + * http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=23600 + */ +static void +setup_pr23600(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 512 +#define TOTAL 20971376ULL +#define USED 5719864ULL +#define AVAIL 15251512ULL + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL, + .f_bfree = TOTAL - USED, + .f_bavail = AVAIL, + .f_bresvd = TOTAL - USED - AVAIL, + .f_mntfromname = "/dev/wd0e", + .f_mntonname = "/mount/windows/C", +#undef AVAIL +#undef USED +#undef TOTAL +#undef BSIZE + }; + + *getnewstatvfs() = tmpl; +} + +int +getmntinfo(struct statvfs **mntbuf, int flags) +{ + + setup_filer(); + setup_ld0g(); + setup_strpct(); + setup_pr23600(); + + *mntbuf = allstatvfs; + return (sfused); +} diff --git a/contrib/netbsd-tests/bin/df/t_df.sh b/contrib/netbsd-tests/bin/df/t_df.sh new file mode 100755 index 000000000000..ffb5aad3e0d0 --- /dev/null +++ b/contrib/netbsd-tests/bin/df/t_df.sh @@ -0,0 +1,148 @@ +# $NetBSD: t_df.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case normal +normal_head() { + atf_set "descr" "Checks that the output of df without flags is" \ + "correct according to some already-known, sane" \ + "output" +} +normal_body() { + cat >expout <expout <&1` + if [ "$res" != "$2" ]; then + atf_fail "Expected $2, got $res from expression: " \ + "`eval echo $1`" + fi +} + +atf_test_case lang +lang_ops_head() { + atf_set "descr" "Test that expr(1) works with non-C LANG (PR bin/2486)" +} +lang_body() { + + export LANG=nonexistent + atf_check -s exit:0 -o inline:"21\n" -e empty -x "expr 10 + 11" + + export LANG=ru_RU.KOI8-R + atf_check -s exit:0 -o inline:"21\n" -e empty -x "expr 10 + 11" +} + +atf_test_case overflow +overflow_head() { + atf_set "descr" "Test overflow cases" +} +overflow_body() { + test_expr '4611686018427387904 + 4611686018427387903' \ + '9223372036854775807' + test_expr '4611686018427387904 + 4611686018427387904' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 + 4611686018427387904'" + test_expr '4611686018427387904 - -4611686018427387904' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 - -4611686018427387904'" + test_expr '-4611686018427387904 - 4611686018427387903' \ + '-9223372036854775807' + test_expr '-4611686018427387904 - 4611686018427387905' \ + "expr: integer overflow or underflow occurred for operation '-4611686018427387904 - 4611686018427387905'" + test_expr '-4611686018427387904 \* 1' '-4611686018427387904' + test_expr '-4611686018427387904 \* -1' '4611686018427387904' + test_expr '-4611686018427387904 \* 2' '-9223372036854775808' + test_expr '-4611686018427387904 \* 3' \ + "expr: integer overflow or underflow occurred for operation '-4611686018427387904 * 3'" + test_expr '-4611686018427387904 \* -2' \ + "expr: integer overflow or underflow occurred for operation '-4611686018427387904 * -2'" + test_expr '4611686018427387904 \* 1' '4611686018427387904' + test_expr '4611686018427387904 \* 2' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 * 2'" + test_expr '4611686018427387904 \* 3' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 * 3'" +} + +atf_test_case gtkmm +gtkmm_head() { + atf_set "descr" "Test from gtk-- configure that cause problems on old expr" +} +gtkmm_body() { + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 5' '1' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 6' '0' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 3 \& 5 \>= 5' '0' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 2 \& 4 = 4 \& 5 \>= 5' '0' + test_expr '3 \> 2 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 6' '1' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 3 \| 3 = 3 \& 4 = 4 \& 5 \>= 5' '1' +} + +atf_test_case colon_vs_math +colon_vs_math_head() { + atf_set "descr" "Basic precendence test with the : operator vs. math" +} +colon_vs_math_body() { + test_expr '2 : 4 / 2' '0' + test_expr '4 : 4 % 3' '1' +} + +atf_test_case arithmetic_ops +arithmetic_ops_head() { + atf_set "descr" "Dangling arithemtic operator" +} +arithmetic_ops_body() { + test_expr '.java_wrapper : /' '0' + test_expr '4 : \*' '0' + test_expr '4 : +' '0' + test_expr '4 : -' '0' + test_expr '4 : /' '0' + test_expr '4 : %' '0' +} + +atf_test_case basic_math +basic_math_head() { + atf_set "descr" "Basic math test" +} +basic_math_body() { + test_expr '2 + 4 \* 5' '22' +} + +atf_test_case basic_functional +basic_functional_head() { + atf_set "descr" "Basic functional tests" +} +basic_functional_body() { + test_expr '2' '2' + test_expr '-4' '-4' + test_expr 'hello' 'hello' +} + +atf_test_case compare_ops_precedence +compare_ops_precedence_head() { + atf_set "descr" "Compare operator precendence test" +} +compare_ops_precedence_body() { + test_expr '2 \> 1 \* 17' '0' +} + +atf_test_case compare_ops +compare_ops_head() { + atf_set "descr" "Compare operator tests" +} +compare_ops_body() { + test_expr '2 \!= 5' '1' + test_expr '2 \!= 2' '0' + test_expr '2 \<= 3' '1' + test_expr '2 \<= 2' '1' + test_expr '2 \<= 1' '0' + test_expr '2 \< 3' '1' + test_expr '2 \< 2' '0' + test_expr '2 = 2' '1' + test_expr '2 = 4' '0' + test_expr '2 \>= 1' '1' + test_expr '2 \>= 2' '1' + test_expr '2 \>= 3' '0' + test_expr '2 \> 1' '1' + test_expr '2 \> 2' '0' +} + +atf_test_case multiply +multiply_head() { + atf_set "descr" "Test the multiply operator (PR bin/12838)" +} +multiply_body() { + test_expr '1 \* -1' '-1' + test_expr '2 \> 1 \* 17' '0' +} + +atf_test_case negative +negative_head() { + atf_set "descr" "Test the additive inverse" +} +negative_body() { + test_expr '-1 + 5' '4' + test_expr '- 1 + 5' 'expr: syntax error' + + test_expr '5 + -1' '4' + test_expr '5 + - 1' 'expr: syntax error' + + test_expr '1 - -5' '6' +} + +atf_test_case math_precedence +math_precedence_head() { + atf_set "descr" "More complex math test for precedence" +} +math_precedence_body() { + test_expr '-3 + -1 \* 4 + 3 / -6' '-7' +} + +atf_test_case precedence +precedence_head() { + atf_set "descr" "Test precedence" +} +precedence_body() { + # This is messy but the shell escapes cause that + test_expr 'X1/2/3 : X\\\(.\*[^/]\\\)//\*[^/][^/]\*/\*$ \| . : \\\(.\\\)' '1/2' +} + +atf_test_case regex +regex_head() { + atf_set "descr" "Test proper () returning \1 from a regex" +} +regex_body() { + # This is messy but the shell escapes cause that + test_expr '1/2 : .\*/\\\(.\*\\\)' '2' +} + +atf_init_test_cases() +{ + atf_add_test_case lang + atf_add_test_case overflow + atf_add_test_case gtkmm + atf_add_test_case colon_vs_math + atf_add_test_case arithmetic_ops + atf_add_test_case basic_math + atf_add_test_case basic_functional + atf_add_test_case compare_ops_precedence + atf_add_test_case compare_ops + atf_add_test_case multiply + atf_add_test_case negative + atf_add_test_case math_precedence + atf_add_test_case precedence + atf_add_test_case regex +} diff --git a/contrib/netbsd-tests/bin/pax/t_pax.sh b/contrib/netbsd-tests/bin/pax/t_pax.sh new file mode 100755 index 000000000000..63ae7f8965ce --- /dev/null +++ b/contrib/netbsd-tests/bin/pax/t_pax.sh @@ -0,0 +1,54 @@ +# $NetBSD: t_pax.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case append +append_head() { + atf_set "descr" "Ensure that appending a file to an archive" \ + "produces the same results as if the file" \ + "had been there during the archive's creation" +} +append_body() { + touch foo bar + + # store both foo and bar into file1.tar + atf_check -s eq:0 -o empty -e empty \ + pax -w -b 512 -x ustar -f file1.tar foo bar + + # store foo into file2.tar, then append bar to file2.tar + atf_check -s eq:0 -o empty -e empty \ + pax -w -b 512 -x ustar -f file2.tar foo + atf_check -s eq:0 -o empty -e empty \ + pax -w -b 512 -x ustar -f file2.tar -a bar + + # ensure that file1.tar and file2.tar are equal + atf_check -s eq:0 -o empty -e empty cmp file1.tar file2.tar +} + +atf_init_test_cases() +{ + atf_add_test_case append +} diff --git a/contrib/netbsd-tests/bin/ps/keywords b/contrib/netbsd-tests/bin/ps/keywords new file mode 100644 index 000000000000..3f05f5464b84 --- /dev/null +++ b/contrib/netbsd-tests/bin/ps/keywords @@ -0,0 +1,123 @@ +# $NetBSD: keywords,v 1.2 2014/01/16 04:16:32 mlelstv Exp $ +# +# Table of keywords for use with ps "-o" option. +# +# The first column (keyword) is the name of a keyword. +# +# The second column (header) is the default column header associated +# with the keyword, except if the keyword is an alias, in which case the +# second column is the name of another keyword. +# +# The third column (flag) may be blank, "LJUST", or "ALIAS". "ALIAS" +# means that the keyword is an alias. "LJUST" means that the keyword +# should be displayed in a left-justified column. The default is that +# the keyword should be displayed in a right-justified column. +# +# keyword header flag +# +ktracep KTRACEP +nwchan WCHAN +p_ru P_RU +paddr PADDR +rlink RLINK +%cpu %CPU +%mem %MEM +acflag ACFLG +acflg acflag ALIAS +args command ALIAS +blocked sigmask ALIAS +caught sigcatch ALIAS +comm COMMAND LJUST +command COMMAND LJUST +cpu CPU +cputime time ALIAS +ctime CTIME +egid EGID +egroup EGROUP LJUST +etime ELAPSED +euid EUID +euser EUSER LJUST +f F +flags f ALIAS +gid GID +group GROUP LJUST +groupnames GROUPNAMES LJUST +groups GROUPS LJUST +holdcnt HOLDCNT +ignored sigignore ALIAS +inblk INBLK +inblock inblk ALIAS +jobc JOBC +ktrace KTRACE +laddr LADDR +lid LID +lim LIM +login LOGIN LJUST +logname login ALIAS +lstart STARTED LJUST +lstate STAT LJUST +ltime LTIME +majflt MAJFLT +minflt MINFLT +msgrcv MSGRCV +msgsnd MSGSND +ni nice ALIAS +nice NI +nivcsw NIVCSW +nlwp NLWP +nsignals nsigs ALIAS +nsigs NSIGS +nswap NSWAP +nvcsw NVCSW +oublk OUBLK +oublock oublk ALIAS +pagein PAGEIN +pcpu %cpu ALIAS +pending sig ALIAS +pgid PGID +pid PID +pmem %mem ALIAS +ppid PPID +pri PRI +re RE +rgid RGID +rgroup RGROUP LJUST +rlwp RLWP +rss RSS +rssize rsz ALIAS +rsz RSZ +ruid RUID +ruser RUSER LJUST +sess SESS +sid SID +sig PENDING +sigcatch CAUGHT +sigignore IGNORED +sigmask BLOCKED +sl SL +start STARTED +stat state ALIAS +state STAT LJUST +stime STIME +svgid SVGID +svgroup SVGROUP LJUST +svuid SVUID +svuser SVUSER LJUST +tdev TDEV +time TIME +tpgid TPGID +tsess TSESS +tsiz TSIZ +tt TTY LJUST +tty TTY LJUST +uaddr UADDR +ucomm UCOMM LJUST +uid UID +upr UPR +user USER LJUST +usrpri upr ALIAS +utime UTIME +vsize vsz ALIAS +vsz VSZ +wchan WCHAN LJUST +xstat XSTAT diff --git a/contrib/netbsd-tests/bin/ps/t_ps.sh b/contrib/netbsd-tests/bin/ps/t_ps.sh new file mode 100755 index 000000000000..8f8829bc3543 --- /dev/null +++ b/contrib/netbsd-tests/bin/ps/t_ps.sh @@ -0,0 +1,404 @@ +# $NetBSD: t_ps.sh,v 1.2 2014/01/16 04:16:32 mlelstv Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# the implementation of "ps" to test +: ${TEST_PS:="ps"} +# tab and newline characters +tab="$(printf '\t')" +# nl="$(printf '\n')" doesn't work +nl=' +' + +# +# Parse the "keywords" file into a load of shell variables +# +setup_keywords() +{ + # Set variables representing the header text + # for all normal keywords (except aliases), and + # for regular expressions to match the text in left- or + # right-justified columns. + # For example, head_text_p_cpu="%CPU" head_regexp_p_cpu=" *%CPU". + while read keyword heading flag + do + case "$keyword" in + ''|\#*) continue + ;; + esac + [ x"$flag" = x"ALIAS" ] && continue + kvar="${keyword}" + case "${keyword}" in + %*) kvar="p_${keyword#%}" + ;; + esac + eval head_text_${kvar}=\'"${heading}"\' + case "${flag}" in + '') # right justified + eval head_regexp_${kvar}=\'" *${heading}"\' + ;; + LJUST) # left justified + eval head_regexp_${kvar}=\'"${heading} *"\' + ;; + *) atf_fail "unknown flag in keywords" + ;; + esac + done <"$(atf_get_srcdir)/keywords" + + # Now do the aliases. + while read keyword heading flag + do + case "$keyword" in + ''|\#*) continue + ;; + esac + [ x"$flag" != x"ALIAS" ] && continue + kvar="${keyword}" + avar="${heading}" + case "${keyword}" in + %*) kvar="p_${keyword#%}" + ;; + esac + case "${heading}" in + %*) avar="p_${heading#%}" + ;; + esac + eval head_text_${kvar}=\"\$head_text_${avar}\" + eval head_regexp_${kvar}=\"\$head_regexp_${avar}\" + done <"$(atf_get_srcdir)/keywords" + + # default sets of keywords + default_keywords='pid tty stat time command' + j_keywords='user pid ppid pgid sess jobc state tt time command' + l_keywords='uid pid ppid cpu pri nice vsz rss wchan state tt time command' + s_keywords='uid pid ppid cpu lid nlwp pri nice vsz rss wchan lstate tt ltime command' + u_keywords='user pid %cpu %mem vsz rss tt state start time command' + v_keywords='pid state time sl re pagein vsz rss lim tsiz %cpu %mem command' +} + +# Convert a list of keywords like "pid comm" to a regexp +# like " *PID COMMAND *" +heading_keywords_to_regexp() +{ + local keywords="$1" + local regexp + regexp="$(echo "$keywords" | \ + sed -E -e 's/\%/p_/g' -e 's/(^| )/\1\$head_regexp_/g')" + eval regexp=\""${regexp}"\" + regexp="^${regexp}\$" + echo "$regexp" +} + +# +# Check that a string matches a regexp; use the specified id +# in error or success messages. +# +check_regexp() { + local id="$1" string="$2" regexp="$3" + if ! expr "$string" : "$regexp" >/dev/null + then + atf_fail "${id}: expected [${regexp}], got [${string}]" + false + fi +} + +# +# Run "ps $args -p $$"; check that only one line is printed, +# without a preceding header line. +# +check_no_heading_line() +{ + local args="$1" + local output="$(eval "${TEST_PS} $args -p $$")" + case "$output" in + *"$nl"*) + local firstline="${output%%${nl}*}" + atf_fail "check_no_heading_line [$args] got [$firstline]" + ;; + *) + ;; + esac +} + +# +# Run "ps $args"; check that the heading matches the expected regexp. +# +check_heading_regexp() +{ + args="$1" + regexp="$2" + actual="$( eval "${TEST_PS} $args" | sed -e 1q )" + check_regexp "heading [$args]" "${actual}" "${regexp}" +} + +# +# Run "ps $args"; check that the heading matches a regexp constructed +# from the specified keywords. +# +check_heading_keywords() +{ + args="$1" + keywords="$2" + check_heading_regexp "$args" "$(heading_keywords_to_regexp "$keywords")" +} + +# +# Try several variations on "ps $flag", "ps -$flag", etc., +# and check that the heading always has the correct keywords. +# +check_heading_variations() +{ + flag="$1" + keywords="$2" + for args in "$flag" "-$flag" "-$flag$flag -$flag"; do + check_heading_keywords "$args" "$keywords" + done +} + +atf_test_case default_columns +default_columns_head() +{ + atf_set "descr" "Checks that the default set of columns is correct" \ + "and also check that the columns printed by the -j," \ + "-l, -s, -u and -v flags alone are correct" +} +default_columns_body() +{ + setup_keywords + check_heading_keywords '' "$default_keywords" + check_heading_variations 'j' "$j_keywords" + check_heading_variations 'l' "$l_keywords" + check_heading_variations 's' "$s_keywords" + check_heading_variations 'u' "$u_keywords" + check_heading_variations 'v' "$v_keywords" +} + +atf_test_case minus_O +minus_O_head() +{ + atf_set "descr" "Checks that 'ps -O foo' inserts columns just after" \ + "the pid column" +} +minus_O_body() +{ + setup_keywords + check_heading_keywords '-O %cpu,%mem' \ + "$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')" + check_heading_keywords '-O %cpu -O %mem' \ + "$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')" + check_heading_keywords '-O%cpu -O%mem' \ + "$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')" +} + +atf_test_case minus_o +minus_o_head() +{ + atf_set "descr" "Checks simple cases of 'ps -o foo' to control which" \ + "columns are printed; this does not test header" \ + "overriding via 'ps -o foo=BAR'" +} +minus_o_body() +{ + setup_keywords + # Keywords for "-o name" override the default display + check_heading_keywords '-o pid,%cpu,%mem' \ + "pid %cpu %mem" + check_heading_keywords '-o pid -o %cpu,%mem' \ + "pid %cpu %mem" + check_heading_keywords '-opid -o %cpu,%mem' \ + "pid %cpu %mem" + # Space works like comma + check_heading_keywords '-opid -o "%cpu %mem"' \ + "pid %cpu %mem" + # Check missing pid + check_heading_keywords '-o comm' \ + "comm" + # Check pid present but not first + check_heading_keywords '-o comm,pid' \ + "comm pid" +} + +atf_test_case override_heading_simple +override_heading_simple_head() +{ + atf_set "descr" "Tests simple uses of header overriding via" \ + "'ps -o foo=BAR'. This does not test columns " \ + "with null headings, or headings with embedded" \ + "space, ',' or '='." +} +override_heading_simple_body() +{ + setup_keywords + check_heading_regexp '-o pid=PPP -o comm' \ + '^ *PPP '"${head_text_comm}"'$' # no trailing space + check_heading_regexp '-o pid=PPP -o comm=CCC' \ + '^ *PPP CCC$' + check_heading_regexp '-o pid,comm=CCC' \ + '^'"${head_regexp_pid}"' CCC$' + check_heading_regexp '-o pid -o comm=CCC' \ + '^'"${head_regexp_pid}"' CCC$' + # Check missing pid + check_heading_regexp '-o comm=CCC' \ + '^CCC$' + # Check pid present but not first + check_heading_regexp '-o comm=CCC -o pid=PPP' \ + '^CCC *PPP$' + check_heading_regexp '-o comm,pid=PPP' \ + '^'"${head_regexp_comm}"' *PPP$' +} + +atf_test_case override_heading_embedded_specials +override_heading_embedded_specials_head() +{ + atf_set "descr" "Tests header overriding with embedded space," \ + "',' or '='. Everything after the first '='" \ + "is part of the heading." +} +override_heading_embedded_specials_body() +{ + setup_keywords + # Check embedded "," or "=" in override header. + check_heading_regexp '-o comm,pid==' \ + '^'"${head_regexp_comm}"' *=$' + check_heading_regexp '-o comm,pid=,' \ + '^'"${head_regexp_comm}"' *,$' + check_heading_regexp '-o pid=PPP,comm' \ + '^ *PPP,comm$' # not like '-o pid=PPP -o comm' + check_heading_regexp '-o pid=PPP,comm=CCC' \ + '^ *PPP,comm=CCC$' # not like '-o pid=PPP -o comm=CCC' + check_heading_regexp '-o comm,pid=PPP,QQQ' \ + '^'"${head_regexp_comm}"' *PPP,QQQ$' + check_heading_regexp '-o comm,pid=ppid,tty=state' \ + '^'"${head_regexp_comm}"' *ppid,tty=state$' + # Check embedded space or tab in override header. + check_heading_regexp '-o comm,pid="PPP QQQ"' \ + '^'"${head_regexp_comm}"' *PPP QQQ$' + check_heading_regexp '-o comm,pid="PPP${tab}QQQ"' \ + '^'"${head_regexp_comm}"' *PPP'"${tab}"'QQQ$' +} + +atf_test_case override_heading_some_null +override_heading_some_null_head() +{ + atf_set "descr" "Tests simple uses of null column headings" \ + "overriding via 'ps -o foo=BAR -o baz='. This" \ + "does not test the case where all columns have" \ + "null headings." +} +override_heading_some_null_body() +{ + setup_keywords + check_heading_regexp '-o pid=PPP -o comm=' \ + '^ *PPP *$' + check_heading_regexp '-o pid= -o comm=CCC' \ + '^ * CCC$' + check_heading_regexp '-o pid -o comm=' \ + '^'"${head_regexp_pid}"' *$' + # Check missing pid + check_heading_regexp '-o ppid= -o comm=CCC' \ + '^ * CCC$' + check_heading_regexp '-o ppid=PPP -o comm=' \ + '^ *PPP *$' + # Check pid present but not first + check_heading_regexp '-o comm= -o pid=PPP' \ + '^ * PPP$' + check_heading_regexp '-o comm,pid=' \ + '^'"${head_regexp_comm}"' *$' + # A field with a null custom heading retains a minimum width + # derived from the default heading. This does not apply + # to a field with a very short (non-null) custom heading. + # + # We choose "holdcnt" as a column whose width is likely to be + # determined entirely by the header width, because the values + # are likely to be very small. + check_heading_regexp '-o holdcnt -o holdcnt -o holdcnt' \ + '^HOLDCNT HOLDCNT HOLDCNT$' + check_heading_regexp '-o holdcnt -o holdcnt= -o holdcnt' \ + '^HOLDCNT HOLDCNT$' + check_heading_regexp '-o holdcnt -o holdcnt=HH -o holdcnt' \ + '^HOLDCNT HH HOLDCNT$' +} + +atf_test_case override_heading_all_null +override_heading_all_null_head() +{ + atf_set "descr" "Tests the use of 'ps -o foo= -o bar=' (with a" \ + "null heading for every column). The heading" \ + "should not be printed at all in this case." +} +override_heading_all_null_body() +{ + setup_keywords + # A heading with a space is not a null heading, + # so should not be suppressed + check_heading_regexp '-o comm=" "' \ + '^ *$' + # Null headings should be suppressed + check_no_heading_line '-o pid= -o comm=' + check_no_heading_line '-o pid= -o comm=' + # Check missing pid + check_no_heading_line '-o ppid=' + check_no_heading_line '-o comm=' + check_no_heading_line '-o command=' + check_no_heading_line '-o ppid= -o comm=' + check_no_heading_line '-o comm= -o ppid=' + # Check pid present but not first + check_no_heading_line '-o comm= -o pid=' + check_no_heading_line '-o ppid= -o pid= -o command=' +} + +atf_test_case duplicate_column +duplicate_column_head() +{ + atf_set "descr" "Tests the use of -o options to display the" \ + "same column more than once" +} +duplicate_column_body() +{ + setup_keywords + # two custom headers + check_heading_regexp '-o pid=PPP -o pid=QQQ' \ + '^ *PPP *QQQ$' + # one custom header, before and after default header + check_heading_regexp '-o pid=PPP -o pid' \ + '^ *PPP '"${head_regexp_pid}"'$' + check_heading_regexp '-o pid -o pid=QQQ' \ + '^'"${head_regexp_pid}"' *QQQ$' + # custom headers both before and after default header + check_heading_regexp '-o pid=PPP -o pid -o pid=QQQ' \ + '^ *PPP '"${head_regexp_pid}"' *QQQ$' +} + +atf_init_test_cases() { + atf_add_test_case default_columns + atf_add_test_case minus_O + atf_add_test_case minus_o + atf_add_test_case override_heading_simple + atf_add_test_case override_heading_embedded_specials + atf_add_test_case override_heading_some_null + atf_add_test_case override_heading_all_null + atf_add_test_case duplicate_column +} diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_case.out new file mode 100644 index 000000000000..4c4205563e80 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_case.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_compound.out new file mode 100644 index 000000000000..01113ca97a69 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_compound.out @@ -0,0 +1,8 @@ +before case +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_file.out new file mode 100644 index 000000000000..52640203d8da --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_file.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_for.out new file mode 100644 index 000000000000..e116ee2b6a66 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_for.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_func.out new file mode 100644 index 000000000000..906a804d2185 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_func.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_subshell.out new file mode 100644 index 000000000000..073caff318ba --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_subshell.out @@ -0,0 +1,8 @@ +before case +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_until.out new file mode 100644 index 000000000000..f47bd43cccba --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_until.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_while.out new file mode 100644 index 000000000000..e9a73f8112b1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_while.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_case.out new file mode 100644 index 000000000000..7919427ae304 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_case.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_compound.out new file mode 100644 index 000000000000..9195e0889eb9 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_compound.out @@ -0,0 +1,8 @@ +before case +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_file.out new file mode 100644 index 000000000000..100a5906f0a4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_file.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_for.out new file mode 100644 index 000000000000..9a078d0abc1e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_for.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_func.out new file mode 100644 index 000000000000..6282c89d7437 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_func.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_subshell.out new file mode 100644 index 000000000000..b066ab64b7d7 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_subshell.out @@ -0,0 +1,8 @@ +before case +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_until.out new file mode 100644 index 000000000000..afc85b6561a1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_until.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_while.out new file mode 100644 index 000000000000..cb4137d23391 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_while.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_case.out new file mode 100644 index 000000000000..734369d564e3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_case.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before case +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_compound.out new file mode 100644 index 000000000000..2fae84e35df0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_compound.out @@ -0,0 +1,6 @@ +before case +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_file.out new file mode 100644 index 000000000000..f97ecc6dab50 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_file.out @@ -0,0 +1,5 @@ +before case +before dotcmd +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_for.out new file mode 100644 index 000000000000..d863537007be --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_for.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before for +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_func.out new file mode 100644 index 000000000000..aed8fa4db71a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_func.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_subshell.out new file mode 100644 index 000000000000..364d2458e604 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_subshell.out @@ -0,0 +1,6 @@ +before case +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_until.out new file mode 100644 index 000000000000..daf3811e2e9a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_until.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before until +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_while.out new file mode 100644 index 000000000000..ef6a6764d515 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_while.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before while +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_case.out new file mode 100644 index 000000000000..144bcd6d00f4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_case.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_compound.out new file mode 100644 index 000000000000..3fd7b2f92e2a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_compound.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_file.out new file mode 100644 index 000000000000..5ad5ed396a74 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_file.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_for.out new file mode 100644 index 000000000000..7f03e495bcde --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_for.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_func.out new file mode 100644 index 000000000000..82e86b3c778e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_func.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_subshell.out new file mode 100644 index 000000000000..e26e980f7ebf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_subshell.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_until.out new file mode 100644 index 000000000000..34dd25adeaa0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_until.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_while.out new file mode 100644 index 000000000000..7019045bc39f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_while.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_case.out new file mode 100644 index 000000000000..206548ccff38 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_case.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_compound.out new file mode 100644 index 000000000000..a8c7efc159ec --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_compound.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_file.out new file mode 100644 index 000000000000..c619ad560f9d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_file.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_for.out new file mode 100644 index 000000000000..35b092a42fb3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_for.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_func.out new file mode 100644 index 000000000000..198dbd6af513 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_func.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_subshell.out new file mode 100644 index 000000000000..1ecaa96e422f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_subshell.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_until.out new file mode 100644 index 000000000000..4a74a8e8e431 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_until.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_while.out new file mode 100644 index 000000000000..b2d939ed538c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_while.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_case.out new file mode 100644 index 000000000000..995d5b556f42 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_case.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before case +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_compound.out new file mode 100644 index 000000000000..f6e4858e6f5d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_compound.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +compound start +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_file.out new file mode 100644 index 000000000000..84347b28f74d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_file.out @@ -0,0 +1,5 @@ +compound start +before dotcmd +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_for.out new file mode 100644 index 000000000000..ec234472aa6d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_for.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before for +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_func.out new file mode 100644 index 000000000000..12798d0e0322 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_func.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_subshell.out new file mode 100644 index 000000000000..af0ab785fbb4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_subshell.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_until.out new file mode 100644 index 000000000000..a108f502d2c6 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_until.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before until +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_while.out new file mode 100644 index 000000000000..ef34c037a9f8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_while.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before while +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_case.out new file mode 100644 index 000000000000..2f34f10c726b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_case.out @@ -0,0 +1,6 @@ +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_compound.out new file mode 100644 index 000000000000..0c7300d6a3ee --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_compound.out @@ -0,0 +1,6 @@ +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_file.out new file mode 100644 index 000000000000..fb4db197ddac --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_file.out @@ -0,0 +1,4 @@ +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_for.out new file mode 100644 index 000000000000..66f445287d5b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_for.out @@ -0,0 +1,5 @@ +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_func.out new file mode 100644 index 000000000000..c5488abadbc5 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_func.out @@ -0,0 +1,6 @@ +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_subshell.out new file mode 100644 index 000000000000..47e2394084af --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_subshell.out @@ -0,0 +1,6 @@ +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_until.out new file mode 100644 index 000000000000..b51ff195bd84 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_until.out @@ -0,0 +1,5 @@ +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_while.out new file mode 100644 index 000000000000..0fd3a83ce03d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_while.out @@ -0,0 +1,5 @@ +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_case.out new file mode 100644 index 000000000000..2cf3be6d3b4e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_case.out @@ -0,0 +1,6 @@ +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_compound.out new file mode 100644 index 000000000000..7bec42019aee --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_compound.out @@ -0,0 +1,6 @@ +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_file.out new file mode 100644 index 000000000000..2f8806c60b6d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_file.out @@ -0,0 +1,4 @@ +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_for.out new file mode 100644 index 000000000000..e8da2390bbbf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_for.out @@ -0,0 +1,6 @@ +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_func.out new file mode 100644 index 000000000000..da683c02a158 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_func.out @@ -0,0 +1,6 @@ +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_subshell.out new file mode 100644 index 000000000000..388558b060e6 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_subshell.out @@ -0,0 +1,6 @@ +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_until.out new file mode 100644 index 000000000000..bb0f28134eee --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_until.out @@ -0,0 +1,6 @@ +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_while.out new file mode 100644 index 000000000000..63338234aa4c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_while.out @@ -0,0 +1,6 @@ +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_case.out new file mode 100644 index 000000000000..486685242bda --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_case.out @@ -0,0 +1,4 @@ +before dotcmd +before case +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_compound.out new file mode 100644 index 000000000000..6b831451d867 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_compound.out @@ -0,0 +1,4 @@ +before dotcmd +compound start +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_file.out new file mode 100644 index 000000000000..2d6742310a0f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_file.out @@ -0,0 +1,3 @@ +before dotcmd +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_for.out new file mode 100644 index 000000000000..83f8e002950f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_for.out @@ -0,0 +1,4 @@ +before dotcmd +before for +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_func.out new file mode 100644 index 000000000000..a0db2c99cfa8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_func.out @@ -0,0 +1,5 @@ +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_subshell.out new file mode 100644 index 000000000000..83cd0e4ed0b0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_subshell.out @@ -0,0 +1,4 @@ +before dotcmd +subshell start +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_until.out new file mode 100644 index 000000000000..fdf2449045a1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_until.out @@ -0,0 +1,4 @@ +before dotcmd +before until +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_while.out new file mode 100644 index 000000000000..a733aa38912b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_while.out @@ -0,0 +1,4 @@ +before dotcmd +before while +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_case.out new file mode 100644 index 000000000000..262db24358d4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_case.out @@ -0,0 +1,5 @@ +before for +before dotcmd +before case +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_compound.out new file mode 100644 index 000000000000..418a4de73c0c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_compound.out @@ -0,0 +1,5 @@ +before for +before dotcmd +compound start +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_file.out new file mode 100644 index 000000000000..752c95c9815c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_file.out @@ -0,0 +1,4 @@ +before for +before dotcmd +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_for.out new file mode 100644 index 000000000000..20af6224fc55 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_for.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_func.out new file mode 100644 index 000000000000..fe0cab4fa49b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_func.out @@ -0,0 +1,5 @@ +before for +before dotcmd +before function +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_subshell.out new file mode 100644 index 000000000000..985aab6270c4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_subshell.out @@ -0,0 +1,10 @@ +before for +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_until.out new file mode 100644 index 000000000000..b47c90198f18 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_until.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_while.out new file mode 100644 index 000000000000..deb4cebaece8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_while.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_case.out new file mode 100644 index 000000000000..e989063290ea --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_case.out @@ -0,0 +1,8 @@ +before for +before dotcmd +before case +before continue +before dotcmd +before case +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_compound.out new file mode 100644 index 000000000000..0fd23b628719 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_compound.out @@ -0,0 +1,8 @@ +before for +before dotcmd +compound start +before continue +before dotcmd +compound start +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_file.out new file mode 100644 index 000000000000..286bb88c1ea1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_file.out @@ -0,0 +1,6 @@ +before for +before dotcmd +before continue +before dotcmd +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_for.out new file mode 100644 index 000000000000..044d5a35c55e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_for.out @@ -0,0 +1,14 @@ +before for +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_func.out new file mode 100644 index 000000000000..a0cc6cc18fd8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_func.out @@ -0,0 +1,8 @@ +before for +before dotcmd +before function +before continue +before dotcmd +before function +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_subshell.out new file mode 100644 index 000000000000..f1ae7aab16d0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_subshell.out @@ -0,0 +1,10 @@ +before for +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_until.out new file mode 100644 index 000000000000..b1c4147a9730 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_until.out @@ -0,0 +1,14 @@ +before for +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_while.out new file mode 100644 index 000000000000..f8e5c5d11830 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_while.out @@ -0,0 +1,14 @@ +before for +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_case.out new file mode 100644 index 000000000000..24b7145a05c4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_case.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before case +before return +after dotcmd, return value: 0 +before dotcmd +before case +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_compound.out new file mode 100644 index 000000000000..30b4dac3988e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_compound.out @@ -0,0 +1,10 @@ +before for +before dotcmd +compound start +before return +after dotcmd, return value: 0 +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_file.out new file mode 100644 index 000000000000..88555621c77f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_file.out @@ -0,0 +1,8 @@ +before for +before dotcmd +before return +after dotcmd, return value: 0 +before dotcmd +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_for.out new file mode 100644 index 000000000000..52a72a9fb0c8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_for.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before for +before return +after dotcmd, return value: 0 +before dotcmd +before for +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_func.out new file mode 100644 index 000000000000..4f0fee21740b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_func.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_subshell.out new file mode 100644 index 000000000000..4b8f36c1a331 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_subshell.out @@ -0,0 +1,10 @@ +before for +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_until.out new file mode 100644 index 000000000000..3eaf9df84b8b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_until.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before until +before return +after dotcmd, return value: 0 +before dotcmd +before until +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_while.out new file mode 100644 index 000000000000..8cbad954cdad --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_while.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before while +before return +after dotcmd, return value: 0 +before dotcmd +before while +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_case.out new file mode 100644 index 000000000000..7373371e511b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_case.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_compound.out new file mode 100644 index 000000000000..e87b4a2e8e14 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_compound.out @@ -0,0 +1,8 @@ +before function +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_file.out new file mode 100644 index 000000000000..cf144227aefe --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_file.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before break +after break, return value: 0 +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_for.out new file mode 100644 index 000000000000..c3853488a517 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_for.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before for +before break +after for +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_func.out new file mode 100644 index 000000000000..5c1c4c830164 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_func.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before function +before break +after break +after function +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_subshell.out new file mode 100644 index 000000000000..affe3e4bdefb --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_subshell.out @@ -0,0 +1,8 @@ +before function +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_until.out new file mode 100644 index 000000000000..b0f942a04fbf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_until.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before until +before break +after until +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_while.out new file mode 100644 index 000000000000..d687aa766498 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_while.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before while +before break +after while +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_case.out new file mode 100644 index 000000000000..b1ad4be38bfd --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_case.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_compound.out new file mode 100644 index 000000000000..d6a5edd9940f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_compound.out @@ -0,0 +1,8 @@ +before function +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_file.out new file mode 100644 index 000000000000..f300d6afee79 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_file.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before continue +after continue, return value: 0 +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_for.out new file mode 100644 index 000000000000..d46095d58d36 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_for.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before for +before continue +before continue +after for +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_func.out new file mode 100644 index 000000000000..3ff73a2bdaa9 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_func.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before function +before continue +after continue +after function +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_subshell.out new file mode 100644 index 000000000000..fd295aad8542 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_subshell.out @@ -0,0 +1,8 @@ +before function +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_until.out new file mode 100644 index 000000000000..7a6508328e00 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_until.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before until +before continue +before continue +after until +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_while.out new file mode 100644 index 000000000000..6ecbe8261164 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_while.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before while +before continue +before continue +after while +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_case.out new file mode 100644 index 000000000000..8f0c0948357a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_case.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before case +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_compound.out new file mode 100644 index 000000000000..e3d86704f79d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_compound.out @@ -0,0 +1,6 @@ +before function +before dotcmd +compound start +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_file.out new file mode 100644 index 000000000000..95e341525799 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_file.out @@ -0,0 +1,5 @@ +before function +before dotcmd +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_for.out new file mode 100644 index 000000000000..511cc39ca34f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_for.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before for +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_func.out new file mode 100644 index 000000000000..a87d3a780043 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_func.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before function +before return +after function +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_subshell.out new file mode 100644 index 000000000000..fdb37b20979e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_subshell.out @@ -0,0 +1,6 @@ +before function +before dotcmd +subshell start +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_until.out new file mode 100644 index 000000000000..08b45be42f4f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_until.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before until +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_while.out new file mode 100644 index 000000000000..27fbcaf88b22 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_while.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before while +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_case.out new file mode 100644 index 000000000000..155daea6606d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_case.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_compound.out new file mode 100644 index 000000000000..a643ac080d91 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_compound.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_file.out new file mode 100644 index 000000000000..2556d89acbbe --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_file.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_for.out new file mode 100644 index 000000000000..27040a992adf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_for.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_func.out new file mode 100644 index 000000000000..83ec062eed6a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_func.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_subshell.out new file mode 100644 index 000000000000..8a53ac59e578 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_subshell.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_until.out new file mode 100644 index 000000000000..a31fa5bfa332 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_until.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_while.out new file mode 100644 index 000000000000..42eb970ef81d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_while.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_case.out new file mode 100644 index 000000000000..4d74b7b151e2 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_case.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_compound.out new file mode 100644 index 000000000000..4328df396efb --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_compound.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_file.out new file mode 100644 index 000000000000..a4a6e4ae0411 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_file.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_for.out new file mode 100644 index 000000000000..e82988936104 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_for.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_func.out new file mode 100644 index 000000000000..e0ead4c87cb9 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_func.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_subshell.out new file mode 100644 index 000000000000..dfcdfb46a662 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_subshell.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_until.out new file mode 100644 index 000000000000..66e8f9f269ae --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_until.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_while.out new file mode 100644 index 000000000000..f1c83f43d394 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_while.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_case.out new file mode 100644 index 000000000000..008d9396a260 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_case.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before case +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_compound.out new file mode 100644 index 000000000000..bdab2314d44b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_compound.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +compound start +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_file.out new file mode 100644 index 000000000000..43d011dfb970 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_file.out @@ -0,0 +1,5 @@ +subshell start +before dotcmd +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_for.out new file mode 100644 index 000000000000..7cfed898d338 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_for.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before for +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_func.out new file mode 100644 index 000000000000..b695c53484c8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_func.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_subshell.out new file mode 100644 index 000000000000..c5ccf597e61c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_subshell.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_until.out new file mode 100644 index 000000000000..64737ad7341f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_until.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before until +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_while.out new file mode 100644 index 000000000000..de520c4493ef --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_while.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before while +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_case.out new file mode 100644 index 000000000000..f0483b459129 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_case.out @@ -0,0 +1,5 @@ +before until +before dotcmd +before case +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_compound.out new file mode 100644 index 000000000000..a5e37ba7ab5d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_compound.out @@ -0,0 +1,5 @@ +before until +before dotcmd +compound start +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_file.out new file mode 100644 index 000000000000..a2fde4dafe28 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_file.out @@ -0,0 +1,4 @@ +before until +before dotcmd +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_for.out new file mode 100644 index 000000000000..8b3faf520a8f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_for.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_func.out new file mode 100644 index 000000000000..a83ce2b82c0c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_func.out @@ -0,0 +1,5 @@ +before until +before dotcmd +before function +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_subshell.out new file mode 100644 index 000000000000..008d30dfc7d6 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_subshell.out @@ -0,0 +1,10 @@ +before until +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_until.out new file mode 100644 index 000000000000..05fb94a46af3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_until.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_while.out new file mode 100644 index 000000000000..6ae1f9c4225d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_while.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_case.out new file mode 100644 index 000000000000..40028fb08139 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_case.out @@ -0,0 +1,8 @@ +before until +before dotcmd +before case +before continue +before dotcmd +before case +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_compound.out new file mode 100644 index 000000000000..3641e1e3f5c2 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_compound.out @@ -0,0 +1,8 @@ +before until +before dotcmd +compound start +before continue +before dotcmd +compound start +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_file.out new file mode 100644 index 000000000000..c9f5193b740f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_file.out @@ -0,0 +1,6 @@ +before until +before dotcmd +before continue +before dotcmd +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_for.out new file mode 100644 index 000000000000..fd582401d026 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_for.out @@ -0,0 +1,14 @@ +before until +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_func.out new file mode 100644 index 000000000000..6beb16323068 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_func.out @@ -0,0 +1,8 @@ +before until +before dotcmd +before function +before continue +before dotcmd +before function +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_subshell.out new file mode 100644 index 000000000000..534509e7e69d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_subshell.out @@ -0,0 +1,10 @@ +before until +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_until.out new file mode 100644 index 000000000000..ddfeb2797a7e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_until.out @@ -0,0 +1,14 @@ +before until +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_while.out new file mode 100644 index 000000000000..5707821eca00 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_while.out @@ -0,0 +1,14 @@ +before until +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_case.out new file mode 100644 index 000000000000..70dd420505cd --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_case.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before case +before return +after dotcmd, return value: 0 +before dotcmd +before case +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_compound.out new file mode 100644 index 000000000000..145d2c580f07 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_compound.out @@ -0,0 +1,10 @@ +before until +before dotcmd +compound start +before return +after dotcmd, return value: 0 +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_file.out new file mode 100644 index 000000000000..5b0adb198c6d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_file.out @@ -0,0 +1,8 @@ +before until +before dotcmd +before return +after dotcmd, return value: 0 +before dotcmd +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_for.out new file mode 100644 index 000000000000..b113e8c0552a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_for.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before for +before return +after dotcmd, return value: 0 +before dotcmd +before for +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_func.out new file mode 100644 index 000000000000..1ab16ab70360 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_func.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_subshell.out new file mode 100644 index 000000000000..d44463108242 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_subshell.out @@ -0,0 +1,10 @@ +before until +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_until.out new file mode 100644 index 000000000000..39980179a781 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_until.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before until +before return +after dotcmd, return value: 0 +before dotcmd +before until +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_while.out new file mode 100644 index 000000000000..9b140cf7a0a3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_while.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before while +before return +after dotcmd, return value: 0 +before dotcmd +before while +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_case.out new file mode 100644 index 000000000000..1b0731fcaf38 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_case.out @@ -0,0 +1,5 @@ +before while +before dotcmd +before case +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_compound.out new file mode 100644 index 000000000000..05c23eb4284c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_compound.out @@ -0,0 +1,5 @@ +before while +before dotcmd +compound start +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_file.out new file mode 100644 index 000000000000..cb70ae19221e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_file.out @@ -0,0 +1,4 @@ +before while +before dotcmd +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_for.out new file mode 100644 index 000000000000..b94eac165604 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_for.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_func.out new file mode 100644 index 000000000000..7d54c1514a67 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_func.out @@ -0,0 +1,5 @@ +before while +before dotcmd +before function +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_subshell.out new file mode 100644 index 000000000000..234cd663c2e0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_subshell.out @@ -0,0 +1,10 @@ +before while +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_until.out new file mode 100644 index 000000000000..f3602302673f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_until.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_while.out new file mode 100644 index 000000000000..451b0a23671b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_while.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_case.out new file mode 100644 index 000000000000..d7f412c0d554 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_case.out @@ -0,0 +1,8 @@ +before while +before dotcmd +before case +before continue +before dotcmd +before case +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_compound.out new file mode 100644 index 000000000000..001904764a68 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_compound.out @@ -0,0 +1,8 @@ +before while +before dotcmd +compound start +before continue +before dotcmd +compound start +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_file.out new file mode 100644 index 000000000000..9070dea4528e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_file.out @@ -0,0 +1,6 @@ +before while +before dotcmd +before continue +before dotcmd +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_for.out new file mode 100644 index 000000000000..98696ee40190 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_for.out @@ -0,0 +1,14 @@ +before while +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_func.out new file mode 100644 index 000000000000..77efc2c9c87a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_func.out @@ -0,0 +1,8 @@ +before while +before dotcmd +before function +before continue +before dotcmd +before function +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_subshell.out new file mode 100644 index 000000000000..b4106a1e2d83 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_subshell.out @@ -0,0 +1,10 @@ +before while +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_until.out new file mode 100644 index 000000000000..7f893a015a6a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_until.out @@ -0,0 +1,14 @@ +before while +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_while.out new file mode 100644 index 000000000000..317be17fadc4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_while.out @@ -0,0 +1,14 @@ +before while +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_case.out new file mode 100644 index 000000000000..abb6a4afcfab --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_case.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before case +before return +after dotcmd, return value: 0 +before dotcmd +before case +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_compound.out new file mode 100644 index 000000000000..b37418b3d34e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_compound.out @@ -0,0 +1,10 @@ +before while +before dotcmd +compound start +before return +after dotcmd, return value: 0 +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_file.out new file mode 100644 index 000000000000..1c4791ef7639 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_file.out @@ -0,0 +1,8 @@ +before while +before dotcmd +before return +after dotcmd, return value: 0 +before dotcmd +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_for.out new file mode 100644 index 000000000000..0569d6fe6707 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_for.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before for +before return +after dotcmd, return value: 0 +before dotcmd +before for +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_func.out new file mode 100644 index 000000000000..cb5a30853a10 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_func.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_subshell.out new file mode 100644 index 000000000000..161a227239bc --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_subshell.out @@ -0,0 +1,10 @@ +before while +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_until.out new file mode 100644 index 000000000000..d84a5f71dca8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_until.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before until +before return +after dotcmd, return value: 0 +before dotcmd +before until +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_while.out new file mode 100644 index 000000000000..4eeaaa9b5244 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_while.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before while +before return +after dotcmd, return value: 0 +before dotcmd +before while +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command new file mode 100755 index 000000000000..fda4e53a302a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command @@ -0,0 +1,129 @@ +#!/bin/sh +# +# $NetBSD: scoped_command,v 1.1 2014/05/31 14:29:06 christos Exp $ +# +# Copyright (c) 2014 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jarmo Jaakkola. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +set -e + +# USAGE: +# scoped_command scope cmd msg var_suffix +# +# Write to stdout a piece of Bourne Shell script with _cmd_ in specific +# _scope_. The execution of _cmd_ is bracketed by prints of "before _msg_" +# and "after _msg_, return value ${?}". If the generated script uses +# variables, __var_suffix_ is appended to their names to allow nesting of +# scripts generated this way. +# +# _scope_ should be one of: case, compound, file, for, func, subshell, +# until, while. +# _cmd_ is the command line to execute. Remember proper quoting! +# _msg_ is text that will be used inside single quotes. +# _var_suffix_ is a syntactically valid identifier name. + +# don't rely on command lists (';') +cmd="echo 'before ${3}' +${2} +echo 'after ${3}, return value:' ${?}" + +echo "#!/bin/sh" + +[ 'func' = "${1}" ] && cat <0, and is not part of the compound list following a +# while, until, or if keyword, and is not a part of an AND or OR list, +# and is not a pipeline preceded by the ! reserved word, then the shell +# shall immediately exit. + +crud() { + set -e + for x in a + do + BAR="foo" + false && echo true + echo mumble + done +} + +atf_test_case set_e +set_e_head() { + atf_set "descr" "Tests that 'set -e' turns on error detection" \ + "and that it behaves as defined by the standard" +} +set_e_body() { + foo=`crud` + atf_check_equal 'x$foo' 'xmumble' +} + +atf_init_test_cases() { + atf_add_test_case set_e +} diff --git a/contrib/netbsd-tests/bin/sh/t_evaltested.sh b/contrib/netbsd-tests/bin/sh/t_evaltested.sh new file mode 100755 index 000000000000..e40f8bd4b3be --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_evaltested.sh @@ -0,0 +1,60 @@ +# $NetBSD: t_evaltested.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2011 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case evaltested + +evaltested_head() { + atf_set "descr" "Tests that eval in a tested context does not exit" +} + +evaltested_body() { + set -e +cat > helper.sh << EOF +set -e +if eval false +then + echo "'eval false' returned true" + exit 1 +fi +echo "passed" +exit 0 +EOF + output="$(/bin/sh helper.sh)" + [ $? = 0 ] && return + + if [ -n "$output" ] + then + atf_fail "$output" + else + atf_fail "'eval false' exited from a tested context" + fi + +} + +atf_init_test_cases() { + atf_add_test_case evaltested +} diff --git a/contrib/netbsd-tests/bin/sh/t_exit.sh b/contrib/netbsd-tests/bin/sh/t_exit.sh new file mode 100755 index 000000000000..62c5869c009c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_exit.sh @@ -0,0 +1,105 @@ +# $NetBSD: t_exit.sh,v 1.3 2012/04/13 06:12:32 jruoho Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +crud() { + test yes = no + + cat <helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +} + +atf_test_case trap_zero__explicit_exit +trap_zero__explicit_exit_body() { + echo '( trap "echo exiting" 0; exit )' >helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +} + +atf_test_case trap_zero__explicit_return +trap_zero__explicit_return_body() { + echo '( trap "echo exiting" 0; return )' >helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +} + +atf_init_test_cases() { + atf_add_test_case background + atf_add_test_case function + atf_add_test_case readout + atf_add_test_case trap_subshell + atf_add_test_case trap_zero__implicit_exit + atf_add_test_case trap_zero__explicit_exit + atf_add_test_case trap_zero__explicit_return +} diff --git a/contrib/netbsd-tests/bin/sh/t_expand.sh b/contrib/netbsd-tests/bin/sh/t_expand.sh new file mode 100755 index 000000000000..eeaad5f7db71 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_expand.sh @@ -0,0 +1,142 @@ +# $NetBSD: t_expand.sh,v 1.2 2013/10/06 21:05:50 ast Exp $ +# +# Copyright (c) 2007, 2009 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# +# This file tests the functions in expand.c. +# + +delim_argv() { + str= + while [ $# -gt 0 ]; do + if [ -z "${str}" ]; then + str=">$1<" + else + str="${str} >$1<" + fi + shift + done + echo ${str} +} + +atf_test_case dollar_at +dollar_at_head() { + atf_set "descr" "Somewhere between 2.0.2 and 3.0 the expansion" \ + "of the \$@ variable had been broken. Check for" \ + "this behavior." +} +dollar_at_body() { + # This one should work everywhere. + got=`echo "" "" | sed 's,$,EOL,'` + atf_check_equal ' EOL' '$got' + + # This code triggered the bug. + set -- "" "" + got=`echo "$@" | sed 's,$,EOL,'` + atf_check_equal ' EOL' '$got' + + set -- - + shift + n_arg() { echo $#; } + n_args=`n_arg "$@"` + atf_check_equal '0' '$n_args' +} + +atf_test_case dollar_at_with_text +dollar_at_with_text_head() { + atf_set "descr" "Test \$@ expansion when it is surrounded by text" \ + "within the quotes. PR bin/33956." +} +dollar_at_with_text_body() { + set -- + atf_check_equal '' "$(delim_argv "$@")" + atf_check_equal '>foobar<' "$(delim_argv "foo$@bar")" + atf_check_equal '>foo bar<' "$(delim_argv "foo $@ bar")" + + set -- a b c + atf_check_equal '>a< >b< >c<' "$(delim_argv "$@")" + atf_check_equal '>fooa< >b< >cbar<' "$(delim_argv "foo$@bar")" + atf_check_equal '>foo a< >b< >c bar<' "$(delim_argv "foo $@ bar")" +} + +atf_test_case strip +strip_head() { + atf_set "descr" "Checks that the %% operator works and strips" \ + "the contents of a variable from the given point" \ + "to the end" +} +strip_body() { + line='#define bindir "/usr/bin" /* comment */' + stripped='#define bindir "/usr/bin" ' + atf_expect_fail "PR bin/43469" + atf_check_equal '$stripped' '${line%%/\**}' +} + +atf_test_case varpattern_backslashes +varpattern_backslashes_head() { + atf_set "descr" "Tests that protecting wildcards with backslashes" \ + "works in variable patterns." +} +varpattern_backslashes_body() { + line='/foo/bar/*/baz' + stripped='/foo/bar/' + atf_check_equal $stripped ${line%%\**} +} + +atf_test_case arithmetic +arithmetic_head() { + atf_set "descr" "POSIX requires shell arithmetic to use signed" \ + "long or a wider type. We use intmax_t, so at" \ + "least 64 bits should be available. Make sure" \ + "this is true." +} +arithmetic_body() { + atf_check_equal '3' '$((1 + 2))' + atf_check_equal '2147483647' '$((0x7fffffff))' + atf_check_equal '9223372036854775807' '$(((1 << 63) - 1))' +} + +atf_test_case iteration_on_null_parameter +iteration_on_null_parameter_head() { + atf_set "descr" "Check iteration of \$@ in for loop when set to null;" \ + "the error \"sh: @: parameter not set\" is incorrect." \ + "PR bin/48202." +} +iteration_on_null_parameter_body() { + s1=`/bin/sh -uc 'N=; set -- ${N}; for X; do echo "[$X]"; done' 2>&1` + s2=`/bin/sh -uc 'N=; set -- ${N:-}; for X; do echo "[$X]"; done' 2>&1` + atf_check_equal '' '$s1' + atf_check_equal '[]' '$s2' +} + +atf_init_test_cases() { + atf_add_test_case dollar_at + atf_add_test_case dollar_at_with_text + atf_add_test_case strip + atf_add_test_case varpattern_backslashes + atf_add_test_case arithmetic + atf_add_test_case iteration_on_null_parameter +} diff --git a/contrib/netbsd-tests/bin/sh/t_fsplit.sh b/contrib/netbsd-tests/bin/sh/t_fsplit.sh new file mode 100755 index 000000000000..2c3dbae23dc8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_fsplit.sh @@ -0,0 +1,186 @@ +# $NetBSD: t_fsplit.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# The standard +# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html +# explains (section 2.6) that Field splitting should be performed on the +# result of variable expansions. +# In particular this means that in ${x-word}, 'word' must be expanded as if +# the "${x-" and "}" were absent from the input line. +# +# So: sh -c 'set ${x-a b c}; echo $#' should give 3. +# + +nl=' +' + +check() +{ + result="$(eval $1)" + # Remove newlines + oifs="$IFS" + IFS="$nl" + result="$(echo $result)" + IFS="$oifs" + if [ "$2" != "$result" ] + then + atf_fail "expected [$2], found [$result]" + fi +} + +atf_test_case for +for_head() { + atf_set "descr" "Checks field splitting in for loops" +} +for_body() { + unset x + + # Since I managed to break this, leave the test in + check 'for f in $x; do echo x${f}y; done' '' +} + +atf_test_case default_val +default_val_head() { + atf_set "descr" "Checks field splitting in variable default values" +} +default_val_body() { + unset x + + # Check that IFS is applied to text from ${x-...} unless it is inside + # any set of "..." + check 'set ${x-a b c}; echo $#' 3 + check 'for i in ${x-a b c}; do echo "z${i}z"; done' 'zaz zbz zcz' + check 'for i in ${x-"a b" c}; do echo "z${i}z"; done' 'za bz zcz' + check 'for i in ${x-"a ${x-b c}" d}; do echo "z${i}z"; done' 'za b cz zdz' + check 'for i in ${x-"a ${x-"b c"}" d}; do echo "z${i}z"; done' 'za b cz zdz' + check 'for i in ${x-a ${x-"b c"} d}; do echo "z${i}z"; done' 'zaz zb cz zdz' + check 'for i in ${x-a ${x-b c} d}; do echo "z${i}z"; done' 'zaz zbz zcz zdz' +} + +atf_test_case ifs_alpha +ifs_alpha_head() { + atf_set "descr" "Checks that field splitting works with alphabetic" \ + "characters" +} +ifs_alpha_body() { + unset x + + # repeat with an alphabetic in IFS + check 'IFS=q; set ${x-aqbqc}; echo $#' 3 + check 'IFS=q; for i in ${x-aqbqc}; do echo "z${i}z"; done' 'zaz zbz zcz' + check 'IFS=q; for i in ${x-"aqb"qc}; do echo "z${i}z"; done' 'zaqbz zcz' + check 'IFS=q; for i in ${x-"aq${x-bqc}"qd}; do echo "z${i}z"; done' 'zaqbqcz zdz' + check 'IFS=q; for i in ${x-"aq${x-"bqc"}"qd}; do echo "z${i}z"; done' 'zaqbqcz zdz' + check 'IFS=q; for i in ${x-aq${x-"bqc"}qd}; do echo "z${i}z"; done' 'zaz zbqcz zdz' +} + +atf_test_case quote +quote_head() { + atf_set "descr" "Checks that field splitting works with multi-word" \ + "fields" +} +quote_body() { + unset x + + # Some quote propagation checks + check 'set "${x-a b c}"; echo $#' 1 + check 'set "${x-"a b" c}"; echo $1' 'a b c' + check 'for i in "${x-a b c}"; do echo "z${i}z"; done' 'za b cz' +} + +atf_test_case dollar_at +dollar_at_head() { + atf_set "descr" "Checks that field splitting works when expanding" \ + "\$@" +} +dollar_at_body() { + unset x + + # Check we get "$@" right + check 'set ""; for i; do echo "z${i}z"; done' 'zz' + check 'set ""; for i in "$@"; do echo "z${i}z"; done' 'zz' + check 'set "" ""; for i; do echo "z${i}z"; done' 'zz zz' + check 'set "" ""; for i in "$@"; do echo "z${i}z"; done' 'zz zz' + check 'set "" ""; for i in $@; do echo "z${i}z"; done' '' + check 'set "a b" c; for i; do echo "z${i}z"; done' 'za bz zcz' + check 'set "a b" c; for i in "$@"; do echo "z${i}z"; done' 'za bz zcz' + check 'set "a b" c; for i in $@; do echo "z${i}z"; done' 'zaz zbz zcz' + check 'set " a b " c; for i in "$@"; do echo "z${i}z"; done' 'z a b z zcz' + check 'set --; for i in x"$@"x; do echo "z${i}z"; done' 'zxxz' + check 'set a; for i in x"$@"x; do echo "z${i}z"; done' 'zxaxz' + check 'set a b; for i in x"$@"x; do echo "z${i}z"; done' 'zxaz zbxz' +} + +atf_test_case ifs +ifs_head() { + atf_set "descr" "Checks that IFS correctly configures field" \ + "splitting behavior" +} +ifs_body() { + unset x + + # Some IFS tests + check 't="-- "; IFS=" "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '0' + check 't=" x"; IFS=" x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '1' + check 't=" x "; IFS=" x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '1' + check 't=axb; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 a:b' + check 't="a x b"; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 a : b' + check 't="a xx b"; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '3 a :: b' + check 't="a xx b"; IFS="x "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '3 a::b' + # A recent 'clarification' means that a single trailing IFS non-whitespace + # doesn't generate an empty parameter + check 't="xax"; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 :a' + check 't="xax "; IFS="x "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 :a' + # Verify that IFS isn't being applied where it shouldn't be. + check 'IFS="x"; set axb; IFS=":"; r="$*"; IFS=; echo $# $r' '1 axb' +} + +atf_test_case var_length +var_length_head() { + atf_set "descr" "Checks that field splitting works when expanding" \ + "a variable's length" +} +var_length_body() { + unset x + + # Check that we apply IFS to ${#var} + long=12345678123456781234567812345678 + long=$long$long$long$long + check 'echo ${#long}; IFS=2; echo ${#long}; set 1 ${#long};echo $#' '128 1 8 3' + check 'IFS=2; set ${x-${#long}}; IFS=" "; echo $* $#' '1 8 2' + check 'IFS=2; set ${x-"${#long}"}; IFS=" "; echo $* $#' '128 1' +} + +atf_init_test_cases() { + atf_add_test_case for + atf_add_test_case default_val + atf_add_test_case ifs_alpha + atf_add_test_case quote + atf_add_test_case dollar_at + atf_add_test_case ifs + atf_add_test_case var_length +} diff --git a/contrib/netbsd-tests/bin/sh/t_here.sh b/contrib/netbsd-tests/bin/sh/t_here.sh new file mode 100755 index 000000000000..250c686aa39a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_here.sh @@ -0,0 +1,73 @@ +# $NetBSD: t_here.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +nl=' +' + +check() +{ + SVIFS="$IFS" + result="$(eval $1)" + # Remove newlines + oifs="$IFS" + IFS="$nl" + result="$(echo $result)" + IFS="$oifs" + if [ "$2" != "$result" ] + then + atf_fail "expected [$2], found [$result]" + fi + IFS="$SVIFS" +} + +atf_test_case all +all_head() { + atf_set "descr" "Basic tests for here documents" +} +all_body() { + y=x + + IFS= + check 'x=`cat </dev/null | tr '\n' ' ' | sed 's/ *$//'` + if [ "$result" != "$2" ]; then + MSG=`printf "%-56s %-8s %s" "$3" "$result" "$2"` + failwith "$MSG" + failcount=`expr $failcount + 1` + fi + count=`expr $count + 1` +} + +# direct check: try the given expression. +dcheck() +{ + check1 "$1" "$2" "$1" +} + +# eval check: indirect through eval. +# as of this writing, this changes the behavior pretty drastically and +# is thus important to test. (PR bin/29861) +echeck() +{ + check1 'eval '"'($1)'" "$2" "eval '($1)'" +} + +atf_test_case all +all_head() { + atf_set "descr" "Tests that 'set -e' works correctly" +} +all_body() { + count=0 + failcount=0 + + # make sure exiting from a subshell behaves as expected + dcheck '(set -e; exit 1; echo ERR$?); echo OK$?' 'OK1' + echeck '(set -e; exit 1; echo ERR$?); echo OK$?' 'OK1' + + # first, check basic functioning. + # The ERR shouldn't print; the result of the () should be 1. + # Henceforth we'll assume that we don't need to check $?. + dcheck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1' + echeck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1' + + # these cases should be equivalent to the preceding. + dcheck '(set -e; /nonexistent; echo ERR); echo OK' 'OK' + echeck '(set -e; /nonexistent; echo ERR); echo OK' 'OK' + dcheck '(set -e; nonexistent-program-on-path; echo ERR); echo OK' 'OK' + echeck '(set -e; nonexistent-program-on-path; echo ERR); echo OK' 'OK' + dcheck 'f() { false; }; (set -e; f; echo ERR); echo OK' 'OK' + echeck 'f() { false; }; (set -e; f; echo ERR); echo OK' 'OK' + dcheck 'f() { return 1; }; (set -e; f; echo ERR); echo OK' 'OK' + echeck 'f() { return 1; }; (set -e; f; echo ERR); echo OK' 'OK' + + # but! with set -e, the false should cause an *immediate* exit. + # The return form should not, as such, but there's no way to + # distinguish it. + dcheck 'f() { false; echo ERR; }; (set -e; f); echo OK' 'OK' + echeck 'f() { false; echo ERR; }; (set -e; f); echo OK' 'OK' + + # set is not scoped, so these should not exit at all. + dcheck 'f() { set +e; false; echo OK; }; (set -e; f); echo OK' 'OK OK' + echeck 'f() { set +e; false; echo OK; }; (set -e; f); echo OK' 'OK OK' + + # according to the standard, only failing *simple* commands + # cause an exit under -e. () is not a simple command. + # Correct (per POSIX): + #dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK' + #echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK' + # Wrong current behavior: + dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK' + echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK' + + # make sure an inner nested shell does exit though. + dcheck '(set -e; (false; echo ERR)); echo OK' 'OK' + + # The left hand side of an || or && is explicitly tested and + # thus should not cause an exit. Furthermore, because a || or + # && expression is not a simple command, there should be no + # exit even if the overall result is false. + dcheck '(set -e; false || true; echo OK); echo OK' 'OK OK' + echeck '(set -e; false || true; echo OK); echo OK' 'OK OK' + dcheck '(set -e; false && true; echo OK); echo OK' 'OK OK' + echeck '(set -e; false && true; echo OK); echo OK' 'OK OK' + + # However, the right hand side is not tested, so a failure + # there *should* cause an exit, regardless of whether it + # appears inside a non-simple command. + # + # Note that in at least one place the standard does not + # distinguish between the left and right hand sides of + # logical operators. It is possible that for strict + # compliance these need to not exit; however, if so that + # should probably be limited to when some strict-posix setting + # is in effect and tested accordingly. + # + dcheck '(set -e; false || false; echo ERR); echo OK' 'OK' + dcheck '(set -e; true && false; echo ERR); echo OK' 'OK' + echeck '(set -e; false || false; echo ERR); echo OK' 'OK' + echeck '(set -e; true && false; echo ERR); echo OK' 'OK' + + # correct: + #dcheck '(set -e; false && false; echo ERR); echo OK' 'OK' + #echeck '(set -e; false && false; echo ERR); echo OK' 'OK' + + # wrong current behavior: + dcheck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' + echeck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' + + # A failure that is not reached because of short-circuit + # evaluation should not cause an exit, however. + dcheck '(set -e; true || false; echo OK); echo OK' 'OK OK' + echeck '(set -e; true || false; echo OK); echo OK' 'OK OK' + + # For completeness, test the other two combinations. + dcheck '(set -e; true || true; echo OK); echo OK' 'OK OK' + dcheck '(set -e; true && true; echo OK); echo OK' 'OK OK' + echeck '(set -e; true || true; echo OK); echo OK' 'OK OK' + echeck '(set -e; true && true; echo OK); echo OK' 'OK OK' + + # likewise, none of these should exit. + dcheck '(set -e; while false; do :; done; echo OK); echo OK' 'OK OK' + dcheck '(set -e; if false; then :; fi; echo OK); echo OK' 'OK OK' + # problematic :-) + #dcheck '(set -e; until false; do :; done; echo OK); echo OK' 'OK OK' + dcheck '(set -e; until [ "$t" = 1 ]; do t=1; done; echo OK); echo OK' \ + 'OK OK' + echeck '(set -e; while false; do :; done; echo OK); echo OK' 'OK OK' + echeck '(set -e; if false; then :; fi; echo OK); echo OK' 'OK OK' + echeck '(set -e; until [ "$t" = 1 ]; do t=1; done; echo OK); echo OK' \ + 'OK OK' + + # the bang operator tests its argument and thus the argument + # should not cause an exit. it is also not a simple command (I + # believe) so it also shouldn't exit even if it yields a false + # result. + dcheck '(set -e; ! false; echo OK); echo OK' 'OK OK' + dcheck '(set -e; ! true; echo OK); echo OK' 'OK OK' + echeck '(set -e; ! false; echo OK); echo OK' 'OK OK' + echeck '(set -e; ! true; echo OK); echo OK' 'OK OK' + + # combined case with () and &&; the inner expression is false + # but does not itself exit, and the () should not cause an + # exit even when failing. + # correct: + #dcheck '(set -e; (false && true); echo OK); echo OK' 'OK OK' + #echeck '(set -e; (false && true); echo OK); echo OK' 'OK OK' + # wrong current behavior: + dcheck '(set -e; (false && true); echo OK); echo OK' 'OK' + echeck '(set -e; (false && true); echo OK); echo OK' 'OK' + + # pipelines. only the right-hand end is significant. + dcheck '(set -e; false | true; echo OK); echo OK' 'OK OK' + echeck '(set -e; false | true; echo OK); echo OK' 'OK OK' + dcheck '(set -e; true | false; echo ERR); echo OK' 'OK' + echeck '(set -e; true | false; echo ERR); echo OK' 'OK' + + dcheck '(set -e; while true | false; do :; done; echo OK); echo OK' \ + 'OK OK' + dcheck '(set -e; if true | false; then :; fi; echo OK); echo OK' \ + 'OK OK' + + + # According to dsl@ in PR bin/32282, () is not defined as a + # subshell, only as a grouping operator [and a scope, I guess] + # so the nested false ought to cause the whole shell to exit, + # not just the subshell. dholland@ would like to see C&V, + # because that seems like a bad idea. (Among other things, it + # would break all the above test logic, which relies on being + # able to isolate set -e behavior inside ().) However, I'm + # going to put these tests here to make sure the issue gets + # dealt with sometime. + # + # XXX: the second set has been disabled in the name of making + # all tests "pass". + + # 1. error if the whole shell exits (current behavior) + dcheck 'echo OK; (set -e; false); echo OK' 'OK OK' + echeck 'echo OK; (set -e; false); echo OK' 'OK OK' + # 2. error if the whole shell does not exit (dsl's suggested behavior) + #dcheck 'echo OK; (set -e; false); echo ERR' 'OK' + #echeck 'echo OK; (set -e; false); echo ERR' 'OK' + + # The current behavior of the shell is that it exits out as + # far as -e is set and then stops. This is probably a + # consequence of it handling () wrong, but it's a somewhat + # curious compromise position between 1. and 2. above. + dcheck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK' + echeck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK' + + # backquote expansion (PR bin/17514) + + # correct + #dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' + # wrong current behavior + dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + + dcheck '(set -e; x=`false`; echo ERR); echo OK' 'OK' + dcheck '(set -e; x=$(false); echo ERR); echo OK' 'OK' + dcheck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' + dcheck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' + + # correct + #echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' + + # wrong current behavior + echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + + echeck '(set -e; x=`false`; echo ERR); echo OK' 'OK' + echeck '(set -e; x=$(false); echo ERR); echo OK' 'OK' + echeck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' + echeck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' + + # shift (PR bin/37493) + # correct + #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK OK' + #echeck '(set -e; shift || true; echo OK); echo OK' 'OK OK' + # wrong current behavior + dcheck '(set -e; shift || true; echo OK); echo OK' 'OK' + echeck '(set -e; shift || true; echo OK); echo OK' 'OK' + + # Done. + + if [ "x$SH_FAILS" != x ]; then + printf '%-56s %-8s %s\n' "Expression" "Result" "Should be" + echo "$SH_FAILS" + atf_fail "$failcount of $count failed cases" + else + atf_pass + fi +} + +atf_init_test_cases() { + atf_add_test_case all +} diff --git a/contrib/netbsd-tests/bin/sh/t_ulimit.sh b/contrib/netbsd-tests/bin/sh/t_ulimit.sh new file mode 100755 index 000000000000..3e7c0a68e70f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_ulimit.sh @@ -0,0 +1,46 @@ +# $NetBSD: t_ulimit.sh,v 1.1 2012/06/11 18:32:59 njoly Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# ulimit builtin test. + +atf_test_case limits +limits_head() { + atf_set "descr" "Checks for limits flags" +} +limits_body() { + atf_check -s eq:0 -o ignore -e empty \ + /bin/sh -c "ulimit -a" + for l in $(ulimit -a | sed 's,^.*(,,;s, .*$,,'); + do + atf_check -s eq:0 -o ignore -e empty \ + /bin/sh -c "ulimit $l" + done +} + +atf_init_test_cases() { + atf_add_test_case limits +} diff --git a/contrib/netbsd-tests/bin/sh/t_varquote.sh b/contrib/netbsd-tests/bin/sh/t_varquote.sh new file mode 100755 index 000000000000..17687779637a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_varquote.sh @@ -0,0 +1,81 @@ +# $NetBSD: t_varquote.sh,v 1.2 2012/03/25 18:50:19 christos Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# Variable quoting test. + +check() { + if [ "$1" != "$2" ] + then + atf_fail "expected [$2], found [$1]" 1>&2 + fi +} + +atf_test_case all +all_head() { + atf_set "descr" "Basic checks for variable quoting" +} +all_body() { + foo='${a:-foo}' + check "$foo" '${a:-foo}' + + foo="${a:-foo}" + check "$foo" "foo" + + foo=${a:-"'{}'"} + check "$foo" "'{}'" + + foo=${a:-${b:-"'{}'"}} + check "$foo" "'{}'" + + foo="${a:-"'{}'"}" + check "$foo" "'{}'" + + foo="${a:-${b:-"${c:-${d:-"x}"}}y}"}}z}" + # " z*" + # ${a:- } + # ${b:- } + # " y*" + # ${c:- } + # ${d:- } + # "x*" + check "$foo" "x}y}z}" +} + +atf_test_case nested_quotes_multiword +nested_quotes_multiword_head() { + atf_set "descr" "Tests that having nested quoting in a multi-word" \ + "string works (PR bin/43597)" +} +nested_quotes_multiword_body() { + atf_check -s eq:0 -o match:"first-word second-word" -e empty \ + /bin/sh -c 'echo "${foo:="first-word"} second-word"' +} + +atf_init_test_cases() { + atf_add_test_case all + atf_add_test_case nested_quotes_multiword +} diff --git a/contrib/netbsd-tests/bin/sh/t_wait.sh b/contrib/netbsd-tests/bin/sh/t_wait.sh new file mode 100755 index 000000000000..99b47df7ad27 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_wait.sh @@ -0,0 +1,59 @@ +# $NetBSD: t_wait.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case individual +individual_head() { + atf_set "descr" "Tests that waiting for individual jobs works" +} +individual_body() { + # atf-sh confuses wait for some reason; work it around by creating + # a helper script that executes /bin/sh directly. + cat >helper.sh < 4 +node 1 -> 1 +node 2 -> 1 +node 3 -> 4 +node 4 -> 0 +node 5 -> 2 +node 6 -> 1 +node 7 -> 1 +node 8 -> 6 +node 9 -> 2 +node 10 -> 1 +node 11 -> 1 +node 12 -> 3 +node 13 -> 1 +node 14 -> 4 +node 15 -> 3 +node 16 -> 5 +node 17 -> 0 +node 18 -> 2 +node 19 -> 0 +node 20 -> 2 +node 21 -> 2 +node 22 -> 0 +node 23 -> 1 +20 nodes used out of 24 +47 items +load 1.95 actual load 2.35 +init2=10 +cipher1=NULL +s_client:cipher1=DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5cipher2 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +---------------------------- DUMP ------------------------ +[req] Attribute_text_7=Email Address +[req] Attribute_text_2=State or Province Name (full name) +[default] tmp_cert_dir=/tmp/eay/.ca_certs +[req] Attribute_text_1=Country Name (2 letter code) +[[genrsa]] +[req] Attribute_default_5=TR +[req] Attribute_text_6=Common Name (eg, YOUR name) +[req] Attribute_default_1=AU +[[req]] +[[special]] +[[gendh]] +[req] Attribute_text_3=Locality Name (eg, city) +[req] Attribute_type_1=countryName +[default] init5==10' again +[req] Attribute_type_3=localityName +[s_client] cipher3=DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +[default] in\#it1=10 +[req] Attribute_text_4=Organization Name (eg, company) +[req] Attribute_type_7=emailAddress +[gendh] def_generator=2 +[default] HOME=/tmp/eay +[s_client] cipher4=DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +[default] init=5 +[SSLeay] version=0.5.0 +[req] Attribute_type_4=organizationName +[default] tmp2_cert_dir=thisis/tmp/eaystuff +[req] Attribute_type_5=organizationalUnitName +[[SSLEAY]] +[default] init4=10' +[[default]] +[default] LOGNAME=Eric Young (home=/tmp/eay) +[special] RANDFILE=/tmp/eay/.rand +[req] default_keyfile=privkey.pem +[req] Attribute_default_4=Mincom Pty Ltd +[req] Attribute_default_2=Queensland +[gendh] default_bits=512 +[req] default_bits=512 +[default] init2=10 +[SSLEAY] version=0.5.0 +[s_client] cipher1=DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5cipher2 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +[req] Attribute_text_5=Organizational Unit Name (eg, section) +[req] Attribute_type_2=stateOrProvinceName +[genrsa] default_bits=512 +[default] init3=10' +[[SSLeay]] +[[s_client]] +[req] Attribute_type_6=commonName diff --git a/contrib/netbsd-tests/crypto/libcrypto/conf/d_conf_ssleay.cnf b/contrib/netbsd-tests/crypto/libcrypto/conf/d_conf_ssleay.cnf new file mode 100644 index 000000000000..3fdde34dd264 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/conf/d_conf_ssleay.cnf @@ -0,0 +1,78 @@ +# +# This is a test configuration file for use in SSLeay etc... +# + +init = 5 +in\#it1 =10 +init2='10' +init3='10\'' +init4="10'" +init5='='10\'' again' + +SSLeay::version = 0.5.0 + +[genrsa] +default_bits = 512 +SSLEAY::version = 0.5.0 + +[gendh] +default_bits = 512 +def_generator = 2 + +[s_client] +cipher1 = DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5\ +cipher2 = 'DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5' +cipher3 = "DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5" +cipher4 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 + +[ default ] +#cert_dir = $ENV::HOME/.ca_certs + +HOME = /tmp/eay + +tmp_cert_dir = $HOME/.ca_certs +tmp2_cert_dir = thisis$(HOME)stuff + +LOGNAME = Eric Young (home=$HOME) + +[ special ] + +#H=$HOME +#H=$default::HOME +#H=$ENV::HOME +# +# SSLeay example configuration file. +# This is mostly being used for generation of certificate requests. +# + +RANDFILE = $HOME/.rand + +[ req ] +default_bits = 512 +default_keyfile = privkey.pem + +Attribute_type_1 = countryName +Attribute_text_1 = Country Name (2 letter code) +Attribute_default_1 = AU + +Attribute_type_2 = stateOrProvinceName +Attribute_text_2 = State or Province Name (full name) +Attribute_default_2 = Queensland + +Attribute_type_3 = localityName +Attribute_text_3 = Locality Name (eg, city) + +Attribute_type_4 = organizationName +Attribute_text_4 = Organization Name (eg, company) +Attribute_default_4 = Mincom Pty Ltd + +Attribute_type_5 = organizationalUnitName +Attribute_text_5 = Organizational Unit Name (eg, section) +Attribute_default_5 = TR + +Attribute_type_6 = commonName +Attribute_text_6 = Common Name (eg, YOUR name) + +Attribute_type_7 = emailAddress +Attribute_text_7 = Email Address + diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh b/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh new file mode 100755 index 000000000000..6965a5727022 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh @@ -0,0 +1,41 @@ +# $NetBSD: t_certs.sh,v 1.1 2010/07/10 16:43:25 jmmv Exp $ +# +# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case x509v3 +x509v3_head() +{ + atf_set "descr" "Checks x509v3 certificates" +} +x509v3_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_x509v3test" +} + +atf_init_test_cases() +{ + atf_add_test_case x509v3 +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh b/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh new file mode 100755 index 000000000000..127040773aa7 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh @@ -0,0 +1,122 @@ +# $NetBSD: t_ciphers.sh,v 1.4 2012/07/14 16:04:06 spz Exp $ +# +# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case bf +bf_head() +{ + atf_set "descr" "Checks blowfish cipher" +} +bf_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_bftest" +} + +atf_test_case cast +cast_head() +{ + atf_set "descr" "Checks CAST cipher" + atf_set "timeout" "300" +} +cast_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_casttest" +} + +atf_test_case des +des_head() +{ + atf_set "descr" "Checks DES cipher (libdes)" +} +des_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_destest" +} + +atf_test_case evp +evp_head() +{ + atf_set "descr" "Checks EVP cipher" +} +evp_body() +{ + atf_check -o ignore -e ignore $(atf_get_srcdir)/h_evp_test $(atf_get_srcdir)/evptests.txt +} + +atf_test_case rc2 +rc2_head() +{ + atf_set "descr" "Checks RC2 cipher" +} +rc2_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rc2test" +} + +atf_test_case rc4 +rc4_head() +{ + atf_set "descr" "Checks RC4 cipher" +} +rc4_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rc4test" +} + +atf_test_case idea +idea_head() +{ + atf_set "descr" "Checks IDEA cipher" +} +idea_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ideatest" +} + +atf_test_case rc5 +rc5_head() +{ + atf_set "descr" "Checks RC5 cipher" +} +rc5_body() +{ + [ -x "$(atf_get_srcdir)/h_rc5test" ] \ + || atf_skip "RC5 support not available; system built" \ + "with MKCRYPTO_RC5=no" + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rc5test" +} + +atf_init_test_cases() +{ + atf_add_test_case bf + atf_add_test_case cast + atf_add_test_case des + atf_add_test_case evp + atf_add_test_case rc2 + atf_add_test_case rc4 + atf_add_test_case idea + atf_add_test_case rc5 +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh b/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh new file mode 100755 index 000000000000..700dbdbf9fc9 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh @@ -0,0 +1,108 @@ +# $NetBSD: t_hashes.sh,v 1.2 2012/07/14 16:04:06 spz Exp $ +# +# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case hmac +hmac_head() +{ + atf_set "descr" "Checks HMAC message authentication code" +} +hmac_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_hmactest" +} + +atf_test_case md2 +md2_head() +{ + atf_set "descr" "Checks MD2 digest" +} +md2_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_md2test" +} + +atf_test_case md4 +md4_head() +{ + atf_set "descr" "Checks MD4 digest" +} +md4_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_md4test" +} + +atf_test_case md5 +md5_head() +{ + atf_set "descr" "Checks MD5 digest" +} +md5_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_md5test" +} + +atf_test_case ripemd +ripemd_head() +{ + atf_set "descr" "Checks RMD-160 digest" +} +ripemd_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ripemdtest" +} + +atf_test_case sha +sha_head() +{ + atf_set "descr" "Checks SHA-1 digest" +} +sha_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_shatest" +} + + +atf_test_case mdc2 +mdc2_head() +{ + atf_set "descr" "Checks MDC2 digest" +} +mdc2_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_mdc2test" +} + +atf_init_test_cases() +{ + atf_add_test_case hmac + atf_add_test_case md2 + atf_add_test_case md4 + atf_add_test_case md5 + atf_add_test_case ripemd + atf_add_test_case sha + atf_add_test_case mdc2 +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh new file mode 100755 index 000000000000..aa7af27ceee4 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh @@ -0,0 +1,107 @@ +# $NetBSD: t_libcrypto.sh,v 1.3 2010/11/08 19:06:12 pooka Exp $ +# +# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case engine +engine_head() +{ + atf_set "descr" "Checks ENGINE framework" +} +engine_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_enginetest" +} + +atf_test_case rand +rand_head() +{ + atf_set "descr" "Checks peudo-random number generator" +} +rand_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_randtest" +} + +atf_test_case bn +bn_head() +{ + atf_set "descr" "Checks BIGNUM library" + atf_set "timeout" "300" +} +bn_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_bntest" + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_divtest" + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_exptest" +} + +atf_test_case conf +conf_head() +{ + atf_set "descr" "Checks configuration modules" +} +conf_body() +{ + cp $(atf_get_srcdir)/d_conf_ssleay.cnf ssleay.cnf + + atf_check -o file:$(atf_get_srcdir)/d_conf.out \ + $(atf_get_srcdir)/h_conftest +} + +atf_test_case lhash +lhash_head() +{ + atf_set "descr" "Checks lhash - dynamic hash tables" +} +lhash_body() +{ + atf_check -o ignore -e ignore -x \ + "echo hoge | $(atf_get_srcdir)/h_lhashtest" +} + +atf_test_case threads +threads_head() +{ + atf_set "descr" "Checks threading" +} +threads_body() +{ + $(atf_get_srcdir)/h_threadstest \ + -cert $(atf_get_srcdir)/d_server.pem \ + -ccert $(atf_get_srcdir)/d_client.pem \ + 2>&1 | tee out + atf_check -s eq:1 -o empty -e empty grep :error: out +} + +atf_init_test_cases() +{ + atf_add_test_case engine + atf_add_test_case rand + atf_add_test_case bn + atf_add_test_case conf + atf_add_test_case lhash + atf_add_test_case threads +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh new file mode 100755 index 000000000000..1453e757a4cc --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh @@ -0,0 +1,110 @@ +# $NetBSD: t_pubkey.sh,v 1.3 2011/06/09 05:25:21 spz Exp $ +# +# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case dsa +dsa_head() +{ + atf_set "descr" "Checks DSA cipher" +} +dsa_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_dsatest" +} + +atf_test_case dh +dh_head() +{ + atf_set "descr" "Checks Diffie-Hellman key agreement protocol" +} +dh_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_dhtest" +} + +atf_test_case rsa +rsa_head() +{ + atf_set "descr" "Checks RSA" + atf_set "timeout" "300" +} +rsa_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rsatest" +} + +atf_test_case ec +ec_head() +{ + atf_set "descr" "Checks EC cipher" + atf_set "timeout" "300" +} +ec_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ectest" +} + +atf_test_case ecdh +ecdh_head() +{ + atf_set "descr" "Checks ECDH key agreement protocol" +} +ecdh_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ecdhtest" +} + +atf_test_case ecdsa +ecdsa_head() +{ + atf_set "descr" "Checks ECDSA algorithm" + atf_set "timeout" "300" +} +ecdsa_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ecdsatest" +} + +atf_test_case srp +srp_head() +{ + atf_set "descr" "Checks SRP key agreement protocol" +} +srp_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_srptest" +} + +atf_init_test_cases() +{ + atf_add_test_case dsa + atf_add_test_case dh + atf_add_test_case rsa + atf_add_test_case ec + atf_add_test_case ecdh + atf_add_test_case ecdsa + atf_add_test_case srp +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_aesctr1.c b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr1.c new file mode 100644 index 000000000000..41d866cf17cb --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr1.c @@ -0,0 +1,250 @@ +/* $NetBSD: h_aesctr1.c,v 1.4 2014/01/19 13:40:59 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include +#include + +#include +#include + +#include + +/* + * Test vectors from RFC 3686 + * + * Test vectors 3, 6, and 9 are disabled because we don't support + * 36-byte (ie, unpadded) operations. + */ + +const struct { + size_t len; + size_t key_len; + unsigned char key[36]; /* Includes 32-bit nonce */ + unsigned char iv[8]; + unsigned char plaintx[36]; + unsigned char ciphertx[36]; +} tests[] = { + /* Test Vector #1: Encrypting 16 octets using AES-CTR w/ 128-bit key*/ + { 16, 20, + { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, + 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E, + 0x00, 0x00, 0x00, 0x30 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, + 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8 } + }, + + /* Test Vector #2: Encrypting 32 octets using AES-CTR w/ 128-bit key */ + { 32, 20, + { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, + 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63, + 0x00, 0x6C, 0xB6, 0xDB }, + { 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, + 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, + 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, + 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28 } + }, + + /* Test Vector #3: Encrypting 36 octets using AES-CTR w/ 128-bit key */ +/* { 36, 20, + { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, + 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC, + 0x00, 0xE0, 0x01, 0x7B }, + { 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + { 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, + 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, + 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, + 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, + 0x25, 0xB2, 0x07, 0x2F } + }, +*/ + /* Test Vector #4: Encrypting 16 octets using AES-CTR w/ 192-bit key */ + { 16, 28, + { 0x16, 0xAF, 0x5B, 0x14, 0x5F, 0xC9, 0xF5, 0x79, + 0xC1, 0x75, 0xF9, 0x3E, 0x3B, 0xFB, 0x0E, 0xED, + 0x86, 0x3D, 0x06, 0xCC, 0xFD, 0xB7, 0x85, 0x15, + 0x00, 0x00, 0x00, 0x48 }, + { 0x36, 0x73, 0x3C, 0x14, 0x7D, 0x6D, 0x93, 0xCB }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0x4B, 0x55, 0x38, 0x4F, 0xE2, 0x59, 0xC9, 0xC8, + 0x4E, 0x79, 0x35, 0xA0, 0x03, 0xCB, 0xE9, 0x28 } + }, + + /* Test Vector #5: Encrypting 32 octets using AES-CTR w/ 192-bit key */ + { 32, 28, + { 0x7C, 0x5C, 0xB2, 0x40, 0x1B, 0x3D, 0xC3, 0x3C, + 0x19, 0xE7, 0x34, 0x08, 0x19, 0xE0, 0xF6, 0x9C, + 0x67, 0x8C, 0x3D, 0xB8, 0xE6, 0xF6, 0xA9, 0x1A, + 0x00, 0x96, 0xB0, 0x3B }, + { 0x02, 0x0C, 0x6E, 0xAD, 0xC2, 0xCB, 0x50, 0x0D }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0x45, 0x32, 0x43, 0xFC, 0x60, 0x9B, 0x23, 0x32, + 0x7E, 0xDF, 0xAA, 0xFA, 0x71, 0x31, 0xCD, 0x9F, + 0x84, 0x90, 0x70, 0x1C, 0x5A, 0xD4, 0xA7, 0x9C, + 0xFC, 0x1F, 0xE0, 0xFF, 0x42, 0xF4, 0xFB, 0x00 } + }, + + /* Test Vector #6: Encrypting 36 octets using AES-CTR w/ 192-bit key */ +/* + { 36, 28, + { 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59, + 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B, + 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE, + 0x00, 0x07, 0xBD, 0xFD }, + { 0x5C, 0xBD, 0x60, 0x27, 0x8D, 0xCC, 0x09, 0x12 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + { 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F, + 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58, + 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88, + 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88, + 0xAB, 0xEE, 0x09, 0x35 }, + }, +*/ + /* Test Vector #7: Encrypting 16 octets using AES-CTR w/ 256-bit key */ + { 16, 36, + { 0x77, 0x6B, 0xEF, 0xF2, 0x85, 0x1D, 0xB0, 0x6F, + 0x4C, 0x8A, 0x05, 0x42, 0xC8, 0x69, 0x6F, 0x6C, + 0x6A, 0x81, 0xAF, 0x1E, 0xEC, 0x96, 0xB4, 0xD3, + 0x7F, 0xC1, 0xD6, 0x89, 0xE6, 0xC1, 0xC1, 0x04, + 0x00, 0x00, 0x00, 0x60 }, + { 0xDB, 0x56, 0x72, 0xC9, 0x7A, 0xA8, 0xF0, 0xB2 }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0x14, 0x5A, 0xD0, 0x1D, 0xBF, 0x82, 0x4E, 0xC7, + 0x56, 0x08, 0x63, 0xDC, 0x71, 0xE3, 0xE0, 0xC0 }, + }, + + /* Test Vector #8: Encrypting 32 octets using AES-CTR w/ 256-bit key */ + { 32, 36, + { 0xF6, 0xD6, 0x6D, 0x6B, 0xD5, 0x2D, 0x59, 0xBB, + 0x07, 0x96, 0x36, 0x58, 0x79, 0xEF, 0xF8, 0x86, + 0xC6, 0x6D, 0xD5, 0x1A, 0x5B, 0x6A, 0x99, 0x74, + 0x4B, 0x50, 0x59, 0x0C, 0x87, 0xA2, 0x38, 0x84, + 0x00, 0xFA, 0xAC, 0x24 }, + { 0xC1, 0x58, 0x5E, 0xF1, 0x5A, 0x43, 0xD8, 0x75 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0xF0, 0x5E, 0x23, 0x1B, 0x38, 0x94, 0x61, 0x2C, + 0x49, 0xEE, 0x00, 0x0B, 0x80, 0x4E, 0xB2, 0xA9, + 0xB8, 0x30, 0x6B, 0x50, 0x8F, 0x83, 0x9D, 0x6A, + 0x55, 0x30, 0x83, 0x1D, 0x93, 0x44, 0xAF, 0x1C }, + }, + + /* Test Vector #9: Encrypting 36 octets using AES-CTR w/ 256-bit key */ +/* + { 36, 36, + { 0xFF 0x7A 0x61 0x7C 0xE6 0x91 0x48 0xE4, + 0xF1 0x72 0x6E 0x2F 0x43 0x58 0x1D 0xE2, + 0xAA 0x62 0xD9 0xF8 0x05 0x53 0x2E 0xDF, + 0xF1 0xEE 0xD6 0x87 0xFB 0x54 0x15 0x3D, + 0x00 0x1C 0xC5 0xB7 }, + { 0x51 0xA5 0x1D 0x70 0xA1 0xC1 0x11 0x48 }, + { 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07, + 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F, + 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17, + 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F, + 0x20 0x21 0x22 0x23 }, + { 0xEB 0x6C 0x52 0x82 0x1D 0x0B 0xBB 0xF7, + 0xCE 0x75 0x94 0x46 0x2A 0xCA 0x4F 0xAA, + 0xB4 0x07 0xDF 0x86 0x65 0x69 0xFD 0x07, + 0xF4 0x8C 0xC0 0xB5 0x83 0xD6 0x07 0x1F, + 0x1E 0xC0 0xE6 0xB8 }, + }, +*/ +}; + +int +main(void) +{ + int fd, res; + size_t i; + struct session_op cs; + struct crypt_op co; + unsigned char buf[36]; + + for (i = 0; i < __arraycount(tests); i++) { + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open %zu", i); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_AES_CTR; + cs.keylen = tests[i].key_len; + cs.key = __UNCONST(&tests[i].key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION %zu", i); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].plaintx); + co.dst = buf; + co.dst_len = sizeof(buf); + co.iv = __UNCONST(&tests[i].iv); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT %zu", i); + + if (memcmp(co.dst, tests[i].ciphertx, tests[i].len)) { + size_t j; + printf(" Loc Actual Golden\n"); + for (j = 0; j < tests[i].len; j++) + printf("0x%2zu: 0x%2x 0x%2x\n", j, + buf[j], tests[i].ciphertx[j]); + warnx("verification failed %zu", i); + } + close(fd); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_aesctr2.c b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr2.c new file mode 100644 index 000000000000..4bbd30ea1ecd --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr2.c @@ -0,0 +1,97 @@ +/* $NetBSD: h_aesctr2.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +unsigned char key[20] = {0xae, 0x68, 0x52, 0xf8, 0x12, 0x10, 0x67, 0xcc, + 0x4b, 0xf7, 0xa5, 0x76, 0x55, 0x77, 0xf3, 0x9e, + 0x00, 0x00, 0x00, 0x30}; +unsigned char iv[8] = {0}; +char plaintx[16] = "Single block msg"; +const unsigned char ciphertx[16] = { + 0xe4, 0x09, 0x5d, 0x4f, 0xb7, 0xa7, 0xb3, 0x79, + 0x2d, 0x61, 0x75, 0xa3, 0x26, 0x13, 0x11, 0xb8 +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char ibuf[24]; + unsigned char obuf[24]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_AES_CTR; + cs.keylen = 20; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memcpy(ibuf, iv, 8); + memcpy(ibuf + 8, plaintx, 16); + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(ibuf); + co.src = ibuf; + co.dst = obuf; + co.dst_len = sizeof(obuf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + memset(ibuf, 0, sizeof(ibuf)); + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_DECRYPT; + co.len = sizeof(obuf); + co.src = obuf; + co.dst = ibuf; + co.dst_len = sizeof(ibuf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp((char *)co.dst + 8, plaintx, sizeof(plaintx))) + warnx("verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_arc4.c b/contrib/netbsd-tests/crypto/opencrypto/h_arc4.c new file mode 100644 index 000000000000..4bf8428549bf --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_arc4.c @@ -0,0 +1,80 @@ +/* $NetBSD: h_arc4.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +unsigned char key[] = "abcdefgh"; +char plaintx[16] = "1234567890123456"; +const unsigned char ciphertx[16] = { + 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, + 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_ARC4; + cs.keylen = 8; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + errx(1, "verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_camellia.c b/contrib/netbsd-tests/crypto/opencrypto/h_camellia.c new file mode 100644 index 000000000000..bb489e77824d --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_camellia.c @@ -0,0 +1,87 @@ +/* $NetBSD: h_camellia.c,v 1.3 2014/01/17 19:39:51 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +/* Test vector from RFC3713 */ +unsigned char key[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; +unsigned char iv[16] = {0}; +char plaintx[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}; +const unsigned char ciphertx[16] = { + 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, + 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_CAMELLIA_CBC; + cs.keylen = 32; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + warnx("verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_cbcdes.c b/contrib/netbsd-tests/crypto/opencrypto/h_cbcdes.c new file mode 100644 index 000000000000..4861d783fe7d --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_cbcdes.c @@ -0,0 +1,82 @@ +/* $NetBSD: h_cbcdes.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +unsigned char key[] = "abcdefgh"; +unsigned char iv[8] = {0}; +char plaintx[16] = "1234567890123456"; +const unsigned char ciphertx[16] = { + 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, + 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_DES_CBC; + cs.keylen = 8; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + errx(1, "verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_comp.c b/contrib/netbsd-tests/crypto/opencrypto/h_comp.c new file mode 100644 index 000000000000..dd5f6470c5d6 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_comp.c @@ -0,0 +1,90 @@ +/* $NetBSD: h_comp.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include +#include + +#include +#include + +#include + +char text[100000] = {0}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co1, co2; + unsigned char buf1[10000], buf2[100000]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.comp_alg = CRYPTO_GZIP_COMP; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co1, 0, sizeof(co1)); + co1.ses = cs.ses; + co1.op = COP_COMP; + co1.len = sizeof(text); + co1.src = text; + co1.dst = buf1; + co1.dst_len = sizeof(buf1); + res = ioctl(fd, CIOCCRYPT, &co1); + if (res < 0) + err(1, "CIOCCRYPT1"); + fprintf(stderr, "len %d/%d\n", co1.len, co1.dst_len); +#if 0 + buf1[co1.dst_len - 8]++; /* modify CRC */ +#endif + write(1, buf1, co1.dst_len); + memset(&co2, 0, sizeof(co2)); + co2.ses = cs.ses; + co2.op = COP_DECOMP; + co2.len = co1.dst_len; + co2.src = buf1; + co2.dst = buf2; + co2.dst_len = sizeof(buf2); + buf2[10] = 0x33; + res = ioctl(fd, CIOCCRYPT, &co2); + fprintf(stderr, "canary: %x\n", buf2[10]); + if (res < 0) + err(1, "CIOCCRYPT2"); + fprintf(stderr, "len %d/%d\n", co2.len, co2.dst_len); + if (memcmp(text, buf2, co2.dst_len)) + errx(1, "memcmp"); + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib.c b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib.c new file mode 100644 index 000000000000..7a57ceb31839 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib.c @@ -0,0 +1,92 @@ +/* $NetBSD: h_comp_zlib.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +char text[10000] = {0}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co1; + unsigned char buf1[10000], buf2[10000]; + z_stream z; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.comp_alg = CRYPTO_DEFLATE_COMP; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co1, 0, sizeof(co1)); + co1.ses = cs.ses; + co1.op = COP_COMP; + co1.len = sizeof(text); + co1.src = text; + co1.dst = buf1; + co1.dst_len = sizeof(buf1); + co1.flags = COP_F_BATCH; + res = ioctl(fd, CIOCCRYPT, &co1); + if (res < 0) + err(1, "CIOCCRYPT"); + + memset(&z, 0, sizeof(z)); + z.next_in = buf1; + z.avail_in = co1.dst_len; + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = 0; + z.next_out = buf2; + z.avail_out = sizeof(buf2); + res = inflateInit2(&z, -15); + if (res != Z_OK) + errx(1, "inflateInit: %d", res); + do { + res = inflate(&z, Z_SYNC_FLUSH); + } while (res == Z_OK); + if (res != Z_STREAM_END) + errx(1, "inflate: %d", res); + if (z.total_out != sizeof(text)) + errx(1, "decomp len %lu", z.total_out); + if (memcmp(buf2, text, sizeof(text))) + errx(1, "decomp data mismatch"); + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib_rnd.c b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib_rnd.c new file mode 100644 index 000000000000..86ed55afaaf3 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib_rnd.c @@ -0,0 +1,96 @@ +/* $NetBSD: h_comp_zlib_rnd.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include +#include + +#include +#include + +#include + +char text[1000]; + +int +main(void) +{ + unsigned int i; + int fd, res; + struct session_op cs; + struct crypt_op co1; + unsigned char buf1[10000], buf2[10000]; + z_stream z; + + for (i = 0; i < sizeof(text)/sizeof(long); i++) + *(long *)(text + i * sizeof(long)) = random(); + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.comp_alg = CRYPTO_DEFLATE_COMP; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co1, 0, sizeof(co1)); + co1.ses = cs.ses; + co1.op = COP_COMP; + co1.len = sizeof(text); + co1.src = text; + co1.dst = buf1; + co1.dst_len = sizeof(buf1); + res = ioctl(fd, CIOCCRYPT, &co1); + if (res < 0) + err(1, "CIOCCRYPT"); + + memset(&z, 0, sizeof(z)); + z.next_in = buf1; + z.avail_in = co1.dst_len; + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = 0; + z.next_out = buf2; + z.avail_out = sizeof(buf2); + res = inflateInit2(&z, -15); + if (res != Z_OK) + errx(1, "inflateInit: %d", res); + do { + res = inflate(&z, Z_SYNC_FLUSH); + } while (res == Z_OK); + if (res != Z_STREAM_END) + errx(1, "inflate: %d", res); + if (z.total_out != sizeof(text)) + errx(1, "decomp len %lu", z.total_out); + if (memcmp(buf2, text, sizeof(text))) + errx(1, "decomp data mismatch"); + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_gcm.c b/contrib/netbsd-tests/crypto/opencrypto/h_gcm.c new file mode 100644 index 000000000000..33f41f0eb271 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_gcm.c @@ -0,0 +1,126 @@ +/* $NetBSD: h_gcm.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +unsigned char key[20] = { 0 }; +char plaintx[16] = { 0 }; +unsigned char iv[16] = { 0 }; +const unsigned char ciphertx[16] = { + 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, + 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78 +}; +const unsigned char hash[16] = { + 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, + 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char databuf[16]; + unsigned char macbuf[16]; + unsigned char databuf2[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_AES_128_GMAC; + cs.mackeylen = sizeof(key); + cs.mackey = key; + cs.cipher = CRYPTO_AES_GCM_16; + cs.key = key; + cs.keylen = sizeof(key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + memset(databuf, 0, sizeof(databuf)); + memset(macbuf, 0, sizeof(macbuf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = databuf; + co.mac = macbuf; + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); +#if 1 + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + errx(1, "verification failed"); + if (memcmp(macbuf, hash, sizeof(hash))) + errx(1, "hash failed"); +#else + { + int i; + for (i = 0; i < sizeof(databuf); i++) + printf("%02x ", databuf[i]); + printf("\n"); + } + { + int i; + for (i = 0; i < sizeof(macbuf); i++) + printf("%02x ", macbuf[i]); + printf("\n"); + } +#endif + memset(databuf2, 0, sizeof(databuf2)); + memset(macbuf, 0, sizeof(macbuf)); + co.ses = cs.ses; + co.op = COP_DECRYPT; + co.len = sizeof(databuf); + co.src = databuf; + co.dst = databuf2; + co.mac = macbuf; + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, plaintx, sizeof(plaintx))) + errx(1, "verification failed"); + if (memcmp(macbuf, hash, sizeof(hash))) + errx(1, "hash failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_md5.c b/contrib/netbsd-tests/crypto/opencrypto/h_md5.c new file mode 100644 index 000000000000..98379c79d2ed --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_md5.c @@ -0,0 +1,109 @@ +/* $NetBSD: h_md5.c,v 1.5 2014/01/18 20:10:34 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +/* Test vectors from RFC1321 */ + +const struct { + size_t len; + unsigned char plaintx[80]; + unsigned char digest[16]; +} tests[] = { + { 0, "", + { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, + 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, + { 1, "a", + { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, + 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, + { 3, "abc", + { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, + 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, + { 14, "message digest", + { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, + 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, + { 26, "abcdefghijklmnopqrstuvwxyz", + { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, + 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, + { 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, + 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, + { 80, "123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890", + { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, + 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, +}; + +int +main(void) +{ + int fd, res; + size_t i; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_MD5; + + for (i = 0; i < __arraycount(tests); i++) { + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %zu", i); + + memset(&co, 0, sizeof(co)); + memset(&buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].plaintx); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %zu", i); + + if (memcmp(co.mac, tests[i].digest, sizeof(tests[i].digest))) + errx(1, "verification failed test %zu", i); + + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %zu", i); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_md5hmac.c b/contrib/netbsd-tests/crypto/opencrypto/h_md5hmac.c new file mode 100644 index 000000000000..6753094c51e1 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_md5hmac.c @@ -0,0 +1,181 @@ +/* $NetBSD: h_md5hmac.c,v 1.4 2014/01/18 02:31:14 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +#define MD5_HMAC_KEYLEN 16 /* Fixed key length supported */ + +/* Test data from RFC2202 */ +const struct { + int num; + size_t key_len; + size_t len; + unsigned char key[80]; + unsigned char data[80]; + unsigned char mac[16]; +} tests[] = { + /* Test #1 */ + { 1, 16, 8, + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b }, + "Hi There", + { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, + 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d } + }, + /* Test #2 */ + { 2, 4, 28, + "Jefe", + "what do ya want for nothing?", + { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, + 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 } + }, + /* Test #3 */ + { 3, 16, 50, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, + 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } + }, + /* Test #4 */ + { 4, 25, 50, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19 }, + { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd }, + { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea, + 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 } + }, + /* Test #5 */ + { 5, 16, 20, + { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c }, + "Test With Truncation", + { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00, + 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c } + }, + /* Test #6 */ + { 6, 80, 54, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key - Hash Key First", + { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f, + 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd } + }, + /* Test #7 */ + { 7, 80, 73, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key and Larger " + "Than One Block-Size Data", + { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee, + 0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e } + }, +}; + +int +main(void) +{ + size_t i; + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + for (i = 0; i < __arraycount(tests); i++) { + if (tests[i].key_len != MD5_HMAC_KEYLEN) + continue; + + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_MD5_HMAC; + cs.mackeylen = tests[i].key_len; + cs.mackey = __UNCONST(&tests[i].key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %d", tests[i].num); + + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].data); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %d", tests[i].num); + + if (memcmp(co.mac, tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %d", tests[i].num); + + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %d", tests[i].num); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_null.c b/contrib/netbsd-tests/crypto/opencrypto/h_null.c new file mode 100644 index 000000000000..85e480592583 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_null.c @@ -0,0 +1,76 @@ +/* $NetBSD: h_null.c,v 1.3 2014/01/17 19:35:33 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +unsigned char key[] = "abcdefgh"; +char plaintx[16] = "1234567890123456"; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_NULL_CBC; + cs.keylen = 8; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, plaintx, sizeof(plaintx))) + errx(1, "verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_sha1hmac.c b/contrib/netbsd-tests/crypto/opencrypto/h_sha1hmac.c new file mode 100644 index 000000000000..c153f761f2b8 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_sha1hmac.c @@ -0,0 +1,191 @@ +/* $NetBSD: h_sha1hmac.c,v 1.2 2014/01/18 02:31:14 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + +#define SHA1_HMAC_KEYLEN 20 /* Only key-length we support */ + +/* Test data from RFC2202 */ +const struct { + int num; + size_t key_len; + size_t len; + unsigned char key[80]; + unsigned char data[80]; + unsigned char mac[20]; +} tests[] = { + /* Test #1 */ + { 1, 20, 8, + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + "Hi There", + { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, + 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, + 0xf1, 0x46, 0xbe, 0x00 } + }, + /* Test #2 */ + { 2, 4, 28, + "Jefe", + "what do ya want for nothing?", + { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, + 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, + 0x25, 0x9a, 0x7c, 0x79 } + }, + /* Test #3 */ + { 3, 20, 50, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, + 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, + 0x63, 0xf1, 0x75, 0xd3 } + }, + /* Test #4 */ + { 4, 25, 50, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19 }, + { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd }, + { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, + 0xbc, 0x84, 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, + 0x2d, 0x72, 0x35, 0xda } + }, + /* Test #5 */ + { 5, 20, 20, + { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c }, + "Test With Truncation", + { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, + 0xe7, 0xf2, 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, + 0x4a, 0x9a, 0x5a, 0x04 } + }, + /* Test #6 */ + { 6, 80, 54, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key - Hash Key First", + { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, + 0x95, 0x70, 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, + 0xed, 0x40, 0x21, 0x12 } + }, + /* Test #7 */ + { 7, 80, 73, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key and Larger Than " + "One Block-Size Data", + { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, + 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, + 0xbb, 0xff, 0x1a, 0x91 } + }, +}; + +int +main(void) +{ + size_t i; + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[20]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + for (i = 0; i < __arraycount(tests); i++) { + if (tests[i].key_len != SHA1_HMAC_KEYLEN) + continue; + + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_SHA1_HMAC; + cs.mackeylen = tests[i].key_len; + cs.mackey = __UNCONST(&tests[i].key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %d", tests[i].num); + + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].data); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %d", tests[i].num); + + if (memcmp(co.mac, &tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %d", tests[i].num); + + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %d", tests[i].num); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_xcbcmac.c b/contrib/netbsd-tests/crypto/opencrypto/h_xcbcmac.c new file mode 100644 index 000000000000..3f89c6e3e5e1 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_xcbcmac.c @@ -0,0 +1,109 @@ +/* $NetBSD: h_xcbcmac.c,v 1.4 2014/01/16 23:56:04 joerg Exp $ */ + +/*- + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include +#include +#include + +#include +#include + +#include + + +/* test vectors from RFC3566 */ +unsigned char key[16] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f +}; +char plaintx[1000] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21 +}; +const struct { + size_t len; + unsigned char mac[12]; +} tests[] = { + { 0, { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, + 0xc0, 0x1c, 0x45, 0x73, 0xdf, 0xd5 } }, + { 3, { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, + 0x19, 0xaf, 0xe7, 0x21, 0x9c, 0xee } }, + { 16, { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, + 0x68, 0xa7, 0x99, 0x98, 0xa4, 0x39 } }, + { 20, { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, + 0x62, 0x15, 0xb8, 0x98, 0x5c, 0x63 } }, + { 32, { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, + 0xf3, 0xd3, 0x68, 0x07, 0x73, 0x4b } }, + { 34, { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, + 0x18, 0xa3, 0x06, 0x77, 0xd5, 0x48 } }, + { 1000, { 0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, + 0x30, 0x25, 0x37, 0x61, 0x10, 0x3b } }, +}; + +int +main(void) +{ + int fd, res; + size_t i; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_AES_XCBC_MAC_96; + cs.mackeylen = sizeof(key); + cs.mackey = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + for (i = 0; i < __arraycount(tests); i++) { + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + if (tests[i].len == sizeof(plaintx)) + memset(&plaintx, 0, sizeof(plaintx)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = plaintx; + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %zu", i); + if (memcmp(buf, &tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %zu", i); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh new file mode 100755 index 000000000000..f7faa3af9aca --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh @@ -0,0 +1,272 @@ +# $NetBSD: t_opencrypto.sh,v 1.4 2014/01/18 15:15:16 pgoyette Exp $ +# +# Copyright (c) 2014 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# Start a rumpserver, load required modules, and set requires sysctl vars + +start_rump() { + rump_libs="-l rumpvfs -l rumpdev -l rumpdev_opencrypto" + rump_libs="${rump_libs} -l rumpkern_z -l rumpkern_crypto" + + rump_server ${rump_libs} ${RUMP_SERVER} || \ + return 1 + + rump.sysctl -w kern.cryptodevallowsoft=-1 && \ + return 0 + + rump.halt + + return 1 +} + +common_head() { + atf_set descr "$1" + atf_set timeout 10 + atf_set require.progs rump_server rump.sysctl rump.halt +} + +common_body() { + local status + + start_rump || atf_skip "Cannot set-up rump environment" + LD_PRELOAD="/usr/lib/librumphijack.so" ; export LD_PRELOAD + RUMPHIJACK="blanket=/dev/crypto" ; export RUMPHIJACK + $(atf_get_srcdir)/$1 + status=$? + unset RUMPHIJACK + unset LD_PRELOAD + if [ $status -ne 0 ] ; then + atf_fail "$1 returned non-zero status, check output/error" + fi +} + +common_cleanup() { + unset RUMPHIJACK + unset LD_PRELOAD + rump.halt +} + +atf_test_case arc4 cleanup +arc4_head() { + common_head "Test ARC4 crypto" +} + +arc4_body() { + atf_skip "ARC4 not implemented by swcrypto" + common_body h_arc4 +} + +arc4_cleanup() { + common_cleanup +} + +atf_test_case camellia cleanup +camellia_head() { + common_head "Test CAMELLIA_CBC crypto" +} + +camellia_body() { + common_body h_camellia +} + +camellia_cleanup() { + common_cleanup +} + +atf_test_case cbcdes cleanup +cbcdes_head() { + common_head "Test ARC4 crypto" +} + +cbcdes_body() { + common_body h_cbcdes +} + +cbcdes_cleanup() { + common_cleanup +} + +atf_test_case comp cleanup +comp_head() { + common_head "Test GZIP_COMP Compression" +} + +comp_body() { + common_body h_comp +} + +comp_cleanup() { + common_cleanup +} + +atf_test_case comp_deflate cleanup +comp_deflate_head() { + common_head "Test DEFLATE_COMP Compression" +} + +comp_deflate_body() { + common_body h_comp_zlib +} + +comp_deflate_cleanup() { + common_cleanup +} + +atf_test_case comp_zlib_rnd cleanup +comp_zlib_rnd_head() { + common_head "Test DEFLATE_COMP Compression with random data" +} + +comp_zlib_rnd_body() { + common_body h_comp_zlib_rnd +} + +comp_zlib_rnd_cleanup() { + common_cleanup +} + +atf_test_case aesctr1 cleanup +aesctr1_head() { + common_head "Test AES_CTR crypto" +} + +aesctr1_body() { + common_body h_aesctr1 +} + +aesctr1_cleanup() { + common_cleanup +} + +atf_test_case aesctr2 cleanup +aesctr2_head() { + common_head "Test AES_CTR crypto" +} + +aesctr2_body() { + common_body h_aesctr2 +} + +aesctr2_cleanup() { + common_cleanup +} + +atf_test_case gcm cleanup +gcm_head() { + common_head "Test AES_GCM_16 crypto" +} + +gcm_body() { + common_body h_gcm +} + +gcm_cleanup() { + common_cleanup +} + +atf_test_case md5 cleanup +md5_head() { + common_head "Test MD5 crypto" +} + +md5_body() { + common_body h_md5 +} + +md5_cleanup() { + common_cleanup +} + +atf_test_case md5_hmac cleanup +md5_hmac_head() { + common_head "Test MD5_HMAC crypto" +} + +md5_hmac_body() { + common_body h_md5hmac +} + +md5_hmac_cleanup() { + common_cleanup +} + +atf_test_case null cleanup +null_head() { + common_head "Test NULL_CBC crypto" +} + +null_body() { + common_body h_null +} + +null_cleanup() { + common_cleanup +} + +atf_test_case sha1_hmac cleanup +sha1_hmac_head() { + common_head "Test SHA1_HMAC crypto" +} + +sha1_hmac_body() { + common_body h_sha1hmac +} + +sha1_hmac_cleanup() { + common_cleanup +} + +atf_test_case xcbcmac cleanup +xcbcmac_head() { + common_head "Test XCBC_MAC_96 crypto" +} + +xcbcmac_body() { + common_body h_xcbcmac +} + +xcbcmac_cleanup() { + common_cleanup +} + +atf_init_test_cases() { + RUMP_SERVER="unix://t_opencrypto_socket" ; export RUMP_SERVER + + atf_add_test_case arc4 + atf_add_test_case camellia + atf_add_test_case cbcdes + atf_add_test_case comp + atf_add_test_case comp_deflate + atf_add_test_case comp_zlib_rnd + atf_add_test_case aesctr1 + atf_add_test_case aesctr2 + atf_add_test_case gcm + atf_add_test_case md5 + atf_add_test_case md5_hmac + atf_add_test_case null + atf_add_test_case sha1_hmac + atf_add_test_case xcbcmac +} diff --git a/contrib/netbsd-tests/dev/audio/h_pad.c b/contrib/netbsd-tests/dev/audio/h_pad.c new file mode 100644 index 000000000000..dd481ac1a85c --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/h_pad.c @@ -0,0 +1,76 @@ +/* $NetBSD: h_pad.c,v 1.1 2010/08/04 13:15:15 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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 + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "h_pad_musa.c" + +/* + * Stuff some audio into /dev/audio, read it from /dev/pad. Use in + * conjunction with t_pad, which tests that we got sensible output + * by comparing against a previous audibly good result. + */ + +#define BUFSIZE 1024 + +int +main(int argc, char *argv[]) +{ + char buf[BUFSIZE]; + char zeros[BUFSIZE]; + int padfd, audiofd; + ssize_t n; + + rump_init(); + audiofd = rump_sys_open("/dev/audio0", O_RDWR); + if (audiofd == -1) + err(1, "open audio"); + + padfd = rump_sys_open("/dev/pad0", O_RDONLY); + if (padfd == -1) + err(1, "open pad"); + + if ((n = rump_sys_write(audiofd, musa, sizeof(musa))) != sizeof(musa)) + err(1, "write"); + + memset(zeros, 0, sizeof(zeros)); + while ((n = rump_sys_read(padfd, buf, sizeof(buf))) > 0) { + if (memcmp(buf, zeros, sizeof(buf)) == 0) + break; + write(STDOUT_FILENO, buf, n); + } +} diff --git a/contrib/netbsd-tests/dev/audio/h_pad_musa.c b/contrib/netbsd-tests/dev/audio/h_pad_musa.c new file mode 100644 index 000000000000..322305ea4921 --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/h_pad_musa.c @@ -0,0 +1,344 @@ +unsigned char musa[] = { +0x46, 0xdb, 0x76, 0x67, 0x61, 0xff, 0xfc, 0x67, 0xff, 0xe9, 0xdb, 0x79, +0x5d, 0x53, 0x5b, 0x79, 0xef, 0x65, 0x67, 0x5b, 0x67, 0x67, 0x72, 0x66, +0x4f, 0x5b, 0xe7, 0xf5, 0x5e, 0x53, 0x61, 0xe7, 0x5c, 0x53, 0x67, 0x67, +0x67, 0x5b, 0x54, 0x60, 0x4e, 0xec, 0xef, 0x5b, 0x5b, 0x6f, 0x69, 0xff, +0x71, 0x53, 0x77, 0x67, 0x67, 0x5b, 0x5b, 0x5b, 0x75, 0x6c, 0x67, 0x6d, +0x67, 0x7e, 0xff, 0x63, 0x66, 0x61, 0x67, 0x5b, 0x5b, 0x67, 0x67, 0x5f, +0x5b, 0x64, 0x5b, 0x5b, 0x55, 0x53, 0x5c, 0x5d, 0x67, 0x53, 0x63, 0x5e, +0xe7, 0xf5, 0x51, 0x5b, 0x5e, 0x5e, 0x67, 0x5b, 0x67, 0xff, 0x67, 0x67, +0xe9, 0x6e, 0x67, 0x5c, 0x60, 0x67, 0x7a, 0xff, 0xe7, 0xff, 0x58, 0x5b, +0x64, 0x6e, 0x67, 0x55, 0x5f, 0xff, 0xff, 0xff, 0xff, 0x56, 0x5b, 0x53, +0x5b, 0x67, 0x54, 0x58, 0x67, 0x67, 0x6e, 0x67, 0x5c, 0x58, 0x67, 0x67, +0x5b, 0x65, 0x64, 0x70, 0x5b, 0x5b, 0x67, 0xfc, 0xf7, 0xf2, 0xff, 0xec, +0x73, 0x67, 0x67, 0xff, 0x67, 0x74, 0xff, 0x67, 0x5e, 0x5e, 0x67, 0x72, +0x77, 0x7c, 0x67, 0x5d, 0x5b, 0x67, 0x5b, 0x55, 0x67, 0x5c, 0x67, 0x60, +0x5b, 0x5b, 0x61, 0x54, 0x67, 0x5b, 0xe8, 0x75, 0xe2, 0x67, 0xff, 0x62, +0x5b, 0x5b, 0xff, 0xe8, 0xff, 0xe7, 0x6a, 0xee, 0x78, 0x67, 0xff, 0x67, +0x7a, 0xff, 0x6a, 0xff, 0xff, 0x67, 0xff, 0x71, 0xfd, 0x6c, 0x5e, 0xfe, +0xff, 0x6d, 0xe7, 0xff, 0xec, 0x68, 0x5b, 0xff, 0x5c, 0x6a, 0xeb, 0x69, +0x60, 0xff, 0x67, 0x67, 0x67, 0x7a, 0xdf, 0xec, 0x55, 0x5b, 0x5b, 0x5b, +0x71, 0x5c, 0x77, 0x72, 0x68, 0xe7, 0x6d, 0xff, 0xff, 0xff, 0xdb, 0xe7, +0xde, 0xdb, 0xff, 0xff, 0x69, 0xee, 0x78, 0x67, 0xef, 0xea, 0x5b, 0x5b, +0x67, 0x5d, 0x6f, 0xff, 0xff, 0x67, 0x67, 0x67, 0x61, 0x54, 0x5b, 0xff, +0x67, 0x67, 0x5b, 0x67, 0xf4, 0x67, 0x67, 0x67, 0x5b, 0x65, 0xf2, 0x67, +0xff, 0xe7, 0xe7, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xfc, +0xf7, 0xf2, 0x7d, 0x5b, 0x56, 0x67, 0x5e, 0xe2, 0x7f, 0x67, 0x75, 0x67, +0x6d, 0x63, 0x66, 0x67, 0x5b, 0x5b, 0x5b, 0x5b, 0x65, 0xf0, 0x6a, 0xe7, +0x5f, 0x67, 0xff, 0x6f, 0x7b, 0x67, 0x5b, 0xff, 0xff, 0x72, 0x67, 0xff, +0xff, 0xff, 0xff, 0x67, 0x7e, 0x6d, 0xff, 0xff, 0xff, 0x67, 0xff, 0xee, +0xe7, 0xff, 0xff, 0x6a, 0xe7, 0xe7, 0x7a, 0x67, 0xff, 0xff, 0xff, 0x67, +0x67, 0xff, 0xff, 0x67, 0x67, 0x67, 0x5c, 0x5b, 0x67, 0x7f, 0x67, 0xdb, +0xfe, 0xde, 0xec, 0x5c, 0x61, 0x5b, 0x67, 0x6e, 0x67, 0x67, 0xfe, 0xff, +0xe7, 0xff, 0xe7, 0xff, 0xff, 0xe6, 0xd9, 0xe7, 0xff, 0xff, 0x73, 0x68, +0x6c, 0x55, 0xe7, 0xe7, 0xec, 0x67, 0x5b, 0x71, 0xfd, 0xff, 0xff, 0xff, +0x71, 0x67, 0x5b, 0x53, 0x5e, 0x5e, 0x5b, 0x5d, 0x79, 0x70, 0x67, 0x67, +0x60, 0x5c, 0x67, 0xff, 0x7d, 0x75, 0xff, 0xff, 0xe7, 0xec, 0xff, 0xff, +0xe7, 0xfd, 0x67, 0xf7, 0xdc, 0xf1, 0x6b, 0xe9, 0xff, 0x79, 0x7a, 0x6f, +0xfa, 0xf9, 0xff, 0x5b, 0x53, 0x5b, 0x67, 0x77, 0x67, 0x66, 0x67, 0x5b, +0x67, 0x5b, 0x67, 0x67, 0x74, 0x75, 0x7e, 0xf3, 0x67, 0x5c, 0x67, 0x67, +0x5c, 0x67, 0x6a, 0xea, 0xff, 0xff, 0x67, 0xff, 0x7b, 0x78, 0xdf, 0xff, +0xdd, 0xee, 0xfd, 0xf6, 0x67, 0xe7, 0xff, 0x74, 0x67, 0x67, 0xe7, 0xfe, +0xff, 0xec, 0x5c, 0x61, 0xe7, 0x6a, 0x5b, 0xf8, 0xfb, 0xef, 0x79, 0x65, +0x5f, 0x5b, 0x67, 0x60, 0x67, 0x55, 0xf2, 0xff, 0xe7, 0x61, 0x5b, 0x67, +0x67, 0x5b, 0x5e, 0x5e, 0xe8, 0xf3, 0x67, 0xe8, 0xe7, 0xdd, 0xff, 0xe7, +0xdb, 0xf7, 0x70, 0xff, 0xff, 0x6f, 0xff, 0xff, 0xe7, 0x67, 0xff, 0x60, +0x5c, 0x5d, 0x6e, 0xff, 0xec, 0xff, 0x67, 0x67, 0x67, 0x5b, 0x5b, 0x67, +0x5c, 0xff, 0xff, 0x67, 0x6e, 0x67, 0x67, 0x60, 0x67, 0x67, 0x67, 0x67, +0x67, 0x70, 0xff, 0xff, 0x67, 0xff, 0xff, 0xff, 0xfd, 0xf6, 0xff, 0xff, +0xf5, 0xff, 0xff, 0xe2, 0x6c, 0x67, 0x67, 0xff, 0x67, 0xff, 0x63, 0x5b, +0x67, 0x5b, 0x7b, 0x67, 0x67, 0x5d, 0x49, 0x5b, 0x67, 0xe7, 0xff, 0xdf, +0xe5, 0x4d, 0x3b, 0x55, 0xbe, 0xbf, 0x66, 0x41, 0x5b, 0xc3, 0xd3, 0x47, +0x43, 0x79, 0xcf, 0x67, 0x3e, 0x51, 0xc4, 0xbc, 0x6d, 0x3e, 0x50, 0xdf, +0xe7, 0xf9, 0xd4, 0xca, 0x46, 0x37, 0xee, 0xaf, 0xba, 0x40, 0x34, 0x4b, +0xc9, 0xc7, 0x56, 0x39, 0x46, 0xc5, 0xbc, 0x4f, 0x33, 0x4f, 0xbc, 0xc8, +0x4b, 0x39, 0x7e, 0xb6, 0xbc, 0x4b, 0x39, 0x45, 0xcc, 0xc1, 0xec, 0x41, +0x4a, 0xc5, 0xce, 0x48, 0x4c, 0xc9, 0xc4, 0x59, 0x41, 0x53, 0xd9, 0xdb, +0x56, 0x56, 0xdd, 0xcd, 0xdf, 0x4e, 0x5c, 0xda, 0xc6, 0xf0, 0x5b, 0x5b, +0x53, 0x4f, 0x67, 0x71, 0x53, 0x49, 0x4f, 0xfa, 0xd9, 0xff, 0x5b, 0x4d, +0x5b, 0x45, 0x5e, 0xcb, 0xcd, 0x63, 0x49, 0x49, 0xdf, 0xc9, 0xd3, 0x45, +0x4b, 0xdf, 0xbf, 0xcc, 0x3e, 0x39, 0xc6, 0xb4, 0xc9, 0x44, 0x3c, 0x69, +0xbe, 0xcd, 0x45, 0x37, 0x46, 0xc4, 0xbd, 0x62, 0x3c, 0x4d, 0xbe, 0xce, +0x3d, 0x32, 0x47, 0xc7, 0xc2, 0x69, 0x3f, 0x42, 0xce, 0xbd, 0xcb, 0x4b, +0x38, 0x47, 0xcc, 0xc1, 0xd7, 0xdb, 0xef, 0x42, 0x3f, 0x5f, 0xd8, 0xce, +0xe7, 0xdb, 0xff, 0x51, 0xff, 0xff, 0x73, 0xe7, 0xe7, 0x7a, 0x6b, 0xd4, +0x66, 0x5d, 0x7a, 0x6f, 0x55, 0xed, 0xd3, 0xdc, 0x6b, 0x50, 0x5b, 0x53, +0x6e, 0x68, 0x4c, 0x50, 0x54, 0xd0, 0xc5, 0xe7, 0x48, 0x49, 0xdc, 0xdd, +0xff, 0x5c, 0x3a, 0x4e, 0xce, 0xc1, 0xda, 0x4a, 0x5c, 0x67, 0x67, 0x67, +0x52, 0x5a, 0xf0, 0xd3, 0xd3, 0xd7, 0xcd, 0xdb, 0xed, 0x5b, 0x57, 0xcf, +0xd4, 0x51, 0x47, 0x4d, 0x48, 0x5d, 0xe6, 0xff, 0x59, 0x79, 0xcf, 0xf4, +0x46, 0x4c, 0xd0, 0xc1, 0xcf, 0x4c, 0x3c, 0x41, 0xe0, 0xbd, 0xd5, 0x3e, +0x3e, 0x4e, 0xc5, 0xd4, 0x61, 0x53, 0x56, 0x74, 0xcd, 0xc7, 0xe6, 0x4e, +0x6b, 0xd9, 0xce, 0xe0, 0x52, 0x4a, 0x54, 0xd2, 0xd2, 0xe8, 0x4d, 0x46, +0x4d, 0x69, 0xeb, 0xee, 0x5d, 0xff, 0xff, 0x7d, 0x67, 0x55, 0x4a, 0x67, +0xff, 0xff, 0xdb, 0xf5, 0x68, 0x53, 0x71, 0xdc, 0xe7, 0xeb, 0x54, 0x4d, +0x6b, 0xdc, 0xdb, 0xed, 0x4b, 0x4f, 0xfb, 0xce, 0xdb, 0x53, 0x4a, 0x4b, +0xe4, 0xc3, 0xc5, 0x65, 0x40, 0x4c, 0x67, 0xdb, 0xe7, 0xfe, 0x5b, 0xe7, +0x5c, 0x61, 0x6f, 0xfc, 0x60, 0xff, 0x67, 0x5b, 0x4b, 0x65, 0xe7, 0x65, +0x5a, 0x6f, 0x5a, 0x52, 0x7a, 0xcd, 0xd1, 0x55, 0x5c, 0xdb, 0x4c, 0x54, +0xd1, 0xd6, 0x54, 0x4c, 0x72, 0xdb, 0x4f, 0xef, 0xdb, 0x65, 0x4e, 0xed, +0xc9, 0xd0, 0x4f, 0x6f, 0xff, 0x56, 0x5b, 0xe7, 0x5f, 0x65, 0xe6, 0xf7, +0x4c, 0x46, 0x4c, 0xdd, 0xdc, 0x5e, 0x51, 0x45, 0x56, 0xdf, 0xc6, 0xfa, +0x4c, 0x49, 0x55, 0xd9, 0xe6, 0x5f, 0x53, 0x4d, 0x4f, 0xe7, 0xe7, 0x70, +0x5b, 0x78, 0x71, 0x69, 0xdb, 0xcd, 0xe9, 0x5b, 0x4d, 0x68, 0xe7, 0xd9, +0xd3, 0x75, 0x51, 0x53, 0x6b, 0xd3, 0xe6, 0x67, 0x59, 0x53, 0x49, 0x4e, +0x65, 0x67, 0x6a, 0x5e, 0x4b, 0x53, 0x49, 0xf0, 0xe7, 0xdb, 0x63, 0x4e, +0x77, 0xff, 0xfc, 0xcd, 0xe3, 0x53, 0x49, 0x4f, 0x5b, 0x4b, 0x61, 0xd4, +0xd0, 0xeb, 0xe7, 0xe0, 0xeb, 0xff, 0xe7, 0x61, 0x49, 0xef, 0xd3, 0x6d, +0x53, 0xfb, 0xe7, 0xff, 0xfc, 0xce, 0x79, 0x41, 0x43, 0x48, 0x42, 0x4f, +0xcf, 0xc1, 0xcc, 0xcc, 0xc9, 0x64, 0x40, 0x45, 0x61, 0x78, 0xeb, 0xd7, +0xdd, 0x4f, 0x3d, 0x46, 0x4d, 0x4b, 0x6c, 0xdb, 0xc8, 0xca, 0xd1, 0xe4, +0x52, 0x45, 0x51, 0x68, 0xd8, 0xd3, 0xcd, 0xec, 0x59, 0x4e, 0x53, 0x56, +0x7d, 0x6e, 0x55, 0x7c, 0x67, 0xf8, 0xd4, 0xd3, 0xde, 0x55, 0x53, 0x5a, +0x42, 0x56, 0xcd, 0xd1, 0xd3, 0xcd, 0xc9, 0x57, 0x3c, 0x35, 0x35, 0x3b, +0xe2, 0xbc, 0xb7, 0xbd, 0xcb, 0x6a, 0x47, 0x41, 0x52, 0x71, 0x5a, 0x77, +0xcd, 0xce, 0xe7, 0xdb, 0x59, 0x46, 0x3c, 0x3f, 0x58, 0xe3, 0xc1, 0xc0, +0xc1, 0xe9, 0x58, 0x45, 0x4e, 0x67, 0xe2, 0xe7, 0xd3, 0xd3, 0x69, 0x47, +0x44, 0x45, 0x4a, 0x67, 0xdd, 0x7c, 0x6e, 0xd5, 0xdf, 0xff, 0xdd, 0xdf, +0x4d, 0x64, 0xd8, 0xd3, 0xca, 0xbc, 0xbd, 0x5c, 0x35, 0x2d, 0x2c, 0x34, +0xe8, 0xb7, 0xab, 0xae, 0xb1, 0xc6, 0x43, 0x39, 0x38, 0x34, 0x4a, 0x67, +0x5b, 0x67, 0xd2, 0xcd, 0xd3, 0xce, 0x52, 0x3e, 0x39, 0x47, 0x65, 0xc9, +0xb4, 0xb3, 0xbf, 0x73, 0x4b, 0x3a, 0x43, 0x66, 0xce, 0xcc, 0xc8, 0xcd, +0xea, 0x48, 0x3f, 0x3c, 0x3f, 0x49, 0x72, 0xc9, 0xc1, 0xcb, 0xca, 0x67, +0x38, 0x3d, 0xe6, 0xb5, 0xab, 0xa8, 0xb1, 0x4c, 0x28, 0x1f, 0x23, 0x32, +0xc4, 0xaa, 0xa2, 0xa5, 0xb6, 0x53, 0x2f, 0x29, 0x2b, 0x2f, 0x4b, 0xe7, +0xc9, 0xc9, 0xdb, 0x4d, 0x50, 0xff, 0xd2, 0xcd, 0xe5, 0x48, 0x37, 0x3c, +0x55, 0xc9, 0xb4, 0xad, 0xb3, 0xc9, 0x4a, 0x39, 0x3d, 0x49, 0xde, 0xcc, +0xc1, 0xd9, 0x4b, 0x3c, 0x38, 0x3f, 0x52, 0xff, 0xda, 0xca, 0xc5, 0xcf, +0x4b, 0x3c, 0x37, 0x54, 0xc1, 0xa8, 0xa7, 0xad, 0x50, 0x23, 0x1e, 0x1f, +0x31, 0xc2, 0xa2, 0x9f, 0xa4, 0xbb, 0x36, 0x25, 0x27, 0x34, 0xea, 0xbb, +0xb6, 0xbc, 0x4c, 0x3b, 0x37, 0x43, 0xe1, 0xc2, 0xda, 0x55, 0x49, 0x49, +0x5e, 0xc1, 0xb8, 0xba, 0xbd, 0xdb, 0x62, 0x4a, 0x66, 0xe3, 0xfd, 0x5b, +0x49, 0x45, 0x49, 0x45, 0x51, 0x53, 0x5b, 0x53, 0x67, 0xe7, 0x6d, 0x5f, +0x67, 0x5b, 0xd4, 0xc5, 0x5e, 0x35, 0x3f, 0x6e, 0xbe, 0xaa, 0xa4, 0xb4, +0x3d, 0x28, 0x1d, 0x23, 0x44, 0xaf, 0xa6, 0xa3, 0xb2, 0x51, 0x2a, 0x29, +0x3a, 0x69, 0xaf, 0xb0, 0xc3, 0x47, 0x2d, 0x28, 0x31, 0x4d, 0xc2, 0xb8, +0xbc, 0x52, 0x3a, 0x3b, 0xde, 0xb0, 0xa6, 0xa9, 0xc1, 0x40, 0x2b, 0x28, +0x2f, 0x66, 0xb7, 0xb6, 0xb6, 0xd6, 0x3d, 0x38, 0x30, 0x3d, 0x57, 0xe7, +0xc2, 0xcf, 0xdd, 0xf5, 0x46, 0x4d, 0x78, 0xcd, 0xcb, 0x3c, 0x39, 0x49, +0xbf, 0xa7, 0x9f, 0xa0, 0xbd, 0x39, 0x1e, 0x17, 0x1e, 0x3a, 0xbd, 0xa2, +0xa4, 0xac, 0x60, 0x2c, 0x29, 0x32, 0xdc, 0xb2, 0xbc, 0xc7, 0x38, 0x2a, +0x28, 0x2e, 0x53, 0xb2, 0xad, 0xaf, 0xc5, 0x42, 0x3f, 0x79, 0xba, 0xaa, +0xa7, 0xbf, 0x3e, 0x29, 0x26, 0x2d, 0x52, 0xb5, 0xad, 0xaf, 0xbf, 0x3c, +0x2f, 0x2d, 0x37, 0x4d, 0xbd, 0xbe, 0xc3, 0xd3, 0x66, 0x49, 0x48, 0x45, +0x7d, 0xc3, 0x5d, 0x37, 0x3f, 0x78, 0xba, 0xa3, 0x9d, 0xa9, 0x66, 0x24, +0x19, 0x1c, 0x2b, 0xd9, 0xab, 0x9f, 0xa6, 0xc5, 0x43, 0x33, 0x33, 0xf3, +0xbc, 0xbf, 0x4e, 0x37, 0x28, 0x27, 0x33, 0x65, 0xb5, 0xaa, 0xad, 0xbf, +0x5f, 0x42, 0x41, 0xdb, 0xb5, 0xac, 0xac, 0xcc, 0x35, 0x25, 0x20, 0x29, +0x4e, 0xb1, 0xab, 0xab, 0xbb, 0x42, 0x2a, 0x28, 0x2d, 0x4a, 0xc7, 0xb4, +0xb4, 0xc8, 0x46, 0x3b, 0x37, 0x3f, 0xbe, 0xb1, 0x4d, 0x48, 0x49, 0x41, +0xb6, 0x9c, 0x9d, 0xab, 0x5d, 0x1c, 0x14, 0x1c, 0x2d, 0xca, 0xa3, 0x9d, +0xa9, 0xb7, 0x5a, 0x38, 0x36, 0x5b, 0x44, 0x3e, 0x39, 0x2e, 0x2d, 0x38, +0x42, 0xc9, 0xb3, 0xad, 0xaf, 0xbc, 0xdc, 0x5a, 0x4a, 0x4d, 0x60, 0xc7, +0xb5, 0xb7, 0xca, 0x3f, 0x2e, 0x28, 0x30, 0x4a, 0xb5, 0xa8, 0xaa, 0xb6, +0x47, 0x2e, 0x27, 0x2d, 0x51, 0xbd, 0xad, 0xb2, 0xed, 0x3a, 0x39, 0x38, +0x3c, 0xc9, 0xb0, 0x4e, 0x36, 0x3f, 0xee, 0xad, 0x9b, 0x9e, 0xb2, 0x32, +0x17, 0x12, 0x1b, 0x2d, 0xc4, 0x9d, 0x98, 0x9e, 0xae, 0x5f, 0x2d, 0x2b, +0x2c, 0x32, 0x3d, 0x3f, 0x38, 0x3d, 0x4c, 0x5f, 0xc2, 0xaf, 0xae, 0xac, +0xb9, 0xd9, 0x41, 0x3c, 0x3c, 0x3d, 0x5c, 0xc0, 0xae, 0xaf, 0xbc, 0x3b, +0x28, 0x24, 0x2a, 0x4b, 0xb5, 0xa8, 0xab, 0xbe, 0x40, 0x2a, 0x29, 0x33, +0x54, 0xbb, 0xb4, 0xc9, 0x63, 0x4a, 0x3d, 0x3d, 0x4a, 0xb9, 0xbb, 0x48, +0x37, 0x5d, 0xbd, 0xa5, 0x9a, 0xa1, 0xc6, 0x23, 0x13, 0x11, 0x20, 0x39, +0xaa, 0x99, 0x97, 0xa2, 0xb9, 0x45, 0x2c, 0x28, 0x2a, 0x2e, 0x34, 0x38, +0x35, 0x43, 0x6b, 0xc5, 0xba, 0xad, 0xad, 0xb5, 0xcc, 0x41, 0x32, 0x34, +0x41, 0xe3, 0xd3, 0xc6, 0xbc, 0xbb, 0xbe, 0xe2, 0x38, 0x2a, 0x2b, 0x32, +0x5c, 0xb8, 0xad, 0xae, 0xbb, 0x59, 0x36, 0x2c, 0x31, 0x57, 0xc2, 0xb6, +0xbb, 0xd1, 0x45, 0x3b, 0x36, 0x53, 0xaa, 0xaf, 0x33, 0x3b, 0x4a, 0x4c, +0xa8, 0x9c, 0xad, 0x48, 0x1e, 0x13, 0x19, 0x2e, 0xc5, 0x9d, 0x94, 0x9c, +0xb0, 0x70, 0x2d, 0x24, 0x28, 0x2d, 0x36, 0x46, 0x4b, 0x4e, 0xd3, 0xc0, +0xb6, 0xaf, 0xae, 0xbc, 0xe4, 0x3f, 0x30, 0x34, 0x5d, 0xc8, 0xbb, 0xba, +0xc4, 0xe4, 0xf0, 0xc9, 0x79, 0x38, 0x30, 0x2e, 0x36, 0x56, 0xb9, 0xaf, +0xb1, 0xc3, 0x4d, 0x36, 0x38, 0x3a, 0x3c, 0x6b, 0xd9, 0xca, 0xd0, 0xd3, +0xf9, 0x5b, 0x5f, 0xc3, 0xba, 0x46, 0x34, 0x3d, 0x51, 0xb5, 0xa3, 0xab, +0xd0, 0x32, 0x1f, 0x21, 0x2f, 0xf4, 0xad, 0xa5, 0xa8, 0xb9, 0xfe, 0x3d, +0x38, 0x3d, 0x45, 0x48, 0x48, 0x49, 0x4d, 0x6b, 0xcb, 0xbe, 0xbe, 0xbe, +0xcd, 0x5a, 0x4a, 0x45, 0x4e, 0x71, 0xce, 0xc1, 0xc4, 0xdf, 0x7d, 0x67, +0xf3, 0xe7, 0x6c, 0x4c, 0x41, 0x40, 0x4c, 0xe9, 0xc3, 0xc1, 0xc5, 0xd0, +0x58, 0x46, 0x43, 0x42, 0x49, 0x4f, 0xfa, 0xd5, 0xc9, 0xc5, 0xd0, 0x71, +0x49, 0x4f, 0xd9, 0xd7, 0x33, 0x31, 0x46, 0xcd, 0xa9, 0xa0, 0xae, 0x3c, +0x1e, 0x19, 0x1e, 0x35, 0xb5, 0x9f, 0x9e, 0xa9, 0xca, 0x47, 0x36, 0x30, +0x34, 0x3b, 0x34, 0x32, 0x3b, 0x4e, 0xd1, 0xb9, 0xb0, 0xb7, 0xc9, 0x66, +0x44, 0x3b, 0x41, 0x4b, 0xd1, 0xbb, 0xbc, 0xcd, 0x5c, 0x53, 0xef, 0xe6, +0x57, 0x35, 0x2c, 0x2f, 0x44, 0x49, 0xbc, 0xb7, 0xc4, 0xe7, 0x77, 0x3b, +0x2f, 0x3f, 0x42, 0x49, 0x3e, 0x59, 0xb1, 0xb7, 0x62, 0xed, 0xc2, 0xd2, +0x36, 0x36, 0xc3, 0xaf, 0x2d, 0x21, 0x3a, 0xa6, 0x9c, 0xa4, 0xc0, 0x2b, +0x21, 0x1a, 0x18, 0x37, 0xa3, 0xa0, 0xa9, 0xa7, 0xb1, 0x4b, 0x26, 0x2b, +0x37, 0x4f, 0x43, 0x2c, 0x2f, 0xc8, 0xb9, 0xb5, 0xcf, 0xe6, 0x6e, 0x59, +0x3f, 0x2f, 0x52, 0xba, 0xd8, 0xc3, 0xb8, 0xc3, 0xc4, 0xb5, 0x6d, 0x2f, +0x27, 0x2b, 0x33, 0xed, 0xbb, 0xad, 0xb3, 0x70, 0x35, 0x40, 0x4d, 0x42, +0x3e, 0x48, 0xea, 0xc8, 0xdb, 0xc6, 0xbe, 0xce, 0x6d, 0x3c, 0x34, 0x3f, +0xc9, 0xd5, 0xdd, 0xf0, 0xde, 0x4d, 0x6e, 0x6a, 0xca, 0xb4, 0xbf, 0x48, +0x2d, 0x29, 0x31, 0x3f, 0x53, 0xbf, 0xab, 0xb0, 0xc2, 0xf0, 0x5b, 0x52, +0x3e, 0x39, 0x36, 0x3e, 0x5b, 0xcf, 0xbc, 0xb9, 0xbd, 0x63, 0x4d, 0x4f, +0x5b, 0x67, 0x4c, 0x4d, 0x5f, 0xc8, 0xba, 0xb6, 0xbe, 0xe7, 0x37, 0x2c, +0x32, 0x3e, 0xd5, 0xbf, 0xbc, 0xc2, 0xda, 0x4f, 0x3c, 0x39, 0x36, 0x37, +0x4f, 0xbe, 0xb8, 0xb8, 0xc5, 0xd6, 0x55, 0x53, 0x4d, 0x59, 0xff, 0xe7, +0xd6, 0xde, 0xdb, 0xc8, 0xdb, 0x68, 0x67, 0x56, 0x54, 0x50, 0xe3, 0xfc, +0x52, 0x46, 0x45, 0x54, 0xd7, 0xc9, 0xcd, 0xec, 0x5d, 0x50, 0x4e, 0x5b, +0x5b, 0xe7, 0x60, 0x57, 0x5c, 0xde, 0xc8, 0xce, 0xff, 0x67, 0x67, 0x5e, +0x4f, 0x45, 0x4d, 0xef, 0xc6, 0xc4, 0xcf, 0xff, 0x57, 0x52, 0x49, 0x5f, +0xd1, 0xc9, 0xd7, 0xd2, 0xc9, 0xd2, 0x63, 0x3f, 0x3c, 0x42, 0x4f, 0x67, +0xdb, 0xe2, 0xe2, 0xff, 0x5b, 0x67, 0x7e, 0xe7, 0xec, 0x5b, 0x67, 0xd9, +0xd3, 0xe7, 0x79, 0x4e, 0x5b, 0x55, 0x79, 0x60, 0x54, 0x78, 0xdb, 0xff, +0x57, 0x5a, 0xdc, 0x6c, 0xff, 0x7e, 0x62, 0xff, 0x5b, 0x5e, 0xde, 0xdc, +0xe7, 0x67, 0xe9, 0xe7, 0xdd, 0xe7, 0xe0, 0xe7, 0xce, 0xf0, 0x5a, 0x5a, +0x6f, 0x6a, 0xe7, 0x67, 0xe5, 0xf0, 0x4e, 0x49, 0x45, 0x5d, 0xdc, 0xe7, +0xd3, 0xe7, 0xe7, 0xf4, 0x5c, 0x4f, 0x59, 0x53, 0xff, 0xff, 0xff, 0x57, +0x57, 0xe9, 0x6f, 0xe4, 0xd3, 0xef, 0xde, 0x67, 0xe7, 0xff, 0xdd, 0xd8, +0xe7, 0xe7, 0x58, 0x5c, 0x67, 0x5b, 0x5b, 0x4f, 0x5b, 0x67, 0xf6, 0xd6, +0xdb, 0x67, 0x77, 0x67, 0x57, 0x55, 0x5b, 0x70, 0x67, 0x67, 0x5b, 0x5e, +0xff, 0x5f, 0xe7, 0xff, 0x5b, 0xff, 0xeb, 0xe7, 0xff, 0xff, 0xdb, 0xe7, +0xe7, 0xff, 0xff, 0x5e, 0x67, 0xff, 0x6d, 0x6c, 0xe7, 0x72, 0xff, 0x69, +0x60, 0x67, 0x67, 0xdb, 0xed, 0x7a, 0x6f, 0x5b, 0x78, 0x67, 0xff, 0x67, +0xff, 0x7d, 0x67, 0x67, 0x5b, 0x5b, 0x6d, 0x5b, 0x74, 0x5e, 0xdc, 0x67, +0xdb, 0xce, 0x79, 0x5f, 0xe7, 0x67, 0x6f, 0x55, 0x60, 0xf9, 0xe5, 0xdf, +0xff, 0xdd, 0xfd, 0x69, 0xff, 0x5b, 0x67, 0x67, 0x78, 0xdc, 0x76, 0x73, +0x68, 0xf5, 0x62, 0x5b, 0x73, 0xff, 0xe8, 0xe7, 0xe3, 0xfc, 0x71, 0xe7, +0x6b, 0x58, 0x53, 0x65, 0x6f, 0x7a, 0x67, 0xff, 0x7b, 0x67, 0x5b, 0x5b, +0x53, 0x6e, 0x66, 0x76, 0xed, 0xfe, 0xd6, 0x67, 0x7f, 0xf4, 0xe7, 0xfe, +0xff, 0xff, 0xff, 0x72, 0xeb, 0x67, 0x71, 0xff, 0x67, 0x6f, 0x6a, 0xdb, +0x70, 0xe7, 0x6b, 0x6e, 0x7c, 0x67, 0x5b, 0x53, 0x4d, 0x4d, 0x5c, 0x67, +0xf4, 0xe7, 0xe2, 0xe7, 0xfe, 0x5e, 0x67, 0x67, 0xe7, 0xeb, 0xff, 0x5f, +0x67, 0x67, 0xef, 0x67, 0x5b, 0xff, 0xff, 0xe7, 0xdb, 0xe7, 0xe7, 0x71, +0x67, 0xeb, 0xff, 0x7d, 0x62, 0xed, 0xe7, 0xed, 0x75, 0xff, 0xe7, 0x63, +0x66, 0x5f, 0x5b, 0x66, 0xe7, 0xff, 0xff, 0x67, 0x6a, 0xe7, 0x5f, 0x5d, +0x67, 0x5b, 0xff, 0x6b, 0x5f, 0xe7, 0xff, 0xe7, 0xe8, 0x56, 0x6d, 0x67, +0x59, 0xff, 0x53, 0x66, 0xd0, 0x67, 0x67, 0xf6, 0x68, 0xff, 0xff, 0x67, +0xdf, 0xea, 0xdd, 0xdc, 0x5d, 0xde, 0x5c, 0x50, 0xdb, 0x71, 0xe7, 0xff, +0x72, 0xff, 0x6c, 0x67, 0x67, 0x5b, 0x5b, 0xff, 0xff, 0x5b, 0xe8, 0xff, +0x5b, 0x53, 0x5b, 0x67, 0x67, 0x74, 0xdb, 0xfb, 0x70, 0xed, 0x7a, 0xe7, +0xec, 0x5b, 0x67, 0x64, 0x52, 0xe1, 0xe8, 0xe7, 0x73, 0x68, 0xde, 0x74, +0x68, 0xdb, 0xdb, 0x68, 0x5b, 0xff, 0xff, 0x6e, 0x67, 0x5c, 0x60, 0x53, +0x5a, 0x70, 0x61, 0x52, 0x5b, 0xff, 0x5b, 0xe7, 0xfb, 0xf8, 0x6e, 0x7c, +0x5d, 0x78, 0x7d, 0x5b, 0xff, 0x7e, 0x5b, 0x5b, 0x67, 0x6d, 0xff, 0x5c, +0x72, 0xf7, 0xe7, 0xe7, 0x67, 0xff, 0x5f, 0x6a, 0xff, 0x67, 0xe7, 0xf9, +0x67, 0xff, 0x67, 0x60, 0x5c, 0xff, 0x67, 0x66, 0x63, 0xff, 0xe7, 0xe7, +0x6d, 0xe7, 0x5e, 0xf5, 0xfe, 0x67, 0x56, 0x67, 0xe7, 0xff, 0x67, 0x67, +0x78, 0x4b, 0x5c, 0xd6, 0x5d, 0xdf, 0xe7, 0xff, 0xff, 0x5b, 0x77, 0xff, +0xff, 0xff, 0x53, 0x7e, 0x5b, 0x6d, 0xe7, 0x56, 0x73, 0xfd, 0xe7, 0xf6, +0xfd, 0xff, 0x6f, 0x5b, 0xfb, 0xee, 0x7b, 0xff, 0x79, 0x5b, 0x53, 0x55, +0x53, 0x58, 0x49, 0x5a, 0x6e, 0xdc, 0xff, 0xff, 0xe8, 0x67, 0x67, 0xdb, +0x67, 0x56, 0x54, 0x5b, 0x51, 0x4d, 0x58, 0x5b, 0xea, 0xf1, 0x5d, 0xff, +0xe7, 0xda, 0xe5, 0xd7, 0xde, 0xea, 0xef, 0x67, 0xff, 0x60, 0x5b, 0x67, +0x53, 0x67, 0x50, 0xeb, 0x5b, 0x67, 0x5b, 0x67, 0xed, 0x4a, 0x65, 0xff, +0x5b, 0xd5, 0x57, 0xdd, 0xff, 0x5c, 0xbe, 0x3c, 0xd3, 0x47, 0x5c, 0x68, +0x63, 0x4d, 0xd3, 0x4d, 0xf6, 0x5b, 0x5f, 0xbe, 0x50, 0xdb, 0xe2, 0x74, +0xe7, 0xd8, 0x4f, 0xce, 0x5f, 0x44, 0x41, 0x5f, 0x4e, 0x3d, 0x5d, 0xeb, +0x5c, 0xd3, 0xdd, 0xff, 0xd7, 0xbd, 0x53, 0xca, 0x5e, 0x43, 0xd1, 0xf4, +0x38, 0x67, 0x5b, 0x47, 0x56, 0x5b, 0x67, 0x59, 0x46, 0x57, 0xc5, 0xc5, +0xbc, 0xe4, 0x3f, 0x4b, 0x37, 0xec, 0xc8, 0xcd, 0x49, 0xd7, 0x48, 0x40, +0xe8, 0xd9, 0xbd, 0xca, 0x55, 0xcc, 0xdd, 0x52, 0x3a, 0x4c, 0xe6, 0xc1, +0x74, 0x4d, 0xe7, 0x61, 0x4e, 0x3d, 0xcb, 0xfa, 0x5b, 0x5b, 0xeb, 0x7c, +0x5d, 0xff, 0x5f, 0xfa, 0x45, 0x3c, 0x5e, 0x67, 0xd0, 0xe9, 0xdd, 0x78, +0x3f, 0xed, 0xc7, 0x5b, 0x53, 0x75, 0xff, 0xcf, 0xce, 0x67, 0x6d, 0xf6, +0x68, 0xf9, 0xe7, 0xfc, 0xfb, 0xe1, 0x4b, 0x45, 0x4e, 0x53, 0xdf, 0xea, +0xdf, 0x69, 0xe5, 0xe4, 0x72, 0x67, 0x56, 0x3c, 0x4a, 0xe7, 0x59, 0x53, +0x49, 0x67, 0x46, 0x4d, 0xd7, 0xc6, 0xc1, 0xeb, 0xe7, 0x60, 0xdd, 0xff, +0xe7, 0x67, 0xea, 0xe7, 0x4d, 0xd5, 0xcd, 0x49, 0x46, 0x49, 0xcd, 0xca, +0xda, 0xdb, 0x72, 0x4c, 0x68, 0xde, 0xec, 0x5b, 0xd9, 0x4d, 0x5b, 0x3c, +0x5a, 0xfc, 0x48, 0xdd, 0x4a, 0xfc, 0x57, 0x4d, 0x5f, 0x7a, 0x67, 0xdc, +0xc2, 0xd0, 0xcd, 0xe9, 0xd7, 0x4d, 0x45, 0x43, 0xd8, 0xe7, 0x5b, 0x40, +0x5b, 0xd9, 0xf5, 0xce, 0xe3, 0xd8, 0xdd, 0xca, 0x6b, 0xff, 0xcf, 0xee, +0x5b, 0x4b, 0x5d, 0x67, 0x4c, 0xf6, 0x5f, 0xe0, 0xff, 0x77, 0xd7, 0xe7, +0xe7, 0x53, 0x5c, 0x5e, 0x59, 0xe7, 0x5b, 0x61, 0x68, 0x3b, 0x4a, 0x5c, +0x58, 0x40, 0xef, 0xc9, 0xf4, 0x53, 0xe6, 0xce, 0xf5, 0x5b, 0xe5, 0xce, +0xd0, 0xc6, 0x53, 0x52, 0xe7, 0xf7, 0x4a, 0x5c, 0xff, 0x61, 0x68, 0xf5, +0x4b, 0x7e, 0xff, 0xcb, 0xda, 0x58, 0xff, 0x5c, 0x6a, 0x4d, 0x5a, 0x4f, +0x5e, 0x5d, 0x5f, 0x5e, 0xe7, 0x53, 0xd6, 0x4d, 0xe0, 0xe6, 0xeb, 0x61, +0xeb, 0x4f, 0x65, 0x5c, 0x5e, 0x4d, 0x53, 0x5e, 0x5b, 0x67, 0xff, 0x59, +0xeb, 0xea, 0x55, 0xeb, 0xc5, 0xbf, 0x6e, 0x68, 0xce, 0xd5, 0x60, 0x57, +0xdb, 0x6b, 0x46, 0x59, 0xda, 0x4d, 0x3f, 0x6a, 0xdc, 0x48, 0x54, 0xe7, +0xcc, 0x68, 0x4a, 0x52, 0xd7, 0xc2, 0xe4, 0x5b, 0x53, 0x57, 0x43, 0x77, +0xdf, 0xed, 0x4f, 0x53, 0xfa, 0x6a, 0x7c, 0xd5, 0x55, 0x6e, 0x69, 0xdd, +0xcb, 0xff, 0xd6, 0xff, 0x4d, 0x43, 0xed, 0xc2, 0xcd, 0x4d, 0x4d, 0x79, +0xd1, 0xda, 0x5f, 0x53, 0x4a, 0x53, 0xda, 0xe2, 0x4f, 0x5d, 0x67, 0x5b, +0x54, 0xdd, 0x60, 0x55, 0xe7, 0xf2, 0xd4, 0x5e, 0xe7, 0x53, 0x62, 0x4f, +0x5b, 0xd3, 0x57, 0x4d, 0x73, 0xec, 0x5b, 0x5b, 0x5f, 0xfb, 0x53, 0xf9, +0xfa, 0x5f, 0xcd, 0xda, 0x68, 0x6e, 0xcd, 0x67, 0xf9, 0xd9, 0xee, 0x5b, +0x59, 0x4c, 0x4a, 0x75, 0x4c, 0xff, 0x59, 0x54, 0x45, 0xed, 0xec, 0x54, +0x77, 0xc9, 0x6c, 0xd3, 0x5e, 0x72, 0x66, 0x4c, 0xd5, 0x4e, 0x55, 0x53, +0xff, 0x52, 0x49, 0x7a, 0xe8, 0x67, 0xd8, 0xe7, 0xd1, 0x67, 0x7f, 0xed, +0xe2, 0xfe, 0x67, 0x5e, 0xdc, 0x53, 0x59, 0x5b, 0x67, 0xff, 0x5d, 0x58, +0x53, 0x5a, 0xef, 0x67, 0x79, 0xee, 0x6b, 0xd3, 0xf1, 0xd5, 0xeb, 0x5d, +0x54, 0x56, 0x63, 0xdb, 0xe2, 0x59, 0xdc, 0x76, 0x53, 0x53, 0x53, 0x5d, +0x54, 0x57, 0x5f, 0xe7, 0xf0, 0xcf, 0xd0, 0x57, 0xd7, 0xde, 0x5b, 0x77, +0x60, 0xd7, 0x5b, 0x59, 0xd7, 0x53, 0x76, 0x6d, 0x5c, 0xec, 0x4d, 0x7f, +0x5e, 0xff, 0x5c, 0xe3, 0xf1, 0x5b, 0x5f, 0xf7, 0x5d, 0x60, 0x64, 0x7b, +0x6f, 0x55, 0xea, 0x53, 0x5b, 0x5b, 0x71, 0x5b, 0x5d, 0x67, 0x66, 0x63, +0xe7, 0xe8, 0xff, 0xd9, 0xd3, 0xf4, 0xe7, 0x68, 0xed, 0xd6, 0x5c, 0x6a, +0x77, 0x7c, 0x65, 0x53, 0x65, 0x4d, 0x4f, 0x67, 0x5b, 0x65, 0x53, 0x70, +0x5d, 0xdd, 0x5b, 0xff, 0xeb, 0xda, 0xfc, 0xe9, 0x4c, 0xff, 0x67, 0x6d, +0x53, 0x67, 0x5b, 0x5b, 0x5b, 0x5f, 0x4d, 0xdb, 0x5b, 0xff, 0xe6, 0xea, +0xea, 0xef, 0xe5, 0xe7, 0xe7, 0xda, 0xe0, 0xff, 0x67, 0xe7, 0x4e, 0x68, +0x50, 0x59, 0x5c, 0xec, 0xff, 0xe7, 0x5b, 0xf5, 0xfe, 0x73, 0xf6, 0xe7, +0xff, 0x63, 0xeb, 0x6e, 0x67, 0x5d, 0x68, 0x65, 0x5b, 0x57, 0xff, 0xff, +0xe0, 0xff, 0x5d, 0x5f, 0x68, 0xff, 0xff, 0x68, 0xde, 0x5e, 0x67, 0x74, +0xff, 0x68, 0x73, 0xf6, 0xfd, 0xe7, 0xff, 0xfc, 0xdf, 0xff, 0xe7, 0x67, +0x67, 0xea, 0xdf, 0x7a, 0x5b, 0x67, 0xff, 0x5b, 0x60, 0x5b, 0x53, 0x56, +0xfe, 0xf5, 0x74, 0x67, 0x62, 0xff, 0x67, 0x6d, 0x5b, 0x7d, 0x72, 0xe7, +0x5c, 0xe7, 0x5b, 0x65, 0xf0, 0xff, 0x6a, 0xef, 0xfa, 0xe4, 0x67, 0x69, +0xff, 0x5b, 0xdb, 0xe3, 0xdf, 0x67, 0x76, 0xe7, 0x7e, 0x5b, 0xff, 0x67, +0x67, 0xe7, 0x5c, 0x61, 0x53, 0xea, 0x5b, 0x64, 0x65, 0x7c, 0x5d, 0x67, +0x6f, 0x67, 0x5d, 0x5b, 0xfb, 0xff, 0xd7, 0xff, 0xdd, 0x6a, 0x67, 0x6c, +0x56, 0xe8, 0xec, 0xe2, 0x5b, 0x67, 0x6c, 0xfe, 0x5e, 0x60, 0xe6, 0x53, +0x67, 0x7c, 0x5f, 0xf8, 0xfb, 0x67, 0xe7, 0xff, 0xe7, 0xe7, 0xdb, 0xdf, +0x67, 0x55, 0x61, 0x5c, 0x6c, 0x53, 0x69, 0xe7, 0x5b, 0x67, 0x62, 0x56, +0x67, 0x61, 0x67, 0xe8, 0xdb, 0x77, 0xdd, 0xdb, 0xeb, 0x67, 0x5b, 0xff, +0x5d, 0x6f, 0x67, 0x67, 0xe7, 0xff, 0x67, 0xe0, 0xe9, 0xeb, 0xe4, 0x67, +0xff, 0x67, 0x67, 0x75, 0x5b, 0x7f, 0xf4, 0xff, 0xff, 0x72, 0x77, 0x5b, +0x67, 0x5b, 0x67, 0xe7, 0x5b, 0x7a, 0x6f, 0x5d, 0xea, 0x61, 0x4d, 0x60, +0xe7, 0x79, 0x59, 0xff, 0x7d, 0x56, 0x5e, 0x67, 0x59, 0x5b, 0xe7, 0xde, +0x75, 0x7e, 0xf7, 0x6f, 0x66, 0x67, 0xf0, 0xfc, 0xe7, 0x67, 0xff, 0x7e, +0x6a, 0x6a, 0x67, 0x67, 0xff, 0xee, 0x67, 0x77, 0xee, 0x67, 0x67, 0x61, +0x67, 0x67, 0x67, 0x67, 0x51, 0xe7, 0x5c, 0x5b, 0xff, 0x5c, 0x72, 0x67, +0x67, 0xff, 0x5d, 0xff, 0x53, 0x6a, 0x5e, 0x57, 0x5d, 0xea, 0xe7, 0xfb, +0xe7, 0xe7, 0xfc, 0xe7, 0xdb, 0xff, 0xff, 0xf3, 0xe7, 0x67, 0xff, 0xff, +0xe7, 0x76, 0x66, 0x5b, 0xff, 0x69, 0xff, 0x64, 0x4e, 0x60, 0xea, 0x5b, +0x67, 0x67, 0x67, 0x5b, 0x67, 0x5b, 0x57, 0x67, 0x77, 0xee, 0xe7, 0xe7, +0xed, 0xff, 0xff, 0x62, 0x5b, 0x67, 0x6c, 0xff, 0x5b, 0x6c, 0xdc, 0x5a, +0x5d, 0x67, 0x71, 0x79, 0x67, 0xd3, 0xe7, 0xff, 0xe7, 0xfb, 0xff, 0xe0, +0x66, 0x67, 0xe7, 0x67, 0x76, 0xe7, 0x67, 0x67, 0x5e, 0xff, 0x6d, 0x5e, +0x68, 0x61, 0x6c, 0xff, 0x53, 0x5d, 0xe9, 0x5f, 0x55, 0xe9, 0x5b, 0x67, +0x67, 0x5f, 0xfa, 0x57, 0x66, 0xe7, 0x6b, 0x67, 0xff, 0xff, 0xe7, 0xff, +0xd8, 0xed, 0xff, 0x74, 0xec, 0x68, 0x67, 0xe7, 0x68, 0xee, 0xff, 0x7c, +0xf1, 0x64, 0x5a, 0x67, 0x53, 0x65, 0x67, 0x5b, 0x79, 0x70, 0x67, 0x5d, +0x4f, 0x54, 0xff, 0xf2, 0x7d, 0x76, 0xe7, 0xe8, 0x75, 0xde, 0xff, 0x5b, +0x75, 0x5b, 0xed, 0x76, 0x66, 0x6e, 0x67, 0x7b, 0x5f, 0x67, 0x67, 0x5b, +0x5d, 0xdd, 0xef, 0xf7, 0xda, 0x60, 0xe6, 0xe3, 0x61, 0xfd, 0xf6, 0xff, +0x67, 0x62, 0x59, 0x53, 0x74, 0x6d, 0x5b, 0xff, 0x5b, 0x67, 0x72, 0x6f, +0x5b, 0xff, 0x6b, 0xe7, 0xe7, 0x67, 0x67, 0xef, 0xdd, 0x6a, 0x60, 0x67, +0xe7, 0xe7, 0x65, 0x63, 0xf3, 0xe9, 0x62, 0x74, 0x67, 0xff, 0xf5, 0xe7, +0xff, 0xff, 0x68, 0x53, 0x6b, 0x69, 0xff, 0xe7, 0xe7, 0xf0, 0x79, 0x55, +0x53, 0x5d, 0xff, 0x67, 0xdb, 0xf8, 0x6e, 0x7a, 0x53, 0xff, 0x5b, 0x51, +0x5e, 0x67, 0x5e, 0x5e, 0x67, 0x67, 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 0xe7, +0x78, 0x7b, 0xf0, 0xea, 0x67, 0xff, 0x67, 0x79, 0xff, 0xe7, 0xf8, 0x6e, +0xe9, 0xff, 0x61, 0xff, 0x58, 0x67, 0x5b, 0x75, 0x67, 0xff, 0x5b, 0x67, +0x67, 0x6d, 0x5b, 0x5b, 0x5f, 0x5d, 0x67, 0x5b, 0x53, 0x5b, 0x67, 0x79, +0xff, 0xf0, 0xe9, 0x67, 0x60, 0x5b, 0x67, 0x6e, 0x67, 0xff, 0xe7, 0xe8, +0x6c, 0xf4, 0x67, 0x67, 0xf5, 0xdc, 0x6d, 0xff, 0xff, 0x6e, 0x67, 0xff, +0x65, 0xf8, 0xf7, 0x5c, 0xea, 0xff, 0xd7, 0xff, 0xff, 0x70, 0x5b, 0x5d, +0xff, 0x66, 0x53, 0x6e, 0x66, 0x76, 0xff, 0x67, 0x67, 0x53, 0x5b, 0x73, +0x76, 0x67, 0xe7, 0xdd, 0x67, 0xff, 0x5b, 0x65, 0x67, 0x67, 0xff, 0x6f, +0x7a, 0x79, 0x67, 0x69, 0xe7, 0xee, 0xe7, 0xe7, 0xe7, 0xff, 0x4d, 0xe7, +0xe8, 0xff, 0x67, 0x7f, 0xff, 0x67, 0x67, 0x6d, 0x58, 0xe7, 0x67, 0x6b, +0xff, 0x5b, 0x67, 0x5d, 0x5b, 0x52, 0x59, 0xfe, 0x53, 0x78, 0xff, 0x53, +0x63, 0x72, 0x5b, 0x51, 0x5b, 0x5c, 0xec, 0xf4, 0xe7, 0xd9, 0xd6, 0xfe, +0xed, 0x63, 0x5b, 0xff, 0x67, 0x7c, 0xff, 0x67, 0xe9, 0x6f, 0x67, 0x67, +0xff, 0xdb, 0xe4, 0x67, 0x5c, 0x67, 0x5f, 0x5b, 0x5b, 0x5b, 0x5b, 0x75, +0x67, 0x67, 0x67, 0xe7, 0x67, 0x5b, 0x67, 0x67, 0x5f, 0x67, 0xe9, 0xff, +0x5b, 0x65, 0xe7, 0xea, 0x7a, 0xff, 0x7a, 0x67, 0x5f, 0x67, 0x6b, 0x5b, +0x67, 0x67, 0x61, 0x67, 0x67, 0xff, 0xe8, 0x5b, 0xff, 0xe7, 0xe7, 0xe7, +0xe7, 0xe7, 0x67, 0x5c, 0x5b, 0x5b, 0x67, 0xff, 0x67, 0xea, 0x6f, 0x67, +0x67, 0x67, 0x4e, 0x53, 0xe9, 0x79, 0x59, 0xdd, 0xd4, 0xe3, 0xdd, 0xe8, +0x5b, 0x62, 0x7f, 0xd1, 0x6d, 0x53, 0xed, 0x6e, 0x66, 0x67, 0x67, 0x67, +0x67, 0xff, 0x69, 0x67, 0xea, 0x5d, 0x6f, 0xdb, 0x5f, 0x5b, 0xe7, 0xf7, +0xd0, 0xe8, 0xec, 0x73, 0x5b, 0x67, 0xf4, 0x67, 0x74, 0x67, 0x5b, 0x5b, +0x5b, 0x66, 0x53, 0x55, 0x5b, 0x71, 0x5b, 0x5c, 0x70, 0xed, 0x4e, 0x4d, +0x6a, 0xe7, 0x6f, 0xfb, 0xd5, 0xdf, 0x67, 0x77, 0x72, 0xfd, 0xe7, 0xed, +0x68, 0xff, 0x74, 0x67, 0x61, 0xff, 0x68, 0x6e, 0x53, 0x5b, 0x67, 0x5a, +0x5a, 0xff, 0xdd, 0x5e, 0x57, 0xea, 0xff, 0x4d, 0x6b, 0xf8, 0x53, 0x67, +0x67, 0xf2, 0x7b, 0x53, 0x58, 0x5b, 0x56, 0x67, 0xe7, 0xf4, 0x6c, 0xff, +0xe7, 0xff, 0x68, 0xee, 0x77, 0x7c, 0xf1, 0x67, 0xe7, 0x5f, 0x6a, 0xff, +0xff, 0xff, 0xff, 0x60, 0xfc, 0xe7, 0x72, 0x54, 0x76, 0x67, 0x67, 0x67, +0xd9, 0xdb, 0x4f, 0x67, 0x5b, 0x5b, 0x56, 0x67, 0xe7, 0x4e, 0xea, 0x7b, +}; diff --git a/contrib/netbsd-tests/dev/audio/t_pad.sh b/contrib/netbsd-tests/dev/audio/t_pad.sh new file mode 100755 index 000000000000..8caf23a7de90 --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/t_pad.sh @@ -0,0 +1,47 @@ +# $NetBSD: t_pad.sh,v 1.3 2010/11/07 17:51:17 jmmv Exp $ +# +# Copyright (c) 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case pad_output +pad_output_head() +{ + + atf_set "descr" "Check pad driver output against known-good output" +} + +pad_output_body() +{ + + atf_check -s exit:0 uudecode $(atf_get_srcdir)/t_pad_output.bz2.uue + atf_check -s exit:0 bunzip2 t_pad_output.bz2 + atf_check -s exit:0 -o file:t_pad_output $(atf_get_srcdir)/h_pad +} + +atf_init_test_cases() +{ + + atf_add_test_case pad_output +} diff --git a/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue new file mode 100644 index 000000000000..0aadfa7dae51 --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue @@ -0,0 +1,998 @@ +begin 644 t_pad_output.bz2 +M0EIH.3%!629368,\S/H`A(]_____________________________________ +M________X)/JWW=]LJ1DQ(V-I-I+:VTPD*VTAK31))5F;9)60#$TK+5K#:U* +M-:*D!0Q6EMLA*CJG75+322@`44*+KJ[*:U%`=]N\V@VVF]YP#E5K*A78P,S# +MZT/(+W<.M[>RM[LO9>]N>KVVVVU[MVU7+6MC5M6U%;5E +ML)MD:LTBI`6RBM)!"VL!D))"-@4VJM56U;9JFF@VK`!M@#+8S0%3:-K6VU,V +MQK&@`*!FV;6S9MLU5K8:M9K62MA;`J:+:(V9I2W6NUFUK,VJ:NMVZVSK;O96 +M[N]W=W=>WO>;6M[W;W=[WO>\Y]SN]#??>>'&P/6$RM"O;IU+34 +MFG(=*=!IK(YZ=U(J4%`]!0#1IC5NTN.DU1;44FHUEELQ;`VK&UJE(JJ:8 +MYP:41,@3``T!,"::&F!`9#3)@33331IH-``TT9`U,&@TR&0R833`$T,F$Q#$ +M8`$T9&C1IDR,F(--&3330#0(-)(1H`!H``````````"8`3`3(P3$P$8!!HT$ +MP#(TT:$P``)@$G@)HTP)IZ$QI,$,`%!II*(3``P8":::!&`F@$P308@3$-4\ +MP1-3]3$CR9$8;4U/*&T;4F3$S2:>IDR9#!&0T,U`:`&AZ)Y)ZC0QJ;4]0S4> +MIH9&@"34E*2)E&R>I[;8$CTH8"3!)X4]-,30:!&3)J>BGDP*::-I,AC*:-#0 +M-&F@`!IH`:::!D>H````````#3(``!E2@3Q(T8--#0F@D],U3\03830Q4_$: +M3,)B9-3T:,"(]&IL29Z5/3PDS331H:$\*83::9)ZGHTR>B8JG^FC0&3$T4_1 +M,FT9&2;:FAJ;)I,:&BH)-2DH04]-4_9MJHQGFI--$,F@9)DRC:;5,T%-E-JF +M]4;PIZI^H:GIFHU/TU0\DV(RGE&F9-BIY30]3)^J-/4_4TC0S1I-!ZGJ9-,0 +M\4T9/4:>H/:D>H'E&0>IH>HVD_P'^!QBM$WZH/L1P,O'$"(@>"7Z["OJJJC@L[DDKWX>; +M.I?\7_4S95A_"B0(B%P@`M:^O>ZN;N>U[CV8\/P,*1D\ +M7FF6F$[Y:6L3:\[_+_H\CA[6TL6?19]ONV3@J2HH`B+%I;W +M(>S39[Z?/-HJX`Q!(#:_XGN6K[U>EW4[>PI':-BK]?0U_-QOB$O00%%Q](-)Q'ARFMZF:4`2*C^K!H/K3RKK] +M-!9O<*COJ&H>OZ>?,I"7:06C:]$#!7=16YRM^YR+4QSHV:?UYS-:GS>'Q=RQ +MJZ,5W7X32SQ$BH3;@MD0(9(:S=IYT\NE&+^6.SB+>\:ITL]=6UAGJM2M)W:( +MJL&O*9A]EW6N7E +MT$1*_C_D\Z#.K+*R1LK?8&:X&741@Y7;2OI4^=RX&FBJO1*H5P0`W[?B=1S] +MJXQJ3RQ_#P1&\SW>R<6MHC1*ME4`1/!DV<`FG!NU#,,JP_VGKDJ-W'7A.6-2 +MH`@6BQ/H[0!?G+3#@BKUE&XG'87&!\'ZM:%FJ1+QPCSS0J$0`\ZO.D@Y?+5F +MJA&]I_8/'_YW56@=6IBWCI<93`!/!(_%C%.;ZLRBTGM4?'A=G=<>6D:!@&N; +M=TH@$3>I<;'M)5'3VR4VAD/M+707S3Z(2YR*8E+3FF@$7C[M0Q!NV;BJ(CE2 +M-&U^="FV54K:M?GT>6J*KZ3/ +MO_/9:G327;0T03)*,[RJK)$0%5,/RR65<-0YN"ITIRPN^UD^_^(W,^WOR/(4 +MVI*`3A>M3S""->70*,S":;ARXQSC5TV0X50Z)=GTWO9TS"0#C_CGU`UFBHF3 +M+;]/P;'"@*G:SJH4G4W"\"1=+^O,/M-XO^%*VYMJ>?VUL)0`1G[M:"=>*)G"?50.UXBV(=QK'_H +M^S&@@09*)H!`;`RL74"ZY1NUEI&<@6?):>8W*IZFE5UI/ +M1R(YCJ,..G[%050`52\01%GW-7V6N6VY)^\7"N;]\_OL/L^^W#5EN352!#:Z +M9Z$:0G406)N$S-QB*V?YG;RFPMG)`H#IT^ZPV[#EX/X[HHMB4''<*2RS(K.B +MH*9$"IDAYG.-6D+G2KB34-#K?6CJ_S/ +ML+"GC(B(AYESJ5[#I"'8+FV9)N83_1DF::W>MV<51?SO>O^6'\9+L^UVR&?3 +MD$VR$H2IG/^-,G_SHI&;*/,GEHV@[VK:/2F0+4G@$.&F)A`'<)WDV:A<-ZHC +MV;TU1BO%#Z15\%HR\!^%,8GZ#GP)J`@18-;CR`L\T>D)YM&Q)B:0`_ILC@";7*VII!'K'N_LIANE +M:[1]QOVP<_1HM?;=\.;VT^SL_5UOT9HAI!)BL-@ZP*U@6K=5WR1XFY5YK+N7 +MX.ZBJ)B75\@BJGB*%?!%I]3CC6.TB[8+O*9QXU-IH;F;O;=B\_!G-MV_VU3G +M9R$ZX +M&N25R7JKAWA;W_,$/KZ]1 +M`!:>@T8(OG%LS"]ZJ`'"B-K/PU/HK6&U+#G%\>%L9'7I.*YS9);!$-9U_-HY +M.O!%_0W\5+LF:SK"(O%HM@IMD_MA?A,O&G*MR@1%P:$$*E0\6FL)>74^?E(5 +MTS_S=,8R'-MY^=7NN)A"VO(GG*@(%U<`RJ`#/<@QUHM:YZO@<"*UO.HKR]K> +M;DPH*5+;*`!!OI-N"G'',0\WP<2=5HB'TBO>A;P*KK-&S4NO>:O?5RN"(=O? +M5(!3:2.+`>V(H(AR<(^)5PMK5/Y<6OXD].Z&J8R2$4E3!,!-82,ZN.&UR*ZNXQ'SQI[EH=,#^6*">)R"MTI!&IX +ML6"=@QS3A&ZZ5>KMRS+ZKI29EHO,]GI*G76AU_?.-=L2C%NZAHE#I):\G`BA-\1,:"_GFZDY4OT^U5:S5:8=J3O>9]N[2J@(A7( +M+"?@`"1L:*6!;?\TO*],-NG:>"I]*4]UATF[$G6E2``UOB<"(E21ZG0]6%62 +M4?'\1N5Y3B;O1UQBS6`XT6"KR%(`!X^:Y.D.$IJ&5X6=SO_1;NG%W>Y9TUC, +M["W_2#@*!$0I.!@Z-[V7D("$\ZPS/T*'#=1WV_O@T +M$-1*H(B;IL$.9"./.-O5G+\)Q<7Y5V;3(6,WFN7U%2TU2B1`7<[<86JV5T`! +MYQ5;+_4NRDMY)27_;Y@LGM@>=!E$C7+OB5OKYQ_JVZ^#:KA`AF][SYKE@$Z. +MKL+!<"V'J/;-CB/-+M6!@:8J?=5,$7*87[_H;V;D$6;\'&B':[GERN[CL[)C +M'Z\:.7UY$N#3O/&[;;P:US6P0&FMP0]7YK.Q'-ZHJ+N8GF6IANBI@R@ZVKW] +M/[?A94->@!$*<$2HS*@9*CR,JJW84EL86668I9DIC$0U3R@9(&/XISJ;O<,K]U%BU +MSZ1W7VY;)\*DBH@`6(!9-550K(H$-2JAIS(J=J1!$\T;+@I!$.5]6T@4[H97 +MLKD='QVHK%;I1^Y>)2=K'"=PC=]3*WF\Z`B`NY-GO"%@.XJNS)Q8IWM< +M['Z*7@RNX/$:/SYG6YN\O1LH)#9?\NSQ)BUG34?L$;J9V=:>I.]>RT66G\VN=KW*?VY"J0`L>-A] +MD$.KY:H;B-Q<6ZKG#LK>VLXM`Y>3CT-TG@`2_8(ICBUL6QR:8RTY4#7/[N'D +M9+/?KZ6RD$\B(,]UW<1J>P"7,XXK(?KJJ"'B32W=5.RE-ROA4@LY+>NU500$ +M)[_KYKSL`@-0%SIJ6R*XIS2RZN8:/J[80?PJ*:VT,+G?5^ZJ"+M=KQ63:">: +M00LGQX?8;#OBE5(N'U/?^4KO_1(IP("^B\&D]OE($J)6^%GG@KVU7H:;GJMTH`B%P"+/VUMXL +MM`H,JWO;._<,SA?!GAWG%^ZSS@?9_%%2J``!C22`U&2;6U1TD[T/.R3%R]S: +M@RN_';NSQT%-!1HF?S@Q\DWM``,9R&4@SO;;91IS&.J^E3UD5C\=.CH)\\T= +M[BL)(Y-;*^$`W/S8+'<8*#\UW']]%D7*MF9%5]`]&4HWJ!Q,I,1*INU8`%[T +M\@7KRUFYK"PYH&:`?>L^_O.'+TSL8[V,`R[MEXL,$]<3JV1`?UHY'7@%;BVZ +MG-]Z^PL"[P$-'N'6AU)/(A*O(!*-=Y>-`[JY&EV>FY2S;U*BV:C7T6/:\C?MO@:-<^W5=.T\`Z8W:;BLFE'.9B2X>+.=!JVI!QUO>XT--O) +M[=ZS2&L>69P3_>8&HD]YO%24B+%7M0?K2(N"%2TTXV+,IH&$\O)OB1_A(8AQ +M7A.!:]I_@Y;%1``'K9:V!B,NF``:OPF?!9S[A/3>LS%+Z!5TNL;^]CFCD_Y, +M3R`?(A$J`1!1BZH]R,&XRWJJ?G_NP2M(=YJ*0=,,S+98/\?O7S>7'U$XXV.XW%N\;-Q,`T0'+$5Z;F&ZZA]@V(D"BD?:`; +M=S>)A-.=D9J8S\+(1K\R/P?E6O!"J^?\W-1#\S?1>Q +MS[PV>Z9M[RE3)>NX2DF%GF5JR+.Z(2BI22 +MB;KN%RX7I/]0D`$N8K5Q9'"!?I>K'$_TQ9Q@_U<,':[%6RYA^"9RM.@_+>*:ZQB]?$?ZJ +M,QBKG_)*"7KO7P(&T^/P$'#"=8\Y)3C)).KOW;W#$ZK#8%*U7=U2QQ_[_V-5 +MB("08I,$3D/,Y_O.X$G?;WRZ%R:T#1V%)+(O3#@@-#DZK[!]4DU,=5X&GCA;22225I!AS0\_.D/@*J67P1?`GX4NB +MM+WX?[#5IV$U5-6;8B#`3/Z/GTC>E4``\&WQR(?:\Y+T'VG?%7$].V>IA\5= +MWKZ?7J0(/?8[MN@DR(>-$T'IC@M)FG]4#LE7.O&OWT77(2(.6D``T&_GMEE4 +M8R)HJY%Y##J,/(N>"Q9#JM*QF?E1*9`LGG>[R\*P(`/47`4QF\_/L\4-TL60 +MH'?1"-Z>'882<1"DIK($5)0"A?U((?& +MB[RFPV#OB!Q:W`H6^(/^ZR")'HZ-`0`X_!Z,WXI&U#7P8%4V[YE\Y=UE^M5W?QW-TQ5[_UNM`@,QV +M:($!,;*%[OR&35=\:Z;3E4+'CK]55]XX5K>J?Y1(%P_?;;.&KB(E]NE$7Z/4 +MA^KG)K4,F'5#[X'??SK)UDVI3R(5]D`0MK5=V=GT;@W=;7>OF39G]ED7^XQ7 +M/S"*A?84/HU@@7>T2CQ@"O6S4*QPQ9BGF512;):"I=E5_#QA_J%,$4^1$%)G +MN)[OT@KO'UL_]22:=PV&TYH\?N6X9[;YBINKW3^#4+8!:1YLP1;6DY*P)968 +MT!52)%K7@9,9.4]4UDRN52/\Z@1`=S:."8`0YW@B&9YL,7@R69XDD(!Y2##/ +M`K'9/WK+RW(9`2IV[`+LULJG_2*#%4S>=T?OXZ$PI!"5WUHS7Y`#)\B!38#$ +MXJ]FWZDII/45>LKFO(A)*BDPT/G,\'@/+0`"*^;E3A:S53A$-1VD##4S_,7< +MKO7Y^ED$4'[&)0`;HOP8Y-K0S-6^7W`D]'6U3&QYO@LG)#+I\#8Z]3 +M``[6+`$CT2?-=6_NMD:G#_R=:F#$ECZW]O/]S`25;1]0D9S!URG"8]HVP'8H +ML>U>A79$N1B)RG[]8E!+]9V9!O&!B]M,&]8%+P8^(J=-:MDHV;Y:#:-]SO=0 +MU>-O%,`AE^1!SNJ!%?8L6>;%:1U\^]ST%C^I_VT5[J2EM52T>V))!8/8!`8LCK?SQG!%$DQ"H4&C=77246E/XR:!1 +M\N^XK%W@"&)^K?!K]QBL-P/N)+CY!!1XYZ4K91D+;ZJ)`6_*(A6T6JG'01$Q +M%;/;.^]B.%WHD=)CB*S?IX!>*9;'H@0\3YW=O%3JLIOBMLU?)Z2/Y.-=>U\+ +MN_M(U:&-DE0B'?Y,FT4Q$66G?[7-W0J=-C=G=S^G05M:S)9"WR=THUP`+XSR +MB]P' +MV?/-X,(,J`@5Y5;[Q[Q(8`0$BGM]Z^;56<(B/=W%D5XF@/9*^KWZ^6@?;5AD +M4R(1T^YH^20+*X4W_<:[4RZT.KJO72BYYV(4?)6XRH1#!^620);6EKH5JH(@ +MG$.O-G1RZU_$?\T\`F*$UK\`6QSW$V+/W5-H?;P="7=KV]5_0K?%2!#8WSZ" +M(=K95/UB]E:=K.[Z?_P(]LL[+D.P4K<9$`L-.$K$!FNLV<"/]0`$"4VO1[// +M>Q`R!4#K+OXX'N4OI>T@085=/J`(N<@A=H0(0L+U+WF17Z0=1NV+?R9C2T.] +MH>[SM%:5>@6O',,S,K$0RCGRR!"M0OU\5W^[VI?^V-4L=%);).JFEF^G`J`$J_#?2-UI01;`(L +M-=>0(O\4]73WL6T*MO4MX4[VKM-RH$"OO?[IF%(@,TJ<;/A.4^.S\O;L203& +M];U^M>4]\7+,)-UYX#]20,""YW*\4W)0EXQ,B<S+6[81RMJ&.OA1/=]B`, +MQ<6E>`!44N1]'2Z.G'FCO,Y1R"AS?2CMUJ=M^V_X;7.9Y``4UZW3N``/?$^? +MUN/WV[YVI%W`C3/%YYPZK2T'5PZ2(B$%^>5(@':XR/PB*=]VG'"W$7>EFRXRN66F&E5(A5Y^Z`(=968%Y=U46D3>'NMI+*4#&[/5[>-6E8@-: +M0((WTR>U@0]*7X;X>$H7Q22X4:BT/K?R3@(1J:^""+%'UFZ[:_&!#7DD_X)" +MVV\79J=PO$U\-Y99Y)`:M7ZKG#2CT=MSUV=X;)MV2PB-4S)G24Z^0=,5F&FN +M%3I;C\.>V/^47`1#$T.'W.41%]'S3=Q04:A'W[AUY/T+#E9*)$ +M$K]7^?<^<`!D(_N.G.P#%3;:O3EN@\LE(+S[E^JL&733?-`( +M0K/ED]OP79,C@"%NF-_]V^0-< +MZ6P@N3OB9%8B*VZG;UX[_,`(9/M0F?<$`)]!48ENTNK1J^KT:U"\EAHNTZU1>;F7">""]QN?,1NV$AYO$"( +M5>4W_9\Q_&MNY_L/;TOCP:Q@D>G'1RZO=95!14Q1?J"(+L\]YGY^=@4J0*\7 +M63I,2.G69B> +MTL]SD\HK-A--A.>K:/^F2CCL:V\!3;6)L/$`@P8]>H(L@"@>\R0S*(MDGMZXR +MNFE08'-''9/U][FBFF@1G!9VSW&/T/=9$)I*W@7.-LFNT($$[TT=#=^=5;>1?N-PJ +MJFE9Z55TBG"PVD;;OJ'X*W6B`S\]S]^"(3'0I;'JO06]92\N*V0-++C9,=I. +MI.5%=>A\UE,JY`.EIMPF&9]RUF-"LR^8#?@1\JN +M+M_!=WR_A.7Y=8`*:UE?ZR(#_EOJV$8T^YLU&',YJSTJYF[1IY76J%AW"B1< +M'/\JC(@/TS<1.$8SXL99,WI%.R8IN[O;UFI5(Q.!!K!$*GWP,3M=S2IO>Y&6 +MJUO'MQ\9M/;&J\84\&J7&ZG((W4OW*;R0?*C/?`]GNLF=LMUQF>-]-!_#PM= +M]M8R8"B((DLK@VWRS-7YRD9WX,BCZ\LB5#8RLF(%;A5D!$*_(==E[/0B +MKEDZY=*VF3[:GY#QQN*@01^UU23@#VJ@(9;E-_-JR!">Z-M1]_CO79T,UVOJ +M<7CV +MXZWE)8`H-MD'M_"<`%3HL+K2``4$ +M?O=[_II043;+9ORML+!YX$&K>%2(HB4WE;4`BIFK1*W."MU%%GU[,J.]`S\2 +M.J[57M!#(B!9R"(@5'U[_OUNQSF)@[?AXOFBQQFU"D+C?9KN-C=I$B!BX;+X +M.R5P03;Z>!$%Q>XEHY,]-E:^M_6<7T[,<[2KU,Q/;N]R&I>E@$_<3@;E13B( +M$MAE[74'7JYBNHW(C,%5"N`/?!*OU^=6ED""&;>W +MC)\7"9C9."X330W+=+#MUJ+#\M_=40`N\#O8F3($+&OW&CKUN655SEJD;OF^ +M;2=\A>DX0!Q0QUT_+<'&A#`#NX*RZ`0O'[IWGQZ^)^-;WZ'I,SDYM++,JI`6FEZNG2"("QW,EX^%EDBQL`Z;.2V\C884:S:]`G%$4'YO: +MPB`4?B\\6/IEC!D8%B\2/H&@U-KQ,MRB$,\1*^<]/;M=XL@@6I9V^"QT93W: +M[Y#=#Y8V'6.*LY99X?+U$U&^W@J*`AZTNST47H01%_STWZ+R+B9X5<=S[4WD +M?EJU@,.27;_&QCI<.DG$A><76W7UBJ,6B!.;YH[C;K"OOB(@B9C\NZ#`KZQ^ +M69US2F5&@UQI^BYQ(`SFVR6UK-(@("H@&>\4*.`Z9$0SGGB_/H?#H/K>>I66 +M#E(<^*_!I1=]$W[&C?OJ@$&/M\F4GE;P?*@75*KC'"?H.:Z-U;HU0AY4*?/8 +M>K(B"=G-&K;!HW&#@?LWSW^&AX-N-)3,P&16?[11`'^B)[6D0&M??UVX_#2I +MK;JFEY2#3S,DH)8;<_VOSS\1[VF<7[BA!`JRUDN;I?1O8ZXOK<_KJ'?5W3\G +M.G=XJTRT:DSV"F^]XQ-!T[-65E( +M%OV#6B]38E!_T +M[][;B&\7VG,9()1_78^$U:"JX"6K]K6K#&J@O5I-4P?GV%F:!,;CD&F+^I*[ +M?U+\C)H]6FIKBSW"Z0/ZH*30$`UE!"IK`6-'ZY?%0/NGGA3I`IUET[1"?*L0 +M'5[?=5MQ1,`!`F9-L^NSRM[V>;(/3[@/?`][C<_/2U>PSF1HWU\"Q1RD.AJ7 +M'?V>.!PN1E]%3SO1H""7K[9E0'6;QN7C*E.FZ+I,X]I&-ND28M7(^//T"ZF\-+V#*H]#2,D+D$\@G=3=D"*&O.0_1ZM],YS.Q@^I +M>GU#)EM2@RY5/EYAW6I-!!GK(QE)\JEPQA)#)$6SA:<>B:=/L;&EO$I]$"G% +M>KMQ3/Y$`Q('#C)7IU7^4>TI(AE:>@U.U8X3`U$MW5!(-IOT*K=^[%/.B45/UV +MD8G]4>N-[+F&FF82)^JF$ZBO:UU&2!]W#QC&_>F^R<;%S5)N-2VN*>&V0\'R +M]:1$`$6-Z.PQ0@/&\;>RK#'X=-,545(]M[V'E:.IDNC^YG/^O85GX+$MQ+E7JQZ%RJZF`75RX/'6^\;T0`!%S]%C.FZ^75]SC +MXEYF,*DVJC,KC-D7R!TTY/SSED5C$Y+-,X-/&7[5'$DXSZID6&Q06J_U[]&W +M%C#Z74[B+JA5N4&Q6:\O*Q6:+TY;[TX`*?QO+T;JRJ>!L]<`!<95:[2_\ZC#>1U +MG6#4F]Y+.@3#<7>86G%3(//9]+>@`(3<8QL_\;QA=;)-RE\AY)5=Y!IY52EG +MA\*'55#J1`!=I85^WU.;G_Q=VG79*G89%1_>3]SN\J4%AS(L;-R$O8LJX"L, +MSW>P]@B+3H6M7TEE<4Z/^EC!&BL?5(U6K.:@LD#)SWGSPF?;_'\I#Z0(G3!R +M]@O=M$IY*I_V4?VE*CN>JOZSG3"DD4"(EMR5/R_/VQ*DHD`3;"]JXZCK4_-2 +M[S%W>S;K2VM)*DK9PQ5"4#AY/!:_Q:J_^.4/_X&`@0ED9\LU>$KH.-X!LWV\ +M3H-&`W.UH??+DTZE;Q85P,:8#'!!.[.CZ5[E;')_BCSXHY9)($$Y_=8G[_#3 +MR*"BEF;+!77`[!<4"\YAP.9V9EZE$H@`&A*"E47\5_E\M,H^GVR[NT9Y>M[U +ME9:M?@UTE,%A,=+WM2;S!$Y/K=W&5+1:PU+16%-<'\HL7V;A9/]'JTUKS=)R +M%%..\LU+2LL@//Y$1/[(\UQOT_>`],HX\:-;SV4;T5))ZUJ"FC&!J(X"S,"' +M`CIKC4ZZNLJ61`AA3*:)MCRL'/LQM"?B]C'K6DF&% +M<,8&,8P,8B*#WED'1U^222>@K]314[E`^,R`?L^WD%L]1H*,B +MM.AP#P5)X!%)J3;E3X*9,V^S8K"A24(*Y\:12`!>4=,H004(7YH?=8`\A:&J8L9\J +M2)!?['A8I7(2(RD=4:NL(4B!#FK\V%.+#=G>)6/7M62!')**!';IM9SW141@ +M7YZ[.XF5%@_(#>_`@>;HX$W +MJ%^S_TX15?":L&/-'I>"?5GA2YT0VWV06#"L=^)R;F//*`K +MKKT@\%''`1=\QHF0@[W^2H`\[R'?RQWH0]2>('^+TV?16WU,0<64_'0RC:4$ +MW+(Q`,&0!M(*PM^4_8>Z7T!`7--Z$UDMY9`0@*K2+48SF#RMR>^UO.!1'E?P +M*:^[C-WI-4WB$@ML0$P\6FQZ$7ZP.AM<1:BJ\%(1RPSKR] +MV.H>!"$U#*]%8(@GI^U*86WRM#VN$N9_?U!T$RTHA\1K>;M"`5)K2BQQ'I4FL< +M\'R#S4CQ>-1S^+Y2GJ$PAXZ?RY(76 +MJN1N1'O"Y(H9$M,6V':I)0X3=FS\$)\P]5B$J.N2_.#VYU>TER!M&9E2BKC.\80#LZO71W]\UGP!L'5L-\^B^^JYW`!:/WT6D +M.D[:L<;PHF"=(6&XC<7]&@1('A[1P'9TUNOU`%I%YOM'P/EHLKS++Q>$B2X- +MRO\:_73A5A4=*L\71_*4PSBZ,O:%FF6V/$WXS&A`K:'X\4^,)_IUK[`;9&W^ +M@U$8>!6[5;@OGLZ+Y1%^]\O:T:*03K8>#>]4X6!HYL>I6B[_I=7XB*&21)'EG27&A/%_YZ1^2"$/H5(Y9U59^QKW1R:=20X +MG-[/RQ.O$`3T$^G"OXC2)48<'^S$N7NVQW*'7E]`]>ICVZC0BU^XZ//49DIQ +MIYMK/9@\69A':D^H*E^EI)EVUGQ[A'A3Q,?Y;@-_IU*#B'L"5_/;X&M0A#)G +M2'",.?/->/YMS]2=?1_$^`(NOZ$KQ">,*[.<;HDEC&V[7T2B9'4'++,W4:L4 +MAP2+/:!QT`S?1NZ7V:XS+$'19_9P#[WQ3N[=_:=`E"W#^M2$>,U<] +MCCDJ=`R3&9M^P=)%8(_^@5,0,YLS1D+VX +MB"0NBQG*CR40N(B>@&CHB;7EHX(/7IP&WYKXA4"$7M<@2SQWSINR$O67IRIG +MI:FI`0QZ<;SY;K`2K+\CB=U:E;7L`HCZ=8X,:Q'[#3WIS?@+?ZO3GTS*N?DM +MH1=PQ/Y:7,AQW1H1-S729BK:J#01*W`K:R50HJA`WF(DH(L.F";C=WYDT9#T +M\V%:D(KI6OAU+&*U!T@JE2VN.BCH]S+L`7PO^HW+2%-;.%]@HG9\.`,$VKQX +M%WAH)LR2+J+7XM5?GG"R@F=U\OAQR&[-;[!]Q*_VEW +MG%6O0&4QVV!U'G`3_\GVR/B'1._WPDEQ8)B;NB76D[B3501)7:A8FMO4:#P0 +M5UK?R/#HZ[12_W)A73Q\T0KX/S0\NA9P*#^V93Z%H]A!'*>W)BX]:T$ +M)"RPZ3IOQXHT%9];7_;@[!<2[?VA1K3>9-^,-&Y(-,KS^OGG+5GPYVU3^=^/ +MC:Y(<@O:Q?)6'*):@C<>B86)XP+++-0%GX?UY3OA`;TJBLL.1`];EA:W@H1+ +MFWQ5ZU`:XQ%.6NQLI4$I:K4M#-L2$#E5Z;6I0+N:(;UTWG4H$"@G>EW>CAFS +M_^,1KGV^^Y%EU#_RT6R!;+P)O%.C-5:D0>N8CNIV?H&92%D0E=99K'J0@OH? +MI\:R:MSFH(?'=7OF^4T=-3NOPN<)?F+9SG9I^Z_N6P7&Y#GKT[S$* +M#A++4^(1<1P\C&0UAU,I>8Q9PG1B]C\VRX_ +M9JP&[6SYP*.V0ZX%@]2T.SX`E+EY077*6$]FQM##@K7Y^@X/DM@>A:G;@^^, +M?+U1N8;'*;2@U<"6C=+]Z1-?OE1`";C],MJ!.!?`>K&8CP= +M7GAO3D05MC\5$_,&%";AV0@3.M4`-U.S7;E%@7WT?:25M]7NAS"Y^2QISKK_ +MH+]&5V?3?+NMH0W/UW6_SN"]37@2Z08YSF']P'%`B'?]G#$6DR<\UQ8#SI%P +MXI&$\FD%Y<1U;;N9SV@=UE@D=&B#P3DR6`U+3FMA"(LR?%(B3Q#D'3YP#&^? +M0'2B5'(?Q&$T1*+CY?^/I)C&`1J3>1P+1+W_D)\(3`#J)](_A+&"!^?SU]8? +M"28QC`P0W\UV'Z[,B!_B].@W[(>E_JH(=DP6$^DB0XQ`&!&'[J;T?/OQ!I>C +M@FZA5`_UVSAXP`X;H>/?"S,,UT2QS.WVRQ9XI>\PSRYGIL(SI+`G`KU8F,M/ +MAT)KJZ;9$_UNX)_DCN4$`:?,W=.O+I5?V`,N3W)IW?CA/[UBW`DB,/4PA/2SF6H +M6+7S$O]DOWX,NM7A:Z`\>&))AA*C==8X=24JS!`LTMRD[S.*EF8-D,-DD@:* +M`=3P-VF4A^B/=RWXI2,+*T63O'5DW0&>5S"4AHZ*0BCHZ==]0M4G;VF*!^\6 +MPI&[M#O6T.[KGZ-`2N*L9%E,#CYF@>0P%A[&%'8/X#;[+,FRA\YXGS!E"^M= +MLO"?+QDY1*I8:/L"]I[_"ZTI('ALL45>)ON$!V>$]5WBOO08KW`%3&$IT7'/ +M"N:MRTF!W]L>04)N8(4:*$5SZ_2-3?X_/QI&'&"72U5M^'KU[)`^T7ZB":X] +M6&@+NJ5@NS;>@E'L?9ECR1IJ?\_++8Q@A%-8W^,W.!"2V5WK3.[4['`*427> +MHF4\&/2?"P@9<34N<%"UBGHT/VD[8<2Y%W!T+\^3@]G0\M(&IG-':+K?%:-# +M_6F.RN0LWE@_X,-IJRT>..QNN(95O?[+9B2F$^L)*^2V_`<_ +M'.S&Z9DGXB5FAUZ1J.!Z*),WD5X,^@?69UOAHIO?"HH$7W'1HAOS/35PGO.J +M@_5A7?%5="PEW1M":87D>>X!)63T;%S@K,'#117&"AR\MWQWE,E(R&YN`-"I +MEP=CNPU'S0=8^1F!;.^4F2%A]Y;F>&=+&A]5S>_/W=`;W\N4@916C.7A[DD< +M$9E"P=Q701:G,KG:^YK2JZ8*]D/U-M +M':[)`D!W-"7GH-T(C06CQWKDTP'MPAZ7]^BV>C-`V9P1C2;&V&3[`M)CW>#U +M8#VWB[FYG])/?#='&KTI#9V.`^5/I<,=?M4UFV%50VUL:CPLU=$5%MF"O*+3 +M&`^'DSEED>LQ')8!5V1O/]DDM]R6%TTL#55QA;M@`QEHE=5L1X^ML58"4]C-\(S0W0H7C0:G\!\T`P>P(+95&J83^.,;[;ZWB2XME-9^4*HZ5_*" +M%I7$49.OATU(>X][?>OL+>]]T.`O1/H?M[KCGT%GQ.#R,[>!G/M)RHX&'UY& +M$"[,Y*#!=N7AM-$8"*:^[CJ:A.,RO4H`'GR7[.=,(7[$;U#'8;4TV^9:P*_>LI)"I.8%>;`/J`\#T$0ES"FT.H7 +MJ\Y)^XP[;^-2UJ1M2?3!JS#";.9]Z*L=37:E=EP`@^GCB!Y]2,-8@RZV3_+P +MW4.$)`2=)\).D`F*<4MV'YX0^3H7X&U)A[->$]HTP-*9]_R\]'&L]'V3+K9K +M\&0S2PV+A%J@W2,.Y2=276YF0T-:`YK7?H:/Z,5;GC<&?O#]V8;?M/#6EVF( +M#5TE8'F_LIMC[/-WTW)?<44-@K/E3)BDH/L??^?.7X0ORS*;M3B'9_ +MZKVX<)B3!K#%#=`DYC]#6<-7/1!IV.&D,[=KE7/`H^7W_O@:BGFPUNJ[)\@X4MTZT +M&X:T%J2&/X3C%C3_OSFO5+GAA&<#?.`RP_@8E/9%(O6%H8N'0S&L:;A&]P:% +M4+V_2D^;+C1WILVC6MMP^0<(.4)[Q!B_KW7`JS +M_>-=3-"A0FA6Z=^/]FTX;_.]LX&S$,P7=@+BSC(<_I-1I[HT.TLMW3O +MAB$T+!`&6.8@-2LBY,*1//D4\"$7`L:W"Y-@S<_K?*=2]2.]G(DX%#J=4VN7 +M2?(Z7.!02!QS$K]NWLB)LWG*/-S`OW4TH.8/[HX.XL:].'N5>X69DX*=A$%, +MS9V%#T_\P&K5G@=;.BHI[+EO)B;5O_^YWFK^B.+-13E0N+)2T^VDA7+A +MW'"`VRG35`ILVT7YS%;Z`!Z4!_[NZZ2&&">8UT<[`?OU&5+.S],$3<<@YG>$>7'@CCPKCB7)GX%3YJ +M>2S\^[M[J>`E3KT`[@A_+^-==!5@C(*$/GL):0B"2",A%16+`%6+%@`"H*R! +M]F@65A#^T)]]]%8+?WZYE0`PJ(PC?MK/)=LL>"NMJ'4S6"+/#H5)^N:8KG$# +M+3FFWEX'6&1PV?K`";@&G`-89]<*,JCW/&=WZ&AQ1*),G3DZOV!YSOS.G:@) +MQEI+Z(LGU^EGW/@3L)0M_.)#07V_K/%Q#O;'PIV$32-Y]])>_;=JVR+"8.MB +MHNE6*WQX'O@,O^@PP5_O>7E^++)E./$O8#?GFAZI>V:-K1V8/8G1NB&P]+;D +M-J_/VLR'5.#U>JE"JEY446",M2K:(Y8_S'_:+&8A\`G_=60]0WHGW357C&:_ +MXQUA#0D=>U'%V-K[V[(>PB%IC_@P>W@:^\[GESH8WT3N.Q\B_&RV;D4;_1F! +M^N!C<=^@>H\R*OK4M6V#0AS]>FT[4.687DP=GYYF(CXEE-#3'K_#,C[SG:7$ +M77R'I/!R=B8-9+%T78&8P=/(FAP5U^*874P2@^B#FY?X1SC&4O"-4N61PQ3* +M1?'8X&F4EN.PF +M+U2A3L"0WJ3J//YDC\4K68=*=@8M?F2J-E4'A@VNX:2JFR$6O&]?]/\2.G=M$ST6JF\[ +M1"K1\[XW?4!YZB(9TJPU,'/2/\%XGK'4KT&K836D=73KH"6[?O;(X"8%N%'2 +M1>KFL_CI&<#GMQHY30BCNV2+UHG3Q71@?$4@.!Q!XCN(JGQR6MQX@/F`DS&(QD0G&0%`18P%(*=QD(?J$/;D +M/YZ#GX[E%W#`D;EMZ-"GC@8@LVFFK[D$X)@>LBNE+2W'FAOUVI,2O'MF76=X6S4][D +ME#K,,EU[!EY&![\='&Q:CE^]S7B];DHF7N\$I[,S87TCA_['[:?^_/X0F>6] +M6[RV?"38Z5_0V%N\02$L??^&N]1<+7ZNWAJ\PHGJ7N"6!IF?V["%X5F$E_"T +MDVB;9?NV#Q9F)DE-?4H]`;!T`D88=7\,.1>CSK_+:LWHHY/*T6!?ZQK"CTZ$ +M7,*=R$+B/E-/#/E-MR`G1KITJNSC'49,W3O26+.`ZTC(!OLURMI$KIP'J8)VI09<-K1PM%Y +M9Z%KC"Q@0(Z)^VH=)IB'%28NV@*SWQ\-EF_5\9\PT:S?[^,SM4.3S#AR-)G] +M#7X.MJ[V]SM[;ZYXDBTC'),',6>1+.+W%H-+S.'PN6Q-VDDS)4WM#48(/4AT +MX]Y^D*:HW0R+F6R96QTC(\P,^ZQ:UT2'"II,\(_7U%5L;$B/;HBVXVY@#$6W +M!@8P,-28XP)4/O/_E7,1,C*%&0\]@?O$@?DO3ZZ(?%ESHB/=;E'#01P^8?:# +MP>V:3T_SB3Q@'B,<0#PH3*`!^=Z`5="Q=9[$08RKR88_T/[A]ZNIV@R5ZBT. +MQUY$%=SF9][:FJ&W.^0)^U0DRG[!;#!A%BD$YU0J9I1^%EMW(*GQ.VF_2FAE8-+_F[X6N^$ +M>U+.=P-_^0K:]M<%;\I',I'SVRB&H+/NX& +MY38=6B]^ +M^G?]C,NU^F. +MTTUH+=F9*#'G1..67TN#F;)Q8X^_J'W?WS#69C#DG%3NS=SW:-Y;94J3;!]!8,.QADJ +M.@Q5D(9:W?0'8-D.B*JL#I==_^"*/:DQ];FN,FYO&>='RYE):\)PT;EO[>0@ +MD=^Z"1%=W&_D-'4Q_I^>L1]K"N=MLD[QF^7/^&[6DHSRA[AOV8E7=@.,'#!" +MDJJMULZVQX=5-&^F^YS>^]WXY/?Q,""<&_JWTQNH5J@WF@C[FQY4?A1_` +M_4IMFN(1:D:,.GTGU$)3IO6HF8]4'Y1FMLQ%A'28([*+E!M9>(;Q'B.B9>A? +M'!W:L5U*@G5?.N\UT4-G&UJ[&B;T7]YNOTL6(_7/S$Y*K[&I<564J2^T^;TR +MG>OU=*364D10/3"S-)K7JIRZSE4EG9&AFGI%(F2O3KP.]K>G62P=^[W?KQI6 +M/"`W@!X0!!0`=%$NE%8?5,4DH`?,0(@8$,W6`?A('BO3/%R=G!G#QKE[LZ+K +M3Y1USS[F8:,K9A8-]EA;UNVV]]F(.A4[AGW&A.4#G[%_V>>":UB%T7`@=T]A +M(I:GC!@1(*H6Q+7DOL90\29`HY`A].GJ?58A<'9SJ1H_C!24(]>3L+/7@WSV +M!W8_+.^X*:>JZ981ZACHJT7JX\L2JZ(W:<6!0)^;K@TF[K3=FU%ZE.Q"^/YL +MW=01W'S*@I"CC4,K&;G_!M';W1]QPWMKG5(^\&3XY$(S?Q.]1BZ+7N(#KR!> +M+XS$_[YS3V<&*`P3D:(45+1PKJSGI^,E4N@2`P/ZY."=I5 +MR@HW-L#:^3["SRD#3.!Y.4@CO4:93H#F-K^7Y9\9^HKV?E?./"^)\Z?._`G, +M>X'UTZJI^XJ3YJBGS:J0H4144160_B(2=#YU?$YEI\)A8.5NGU/SCYWA^LJ# +M!Z,#A;R$T-[7V!O((RHW2M^GKDYU8'6IQ_'OW&>@USA6X31S>1C==W-.^'K/ +MOF:'"4_F\&(B7MMI +M-?01",'5/Y3FDI[N9)][S@)(>EB"2S.M\V^N-ZZXKJ(I.GUT`:WG&AN7S#)B +MCXGE^^%[!*'7:WN$?\LH_Q+I=.@1!0LHR#IT]^BQ,3+9NGU9$''G2;8GQO^- +MKNU3#O*1,_/TT>G\%[*#A817^$RXOL8\,D6CR\Q-;KV952D7)6GTP0N7#'+4 +MQZH$[E\N3\;+F04'R.D>C]542>YGU2';JE0]\'TMJL,DL'V"!H6IC%*HYETD +MET]G3==\MA<>;D/`1)7YGDUV2]HJ%M]V^?OPO-6E-4 +M!.U2:%Y+8$2;T/'?.Z6/FO?:^AONRI&<]J)T5I#ZP<09]5QMS**@^.,('PSE +MK8V#4W)GWH@M[&'G1F!QH00UU&N@^L="L=^(2#B(&"9J)GH;U!!U;0Q9*E%K +MWZ^E??%\0/XQ,G`2%M(6,6K*3.M**8Y2$6'N65?U33-BZ^0\*\U8Z@J*RJK& +MI3>,I+Q]2=-9;+4X.9*>G,8%+&,#&,8%3BG...-2U4(R#112Q11*82'P?^_I +M4?,E>L^E\P^P-1+AM=35*`W5/%"G9>.>GQ@R6F2.=`CZXYCZ3X!,+99G%;M&2'?XMC_<3;:^(RO6W:3H\ +MRCIZ0T?O.:243'^KO&[@*3WG?(U',;O^^W;YU,^Y%V=NU!'TYFQPV_JU!XQH +M?&MVQHS89&VV*S^M7-]N<)0?,56;0^GG2$2JF,>HE:-20HCHMY7H;5F +M"=#LL''.$[^!^;G1.B:G)M_KXTLB!J//U^O;4*-53%060*`44!8>DD)\^CXZ +M1D8SQDGQY!$)9#[WG>T?(GLT8!K-8*FZ-JH1IU\./AK]B5)@I%V\!3Y1@,Z, +MH&3_2':#WC8VT?=A:)5@(E9QC@=UX(PVLV-3^_XPJ*3P$'K/I +M[`L*0_AC%**F(Y3'=9O=@P<#P<2B\+USU.;1_XF%S"JNZF9 +M,PK/'?TIV3FV=C*']')LVF7M73R8&#A<4C1'(TK,(\ +MP8927*$.764Q@)([*%E)4$#Y@)%A-P#V>*K"(Q8$+1063M^R>5[)RU^L,&B& +M$;I4+'8RYTM,\G9+VY.5//>!?*D?2(:)K/7L\PB9,@$2H&?I4BD3TF>:KFVG +MPD&OOTH/1`0,^K6'82:#X5@;1*./%3N+T%1)[/YKJ#5MK*V)?W94]P@%Q41C +MX3E8^OK;=V6QA9&?1H+-?5NKTGLYV'8A6MJ;6I+8W1/9VVYZAO2HRDG(N,C( +M,ZI$(3QZ./`C/5]6"J'J@Q6>K9J`,@JL6U2F>K5`!0C%D_QLGK?D(>LR?0BS +MRK:I_6JO6]>)Z_N!FGR#T/>!D:%N#V.J"'HZKG2FQK.*W7>5UKNEI%==OOPA +M-4AI%-]_G\)5&=$153PP/NM3FC=J*VC,?X(.IO%WP-"[;]LSA._&=?#N=WD< +M-2VT[>31V)+@DQH1FZQ94YN85,3L9J7(YE2KV%[.J]817+ZAOCU@!:W@)FB5 +M(#"=&/09NL3=W4)#T@IGI`P9#TC_XDH].I41BJM-$D*BC``QC:HQ1;U%_8Q' +M`T9&1FS-;8F*)`[#U='5::S9IK@K&!TM#YW'^)\7C]LC[ +M5?1$Z134@8E.L=SV-J<;D4BI6^3\N,N,:^M)SLF)JN$U(MW_)_:\3T(\G/YN +M=)7PYF'\_-Q.?X4K+;K2+F5?TH2>HP4*'[5I`U,A\XXB(`XP,0#;81A^-(+CR?,;F.X!XQAQ?B +M@<-+'W,C'"0M_TUW5$H8J?/^2UQF +MKQ:#(,"B8FV")YF1X2F'PKJ2R2?#5\I\H"I9(9('K8%>D@EG^8:M5L$;BI_& +M2F3.LB.FC@,^9YUG\.[\C0;-K._$J6X;<_!JB_RN!!D5'V\IVCA4LZMZ,' +M7^%V-3,?#]I;\M5=B/W%4?:'HM\AO^&H^FY&1.PLG&RLG@=O^*X1VTI+=SJ79*BY<1Y$%:V +MI)!MHEL%"EM`+8*G.(OBB(D@G-*6PE)>DG('CYHD^CU!\:2F-26*-TX6K:=6 +MFJM'YX/&J^(ZGE2P,.JBB]1ZK=3/JRO<>Q7V4JDZ1*/J*R?8%1Q2YOJ)?._N +M8U0#TUY[0^@"\?5X]'1SW3H\W2&@HTA6TI&D55*^8$%&1V.OJ.T+9AVE5%$A +MVB"(=%*%5\2J(!T5%&)"X7HQ0Y_''P^X^M]]=YWB=EZ7_*I^&]3]KMO0\7Y8 +M1C-:-CRWBVZ-M;'^N1\I9`D)Z5VF/>K+FK)Z>GIR)/2'=143B=<\F'.SF>=@ +M[!=]Y,>F=6Z=;"C;U>J(G5"JZMJ5@5(H*=5"D58B+`:H@'W+`*!0ZR2F@ZO6 +ME)P#BXF#>*0&DN@H'CSF$OS\MU#K24)E(._\7N6I4L#Y:9\/>-[4`>/6I_WQ +M`T2+H-^Q,"9I%=2L[/++2>H)OW35%CN!+?9*5!Q5A`I'9;4G:LZ#YB>E*JB= +M4>_]B_;'Q.9WO!X`YVJ>U@=UM0=[?G=G=3F45W6I*@HTU(6)$13RJJ+`#NRP +M>3W3NIW:FK46]F?5]WO]\W-Y-J>VKAFO2A> +M*9Y`ST"9X%U0J!,])$04`+AC)N!SY-TW>UW3V?C_3YMW.^P^IC\SV7LOVCT_ +MI^^RAUX?U+DH?^18E?LYI0KPB>1"[R+:I"77J:BGI"BA*"JBUZGE-@J)YQ6Y +M6%550T'WZ_VO:_$GM>U.OV4['SNQV47X1VE#M':@IV@4&JD.U`$8BI`.G +M!JJ8':4/A?W>W+=OMGP_AOPY\VWS3.XF7RO$IN/;\^$UU67U[;Z($:Y=<$GV +M!;Z!R@F'):4H)R9.N6XS9E?J#J]7C]835WK-C=*<;=M$"V+8MVE6V0"Q`BIU4(P1'JU) +M&`+(*'59"=5I$B.!!P$2/J8.-(Y#Q,KJ-6'*VYG\)<7_S?>&KVC_5M'@M_2* +M3HR[!,1**?^.5E#)W\HX.'?X^-E8V1ZBM5[2I(K`+6G5`E05154,540HI15- +M"K(+A>7VV(,7,W?C\;%ZGMMZT0;%=A6U9 +M",3>LIB65(LH"0ED5>95$G4DC!%BH]-IA`ZD+5TZAU)TP$WD0;XIP_>+B_7: +M?[R\;88GAZ^[X&'+]*;35!*7]D'`RHEI"<@2DI"F)F)%&%OZG0XN(]'Q:U3C +M05.,./A18#QG#:H%@AQL*6ZH4DDN8),@'(JJAR`V.0<>N_/='/YVT;/Q_,]' +M['S\7V,CT_;^Z/CU_E[.)D+)O_M<`X^'BX^%CN8L8C3K2DY_/J;&PE:HHK*A +M-4.0Y/=RAA7V%AXN'W^QP=BORZ=4#*JTF5!595%.JP% +M*J,1&%2$%5$0$8<;"`BS9R03N4A9[W1GJE>7/;4=+EY>C1Q_F_4]4'3]=ZJ_ +M][?7]/`\![Z.X/L7TB1P,7#[+%P,'&]L(Z5_AB&*%4!BB9$H(YZ0Z$@VHH9) +M8@(P%"'/(LZ!MHJ;4$40)2);X:@BTQV8WQ[;WVEQCZ7_[W:S/1_!\S@7RQ2< +M+RL,X%Z#$(P^OS%#:9K)FM4J7':U2K`S0%`-\`6=^W((BA)F%8AD4,VZZI1@ +M][3;_G=N_J>;K?$[KY_Y!ON!U\"3?,K\SF_%_VWI/-6Y<@N8,]TVS:M;5-I%FV6K;:4.IA +M+2"BFUA*$4"%05S4`PS&J=/\$[AR_"[GK9>4]++!-F5$SBT@L84A-4(L@=+907(I%(!0JR +M8"U@3`=O&8T=[ZI/K.9S"R.3KY$=E19'&8+ZXOO\CZ^[Q[[[S7VIILT--!2PVTLQ3> +MTH&JKF51"P&C(4HJHL"4"P,PN9!(4(%ND6Z6AHC2H,#+VIY8N_A<>]Q!!!!7 +M=O%X/$(ZC""7@\22""`Q(8B083!D"YA;W9TO,7'CX\;;XZ;:4%6<"FQA:I:BZHEI%L@,@BJPEI(6<46YBP +M,C(2X0B02`^!4=?7.=XOB8/CVAJD69S51N5ES)R%)H$B:A54DB:R,#W24))1 +M(+`6$+XJDOOJ@JZ<7#.'L=+BCT/SLYG-+,N6<+2I"H*&D%,H2&D!I,D@R:20 +M:0TGA:2HNT:M^4,M\\0X_J4_I'+S<):UIX:#32S&P8TF-4+`H!C +M%A-PA%C&$F,4`-%H!6J;>K9()%GUMAR\00Z%5770"X! +MAQ:"5(."M#&`5)!%933(3"*0R"S`6834<)=V^03DXO/Z_N.E;I>+W?-_.^GU +MN7:V/1S%/::K;MVU5+-#0-"14$DT)"Y%`I(B*!*)F$3&,$MFNK,=RTT8F.'Y +MOZ>[Y&[J=:MG=Y]CNINU +MT2GKG)QZ5Y!P=W7P:[A"J)<-U1ET%)=(.MH"Z$1%@L4N0JJ*0)0L-?,JM=MP +MZ?-[7F^KZ&TWO+^CW)N%;B;@;A>0O4%$OH(R$4(J(2%X7LI6!0-53#FFYO37 +M#=A#>OZ.F)!2@+,\)#TSP^KZOU?PO"Y>W;'"C:EQ5UUU*6LU1C9,6E86)<$6 +M`B$+$BDC50A:62A)0"PL%LYS3O<'[$^X-\]S[WEX:;D2X=;5774%UQ<>YUAJ +M9="*%@A=^DZO>]$X>IGD7X7%%Y>)A9J2T6 +M(S`%BF#5JD+0BR3K),6$0PHJ3#&F:C'4>WL468SI(Y6H*/'^D/D=;EZ/`?`+ +MBYUEUI05+J5H2JHGBA="YK54+$AKDFXP*15LR!K)J8(ZVI4W-9X]PC<:;?&/ +M&[_-.`W$=SQMQYNYN`%122\@I%(Q"DDO)+P%O!;S+?>I?&47$.Y_/U>5SL;H +M[>QV!IN6K0<`;"..$(0V2'$#"`,4`*+)&"0F:,SF>:J3(S<%_2\?L<(CG1E61D0RD%4)D!@PE#!2$RBC$F39DA0C8):#8C +MI.UWAO5WZ?)6?JUZ;P@*(#;("$4S/#MVJ0VZM*XCG:>=S3/=ANY9N5.\B_ENY5OUXISC!3`P#!D2:V2 +M)`%!0)A+\+6E6%TOTTZ6/'Y-W:UZ]9PFO6E5KLFNU5KAK09#<*HAK)&U!"E8 +M$HULFNHZ5:Q;;P\//,0ZV?.-SA\.KR\OEZR\O"\BD4A>0%A#+?0$J(R@X30A +M?+JO;I5ZY>2O&R\RW.ZNW7X'3Z.[T<-3:T'-UTLVI%EFU1+60$%D"P`I(*$+ +M`L#$B(8W75,2TT5KZ>CQ_<]7]_M:?A[NZ;KIAI]##%,8H8R8H#`P:%9"I`%` +MF!,$:11FE%,X*6!M36N9M.I5&MK]CF[I;:(SVVQ4N`Z1!K![&+#'&JJ+%,0F +M-%0"B$60F,,$@EY2'G721I9^<&'6V-2QJ*PRIEUIEGW,SR>7=./C]KC\GXO=TV.]O;W#I-'0TT!8:0!$-2$ +MT`BR%D*%9`TAO52PHF@Z4*G";71RS[O!YWF^7X.[AQN>6O#&JF)E4J9"Y`H* +M90%DR0$"(PBQ2$R@JF654U,C(Q-_B.+KGG?9W\^["\O+]RZXM11+")<187$E +MTD52`JB)2`:U4+E)H&IJ*:QG-S1;:MN%NX.H<;EO>V%LZ9@X.H&`8(H"3!@4HA*A!9(BL@;`V) +M0PHF>RHRJ0QV9F9P9Y>GCZ'M>O[\ZAL,^'+/I!F9NQ2IL1,G9-@TRH68U4A4 +M)-B`I"DDH14-2G43"5-@6:ARK8NQQKJMFML6WN;ZGI]YACC;#E9CE%QF#-J9 +MJB9FF2H126`BBA#0%YE-4(:):4III-XX]M5EEP\/#V.+L8X#EV'/C,9?C,84 +M06&),$)BV0E226:0E`B"(8%YK-#P<[K_;];7[\ZW4N+]?0PW^#62:X10-<`U +MH0C'@J`RZU0H>"F[?PX.KE\?DN]7Q?%.<\WG!G+UEPCNTFS9G,A,Z!$%AF18"R8D! +M29I)0P4"5)FTE1S,[8!EPYT]7I[N9U^_Z_Q.,PPW^;KH+J"YD3514H%`1@7` +M`7!*"4)@ES):T(NUY=[+AXD-#5V2RZ.)9V@W9<%,N!P$DN($SJB4D9(9JP*0 +M"G)HS0',U=38\=<;QUNG%IV.8E'G'P/)R,CK]ASRZJ')LV&Q8O)30FZ(F,Q1 +M"8U1*DF*$N80H`Q8(8.+14-4/@,5I^PUGV>AUM/GO#?T"0P$A]5 +M4/A\J91BLF-KKBI)2%TD%"69(Q1990L'@'JBU8#`%D51N:D"[,/"T;FR"0[F +MNO5GWP\CKS[`I8%+%*54J2U5)4@I+2`H!9"4,DJ$$$A'T?*JJ$$O"L\^I"O6 +MK7;>?R=#0IM-3M!C;3;85'*DRDR2,'&BDR`LR#"+D@08*-@EL$HVK;;=(%MN +MH;@J4]/G=AZ1Z,6*2O"?/@@?$`@)@(+I-$2!HJL!DB@32J*9`=VJH0""2(!` +M'`Z:1U'1L[@L[EZQ8#3E758VZ"Z0)9#K;:+E"LJ9/$8(B@@"P`Q!568Y5EPY +M]2JZQUR^5U-7EULU_1@I5"\Z^\]2?IA8`#`PI`00@@"!8$S!(+`AB"B@VAFF +M1SY^/Y7K?)_'>_^/YAM\$ZFWJ<[>TW3>4-#0TFZB!HEFY@H:F +M25("@9$6-5"%$6+F8A;-AMX^"VY)Z'@Z^&')@7SR6-W/?X/>>>F9\7Y/#E>I>:]S74I2B(+KJ@J'-044 +M!)!1UU)$!$E@F.61+$PWC-6:*6:T%TK?0X0BFZXH3:\42$AL*J-L(R$8IE!8 +M9)$A)E!5#(14,K9-0!6FT:;BKZRYPXHZ':2HA66=,S)H6:)+%FB:$EE00+]$ +M199!"*!>WMD)8BHEI>RR%%Y5Q0Z[VKZY+WO-W]SJUT2Y-XK>WF88 +MBXWU6*AB19JD%4(L#$@*$%),06"E),9BA`:55:#0:,R::T8GFQ2Y5GB:L73L +M#5WG8#`JP&`/H]`H@A8AO$1AHA$`4-&18I*8!2.FB)H;NFE+R3N=7QVNR:^W +M=[SE+KQB:[]+DR\/.ZMQTL> +MM.GSL,2BE,3%'&"F.-$HBK"H$IQ2+(A>56"G:.:=3J75VSP^AT?:Z'=E^QL' +M:EY,I"]D2`982"A,I+TO&FJV*4CC,3$HA29TRI9S[N+CWSXIQG6P= +M_FFX[A>+#*7C%)>12*$.TA`O24DE-]`!1#M^9AT +M,7J3DN-SZ/;W?)YVYH[=RZXNNNJC75!8N99DHFID@P!9K2DE,DN5"'T95424V:&M +MQUE"7&Z7[R<\X6GI&KGRTM]+?>E]!EOI`J%Z4R4$&(2]IDO0!@IPLF6Z\H;Y +M5;XRX;E-:QNLZ-ZO>/:#H]K>&A:>&HXF,N1#"J"A!"&#"(04@8(181 +M@IC!Q*$Q:HJ*Y$QG52P[^X[KZ[K>%SCNLO0R[.YM&YN#MUMFGB>'EZ/O?2N-P/&`W!W*+ +M-F%@1FXC`4DW`(2@1!*,H!2F9*S)69F+11@#)8=KW_AQR, +MNEF=+$$5Q,[49!D*&5-$0,JI$*0B2"DR3)`I`LP*++CE54AR9X9=_#+I7G-N +M-=QO:7E^$P55,,`O0,"+"F,`4`PA>TX4TH85-142J+@WK]ZY>3'O\>^7&-U] +M:[V7M\+S6WR7T4!4(VJ`D"]*2$6`42^K[00#!-0$$!Y]II&@<[.<&O:Y78V] +M3;VZNAHK#3?@GP,4SP2)])M5V^)8J3;50VLEI*011B2+)#:!?GHR>I`84*OV +M8!(,`VQEX..D66N-DY"!550F04(2_QE"*`B9!0$HBE``H!*,&0!C"ADX]"@M +M`T]&K'M<;H]#O^LZ^NX5RC6MHPK&XR:FBM^6@I+$LR4PF_)+DLTPBD!#>8F] +M2'2WZ"C5;;:C:[=_>>KMV\_9V\)W.%?MLI3>G:WWB@L+P+T)A%0IB(11$")2(E("DD1&)`J!0 +MD%@I!A(I-$T(.BI4JM:M%$1`9U#.4KG74T:5Z[JS[3S@<Z_!>>-STX-\RWI+Q;FZZ%$+U2F% +M((0WRMS(BE``0DH',R@PC+54E2J$)-!),>+]%XIXHI]$GBE12>*K[MLR +M%I`6187)."/!H+I4X)VAP:L7&U2;6UXWC:YQ,O"RY8T&4RS*D6"!E$BR#"3+ +M50@I?KN.? +M-2Y.G7&4;@MC8.YMQ;SP;#0SF\Y6*Q(U<5U#(601(`1TQ@.PM5B%H04ADR"+ +MF9UL.`,]W.4[N64]/LYK=^KKI_+^1CP8Y9<\Y_0KH&>6<;59S)#("8" +M2"PC)C12E!9LS(O,,7*Q1CJR\?5XECE/-ZW;?D_3^C\CK[,"_(9@8!B<`&+3 +M6-%$E$#)`%("$AL@HI;28@+2F;.G::V!=; +M=NU".FVD*)M8,)M':P%D0AHP-K"&HI8-IQPY!/>>\V;MU]W2.QAQ=C*M6)B] +M3*Q13E,IE,D8Y3)$#(5(A#U$*9#)(4PF9FQ,L^/CW1>/>XGX?E?#Y.QMWMW( +M,2\W'"84)=J:E0*0@D"]A`9+V4E[8E%TZ=,OM:NG=TZ\&'@]7X./AY;CD,#@ +MX1R.#A-F/2 +MY5X<(TC2FDB&E(:0R1(32JIOT."Q$$@#+)`6$#,((&0F8;]3EK#(J2-K*&IJ +M1V+%N>)Z3VE$Q,;Z*AB8:K2P"ZG%C)@RD)00\1).*A*8"0XIQ1&<7,(@"/HTT$S1"*#)!5`DR$B=6*"!8$5T/AXH^$4&8)4)0R`A"RL@+ +M)$+-%BBQRLPCQ.GR#LNS36.Q[,I#LX'9ID2Y)<2X$C)#J^HJ060B'NJ]V/,H +M]WJ>).A-^W:L6:.YP[YXW"G7/6/E=QQN%V%V]5V!&:=)E,*126%*%"06$!AH +M`@@$T`04`S(-7:N0,DJJI"DE0)G:2$K.D3.HO..`Y_#54:&W3;PSV?+F9Q_! +MZ.S8XF&-54<#&S)>XHD;4LU)C).8(',M4@6D@*$,2]QMCJM2K4J50I5H&==F +M8.SR^&.*+X-T;.]`^X`XVJN`"TRSJ"2HQ8`P@4D,V`,SJJ4S +M,TAIR<+]R5Q=_IU[MC;J`SILVX+E05$L@55>#Q>12Z20"(+C$5083M@8I321 +M""R`8P,4%2'@\ZCP=%5\*2JV:U45&'>B&UOP4ALU+3;SH===4IL%FRFA(9HQ +M(,`S=B+)(U1144T^+A7; +MIG5FJU9'*JN!75`*8$K"HF`&$9&!@,!D#!BDD0,$*2I@C!,*!W-I-K:.1M<_ +MG]3ZOH=#R_G6U>9JV+%FUK3=TJVB6AHM6&Q0MH#I30T`D-%C)&$F9(`DS+5" +MT%FF[-D#-,P[F[CMZKF/5[V#Q]-NS9L%S53' +M/.IF&:JQ"9F=%(1)"D$5@I20J&21QYGF^1Z'+T<>3Q#9-K9V3"L" +M[`PF$K`P)A304A4'"HDF$84R5"3BJP1(4DH,&,.0[-%KF[,]F69LLF=BJ-5DS-@FQ8[`-C55"NJA!O/ +M2:M6Y>T\[C=&S>@&V^\\CR../.AQCK"C`CJ.JBI)2L+(5))L&$B138D3";.+ +MB,>WQX^9X3X!Y?GW\>'':K\,!;@OOHHDJ0O!581(`7@7L1KBM>8/"8S%,.'+ +MO=KWVO6.O2YN+II=S+%I>:I"\JJ"7+?02@)2L",N1O:3EN2[<[R06]>Y3\7S_P7PSWATY#/Z!S0CTX&8&ET_(/\7ZM\KBM?=><)A,,)?A!00#`5(,D,$@L( +M,.;@%P\*486PQKQ,)VN$R\JU9>I^2.=Z7I'@\SJE=;AZVUVAM-KMK;M#;`7: +MK!DAM0+,E20VH(R4A)4=M33=1-._Y&CZ'8]#R_+._\3O'_XX&?UO4._U>AJV +MQM'$P#!F,"HU1#%%EU4*`P@;$:=VT"R%F4R2@MU*HHMT^H.\9]GE\WH6MW?E +M][_=Y2]_IZ9-O;Y5)B8!@LP1F1,"82<5%@(28,IDDH!<##;97*+9"DH6SW9I +M\3N[V;G=KKR_,'9T04D9*JJ,!<.''?UCP_7__33SZ>>='P,*Q,<&L7'( +MFG-.DXNG24HNF$TQ@I!`,D50(R/0HS*9GF9U113Y7:U'G^9CKQKP&YUM9T-> +M_OX8$PDP$88#!@8(B09)@TE,`$F$5,)@?5XE7[_F=8ZIT_*[?]#T1^J]9^5^ +MY_;9.OY'(MB6QM&TLV"S!`4+(P+)$(&(K%)(DLP;"F,<:;3U+FW.F9'5S[NM +MM[>OR?&]C7(V;6Z_&:A@B8&!,,*)1*9(P`P8I`0Z4(#JE22`Z07%(;#;D[>_ +M[\@8>W]UN9_)O[M_GKH:#S[[N]54G)RZ&C$'0J)-$:J@-"'NXR,"&C)NH0K1 +M$L#5:!RTM:;W*\9Z_X3S_?_&X^D_H#_]]X.[W7;ECM[8RZK#:&-@<6D+K29( +MP$DLL&#(3%6]DER0NC8,+6JCUAS7'F:F&'"\JO7UZSNCU7E;$CTUYF`+I%H6 +MK5JE006@2,D481$!$1(5%$2`4"203/&1`FLB@03.9S.KGG<'.'J>MU^GL&@\ +MGR?-/TO>_ZSTO79,EV&[C3CP-P*2V(#J82*(!A&`(@1'41VVK+]0&()`5UUZ +M0MM\ZNMK7?]?S>\Y:^A(_\UV'88?5Z>I_<[?K;NC>->G7FCGQ=&OG#7D->)! +M8"P2&O$"Y"@)H9`0-=IH=;7US7-T];N[G/JC=W.]-WG^OKO:O=]8\\^5]`?- +M'9<^GTL#<%3E;E6J*LF15IBI54;B52"2!6((#E:HARQDUI1()B[NW +M>$4:)#5QLY8_09!4CE3&JH3Z%@@&4112:F0J0#38+IL/*20W["9(9$49J'.- +MR877489,.\W!PKL19QJG?>NF6'V;%_(77&%J\_@\!(A%AB%]%@#Q0@`O!8$) +M4$D2$68I"DD+!<6;&$N]5F6QFV^^G/WCZSH_N_YS^`KU:<<>C,C+(R0J@QWNB[S +M5AJB'FZW=L<3>V;5K`>3FV4TS% +M0U'`%Q60NQ2H)"ENHA0068HI%D0,:9IH,QE50LZDU'FAS+J]+G9CK>3N_TM5 +M?M[/MOEE]U]>I*PY''##$!5C),%(L8)"8VJ4K`]VP-2$M,2D,)CR/)R&.2][ +MTSZWY?6ZPK?3D8'2\SY.$O`P9/#]T>[PL/[WN?2\VU101T4C&5$!1)-$44,2 +ME8!K(JK&!-#(L%)$#0IGI-`:#0'&%H45ASK2VC9'L/]/@>)[!E63Y7C45P), +MB1@8'!ZG<4]41ZQ%&BD471**FN:&:[<-$N60-=@BLC"&BYNN((J"B"@(H%*( +M"I%H`B@:)UMS!Y/K_4>X^#Q_J[PZ'%,B1SXL#2[KTF^JX*8WJ=6/'-'42E1C +M2.DP)192(-)@`-(JJ('4*4B"4$G[])+(>RA"C^GR'B:J.24UR!Y2\L[GP?E9 +M>^^+6K>U>]W\'`^E_*]*]=\'!@PL#Z5\;YS!BBX`H8B0O,H,AH`%"@*`22!3 +M4`VBBL,65("ASHR`S:QV\Y!AB'>'#NR'0TFS,C(P>G/Y+UGSD"#WYY!H?0K' +MWU)/HZ-ILXF(\L^L\L30&=G!F_/]#2[R+^IDCH^>;^_ONG@7WY;/#[S=\&C7?Z^N:_3.QV#8 +M38V$UZ1-@V&(!L,&,61(0X&0668?4VH@,)PBSR5X>`^DXN+_E]-Y0]WD*XQ. +MAXD<&[C=>=DIACVSJ4:MW.UI$ILH9L34VVT,X`XS;E.'$X$VF;6X\#C&(Z3` +M.G(V2I#I)#4%:JZ;8A2,$8!TT48K%@DDY:"@C(ZU22I.6*Z30&XQH$,YFYN@ +M3-L#0R::E\'B=LWY:3`0&^>:-)^-'<>4C*"`^DK+=N59/6@RIK-P^ZX/,.'? +M.'A!X;(<)#Q8(HR!PHH,Z:$-U+,(5#B1%XH<*;G?MW^(XZ^O/F_8^#F%B7^%N6<'&GC8VAMC;6P+6U:/.& +M;7KD3DKH'2(@A'I5%I*A`Z3%1D(PZ21*Z0$B8`Q-C=:G$WO<&3?^.KFYUN/'D"7AX%]A8F#1CC7$R>D-E*24A+*1BDA0 +MTE(`)%)2%*(*)D4I@5(3C*B(J8W7$+@XTH=A]MO6\3[#VO$B("'S6/TM\L=Z +MJWY__<1V5\M8A#1<7&):3]D--^Z:F)!S#2$>:65-,ZQ_EJHTI#,"95 +MRFG?OANL^[$"/Y^Z#TT8BFZ!GW4NC&)1+I)(%PH42V20@(")<()%LHB*%-S> +M[_?K]+CZ(*]3J01(\^RYCV +M+F81;Y'4GKKG5_3DS[X7]AS7Z.PM# +M`V.CL#9E$%X[/0()V;&TB;3`NHI4W@F]O)`8*K(P"]%`ZK%`8Q`C$!`F"L<# +MJDX_KX"!*!,Z\=_O7V\LQ]I[8[7AQM1NV5.=X5,ZIG9,2N9#)]]?-_%_?.AA +M\L!FB4A,A78\D0JWU/\CIZXL(RI2&C92NS75;=I48KYE31%3(6WJ.+I\?(KV +M\;8KQQO^36PFW1EU+[=S!2Z_N+'LAK`;\BJ6;V_;CF\1#1WO"%%'BOA/#/"L +M\(3PKYJ`4RD5!^HHDEC`H8&!GOSF>V\UR?/;I;/88"BI'T@R%U[XFV<[ZOR8&A45^=I,9=[U13ED^ +MCH$16\CO2FIF,_BY-Z'=^F79U\/7UP:VJ +M-4PZJ!O'0(+22HC&,@?Y&=QD^F2E&"3R5?:2@,>.#X'T:5X`J3/QG\_K&2Z" +MP=.)MRD=6;BT?3S9^VP9B6Z/V3$@,BXG_[&)*/+2^6A0C)$DF^EO>]<@V&XP +ME=*[>=E&:Y0Y%I75I".K=NC"%%.6T*'!T,Q$Z#++QLM$-)LM"M9&(0<*")V93T6AIE/?,J!"Y`B(G6ZV\G +M?8M+$ZK?/E^=9&9"9[:-TW0H5G\+T)*2T(G+V*&7QN'!J4-#(\+I9?PX/ +MG5,O$P]G$'G^\R>Y:Q'8(]P'[YQX<)^#^!F?1=S6U7ET29M.JLL?17H):RW-RP7 +M_AN\)44@?F#EOV,/_TSZ=1I[%I8?-H9%CFZDNA,I4Z3>'XLK"MXTVG#/P)`G +M5:53;VZNUM;+03O57>QU!WULR,JI1)WT1%(R`=_O411&?(0"I<@DW(=T_-WC +M[3C&/E[W\WT.+^@;SWGL_C>9O?HGY9Y'ZJ$XJAW;56,H[&'_#)PTQ^.U=@?H +M/^0-?-Z2#Y)JM*1>]4`I(J7)G>M19'#1.>H]6)6IO@>+S,,X`E8V7@S9N,+K +MD7)Q\M;^LR_U_J[TMW +MS4B61\"8MVZFYZ-+^GFGT]FP]JDXQ@L4^B5ORJXW,JND]#0=ZOMT05L:<1_Z +M>7E;.I.-JEJ=5H^=F2A_!5L_C/97>5_BBCQO:?$SK&%=UZ=V.5I8]X/U,>9[ +M@=[E`7]N?QM[0(/3]*>F=?4P]-<^*H>F`*>V?3449!A`]-D6;PDP;E&#)]6* +M7/H5^L]R>#OZGP,G@GA#[7ZP^C[KY6J?)R0OIZXEZP=/3A6L=P[6#ASE(>3) +MW#:JJO/Q_T.I$*HIZ@Q$.JBM5WW`^/HP][\J^A4H+'4TZ?JTFDQO`7[A1.;# +MH^$Q-O/"V+>I;O5$]Y\H<'/%&CDGS_A'M+YO0#7P;6&*"W,H-1)&1.?SY\`XQ@>-:R8.- +MO#"5((70P-%W'SO5F)C^[Y$8'@Z1>-.>AO..PW"'G>OT1O7YH7HJ;0 +MZISSV0Q<#L9PD!]6^9B(/R,.YUUI(I;?Z>JY:V(9)!?1)LUEK.@9M@HA_-_E +MHP4K)2^.=S*`K9Y;3IZ+;0F.["`\GA8A@9':L-^,'BX%K-P$# +M-TNVZ8!Z8%8$%!J=)-@D`5B.D#VZ`IM"2OC4Q1$121`"WQJ@(R")P.)S$>)M +M(/452SI[UFG9WASW'OL]Q[8_A-]4U8$E/3#!S^6;J;%E[ +M#QK(.J:5VU=<1_M,3AQ`?O?#:>O@;<,]C^+0*O(Q&. +M/'B(%I(2PJJ@L"$$8060$5061D(B$8D!9(08'EI^[1C(D^J$)X2`$8@$$`,H +M@*!`$*ZZ@HOY'%H*`/V/E<)%EYFRP\&2&V\3HE^K9&S>L6C)KR)JZZ.V^J$] +M;,!Z;&R?Q@P84,RMM0L[/5\6B@WXN&]]N]UBB)VX3MT8&%F$Z>C%&PO,BOOO +MHJZ_IT,0P-PX5C([/KA%QTV$0X/:HXC2?K^K['$BK]VT@L`0\X3[1GY#=YZ,//3\N>@>ADJLW@^XK\I/<_YIJ[WV +MO\YR$8M`2:C;T9IW#YXI+A(K8_:>$ICD[BO?TRD:U%2&GC\P<<&90?KV9I.S +MXM1H*+Q)W-_).SB$,>8%"A)X43[[@I_R*83!:4>WM/)9\[^M>Y6.)OYY1Y[U +MH.R=T14/ML/V3XM\;5&QLFB(V'%;$9EV`J[#G/T9#8?)D71ZT,5!_&+C#"]; +M6>'E=@N!.-I)^!82HG?2YK\TJ6]!^I[U`O>&,^WC"%D$YSH8?!X#SX324!1_W+I6,TG1GX$M,^P1! +M+S[]WL`&1=4AF\[PH)95Y-2;9+!UDE>?5K%&H5X399N=1M?SS]?VJ[*`Z[J< +M-CZ.X\`CT,OQ%)OT<)[W88NE&3,(#?^E"@[3&-GCLLMS>A4U1UYX^NWU[.LK +M;6FC0>?'FNMG)(F[50M?/XTRYU]I49?/C'.YN5]][@LM0W\8)"ZW".RAF*@Q +M!'R;4JBBW-$&EGO\=0LS5+(AF6S.SO<=E&G'C+DZ0[]M:)9T%+G3#+ON1NI2 +MPD'O,1&X=VQ$DGP-*X0;;<-'X]27@!H%X:A.H[%WBG[:ULQ(B4L)2EF($Z,A +MS3[G\YQ,%(IDLB><#VJ(!)C!+9F4B8"=&`ROHS65RG26Q0,NPE*G-X=M$S$. +M'6UZ4&!L?F&):[T1KD:WK8\4`G:67B77+O$)F6$QU7YGO2?WO!7C[&Y[E +MGW'VQ_%\"Z>_$9ZRO+)/O8JFFR![\%8"'J$!20]^BQ$/:)*8""PVH?(ACAP' +M7`T\A`W*PQ5$/N+4T&G8*C/!F?]310_2Y548:[99]-4K6&[I8#_S3JXU5%3M +M(U:.&S^`*W$WL+S-7G*+T:#[YX?,G+BWSU7X$;+):PJM_>$:>'XK/8C+'$D`]J'O4G +M6PY*J'E&"68MBV2;MJ&8.N",STQ@?F:F:9YGU.EVL]Y871^T7RJP]?K6G!MV +M%+'^M)UFJ4>4CI0O8&67O8Q87L\)>(DI:\Z+1L>QJ&LO]6CO*FU0U6J\*#?A +M[E6C?;[):YL:=N*=0-Y@WT9^%=F+COK:RCYGX-AS +ML&H9KI*G`#DQ3O>OEM1:[M66\93RNK:120N4;ZIMWA_-A6?B1*MNA3@_Y*IY +MK#-QLB-V@;XI(/PV6I9G'NSQ\A#^?V>3C7`?#%!9#S_O_;\`R, +M1`.R3X9+J"@AZA@4R'O6*2)#Z'H'PT^3Z40'SJ\X=#%V*SPZL]J!!:$[*G`> +M16AW/%-+[(:"&P\;4Y92L>?LXJ*Z,Y(%1\)GP+`H=8HCKL64K:0"L&LQ +MF<;#2M"KUKIVD_AA1J7H)>26C`+X/.L@L=9@5BB)*XWPHZ9RY!@U82YU$,,Q +MWBWN\ZN%N%F2P$!C!D>0DR2DK^J$WJEK:H1";Z3`+;4-"@H.6"'A-^K!VG_9 +MFCPYC(4-A[!:J%UJ\H]M<0Q].]#A:O+`'E"^VY0=S'['?4YH +M;CA$SJ=7\8)'$K.ZG:+A"K;J@)/NI*C*5^(Q]V>V%#?B^>\SZ`A?JU&J,VCV +M_QMS87?=\KH*Y#6+))D$0A6/B:=BKLL;DCTY=4%->L.F;KC@\Y/UTE +ML4+:T"]DQ?!0J#F`-G. +M+=J[&%>-#O07N>OX31K="'0M!QK&:-JMJ +M@H9``=NQAZ'5'`]$[$[3WIB>RCYZ=:@^I]S/5^?3^7JI +M\\5-@H'P?BC.B,#W_42;XSP25C:X>_PCTV>%,I\`"Z3'V<1;\W?R!`<$LBU[ +MD0S-4]KMHM8G%[:9_W`PCA-G@+]>H?NSGKDDWD[D2&=Z6M4D'OHWCQ%>WXAV +M+*BKES1"]#>!WW4UHKK(^6XPB&MZ=#?/Y(U@,6Q'N?TC:"X)S],$W6N<_S7M +M#SNN;WMYJU+3^")NLFZ[E.B`+/.]I"M-3:"L9&^;D#Q"RD,M:.K10TA(0L#, +M^]84EAOGMA=8T_1N-#N[2"IVMM'!^GZ7I*K'A<&%^>__MF6E-'9N0GD`VN)P +M.]W(74:'RLZ:W'RBLX_CZN8F)F9G3%VL*%I."FX1AXLU/&]LX7H,$O;]VT>R +MA354>J<*(7S>Z5@9VFP3AF>F9QIL6KP2K+TXF6PA-W<()S)_W37^O333C3@: +M&2@=#TTZ"YM'K5@0`:D/S\5[T(41"#X/Q<0CZ]E@Q=V-M=_A\^7XS`RGN&9= +MOBZ.I=4.W`A0AUH9Y+F-MTZ2G[4HW+_'G"9_Y:JT!J#Z0W9TNF&_ROBLV?:^ +M+Q"BQZ^CO*Y>+<09(65'F!M-$6N\G!.337V(QLRIA$-A>"C09?=6-?&UG4X0 +MAD,L1(-%2?5B[,!;G`RU^:?$'5@0-0EB!6]+5<1Z^TIPGZ3.B(?P;7$&RVQK +M>4%U8,-D?`V4Z=+);$=',HWY\X1>@).V=(:!>)WH_@*/O@]R=1G3,Y(C78S* +MH(N+5U4^,85FLX./@BY^IV!`3`KV'$[X0%$1:MWDZFX2H96&[/',$(5/#+^% +M:I22A55W9OAKR$!K26&L1'1R62+?,*J;&_)N?'C>.\-I\XU\]"0BK/F1VA4) +MP2`-,'5KC2&TK\H8'C(;LDX570PSB>3$#Z1K^J.#L"Z]J8#.@W7.`M% +M!(/`/!C":0AZY.`K&",#L!DA3/(5BP_42>VNWR=_/(50,\B9TX*XP<*T#CQH +M+LBGC3QP2,;,K@&;V.NOO)T37^G6T(@W[.K>74Y=90'6M*W2SEKQ\:J+@.K$ +M&;06$``Y.*L=-B,P_$'9OB0)$"1]#,#>>:Y=@W!-4$AM\IHMN4TW9A:6%VKP>'RJP>*DVOU-@52EF&] +M';+'4QG&,]NFH/:&9CR!:$/0]<7PD',:+.]5>QM.;W-A60ER;:U5N]!CMF7Q[D==POQR!1+#BLCJO.$>O>O,^_5P<\)/BJCMKM><`[ +MNX_`V/EGZ0.#15Y(?,F_L\FVW_E6O'!3>#1[-P +M5D[-IBQ&F;(T8ZI_0N_9_Q-+9&NOCK=Y_WJ#G$=`P.;&N]CN[8*M]6C](,XY +MYH8VD<+^7_?\8?;U"P!%/ND6D%VML;.2MT`+),IDS4<-E4+F8^35'>\N)3"V +M:XDX);1<&-89YIFC1G`)`R'&AZ,ZUEE4?*1B-CVS!1`1&QRBZRNU./^AL,9C:5'#E!T=?;V.:'%DRES +M'OJ8`>N6K4FZE#1U:N/,TOU+.K9N2SV, +MM+;)T#WT.YD#`=;F$$R926# +M/U70PT51@%D+"U*W>HP\C>9%)=\`XCIS%9!R!/YA' +M4SA\]RVUD-0&.`J_PX>_MO``SY+!YAQKZ)K#B[N&!/MCS-TZK=DL;U++>F3* +M@Y=[6U:Z(>J-_F'_.WX!;Z3[X9=96F;V$JM%XCA"VPU,.06#06CZ!X-MWN96/.`WS]P)E0J`-HA- +M7D!_AX)E5"OQ@?\NC7Y/F"![\.$T=VO;354>S-"_.=S9FAPJG:,-%3Z&AZ4= +M:V%#?W:[7>(12,WZOR_4E7C3!T:?@&-5E!!_,)KH1[=*[-N!USQ#02O-Y+>I +MY"-2%54K2?^0;Y<&4L%2&!>7Q'#A]XS^)`:J/O[NCZF*LT`]MMEU>0:..IV/ +MU*(T/FTP1L]KWS5'`Y7X="#BXUG=5.&:+7'>L"FS).6)'+_40@+/WTW]%F@T +M@2/B&O^,OV',!R`?3@"5R"WCW,3?LIS24M,GCR&9G["]==T:&>Q*$A1J,FS' +M"&9^6Y#_V#1'-(MZ[RQ?J@K94FA$ +M2QI77=Z@^*/8?#$0X7P6L:!JO/MS@A!^^&;.A/RIH>-1Y1?:(UXF+NE,M?#T +M+[:;,>E'C&R@A`?,&^@Z7;SY_/>CP(YGO2RH-)]HRRM7-/V="\W9PX]T)RM) +M^WGFXX"08N2H?S1FR9("PS)PS?.Z"IZF+^[M\.'<3MT/+KSL%3EQM(,?3EF] +M!(=B[="R_MK*LD#1,<+>@=OR>G0G1:+VX?J[I%@7ZBZ'7\P +M[2QH)3F*"D$KYQRRB*W`23H@N$DR@4*E>LL$QUO]!P0(0P**ZZL]."YT'_?K +M6UDU/D\8[KWF^R(2"5&#;%:@O$:L3]MDQ\O8^8!,1[?5#1MAWHD"+OO!PX5^SG!.6 +M,0#(,YM1"V*N[643BA]L=Q;7S4]WL?"MEZ39S5'/1,B]C3A-ZLF#C/]LX>*M +MT?N+4HIO/\X:KBVNC/I%W>S+N*3PGJ9@"31/],=MNS<^FF$3HRP?$2+-X)@+ +M"2TA_M^OD40AT>GOG$;,!`]8Y)$0Z#B&$&1JR&Y]5W(T)I%F.4[)T08`6V=- +MS.'2("&MC"`OG&WO#0*>YB#2@*0`;4_[>AZN@]@ +MA^>;YD/8,GYHJ?'6J]VU(0/D_%_TW$F_0!8""21?B(`$E(L6*HC`!8",)!44 +M545&,1545&$`%06(!%('QO@W'7158HJ*J"R+`_@,GP7]%NJI2'IH:$[WT_FO +MNJF_8C@@PQS@N*CDI*!@8Q@#(?[/&,./RTO7'P6@2R^B$BUF?.(P,P+V0.`E +M]IT&W0R0ED.R&=)JW\K;GT+SNYPEC/7_[G\+P`EY4W)CVHV:U#>T@X\B)5NY +M6HV=E-J?).P['@?O;+G^'@2/=?R\I=*D`3/@B'1>O@>!*[SBU]U@)$SL30`C +M:&/VCU4*:3`*6/+.V'[K?)2`%K<+^X754U( +M=;.Z_)(Y$'+'?(M+T,:>(GVGK6>G&@VUV;VGP'@0,0^Y2>VP*@I,/E30?Z'L +M6Q\)R[/>.T^WQ)2@V2GTZU2_$B<47FU2J.;X;FC!\$N7Z_&L5/AY>Z^-_F=O +MAHY$&N3Z4PPCUD`W<1T)SE!W#@:$$_H3V@S!OFWE4>(O389=DZ,K)BY"PFGB +M169)&!(BC?SB09SY5PC(KR'BVW"JUOSZRNELQO05-VN1+!U>6BH1N0>(!FUB +MCBCC]RBYE)H"TJ2:!JGN.;6?;21TBN]D_H\-VP(??L4/=,]:P5`#^Q`N)+R> +M(=+Q6#NW%0N?N='/Z'B'=QK>."M\B;S7\@3Y$Y>./]C0P\HBA]I^B/$@FL:F7>8>!*L1`_Y^(`GDS*]1@);R'=J/I$\@ +M^"N-]@:8:;W?Y>_83GQ/"'+DLO'V[9TM@*;Y7%\"6OS50;DZ=+`0@(:X=]YH +M[;;?8X.Y"3F@[/[R_A.%LNE@2)5B[V3A:RAP]F3#GK%M.@=-U('I`7/\XO`> +MCY)FDI/8'87D\OI9T+K#XWCZR;%V#0*+&:V*R-8V_ +MBUWC,BOX0[.;+8_?@U^N1O4!?] +M(;\\&/DU3SHX][0$/X>RSK]ED+BMRZ."8'W;[KI=&:.`P+CRXIB`/VYH+ZM& +M3I*WT_4T0$+6'`20G=K*"]O32[%YX:.*2W0Z0C6)N+D-9S?]G<9X^0W,JAGN +M$R>3&Q9\%\UZ,XY!N:]>NI%*C?5#!!"HE_:4J+5`0$'V#V3!.SNO:JWX+$.D]7RE`PY84M+Z'G(1#:4=/Z*$PJ39?+J!T,W?J@HDT,+SXE$"1/\ +MHX-*;`IJ_!S8&/U6G^+U%G@-JR.H$WY*4X)[U-YH\Q;?C&R$EF^M,[:@0@*2 +M&'`AC?^ZI\OE`;*W.C:>/P^/Z%[$=3XS'DNZ7@_6P.%V+SI84&:.52EU[X;H +MX!WD;S-6L0'"+*R30&+9X^:.E0?BN8>'GO5&/7Y(Q+&`9M-UNU.C$9P,?\!H<[9([*?`7XFQ$?2?LZ=(7\ +M!P[+,]8':?6U1TG5XF@+A!X1U-FF/?-?DTO1JFPBC*K`7#($6%/8A +M*_@K)X:=2-Q$4<.]S'&$DL6?;6#6R+(>68FZ;NE+_H\M(S<>(E\LYZ=/8'1, +M_]S04FV/QPK)\QW/*'JJ=)X2F>`6[3G!67(LX'#\$FQ[$[G=2[<[YKNM-*>*\E#=)3$*BI;[, +M:5J/%VJ-/B8=(_P"CCN3LP%KN&K7_%@Y?3]55AM,?*N?R+" +MP[SXHS_('QIW8BRK%181UQY0&MP._*MR$(\1K2:X?(9LP93H0M64RA"`F`!DOJ$6Z#A.+=0A@:G0^@*F0-[Z+%D#TN;ZZ8BM +MO2V+`>:6`/E]*0A]EF7VYT8,,ID7FQWBH=9C;L^3Y=T(`M8Y(V5;USQ).SFX +M0%M5R@A3HLZ@"6U9XX$D_RBMIRW.!+7D>&(#8J&!JY+P'BE?3VD4E8S/]+Y? +M\`)\*4KDL;;GB3*,%/^_2\,^FX#36$6&K6E?F8)&'DL^:"NLG^,MIDRE@:I( +M!(Z?;[2T(:MUL4E)0%9O_((D'RDNTQK9X@X>B(>N2!SK-V.88'8N,^<#QBOI +M!N<(:GE`!,T>.V9TNCOX:*D]2;@4)!P;S1 +M-+/SF,T`&B5J];J:\=J&"(P%'=O%38F?[O8=_&/"EZFR(LEK09Y8K9DGP=_& +ML.]WJULB(.#QW!?D(26%T@%C<,:^HM@)@\_9:=3S3Q?6I(N#.]ZH!&B$Y!%3 +MZ]C.`@FF$!IS`%]T;B'-OE+.,;4">J[K1QV]K5S$GJ<9-N>#@9V^F!+.NSE- +M^MUQ"VKD((]_$-59OXCD''42L"%M=-U-0H,N^@!?"29/KE//86TH!*/C+RQ[Q:?:HS9!?N>A@P+!IFJ#157@%L;S!FB3DY+?O +MF=J`3,?,_=CG,)!PY[R`5&0IY4_06_LUIO^K@(!V +M2!N(;\E<@D$0,.K9=`@@1R!()VJ!!!'\2&WQC':;KY'R(>SS)789D*;5*W0[ +M_P8AT@$=.[NHMQ\O0:0!XR$[W+W?YE^?@4:*4-'N/1^AQ@]A^)1)],7I=M[S +M[G('0TJ#TE/CI)J.CZ%TGW7\K_RKDCXH('$3?H;?Z6EHD!AZ3GH_L.V +MJ4RF2@?X?TOHOY/ZOD_*X$)MV[-_D5?%E<00*"`$M92^:,/8<&7VRFC@@ +MLU/-IYKCOU$]==0E?>>[*`B",EWWY;>AMTL@UM^:^4!Z.S2W&4:^RE@BPI?= +M+_]1]9ZZSB.]9"\X`DF8,%GG3ZC]*+,`AK4.ZU6):Z/YXD.3.+ST?M+?-<44 +M((;6%M='K):S?%FBD.\[V:,1!7K'&VDO-MVR545@/_*5:;%;Y$.J&1`9*>QZ +M_(,GZ?Z*5SNP0D+M@@WP.-K83>]V0@=)G^A\_G'I!$26\FSU(\)%O`VT3L1@ +M'R`Q$ISR4L]V.[_M<;-QB9:<2,/@#N3SK$CQ-GJ77JHWV/3)``>U:`--&OX. +M#S-4[F;>S-HD(!=6897[+_$Q=2#@\GL'XZ0"A*>E'X%A(Y<;MSN=P:=`!DDZ +M8SU\F3NI"81\TSO=V\\ZV/@A(3KC7;/<;F*57`S@1J9/A>%\Z7QZB,P,&-^6QF$A(Y<4[=GV4J*$S<6ZNZBKX*,`L^GT;8 +MZ"L98KT1^4YN()"WR6O`M>51.^,R3F_,/F(@RP:2.FR=/_)D2YWC97@!5?/Q +MNQ83BYM-S87.\VN$M:9'``0.&5A?&C%K[,Y2WZ+$U2(`=."QI;N@%3=H]VO4 +M.RP^8MD%C%E,G[AT67L.*[DH-W#&B@AI'SZ\&%)V"2_">XW]FCX(>R4KX+JO +MY?]2[AHS4RF6&4LEO;HX!0=[X^!<[`LZD[2RFOLKGP0EI34W:YP1U-_E]&_? +MO(R,O=$THQ`#)7/,=NF';*I6]W]Y(Q"&`6;4WKH@1[+\US21L6J[R;SW+1R( +M=O[XGC_R+':MS]5.V5-X1#'5_C2J7%T=FA]BW7$$"=B(!T=$MT]G?9MP>&[@ +M+0*$O*1V#UGJ<]X+OT_#T%'(R\U09F#]3?N?,`(;]F/@;:/YA2]UFJH'1M7] +M$<`4R:^9&@5@3/BS06I#GI[XA(AD&'W+M&++I-G&$SC7^9]/910"F?W]]V!. +M2DE'->YP$<(9`>2#98/T`(^D-1/>VO>$=6(0`DX/A8^V$RM@-UGDMN#[MZU) +M(%_ZFSBN0J7AY6<9\]F/(]*D1B`>6#V!(FN*@LL9E3X`]@/C8OU):W1X`&6- +M%);EL8DTQ$^I^ZI6T8@&PY4SAGYOKV%?%(0`RQ#UB-':?K +M$6+EQ+T*YFZ*Z42%I83OWZZ01$C>.M(>00;UHM3Y-(?`7J&_MJ\J)\D=_M\I +M/'CX(9RM;P7!'ZHX6QWFE@6.F12'U>,W%5XFY-)E8?-3<.AD2A/!/67G\A"`PJNM)D +MUJ&PK6W=C/<)J2001,\=X7PBJ\_X`D(*AX#,GCQ;M*(AUEB)#\]5Q7J>YUNL +MOCR,1?#B_K1P1X\@^V$$LD/?`:AO] +M2Q*^U#$V`I$9`D,'JJ@-_Q&155;VJ>>BC(&]4`>GX0MUK8WBU&HS=O+2N*`, +MWY`.EKI<6?PK5H!2W$\+[56/G_RB8/].OP^W:]OH8LD>"X5>77@Y353MO>\* +M"#>V2J*14K]+_:?+^Q>_XF6HY`^`L-&OY/(%:0[)9&F[5MC#P`_Z"\E'ZBQ/ +M@IT9TG6D_OGZ)`7\]_<+D3!X$(_@+IP3FG-``"J9Z-.22VN@S[5\JA#(NU;$7:Y/EP. +M>=XW?8K"B])0`=P7G]`EG.82?EFKU(!.'T@S^:!<:[!&^?>;1F]BQ?>%$`R;MZP3FB +M)HPT'8O3Y-5-_\[6;UCA.7\T0BR=31@!P&=IZCA+;EL9K@>J&1P!--T +M[!D5`)M>QO'UQX"$>"`5>_^$507D[\38R@FE*G4SR00$NRO-Z"H>]1-ZJ0J7 +MGO?^C;+X>Z[Q8)M%BZ(R4QVU[3"(=;-4<4XD&Z#5H^% +M20`+=ADJ<@EBTD//@Y5@/@ER*FP/Z[=WF(R-(GR#&E@ANN8X;H=2=7HY91!> +MWSMT0BOR=X,>^'@7\7W@>AC("H66:_@X1]ZG#?TMR.KN62"`;,_=(P*-2-P] +MYQ57<@\1"*1*\%8@?!J@+?KO"*?(O3/XV.02M760^0@$)4`AT!CKM>WO#9J4 +MIHE6`>U"E)A$N;L`<=U1AT]'`+/<:Z7K(T +MV^[&``37:C#LO;JMXP(@,[-N_.)O/9&.?PWH +MGOU9;T;Y;)46EP0FP[/YN/OMM7FD8.&S^$"W>T0PM/8;>,G48)X@.!M*"JSJ +M3[Y/@O"AXFAZ5PD8/PAN20%S[/8X^]G;8OM)09W%'(F7S1LJJ>,A.)@R9P:O +MPD7LRWUC(37JY\#"]7<(!.\0?ES3X>(]0/#22#+;:A41)()K_'R9Z>P5&13M +MM(X['KTT@,G(;%TN.J[@8O>0$&^KB%AR=/Z9JF@OV:P@7KHI`(9HYPN*L$-I +M5ENTV3IZ'!:=:4SV4LB9[=:>2"]Z.6YYL,!*OT0R`N5?8>8AFND_,%`CMV`R +M(']&(J=UW?;(0W`YW>6-+L'FOK@`YRU2VL[$^>;M*DA,WYCCZ;-)!#N1>Z&_2P!@`#VJ>2M"]3;+DS[JG)1%Z=Z`&MN3`_9F@ETS;>HWH(="JK/I@)-XU4Z(3]'$3RJTB&'928F(9?+N,`C@"K(E$. +M&-YOUJI102QXJV(2IL%PVO:J6,47["0P5+%W--4`!KVW07_8*F['9S" +M("_Y;T[_WP/9S_:E!.;$OU(2+Y)NK(1#>SNT-O*:EY:0"N*:@(@E<#*P_19G +M>IAD8'[;2I)I_&U0RO%;YVF7$B-_Q;(.-\``Z,L*T1X>NK?8@+OAX!`3W'F< +M3;;CE'R<>K``%HM;$L/UU"4YI,C?9A'`=JLBT?=IWT1\1X9:"1`+2D!*Z&P3 +M,3L&?8.3Z^4UAC`"H[.,X)$);/\ZT]=_"P?T=^C-Z.S2`+Q>8?$`+G>IC?>Z +M=&/@2A"E]#4WRG4%4]P'N1062HNE/EF<]$2_(#<>`]71!#&"#U=4-I)P.GSF +M;"*14/H(J7ROZ/98AXP>=X]SR&4;QPO$P$GYS.=(B$=X*W-5PR$VEMJO8CB5>*!:+H' +M<1;CI%@3GROAL2RZ?[\TV9_?5`>GGK4;>HD0W>\` +M#9X.L4'53*6CEN77\"&?EM`+")WCF4FA!#FN/'^2[PB1/P.D[3WK\S,V",A; +MMLS2@B^E<+?"DZ:W2(C9=_]Z_:$BFR^?;'+DGH7T3/@^T2`&:IK-_"+O2J,\ +MU(I")8_O%D!.V%YX)2D28IV6TMK6-`_))`1T41#5K20\B'GKS]JR;=(Q8=): +MW'#(F6\1PCH[Y+'R?>&X\@$+F[\Z]/JFX/WB@_'"%9U2+4HW)<%[F>%PR*(3 +M!*Z;&$!2R@WV,2,9M\@_W2*"J/3'D0L/TC.FQ!UV%9%)J20[+VILG+(@L;3' +MJ4ZU&/#+\-9'DHB\D(@+T4/OO"++X5C%.&R_]HT)**=DMC2"`I(QWC +MUFFA^=,:]J1[3&B__-R=8*!";O@"6??F+AZ"\M^A*()`!=W;63[.$ +M"T*4'5]I\],)6QK$4"7UY`/EYW_:TBLUCE?XB8E`LC)Q2`>=Z[CNZ79I3(A* +MR^#N"D(7G;K7XSTCBA5@3-!NRE`+,T'1*2"'<(L/-D_-DRI`3;7U0Z;)>OD9'`J5L@%)4F+Z[H77]D(68S4>S,D06Z.LZRNG:S!S +M]9!9D428`+62>C$"5$6;RR>\')].P3D$$](H$P`+Q$#R9EM],/LF@J(<\D$. +M/5Z&N(%&=::F4A=/.[EPZ3,D0?,TDHW$5#VJ_.+9+T:K@@-AS%F]'`C^0RN6 +M.T3PP8P/*Y'L<'%D6,M?KEX1GTQ[F(9"7L'']09$3[G=+LLC3'M&O\_2D"J. +M-23_-0=UH]+PB_]$2:EHB(LCL+EZ9_L$K.P?_!%C4V@TJGK^RF'5?3&HH#W4<^([=]`GB(* +MD5I(S67Z/>1&OB,!+&4]W!]L15^9&!#?R>\^KRQ1*/45V%@$06[2:O-W1)4; +M5P@K=*ED%_UM9$F,;'O,ZY(K.AE-9\B+4;OV3YR(NU(3Z&/-6M70(BN9+N\' +ML6C@L['=3AH(!OA(W687;HO@OIEU!I<8"+%8DSU=CH3+KG7])+2RW&G9)9!$ +MQ3;ITH2B6!BN`1`O#JF@(/QQ`10C/`7':QDX8,LL'T0#(.-2M,NJR,(=0>`1/&Y[*7J[B?1AG% +M9-1B$-Z+7N*DI('6:N>R8MBAV_Z_7(O.3=5P8[)($D+5KG$;E14J\-D@R_UF +MLF&AA&/2@6)ZJ;TZ"\7E;.)/TN*8W)V^ICH>)^QR\OC]+_7M)4#V.("KGD7? +M9_&Y+>H95?]3-GMO9,YO+``2779/YN6']*5(!!*+T\?CMLH@"7+1>[/ +MD0(#@&)QD)H9/ODAR$DD)/>;%E;NN8`?8H>.\=GM&$A]>FMMU]R]\GP4Z;Z? +M&K\1"`'8'_&H29W967@\S[B@0/F@@@$"@$$$" +M[H'M:I>M='#:"WN/&D).V0(?^EY+-1M?,[Z5E14BV`0Q$FYY5JF1__B[DBG" +&A(09YF?0 +` +end diff --git a/contrib/netbsd-tests/dev/cgd/paramsfile b/contrib/netbsd-tests/dev/cgd/paramsfile new file mode 100644 index 000000000000..066eab6fc434 --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/paramsfile @@ -0,0 +1,8 @@ +algorithm aes-cbc; +iv-method encblkno1; +keylength 128; +verify_method none; +keygen pkcs5_pbkdf2/sha1 { + iterations 42; + salt AAAAgKajcCnHR7sR1k1RKQ9Q0uY=; +}; diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd.sh b/contrib/netbsd-tests/dev/cgd/t_cgd.sh new file mode 100755 index 000000000000..9cd50a5fd86d --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/t_cgd.sh @@ -0,0 +1,159 @@ +# $NetBSD: t_cgd.sh,v 1.11 2013/02/19 21:08:24 joerg Exp $ +# +# Copyright (c) 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawcgd=/dev/rcgd0${rawpart} +cgdserver=\ +"rump_server -lrumpvfs -lrumpkern_crypto -lrumpdev -lrumpdev_disk -lrumpdev_cgd" + +atf_test_case basic cleanup +basic_head() +{ + + atf_set "descr" "Tests that encrypt/decrypt works" + atf_set "require.progs" "rump_server" +} + +basic_body() +{ + + d=$(atf_get_srcdir) + atf_check -s exit:0 \ + ${cgdserver} -d key=/dev/dk,hostpath=dk.img,size=1m unix://csock + + export RUMP_SERVER=unix://csock + atf_check -s exit:0 -x "echo 12345 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + atf_check -s exit:0 -e ignore -x \ + "dd if=${d}/t_cgd count=2 | rump.dd of=${rawcgd}" + atf_check -s exit:0 -e ignore dd if=${d}/t_cgd of=testfile count=2 + atf_check -s exit:0 -e ignore -o file:testfile \ + rump.dd if=${rawcgd} count=2 +} + +basic_cleanup() +{ + + env RUMP_SERVER=unix://csock rump.halt || true +} + +atf_test_case wrongpass cleanup +wrongpass_head() +{ + + atf_set "descr" "Tests that wrong password does not give original " \ + "plaintext" + atf_set "require.progs" "rump_server" +} + +wrongpass_body() +{ + + d=$(atf_get_srcdir) + atf_check -s exit:0 \ + ${cgdserver} -d key=/dev/dk,hostpath=dk.img,size=1m unix://csock + + export RUMP_SERVER=unix://csock + atf_check -s exit:0 -x "echo 12345 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + atf_check -s exit:0 -e ignore -x \ + "dd if=${d}/t_cgd | rump.dd of=${rawcgd} count=2" + + # unconfig and reconfig cgd + atf_check -s exit:0 rump.cgdconfig -u cgd0 + atf_check -s exit:0 -x "echo 54321 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + + atf_check -s exit:0 -e ignore dd if=${d}/t_cgd of=testfile count=2 + atf_check -s exit:0 -e ignore -o not-file:testfile \ + rump.dd if=${rawcgd} count=2 +} + +wrongpass_cleanup() +{ + + env RUMP_SERVER=unix://csock rump.halt || true +} + + +atf_test_case unaligned_write cleanup +unaligned_write_head() +{ + + atf_set "descr" "Attempt unaligned writes to a raw cgd device" + atf_set "require.progs" "rump_server" +} + +unaligned_write_body() +{ + d=$(atf_get_srcdir) + atf_check -s exit:0 \ + ${cgdserver} -d key=/dev/dk,hostpath=dk.img,size=1m unix://csock + + export RUMP_SERVER=unix://csock + atf_check -s exit:0 -x "echo 12345 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + + # Check that cgd rejects writes of totally bogus lengths. + atf_check -s not-exit:0 -e ignore -x \ + "echo die hard | rump.dd of=${rawcgd} bs=123 conv=sync" + + # Check that cgd rejects non-sector-length writes even if they + # are integral multiples of the block size. + atf_check -s not-exit:0 -e ignore -x \ + "echo die hard | rump.dd of=${rawcgd} bs=64 conv=sync" + atf_check -s not-exit:0 -e ignore -x \ + "echo die hard | rump.dd of=${rawcgd} bs=256 conv=sync" + + # Check that cgd rejects misaligned buffers, produced by + # packetizing the input on bogus boundaries and using the + # bizarre behaviour of `bs=N' in dd. + atf_check -s not-exit:0 -e ignore -x \ + "(echo -n x && sleep 1 && head -c 511 + + + + cmd_data + + command + targets + event_nr + 0x0 + flags + 0x4 + version + + 0x4 + 0x1 + 0x0 + + + \ No newline at end of file diff --git a/contrib/netbsd-tests/dev/dm/dm_version_cmd.plist b/contrib/netbsd-tests/dev/dm/dm_version_cmd.plist new file mode 100644 index 000000000000..e40e53ebdd51 --- /dev/null +++ b/contrib/netbsd-tests/dev/dm/dm_version_cmd.plist @@ -0,0 +1,20 @@ + + + + + cmd_data + + command + version + event_nr + 0x0 + flags + 0x4 + version + + 0x4 + 0x0 + 0x0 + + + \ No newline at end of file diff --git a/contrib/netbsd-tests/dev/dm/h_dm.c b/contrib/netbsd-tests/dev/dm/h_dm.c new file mode 100644 index 000000000000..3380ad3fb5b2 --- /dev/null +++ b/contrib/netbsd-tests/dev/dm/h_dm.c @@ -0,0 +1,146 @@ +/* $NetBSD: h_dm.c,v 1.1 2010/10/06 11:24:55 haad Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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 + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +int dm_test_targets(void); +int dm_test_versions(void); + +/* + * Test simple dm versions command on device-mapper device. + */ +int +dm_test_versions(void) { + int fd; + int error; + prop_dictionary_t dict_in, dict_out; + struct plistref prefp; + char *xml; + + error = 0; + + error = rump_init(); + if (error != 0) + err(1, "Rump init failed"); + + fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0); + if (fd == -1) + err(1, "Open dm device failed"); + + dict_in = prop_dictionary_internalize_from_file("dm_version_cmd.plist"); + dict_out = prop_dictionary_create(); + + prop_dictionary_externalize_to_pref(dict_in, &prefp); + + error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp); + if (error < 0) + err(1, "Dm control ioctl failed"); + + dict_out = prop_dictionary_internalize(prefp.pref_plist); + + xml = prop_dictionary_externalize(dict_out); + + rump_sys_close(fd); + + return error; +} + +/* + * Test simple dm targets command on device-mapper device. + */ +int +dm_test_targets(void) { + int fd; + int error; + prop_dictionary_t dict_in, dict_out; + struct plistref prefp; + char *xml; + + error = 0; + + error = rump_init(); + if (error != 0) + err(1, "Rump init failed"); + + fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0); + if (fd == -1) + err(1, "Open dm device failed"); + + dict_in = prop_dictionary_internalize_from_file("dm_targets_cmd.plist"); + dict_out = prop_dictionary_create(); + + prop_dictionary_externalize_to_pref(dict_in, &prefp); + + error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp); + if (error < 0) + err(1, "Dm control ioctl failed"); + + dict_out = prop_dictionary_internalize(prefp.pref_plist); + + xml = prop_dictionary_externalize(dict_out); + + rump_sys_close(fd); + + return error; +} + +int +main(int argc, char **argv) { + int error; + + error = 0; + + error = dm_test_versions(); + if (error != 0) + err(1, "dm_test_versions failed"); + + error = dm_test_targets(); + if (error != 0) + err(1, "dm_test_targets failed"); + + return error; +} diff --git a/contrib/netbsd-tests/dev/dm/t_dm.sh b/contrib/netbsd-tests/dev/dm/t_dm.sh new file mode 100755 index 000000000000..02d1ee34cd15 --- /dev/null +++ b/contrib/netbsd-tests/dev/dm/t_dm.sh @@ -0,0 +1,47 @@ +# $NetBSD: t_dm.sh,v 1.2 2010/11/07 17:51:17 jmmv Exp $ +# +# Copyright (c) 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case dm_test +dm_test_head() +{ + atf_set "descr" "Check dm driver routines and create lineary, stripe mapped disks" +} + +dm_test_body() +{ + # XXX Actually we need disks than 1 for stripe check let it leave for later now. + #atf_check -s exit:0 uudecode $(atf_get_srcdir)/t_dm_disk_1.bz2.uue + #atf_check -s exit:0 bunzip2 t_dm_disk_1.bz2 + #atf_check -s exit:0 -o file:t_dm_disk_1 $(atf_get_srcdir)/h_dm + atf_check -s exit:0 $(atf_get_srcdir)/h_dm +} + +atf_init_test_cases() +{ + + atf_add_test_case dm_test +} diff --git a/contrib/netbsd-tests/dev/md/h_mdserv.c b/contrib/netbsd-tests/dev/md/h_mdserv.c new file mode 100644 index 000000000000..f5ac6a9e66ee --- /dev/null +++ b/contrib/netbsd-tests/dev/md/h_mdserv.c @@ -0,0 +1,109 @@ +/* $NetBSD: h_mdserv.c,v 1.4 2011/02/10 13:29:02 pooka Exp $ */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define MDSIZE (1024*1024) + +#define REQUIRE(a, msg) if ((a) != 0) err(1, msg); + +static void * +prober(void *arg) +{ + int fd, error; + char buf[4]; + ssize_t n; + + fd = rump_sys_open(arg, O_RDONLY); + for (;;) { + n = rump_sys_read(fd, buf, sizeof(buf)); + + switch (n) { + case 4: + error = 0; + goto out; + + case -1: + if (errno == ENXIO) { + usleep(1000); + continue; + } + + /* FALLTHROUGH */ + default: + error = EPIPE; + goto out; + } + } + out: + + error = rump_daemonize_done(error); + REQUIRE(error, "rump_daemonize_done"); + + if (error) + exit(1); + + return NULL; +} + +int +main(int argc, char *argv[]) +{ + pthread_t pt; + struct md_conf md; + int fd, error; + + if (argc != 2) + exit(1); + + md.md_addr = calloc(1, MDSIZE); + md.md_size = MDSIZE; + md.md_type = MD_UMEM_SERVER; + + error = rump_daemonize_begin(); + REQUIRE(error, "rump_daemonize_begin"); + + error = rump_init(); + REQUIRE(error, "rump_init"); + + error = rump_init_server("unix://commsock"); + REQUIRE(error, "init server"); + + if ((fd = rump_sys_open(argv[1], O_RDWR)) == -1) + err(1, "open"); + + /* + * Now, configuring the md driver also causes our process + * to start acting as the worker for the md. Splitting it + * into two steps in the driver is not easy, since md is + * supposed to be unconfigured when the process dies + * (process may exit between calling ioctl1 and ioctl2). + * So, start a probe thread which attempts to read the md + * and declares the md as configured when the read is + * succesful. + */ + error = pthread_create(&pt, NULL, prober, argv[1]); + REQUIRE(error, "pthread_create"); + pthread_detach(pt); + + if (rump_sys_ioctl(fd, MD_SETCONF, &md) == -1) { + rump_daemonize_done(errno); + exit(1); + } + + return 0; +} diff --git a/contrib/netbsd-tests/dev/md/t_md.sh b/contrib/netbsd-tests/dev/md/t_md.sh new file mode 100755 index 000000000000..85de73e80b23 --- /dev/null +++ b/contrib/netbsd-tests/dev/md/t_md.sh @@ -0,0 +1,65 @@ +# $NetBSD: t_md.sh,v 1.7 2011/05/14 17:42:28 jmmv Exp $ +# +# Copyright (c) 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawmd=/dev/rmd0${rawpart} + +atf_test_case basic cleanup +basic_head() +{ + + atf_set "descr" "Check that md can be created, read and written" +} + +basic_body() +{ + + # Scope out raw part. This is actually the *host* raw partition, + # but just let it slide for now, since they *should* be the same. + rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` + + atf_check -s exit:0 $(atf_get_srcdir)/h_mdserv ${rawmd} + + export RUMP_SERVER=unix://commsock + atf_check -s exit:0 -e ignore -x \ + "dd if=/bin/ls count=10 | rump.dd of=${rawmd} seek=100" + atf_check -s exit:0 -e ignore -x \ + "rump.dd if=${rawmd} skip=100 count=10 | dd of=testfile" + atf_check -s exit:0 -e ignore -o file:testfile dd if=/bin/ls count=10 +} + +basic_cleanup() +{ + + env RUMP_SERVER=unix://commsock rump.halt +} + +atf_init_test_cases() +{ + + atf_add_test_case basic +} diff --git a/contrib/netbsd-tests/dev/raidframe/t_raid.sh b/contrib/netbsd-tests/dev/raidframe/t_raid.sh new file mode 100755 index 000000000000..ae21eedf5e34 --- /dev/null +++ b/contrib/netbsd-tests/dev/raidframe/t_raid.sh @@ -0,0 +1,323 @@ +#! /usr/bin/atf-sh +# $NetBSD: t_raid.sh,v 1.12 2013/02/19 21:08:24 joerg Exp $ +# +# Copyright (c) 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawraid=/dev/rraid0${rawpart} +raidserver="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe" + +makecfg() +{ + level=${1} + ncol=${2} + + printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf + diskn=0 + while [ ${ncol} -gt ${diskn} ] ; do + echo "/disk${diskn}" >> raid.conf + diskn=$((diskn+1)) + done + + printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \ + >> raid.conf +} + +atf_test_case smalldisk cleanup +smalldisk_head() +{ + atf_set "descr" "Checks the raidframe works on small disks " \ + "(PR kern/44239)" + atf_set "require.progs" "rump_server" +} + +smalldisk_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=1m \ + -d key=/disk1,hostpath=disk1.img,size=1m \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 +} + +smalldisk_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + + +# make this smaller once 44239 is fixed +export RAID_MEDIASIZE=32m + +atf_test_case raid1_compfail cleanup +raid1_compfail_head() +{ + atf_set "descr" "Checks that RAID1 works after component failure" + atf_set "require.progs" "rump_server" +} + +raid1_compfail_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server with failed component + rump.halt + rm disk1.img # FAIL + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 +} + +raid1_compfail_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + + + +atf_test_case raid1_comp0fail cleanup +raid1_comp0fail_head() +{ + atf_set "descr" "Checks configuring RAID1 after component 0 fails" \ + "(PR kern/44251)" + atf_set "require.progs" "rump_server" +} + +raid1_comp0fail_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # restart server with failed component + rump.halt + rm disk0.img # FAIL + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 +} + +raid1_comp0fail_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + +atf_test_case raid1_normal cleanup +raid1_normal_head() +{ + atf_set "descr" "Checks that RAID1 -c configurations work " \ + "in the normal case" + atf_set "require.progs" "rump_server" +} + +raid1_normal_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server, disks remain normal + rump.halt + + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 + +} + +raid1_normal_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + + +atf_test_case raid5_compfail cleanup +raid5_compfail_head() +{ + atf_set "descr" "Checks that RAID5 works after component failure" + atf_set "require.progs" "rump_server" +} + +raid5_compfail_body() +{ + makecfg 5 3 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server with failed component + rump.halt + rm disk2.img # FAIL + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 +} + +raid5_compfail_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + +atf_test_case raid5_normal cleanup +raid5_normal_head() +{ + atf_set "descr" "Checks that RAID5 works after normal shutdown " \ + "and 'raidctl -c' startup" + atf_set "require.progs" "rump_server" +} + +raid5_normal_body() +{ + makecfg 5 3 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server after normal shutdown + rump.halt + + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 +} + +raid5_normal_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + +atf_init_test_cases() +{ + atf_add_test_case smalldisk + atf_add_test_case raid1_normal + atf_add_test_case raid1_comp0fail + atf_add_test_case raid1_compfail + atf_add_test_case raid5_normal + atf_add_test_case raid5_compfail +} diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/SCSITEST.ioconf b/contrib/netbsd-tests/dev/scsipi/libscsitest/SCSITEST.ioconf new file mode 100644 index 000000000000..afee6c80bd58 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/SCSITEST.ioconf @@ -0,0 +1,12 @@ +# $NetBSD: SCSITEST.ioconf,v 1.1 2014/04/24 21:46:44 pooka Exp $ +# + +ioconf scsitest + +include "conf/files" +include "dev/scsipi/files.scsipi" +include "rump/dev/files.rump" + +pseudo-root mainbus* + +scsitest0 at mainbus? diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.c b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.c new file mode 100644 index 000000000000..8f214f783d8c --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.c @@ -0,0 +1,259 @@ +/* $NetBSD: scsitest.c,v 1.2 2014/04/25 00:24:39 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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. + */ + +/* + * A SCSI target which is useful for debugging our scsipi driver stack. + * Currently it pretends to be a single CD. + * + * Freely add the necessary features for your tests. Just remember to + * run the atf test suite to make sure you didn't cause regressions to + * other tests. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: scsitest.c,v 1.2 2014/04/25 00:24:39 pooka Exp $"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "scsitest.h" + +int scsitest_match(device_t, cfdata_t, void *); +void scsitest_attach(device_t, device_t, void *); + +struct scsitest { + struct scsipi_channel sc_channel; + struct scsipi_adapter sc_adapter; +}; + +CFATTACH_DECL_NEW(scsitest, sizeof(struct scsitest), scsitest_match, + scsitest_attach, NULL, NULL); + +/* + * tosi.iso can be used to deliver CD requests to a host file with the + * name in USE_TOSI_ISO (yes, it's extrasimplistic). + */ +//#define USE_TOSI_ISO + +#define CDBLOCKSIZE 2048 +static uint32_t mycdsize = 2048; +static int isofd; + +#define MYCDISO "tosi.iso" + +unsigned rump_scsitest_err[RUMP_SCSITEST_MAXERROR]; + +static void +sense_notready(struct scsipi_xfer *xs) +{ + struct scsi_sense_data *sense = &xs->sense.scsi_sense; + + xs->error = XS_SENSE; + + sense->response_code = 0x70; + sense->flags = SKEY_NOT_READY; + sense->asc = 0x3A; + sense->ascq = 0x00; + sense->extra_len = 6; +} + +/* + * This is pretty much a CD target for now + */ +static void +scsitest_request(struct scsipi_channel *chan, + scsipi_adapter_req_t req, void *arg) +{ + struct scsipi_xfer *xs = arg; + struct scsipi_generic *cmd = xs->cmd; +#ifdef USE_TOSI_ISO + int error; +#endif + + if (req != ADAPTER_REQ_RUN_XFER) + return; + + //show_scsipi_xs(xs); + + switch (cmd->opcode) { + case SCSI_TEST_UNIT_READY: + if (isofd == -1) + sense_notready(xs); + + break; + case INQUIRY: { + struct scsipi_inquiry_data *inqbuf = (void *)xs->data; + + memset(inqbuf, 0, sizeof(*inqbuf)); + inqbuf->device = T_CDROM; + inqbuf->dev_qual2 = SID_REMOVABLE; + strcpy(inqbuf->vendor, "RUMPHOBO"); + strcpy(inqbuf->product, "It's a LIE"); + strcpy(inqbuf->revision, "0.00"); + break; + } + case READ_CD_CAPACITY: { + struct scsipi_read_cd_cap_data *ret = (void *)xs->data; + + _lto4b(CDBLOCKSIZE, ret->length); + _lto4b(mycdsize, ret->addr); + + break; + } + case READ_DISCINFO: { + struct scsipi_read_discinfo_data *ret = (void *)xs->data; + + memset(ret, 0, sizeof(*ret)); + break; + } + case READ_TRACKINFO: { + struct scsipi_read_trackinfo_data *ret = (void *)xs->data; + + _lto4b(mycdsize, ret->track_size); + break; + } + case READ_TOC: { + struct scsipi_toc_header *ret = (void *)xs->data; + + memset(ret, 0, sizeof(*ret)); + break; + } + case START_STOP: { + struct scsipi_start_stop *param = (void *)cmd; + + if (param->how & SSS_LOEJ) { +#ifdef USE_TOSI_ISO + rumpuser_close(isofd, &error); +#endif + isofd = -1; + } + break; + } + case SCSI_SYNCHRONIZE_CACHE_10: { + if (isofd == -1) { + if ((xs->xs_control & XS_CTL_SILENT) == 0) + atomic_inc_uint(&rump_scsitest_err + [RUMP_SCSITEST_NOISYSYNC]); + + sense_notready(xs); + } + + break; + } + case GET_CONFIGURATION: { + memset(xs->data, 0, sizeof(struct scsipi_get_conf_data)); + break; + } + case SCSI_READ_6_COMMAND: { +#ifdef USE_TOSI_ISO + struct scsi_rw_6 *param = (void *)cmd; + + printf("reading %d bytes from %d\n", + param->length * CDBLOCKSIZE, + _3btol(param->addr) * CDBLOCKSIZE); + rumpuser_pread(isofd, xs->data, + param->length * CDBLOCKSIZE, + _3btol(param->addr) * CDBLOCKSIZE, + &error); +#endif + + break; + } + case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL: + /* hardcoded for now */ + break; + default: + printf("unhandled opcode 0x%x\n", cmd->opcode); + break; + } + + scsipi_done(xs); +} + +int +scsitest_match(device_t parent, cfdata_t match, void *aux) +{ +#ifdef USE_TOSI_ISO + uint64_t fsize; + int error, ft; + + if (rumpuser_getfileinfo(MYCDISO, &fsize, &ft, &error)) + return 0; + if (ft != RUMPUSER_FT_REG) + return 0; + mycdsize = fsize / CDBLOCKSIZE; + + if ((isofd = rumpuser_open(MYCDISO, RUMPUSER_OPEN_RDWR, &error)) == -1) + return 0; +#else + /* + * We pretend to have a medium present initially, so != -1. + */ + isofd = -2; +#endif + + return 1; +} + +void +scsitest_attach(device_t parent, device_t self, void *aux) +{ + struct scsitest *sc = device_private(self); + + aprint_naive("\n"); + aprint_normal("\n"); + + memset(&sc->sc_adapter, 0, sizeof(sc->sc_adapter)); + sc->sc_adapter.adapt_nchannels = 1; + sc->sc_adapter.adapt_request = scsitest_request; + sc->sc_adapter.adapt_minphys = minphys; + sc->sc_adapter.adapt_dev = self; + sc->sc_adapter.adapt_max_periph = 1; + sc->sc_adapter.adapt_openings = 1; + + memset(&sc->sc_channel, 0, sizeof(sc->sc_channel)); + sc->sc_channel.chan_bustype = &scsi_bustype; + sc->sc_channel.chan_ntargets = 2; + sc->sc_channel.chan_nluns = 1; + sc->sc_channel.chan_id = 0; + sc->sc_channel.chan_flags = SCSIPI_CHAN_NOSETTLE; + sc->sc_channel.chan_adapter = &sc->sc_adapter; + + config_found_ia(self, "scsi", &sc->sc_channel, scsiprint); +} diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.h b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.h new file mode 100644 index 000000000000..ba9b84a3f598 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.h @@ -0,0 +1,38 @@ +/* $NetBSD: scsitest.h,v 1.1 2014/04/25 00:24:39 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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. + */ + +#ifndef _RUMP_SCSITEST_H_ +#define _RUMP_SCSITEST_H_ + +enum { + RUMP_SCSITEST_NOISYSYNC, + RUMP_SCSITEST_MAXERROR +}; + +extern unsigned rump_scsitest_err[RUMP_SCSITEST_MAXERROR]; + +#endif /* _RUMP_SCSITEST_H_ */ diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest_component.c b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest_component.c new file mode 100644 index 000000000000..db0e209ad322 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest_component.c @@ -0,0 +1,46 @@ +/* $NetBSD: scsitest_component.c,v 1.1 2014/04/24 21:46:44 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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 +__KERNEL_RCSID(0, "$NetBSD: scsitest_component.c,v 1.1 2014/04/24 21:46:44 pooka Exp $"); + +#include +#include +#include +#include +#include + +#include "ioconf.c" + +#include "rump_private.h" + +RUMP_COMPONENT(RUMP_COMPONENT_DEV) +{ + + config_init_component(cfdriver_ioconf_scsitest, + cfattach_ioconf_scsitest, cfdata_ioconf_scsitest); +} diff --git a/contrib/netbsd-tests/dev/scsipi/t_cd.c b/contrib/netbsd-tests/dev/scsipi/t_cd.c new file mode 100644 index 000000000000..58e61a564ea0 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/t_cd.c @@ -0,0 +1,81 @@ +/* $NetBSD: t_cd.c,v 1.7 2014/04/25 00:24:39 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "scsitest.h" + +#include "../../h_macros.h" + +ATF_TC(noisyeject); +ATF_TC_HEAD(noisyeject, tc) +{ + + atf_tc_set_md_var(tc, "descr", "test for CD eject noisyness " + "(PR kern/43785)"); +} + +ATF_TC_BODY(noisyeject, tc) +{ + static char fname[] = "/dev/rcd0_"; + int part, fd, arg = 0; + + RL(part = getrawpartition()); + fname[strlen(fname)-1] = 'a' + part; + rump_init(); + /* + * Rump CD emulation has been fixed, so no longer a problem. + * + atf_tc_expect_signal(SIGSEGV, "PR kern/47646: Broken test or " + "a real problem in rump or the driver"); + */ + RL(fd = rump_sys_open(fname, O_RDWR)); + RL(rump_sys_ioctl(fd, DIOCEJECT, &arg)); + + ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0); + RL(rump_sys_close(fd)); + // atf_tc_expect_fail("PR kern/43785"); + ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, noisyeject); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh new file mode 100755 index 000000000000..5b54431fad85 --- /dev/null +++ b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh @@ -0,0 +1,398 @@ +# $NetBSD: t_swsensor.sh,v 1.7 2013/04/14 16:07:46 martin Exp $ + +get_sensor_info() { + rump.envstat -x | \ + sed -e "\;swsensor;,\;/array;p" -e "d" +} + +get_sensor_key() { + get_sensor_info | grep -A1 $1 | grep integer | sed -e 's;<[/a-z]*>;;g' +} + +get_powerd_event_count() { + grep "not running" powerd.log | wc -l +} + +get_rnd_bits_count() { + env RUMPHIJACK=blanket=/dev/random:/dev/urandom \ + RUMP_SERVER=unix://t_swsensor_socket \ + LD_PRELOAD=/usr/lib/librumphijack.so rndctl -l | \ + grep "swsensor-sensor" | \ + awk '{print $2}' +} + +check_powerd_event() { + event=$(grep "not running" powerd.log | \ + sed -e "$1p" -e "d" ) + event=${event##*//} + script=${event%% *} + event=${event#* } + device=${event%% *} + event=${event#* } + state=${event%% *} + sensor=${event#* } + sensor=${sensor% *} + + if [ "${script}" != "sensor_indicator" ] ; then + echo "Event uses wrong script: ${script}" + elif [ "${device}" != "swsensor" ] ; then + echo "Event uses wrong device: ${device}" + elif [ "${sensor}" != "sensor" ] ; then + echo "Event uses wrong sensor: ${sensor}" + elif [ "${state}" != "$2" ] ; then + echo "Event uses wrong state: ${state}" + fi +} + +# Start the rump server, then load the swsensor module with the +# requested properties + +start_rump() { + rump_allserver -l rumpvfs -l rumpdev -l rumpdev_sysmon ${RUMP_SERVER} + if [ $( get_sensor_info | wc -l ) -ne 0 ] ; then + rump.modunload swsensor + rump.modload -f $1 swsensor + else + rump.modload $1 swsensor + fi + return $? +} + +common_head() { + atf_set descr "$1" + atf_set timeout 60 + atf_set require.progs rump.powerd rump.envstat rump.modload \ + rump.halt rump.sysctl rump_server \ + sed grep awk \ + rndctl expr +} + +common_cleanup() { + rump.modunload swsensor + rump.halt +} + +create_envsys_conf_files() { + cat << ENV0 > env0.conf + swsensor { + refresh-timeout = 2s; + } +ENV0 + cat << ENV1 > env1.conf + swsensor { + sensor0 { critical-min = $(( $1 - $2 )); } + } +ENV1 + cat << ENV2 > env2.conf + swsensor { + sensor0 { critical-min = $1; } + } +ENV2 +} + +# Test body common to all sensors +# $1 sensor mode +# $2 initial sensor value +# $3 initial limit +# $4 amount to lower limit +# $5 difference from limit to trigger event +# $6 sensor flags, for FHAS_ENTROPY and FMONNOTSUPP + +common_body() { + # Start the rump-server process and load the module + modload_args="-i mode=$1 -i value=$2 -i limit=$3 ${6:+-i flags=$6}" + start_rump "$modload_args" + + # create configuration files for updates + create_envsys_conf_files $3 $4 + + if [ $? -ne 0 ] ; then + atf_skip "Cannot set-up rump environment" + fi + + # start powerd so we can detect sensor events + rump.powerd -n -d > powerd.log 2>&1 & + if [ -z "$(jobs)" ] ; then + skip_events=1 + echo "Skipping event sub-tests - powerd did not start" + else + skip_events=0 + expected_event=1 + fi + + # Step 0 - verify that sensor is registered + get_sensor_info | grep -q swsensor || + atf_fail "0: Device swsensor not registered" + + # Step 1 - update the refresh-timeout and verify + # (use $(( ... )) since the timeout is displayed in hex!) + rump.envstat -c env0.conf + if [ $(( $( get_sensor_key refresh-timeout ) )) -ne 2 ] ; then + atf_fail "1: Could not set refresh-timout to 2s" + fi + + # Step 2 - verify that we can read sensor's value + if [ $1 -ne 0 -a $( get_sensor_key cur-value ) -ne $2 ] ; then + atf_fail "2: Value not available" + fi + + # Step 3 - verify that changes in sensor value are seen + rump.sysctl -w hw.swsensor.cur_value=$(( $2 + 1 )) + if [ $( get_sensor_key cur-value ) -ne $(( $2 + 1 )) ] ; then + atf_fail "3: Value not updated" + fi + + # Step 4 - if sensor provides hw limit, make sure we can read it + if [ $1 -ne 0 ] ; then + if [ $( get_sensor_key critical-min ) -ne $3 ] ; then + atf_fail "4: Limit not set by device" + fi + fi + + # Step 5 - if sensor provides hw limit, make sure it works + if [ $1 -ne 0 -a ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "5: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "5: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "critical-under") + if [ -n "${evt}" ] ; then + atf_fail "5: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 6 - verify that we return to normal state + if [ $1 -ne 0 -a ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 + $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "6: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "6: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "normal") + if [ -n "${evt}" ] ; then + atf_fail "6: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 7 - verify that we can set our own limit + + # Steps 7 thru 12 are skipped if the sensor cannot be monitored + if [ $( expr \( 0$6 / 2048 \) % 2 ) -ne 1 ] ; then + rump.envstat -c env1.conf + if [ $( get_sensor_key critical-min ) -ne $(( $3 - $4 )) ] ; then + atf_fail "7: Limit not set by envstat -c" + fi + + # Step 8 - make sure user-set limit works + if [ ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $4 - $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "8: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "8: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "critical-under") + if [ -n "${evt}" ] ; then + atf_fail "8: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 9 - verify that we return to normal state + if [ ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $4 + $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "9: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "9: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "normal") + if [ -n "${evt}" ] ; then + atf_fail "9: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 10 - reset to defaults + rump.envstat -S + if [ $1 -eq 0 ] ; then + get_sensor_info | grep -q critical-min && + atf_fail "10: Failed to clear a limit with envstat -S" + else + if [ $( get_sensor_key critical-min ) -ne $3 ] ; then + atf_fail "10: Limit not reset to initial value" + fi + fi + + # Step 11 - see if more events occur + if [ ${skip_events} -eq 0 ] ; then + rump.envstat -c env0.conf + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $4 - $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -ge ${expected_event} ] ; then + if [ $1 -ne 2 ] ; then + atf_fail "11b Event triggered after reset" + fi + evt=$( check_powerd_event ${cnt} "critical-under") + if [ -n "${evt}" ] ; then + atf_fail "11a: ${evt}" + fi + fi + fi + + # Step 12 - make sure we can set new limits once more + rump.envstat -c env2.conf + if [ $( get_sensor_key critical-min ) -ne $3 ] ; then + atf_fail "12a: Limit not reset to same value" + fi + rump.envstat -c env1.conf + if [ $( get_sensor_key critical-min ) -ne $(( $3 - $4 )) ] ; then + atf_fail "12b: Limit not reset to new value" + fi + fi + + # Step 13 - confirm registration (or lack thereof) with rndctl + rnd_bits=$( get_rnd_bits_count ) + if [ $( expr \( 0$6 / 8192 \) % 2 ) -eq 1 ] ; then + if [ -z "$rnd_bits" ] ; then + atf_fail "13a: Not registered with rndctl" + fi + else + if [ -n "$rnd_bits" ] ; then + atf_fail "13b: Wrongly registered with rndctl" + fi + fi + + # Steps 14 and 15 are only if sensor is providing entropy + if [ $( expr \( 0$6 / 8192 \) % 2 ) -ne 1 ] ; then + return + fi + + # Step 14 - make sure entropy collected when device is being polled + rump.envstat -c env0.conf + rump.sysctl -w hw.swsensor.cur_value=$3 + sleep 5 + rump.sysctl -w hw.swsensor.cur_value=$(( $3 + $4 )) + sleep 5 + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -le $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "14a: entropy bits did not increase after polling" + fi + rnd_bits=$new_rnd_bits + sleep 5 + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -gt $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "14b: entropy bits increased after poll with no value change" + fi + + # Step 15 - make sure entropy collected when device is interrogated + # + rump.envstat -c env0.conf + rump.sysctl -w hw.swsensor.cur_value=$3 + get_sensor_key cur-value + rnd_bits=$( get_rnd_bits_count ) + rump.sysctl -w hw.swsensor.cur_value=$(( $3 + $4 )) + get_sensor_key cur-value + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -le $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "15a: entropy bits did not increase after interrogation" + fi + rnd_bits=$new_rnd_bits + get_sensor_key cur-value + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -gt $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "15b: entropy bits increased after interrogation with no value change" + fi +} + +atf_test_case simple_sensor cleanup +simple_sensor_head() { + common_head "Test a simple sensor" +} + +simple_sensor_body() { + common_body 0 50 30 10 1 +} + +simple_sensor_cleanup() { + common_cleanup +} + +atf_test_case limit_sensor cleanup +limit_sensor_head() { + common_head "Test a sensor with internal limit" +} + +limit_sensor_body() { + common_body 1 45 25 8 2 +} + +limit_sensor_cleanup() { + common_cleanup +} + +atf_test_case alarm_sensor cleanup +alarm_sensor_head() { + common_head "Test a sensor with internal checking" +} + +alarm_sensor_body() { + common_body 2 40 20 6 3 +} + +alarm_sensor_cleanup() { + common_cleanup +} + +atf_test_case entropy_polled_sensor cleanup +entropy_polled_sensor_head() { + common_head "Test a simple sensor that provides entropy" +} + +entropy_polled_sensor_body() { + common_body 0 50 30 10 1 8192 +} + +entropy_polled_sensor_cleanup() { + common_cleanup +} + +atf_test_case entropy_interrupt_sensor cleanup +entropy_interrupt_sensor_head() { + common_head "Test a sensor that provides entropy without polling" +} + +entropy_interrupt_sensor_body() { + common_body 0 50 30 10 1 10240 +} + +entropy_interrupt_sensor_cleanup() { + common_cleanup +} + +atf_init_test_cases() { + RUMP_SERVER="unix://t_swsensor_socket" ; export RUMP_SERVER + atf_add_test_case simple_sensor + atf_add_test_case limit_sensor + atf_add_test_case alarm_sensor + atf_add_test_case entropy_polled_sensor + atf_add_test_case entropy_interrupt_sensor +} diff --git a/contrib/netbsd-tests/dev/sysmon/t_swwdog.c b/contrib/netbsd-tests/dev/sysmon/t_swwdog.c new file mode 100644 index 000000000000..19e3795f0b59 --- /dev/null +++ b/contrib/netbsd-tests/dev/sysmon/t_swwdog.c @@ -0,0 +1,192 @@ +/* $NetBSD: t_swwdog.c,v 1.5 2011/06/26 12:14:59 christos Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "../../h_macros.h" + +static volatile sig_atomic_t tcount; + +static void +sigcount(int sig) +{ + + assert(sig == SIGUSR1); + tcount++; +} + +/* + * Since we are testing for swwdog's ability to reboot/panic, we need + * to fork and monitor the exit status from the parent and report + * something sensible back to atf. + */ +static int +testbody(int max) +{ + char wname[WDOG_NAMESIZE]; + struct wdog_conf wc; + struct wdog_mode wm; + pid_t p1, p2; + int status; + int fd; + + signal(SIGUSR1, sigcount); + + switch ((p1 = fork())) { + case 0: + break; + case -1: + atf_tc_fail_errno("fork"); + break; + default: + p2 = wait(&status); + ATF_REQUIRE_EQ(p1, p2); + ATF_REQUIRE_EQ(tcount, max); + return status; + } + + rump_init(); + + fd = rump_sys_open("/dev/watchdog", O_RDWR); + if (fd == -1) + err(1, "open watchdog"); + + wc.wc_count = 1; + wc.wc_names = wname; + + if (rump_sys_ioctl(fd, WDOGIOC_GWDOGS, &wc) == -1) + err(1, "can't fetch watchdog names"); + + if (wc.wc_count) { + assert(wc.wc_count == 1); + + strlcpy(wm.wm_name, wc.wc_names, sizeof(wm.wm_name)); + wm.wm_mode = WDOG_MODE_ETICKLE; + wm.wm_period = 1; + if (rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm) == -1) + atf_tc_fail_errno("failed to set tickle"); + + usleep(400000); + if (max == 1) + rump_sys_ioctl(fd, WDOGIOC_TICKLE); + else { + wm.wm_mode = WDOG_MODE_DISARMED; + rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm); + } + kill(getppid(), SIGUSR1); + + sleep(2); + printf("staying alive\n"); + kill(getppid(), SIGUSR1); + _exit(2); + } + /* fail */ + _exit(1); +} + +ATF_TC(reboot); +ATF_TC_HEAD(reboot, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check swwdog reboot capability"); +} + +ATF_TC_BODY(reboot, tc) +{ + extern bool rumpns_swwdog_reboot; + int status; + + /* XXX: should use sysctl */ + rumpns_swwdog_reboot = true; + status = testbody(1); + + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE_EQ(WEXITSTATUS(status), 0); +} + +ATF_TC(panic); +ATF_TC_HEAD(panic, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check swwdog panic capability"); +} + +ATF_TC_BODY(panic, tc) +{ + extern bool rumpns_swwdog_reboot; + int status; + + /* XXX: should use sysctl */ + rumpns_swwdog_reboot = false; + status = testbody(1); + + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE_EQ(WTERMSIG(status), SIGABRT); +} + +ATF_TC(disarm); +ATF_TC_HEAD(disarm, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check swwdog disarm capability"); +} + +ATF_TC_BODY(disarm, tc) +{ + int status; + + status = testbody(2); + + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE_EQ(WEXITSTATUS(status), 2); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, panic); + ATF_TP_ADD_TC(tp, reboot); + ATF_TP_ADD_TC(tp, disarm); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/cd9660/pr_48787.image.bz2.uue b/contrib/netbsd-tests/fs/cd9660/pr_48787.image.bz2.uue new file mode 100644 index 000000000000..d8f7488f36d2 --- /dev/null +++ b/contrib/netbsd-tests/fs/cd9660/pr_48787.image.bz2.uue @@ -0,0 +1,103 @@ +begin 644 pr_48787.image.bz2 +M0EIH.3%!62936>D^3`0``+M_V?_7U17T!W_H/^_?8..V$"1DB`0``B$`0I-H +MP`+N-!HLI8)131H4](]3TC(VH`S4;4````T&@R&C0R:!*$1D(8B:C!,(Q-&3 +M-`!,``"&:`FC'&AH&C3(TT:9`8F"``&@-`:9`8$R`J1(A&A$R&391FA#TC0V +MHQ'J8@&T@VHT`QII&Z!"B5;S7YT+1"ZB8Y+5"M,5_J`!]Y:[$2%,%W`ZAA2@ +MVE)'DK^*?'3QU`DFQ4@22)(B[N3GZN?E<)`DDB.C)7\X71*B1K*2))(DD1HI +MU5$TUVF[4JP89^FHY$B*FEBC(RN$5"8O'XO]1++(._=;ZKXR%:QK3^W7/>RT +M8EODZ#MX53U8C0F]6O.G4J/9YNQA$B2))$<[H5(]"2=])+_3RW)O*AI[)9@D^JV5RK3?43-;"G;69#AH8,(5;:7UN,<5%98$9;9; +M\G*RT*37_9[;D'P/`1(R-$D.!36\S6N:_M>!][4*&3?'S858VCD+-3PINFR8 +M,C9?J+9ME:9.,_OR\C;3K'27W:K<<&>MMC;HS".>68$Y&.B608>JM?)+3$:Z +MY539A<7-E*'_YY..1'ECZBIG5%1%U93-9*1-5T_C!\)&2@?*CQB>(Q\0G(J< +M6%PDB4L,2$>Q4IM%6A+%4K/0-!7*348,9!&#<9@JNP&+LBI>+9&*JC6ZE293 +MY%-8H^HI12#5$9J;"0@$DA.](1+1.SH#B10&H6C48:PMPI7=#M2A@I%'\J2P +M.Y(+0C:B.&>F(^[(>)1+M\+QH%@O#4OE(\RE*14IZ7+9R*G8IYV^O=Y<=4HY +M1C@SCIZ=$DT]"`>IH&@`#1Z)M3"-#(T#$4:I[4U`/4T-````````````!PT-&31H +MT::&1D,(`R`&0::``!D#(`D4IZIZ0-`T````````````]&II7`12+EV$9U/B +MB!*_@T]?CB(F_;A17-%[AD,R8`JV@70VUC,Y6`FQ"$@1@M3"$@0)"3F`Y&Q/$XJBC2?^*)EA9:/'NE+<&E/_K^ +M-Z0($"0E11*I%KQK=*`$'NO&"YPP%*V4`5T>42;8B[:=M@:9#;@')!UFD +M8$)CB(&5G68PD`TD`[D"*AV+N\79)G^Q/SOS[CLC2P3T;\WCMH#X(5\++`-# +ML-+?DXEFS9H@P06,,HP2-X<1W%B*AY`JW`=,R?NG%O?)8;N6134$BXK2#F&& +M*"8&QUDIX$R\2.;XAFVSP/=K'6.!M8;%=UGWD84CA7$<.IJ0]NS'LEV@J(Q[ +MA='$&9W%-><1MMG8-JCG-DG+D,4"H>!`EJIEKV61?:5TW2M97U?>B%$S@N0G +M4!Q5$=A,ES!Z%;4P):4`FG@`X=YHB%#"PIU084Y4 +M@/JFD\8E9G8Y\8:0TJYP'=17J(:!3R>)1/FE%'Z2XBYRI259/935.OC-50: +M#[&,:!IG0R$A"P8>:89+I+'"&$B")A'5G8B+ZJ14JXH:'.:@IH0&T(0($A+" +/#6J,VO\7="Thomas Schmitt (scdbackup@gmx.net)", +# ="Thomas Schmitt" and ="1999" +# an Open Source license approved by opensource.org +# + +mntpnt="" + +atf_test_case pr_kern_48787 cleanup +pr_kern_48787_head() { + atf_set "descr" "Verifies 32bit overflow isssues from PR kern/48787 are fixed" + atf_set "require.user" "root" + atf_set "require.progs" "rump_cd9660 bunzip2 stat" + atf_set "timeout" 6000 +} + +pr_kern_48787_body() { + avail=$( df -Pk . | awk '{if (NR==2) print $4}' ) + if [ $avail -lt 4500000 ]; then + atf_skip "not enough free disk space, have ${avail} Kbytes, need ~ 4500000 Kbytes" + fi + bunzip2 < $(atf_get_srcdir)/pr_48787.image.bz2 > pr_48787.image + mntpnt=$(pwd)/mnt + mkdir ${mntpnt} + rump_cd9660 -o norrip ./pr_48787.image ${mntpnt} + if [ ! -r ${mntpnt}/small_file ]; then + atf_fail "${mntpnt}/small_file does not exist" + fi + if [ ! -r ${mntpnt}/my/large_file ]; then + atf_fail "${mntpnt}/my/large_file does not exist" + fi + umount ${mntpnt} + rump_cd9660 ./pr_48787.image ${mntpnt} + if [ ! -r ${mntpnt}/small_file ]; then + atf_fail "${mntpnt}/small_file does not exist" + fi + if [ ! -r ${mntpnt}/my/large_file ]; then + atf_fail "${mntpnt}/my/large_file does not exist" + fi + echo "this assumes current cd9660 inode encoding - adapt on changes" + atf_check -o match:"^4329541966$" stat -f "%i" ${mntpnt}/small_file + atf_check -o match:"^4329545920$" stat -f "%i" ${mntpnt}/my/large_file + umount ${mntpnt} + touch "done" +} + +pr_kern_48787_cleanup() { + if [ ! -f done ]; then + if [ "x${mntpnt}" != "x" ]; then + umount -f ${mntpnt} || true + fi + fi +} + +atf_init_test_cases() { + atf_add_test_case pr_kern_48787 +} diff --git a/contrib/netbsd-tests/fs/common/fstest_ext2fs.c b/contrib/netbsd-tests/fs/common/fstest_ext2fs.c new file mode 100644 index 000000000000..85bb79f7ebd0 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_ext2fs.c @@ -0,0 +1,139 @@ +/* $NetBSD: fstest_ext2fs.c,v 1.2 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct ext2fstestargs { + struct ufs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +ext2fs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct ext2fstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_ext2fs -F -s %"PRId64" %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.ext2fs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return res; +} + +int +ext2fs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct ext2fstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +ext2fs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct ext2fstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_EXT2FS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +ext2fs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_ffs.c b/contrib/netbsd-tests/fs/common/fstest_ffs.c new file mode 100644 index 000000000000..7ae4e8f5970c --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_ffs.c @@ -0,0 +1,156 @@ +/* $NetBSD: fstest_ffs.c,v 1.6 2012/08/05 02:03:05 riastradh Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct ffstestargs { + struct ufs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +ffs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size, + void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct ffstestargs *args; + struct sigaction act, oact; + + size /= 512; + snprintf(cmd, 1024, "newfs -F -s %"PRId64" %s >/dev/null", size, image); + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &act, &oact); + res = system(cmd); + sigaction(SIGCHLD, &oact, NULL); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.ffs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} +__strong_alias(ffslog_fstest_newfs,ffs_fstest_newfs); + +int +ffs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct ffstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) { + errno = res; + return -1; + } + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} +__strong_alias(ffslog_fstest_delfs,ffs_fstest_delfs); + +int +ffs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct ffstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_FFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +ffslog_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + + return ffs_fstest_mount(tc, buf, path, flags | MNT_LOG); +} + +int +ffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} +__strong_alias(ffslog_fstest_unmount,ffs_fstest_unmount); diff --git a/contrib/netbsd-tests/fs/common/fstest_lfs.c b/contrib/netbsd-tests/fs/common/fstest_lfs.c new file mode 100644 index 000000000000..fd131cffe6b8 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_lfs.c @@ -0,0 +1,192 @@ +/* $NetBSD: fstest_lfs.c,v 1.4 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" +#include "mount_lfs.h" + +sem_t lfs_clearnerloop; + +struct lfstestargs { + struct ufs_args ta_uargs; + pthread_t ta_cleanerthread; + sem_t ta_cleanerloop; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; + char ta_mntpath[MAXPATHLEN]; + char ta_hostpath[MAXPATHLEN]; +}; + +int +lfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size, + void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct lfstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_lfs -D -F -s %"PRId64" ./%s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + strcpy(args->ta_hostpath, image); + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.lfs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + sem_init(&args->ta_cleanerloop, 0, 0); + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +lfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct lfstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + pthread_join(args->ta_cleanerthread, NULL); + free(args); + + return 0; +} + +static void * +cleaner(void *arg) +{ + char thepath[MAXPATHLEN]; + struct lfstestargs *args = arg; + const char *the_argv[7]; + char buf[64]; + + /* this inspired by the cleaner code. fixme */ + sprintf(thepath, "/dev/r%s", args->ta_devpath+5); + rump_pub_etfs_register(thepath, args->ta_hostpath, RUMP_ETFS_CHR); + sprintf(buf, "%p", &args->ta_cleanerloop); + + the_argv[0] = "megamaid"; + the_argv[1] = "-D"; /* don't fork() & detach */ + the_argv[2] = "-S"; + the_argv[3] = buf; + the_argv[4] = args->ta_mntpath; + the_argv[5] = NULL; + + /* xxxatf */ + optind = 1; + opterr = 1; + + lfs_cleaner_main(5, __UNCONST(the_argv)); + + return NULL; +} + +int +lfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + struct lfstestargs *args = buf; + int res; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_LFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + if (res == -1) + return res; + + strcpy(args->ta_mntpath, path); + res = pthread_create(&args->ta_cleanerthread, NULL, cleaner, args); + if (res) + return res; + + /* wait for cleaner to initialize */ + sem_wait(&args->ta_cleanerloop); + + return 0; +} + +int +lfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) { + return res; + } + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_msdosfs.c b/contrib/netbsd-tests/fs/common/fstest_msdosfs.c new file mode 100644 index 000000000000..2c94e3f92fa8 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_msdosfs.c @@ -0,0 +1,140 @@ +/* $NetBSD: fstest_msdosfs.c,v 1.3 2012/03/26 15:10:26 njoly Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct msdosfstestargs { + struct msdosfs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +msdosfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct msdosfstestargs *args; + + size /= 512; size -= (size % 63); + snprintf(cmd, 1024, "newfs_msdos -C %"PRId64"s %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.msdosfs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + args->ta_uargs.mask = 0755; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +msdosfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct msdosfstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +msdosfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct msdosfstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_MSDOS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +msdosfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_nfs.c b/contrib/netbsd-tests/fs/common/fstest_nfs.c new file mode 100644 index 000000000000..5ef256f1be41 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_nfs.c @@ -0,0 +1,326 @@ +/* $NetBSD: fstest_nfs.c,v 1.9 2011/02/28 21:08:46 pooka Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, 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. + * + * 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 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" +#include "mount_nfs.h" +#include "../../net/config/netconfig.c" + +#define SERVERADDR "10.3.2.1" +#define SERVERROADDR "10.4.2.1" +#define CLIENTADDR "10.3.2.2" +#define CLIENTROADDR "10.4.2.2" +#define NETNETMASK "255.255.255.0" +#define EXPORTPATH "/myexport" + +static void +childfail(int status) +{ + + atf_tc_fail("child died"); +} + +/* fork rump nfsd, configure interface */ +static int +donewfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + const char *srcdir; + char *nfsdargv[16]; + char nfsdpath[MAXPATHLEN]; + char imagepath[MAXPATHLEN]; + char ethername[MAXPATHLEN], ethername_ro[MAXPATHLEN]; + char ifname[IFNAMSIZ], ifname_ro[IFNAMSIZ]; + char cwd[MAXPATHLEN]; + struct nfstestargs *args; + pid_t childpid; + int pipes[2]; + int devnull; + + /* + * First, we start the nfs service. + */ + srcdir = atf_tc_get_config_var(tc, "srcdir"); + sprintf(nfsdpath, "%s/../nfs/nfsservice/rumpnfsd", srcdir); + sprintf(ethername, "/%s/%s.etherbus", getcwd(cwd, sizeof(cwd)), image); + sprintf(ethername_ro, "%s_ro", ethername); + sprintf(imagepath, "/%s/%s", cwd, image); + + nfsdargv[0] = nfsdpath; + nfsdargv[1] = ethername; + nfsdargv[2] = ethername_ro; + nfsdargv[3] = __UNCONST(SERVERADDR); + nfsdargv[4] = __UNCONST(SERVERROADDR); + nfsdargv[5] = __UNCONST(NETNETMASK); + nfsdargv[6] = __UNCONST(EXPORTPATH); + nfsdargv[7] = imagepath; + nfsdargv[8] = NULL; + + signal(SIGCHLD, childfail); + if (pipe(pipes) == -1) + return errno; + + switch ((childpid = fork())) { + case 0: + if (chdir(dirname(nfsdpath)) == -1) + err(1, "chdir"); + close(pipes[0]); + if (dup2(pipes[1], 3) == -1) + err(1, "dup2"); + if (execvp(nfsdargv[0], nfsdargv) == -1) + err(1, "execvp"); + case -1: + return errno; + default: + close(pipes[1]); + break; + } + + /* + * Ok, nfsd has been run. The following sleep helps with the + * theoretical problem that nfsd can't start fast enough to + * process our mount request and we end up doing a timeout + * before the mount. This would take several seconds. So + * try to make sure nfsd is up&running already at this stage. + */ + if (read(pipes[0], &devnull, 4) == -1) + return errno; + + /* + * Configure our networking interface. + */ + rump_init(); + netcfg_rump_makeshmif(ethername, ifname); + netcfg_rump_if(ifname, CLIENTADDR, NETNETMASK); + netcfg_rump_makeshmif(ethername_ro, ifname_ro); + netcfg_rump_if(ifname_ro, CLIENTROADDR, NETNETMASK); + + /* + * That's it. The rest is done in mount, since we don't have + * the mountpath available here. + */ + args = malloc(sizeof(*args)); + if (args == NULL) + return errno; + memset(args, 0, sizeof(*args)); + args->ta_childpid = childpid; + strcpy(args->ta_ethername, ethername); + + *argp = args; + + return 0; +} + +int +nfs_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + + return donewfs(tc, argp, image, size, fspriv); +} + +int +nfsro_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + + return donewfs(tc, argp, image, size, fspriv); +} + +/* mount the file system */ +static int +domount(const atf_tc_t *tc, void *arg, const char *serverpath, + const char *path, int flags) +{ + char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN]; + const char *nfscliargs[] = { + "nfsclient", + serverpath, + path, + NULL, + }; + struct nfs_args args; + int mntflags; + + if (rump_sys_mkdir(path, 0777) == -1) + return errno; + + /* XXX: atf does not reset values */ + optind = 1; + opterr = 1; + + /* + * We use nfs parseargs here, since as a side effect it + * takes care of the RPC hulabaloo. + */ + mount_nfs_parseargs(__arraycount(nfscliargs)-1, __UNCONST(nfscliargs), + &args, &mntflags, canon_dev, canon_dir); + + if (rump_sys_mount(MOUNT_NFS, path, flags, &args, sizeof(args)) == -1) { + return errno; + } + + return 0; +} + +int +nfs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags) +{ + + return domount(tc, arg, SERVERADDR ":" EXPORTPATH, path, flags); +} + +/* + * This is where the magic happens! + * + * If we are mounting r/w, do the normal thing. However, if we are + * doing a r/o mount, switch use the r/o server export address + * and do a r/w mount. This way we end up testing the r/o export policy + * of the server! (yes, slightly questionable semantics, but at least + * we notice very quickly if our assumption is broken in the future ;) + */ +int +nfsro_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags) +{ + + if (flags & MNT_RDONLY) { + flags &= ~MNT_RDONLY; + return domount(tc, arg, SERVERROADDR":"EXPORTPATH, path, flags); + } else { + return domount(tc, arg, SERVERADDR":"EXPORTPATH, path, flags); + } +} + +static int +dodelfs(const atf_tc_t *tc, void *arg) +{ + + /* + * XXX: no access to "args" since we're called from "cleanup". + * Trust atf to kill nfsd process and remove etherfile. + */ +#if 0 + /* + * It's highly expected that the child will die next, so we + * don't need that information anymore thank you very many. + */ + signal(SIGCHLD, SIG_IGN); + + /* + * Just KILL it. Sending it SIGTERM first causes it to try + * to send some unmount RPCs, leading to sticky situations. + */ + kill(args->ta_childpid, SIGKILL); + wait(&status); + + /* remove ethernet bus */ + if (unlink(args->ta_ethername) == -1) + atf_tc_fail_errno("unlink ethername"); +#endif + + return 0; +} + +int +nfs_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + return dodelfs(tc, arg); +} + +int +nfsro_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + return dodelfs(tc, arg); +} + +static int +dounmount(const atf_tc_t *tc, const char *path, int flags) +{ + int status, i, sverrno; + + /* + * NFS handles sillyrenames in an workqueue. Some of them might + * be still in the queue even if all user activity has ceased. + * We try to unmount for 2 seconds to give them a chance + * to flush out. + * + * PR kern/43799 + */ + for (i = 0; i < 20; i++) { + if ((status = rump_sys_unmount(path, flags)) == 0) + break; + sverrno = errno; + if (sverrno != EBUSY) + break; + usleep(100000); + } + if (status == -1) + return sverrno; + + if (rump_sys_rmdir(path) == -1) + return errno; + + return 0; +} + +int +nfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + + return dounmount(tc, path, flags); +} + +int +nfsro_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + + return dounmount(tc, path, flags); +} diff --git a/contrib/netbsd-tests/fs/common/fstest_puffs.c b/contrib/netbsd-tests/fs/common/fstest_puffs.c new file mode 100644 index 000000000000..14e4bfba43ba --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_puffs.c @@ -0,0 +1,452 @@ +/* $NetBSD: fstest_puffs.c,v 1.11 2013/09/09 19:47:38 pooka Exp $ */ + +/* + * Copyright (c) 2010, 2011 The NetBSD Foundation, 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. + * + * 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 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" + +#define BUFSIZE (128*1024) +#define DTFS_DUMP "-o","dump" + +static bool mayquit = false; + +static ssize_t +xread(int fd, void *vp, size_t n) +{ + size_t left; + + left = n; + do { + ssize_t ssz; + + ssz = read(fd, vp, left); + if (ssz == -1) { + return ssz; + } + left -= ssz; + vp = (char *)vp + ssz; + } while (left > 0); + return n; +} + +static ssize_t +xwrite(int fd, const void *vp, size_t n) +{ + size_t left; + + left = n; + do { + ssize_t ssz; + + ssz = write(fd, vp, left); + if (ssz == -1) { + return ssz; + } + left -= ssz; + vp = (const char *)vp + ssz; + } while (left > 0); + return n; +} + +/* + * Threads which shovel data between comfd and /dev/puffs. + * (cannot use polling since fd's are in different namespaces) + */ +static void * +readshovel(void *arg) +{ + struct putter_hdr *phdr; + struct puffs_req *preq; + struct puffstestargs *args = arg; + char buf[BUFSIZE]; + ssize_t n; + int comfd, puffsfd; + + comfd = args->pta_servfd; + puffsfd = args->pta_rumpfd; + + phdr = (void *)buf; + preq = (void *)buf; + + rump_pub_lwproc_newlwp(1); + + for (;;) { + n = rump_sys_read(puffsfd, buf, sizeof(*phdr)); + if (n <= 0) { + fprintf(stderr, "readshovel r1 %zd / %d\n", n, errno); + break; + } + + assert(phdr->pth_framelen < BUFSIZE); + n = rump_sys_read(puffsfd, buf+sizeof(*phdr), + phdr->pth_framelen - sizeof(*phdr)); + if (n <= 0) { + fprintf(stderr, "readshovel r2 %zd / %d\n", n, errno); + break; + } + + /* Analyze request */ + if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) { + assert(preq->preq_optype < PUFFS_VFS_MAX); + args->pta_vfs_toserv_ops[preq->preq_optype]++; + } else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) { + assert(preq->preq_optype < PUFFS_VN_MAX); + args->pta_vn_toserv_ops[preq->preq_optype]++; + } + + n = phdr->pth_framelen; + if (xwrite(comfd, buf, n) != n) { + fprintf(stderr, "readshovel write %zd / %d\n", n, errno); + break; + } + } + + if (n != 0 && mayquit == false) + abort(); + return NULL; +} + +static void * +writeshovel(void *arg) +{ + struct puffstestargs *args = arg; + struct putter_hdr *phdr; + struct puffs_req *preq; + char buf[BUFSIZE]; + size_t toread; + ssize_t n; + int comfd, puffsfd; + + rump_pub_lwproc_newlwp(1); + + comfd = args->pta_servfd; + puffsfd = args->pta_rumpfd; + + phdr = (struct putter_hdr *)buf; + preq = (void *)buf; + + for (;;) { + uint64_t off; + + /* + * Need to write everything to the "kernel" in one chunk, + * so make sure we have it here. + */ + off = 0; + toread = sizeof(struct putter_hdr); + assert(toread < BUFSIZE); + do { + n = xread(comfd, buf+off, toread); + if (n <= 0) { + fprintf(stderr, "writeshovel read %zd / %d\n", + n, errno); + goto out; + } + off += n; + if (off >= sizeof(struct putter_hdr)) + toread = phdr->pth_framelen - off; + else + toread = off - sizeof(struct putter_hdr); + } while (toread); + + if (__predict_false( + PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS + && preq->preq_optype == PUFFS_VFS_UNMOUNT)) { + if (preq->preq_rv == 0) + mayquit = true; + } + + n = rump_sys_write(puffsfd, buf, phdr->pth_framelen); + if ((size_t)n != phdr->pth_framelen) { + fprintf(stderr, "writeshovel wr %zd / %d\n", n, errno); + break; + } + } + + out: + if (n != 0) + abort(); + return NULL; +} + +static void +rumpshovels(struct puffstestargs *args) +{ + pthread_t pt; + int rv; + + if ((rv = rump_init()) == -1) + err(1, "rump_init"); + + if (pthread_create(&pt, NULL, readshovel, args) == -1) + err(1, "read shovel"); + pthread_detach(pt); + + if (pthread_create(&pt, NULL, writeshovel, args) == -1) + err(1, "write shovel"); + pthread_detach(pt); +} + +static void +childfail(int sign) +{ + + atf_tc_fail("child died"); /* almost signal-safe */ +} + +struct puffstestargs *theargs; /* XXX */ + +/* XXX: we don't support size */ +static int +donewfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv, char **theargv) +{ + struct puffstestargs *args; + pid_t childpid; + int *pflags; + char comfd[16]; + int sv[2]; + int mntflags; + size_t len; + ssize_t n; + + *argp = NULL; + + args = malloc(sizeof(*args)); + if (args == NULL) + return errno; + memset(args, 0, sizeof(*args)); + + pflags = &args->pta_pflags; + + /* Create sucketpair for communication with the real file server */ + if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) == -1) + return errno; + + signal(SIGCHLD, childfail); + + switch ((childpid = fork())) { + case 0: + close(sv[1]); + snprintf(comfd, sizeof(sv[0]), "%d", sv[0]); + if (setenv("PUFFS_COMFD", comfd, 1) == -1) + return errno; + + if (execvp(theargv[0], theargv) == -1) + return errno; + case -1: + return errno; + default: + close(sv[0]); + break; + } + + /* read args */ + if ((n = xread(sv[1], &len, sizeof(len))) != sizeof(len)) + err(1, "mp 1 %zd", n); + if (len > MAXPATHLEN) + err(1, "mntpath > MAXPATHLEN"); + if ((size_t)xread(sv[1], args->pta_dir, len) != len) + err(1, "mp 2"); + if (xread(sv[1], &len, sizeof(len)) != sizeof(len)) + err(1, "fn 1"); + if (len > MAXPATHLEN) + err(1, "devpath > MAXPATHLEN"); + if ((size_t)xread(sv[1], args->pta_dev, len) != len) + err(1, "fn 2"); + if (xread(sv[1], &mntflags, sizeof(mntflags)) != sizeof(mntflags)) + err(1, "mntflags"); + if (xread(sv[1], &args->pta_pargslen, sizeof(args->pta_pargslen)) + != sizeof(args->pta_pargslen)) + err(1, "puffstest_args len"); + args->pta_pargs = malloc(args->pta_pargslen); + if (args->pta_pargs == NULL) + err(1, "malloc"); + if (xread(sv[1], args->pta_pargs, args->pta_pargslen) + != (ssize_t)args->pta_pargslen) + err(1, "puffstest_args"); + if (xread(sv[1], pflags, sizeof(*pflags)) != sizeof(*pflags)) + err(1, "pflags"); + + args->pta_childpid = childpid; + args->pta_servfd = sv[1]; + strlcpy(args->pta_dev, image, sizeof(args->pta_dev)); + + *argp = theargs = args; + + return 0; +} + +int +puffs_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + char dtfs_path[MAXPATHLEN]; + char *dtfsargv[6]; + char **theargv; + + /* build dtfs exec path from atf test dir */ + sprintf(dtfs_path, "%s/../puffs/h_dtfs/h_dtfs", + atf_tc_get_config_var(tc, "srcdir")); + + if (fspriv) { + theargv = fspriv; + theargv[0] = dtfs_path; + } else { + dtfsargv[0] = dtfs_path; + dtfsargv[1] = __UNCONST("-i"); + dtfsargv[2] = __UNCONST("-s"); + dtfsargv[3] = __UNCONST("dtfs"); + dtfsargv[4] = __UNCONST("fictional"); + dtfsargv[5] = NULL; + + theargv = dtfsargv; + } + + return donewfs(tc, argp, image, size, fspriv, theargv); +} + +int +p2k_ffs_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + char *rumpffs_argv[5]; + int rv; + + rump_init(); + if ((rv = ffs_fstest_newfs(tc, argp, image, size, fspriv)) != 0) + return rv; + if (mkdir("p2kffsfake", 0777) == -1 && errno != EEXIST) + return errno; + + setenv("P2K_NODETACH", "1", 1); + rumpffs_argv[0] = __UNCONST("rump_ffs"); + rumpffs_argv[1] = __UNCONST(image); + rumpffs_argv[2] = __UNCONST("p2kffsfake"); /* NOTUSED */ + rumpffs_argv[3] = NULL; + + if ((rv = donewfs(tc, argp, image, size, fspriv, rumpffs_argv)) != 0) + ffs_fstest_delfs(tc, argp); + return rv; +} + +int +puffs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags) +{ + struct puffstestargs *pargs = arg; + int fd; + + rump_init(); + fd = rump_sys_open("/dev/puffs", O_RDWR); + if (fd == -1) + return fd; + + if (rump_sys_mkdir(path, 0777) == -1) + return -1; + + if (rump_sys_mount(MOUNT_PUFFS, path, flags, + pargs->pta_pargs, pargs->pta_pargslen) == -1) { + /* apply "to kill a child" to avoid atf hang (kludge) */ + kill(pargs->pta_childpid, SIGKILL); + return -1; + } + + pargs->pta_rumpfd = fd; + rumpshovels(pargs); + + return 0; +} +__strong_alias(p2k_ffs_fstest_mount,puffs_fstest_mount); + +int +puffs_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + /* useless ... */ + return 0; +} + +int +p2k_ffs_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + return ffs_fstest_delfs(tc, arg); +} + +int +puffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + struct puffstestargs *pargs = theargs; + int status; + int rv; + + /* ok, child might exit here */ + signal(SIGCHLD, SIG_IGN); + + rv = rump_sys_unmount(path, flags); + if (rv) + return rv; + + if ((rv = rump_sys_rmdir(path)) != 0) + return rv; + + if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0) + return 0; + kill(pargs->pta_childpid, SIGTERM); + usleep(10); + if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0) + return 0; + kill(pargs->pta_childpid, SIGKILL); + usleep(500); + wait(&status); + + rmdir("p2kffsfake"); + + return 0; +} +__strong_alias(p2k_ffs_fstest_unmount,puffs_fstest_unmount); diff --git a/contrib/netbsd-tests/fs/common/fstest_rumpfs.c b/contrib/netbsd-tests/fs/common/fstest_rumpfs.c new file mode 100644 index 000000000000..e4003db3d026 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_rumpfs.c @@ -0,0 +1,90 @@ +/* $NetBSD: fstest_rumpfs.c,v 1.2 2014/03/16 10:28:03 njoly Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" + +int +rumpfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char tmp[64]; + int res; + + snprintf(tmp, sizeof(tmp), "%"PRId64, size); + res = setenv("RUMP_MEMLIMIT", tmp, 0); + if (res == -1) + return res; + + return rump_init(); +} + +int +rumpfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + + return 0; +} + +int +rumpfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + return rump_sys_mount(MOUNT_RUMPFS, path, flags, NULL, 0); +} + +int +rumpfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + return rump_sys_rmdir(path); +} diff --git a/contrib/netbsd-tests/fs/common/fstest_sysvbfs.c b/contrib/netbsd-tests/fs/common/fstest_sysvbfs.c new file mode 100644 index 000000000000..a7cf7f4cd8e1 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_sysvbfs.c @@ -0,0 +1,139 @@ +/* $NetBSD: fstest_sysvbfs.c,v 1.2 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct sysvbfstestargs { + struct ufs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +sysvbfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct sysvbfstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_sysvbfs -F -s %"PRId64" %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.sysvbfs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +sysvbfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct sysvbfstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +sysvbfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct sysvbfstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_SYSVBFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +sysvbfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_tmpfs.c b/contrib/netbsd-tests/fs/common/fstest_tmpfs.c new file mode 100644 index 000000000000..83848432e21f --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_tmpfs.c @@ -0,0 +1,112 @@ +/* $NetBSD: fstest_tmpfs.c,v 1.2 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct tmpfstestargs { + struct tmpfs_args ta_uargs; +}; + +int +tmpfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + int res; + struct tmpfstestargs *args; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + args->ta_uargs.ta_version = TMPFS_ARGS_VERSION; + args->ta_uargs.ta_root_mode = 0777; + args->ta_uargs.ta_size_max = size; + + *buf = args; + + return 0; +} + +int +tmpfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + struct tmpfstestargs *args = buf; + + free(args); + + return 0; +} + +int +tmpfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct tmpfstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_TMPFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +tmpfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_udf.c b/contrib/netbsd-tests/fs/common/fstest_udf.c new file mode 100644 index 000000000000..3c9e017f388f --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_udf.c @@ -0,0 +1,153 @@ +/* $NetBSD: fstest_udf.c,v 1.4 2013/07/02 15:00:55 reinoud Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct udftestargs { + struct udf_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +udf_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size, + void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct udftestargs *args; + struct sigaction act, oact; + + /* + * Sectorsize can be specified with -S, as a multiple of 512. + * newfs_udf takes humanized number as size in bytes as -s parameter! + */ + snprintf(cmd, 1024, "newfs_udf -F -s %"PRId64" %s >/dev/null", size, image); + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &act, &oact); + res = system(cmd); + sigaction(SIGCHLD, &oact, NULL); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.udf", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + args->ta_uargs.version = UDFMNT_VERSION; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} +__strong_alias(udflog_fstest_newfs,udf_fstest_newfs); + +int +udf_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct udftestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) { + errno = res; + return -1; + } + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} +__strong_alias(udflog_fstest_delfs,udf_fstest_delfs); + +int +udf_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct udftestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_UDF, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +udf_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} +__strong_alias(udflog_fstest_unmount,udf_fstest_unmount); diff --git a/contrib/netbsd-tests/fs/common/fstest_v7fs.c b/contrib/netbsd-tests/fs/common/fstest_v7fs.c new file mode 100644 index 000000000000..92110e430e83 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_v7fs.c @@ -0,0 +1,140 @@ +/* $NetBSD: fstest_v7fs.c,v 1.1 2011/08/11 10:52:12 uch Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct v7fstestargs { + struct v7fs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +v7fs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct v7fstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_v7fs -F -s %"PRId64" %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.v7fs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + args->ta_uargs.endian = _BYTE_ORDER; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +v7fs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct v7fstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +v7fs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct v7fstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_V7FS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +v7fs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_zfs.c b/contrib/netbsd-tests/fs/common/fstest_zfs.c new file mode 100644 index 000000000000..88aa05f28ff7 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_zfs.c @@ -0,0 +1,134 @@ +/* $NetBSD: fstest_zfs.c,v 1.1 2012/08/20 16:37:35 pooka Exp $ */ + +/*- + * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" + +#define SRVPATH "zfssurvo" +#define SRVURL "unix://" SRVPATH +#define ZFSDEV "/zfsdev" + +int +zfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + int res; + int fd; + + /* XXX: hardcoded zfs minimum size */ + size = MAX(64*1024*1024, size); + + res = rump_init(); + if (res != 0) { + errno = res; + return -1; + } + + /* create backing image, sparse file is enough */ + if ((fd = open(image, O_RDWR | O_CREAT, 0777)) == -1) + return -1; + if (ftruncate(fd, size) == -1) { + close(fd); + return -1; + } + close(fd); + + res = rump_pub_etfs_register(ZFSDEV, image, RUMP_ETFS_BLK); + if (res != 0) { + errno = res; + return -1; + } + + res = rump_init_server(SRVURL); + if (res != 0) { + errno = res; + return -1; + } + *buf = NULL; + + return 0; +} + +int +zfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + + unlink(SRVPATH); + return 0; +} + +int +zfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + char tmpbuf[128]; + int error; + + /* set up the hijack env for running zpool */ + setenv("RUMP_SERVER", SRVURL, 1); + snprintf(tmpbuf, sizeof(tmpbuf)-1, "blanket=/dev/zfs:%s:%s", + ZFSDEV, path); + setenv("RUMPHIJACK", tmpbuf, 1); + setenv("LD_PRELOAD", "/usr/lib/librumphijack.so", 1); + + while (*path == '/') + path++; + + /* run zpool create */ + snprintf(tmpbuf, sizeof(tmpbuf)-1, "zpool create %s %s", + path, ZFSDEV); + if ((error = system(tmpbuf)) != 0) { + errno = error; + return -1; + } + + return 0; +} + +int +zfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + + unmount(path, flags); + unlink(SRVPATH); + + return 0; +} diff --git a/contrib/netbsd-tests/fs/common/h_fsmacros.h b/contrib/netbsd-tests/fs/common/h_fsmacros.h new file mode 100644 index 000000000000..b47a70802bba --- /dev/null +++ b/contrib/netbsd-tests/fs/common/h_fsmacros.h @@ -0,0 +1,337 @@ +/* $NetBSD: h_fsmacros.h,v 1.38 2013/06/26 19:29:24 reinoud Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#ifndef __H_FSMACROS_H_ +#define __H_FSMACROS_H_ + +#include + +#include +#include +#include + +#include + +#include "../../h_macros.h" + +#define FSPROTOS(_fs_) \ +int _fs_##_fstest_newfs(const atf_tc_t *, void **, const char *, \ + off_t, void *); \ +int _fs_##_fstest_delfs(const atf_tc_t *, void *); \ +int _fs_##_fstest_mount(const atf_tc_t *, void *, const char *, int); \ +int _fs_##_fstest_unmount(const atf_tc_t *, const char *, int); + +FSPROTOS(ext2fs); +FSPROTOS(ffs); +FSPROTOS(ffslog); +FSPROTOS(lfs); +FSPROTOS(msdosfs); +FSPROTOS(nfs); +FSPROTOS(nfsro); +FSPROTOS(p2k_ffs); +FSPROTOS(puffs); +FSPROTOS(rumpfs); +FSPROTOS(sysvbfs); +FSPROTOS(tmpfs); +FSPROTOS(udf); +FSPROTOS(v7fs); +FSPROTOS(zfs); + +#ifndef FSTEST_IMGNAME +#define FSTEST_IMGNAME "image.fs" +#endif +#ifndef FSTEST_IMGSIZE +#define FSTEST_IMGSIZE (10000 * 512) +#endif +#ifndef FSTEST_MNTNAME +#define FSTEST_MNTNAME "/mnt" +#endif + +#define FSTEST_CONSTRUCTOR(_tc_, _fs_, _args_) \ +do { \ + if (_fs_##_fstest_newfs(_tc_, &_args_, \ + FSTEST_IMGNAME, FSTEST_IMGSIZE, NULL) != 0) \ + atf_tc_fail_errno("newfs failed"); \ + if (_fs_##_fstest_mount(_tc_, _args_, FSTEST_MNTNAME, 0) != 0) \ + atf_tc_fail_errno("mount failed"); \ +} while (/*CONSTCOND*/0); + +#define FSTEST_CONSTRUCTOR_FSPRIV(_tc_, _fs_, _args_, _privargs_) \ +do { \ + if (_fs_##_fstest_newfs(_tc_, &_args_, \ + FSTEST_IMGNAME, FSTEST_IMGSIZE, _privargs_) != 0) \ + atf_tc_fail_errno("newfs failed"); \ + if (_fs_##_fstest_mount(_tc_, _args_, FSTEST_MNTNAME, 0) != 0) \ + atf_tc_fail_errno("mount failed"); \ +} while (/*CONSTCOND*/0); + +#define FSTEST_DESTRUCTOR(_tc_, _fs_, _args_) \ +do { \ + if (_fs_##_fstest_unmount(_tc_, FSTEST_MNTNAME, 0) != 0) { \ + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ + atf_tc_fail_errno("unmount failed"); \ + } \ + if (_fs_##_fstest_delfs(_tc_, _args_) != 0) \ + atf_tc_fail_errno("delfs failed"); \ +} while (/*CONSTCOND*/0); + +#define ATF_TC_FSADD(fs,type,func,desc) \ + ATF_TC(fs##_##func); \ + ATF_TC_HEAD(fs##_##func,tc) \ + { \ + atf_tc_set_md_var(tc, "descr", type " test for " desc); \ + atf_tc_set_md_var(tc, "X-fs.type", #fs); \ + atf_tc_set_md_var(tc, "X-fs.mntname", type); \ + if (strcmp(#fs, "zfs") == 0) { \ + /* This should not be necessary. */ \ + atf_tc_set_md_var(tc, "require.user", "root"); \ + } \ + } \ + void *fs##func##tmp; \ + \ + ATF_TC_BODY(fs##_##func,tc) \ + { \ + if (!atf_check_fstype(tc, #fs)) \ + atf_tc_skip("filesystem not selected"); \ + FSTEST_CONSTRUCTOR(tc,fs,fs##func##tmp); \ + func(tc,FSTEST_MNTNAME); \ + if (fs##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) { \ + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ + atf_tc_fail_errno("unmount failed"); \ + } \ + } + +#define ATF_TC_FSADD_RO(_fs_,_type_,_func_,_desc_,_gen_) \ + ATF_TC(_fs_##_##_func_); \ + ATF_TC_HEAD(_fs_##_##_func_,tc) \ + { \ + atf_tc_set_md_var(tc, "descr",_type_" test for "_desc_);\ + atf_tc_set_md_var(tc, "X-fs.type", #_fs_); \ + atf_tc_set_md_var(tc, "X-fs.mntname", _type_); \ + if (strcmp(#_fs_, "zfs") == 0) { \ + /* This should not be necessary. */ \ + atf_tc_set_md_var(tc, "require.user", "root"); \ + } \ + } \ + void *_fs_##_func_##tmp; \ + \ + ATF_TC_BODY(_fs_##_##_func_,tc) \ + { \ + if (!atf_check_fstype(tc, #_fs_)) \ + atf_tc_skip("filesystem not selected"); \ + FSTEST_CONSTRUCTOR(tc,_fs_,_fs_##_func_##tmp); \ + _gen_(tc,FSTEST_MNTNAME); \ + if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) \ + atf_tc_fail_errno("unmount r/w failed"); \ + if (_fs_##_fstest_mount(tc, _fs_##_func_##tmp, \ + FSTEST_MNTNAME, MNT_RDONLY) != 0) \ + atf_tc_fail_errno("mount ro failed"); \ + _func_(tc,FSTEST_MNTNAME); \ + if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) {\ + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ + atf_tc_fail_errno("unmount failed"); \ + } \ + } + +#define ATF_TP_FSADD(fs,func) \ + ATF_TP_ADD_TC(tp,fs##_##func) + +#define ATF_TC_FSAPPLY_NOZFS(func,desc) \ + ATF_TC_FSADD(ext2fs,MOUNT_EXT2FS,func,desc) \ + ATF_TC_FSADD(ffs,MOUNT_FFS,func,desc) \ + ATF_TC_FSADD(ffslog,MOUNT_FFS,func,desc) \ + ATF_TC_FSADD(lfs,MOUNT_LFS,func,desc) \ + ATF_TC_FSADD(msdosfs,MOUNT_MSDOS,func,desc) \ + ATF_TC_FSADD(nfs,MOUNT_NFS,func,desc) \ + ATF_TC_FSADD(puffs,MOUNT_PUFFS,func,desc) \ + ATF_TC_FSADD(p2k_ffs,MOUNT_PUFFS,func,desc) \ + ATF_TC_FSADD(rumpfs,MOUNT_RUMPFS,func,desc) \ + ATF_TC_FSADD(sysvbfs,MOUNT_SYSVBFS,func,desc) \ + ATF_TC_FSADD(tmpfs,MOUNT_TMPFS,func,desc) \ + ATF_TC_FSADD(udf,MOUNT_UDF,func,desc) \ + ATF_TC_FSADD(v7fs,MOUNT_V7FS,func,desc) + +#define ATF_TP_FSAPPLY_NOZFS(func) \ + ATF_TP_FSADD(ext2fs,func); \ + ATF_TP_FSADD(ffs,func); \ + ATF_TP_FSADD(ffslog,func); \ + ATF_TP_FSADD(lfs,func); \ + ATF_TP_FSADD(msdosfs,func); \ + ATF_TP_FSADD(nfs,func); \ + ATF_TP_FSADD(puffs,func); \ + ATF_TP_FSADD(p2k_ffs,func); \ + ATF_TP_FSADD(rumpfs,func); \ + ATF_TP_FSADD(sysvbfs,func); \ + ATF_TP_FSADD(tmpfs,func); \ + ATF_TP_FSADD(udf,func); \ + ATF_TP_FSADD(v7fs,func); + +/* XXX: this will not scale */ +#ifdef WANT_ZFS_TESTS +#define ATF_TC_FSAPPLY(func,desc) \ + ATF_TC_FSAPPLY_NOZFS(func,desc) \ + ATF_TC_FSADD(zfs,MOUNT_ZFS,func,desc) +#define ATF_TP_FSAPPLY(func) \ + ATF_TP_FSAPPLY_NOZFS(func) \ + ATF_TP_FSADD(zfs,func); + +#else /* !WANT_ZFS_TESTS */ + +#define ATF_TC_FSAPPLY(func,desc) \ + ATF_TC_FSAPPLY_NOZFS(func,desc) +#define ATF_TP_FSAPPLY(func) \ + ATF_TP_FSAPPLY_NOZFS(func) + +#endif /* WANT_ZFS_TESTS */ + +/* + * Same as above, but generate a file system image first and perform + * tests for a r/o mount. + * + * Missing the following file systems: + * + lfs (fstest_lfs routines cannot handle remount. FIXME!) + * + tmpfs (memory backend) + * + rumpfs (memory backend) + * + puffs (memory backend, but could be run in theory) + */ + +#define ATF_TC_FSAPPLY_RO(func,desc,gen) \ + ATF_TC_FSADD_RO(ext2fs,MOUNT_EXT2FS,func,desc,gen) \ + ATF_TC_FSADD_RO(ffs,MOUNT_FFS,func,desc,gen) \ + ATF_TC_FSADD_RO(ffslog,MOUNT_FFS,func,desc,gen) \ + ATF_TC_FSADD_RO(msdosfs,MOUNT_MSDOS,func,desc,gen) \ + ATF_TC_FSADD_RO(nfs,MOUNT_NFS,func,desc,gen) \ + ATF_TC_FSADD_RO(nfsro,MOUNT_NFS,func,desc,gen) \ + ATF_TC_FSADD_RO(sysvbfs,MOUNT_SYSVBFS,func,desc,gen) \ + ATF_TC_FSADD_RO(udf,MOUNT_UDF,func,desc,gen) \ + ATF_TC_FSADD_RO(v7fs,MOUNT_V7FS,func,desc,gen) + +#define ATF_TP_FSAPPLY_RO(func) \ + ATF_TP_FSADD(ext2fs,func); \ + ATF_TP_FSADD(ffs,func); \ + ATF_TP_FSADD(ffslog,func); \ + ATF_TP_FSADD(msdosfs,func); \ + ATF_TP_FSADD(nfs,func); \ + ATF_TP_FSADD(nfsro,func); \ + ATF_TP_FSADD(sysvbfs,func); \ + ATF_TP_FSADD(udf,func); \ + ATF_TP_FSADD(v7fs,func); + +#define ATF_FSAPPLY(func,desc) \ + ATF_TC_FSAPPLY(func,desc); \ + ATF_TP_ADD_TCS(tp) \ + { \ + ATF_TP_FSAPPLY(func); \ + return atf_no_error(); \ + } + +static __inline bool +atf_check_fstype(const atf_tc_t *tc, const char *fs) +{ + const char *fstype; + + if (!atf_tc_has_config_var(tc, "fstype")) + return true; + + fstype = atf_tc_get_config_var(tc, "fstype"); + if (strcmp(fstype, fs) == 0) + return true; + return false; +} + +#define FSTYPE_EXT2FS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ext2fs") == 0) +#define FSTYPE_FFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ffs") == 0) +#define FSTYPE_FFSLOG(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ffslog") == 0) +#define FSTYPE_LFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "lfs") == 0) +#define FSTYPE_MSDOS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "msdosfs") == 0) +#define FSTYPE_NFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "nfs") == 0) +#define FSTYPE_NFSRO(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "nfsro") == 0) +#define FSTYPE_P2K_FFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "p2k_ffs") == 0) +#define FSTYPE_PUFFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "puffs") == 0) +#define FSTYPE_RUMPFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "rumpfs") == 0) +#define FSTYPE_SYSVBFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "sysvbfs") == 0) +#define FSTYPE_TMPFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "tmpfs") == 0) +#define FSTYPE_UDF(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "udf") == 0) +#define FSTYPE_V7FS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "v7fs") == 0) +#define FSTYPE_ZFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "zfs") == 0) + +#define FSTEST_ENTER() \ + if (rump_sys_chdir(FSTEST_MNTNAME) == -1) \ + atf_tc_fail_errno("failed to cd into test mount") + +#define FSTEST_EXIT() \ + if (rump_sys_chdir("/") == -1) \ + atf_tc_fail_errno("failed to cd out of test mount") + +/* + * file system args structures + */ + +struct nfstestargs { + pid_t ta_childpid; + char ta_ethername[MAXPATHLEN]; +}; + +struct puffstestargs { + uint8_t *pta_pargs; + size_t pta_pargslen; + + int pta_pflags; + pid_t pta_childpid; + + int pta_rumpfd; + int pta_servfd; + + char pta_dev[MAXPATHLEN]; + char pta_dir[MAXPATHLEN]; + + int pta_mntflags; + + int pta_vfs_toserv_ops[PUFFS_VFS_MAX]; + int pta_vn_toserv_ops[PUFFS_VN_MAX]; +}; + +#endif /* __H_FSMACROS_H_ */ diff --git a/contrib/netbsd-tests/fs/common/snapshot.c b/contrib/netbsd-tests/fs/common/snapshot.c new file mode 100644 index 000000000000..7baf611b6ed6 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/snapshot.c @@ -0,0 +1,228 @@ +/* $NetBSD: snapshot.c,v 1.7 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +ATF_TC_WITH_CLEANUP(snapshot); +ATF_TC_HEAD(snapshot, tc) +{ + + atf_tc_set_md_var(tc, "descr", "basic snapshot features"); +} + +static void +makefile(const char *path) +{ + int fd; + + fd = rump_sys_open(path, O_CREAT | O_RDWR, 0777); + if (fd == -1) + atf_tc_fail_errno("create %s", path); + rump_sys_close(fd); +} + +ATF_TC_BODY(snapshot, tc) +{ + char buf[1024]; + struct fss_set fss; + int fssfd; + int fd, fd2, i; + + if (system(NEWFS) == -1) + atf_tc_fail_errno("cannot create file system"); + + rump_init(); + begin(); + + if (rump_sys_mkdir("/mnt", 0777) == -1) + atf_tc_fail_errno("mount point create"); + if (rump_sys_mkdir("/snap", 0777) == -1) + atf_tc_fail_errno("mount point 2 create"); + + rump_pub_etfs_register("/diskdev", IMGNAME, RUMP_ETFS_BLK); + + mount_diskfs("/diskdev", "/mnt"); + +#define TESTSTR1 "huihai\n" +#define TESTSZ1 (sizeof(TESTSTR1)-1) +#define TESTSTR2 "baana liten\n" +#define TESTSZ2 (sizeof(TESTSTR2)-1) + + fd = rump_sys_open("/mnt/myfile", O_RDWR | O_CREAT, 0777); + if (fd == -1) + atf_tc_fail_errno("create file"); + if (rump_sys_write(fd, TESTSTR1, TESTSZ1) != TESTSZ1) + atf_tc_fail_errno("write fail"); + + fssfd = rump_sys_open("/dev/rfss0", O_RDWR); + if (fssfd == -1) + atf_tc_fail_errno("cannot open fss"); + makefile(BAKNAME); + memset(&fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST("/mnt"); + fss.fss_bstore = __UNCONST(BAKNAME); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) + atf_tc_fail_errno("create snapshot"); + + for (i = 0; i < 10000; i++) { + if (rump_sys_write(fd, TESTSTR2, TESTSZ2) != TESTSZ2) + atf_tc_fail_errno("write fail"); + } + rump_sys_sync(); + + /* technically we should fsck it first? */ + mount_diskfs("/dev/fss0", "/snap"); + + /* check for old contents */ + fd2 = rump_sys_open("/snap/myfile", O_RDONLY); + if (fd2 == -1) + atf_tc_fail_errno("fail"); + memset(buf, 0, sizeof(buf)); + if (rump_sys_read(fd2, buf, sizeof(buf)) == -1) + atf_tc_fail_errno("read snap"); + ATF_CHECK(strcmp(buf, TESTSTR1) == 0); + + /* check that new files are invisible in the snapshot */ + makefile("/mnt/newfile"); + if (rump_sys_open("/snap/newfile", O_RDONLY) != -1) + atf_tc_fail("newfile exists in snapshot"); + if (errno != ENOENT) + atf_tc_fail_errno("newfile open should fail with ENOENT"); + + /* check that removed files are still visible in the snapshot */ + rump_sys_unlink("/mnt/myfile"); + if (rump_sys_open("/snap/myfile", O_RDONLY) == -1) + atf_tc_fail_errno("unlinked file no longer in snapshot"); + + /* done for now */ +} + +ATF_TC_CLEANUP(snapshot, tc) +{ + + unlink(IMGNAME); +} + +ATF_TC_WITH_CLEANUP(snapshotstress); +ATF_TC_HEAD(snapshotstress, tc) +{ + + atf_tc_set_md_var(tc, "descr", "snapshot on active file system"); +} + +#define NACTIVITY 4 + +static bool activity_stop = false; +static pid_t wrkpid; + +static void * +fs_activity(void *arg) +{ + int di, fi; + char *prefix = arg, path[128]; + + rump_pub_lwproc_newlwp(wrkpid); + + RL(rump_sys_mkdir(prefix, 0777)); + while (! activity_stop) { + for (di = 0; di < 5; di++) { + snprintf(path, sizeof(path), "%s/d%d", prefix, di); + RL(rump_sys_mkdir(path, 0777)); + for (fi = 0; fi < 5; fi++) { + snprintf(path, sizeof(path), "%s/d%d/f%d", + prefix, di, fi); + makefile(path); + } + } + for (di = 0; di < 5; di++) { + for (fi = 0; fi < 5; fi++) { + snprintf(path, sizeof(path), "%s/d%d/f%d", + prefix, di, fi); + RL(rump_sys_unlink(path)); + } + snprintf(path, sizeof(path), "%s/d%d", prefix, di); + RL(rump_sys_rmdir(path)); + } + } + RL(rump_sys_rmdir(prefix)); + + rump_pub_lwproc_releaselwp(); + + return NULL; +} + +ATF_TC_BODY(snapshotstress, tc) +{ + pthread_t at[NACTIVITY]; + struct fss_set fss; + char prefix[NACTIVITY][128]; + int i, fssfd; + + if (system(NEWFS) == -1) + atf_tc_fail_errno("cannot create file system"); + /* Force SMP so the stress makes sense. */ + RL(setenv("RUMP_NCPU", "4", 1)); + RZ(rump_init()); + /* Prepare for fsck to use the RUMP /dev/fss0. */ + RL(rump_init_server("unix://commsock")); + RL(setenv("LD_PRELOAD", "/usr/lib/librumphijack.so", 1)); + RL(setenv("RUMP_SERVER", "unix://commsock", 1)); + RL(setenv("RUMPHIJACK", "blanket=/dev/rfss0", 1)); + begin(); + + RL(rump_sys_mkdir("/mnt", 0777)); + + rump_pub_etfs_register("/diskdev", IMGNAME, RUMP_ETFS_BLK); + + mount_diskfs("/diskdev", "/mnt"); + + /* Start file system activity. */ + RL(wrkpid = rump_sys_getpid()); + for (i = 0; i < NACTIVITY; i++) { + snprintf(prefix[i], sizeof(prefix[i]), "/mnt/a%d", i); + RL(pthread_create(&at[i], NULL, fs_activity, prefix[i])); + sleep(1); + } + + fssfd = rump_sys_open("/dev/rfss0", O_RDWR); + if (fssfd == -1) + atf_tc_fail_errno("cannot open fss"); + makefile(BAKNAME); + memset(&fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST("/mnt"); + fss.fss_bstore = __UNCONST(BAKNAME); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) + atf_tc_fail_errno("create snapshot"); + + activity_stop = true; + for (i = 0; i < NACTIVITY; i++) + RL(pthread_join(at[i], NULL)); + + RL(system(FSCK " /dev/rfss0")); +} + +ATF_TC_CLEANUP(snapshotstress, tc) +{ + + unlink(IMGNAME); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, snapshot); + ATF_TP_ADD_TC(tp, snapshotstress); + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/ffs_common.sh b/contrib/netbsd-tests/fs/ffs/ffs_common.sh new file mode 100755 index 000000000000..eaf7142808a1 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/ffs_common.sh @@ -0,0 +1,99 @@ +# $NetBSD: ffs_common.sh,v 1.2 2013/07/29 13:15:24 skrll Exp $ + +create_ffs() +{ + local endian=$1; shift + local vers=$1; shift + local type=$1; shift + local op; + if [ ${type} = "both" ]; then + op="-q user -q group" + else + op="-q ${type}" + fi + atf_check -o ignore -e ignore newfs ${op} \ + -B ${endian} -O ${vers} -s 4000 -F ${IMG} +} + +create_ffs_server() +{ + local sarg=$1; shift + create_ffs $* + atf_check -o ignore -e ignore $(atf_get_srcdir)/h_ffs_server \ + ${sarg} ${IMG} ${RUMP_SERVER} +} + +rump_shutdown() +{ + for s in ${RUMP_SOCKETS_LIST}; do + atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt; + done +# check that the quota inode creation didn't corrupt the filesystem + atf_check -s exit:0 -o "match:already clean" \ + -o "match:Phase 6 - Check Quotas" \ + fsck_ffs -nf -F ${IMG} +} + +# from tests/ipf/h_common.sh via tests/sbin/resize_ffs +test_case() +{ + local name="${1}"; shift + local check_function="${1}"; shift + local descr="${1}"; shift + + atf_test_case "${name}" cleanup + + eval "${name}_head() { \ + atf_set "descr" "${descr}" + atf_set "timeout" "60" + }" + eval "${name}_body() { \ + RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ + export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ + ${check_function} " "${@}" "; \ + }" + eval "${name}_cleanup() { \ + for s in \${RUMP_SOCKETS_LIST}; do \ + export RUMP_SERVER=unix://\${s}; \ + atf_check -s exit:1 -o ignore -e ignore rump.halt; \ + done; \ + }" + tests="${tests} ${name}" +} + +test_case_root() +{ + local name="${1}"; shift + local check_function="${1}"; shift + local descr="${1}"; shift + + atf_test_case "${name}" cleanup + + eval "${name}_head() { \ + atf_set "descr" "${descr}" + atf_set "require.user" "root" + atf_set "timeout" "360" + }" + eval "${name}_body() { \ + RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ + export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ + ${check_function} " "${@}" "; \ + }" + eval "${name}_cleanup() { \ + for s in \${RUMP_SOCKETS_LIST}; do \ + export RUMP_SERVER=unix://\${s}; \ + atf_check -s exit:1 -o ignore -e ignore rump.halt; \ + done; \ + }" + tests="${tests} ${name}" +} + +atf_init_test_cases() +{ + IMG=fsimage + DIR=target + RUMP_SOCKET=test; + for i in ${tests}; do + atf_add_test_case $i + done +} diff --git a/contrib/netbsd-tests/fs/ffs/h_ffs_server.c b/contrib/netbsd-tests/fs/ffs/h_ffs_server.c new file mode 100644 index 000000000000..dd22d9faf1d8 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/h_ffs_server.c @@ -0,0 +1,113 @@ +/* $NetBSD: h_ffs_server.c,v 1.2 2012/08/24 20:25:50 jmmv Exp $ */ + +/* + * rump server for advanced quota tests + */ + +#include "../common/h_fsmacros.h" + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +int background = 0; + +static void +usage(void) +{ + fprintf(stderr, "usage: %s [-b] [-l] diskimage bindurl\n", + getprogname()); + exit(1); +} + +static void +die(const char *reason, int error) +{ + + warnx("%s: %s", reason, strerror(error)); + if (background) + rump_daemonize_done(error); + exit(1); +} + +static sem_t sigsem; +static void +sigreboot(int sig) +{ + + sem_post(&sigsem); +} + +int +main(int argc, char **argv) +{ + int error; + struct ufs_args uargs; + const char *filename; + const char *serverurl; + int log = 0; + int ch; + + while ((ch = getopt(argc, argv, "bl")) != -1) { + switch(ch) { + case 'b': + background = 1; + break; + case 'l': + log = 1; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 2) + usage(); + + filename = argv[0]; + serverurl = argv[1]; + + if (background) { + error = rump_daemonize_begin(); + if (error) + errx(1, "rump daemonize: %s", strerror(error)); + } + + error = rump_init(); + if (error) + die("rump init failed", error); + + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + die("mount point create", errno); + rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK); + uargs.fspec = __UNCONST("/diskdev"); + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0, + &uargs, sizeof(uargs)) == -1) + die("mount ffs", errno); + + error = rump_init_server(serverurl); + if (error) + die("rump server init failed", error); + if (background) + rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS); + + sem_init(&sigsem, 0, 0); + signal(SIGTERM, sigreboot); + signal(SIGINT, sigreboot); + sem_wait(&sigsem); + + rump_sys_reboot(0, NULL); + /*NOTREACHED*/ + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c b/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c new file mode 100644 index 000000000000..59f3ea3b0917 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c @@ -0,0 +1,468 @@ +/* $NetBSD: h_quota2_tests.c,v 1.4 2012/09/30 21:26:57 bouyer Exp $ */ + +/* + * rump server for advanced quota tests + * this one includes functions to run against the filesystem before + * starting to handle rump requests from clients. + */ + +#include "../common/h_fsmacros.h" + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include "../../h_macros.h" + +int background = 0; + +#define TEST_NONROOT_ID 1 + +static int +quota_test0(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + unsigned int i; + int chowner = 1; + for (i =0; testopts && i < strlen(testopts); i++) { + switch(testopts[i]) { + case 'C': + chowner = 0; + break; + default: + errx(1, "test4: unknown option %c", testopts[i]); + } + } + if (chowner) + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + fd = rump_sys_open("test_fillup", O_CREAT | O_RDWR, 0644); + if (fd < 0) { + error = errno; + warn("rump_sys_open"); + } else { + while (rump_sys_write(fd, buf, sizeof(buf)) == sizeof(buf)) + error = 0; + error = errno; + } + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test1(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + fd = rump_sys_open("test_fillup", O_CREAT | O_RDWR, 0644); + if (fd < 0) { + error = errno; + warn("rump_sys_open"); + } else { + /* + * write up to the soft limit, wait a bit, an try to + * keep on writing + */ + int i; + + /* write 2k: with the directory this makes 2.5K */ + for (i = 0; i < 4; i++) { + error = rump_sys_write(fd, buf, sizeof(buf)); + if (error != sizeof(buf)) + err(1, "write failed early"); + } + sleep(2); + /* now try to write an extra .5k */ + if (rump_sys_write(fd, buf, sizeof(buf)) != sizeof(buf)) + error = errno; + else + error = 0; + } + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test2(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + int i; + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + + for (i = 0; ; i++) { + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0644); + if (fd < 0) + break; + sprintf(buf, "test file no %d", i); + rump_sys_write(fd, buf, strlen(buf)); + rump_sys_close(fd); + } + error = errno; + + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test3(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + int i; + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + + /* + * create files one past the soft limit: one less as we already own the + * root directory + */ + for (i = 0; i < 4; i++) { + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + err(1, "file create failed early"); + sprintf(buf, "test file no %d", i); + rump_sys_write(fd, buf, strlen(buf)); + rump_sys_close(fd); + } + /* now create an extra file after grace time: this should fail */ + sleep(2); + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + error = errno; + else + error = 0; + + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test4(const char *testopts) +{ + static char buf[512]; + int fd, fssfd; + struct fss_set fss; + unsigned int i; + int unl=0; + int unconf=0; + + /* + * take an internal snapshot of the filesystem, and create a new + * file with some data + */ + rump_sys_chown(".", 0, 0); + rump_sys_chmod(".", 0777); + + for (i =0; testopts && i < strlen(testopts); i++) { + switch(testopts[i]) { + case 'L': + unl++; + break; + case 'C': + unconf++; + break; + default: + errx(1, "test4: unknown option %c", testopts[i]); + } + } + + /* first create the snapshot */ + + fd = rump_sys_open(FSTEST_MNTNAME "/le_snap", O_CREAT | O_RDWR, 0777); + if (fd == -1) + err(1, "create " FSTEST_MNTNAME "/le_snap"); + rump_sys_close(fd); + fssfd = rump_sys_open("/dev/rfss0", O_RDWR); + if (fssfd == -1) + err(1, "cannot open fss"); + memset(&fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST("/mnt"); + fss.fss_bstore = __UNCONST(FSTEST_MNTNAME "/le_snap"); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) + err(1, "create snapshot"); + if (unl) { + if (rump_sys_unlink(FSTEST_MNTNAME "/le_snap") == -1) + err(1, "unlink snapshot"); + } + + /* now create some extra files */ + + for (i = 0; i < 4; i++) { + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + err(1, "create %s", buf); + sprintf(buf, "test file no %d", i); + rump_sys_write(fd, buf, strlen(buf)); + rump_sys_close(fd); + } + if (unconf) + if (rump_sys_ioctl(fssfd, FSSIOCCLR, NULL) == -1) + err(1, "unconfigure snapshot"); + return 0; +} + +static int +quota_test5(const char *testopts) +{ + static char buf[512]; + int fd; + int remount = 0; + int unlnk = 0; + int log = 0; + unsigned int i; + + for (i =0; testopts && i < strlen(testopts); i++) { + switch(testopts[i]) { + case 'L': + log++; + break; + case 'R': + remount++; + break; + case 'U': + unlnk++; + break; + default: + errx(1, "test4: unknown option %c", testopts[i]); + } + } + if (remount) { + struct ufs_args uargs; + uargs.fspec = __UNCONST("/diskdev"); + /* remount the fs read/write */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, + MNT_UPDATE | (log ? MNT_LOG : 0), + &uargs, sizeof(uargs)) == -1) + err(1, "mount ffs rw %s", FSTEST_MNTNAME); + } + + if (unlnk) { + /* + * open and unlink a file + */ + + fd = rump_sys_open("unlinked_file", + O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + err(1, "create %s", "unlinked_file"); + sprintf(buf, "test unlinked_file"); + rump_sys_write(fd, buf, strlen(buf)); + if (rump_sys_unlink("unlinked_file") == -1) + err(1, "unlink unlinked_file"); + if (rump_sys_fsync(fd) == -1) + err(1, "fsync unlinked_file"); + rump_sys_reboot(RUMP_RB_NOSYNC, NULL); + errx(1, "reboot failed"); + return 1; + } + return 0; +} + +struct quota_test { + int (*func)(const char *); + const char *desc; +}; + +struct quota_test quota_tests[] = { + { quota_test0, "write up to hard limit"}, + { quota_test1, "write beyond the soft limit after grace time"}, + { quota_test2, "create file up to hard limit"}, + { quota_test3, "create file beyond the soft limit after grace time"}, + { quota_test4, "take a snapshot and add some data"}, + { quota_test5, "open and unlink a file"}, +}; + +static void +usage(void) +{ + unsigned int test; + fprintf(stderr, "usage: %s [-b] [-l] test# diskimage bindurl\n", + getprogname()); + fprintf(stderr, "available tests:\n"); + for (test = 0; test < sizeof(quota_tests) / sizeof(quota_tests[0]); + test++) + fprintf(stderr, "\t%d: %s\n", test, quota_tests[test].desc); + exit(1); +} + +static void +die(const char *reason, int error) +{ + + warnx("%s: %s", reason, strerror(error)); + if (background) + rump_daemonize_done(error); + exit(1); +} + +static sem_t sigsem; +static void +sigreboot(int sig) +{ + + sem_post(&sigsem); +} + +int +main(int argc, char **argv) +{ + int error; + u_long test; + char *end; + struct ufs_args uargs; + const char *filename; + const char *serverurl; + const char *topts = NULL; + int mntopts = 0; + int ch; + + while ((ch = getopt(argc, argv, "blo:r")) != -1) { + switch(ch) { + case 'b': + background = 1; + break; + case 'l': + mntopts |= MNT_LOG; + break; + case 'r': + mntopts |= MNT_RDONLY; + break; + case 'o': + topts = optarg; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 3) + usage(); + + filename = argv[1]; + serverurl = argv[2]; + + test = strtoul(argv[0], &end, 10); + if (*end != '\0') { + usage(); + } + if (test > sizeof(quota_tests) / sizeof(quota_tests[0])) { + usage(); + } + + if (background) { + error = rump_daemonize_begin(); + if (error) + errx(1, "rump daemonize: %s", strerror(error)); + } + + error = rump_init(); + if (error) + die("rump init failed", error); + + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + err(1, "mount point create"); + rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK); + uargs.fspec = __UNCONST("/diskdev"); + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, mntopts, + &uargs, sizeof(uargs)) == -1) + die("mount ffs", errno); + + if (rump_sys_chdir(FSTEST_MNTNAME) == -1) + err(1, "cd %s", FSTEST_MNTNAME); + error = quota_tests[test].func(topts); + if (error) { + fprintf(stderr, " test %lu: %s returned %d: %s\n", + test, quota_tests[test].desc, error, strerror(error)); + } + if (rump_sys_chdir("/") == -1) + err(1, "cd /"); + + error = rump_init_server(serverurl); + if (error) + die("rump server init failed", error); + if (background) + rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS); + + sem_init(&sigsem, 0, 0); + signal(SIGTERM, sigreboot); + signal(SIGINT, sigreboot); + sem_wait(&sigsem); + + rump_sys_reboot(0, NULL); + /*NOTREACHED*/ + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/quotas_common.sh b/contrib/netbsd-tests/fs/ffs/quotas_common.sh new file mode 100755 index 000000000000..0ad002f54ad5 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/quotas_common.sh @@ -0,0 +1,12 @@ +# $NetBSD: quotas_common.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ + +rump_quota_shutdown() +{ + for s in ${RUMP_SOCKETS_LIST}; do + atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt; + done +# check that the quota inode creation didn't corrupt the filesystem + atf_check -s exit:0 -o "match:already clean" \ + -o "match:Phase 6 - Check Quotas" \ + fsck_ffs -nf -F ${IMG} +} diff --git a/contrib/netbsd-tests/fs/ffs/t_clearquota.sh b/contrib/netbsd-tests/fs/ffs/t_clearquota.sh new file mode 100755 index 000000000000..f62a494730cd --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_clearquota.sh @@ -0,0 +1,91 @@ +# $NetBSD: t_clearquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +for e in le be; do + for v in 1 2; do + for q in "user" "group"; do + test_case_root clear_${e}_${v}_${q} clear_quota \ + "clear quota with ${q} enabled" -b ${e} ${v} ${q} + done + test_case_root clear_${e}_${v}_"both" clear_quota \ + "clear quota with both enabled" -b ${e} ${v} "both" + test_case_root clear_${e}_${v}_"both_log" clear_quota \ + "clear quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" + done +done + +clear_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#set and check the expected quota + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 2W/3D ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2weeks 0 20 51200 3days" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done +#now clear the quotas + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -c ${id} + done; + +#check that we do not get positive reply for any quota type + for q in u g ; do + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_fifos.c b/contrib/netbsd-tests/fs/ffs/t_fifos.c new file mode 100644 index 000000000000..fe1d4254a352 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_fifos.c @@ -0,0 +1,158 @@ +/* $NetBSD: t_fifos.c,v 1.5 2010/11/07 17:51:17 jmmv Exp $ */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC_WITH_CLEANUP(fifos); +ATF_TC_HEAD(fifos, tc) +{ + atf_tc_set_md_var(tc, "descr", "test fifo support in ffs"); + atf_tc_set_md_var(tc, "timeout", "5"); +} + +#define teststr1 "raving & drooling" +#define teststr2 "haha, charade" + +static void * +w1(void *arg) +{ + int fd; + + fd = rump_sys_open("sheep", O_WRONLY); + if (fd == -1) + atf_tc_fail_errno("w1 open"); + if (rump_sys_write(fd, teststr1, sizeof(teststr1)) != sizeof(teststr1)) + atf_tc_fail_errno("w1 write"); + rump_sys_close(fd); + + return NULL; +} + +static void * +w2(void *arg) +{ + int fd; + + fd = rump_sys_open("pigs", O_WRONLY); + if (fd == -1) + atf_tc_fail_errno("w2 open"); + if (rump_sys_write(fd, teststr2, sizeof(teststr2)) != sizeof(teststr2)) + atf_tc_fail_errno("w2 write"); + rump_sys_close(fd); + + return NULL; +} + +static void * +r1(void *arg) +{ + char buf[32]; + int fd; + + fd = rump_sys_open("sheep", O_RDONLY); + if (fd == -1) + atf_tc_fail_errno("r1 open"); + if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(teststr1)) + atf_tc_fail_errno("r1 read"); + rump_sys_close(fd); + + if (strcmp(teststr1, buf) != 0) + atf_tc_fail("got invalid str, %s vs. %s", buf, teststr1); + + return NULL; +} + +static void * +r2(void *arg) +{ + char buf[32]; + int fd; + + fd = rump_sys_open("pigs", O_RDONLY); + if (fd == -1) + atf_tc_fail_errno("r2 open"); + if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(teststr2)) + atf_tc_fail_errno("r2 read"); + rump_sys_close(fd); + + if (strcmp(teststr2, buf) != 0) + atf_tc_fail("got invalid str, %s vs. %s", buf, teststr2); + + return NULL; +} + +#define IMGNAME "atf.img" + +const char *newfs = "newfs -F -s 10000 " IMGNAME; +#define FAKEBLK "/dev/sp00ka" + +ATF_TC_BODY(fifos, tc) +{ + struct ufs_args args; + pthread_t ptw1, ptw2, ptr1, ptr2; + + if (system(newfs) == -1) + atf_tc_fail_errno("newfs failed"); + + memset(&args, 0, sizeof(args)); + args.fspec = __UNCONST(FAKEBLK); + + rump_init(); + if (rump_sys_mkdir("/animals", 0777) == -1) + atf_tc_fail_errno("cannot create mountpoint"); + rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK); + if (rump_sys_mount(MOUNT_FFS, "/animals", 0, &args, sizeof(args))==-1) + atf_tc_fail_errno("rump_sys_mount failed"); + + /* create fifos */ + if (rump_sys_chdir("/animals") == 1) + atf_tc_fail_errno("chdir"); + if (rump_sys_mkfifo("pigs", S_IFIFO | 0777) == -1) + atf_tc_fail_errno("mknod1"); + if (rump_sys_mkfifo("sheep", S_IFIFO | 0777) == -1) + atf_tc_fail_errno("mknod2"); + + pthread_create(&ptw1, NULL, w1, NULL); + pthread_create(&ptw2, NULL, w2, NULL); + pthread_create(&ptr1, NULL, r1, NULL); + pthread_create(&ptr2, NULL, r2, NULL); + + pthread_join(ptw1, NULL); + pthread_join(ptw2, NULL); + pthread_join(ptr1, NULL); + pthread_join(ptr2, NULL); + + if (rump_sys_chdir("/") == 1) + atf_tc_fail_errno("chdir"); + + if (rump_sys_unmount("/animals", 0) == -1) + atf_tc_fail_errno("unmount failed"); +} + +ATF_TC_CLEANUP(fifos, tc) +{ + + unlink(IMGNAME); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, fifos); + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/t_getquota.sh b/contrib/netbsd-tests/fs/ffs/t_getquota.sh new file mode 100755 index 000000000000..80f3cc7a6e76 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_getquota.sh @@ -0,0 +1,112 @@ +# $NetBSD: t_getquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +for e in le be; do + for v in 1 2; do + for q in "user" "group"; do + test_case get_${e}_${v}_${q} get_quota \ + "get quota with ${q} enabled" -b ${e} ${v} ${q} + done + test_case get_${e}_${v}_"both" get_quota \ + "get quota with both enabled" -b ${e} ${v} "both" + done +done + +get_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can get the expected quota + for q in ${expect} ; do + atf_check -s exit:0 \ +-o "match:/mnt 0 - - 7days 1 - - 7days" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "match:-- 0 - - 1 - -" \ +-o "not-match:\+\+" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "not-match:-- 0 - - 1 - -" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + rump_quota_shutdown +} + +quota_walk_list() +{ + create_ffs_server $* + local q=$4 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac +} diff --git a/contrib/netbsd-tests/fs/ffs/t_miscquota.sh b/contrib/netbsd-tests/fs/ffs/t_miscquota.sh new file mode 100755 index 000000000000..904ea37f8f6c --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_miscquota.sh @@ -0,0 +1,213 @@ +# $NetBSD: t_miscquota.sh,v 1.8 2013/01/22 06:24:11 dholland Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +test_case_root walk_list_user quota_walk_list \ + "walk user quota list over several disk blocks" -b le 1 user + +test_case_root psnapshot_user quota_snap \ + "create a persistent shapshot of quota-enabled fs, and do some writes" \ + -b le 1 user + +test_case_root npsnapshot_user quota_snap \ + "create a non-persistent shapshot of quota-enabled fs, and do some writes" \ + -boL le 1 user + +test_case_root psnapshot_unconf_user quota_snap \ + "create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \ + -boC le 1 user + +test_case_root npsnapshot_unconf_user quota_snap \ + "create a non-persistent shapshot of quota-enabled fs, and do some writes and unconf" \ + -boLC le 1 user + +test_case log_unlink quota_log \ + "an unlinked file cleaned by the log replay should update quota" \ + -l le 1 user + +test_case log_unlink_remount quota_log \ + "an unlinked file cleaned by the log replay after remount" \ + -oRL le 1 user + + +test_case_root default_deny_user quota_default_deny \ + "new quota entry denied by default entry" 5 -b le 1 user + +test_case_root default_deny_user_big quota_default_deny \ + "new quota entry denied by default entry, with list on more than one block" 5000 -b le 1 user + + +quota_walk_list() +{ + create_ffs_server $* + local q=$4 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + # create 100 users, all in the same hash list + local i=1; + while [ $i -lt 101 ]; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \ + -s10k/20 -h40M/50k -t 2W/3D $((i * 4096)) + i=$((i + 1)) + done + # do a repquota + atf_check -s exit:0 -o 'match:user 409600 block *81920 20 0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt + rump_quota_shutdown +} + +quota_snap() +{ + local flag=$1; shift + create_ffs $* + local q=$3 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + #start our server which takes a snapshot + atf_check -s exit:0 -o ignore \ + $(atf_get_srcdir)/h_quota2_tests ${flag} 4 ${IMG} ${RUMP_SERVER} + # create a few users + local i=1; + while [ $i -lt 11 ]; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \ + -s10k/20 -h40M/50k -t 2W/3D $i + i=$((i + 1)) + done + # we should have 5 files (root + 4 regular files) + atf_check -s exit:0 \ + -o 'match:- - 7days 5 - - 7days' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -av + #shutdown and check filesystem + rump_quota_shutdown +} + +quota_log() +{ + local srv2args=$1; shift + create_ffs $* + local q=$3 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + #start our server which create a file and unlink while keeping + # it open. The server halts itself without flush + atf_check -s exit:0 -o ignore \ + $(atf_get_srcdir)/h_quota2_tests -loU 5 ${IMG} ${RUMP_SERVER} + # we should have one unlinked file, but the log covers it. + atf_check -s exit:0 -o match:'3 files' -e ignore \ + fsck_ffs -nf -F ${IMG} + # have a kernel mount the fs again; it should cleanup the + # unlinked file + atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \ + ${srv2args} -b 5 ${IMG} ${RUMP_SERVER} + #shutdown and check filesystem + rump_quota_shutdown +} + +quota_default_deny() +{ + local nusers=$1; shift + create_ffs_server $* + local q=$4 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + # create $nusers users, so we are sure the free list has entries + # from block 1. Start from 10, as non-root id is 1. + # set default to deny all + ( echo "@format netbsd-quota-dump v1" + echo "# idtype id objtype hard soft usage expire grace" + echo "$q default block 0 0 0 0 0" + echo "$q default file 0 0 0 0 0" + local i=10; + while [ $i -lt $(($nusers + 10)) ]; do + echo "$q $i block 0 0 0 0 0" + echo "$q $i file 0 0 0 0 0" + i=$((i + 1)) + done + ) | atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quotarestore -d /mnt + atf_check -s exit:0 rump.halt + #now start the server which does the limits tests + $(atf_get_srcdir)/h_quota2_tests -oC -b 0 ${IMG} ${RUMP_SERVER} + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_mount.c b/contrib/netbsd-tests/fs/ffs/t_mount.c new file mode 100644 index 000000000000..6a8f74f455f8 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_mount.c @@ -0,0 +1,138 @@ +/* $NetBSD: t_mount.c,v 1.13 2012/11/27 16:01:49 jakllsch Exp $ */ + +/* + * Basic tests for mounting + */ + +/* + * 48Kimage: + * Adapted for rump and atf from a testcase supplied + * by Hubert Feyrer on netbsd-users@ + */ + +#include + +#define FSTEST_IMGSIZE (96 * 512) +#include "../common/h_fsmacros.h" + +#include +#include + +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +ATF_TC(48Kimage); +ATF_TC_HEAD(48Kimage, tc) +{ + atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image"); +} + +ATF_TC_BODY(48Kimage, tc) +{ + void *tmp; + + atf_tc_expect_fail("PR kern/43573"); + FSTEST_CONSTRUCTOR(tc, ffs, tmp); + atf_tc_expect_pass(); + + FSTEST_DESTRUCTOR(tc, ffs, tmp); +} + +ATF_TC(fsbsizeovermaxphys); +ATF_TC_HEAD(fsbsizeovermaxphys, tc) +{ + + atf_tc_set_md_var(tc, "descr", "mounts file system with " + "blocksize > MAXPHYS"); + /* PR kern/43727 */ +} + +ATF_TC_BODY(fsbsizeovermaxphys, tc) +{ + char cmd[1024]; + struct ufs_args args; + struct statvfs svb; + + /* + * We cannot pass newfs parameters via the fstest interface, + * so do things the oldfashioned manual way. + */ + snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 " + "ffs.img > /dev/null", MAXPHYS * 2); + if (system(cmd)) + atf_tc_fail("cannot create file system"); + + rump_init(); + if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK)) + atf_tc_fail("cannot register rump fake device"); + + args.fspec = __UNCONST("/devdisk"); + + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("create mountpoint"); + + /* mount succeeded? bad omen. confirm we're in trouble. */ + if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) { + rump_sys_statvfs1("/mp", &svb, ST_WAIT); + atf_tc_fail("not expecting to be alive"); + } + + /* otherwise we're do-ne */ +} + +ATF_TC(fsbsizeovermaxbsize); +ATF_TC_HEAD(fsbsizeovermaxbsize, tc) +{ + + atf_tc_set_md_var(tc, "descr", "mounts file system with " + "blocksize > MAXBSIZE"); +} + +ATF_TC_BODY(fsbsizeovermaxbsize, tc) +{ + char cmd[1024]; + struct ufs_args args; + struct statvfs svb; + + /* + * We cannot pass newfs parameters via the fstest interface, + * so do things the oldfashioned manual way. + */ + snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 " + "ffs.img > /dev/null", MAXBSIZE * 2); + if (system(cmd)) + atf_tc_fail("cannot create file system"); + + rump_init(); + if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK)) + atf_tc_fail("cannot register rump fake device"); + + args.fspec = __UNCONST("/devdisk"); + + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("create mountpoint"); + + /* mount succeeded? bad omen. confirm we're in trouble. */ + if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) { + rump_sys_statvfs1("/mp", &svb, ST_WAIT); + atf_tc_fail("not expecting to be alive"); + } + + /* otherwise we're do-ne */ +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, 48Kimage); + ATF_TP_ADD_TC(tp, fsbsizeovermaxphys); + ATF_TP_ADD_TC(tp, fsbsizeovermaxbsize); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/t_quota2_1.c b/contrib/netbsd-tests/fs/ffs/t_quota2_1.c new file mode 100644 index 000000000000..333f3c712708 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_quota2_1.c @@ -0,0 +1,114 @@ +/* $NetBSD: t_quota2_1.c,v 1.4 2012/03/15 02:02:22 joerg Exp $ */ + +/* + * Basic tests for quota2 + */ + +#include + +#include "../common/h_fsmacros.h" + +#include +#include + +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +static void +do_quota(const atf_tc_t *tc, int n, const char *newfs_opts, int log) +{ + int i; + char buf[1024]; + int res; + int fd; + struct ufs_args uargs; + + snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d " + "%s %s", (n + 3), newfs_opts, FSTEST_IMGNAME); + if (system(buf) == -1) + atf_tc_fail_errno("cannot create file system"); + + rump_init(); + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + atf_tc_fail_errno("mount point create"); + + rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK); + + uargs.fspec = __UNCONST("/diskdev"); + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0, + &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", FSTEST_MNTNAME); + + atf_tc_expect_pass(); + FSTEST_ENTER(); + RL(rump_sys_chown(".", 0, 0)); + for (i = 0 ; i < n; i++) { + sprintf(buf, "file%d", i); + RL(fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0755)); + sprintf(buf, "test file no %d", i); + RL(rump_sys_write(fd, buf, strlen(buf))); + RL(rump_sys_fchown(fd, i, i+80000)); + rump_sys_close(fd); + } + FSTEST_EXIT(); + if (rump_sys_unmount(FSTEST_MNTNAME, 0) != 0) { + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); + atf_tc_fail_errno("unmount failed"); + } + snprintf(buf, 1024, "fsck_ffs -fn -F %s", FSTEST_IMGNAME); + res = system(buf); + if (res != 0) + atf_tc_fail("fsck returned %d", res); +} + +#define DECL_TEST(nent, newops, name, descr, log) \ +ATF_TC(quota_##name); \ + \ +ATF_TC_HEAD(quota_##name, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", \ + "test quotas with %d users and groups, %s", \ + nent, descr); \ +} \ + \ +ATF_TC_BODY(quota_##name, tc) \ +{ \ + do_quota(tc, nent, newops, log); \ +} + +DECL_TEST(40, "-O1 -B le", 40_O1_le, "UFS1 little-endian", 0) +DECL_TEST(40, "-O1 -B be", 40_O1_be, "UFS1 big-endian", 0) + +DECL_TEST(40, "-O2 -B le", 40_O2_le, "UFS2 little-endian", 0) +DECL_TEST(40, "-O2 -B be", 40_O2_be, "UFS2 big-endian", 0) + +DECL_TEST(40, "-O1", 40_O1_log, "UFS1 log", 1) +DECL_TEST(40, "-O2", 40_O2_log, "UFS2 log", 1) + +DECL_TEST(1000, "-O1 -B le", 1000_O1_le, "UFS1 little-endian", 0) +DECL_TEST(1000, "-O1 -B be", 1000_O1_be, "UFS1 big-endian", 0) + +DECL_TEST(1000, "-O2 -B le", 1000_O2_le, "UFS2 little-endian", 0) +DECL_TEST(1000, "-O2 -B be", 1000_O2_be, "UFS2 big-endian", 0) + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, quota_40_O1_le); + ATF_TP_ADD_TC(tp, quota_40_O1_be); + ATF_TP_ADD_TC(tp, quota_40_O2_le); + ATF_TP_ADD_TC(tp, quota_40_O2_be); + ATF_TP_ADD_TC(tp, quota_40_O1_log); + ATF_TP_ADD_TC(tp, quota_40_O2_log); + ATF_TP_ADD_TC(tp, quota_1000_O1_le); + ATF_TP_ADD_TC(tp, quota_1000_O1_be); + ATF_TP_ADD_TC(tp, quota_1000_O2_le); + ATF_TP_ADD_TC(tp, quota_1000_O2_be); + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c b/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c new file mode 100644 index 000000000000..f648856bbf70 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c @@ -0,0 +1,139 @@ +/* $NetBSD: t_quota2_remount.c,v 1.4 2012/03/15 02:02:22 joerg Exp $ */ + +/* + * Basic tests for quota2 + */ + +#include + +#include "../common/h_fsmacros.h" + +#include +#include +#include + +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +static void +do_quota(const atf_tc_t *tc, int n, const char *newfs_opts, int log) +{ + int i; + char buf[1024]; + int res; + int fd; + struct ufs_args uargs; + struct statvfs fst; + + snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d " + "%s %s", (n + 3), newfs_opts, FSTEST_IMGNAME); + if (system(buf) == -1) + atf_tc_fail_errno("cannot create file system"); + + rump_init(); + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + atf_tc_fail_errno("mount point create"); + + rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK); + + uargs.fspec = __UNCONST("/diskdev"); + + /* read-only doens't have quota enabled */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_RDONLY, + &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs ro %s", FSTEST_MNTNAME); + + if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) + atf_tc_fail_errno("statbfs %s (1)", FSTEST_MNTNAME); + + if ((fst.f_flag & ST_QUOTA) != 0) + atf_tc_fail("R/O filesystem has quota"); + + /* updating to read-write enables quota */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, + MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs rw %s", FSTEST_MNTNAME); + + if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) + atf_tc_fail_errno("statbfs %s (2)", FSTEST_MNTNAME); + + if ((fst.f_flag & ST_QUOTA) == 0) + atf_tc_fail("R/W filesystem has no quota"); + + /* we can update a second time */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, + MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs rw(2) %s", FSTEST_MNTNAME); + + if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) + atf_tc_fail_errno("statbfs %s (3)", FSTEST_MNTNAME); + + if ((fst.f_flag & ST_QUOTA) == 0) + atf_tc_fail("R/W filesystem has no quota"); + + /* create some files so fsck has something to check */ + FSTEST_ENTER(); + RL(rump_sys_chown(".", 0, 0)); + for (i = 0 ; i < n; i++) { + sprintf(buf, "file%d", i); + RL(fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0755)); + sprintf(buf, "test file no %d", i); + RL(rump_sys_write(fd, buf, strlen(buf))); + RL(rump_sys_fchown(fd, i, i+80000)); + rump_sys_close(fd); + } + FSTEST_EXIT(); + if (rump_sys_unmount(FSTEST_MNTNAME, 0) != 0) { + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); + atf_tc_fail_errno("unmount failed"); + } + snprintf(buf, 1024, "fsck_ffs -fn -F %s", FSTEST_IMGNAME); + res = system(buf); + if (res != 0) + atf_tc_fail("fsck returned %d", res); +} + +#define DECL_TEST(nent, newops, name, descr, log) \ +ATF_TC(quota_##name); \ + \ +ATF_TC_HEAD(quota_##name, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", \ + "test filesystem remount with quotas, %s", descr); \ +} \ + \ +ATF_TC_BODY(quota_##name, tc) \ +{ \ + do_quota(tc, nent, newops, log); \ +} + +DECL_TEST(10, "-O1 -B le", 10_O1_le, "UFS1 little-endian", 0) +DECL_TEST(10, "-O1 -B be", 10_O1_be, "UFS1 big-endian", 0) + +#if 0 +/* + * this cause fsck to complain about summaries at the end. + * This sems to be related to -o log (reproductible on a fs with no + * quota enabled). not reproductible with a real kernel ... + */ +DECL_TEST(10, "-O1", 10_O1_log, "UFS1 log", 1) +DECL_TEST(10, "-O2", 10_O2_log, "UFS2 log", 1) +#endif + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, quota_10_O1_le); + ATF_TP_ADD_TC(tp, quota_10_O1_be); +#if 0 + ATF_TP_ADD_TC(tp, quota_10_O1_log); + ATF_TP_ADD_TC(tp, quota_10_O2_log); +#endif + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh b/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh new file mode 100755 index 000000000000..16e47b7a8fb8 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh @@ -0,0 +1,345 @@ +# $NetBSD: t_quotalimit.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +for e in le; do + for v in 1; do + for q in "user" "group"; do + test_case_root limit_${e}_${v}_${q} limit_quota \ + "hit hard limit quota with ${q} enabled" -b ${e} ${v} ${q} + test_case_root limit_${e}_${v}_${q}_log limit_quota \ + "hit hard limit quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q} + test_case_root slimit_${e}_${v}_${q} limit_softquota \ + "hit soft limit quota with ${q} enabled after grace time" \ + -b ${e} ${v} ${q} + test_case_root inolimit_${e}_${v}_${q} limit_iquota \ + "hit hard limit ino quota with ${q} enabled" -b ${e} ${v} ${q} + test_case_root inolimit_${e}_${v}_${q}_log limit_iquota \ + "hit hard limit ino quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q} + test_case_root sinolimit_${e}_${v}_${q} limit_softiquota \ + "hit soft limit ino quota with ${q} enabled after grace time" \ + -b ${e} ${v} ${q} + test_case_root herit_defq_${e}_${v}_${q} inherit_defaultquota \ + "new id herit from default for ${q} quota" -b ${e} ${v} ${q} + test_case_root herit_defq_${e}_${v}_${q}_log inherit_defaultquota \ + "new id herit from default for ${q} quota, WAPBL" -bl ${e} ${v} ${q} + test_case_root herit_idefq_${e}_${v}_${q}_log inherit_defaultiquota \ + "new id herit from default for ${q} ino quota, WAPBL" -bl ${e} ${v} ${q} + done + done +done + +limit_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ + -t 2h/2h ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon \+- 3 2 3 2:0 2 4 6' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +limit_softquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ + -t 1s/1d ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 1: write beyond the soft limit after grace time returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 1 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 2560 B\* 2048 B 3072 B none 2 4 6 ' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon \+- 2 2 3 none 2 4 6' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +limit_iquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ + -t 2h/2h ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +limit_softiquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ + -t 1d/1s ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 3: create file beyond the soft limit after grace time returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 3 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 2560 B 2048 K 3072 K 5 \* 4 6 none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon -\+ 2 2048 3072 5 4 6 none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +inherit_defaultquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ + -t 2h/2h -d + done + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'Disk quotas for .*id 1\): none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon \+- 3 2 3 2:0 2 4 6' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +inherit_defaultiquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ + -t 2h/2h -d + done + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'Disk quotas for .*id 1\): none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_setquota.sh b/contrib/netbsd-tests/fs/ffs/t_setquota.sh new file mode 100755 index 000000000000..5795fe4d46b6 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_setquota.sh @@ -0,0 +1,203 @@ +# $NetBSD: t_setquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +for e in le be; do + for v in 1 2; do + for q in "user" "group"; do + test_case_root set_${e}_${v}_${q} set_quota \ + "set quota with ${q} enabled" -b ${e} ${v} ${q} + test_case_root set_new_${e}_${v}_${q} set_quota_new \ + "set quota for new id with ${q} enabled" -b ${e} ${v} ${q} + test_case_root set_default_${e}_${v}_${q} set_quota_default \ + "set default quota with ${q} enabled" -b ${e} ${v} ${q} + done + test_case_root set_${e}_${v}_"both" set_quota \ + "set quota with both enabled" -b ${e} ${v} "both" + test_case_root set_new_${e}_${v}_"both" set_quota_new \ + "set quota for new id with both enabled" -b ${e} ${v} "both" + test_case_root set_new_${e}_${v}_"both_log" set_quota_new \ + "set quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" + test_case_root set_default_${e}_${v}_"both" set_quota_default \ + "set default quota with both enabled" -b ${e} ${v} "both" + done +done + +set_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can set the expected quota + for q in ${expect} ; do + local id=$(id -${q}) + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 2W/3D ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2weeks 1 20 51200 3days" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "match:-- 0 10 40960 1 20 51200" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + local id=$(id -${q}) + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id} + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "not-match:-- 0 - -" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + rump_quota_shutdown +} + +set_quota_new() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can set the expected quota + for q in ${expect} ; do + local id=1 + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 120W/255D ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2years 0 20 51200 9months" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + local id=$(id -${q}) + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id} + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + rump_quota_shutdown +} + +set_quota_default() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can set the expected quota + for q in ${expect} ; do + local id="-d" + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 2H2M/3540 ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2:2 0 20 51200 59" \ +-o "match:Default (user|group) disk quotas: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + local id="-d" + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id} + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Default (user|group) disk quotas: $" \ + -o "match:Default (user|group) disk quotas: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_snapshot.c b/contrib/netbsd-tests/fs/ffs/t_snapshot.c new file mode 100644 index 000000000000..180a8ccd92b0 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_snapshot.c @@ -0,0 +1,43 @@ +/* $NetBSD: t_snapshot.c,v 1.6 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "ffs.img" +#define NEWFS "newfs -F -s 10000 " IMGNAME +#define FSCK "fsck_ffs -fn -F" +#define BAKNAME "/mnt/le_snapp" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct ufs_args uargs; + + uargs.fspec = __UNCONST(fspec); + + if (rump_sys_mount(MOUNT_FFS, path, 0, &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", path); +} + +static void +begin(void) +{ + + /* empty */ +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c b/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c new file mode 100644 index 000000000000..e1ce17e1006a --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c @@ -0,0 +1,46 @@ +/* $NetBSD: t_snapshot_log.c,v 1.2 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "ffs.img" +#define NEWFS "newfs -F -s 10000 " IMGNAME +#define FSCK "fsck_ffs -fn -F" +#define BAKNAME "/mnt/le_snapp" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct ufs_args uargs; + static int flags = MNT_LOG; + + uargs.fspec = __UNCONST(fspec); + + if (rump_sys_mount(MOUNT_FFS, + path, flags, &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", path); + flags = 0; +} + +static void +begin(void) +{ + + /* empty */ +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c b/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c new file mode 100644 index 000000000000..393f3d41a6c3 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c @@ -0,0 +1,43 @@ +/* $NetBSD: t_snapshot_v2.c,v 1.2 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "ffs.img" +#define NEWFS "newfs -F -s 10000 -O 2 " IMGNAME +#define FSCK "fsck_ffs -fn -F" +#define BAKNAME "/mnt/le_snapp" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct ufs_args uargs; + + uargs.fspec = __UNCONST(fspec); + + if (rump_sys_mount(MOUNT_FFS, path, 0, &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", path); +} + +static void +begin(void) +{ + + /* empty */ +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/fifofs/t_fifo.c b/contrib/netbsd-tests/fs/fifofs/t_fifo.c new file mode 100644 index 000000000000..c4a2060a6ebc --- /dev/null +++ b/contrib/netbsd-tests/fs/fifofs/t_fifo.c @@ -0,0 +1,237 @@ +/* Test case written by Bharat Joshi */ +#include +__RCSID("$NetBSD: t_fifo.c,v 1.1 2011/12/21 00:17:07 christos Exp $"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef STANDALONE +#include +#endif + +#define FIFO_FILE_PATH "./fifo_file" +#define NUM_MESSAGES 20 +#define MSG_SIZE 240 +#define MESSAGE "I am fine" + +static int verbose = 0; + +/* + * child_writer + * + * Function that runs in child context and opens and write to the FIFO. + */ +static void +child_writer(void) +{ + ssize_t rv; + int fd; + size_t count; + char message[MSG_SIZE] = MESSAGE; + static const struct timespec ts = { 0, 10000 }; + + /* Open the fifo in write-mode */ + for (;;) { + fd = open(FIFO_FILE_PATH, O_WRONLY, 0); + if (fd == -1) { + if (errno == EINTR) + continue; + err(1, "Child: can't open fifo in write mode"); + } + break; + } + + for (count = 0; count < NUM_MESSAGES; count++) { + rv = write(fd, message, MSG_SIZE); + if (rv == -1) { + warn("Child: Failed to write"); + break; + } + if (rv != MSG_SIZE) + warnx("Child: wrote only %zd", rv); + nanosleep(&ts, NULL); + } + + close(fd); + if (verbose) { + printf("Child: Closed the fifo file\n"); + fflush(stdout); + } +} + +/* + * _sigchild_handler + * + * Called when a sigchild is delivered + */ +static void +sigchild_handler(int signo) +{ + if (verbose) { + if (signo == SIGCHLD) { + printf("Got sigchild\n"); + } else { + printf("Got %d signal\n", signo); + } + fflush(stdout); + } + +} + +static int +run(void) +{ + pid_t pid; + ssize_t rv; + int fd, status; + size_t buf_size = MSG_SIZE; + char buf[MSG_SIZE]; + struct sigaction action; + static const struct timespec ts = { 0, 500000000 }; + + /* Catch sigchild Signal */ + memset(&action, 0, sizeof(action)); + action.sa_handler = sigchild_handler; + sigemptyset(&action.sa_mask); + + if (sigaction(SIGCHLD, &action, NULL) == -1) + err(1, "sigaction"); + + (void)unlink(FIFO_FILE_PATH); + /* First create a fifo */ + if (mkfifo(FIFO_FILE_PATH, S_IRUSR | S_IWUSR) == -1) + err(1, "mkfifo"); + + switch ((pid = fork())) { + case -1: + err(1, "fork"); + case 0: + /* Open the file in write mode so that subsequent read + * from parent side does not block the parent.. + */ + if ((fd = open(FIFO_FILE_PATH, O_WRONLY, 0)) == -1) + err(1, "failed to open fifo"); + + /* In child */ + child_writer(); + return 0; + + default: + break; + } + + if (verbose) { + printf("Child pid is %d\n", pid ); + fflush(stdout); + } + + /* In parent */ + for (;;) { + if ((fd = open(FIFO_FILE_PATH, O_RDONLY, 0)) == -1) { + if (errno == EINTR) + continue; + else + err(1, "Failed to open the fifo in read mode"); + } + /* Read mode is opened */ + break; + + } + + nanosleep(&ts, NULL); + if (verbose) { + printf("Was sleeping...\n"); + fflush(stdout); + } + + for (;;) { + rv = read(fd, buf, buf_size); + + if (rv == -1) { + warn("Failed to read"); + if (errno == EINTR) { + if (verbose) { + printf("Parent interrupted, " + "continuing...\n"); + fflush(stdout); + } + continue; + } + + break; + } + + if (rv == 0) { + if (verbose) { + printf("Writers have closed, looks like we " + "are done\n"); + fflush(stdout); + } + break; + } + + if (verbose) { + printf("Received %zd bytes message '%s'\n", rv, buf); + fflush(stdout); + } + } + + close(fd); + + if (verbose) { + printf("We are done.. now reap the child"); + fflush(stdout); + } + + // Read the child... + while (waitpid(pid, &status, 0) == -1) + if (errno != EINTR) { + warn("Failed to reap the child"); + return 1; + } + + if (verbose) { + printf("We are done completely\n"); + fflush(stdout); + } + return 0; +} + +#ifndef STANDALONE +ATF_TC(parent_child); + +ATF_TC_HEAD(parent_child, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks that when a fifo is shared " + "between a reader parent and a writer child, that read will " + "return EOF, and not get stuck after the child exits"); +} + +ATF_TC_BODY(parent_child, tc) +{ + ATF_REQUIRE(run() == 0); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, parent_child); + + return atf_no_error(); +} +#else +int +main(void) +{ + verbose = 1; + return run(); +} +#endif diff --git a/contrib/netbsd-tests/fs/h_funcs.subr b/contrib/netbsd-tests/fs/h_funcs.subr new file mode 100644 index 000000000000..1216aaf2124a --- /dev/null +++ b/contrib/netbsd-tests/fs/h_funcs.subr @@ -0,0 +1,63 @@ +#!/bin/sh +# +# $NetBSD: h_funcs.subr,v 1.3 2010/06/23 11:19:17 pooka Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# +# require_fs name +# +# Checks that the given file system is built into the kernel and +# that its corresponding mount(8) utility is available. Otherwise +# skips the test. +# +require_fs() { + local name + local autoload + name="${1}" + + atf_require_prog mount + atf_require_prog mount_${name} + atf_require_prog umount + + # if we have autoloadable modules, just assume the file system + atf_require_prog sysctl + autoload=$(sysctl -n kern.module.autoload) + [ "${autoload}" = "1" ] && return 0 + + set -- $(sysctl -n vfs.generic.fstypes) + found=no + while [ ${#} -gt 1 ]; do + if [ ${1} = ${name} ]; then + found=yes + break + fi + shift + done + [ ${found} = yes ] || \ + atf_skip "The kernel does not include support the " \ + "\`${name}' file system" +} diff --git a/contrib/netbsd-tests/fs/hfs/colon.hfs.bz2.uue b/contrib/netbsd-tests/fs/hfs/colon.hfs.bz2.uue new file mode 100644 index 000000000000..9240e7befa80 --- /dev/null +++ b/contrib/netbsd-tests/fs/hfs/colon.hfs.bz2.uue @@ -0,0 +1,35 @@ +begin 644 colon.hfs.bz2 +M0EIH.3%!629363%?)5P``$+____[_UOQ>_]__^_O\+____1K30045,CBA$'P +M'DA:2!KIT`3V\VRA*B& +M`$,"8C$P$T9!HR:81B,":`D20A3T:GI`9``#(>H-`:-```:````````````` +M08!#1B:`R:83)ID`&$:-,`F`)A!H9`Q,@#``"8F3`3`30%241HC(4_4GJ>U- +M1Y31IM)ID`]3(T>H`#0#0T`:!H!A&@!H`````*9A\>L.>@+P;@Y:4C2%YM29 +M)Z`H>8SU&'"0U30JHOQ^.'A/7!GQK%#A5RVH"2$4VDL&T@ +M65#T*A/GU+(_VI$+*$`TJ"4J1(B1S&-YV+\J^"\Z6EK+@TU[0OQJ+;*HW.MN +M=HTL,CQHCE$C3#EW'>#8!IGYY[*)]U$!0W6L;#U:*4X6IT<@^*5!16E)%(:* +MA["$B&JX1022R8T4#20D@+ZHA_2_9$72HDSJ-FJ"7Z15%U2`@<>BJGD5'+*A +M@M6>?K^MS^LOC8I)EI6[`O3`#CCKU:M6F6A00-$/:LH+!E7(G33<))OZ27I4`@;= +M4C<-$,N=UX98G_0DK)BTS-^)R+8NZ,B3JU:@85&-MM@FCNQW/?= +M'ZL4BR[\&3S\>.K"S#1Z&>2I>^+16EM54PV3%K7M$"E`.N2"E*,8-@V.E<3$ +M,K\RU$&5E//5.'K6A+44]9=\"WF$J@Q1!43!WLA!?"XLR2GOU6G-,W]92)1` +MC@M4A4'FVAA`Q&&_%1B@L_`Z;T`0>[W6SCI%W&=H%Y>2"#E>IN[R3+(:S +MLMC<>N$1&APB(&6_#U<"!5*#IDA;MLNX`J(:/B8I,UNWB3CDPU2.@"(ORCKK +MK(1*"RZ+9V>$I2"PLER`U4BFIY'VTJ#\NYN2-9DRCIP1([QBLNKT:%1K"-P5 +MY)2NL9KM8=ACP>MLBS&J(00HA*QYRUL:'A%8F5]&22@@@D,;3[C,4.9$P)DK +M>\N+DK'4TLDI*LD&>8DEV@DT9B\,_CR;`,Y-E8*MM?Z*?BPU`I[I5^G-B$$A. +M\7&8DC*:*',@VKX0HL8O)DL<-9GG!8>NK.2XS2I.;Z3%Q9OIL8?(6-*DEGHW +MX^&A?%APXI:C@,A/&<6=)7#$UI;1Y6A'C<#/EW-*T(8WC9=`B`%\)M5HIS[\ +MV1%+H,,()X19<,:)U:Y?V\-T!^]'A\%%%+Z6.PQ"QI$]3#11IRB<#.9-L)^! +MB-WJYVQVMP^;7V*W5MG' +MKUWYE^[,*T:U)Y]NUI,00H%8>74G/?LJ0K)51^BXZ+AI*2O[PI`V*%Q@X\YV +M!V?D08"^;*TYO4R)T6G5:M;_M5M*;H4V)1IKCL$01$`#1R%N5,'_B[DBG"A( +%&*^2K@"^ +` +end diff --git a/contrib/netbsd-tests/fs/hfs/t_pathconvert.c b/contrib/netbsd-tests/fs/hfs/t_pathconvert.c new file mode 100644 index 000000000000..307de709be8b --- /dev/null +++ b/contrib/netbsd-tests/fs/hfs/t_pathconvert.c @@ -0,0 +1,83 @@ +/* $NetBSD: t_pathconvert.c,v 1.5 2011/02/25 20:54:18 martin Exp $ */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC(colonslash); +ATF_TC_HEAD(colonslash, tc) +{ + atf_tc_set_md_var(tc, "descr", "HFS+ colons/slashes (PR kern/44523)"); + atf_tc_set_md_var(tc, "timeout", "20"); +} + +#define IMGNAME "colon.hfs" +#define FAKEBLK "/dev/blk" +#define FUNNY_FILENAME "foo:bar" +ATF_TC_BODY(colonslash, tc) +{ + struct hfs_args args; + int dirfd, fd; + char thecmd[1024]; + char buf[DIRBLKSIZ]; + struct dirent *dirent; + int offset, nbytes; + bool ok = false; + + snprintf(thecmd, sizeof(thecmd), "uudecode %s/colon.hfs.bz2.uue", + atf_tc_get_config_var(tc, "srcdir")); + RZ(system(thecmd)); + + snprintf(thecmd, sizeof(thecmd), "bunzip2 " IMGNAME ".bz2"); + RZ(system(thecmd)); + + memset(&args, 0, sizeof args); + args.fspec = __UNCONST(FAKEBLK); + RZ(rump_init()); + + RL(rump_sys_mkdir("/mp", 0777)); + RZ(rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK)); + RL(rump_sys_mount(MOUNT_HFS, "/mp", 0, &args, sizeof args)); + + RL(dirfd = rump_sys_open("/mp", O_RDONLY)); + + RL(nbytes = rump_sys_getdents(dirfd, buf, sizeof buf)); + + for (offset = 0; offset < nbytes; offset += dirent->d_reclen) { + dirent = (struct dirent *)(buf + offset); + if (strchr(dirent->d_name, '/')) + atf_tc_fail("dirent with slash: %s", dirent->d_name); + if (0 == strcmp(FUNNY_FILENAME, dirent->d_name)) + ok = true; + } + + if (!ok) + atf_tc_fail("no dirent for file: %s", FUNNY_FILENAME); + + RL(rump_sys_close(dirfd)); + RL(fd = rump_sys_open("/mp/" FUNNY_FILENAME, O_RDONLY)); + RL(rump_sys_close(fd)); + RL(rump_sys_unmount("/mp", 0)); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, colonslash); + return 0; +} diff --git a/contrib/netbsd-tests/fs/kernfs/t_basic.c b/contrib/netbsd-tests/fs/kernfs/t_basic.c new file mode 100644 index 000000000000..e5ba4a77e1b7 --- /dev/null +++ b/contrib/netbsd-tests/fs/kernfs/t_basic.c @@ -0,0 +1,133 @@ +/* $NetBSD: t_basic.c,v 1.3 2010/05/31 23:44:54 pooka Exp $ */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC(getdents); +ATF_TC_HEAD(getdents, tc) +{ + + atf_tc_set_md_var(tc, "descr", "kernfs directory contains files"); +} + +static void +mountkernfs(void) +{ + + rump_init(); + + if (rump_sys_mkdir("/kern", 0777) == -1) + atf_tc_fail_errno("mkdir /kern"); + if (rump_sys_mount(MOUNT_KERNFS, "/kern", 0, NULL, 0) == -1) + atf_tc_fail_errno("could not mount kernfs"); +} + +ATF_TC_BODY(getdents, tc) +{ + struct dirent *dent; + char buf[8192]; + int dfd; + + mountkernfs(); + + if ((dfd = rump_sys_open("/kern", O_RDONLY)) == -1) + atf_tc_fail_errno("can't open directory"); + if (rump_sys_getdents(dfd, buf, sizeof(buf)) == -1) + atf_tc_fail_errno("getdents"); + + /* + * Check that we get the first three values (., .., boottime). + * Make more complete by autogenerating list from kernfs_vnops.c? + */ + dent = (void *)buf; + ATF_REQUIRE_STREQ(dent->d_name, "."); + dent = _DIRENT_NEXT(dent); + ATF_REQUIRE_STREQ(dent->d_name, ".."); + dent = _DIRENT_NEXT(dent); + ATF_REQUIRE_STREQ(dent->d_name, "boottime"); + + /* done */ +} + +ATF_TC(hostname); +ATF_TC_HEAD(hostname, tc) +{ + + atf_tc_set_md_var(tc, "descr", "/kern/hostname changes hostname"); +} + +static char * +getthehost(void) +{ + static char buf[8192]; + int mib[2]; + size_t blen; + + mib[0] = CTL_KERN; + mib[1] = KERN_HOSTNAME; + blen = sizeof(buf); + if (rump_sys___sysctl(mib, 2, buf, &blen, NULL, 0) == -1) + atf_tc_fail_errno("sysctl gethostname"); + + return buf; +} + +#define NEWHOSTNAME "turboton roos-berg" +ATF_TC_BODY(hostname, tc) +{ + char buf[8192]; + char *shost, *p; + int fd; + + mountkernfs(); + if ((fd = rump_sys_open("/kern/hostname", O_RDWR)) == -1) + atf_tc_fail_errno("open hostname"); + + /* check initial match */ + shost = getthehost(); + buf[0] = '\0'; + if (rump_sys_read(fd, buf, sizeof(buf)) == -1) + atf_tc_fail_errno("read hostname"); + p = strchr(buf, '\n'); + if (p) + *p = '\0'; + ATF_REQUIRE_STREQ_MSG(buf, shost, "initial hostname mismatch"); + + /* check changing hostname works */ + if (rump_sys_pwrite(fd, NEWHOSTNAME, strlen(NEWHOSTNAME), 0) + != strlen(NEWHOSTNAME)) { + atf_tc_fail_errno("write new hostname"); + } + + shost = getthehost(); + ATF_REQUIRE_STREQ_MSG(NEWHOSTNAME, shost, "modified hostname mismatch"); + + /* done */ +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, hostname); + ATF_TP_ADD_TC(tp, getdents); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/lfs/t_pr.c b/contrib/netbsd-tests/fs/lfs/t_pr.c new file mode 100644 index 000000000000..97cb1dbbbf77 --- /dev/null +++ b/contrib/netbsd-tests/fs/lfs/t_pr.c @@ -0,0 +1,60 @@ +/* $NetBSD: t_pr.c,v 1.6 2011/02/22 18:41:05 pooka Exp $ */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC(mknod); +ATF_TC_HEAD(mknod, tc) +{ + + atf_tc_set_md_var(tc, "descr", "mknod(2) hangs on LFS (PR kern/43503)"); + atf_tc_set_md_var(tc, "timeout", "20"); +} + +#define IMGNAME "disk.img" +#define FAKEBLK "/dev/blk" +ATF_TC_BODY(mknod, tc) +{ + struct ufs_args args; + + /* hmm, maybe i should fix newfs_lfs instead? */ + if (system("newfs_lfs -D -F -s 10000 ./" IMGNAME) == -1) + atf_tc_fail_errno("newfs failed"); + + memset(&args, 0, sizeof(args)); + args.fspec = __UNCONST(FAKEBLK); + + rump_init(); + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("cannot create mountpoint"); + rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK); + if (rump_sys_mount(MOUNT_LFS, "/mp", 0, &args, sizeof(args)) == -1) + atf_tc_fail_errno("rump_sys_mount failed"); + + //atf_tc_expect_timeout("PR kern/43503"); + if (rump_sys_mknod("/mp/node", S_IFCHR | 0777, 0) == -1) + atf_tc_fail_errno("mknod failed"); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, mknod); + return 0; +} diff --git a/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c b/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c new file mode 100644 index 000000000000..8b5708f843a3 --- /dev/null +++ b/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c @@ -0,0 +1,51 @@ +/* $NetBSD: t_snapshot.c,v 1.3 2014/06/10 13:15:18 martin Exp $ */ + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "msdosfs.img" +#define NEWFS "newfs_msdos -C 5M " IMGNAME +#define FSCK "fsck_msdos -fn" +#define BAKNAME "/stor/snap" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct msdosfs_args margs; + + memset(&margs, 0, sizeof(margs)); + margs.fspec = __UNCONST(fspec); + margs.version = MSDOSFSMNT_VERSION; + + if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1) + err(1, "mount msdosfs %s", path); +} + +static void +begin(void) +{ + struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, }; + + if (rump_sys_mkdir("/stor", 0777) == -1) + atf_tc_fail_errno("mkdir /stor"); + if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1) + atf_tc_fail_errno("mount storage"); +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/README b/contrib/netbsd-tests/fs/nfs/nfsservice/README new file mode 100644 index 000000000000..8cfa8af62949 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/README @@ -0,0 +1,16 @@ + $NetBSD: README,v 1.1 2010/07/26 15:53:00 pooka Exp $ + +This directory contains the necessary bits to get an NFS server +running in a rump kernel. In essence, it's: + + * rpcbind + * mountd + * nfsd + +Additionally, you need the libc rpc code which is in +tests/fs/common/nfsrpc. + +TODO: make the standard nfs userspace services usable (the challenge +comes from rpc being in libc). + +questions? ==> pooka@netbsd.org diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/exports b/contrib/netbsd-tests/fs/nfs/nfsservice/exports new file mode 100644 index 000000000000..6cc8c5fb80e9 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/exports @@ -0,0 +1,12 @@ +# $NetBSD: exports,v 1.2 2010/12/31 18:11:27 pooka Exp $ +# + +# +# The export dir is currently hardcoded and is exposed to the +# world, where "world" in this case means inside the rump shmif +# IP network, i.e. not a very big world. Probably needs some +# adjustments if we want to test NFS features more carefully, +# but this is enough for the current VFS level tests. +# +/myexport -noresvport -noresvmnt -maproot=0:0 10.3.2.2 +/myexport -ro -noresvport -noresvmnt -maproot=0:0 10.4.2.2 diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/getmntinfo.c b/contrib/netbsd-tests/fs/nfs/nfsservice/getmntinfo.c new file mode 100644 index 000000000000..0c0587a7aba5 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/getmntinfo.c @@ -0,0 +1,85 @@ +/* $NetBSD: getmntinfo.c,v 1.1 2010/07/26 15:53:00 pooka Exp $ */ + +/* + * Copyright (c) 1989, 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. 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 +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: getmntinfo.c,v 1.1 2010/07/26 15:53:00 pooka Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#define getvfsstat(a,b,c) rump_sys_getvfsstat(a,b,c) + +/* + * Return information about mounted filesystems. + */ +int +getmntinfo(mntbufp, flags) + struct statvfs **mntbufp; + int flags; +{ + static struct statvfs *mntbuf; + static int mntsize; + static size_t bufsize; + + _DIAGASSERT(mntbufp != NULL); + + if (mntsize <= 0 && + (mntsize = getvfsstat(NULL, (size_t)0, MNT_NOWAIT)) == -1) + return (0); + if (bufsize > 0 && + (mntsize = getvfsstat(mntbuf, bufsize, flags)) == -1) + return (0); + while (bufsize <= mntsize * sizeof(struct statvfs)) { + if (mntbuf) + free(mntbuf); + bufsize = (mntsize + 1) * sizeof(struct statvfs); + if ((mntbuf = malloc(bufsize)) == NULL) + return (0); + if ((mntsize = getvfsstat(mntbuf, bufsize, flags)) == -1) + return (0); + } + *mntbufp = mntbuf; + return (mntsize); +} diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c b/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c new file mode 100644 index 000000000000..b3625f684d15 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c @@ -0,0 +1,2575 @@ +/* $NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Herb Hasler and Rick Macklem at The University of Guelph. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. 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 +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1989, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; +#else +__RCSID("$NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $"); +#endif +#endif /* not lint */ + +#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 "pathnames.h" + +#ifdef IPSEC +#include +#ifndef IPSEC_POLICY_IPSEC /* no ipsec support on old ipsec */ +#undef IPSEC +#endif +#include "ipsec.h" +#endif + +#include "svc_fdset.h" + +#include + +/* + * Structures for keeping the mount list and export list + */ +struct mountlist { + struct mountlist *ml_next; + char ml_host[RPCMNT_NAMELEN + 1]; + char ml_dirp[RPCMNT_PATHLEN + 1]; + int ml_flag;/* XXX more flags (same as dp_flag) */ +}; + +struct dirlist { + struct dirlist *dp_left; + struct dirlist *dp_right; + int dp_flag; + struct hostlist *dp_hosts; /* List of hosts this dir exported to */ + char dp_dirp[1]; /* Actually malloc'd to size of dir */ +}; +/* dp_flag bits */ +#define DP_DEFSET 0x1 +#define DP_HOSTSET 0x2 +#define DP_KERB 0x4 +#define DP_NORESMNT 0x8 + +struct exportlist { + struct exportlist *ex_next; + struct dirlist *ex_dirl; + struct dirlist *ex_defdir; + int ex_flag; + fsid_t ex_fs; + char *ex_fsdir; + char *ex_indexfile; +}; +/* ex_flag bits */ +#define EX_LINKED 0x1 + +struct netmsk { + struct sockaddr_storage nt_net; + int nt_len; + char *nt_name; +}; + +union grouptypes { + struct addrinfo *gt_addrinfo; + struct netmsk gt_net; +}; + +struct grouplist { + int gr_type; + union grouptypes gr_ptr; + struct grouplist *gr_next; +}; +/* Group types */ +#define GT_NULL 0x0 +#define GT_HOST 0x1 +#define GT_NET 0x2 + +struct hostlist { + int ht_flag;/* Uses DP_xx bits */ + struct grouplist *ht_grp; + struct hostlist *ht_next; +}; + +struct fhreturn { + int fhr_flag; + int fhr_vers; + size_t fhr_fhsize; + union { + uint8_t v2[NFSX_V2FH]; + uint8_t v3[NFSX_V3FHMAX]; + } fhr_fh; +}; + +/* Global defs */ +static char *add_expdir __P((struct dirlist **, char *, int)); +static void add_dlist __P((struct dirlist **, struct dirlist *, + struct grouplist *, int)); +static void add_mlist __P((char *, char *, int)); +static int check_dirpath __P((const char *, size_t, char *)); +static int check_options __P((const char *, size_t, struct dirlist *)); +static int chk_host __P((struct dirlist *, struct sockaddr *, int *, int *)); +static int del_mlist __P((char *, char *, struct sockaddr *)); +static struct dirlist *dirp_search __P((struct dirlist *, char *)); +static int do_nfssvc __P((const char *, size_t, struct exportlist *, + struct grouplist *, int, struct uucred *, char *, int, struct statvfs *)); +static int do_opt __P((const char *, size_t, char **, char **, + struct exportlist *, struct grouplist *, int *, int *, struct uucred *)); +static struct exportlist *ex_search __P((fsid_t *)); +static int parse_directory __P((const char *, size_t, struct grouplist *, + int, char *, struct exportlist **, struct statvfs *)); +static int parse_host_netgroup __P((const char *, size_t, struct exportlist *, + struct grouplist *, char *, int *, struct grouplist **)); +static struct exportlist *get_exp __P((void)); +static void free_dir __P((struct dirlist *)); +static void free_exp __P((struct exportlist *)); +static void free_grp __P((struct grouplist *)); +static void free_host __P((struct hostlist *)); +void get_exportlist __P((int)); +static int get_host __P((const char *, size_t, const char *, + struct grouplist *)); +static struct hostlist *get_ht __P((void)); +static void get_mountlist __P((void)); +static int get_net __P((char *, struct netmsk *, int)); +static void free_exp_grp __P((struct exportlist *, struct grouplist *)); +static struct grouplist *get_grp __P((void)); +static void hang_dirp __P((struct dirlist *, struct grouplist *, + struct exportlist *, int)); +static void mntsrv __P((struct svc_req *, SVCXPRT *)); +static void nextfield __P((char **, char **)); +static void parsecred __P((char *, struct uucred *)); +static int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *)); +static int scan_tree __P((struct dirlist *, struct sockaddr *)); +static void send_umntall __P((int)); +#if 0 +static int umntall_each __P((caddr_t, struct sockaddr_in *)); +#endif +static int xdr_dir __P((XDR *, char *)); +static int xdr_explist __P((XDR *, caddr_t)); +static int xdr_fhs __P((XDR *, caddr_t)); +static int xdr_mlist __P((XDR *, caddr_t)); +static int bitcmp __P((void *, void *, int)); +static int netpartcmp __P((struct sockaddr *, struct sockaddr *, int)); +static int sacmp __P((struct sockaddr *, struct sockaddr *)); +static int allones __P((struct sockaddr_storage *, int)); +static int countones __P((struct sockaddr *)); +static void bind_resv_port __P((int, sa_family_t, in_port_t)); +static void no_nfs(int); +static struct exportlist *exphead; +static struct mountlist *mlhead; +static struct grouplist *grphead; +static char *exname; +static struct uucred def_anon = { + 1, + (uid_t) -2, + (gid_t) -2, + 0, + { 0 } +}; + +static int opt_flags; +static int have_v6 = 1; +static const int ninumeric = NI_NUMERICHOST; + +/* Bits for above */ +#define OP_MAPROOT 0x001 +#define OP_MAPALL 0x002 +#define OP_KERB 0x004 +#define OP_MASK 0x008 +#define OP_NET 0x010 +#define OP_ALLDIRS 0x040 +#define OP_NORESPORT 0x080 +#define OP_NORESMNT 0x100 +#define OP_MASKLEN 0x200 + +static int debug = 1; +#if 0 +static void SYSLOG __P((int, const char *,...)); +#endif +int main __P((int, char *[])); + +/* + * If this is non-zero, -noresvport and -noresvmnt are implied for + * each export. + */ +static int noprivports; + +#define C2FD(_c_) ((int)(uintptr_t)(_c_)) +static int +rumpread(void *cookie, char *buf, int count) +{ + + return rump_sys_read(C2FD(cookie), buf, count); +} + +static int +rumpwrite(void *cookie, const char *buf, int count) +{ + + return rump_sys_write(C2FD(cookie), buf, count); +} + +static off_t +rumpseek(void *cookie, off_t off, int whence) +{ + + return rump_sys_lseek(C2FD(cookie), off, whence); +} + +static int +rumpclose(void *cookie) +{ + + return rump_sys_close(C2FD(cookie)); +} + +int __sflags(const char *, int *); /* XXX */ +static FILE * +rumpfopen(const char *path, const char *opts) +{ + int fd, oflags; + + __sflags(opts, &oflags); + fd = rump_sys_open(path, oflags, 0777); + if (fd == -1) + return NULL; + + return funopen((void *)(uintptr_t)fd, + rumpread, rumpwrite, rumpseek, rumpclose); +} + +/* + * Make sure mountd signal handler is executed from a thread context + * instead of the signal handler. This avoids the signal handler + * ruining our kernel context. + */ +static sem_t exportsem; +static void +signal_get_exportlist(int sig) +{ + + sem_post(&exportsem); +} + +static void * +exportlist_thread(void *arg) +{ + + for (;;) { + sem_wait(&exportsem); + get_exportlist(0); + } + + return NULL; +} + +/* + * Mountd server for NFS mount protocol as described in: + * NFS: Network File System Protocol Specification, RFC1094, Appendix A + * The optional arguments are the exports file name + * default: _PATH_EXPORTS + * "-d" to enable debugging + * and "-n" to allow nonroot mount. + */ +void *mountd_main(void *); +void * +mountd_main(void *arg) +{ + SVCXPRT *udptransp, *tcptransp; + struct netconfig *udpconf, *tcpconf; + int udpsock, tcpsock; + int xcreated = 0; + int maxrec = RPC_MAXDATASIZE; + in_port_t forcedport = 0; + extern sem_t gensem; + pthread_t ptdummy; + + alloc_fdset(); + +#if 0 + while ((c = getopt(argc, argv, "dNnrp:" ADDOPTS)) != -1) + switch (c) { +#ifdef IPSEC + case 'P': + if (ipsecsetup_test(policy = optarg)) + errx(1, "Invalid ipsec policy `%s'", policy); + break; +#endif + case 'p': + /* A forced port "0" will dynamically allocate a port */ + forcedport = atoi(optarg); + break; + case 'd': + debug = 1; + break; + case 'N': + noprivports = 1; + break; + /* Compatibility */ + case 'n': + case 'r': + break; + default: + fprintf(stderr, "usage: %s [-dNn]" +#ifdef IPSEC + " [-P policy]" +#endif + " [-p port] [exportsfile]\n", getprogname()); + exit(1); + }; + argc -= optind; + argv += optind; +#endif + + sem_init(&exportsem, 0, 0); + pthread_create(&ptdummy, NULL, exportlist_thread, NULL); + + grphead = NULL; + exphead = NULL; + mlhead = NULL; + exname = _PATH_EXPORTS; + openlog("mountd", LOG_PID | (debug ? LOG_PERROR : 0), LOG_DAEMON); + (void)signal(SIGSYS, no_nfs); + + if (debug) + (void)fprintf(stderr, "Getting export list.\n"); + get_exportlist(0); + if (debug) + (void)fprintf(stderr, "Getting mount list.\n"); + get_mountlist(); + if (debug) + (void)fprintf(stderr, "Here we go.\n"); + if (debug == 0) { + daemon(0, 0); + (void)signal(SIGINT, SIG_IGN); + (void)signal(SIGQUIT, SIG_IGN); + } + (void)signal(SIGHUP, signal_get_exportlist); + (void)signal(SIGTERM, send_umntall); + pidfile(NULL); + + rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL); + rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL); + + udpsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + tcpsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + + udpconf = getnetconfigent("udp"); + tcpconf = getnetconfigent("tcp"); + + rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec); + + if (udpsock != -1 && udpconf != NULL) { + bind_resv_port(udpsock, AF_INET, forcedport); +#ifdef IPSEC + if (policy) + ipsecsetup(AF_INET, udpsock, policy); +#endif + udptransp = svc_dg_create(udpsock, 0, 0); + if (udptransp != NULL) { + if (!svc_reg(udptransp, RPCPROG_MNT, RPCMNT_VER1, + mntsrv, udpconf) || + !svc_reg(udptransp, RPCPROG_MNT, RPCMNT_VER3, + mntsrv, udpconf)) { + syslog(LOG_WARNING, "can't register UDP service"); + } + else { + xcreated++; + } + } else { + syslog(LOG_WARNING, "can't create UDP service"); + } + + } + + if (tcpsock != -1 && tcpconf != NULL) { + bind_resv_port(tcpsock, AF_INET, forcedport); +#ifdef IPSEC + if (policy) + ipsecsetup(AF_INET, tcpsock, policy); +#endif + listen(tcpsock, SOMAXCONN); + tcptransp = svc_vc_create(tcpsock, RPC_MAXDATASIZE, + RPC_MAXDATASIZE); + if (tcptransp != NULL) { + if (!svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER1, + mntsrv, tcpconf) || + !svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER3, + mntsrv, tcpconf)) + syslog(LOG_WARNING, "can't register TCP service"); + else + xcreated++; + } else + syslog(LOG_WARNING, "can't create TCP service"); + + } + + if (xcreated == 0) { + syslog(LOG_ERR, "could not create any services"); + exit(1); + } + + sem_post(&gensem); + svc_run(); + syslog(LOG_ERR, "Mountd died"); + exit(1); +} + +/* + * The mount rpc service + */ +void +mntsrv(rqstp, transp) + struct svc_req *rqstp; + SVCXPRT *transp; +{ + struct exportlist *ep; + struct dirlist *dp; + struct fhreturn fhr; + struct stat stb; + struct statvfs fsb; + char host[NI_MAXHOST], numerichost[NI_MAXHOST]; + int lookup_failed = 1; + struct sockaddr *saddr; + u_short sport; + char rpcpath[RPCMNT_PATHLEN + 1], dpath[MAXPATHLEN]; + long bad = EACCES; + int defset, hostset, ret; + sigset_t sighup_mask; + struct sockaddr_in6 *sin6; + struct sockaddr_in *sin; + size_t fh_size; + int error = 0; + + (void)sigemptyset(&sighup_mask); + (void)sigaddset(&sighup_mask, SIGHUP); + saddr = svc_getrpccaller(transp)->buf; + switch (saddr->sa_family) { + case AF_INET6: + sin6 = (struct sockaddr_in6 *)saddr; + sport = ntohs(sin6->sin6_port); + break; + case AF_INET: + sin = (struct sockaddr_in *)saddr; + sport = ntohs(sin->sin_port); + break; + default: + syslog(LOG_ERR, "request from unknown address family"); + return; + } + lookup_failed = getnameinfo(saddr, saddr->sa_len, host, sizeof host, + NULL, 0, 0); + if (getnameinfo(saddr, saddr->sa_len, numerichost, + sizeof numerichost, NULL, 0, ninumeric) != 0) + strlcpy(numerichost, "?", sizeof(numerichost)); + ret = 0; + switch (rqstp->rq_proc) { + case NULLPROC: + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_MNT: + if (debug) + fprintf(stderr, + "got mount request from %s\n", numerichost); + if (!svc_getargs(transp, xdr_dir, rpcpath)) { + if (debug) + fprintf(stderr, "-> garbage args\n"); + svcerr_decode(transp); + return; + } + if (debug) + fprintf(stderr, + "-> rpcpath: %s\n", rpcpath); + /* + * Get the real pathname and make sure it is a file or + * directory that exists. + */ +#if 0 + if (realpath(rpcpath, dpath) == 0 || +#endif + strcpy(dpath, rpcpath); + if (rump_sys_stat(dpath, &stb) < 0 || + (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) || + rump_sys_statvfs1(dpath, &fsb, ST_WAIT) < 0) { + (void)chdir("/"); /* Just in case realpath doesn't */ + if (debug) + (void)fprintf(stderr, "-> stat failed on %s\n", + dpath); + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) &bad)) + syslog(LOG_ERR, "Can't send reply"); + return; + } + if (debug) + fprintf(stderr, + "-> dpath: %s\n", dpath); + /* Check in the exports list */ + (void)sigprocmask(SIG_BLOCK, &sighup_mask, NULL); + ep = ex_search(&fsb.f_fsidx); + hostset = defset = 0; + if (ep && (chk_host(ep->ex_defdir, saddr, &defset, + &hostset) || ((dp = dirp_search(ep->ex_dirl, dpath)) && + chk_host(dp, saddr, &defset, &hostset)) || + (defset && scan_tree(ep->ex_defdir, saddr) == 0 && + scan_tree(ep->ex_dirl, saddr) == 0))) { + if ((hostset & DP_HOSTSET) == 0) { + hostset = defset; + } + if (sport >= IPPORT_RESERVED && + !(hostset & DP_NORESMNT)) { + syslog(LOG_NOTICE, + "Refused mount RPC from host %s port %d", + numerichost, sport); + svcerr_weakauth(transp); + goto out; + } + fhr.fhr_flag = hostset; + fhr.fhr_vers = rqstp->rq_vers; + /* Get the file handle */ + memset(&fhr.fhr_fh, 0, sizeof(fhr.fhr_fh)); /* for v2 */ + fh_size = sizeof(fhr.fhr_fh); + error = 0; + if (rump_sys_getfh(dpath, &fhr.fhr_fh, &fh_size) < 0) { + bad = error; + //syslog(LOG_ERR, "Can't get fh for %s %d %d", dpath, error, fh_size); + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, + (char *)&bad)) + syslog(LOG_ERR, "Can't send reply"); + goto out; + } + if ((fhr.fhr_vers == 1 && fh_size > NFSX_V2FH) || + fh_size > NFSX_V3FHMAX) { + bad = EINVAL; /* XXX */ + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, + (char *)&bad)) + syslog(LOG_ERR, "Can't send reply"); + goto out; + } + fhr.fhr_fhsize = fh_size; + if (!svc_sendreply(transp, (xdrproc_t)xdr_fhs, (char *) &fhr)) + syslog(LOG_ERR, "Can't send reply"); + if (!lookup_failed) + add_mlist(host, dpath, hostset); + else + add_mlist(numerichost, dpath, hostset); + if (debug) + (void)fprintf(stderr, "Mount successful.\n"); + } else { + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) &bad)) + syslog(LOG_ERR, "Can't send reply"); + } +out: + (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); + return; + case MOUNTPROC_DUMP: + if (!svc_sendreply(transp, (xdrproc_t)xdr_mlist, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_UMNT: + if (!svc_getargs(transp, xdr_dir, dpath)) { + svcerr_decode(transp); + return; + } + if (!lookup_failed) + ret = del_mlist(host, dpath, saddr); + ret |= del_mlist(numerichost, dpath, saddr); + if (ret) { + svcerr_weakauth(transp); + return; + } + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_UMNTALL: + if (!lookup_failed) + ret = del_mlist(host, NULL, saddr); + ret |= del_mlist(numerichost, NULL, saddr); + if (ret) { + svcerr_weakauth(transp); + return; + } + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_EXPORT: + case MOUNTPROC_EXPORTALL: + if (!svc_sendreply(transp, (xdrproc_t)xdr_explist, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + + + default: + svcerr_noproc(transp); + return; + } +} + +/* + * Xdr conversion for a dpath string + */ +static int +xdr_dir(xdrsp, dirp) + XDR *xdrsp; + char *dirp; +{ + + return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN)); +} + +/* + * Xdr routine to generate file handle reply + */ +static int +xdr_fhs(xdrsp, cp) + XDR *xdrsp; + caddr_t cp; +{ + struct fhreturn *fhrp = (struct fhreturn *) cp; + long ok = 0, len, auth; + + if (!xdr_long(xdrsp, &ok)) + return (0); + switch (fhrp->fhr_vers) { + case 1: + return (xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, NFSX_V2FH)); + case 3: + len = fhrp->fhr_fhsize; + if (!xdr_long(xdrsp, &len)) + return (0); + if (!xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, len)) + return (0); + if (fhrp->fhr_flag & DP_KERB) + auth = RPCAUTH_KERB4; + else + auth = RPCAUTH_UNIX; + len = 1; + if (!xdr_long(xdrsp, &len)) + return (0); + return (xdr_long(xdrsp, &auth)); + }; + return (0); +} + +int +xdr_mlist(xdrsp, cp) + XDR *xdrsp; + caddr_t cp; +{ + struct mountlist *mlp; + int trueval = 1; + int falseval = 0; + char *strp; + + mlp = mlhead; + while (mlp) { + if (!xdr_bool(xdrsp, &trueval)) + return (0); + strp = &mlp->ml_host[0]; + if (!xdr_string(xdrsp, &strp, RPCMNT_NAMELEN)) + return (0); + strp = &mlp->ml_dirp[0]; + if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) + return (0); + mlp = mlp->ml_next; + } + if (!xdr_bool(xdrsp, &falseval)) + return (0); + return (1); +} + +/* + * Xdr conversion for export list + */ +int +xdr_explist(xdrsp, cp) + XDR *xdrsp; + caddr_t cp; +{ + struct exportlist *ep; + int falseval = 0; + int putdef; + sigset_t sighup_mask; + + (void)sigemptyset(&sighup_mask); + (void)sigaddset(&sighup_mask, SIGHUP); + (void)sigprocmask(SIG_BLOCK, &sighup_mask, NULL); + ep = exphead; + while (ep) { + putdef = 0; + if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef)) + goto errout; + if (ep->ex_defdir && putdef == 0 && + put_exlist(ep->ex_defdir, xdrsp, NULL, &putdef)) + goto errout; + ep = ep->ex_next; + } + (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); + if (!xdr_bool(xdrsp, &falseval)) + return (0); + return (1); +errout: + (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); + return (0); +} + +/* + * Called from xdr_explist() to traverse the tree and export the + * directory paths. Assumes SIGHUP has already been masked. + */ +int +put_exlist(dp, xdrsp, adp, putdefp) + struct dirlist *dp; + XDR *xdrsp; + struct dirlist *adp; + int *putdefp; +{ + struct grouplist *grp; + struct hostlist *hp; + int trueval = 1; + int falseval = 0; + int gotalldir = 0; + char *strp; + + if (dp) { + if (put_exlist(dp->dp_left, xdrsp, adp, putdefp)) + return (1); + if (!xdr_bool(xdrsp, &trueval)) + return (1); + strp = dp->dp_dirp; + if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) + return (1); + if (adp && !strcmp(dp->dp_dirp, adp->dp_dirp)) { + gotalldir = 1; + *putdefp = 1; + } + if ((dp->dp_flag & DP_DEFSET) == 0 && + (gotalldir == 0 || (adp->dp_flag & DP_DEFSET) == 0)) { + hp = dp->dp_hosts; + while (hp) { + grp = hp->ht_grp; + if (grp->gr_type == GT_HOST) { + if (!xdr_bool(xdrsp, &trueval)) + return (1); + strp = + grp->gr_ptr.gt_addrinfo->ai_canonname; + if (!xdr_string(xdrsp, &strp, + RPCMNT_NAMELEN)) + return (1); + } else if (grp->gr_type == GT_NET) { + if (!xdr_bool(xdrsp, &trueval)) + return (1); + strp = grp->gr_ptr.gt_net.nt_name; + if (!xdr_string(xdrsp, &strp, + RPCMNT_NAMELEN)) + return (1); + } + hp = hp->ht_next; + if (gotalldir && hp == NULL) { + hp = adp->dp_hosts; + gotalldir = 0; + } + } + } + if (!xdr_bool(xdrsp, &falseval)) + return (1); + if (put_exlist(dp->dp_right, xdrsp, adp, putdefp)) + return (1); + } + return (0); +} + +static int +parse_host_netgroup(line, lineno, ep, tgrp, cp, has_host, grp) + const char *line; + size_t lineno; + struct exportlist *ep; + struct grouplist *tgrp; + char *cp; + int *has_host; + struct grouplist **grp; +{ + const char *hst, *usr, *dom; + int netgrp; + + if (ep == NULL) { + syslog(LOG_ERR, "\"%s\", line %ld: No current export", + line, (unsigned long)lineno); + return 0; + } + setnetgrent(cp); + netgrp = getnetgrent(&hst, &usr, &dom); + do { + if (*has_host) { + (*grp)->gr_next = get_grp(); + *grp = (*grp)->gr_next; + } + if (netgrp) { + if (hst == NULL) { + syslog(LOG_ERR, + "\"%s\", line %ld: No host in netgroup %s", + line, (unsigned long)lineno, cp); + goto bad; + } + if (get_host(line, lineno, hst, *grp)) + goto bad; + } else if (get_host(line, lineno, cp, *grp)) + goto bad; + *has_host = TRUE; + } while (netgrp && getnetgrent(&hst, &usr, &dom)); + + endnetgrent(); + return 1; +bad: + endnetgrent(); + return 0; + +} + +static int +parse_directory(line, lineno, tgrp, got_nondir, cp, ep, fsp) + const char *line; + size_t lineno; + struct grouplist *tgrp; + int got_nondir; + char *cp; + struct exportlist **ep; + struct statvfs *fsp; +{ + int error = 0; + + if (!check_dirpath(line, lineno, cp)) + return 0; + + if (rump_sys_statvfs1(cp, fsp, ST_WAIT) == -1) { + syslog(LOG_ERR, "\"%s\", line %ld: statvfs for `%s' failed: %m %d", + line, (unsigned long)lineno, cp, error); + return 0; + } + + if (got_nondir) { + syslog(LOG_ERR, + "\"%s\", line %ld: Directories must precede files", + line, (unsigned long)lineno); + return 0; + } + if (*ep) { + if ((*ep)->ex_fs.__fsid_val[0] != fsp->f_fsidx.__fsid_val[0] || + (*ep)->ex_fs.__fsid_val[1] != fsp->f_fsidx.__fsid_val[1]) { + syslog(LOG_ERR, + "\"%s\", line %ld: filesystem ids disagree", + line, (unsigned long)lineno); + return 0; + } + } else { + /* + * See if this directory is already + * in the list. + */ + *ep = ex_search(&fsp->f_fsidx); + if (*ep == NULL) { + *ep = get_exp(); + (*ep)->ex_fs = fsp->f_fsidx; + (*ep)->ex_fsdir = estrdup(fsp->f_mntonname); + if (debug) + (void)fprintf(stderr, + "Making new ep fs=0x%x,0x%x\n", + fsp->f_fsidx.__fsid_val[0], fsp->f_fsidx.__fsid_val[1]); + } else { + if (debug) + (void)fprintf(stderr, + "Found ep fs=0x%x,0x%x\n", + fsp->f_fsidx.__fsid_val[0], fsp->f_fsidx.__fsid_val[1]); + } + } + + return 1; +} + + +/* + * Get the export list + */ +/* ARGSUSED */ +void +get_exportlist(n) + int n; +{ + struct exportlist *ep, *ep2; + struct grouplist *grp, *tgrp; + struct exportlist **epp; + struct dirlist *dirhead; + struct statvfs fsb, *fsp; + struct addrinfo *ai; + struct uucred anon; + char *cp, *endcp, *dirp, savedc; + int has_host, exflags, got_nondir, dirplen, num, i; + FILE *exp_file; + char *line; + size_t lineno = 0, len; + + + /* + * First, get rid of the old list + */ + ep = exphead; + while (ep) { + ep2 = ep; + ep = ep->ex_next; + free_exp(ep2); + } + exphead = NULL; + + dirp = NULL; + dirplen = 0; + grp = grphead; + while (grp) { + tgrp = grp; + grp = grp->gr_next; + free_grp(tgrp); + } + grphead = NULL; + + /* + * And delete exports that are in the kernel for all local + * file systems. + */ + num = getmntinfo(&fsp, MNT_NOWAIT); + for (i = 0; i < num; i++) { + struct mountd_exports_list mel; + + /* Delete all entries from the export list. */ + mel.mel_path = fsp->f_mntonname; + mel.mel_nexports = 0; + if (rump_sys_nfssvc(NFSSVC_SETEXPORTSLIST, &mel) == -1 && + errno != EOPNOTSUPP) + syslog(LOG_ERR, "Can't delete exports for %s (%m)", + fsp->f_mntonname); + + fsp++; + } + + /* + * Read in the exports file and build the list, calling + * mount() as we go along to push the export rules into the kernel. + */ + exname = _PATH_EXPORTS; + if ((exp_file = rumpfopen(exname, "r")) == NULL) { + /* + * Don't exit here; we can still reload the config + * after a SIGHUP. + */ + if (debug) + (void)fprintf(stderr, "Can't open %s: %s\n", exname, + strerror(errno)); + return; + } + dirhead = NULL; + while ((line = fparseln(exp_file, &len, &lineno, NULL, 0)) != NULL) { + if (debug) + (void)fprintf(stderr, "Got line %s\n", line); + cp = line; + nextfield(&cp, &endcp); + if (cp == endcp) + goto nextline; /* skip empty line */ + /* + * Set defaults. + */ + has_host = FALSE; + anon = def_anon; + exflags = MNT_EXPORTED; + got_nondir = 0; + opt_flags = 0; + ep = NULL; + + if (noprivports) { + opt_flags |= OP_NORESMNT | OP_NORESPORT; + exflags |= MNT_EXNORESPORT; + } + + /* + * Create new exports list entry + */ + len = endcp - cp; + tgrp = grp = get_grp(); + while (len > 0) { + if (len > RPCMNT_NAMELEN) { + *endcp = '\0'; + syslog(LOG_ERR, + "\"%s\", line %ld: name `%s' is too long", + line, (unsigned long)lineno, cp); + goto badline; + } + switch (*cp) { + case '-': + /* + * Option + */ + if (ep == NULL) { + syslog(LOG_ERR, + "\"%s\", line %ld: No current export list", + line, (unsigned long)lineno); + goto badline; + } + if (debug) + (void)fprintf(stderr, "doing opt %s\n", + cp); + got_nondir = 1; + if (do_opt(line, lineno, &cp, &endcp, ep, grp, + &has_host, &exflags, &anon)) + goto badline; + break; + + case '/': + /* + * Directory + */ + savedc = *endcp; + *endcp = '\0'; + + if (!parse_directory(line, lineno, tgrp, + got_nondir, cp, &ep, &fsb)) + goto badline; + /* + * Add dirpath to export mount point. + */ + dirp = add_expdir(&dirhead, cp, len); + dirplen = len; + + *endcp = savedc; + break; + + default: + /* + * Host or netgroup. + */ + savedc = *endcp; + *endcp = '\0'; + + if (!parse_host_netgroup(line, lineno, ep, + tgrp, cp, &has_host, &grp)) + goto badline; + + got_nondir = 1; + + *endcp = savedc; + break; + } + + cp = endcp; + nextfield(&cp, &endcp); + len = endcp - cp; + } + if (check_options(line, lineno, dirhead)) + goto badline; + + if (!has_host) { + grp->gr_type = GT_HOST; + if (debug) + (void)fprintf(stderr, + "Adding a default entry\n"); + /* add a default group and make the grp list NULL */ + ai = emalloc(sizeof(struct addrinfo)); + ai->ai_flags = 0; + ai->ai_family = AF_INET; /* XXXX */ + ai->ai_socktype = SOCK_DGRAM; + /* setting the length to 0 will match anything */ + ai->ai_addrlen = 0; + ai->ai_flags = AI_CANONNAME; + ai->ai_canonname = estrdup("Default"); + ai->ai_addr = NULL; + ai->ai_next = NULL; + grp->gr_ptr.gt_addrinfo = ai; + + } else if ((opt_flags & OP_NET) && tgrp->gr_next) { + /* + * Don't allow a network export coincide with a list of + * host(s) on the same line. + */ + syslog(LOG_ERR, + "\"%s\", line %ld: Mixed exporting of networks and hosts is disallowed", + line, (unsigned long)lineno); + goto badline; + } + /* + * Loop through hosts, pushing the exports into the kernel. + * After loop, tgrp points to the start of the list and + * grp points to the last entry in the list. + */ + grp = tgrp; + do { + if (do_nfssvc(line, lineno, ep, grp, exflags, &anon, + dirp, dirplen, &fsb)) + goto badline; + } while (grp->gr_next && (grp = grp->gr_next)); + + /* + * Success. Update the data structures. + */ + if (has_host) { + hang_dirp(dirhead, tgrp, ep, opt_flags); + grp->gr_next = grphead; + grphead = tgrp; + } else { + hang_dirp(dirhead, NULL, ep, opt_flags); + free_grp(tgrp); + } + tgrp = NULL; + dirhead = NULL; + if ((ep->ex_flag & EX_LINKED) == 0) { + ep2 = exphead; + epp = &exphead; + + /* + * Insert in the list in alphabetical order. + */ + while (ep2 && strcmp(ep2->ex_fsdir, ep->ex_fsdir) < 0) { + epp = &ep2->ex_next; + ep2 = ep2->ex_next; + } + if (ep2) + ep->ex_next = ep2; + *epp = ep; + ep->ex_flag |= EX_LINKED; + } + goto nextline; +badline: + free_exp_grp(ep, grp); +nextline: + if (dirhead) { + free_dir(dirhead); + dirhead = NULL; + } + free(line); + } + (void)fclose(exp_file); +} + +/* + * Allocate an export list element + */ +static struct exportlist * +get_exp() +{ + struct exportlist *ep; + + ep = emalloc(sizeof(struct exportlist)); + (void)memset(ep, 0, sizeof(struct exportlist)); + return (ep); +} + +/* + * Allocate a group list element + */ +static struct grouplist * +get_grp() +{ + struct grouplist *gp; + + gp = emalloc(sizeof(struct grouplist)); + (void)memset(gp, 0, sizeof(struct grouplist)); + return (gp); +} + +/* + * Clean up upon an error in get_exportlist(). + */ +static void +free_exp_grp(ep, grp) + struct exportlist *ep; + struct grouplist *grp; +{ + struct grouplist *tgrp; + + if (ep && (ep->ex_flag & EX_LINKED) == 0) + free_exp(ep); + while (grp) { + tgrp = grp; + grp = grp->gr_next; + free_grp(tgrp); + } +} + +/* + * Search the export list for a matching fs. + */ +static struct exportlist * +ex_search(fsid) + fsid_t *fsid; +{ + struct exportlist *ep; + + ep = exphead; + return ep; + while (ep) { + if (ep->ex_fs.__fsid_val[0] == fsid->__fsid_val[0] && + ep->ex_fs.__fsid_val[1] == fsid->__fsid_val[1]) + return (ep); + ep = ep->ex_next; + } + return (ep); +} + +/* + * Add a directory path to the list. + */ +static char * +add_expdir(dpp, cp, len) + struct dirlist **dpp; + char *cp; + int len; +{ + struct dirlist *dp; + + dp = emalloc(sizeof(struct dirlist) + len); + dp->dp_left = *dpp; + dp->dp_right = NULL; + dp->dp_flag = 0; + dp->dp_hosts = NULL; + (void)strcpy(dp->dp_dirp, cp); + *dpp = dp; + return (dp->dp_dirp); +} + +/* + * Hang the dir list element off the dirpath binary tree as required + * and update the entry for host. + */ +void +hang_dirp(dp, grp, ep, flags) + struct dirlist *dp; + struct grouplist *grp; + struct exportlist *ep; + int flags; +{ + struct hostlist *hp; + struct dirlist *dp2; + + if (flags & OP_ALLDIRS) { + if (ep->ex_defdir) + free(dp); + else + ep->ex_defdir = dp; + if (grp == NULL) { + ep->ex_defdir->dp_flag |= DP_DEFSET; + if (flags & OP_KERB) + ep->ex_defdir->dp_flag |= DP_KERB; + if (flags & OP_NORESMNT) + ep->ex_defdir->dp_flag |= DP_NORESMNT; + } else + while (grp) { + hp = get_ht(); + if (flags & OP_KERB) + hp->ht_flag |= DP_KERB; + if (flags & OP_NORESMNT) + hp->ht_flag |= DP_NORESMNT; + hp->ht_grp = grp; + hp->ht_next = ep->ex_defdir->dp_hosts; + ep->ex_defdir->dp_hosts = hp; + grp = grp->gr_next; + } + } else { + + /* + * Loop through the directories adding them to the tree. + */ + while (dp) { + dp2 = dp->dp_left; + add_dlist(&ep->ex_dirl, dp, grp, flags); + dp = dp2; + } + } +} + +/* + * Traverse the binary tree either updating a node that is already there + * for the new directory or adding the new node. + */ +static void +add_dlist(dpp, newdp, grp, flags) + struct dirlist **dpp; + struct dirlist *newdp; + struct grouplist *grp; + int flags; +{ + struct dirlist *dp; + struct hostlist *hp; + int cmp; + + dp = *dpp; + if (dp) { + cmp = strcmp(dp->dp_dirp, newdp->dp_dirp); + if (cmp > 0) { + add_dlist(&dp->dp_left, newdp, grp, flags); + return; + } else if (cmp < 0) { + add_dlist(&dp->dp_right, newdp, grp, flags); + return; + } else + free(newdp); + } else { + dp = newdp; + dp->dp_left = NULL; + *dpp = dp; + } + if (grp) { + + /* + * Hang all of the host(s) off of the directory point. + */ + do { + hp = get_ht(); + if (flags & OP_KERB) + hp->ht_flag |= DP_KERB; + if (flags & OP_NORESMNT) + hp->ht_flag |= DP_NORESMNT; + hp->ht_grp = grp; + hp->ht_next = dp->dp_hosts; + dp->dp_hosts = hp; + grp = grp->gr_next; + } while (grp); + } else { + dp->dp_flag |= DP_DEFSET; + if (flags & OP_KERB) + dp->dp_flag |= DP_KERB; + if (flags & OP_NORESMNT) + dp->dp_flag |= DP_NORESMNT; + } +} + +/* + * Search for a dirpath on the export point. + */ +static struct dirlist * +dirp_search(dp, dirp) + struct dirlist *dp; + char *dirp; +{ + int cmp; + + if (dp) { + cmp = strcmp(dp->dp_dirp, dirp); + if (cmp > 0) + return (dirp_search(dp->dp_left, dirp)); + else if (cmp < 0) + return (dirp_search(dp->dp_right, dirp)); + else + return (dp); + } + return (dp); +} + +/* + * Some helper functions for netmasks. They all assume masks in network + * order (big endian). + */ +static int +bitcmp(void *dst, void *src, int bitlen) +{ + int i; + u_int8_t *p1 = dst, *p2 = src; + u_int8_t bitmask; + int bytelen, bitsleft; + + bytelen = bitlen / 8; + bitsleft = bitlen % 8; + + if (debug) { + printf("comparing:\n"); + for (i = 0; i < (bitsleft ? bytelen + 1 : bytelen); i++) + printf("%02x", p1[i]); + printf("\n"); + for (i = 0; i < (bitsleft ? bytelen + 1 : bytelen); i++) + printf("%02x", p2[i]); + printf("\n"); + } + + for (i = 0; i < bytelen; i++) { + if (*p1 != *p2) + return 1; + p1++; + p2++; + } + + for (i = 0; i < bitsleft; i++) { + bitmask = 1 << (7 - i); + if ((*p1 & bitmask) != (*p2 & bitmask)) + return 1; + } + + return 0; +} + +static int +netpartcmp(struct sockaddr *s1, struct sockaddr *s2, int bitlen) +{ + void *src, *dst; + + if (s1->sa_family != s2->sa_family) + return 1; + + switch (s1->sa_family) { + case AF_INET: + src = &((struct sockaddr_in *)s1)->sin_addr; + dst = &((struct sockaddr_in *)s2)->sin_addr; + if (bitlen > sizeof(((struct sockaddr_in *)s1)->sin_addr) * 8) + return 1; + break; + case AF_INET6: + src = &((struct sockaddr_in6 *)s1)->sin6_addr; + dst = &((struct sockaddr_in6 *)s2)->sin6_addr; + if (((struct sockaddr_in6 *)s1)->sin6_scope_id != + ((struct sockaddr_in6 *)s2)->sin6_scope_id) + return 1; + if (bitlen > sizeof(((struct sockaddr_in6 *)s1)->sin6_addr) * 8) + return 1; + break; + default: + return 1; + } + + return bitcmp(src, dst, bitlen); +} + +static int +allones(struct sockaddr_storage *ssp, int bitlen) +{ + u_int8_t *p; + int bytelen, bitsleft, i; + int zerolen; + + switch (ssp->ss_family) { + case AF_INET: + p = (u_int8_t *)&((struct sockaddr_in *)ssp)->sin_addr; + zerolen = sizeof (((struct sockaddr_in *)ssp)->sin_addr); + break; + case AF_INET6: + p = (u_int8_t *)&((struct sockaddr_in6 *)ssp)->sin6_addr; + zerolen = sizeof (((struct sockaddr_in6 *)ssp)->sin6_addr); + break; + default: + return -1; + } + + memset(p, 0, zerolen); + + bytelen = bitlen / 8; + bitsleft = bitlen % 8; + + if (bytelen > zerolen) + return -1; + + for (i = 0; i < bytelen; i++) + *p++ = 0xff; + + for (i = 0; i < bitsleft; i++) + *p |= 1 << (7 - i); + + return 0; +} + +static int +countones(struct sockaddr *sa) +{ + void *mask; + int i, bits = 0, bytelen; + u_int8_t *p; + + switch (sa->sa_family) { + case AF_INET: + mask = (u_int8_t *)&((struct sockaddr_in *)sa)->sin_addr; + bytelen = 4; + break; + case AF_INET6: + mask = (u_int8_t *)&((struct sockaddr_in6 *)sa)->sin6_addr; + bytelen = 16; + break; + default: + return 0; + } + + p = mask; + + for (i = 0; i < bytelen; i++, p++) { + if (*p != 0xff) { + for (bits = 0; bits < 8; bits++) { + if (!(*p & (1 << (7 - bits)))) + break; + } + break; + } + } + + return (i * 8 + bits); +} + +static int +sacmp(struct sockaddr *sa1, struct sockaddr *sa2) +{ + void *p1, *p2; + int len; + + if (sa1->sa_family != sa2->sa_family) + return 1; + + switch (sa1->sa_family) { + case AF_INET: + p1 = &((struct sockaddr_in *)sa1)->sin_addr; + p2 = &((struct sockaddr_in *)sa2)->sin_addr; + len = 4; + break; + case AF_INET6: + p1 = &((struct sockaddr_in6 *)sa1)->sin6_addr; + p2 = &((struct sockaddr_in6 *)sa2)->sin6_addr; + len = 16; + if (((struct sockaddr_in6 *)sa1)->sin6_scope_id != + ((struct sockaddr_in6 *)sa2)->sin6_scope_id) + return 1; + break; + default: + return 1; + } + + return memcmp(p1, p2, len); +} + +/* + * Scan for a host match in a directory tree. + */ +static int +chk_host(dp, saddr, defsetp, hostsetp) + struct dirlist *dp; + struct sockaddr *saddr; + int *defsetp; + int *hostsetp; +{ + struct hostlist *hp; + struct grouplist *grp; + struct addrinfo *ai; + + if (dp) { + if (dp->dp_flag & DP_DEFSET) + *defsetp = dp->dp_flag; + hp = dp->dp_hosts; + while (hp) { + grp = hp->ht_grp; + switch (grp->gr_type) { + case GT_HOST: + ai = grp->gr_ptr.gt_addrinfo; + for (; ai; ai = ai->ai_next) { + if (!sacmp(ai->ai_addr, saddr)) { + *hostsetp = + (hp->ht_flag | DP_HOSTSET); + return (1); + } + } + break; + case GT_NET: + if (!netpartcmp(saddr, + (struct sockaddr *) + &grp->gr_ptr.gt_net.nt_net, + grp->gr_ptr.gt_net.nt_len)) { + *hostsetp = (hp->ht_flag | DP_HOSTSET); + return (1); + } + break; + }; + hp = hp->ht_next; + } + } + return (0); +} + +/* + * Scan tree for a host that matches the address. + */ +static int +scan_tree(dp, saddr) + struct dirlist *dp; + struct sockaddr *saddr; +{ + int defset, hostset; + + if (dp) { + if (scan_tree(dp->dp_left, saddr)) + return (1); + if (chk_host(dp, saddr, &defset, &hostset)) + return (1); + if (scan_tree(dp->dp_right, saddr)) + return (1); + } + return (0); +} + +/* + * Traverse the dirlist tree and free it up. + */ +static void +free_dir(dp) + struct dirlist *dp; +{ + + if (dp) { + free_dir(dp->dp_left); + free_dir(dp->dp_right); + free_host(dp->dp_hosts); + free(dp); + } +} + +/* + * Parse the option string and update fields. + * Option arguments may either be -in + atf_check -o inline:'x\n' sort in +} + +atf_test_case null_bytes +null_bytes_head() +{ + atf_set "descr" "Tests the behavior of null bytes" +} +null_bytes_body() +{ + printf '\0b\n\0a\n' >in + atf_check -o inline:'\0a\n\0b\n' sort -S in +} + +atf_test_case long_records +long_records_head() +{ + atf_set "descr" "Tests long lines and keys" +} +long_records_body() +{ + awk 'BEGIN { x="x" + for(i=1; i<=12; i++) x = x x + for(i=15; i<=25; i++) print x i +}' >in + + awk 'BEGIN { x="x" + for(i=1; i<=12; i++) x = x x + for(i=25; i>=15; i--) print x i +}' >out + + atf_check -o file:out sort -r in + atf_check -o file:out sort -k 1,1r -k 1 in +} + +atf_test_case long_file +long_file_head() +{ + atf_set "descr" "Tests with a long file to try to force intermediate" \ + "files" +} +long_file_body() +{ + awk 'BEGIN { for(i=0; i<20000; i++) print rand() }' >in + sort -S -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out + atf_check -o file:out sort -u -r in +} + +atf_test_case any_char +any_char_head() +{ + atf_set "descr" "Tests with files containing non-printable/extended" \ + "characters" +} +any_char_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_any_char_dflag_out.txt \ + sort -d -k 2 $(atf_get_srcdir)/d_any_char_in.txt + + atf_check -o file:$(atf_get_srcdir)/d_any_char_fflag_out.txt \ + sort -f -k 2 $(atf_get_srcdir)/d_any_char_in.txt + + atf_check -o file:$(atf_get_srcdir)/d_any_char_iflag_out.txt \ + sort -i -k 2 $(atf_get_srcdir)/d_any_char_in.txt +} + +atf_test_case bflag +bflag_head() +{ + atf_set "descr" "Tests the -b flag" +} +bflag_body() +{ + cat >in <in <in <expout <in <expout <in <out <in <in <in <out <in <xx" + atf_check -e ignore sort -c -t: -k2n xx + + atf_check -x "sort -S -k2,2.1b -k2 in >xx" + atf_check -e ignore sort -c -t: -k3n xx + + atf_check -x "sort -S -k2.3 -k2 in >xx" + atf_check -e ignore sort -c -t: -k4n xx + + atf_check -x "sort -S -k2b,2.3 -k2 in >xx" + atf_check -e ignore sort -c -t: -k5n xx + + atf_check -x "sort -S -k2.3,2.1b -k2 in >xx" + atf_check -e ignore sort -c -t: -k6n xx + + atf_check -x "sort -S -k2,2.1b -k2r in >xx" + atf_check -e ignore sort -c -t: -k7n xx + + atf_check -x "sort -S -b -k2,2 -k2 in >xx" + atf_check -e ignore sort -c -t: -k8n xx + + # XXX This test is broken. The standard is not clear on the behavior. + #atf_check -x "sort -S -b -k2,2b -k2 in >xx" + #atf_check -e ignore sort -c -t: -k3n xx +} + +atf_test_case kflag_no_end +kflag_no_end_head() +{ + atf_set "descr" "Tests the -k flag with a field without end" +} +kflag_no_end_body() +{ + cat >in <out <in1 <in2 <out <in <in <out <in <expout <in <expout <in <expout <in <expout <in <out <in1 <in2 <out <in <in <in <out <in <out <out <out <in <expout <in <expout <in <expout <in <expout <./+0 + + atf_check -o file:+0 sort -- +0 +} + +atf_test_case plus_nonmonotone +plus_nonmonotone_head() +{ + atf_set "descr" "Tests += addressing: apparently nonmonotone field" \ + "specs" +} +plus_nonmonotone_body() +{ + cat >in <./+0 + echo 'more contents' >in + cat ./+0 in >expout + + atf_check -o file:expout sort in +0 +} + +atf_test_case plus_bad_tempfile +plus_bad_tempfile_head() +{ + atf_set "descr" "Tests +- addressing: intermediate wrong behavior" \ + "that raised a '+0: No such file or directory' error" +} +plus_bad_tempfile_body() +{ + echo 'good contents' >in + atf_check -o file:in sort -T /tmp +0 in +} + +atf_test_case plus_rflag_invalid +plus_rflag_invalid_head() +{ + atf_set "descr" "Tests +- addressing: invalid record delimiter" +} +plus_rflag_invalid_body() +{ + ( + echo 'z b m f' + echo 'y c o e' + echo 'x a n h' + echo 'x a n g' + ) | tr '\n' '+' >in + + atf_check -o inline:'x a n g+x a n h+z b m f+y c o e+' \ + sort -R + -k2 in +} + +atf_test_case plus_tflag +plus_tflag_head() +{ + atf_set "descr" "Tests +- addressing: using -T caused a 'No such file" \ + "or directory' error" +} +plus_tflag_body() +{ + mkdir ./+ + yes | sed 200000q | sort -T + >/dev/null || atf_fail "program failed" +} + +atf_test_case plus_no_end +plus_no_end_head() +{ + atf_set "descr" "Tests +- addressing: field without end" +} +plus_no_end_body() +{ + cat >in <out </dev/null 2>&1" +} + +atf_test_case stdin +stdin_head() { + atf_set "descr" "Test that tmux(1) does not crash the system " \ + "when stdin(4) is closed (PR kern/46463)" +} + +stdin_body() { + stdincrash +} + +atf_init_test_cases() +{ + atf_add_test_case stdin +} diff --git a/contrib/netbsd-tests/usr.bin/tr/t_basic.sh b/contrib/netbsd-tests/usr.bin/tr/t_basic.sh new file mode 100755 index 000000000000..4515d114a800 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/tr/t_basic.sh @@ -0,0 +1,195 @@ +# $NetBSD: t_basic.sh,v 1.3 2013/08/11 01:50:02 dholland Exp $ +# +# Copyright (c) 2013 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by David A. Holland. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# +# tr -d: delete character +# +atf_test_case dopt +dopt_head() { + atf_set "descr" "Tests for tr -d" +} + +dopt_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -d x' + atf_check -o inline:'abde\n' -x 'echo abcde | tr -d c' + atf_check -o inline:'ace\n' -x 'echo abcde | tr -d bd' + atf_check -o inline:'ae\n' -x 'echo abcde | tr -d b-d' + atf_check -o inline:'b\n' -x 'echo abcde | tr -d ac-e' + atf_check -o inline:'d\n' -x 'echo abcde | tr -d a-ce' + atf_check -o inline:'aei\n' -x 'echo abcdefghi | tr -d b-df-h' + + atf_check -o inline:'' -x 'echo abcde | tr -c -d x' + atf_check -o inline:'c' -x 'echo abcde | tr -c -d c' + atf_check -o inline:'bd' -x 'echo abcde | tr -c -d bd' + atf_check -o inline:'bcd' -x 'echo abcde | tr -c -d b-d' + atf_check -o inline:'acde' -x 'echo abcde | tr -c -d ac-e' + atf_check -o inline:'abce' -x 'echo abcde | tr -c -d a-ce' + atf_check -o inline:'bcdfgh' -x 'echo abcdefghi | tr -c -d b-df-h' + + # see if escape codes work + atf_check -o inline:'splice' -x '(echo spl; echo ice) | tr -d '"'\n'" + atf_check -o inline:'splice' -x '(echo spl; echo ice) | tr -d '"'\012'" + + # see if escape codes work when followed by other things + atf_check -o inline:'slice' -x '(echo spl; echo ice) | tr -d '"'\n'p" + atf_check -o inline:'slice' -x '(echo spl; echo ice) | tr -d '"'\012'p" + + # see if the [=x=] syntax works + atf_check -o inline:'abde\n' -x 'echo abcde | tr -d '"'[=c=]'" + atf_check -o inline:'bde\n' -x 'echo abcde | tr -d '"'[=c=]'a" + + # make sure 0 works + # (ignore stderr as dd blabbers to it) + atf_check -e ignore -o inline:'ab\n' \ + -x '(echo -n a; dd if=/dev/zero bs=3 count=1; echo b) | tr -d '"'\0'" + + # test posix classes + atf_check -o inline:'.\n' -x 'echo aAzZ.123 | tr -d '"'[:alnum:]'" + atf_check -o inline:'.123\n' -x 'echo aAzZ.123 | tr -d '"'[:alpha:]'" + atf_check -o inline:'az\n' -x 'echo "a z" | tr -d '"'[:blank:]'" + atf_check -o inline:'az' -x '(echo a; echo z) | tr -d '"'[:cntrl:]'" + atf_check -o inline:'aAzZ.\n' -x 'echo aAzZ.123 | tr -d '"'[:digit:]'" + atf_check -o inline:' \n' -x 'echo "a z.123" | tr -d '"'[:graph:]'" + atf_check -o inline:'AZ.123\n' -x 'echo aAzZ.123 | tr -d '"'[:lower:]'" + atf_check -o inline:'\n' -x 'echo aAzZ.123 | tr -d '"'[:print:]'" + atf_check -o inline:'aAzZ12\n' -x 'echo aAzZ.12 | tr -d '"'[:punct:]'" + atf_check -o inline:'az' -x 'echo "a z" | tr -d '"'[:space:]'" + atf_check -o inline:'az.123\n' -x 'echo aAzZ.123 | tr -d '"'[:upper:]'" + atf_check -o inline:'zZ.\n' -x 'echo aAzZ.123 | tr -d '"'[:xdigit:]'" +} + +# +# tr -s: squeeze duplicate character runs +# +atf_test_case sopt +sopt_head() { + atf_set "descr" "Tests for tr -s" +} + +sopt_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -s x' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -s c' + atf_check -o inline:'abcde\n' -x 'echo abccccde | tr -s c' + atf_check -o inline:'abcde\n' -x 'echo abbbcddde | tr -s bd' + atf_check -o inline:'abcde\n' -x 'echo abbbcccddde | tr -s b-d' + + atf_check -o inline:'acac\n' -x 'echo acac | tr -s c' + atf_check -o inline:'acac\n' -x 'echo accacc | tr -s c' + + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -c -s x' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -c -s c' + atf_check -o inline:'abcccde\n' -x 'echo abcccde | tr -c -s c' + atf_check -o inline:'abbbcddde\n' -x 'echo abbbcddde | tr -c -s bd' + atf_check -o inline:'abbbccddde\n' -x 'echo abbbccddde | tr -c -s b-d' + atf_check -o inline:'abcccde\n' -x 'echo aaabcccde | tr -c -s b-d' +} + +# +# tr -ds: both -d and -s at once +# +atf_test_case dsopt +dsopt_head() { + atf_set "descr" "Tests for tr -ds" +} + +dsopt_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -ds x y' + atf_check -o inline:'abde\n' -x 'echo abcde | tr -ds c x' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -ds x c' + atf_check -o inline:'abde\n' -x 'echo abcde | tr -ds c c' + atf_check -o inline:'abde\n' -x 'echo abcccde | tr -ds c x' + atf_check -o inline:'abcde\n' -x 'echo abcccde | tr -ds x c' + atf_check -o inline:'abde\n' -x 'echo abcccde | tr -ds c c' + + # -c complements only the first string + atf_check -o inline:'' -x 'echo abcde | tr -c -ds x y' + atf_check -o inline:'c' -x 'echo abcde | tr -c -ds c x' + atf_check -o inline:'' -x 'echo abcde | tr -c -ds x c' + atf_check -o inline:'c' -x 'echo abcde | tr -c -ds c c' + atf_check -o inline:'ccc' -x 'echo abcccde | tr -c -ds c x' + atf_check -o inline:'' -x 'echo abcccde | tr -c -ds x c' + atf_check -o inline:'c' -x 'echo abcccde | tr -c -ds c c' +} + +# +# test substitution +# +atf_test_case subst +subst_head() { + atf_set "descr" "Tests for tr substitution" +} + +subst_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr a-c a-c' + atf_check -o inline:'cbade\n' -x 'echo abcde | tr a-c cba' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr a-z a-z' + atf_check -o inline:'bcdef\n' -x 'echo abcde | tr a-z b-za' + atf_check -o inline:'zabcd\n' -x 'echo abcde | tr b-za a-z' + atf_check -o inline:'bbbbb\n' -x 'echo ababa | tr a b' + atf_check -o inline:'furrfu\n' -x 'echo sheesh | tr a-z n-za-m' + atf_check -o inline:'furrfu\n' -x 'echo sheesh | tr n-za-m a-z' + + atf_check -o inline:'ABCDE\n' -x 'echo abcde | tr a-z A-Z' + atf_check -o inline:'ABC\n' \ + -x 'echo abc | tr '"'[:lower:]' '[:upper:]'" + + # If you don't give enough substitution chars the last is repeated. + atf_check -o inline:'bozoo\n' -x 'echo abcde | tr a-z bozo' + atf_check -o inline:'qaaaa\n' -x 'echo abcde | tr a-z qa' + + # You can use -s with substitution. + atf_check -o inline:'cbade\n' -x 'echo abcde | tr -s a-c cba' + atf_check -o inline:'cbaddee\n' -x 'echo aabbccddee | tr -s a-c cba' +} + +# +# test substitution with -c (does not currently work) +# +atf_test_case csubst +csubst_head() { + atf_set "descr" "Tests for tr substitution with -c" +} + +csubst_body() { + atf_check -o inline:'abcde\n' -x \ + 'echo abcde | tr -c '"'\0-ac-\377' b" + atf_check -o inline:'abcde\n' -x \ + 'echo abcde | tr -c '"'\0-ad-\377' bc" + atf_check -o inline:'QUACK\n' -x \ + 'echo ABCDE | tr -c '"'\0-@' QUACK" +} + +atf_init_test_cases() { + atf_add_test_case dopt + atf_add_test_case sopt + atf_add_test_case dsopt + atf_add_test_case subst + atf_add_test_case csubst +} diff --git a/contrib/netbsd-tests/usr.bin/unifdef/d_basic.in b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.in new file mode 100644 index 000000000000..9de6a94a0773 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.in @@ -0,0 +1,25 @@ +#if defined(__FreeBSD__) +#include +#else +#include +#endif + +#if defined(__FreeBSD__) + #include + #include + #include + #include + #include + #include +#else +#include +#endif + +#if defined(__FreeBSD__) +#endif + +#ifdef __FreeBSD__ +#include +#else +#include +#endif diff --git a/contrib/netbsd-tests/usr.bin/unifdef/d_basic.out b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.out new file mode 100644 index 000000000000..2d52e9e7ae29 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.out @@ -0,0 +1,6 @@ +#include + +#include + + +#include diff --git a/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh new file mode 100755 index 000000000000..43ca2808d7fa --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh @@ -0,0 +1,62 @@ +# $NetBSD: t_basic.sh,v 1.6 2012/10/15 17:49:58 njoly Exp $ +# +# Copyright (c) 2011 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case basic +basic_head() { + atf_set "descr" "A basic test of unifdef(1) (PR bin/42628)" + atf_set "require.progs" "unifdef" +} + +basic_body() { + + atf_check -s ignore -o file:$(atf_get_srcdir)/d_basic.out \ + -x "unifdef -U__FreeBSD__ $(atf_get_srcdir)/d_basic.in" +} + +atf_test_case lastline +lastline_head() { + atf_set "descr" "Checks with directive on last line (PR bin/47068)" +} + +lastline_body() { + + # With newline after cpp directive + printf '#ifdef foo\n#endif\n' >input + atf_check -o file:input unifdef -Ubar input + + # Without newline after cpp directive + printf '#ifdef foo\n#endif' >input + atf_check -o file:input unifdef -Ubar input +} + +atf_init_test_cases() { + atf_add_test_case basic + atf_add_test_case lastline +} diff --git a/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh b/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh new file mode 100755 index 000000000000..66769007e3b6 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh @@ -0,0 +1,48 @@ +# $NetBSD: t_vmstat.sh,v 1.1 2014/01/07 16:47:13 gson Exp $ +# +# Copyright (c) 2013 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +atf_test_case default +default_head() { + atf_set "descr" "Test that vmstat(1) returns success when run with no arguments" +} +default_body() { + atf_check -s exit:0 -o ignore -e empty vmstat +} + +atf_test_case opt_s +opt_s_head() { + atf_set "descr" "Test that vmstat(1) returns success when run with -s (PR 44518)" +} +opt_s_body() { + atf_check -s exit:0 -o ignore -e empty vmstat -s +} + +atf_init_test_cases() +{ + atf_add_test_case default + atf_add_test_case opt_s +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_alignof.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_alignof.c new file mode 100644 index 000000000000..4a661346305b --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_alignof.c @@ -0,0 +1,6 @@ +/* __alignof__ */ +int +main(void) +{ + return __alignof__(short); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_num.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_num.c new file mode 100644 index 000000000000..c3c952e7b722 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_num.c @@ -0,0 +1,7 @@ +double cabs(double _Complex); + +double cabs(double _Complex foo) +{ + double d = __real__ foo; + return d + 0.1fi; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_split.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_split.c new file mode 100644 index 000000000000..7b3d1a1d501e --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_split.c @@ -0,0 +1,8 @@ +int b(double a) { + return a == 0; +} +void a(void) { + double _Complex z = 0; + if (b(__real__ z) && b(__imag__ z)) + return; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c new file mode 100644 index 000000000000..f32a963c76b0 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c @@ -0,0 +1,5 @@ +void sample(void) +{ + int i = 0; i += 1; + int j = 0; j += 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c new file mode 100644 index 000000000000..960d392350ca --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c @@ -0,0 +1,6 @@ +typedef int int_t; +int main(void) { +int i = 0; i += 1; +int_t j = 0; j += 1; +return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c new file mode 100644 index 000000000000..278fe1bb713c --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c @@ -0,0 +1,5 @@ +void sample(int i) +{ + i += 1; + int j = 0; j += 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_for_loops.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_for_loops.c new file mode 100644 index 000000000000..48e380cb3600 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_for_loops.c @@ -0,0 +1,15 @@ +/* c99 for loops */ +extern void foo(int); + +int +main(void) +{ + // Test the basic functionality + for (int i = 0; i < 10; i++) + foo(i); + + // Test that the scope of the iterator is correct + for (int i = 0; i < 10; i++) + continue; + return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_func.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_func.c new file mode 100644 index 000000000000..b827bfa9f6bc --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_func.c @@ -0,0 +1,7 @@ +/* C99 __func__ */ + +void +foo(const char *p) { + p = __func__; + foo(p); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_recursive_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_recursive_init.c new file mode 100644 index 000000000000..347644ffe107 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_recursive_init.c @@ -0,0 +1,13 @@ +/* C99 recursive struct/union initialization */ +struct top { + int i; + char c; + union onion { + short us; + char uc; + } u; + char *s; +} c[] = { + { .s = "foo", .c = 'b', .u = { .uc = 'c' } }, + { .i = 1, .c = 'a', .u = { .us = 2 } }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_struct_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_struct_init.c new file mode 100644 index 000000000000..a94cbd163897 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_struct_init.c @@ -0,0 +1,10 @@ +/* C99 struct initialization */ +struct { + int i; + char *s; +} c[] = { + { .i = 2, }, + { .s = "foo" }, + { .i = 1, .s = "bar" }, + { .s = "foo", .i = -1 }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init1.c new file mode 100644 index 000000000000..0e1a1a8323d9 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init1.c @@ -0,0 +1,8 @@ +/* C99 union initialization */ +union { + int i; + char *s; +} c[] = { + { i: 1 }, + { s: "foo" } +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init2.c new file mode 100644 index 000000000000..51d34d450f21 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init2.c @@ -0,0 +1,8 @@ +/* C99 union initialization */ +union { + int i[10]; + short s; +} c[] = { + { s: 2 }, + { i: { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init3.c new file mode 100644 index 000000000000..f5e8b59f4621 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init3.c @@ -0,0 +1,8 @@ +/* C99 union initialization */ +struct { + int i[10]; + char *s; +} c[] = { + { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + "foo" }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_array_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_array_init.c new file mode 100644 index 000000000000..66f0e9ec158e --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_array_init.c @@ -0,0 +1,6 @@ +/* C9X array initializers */ +int foo[256] = { + [2] = 1, + [3] = 2, + [4 ... 5] = 3 +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c new file mode 100644 index 000000000000..df907cd7a3cd --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c @@ -0,0 +1,16 @@ +/* C9X struct/union member init, with nested union and trailing member */ +union node { + void *next; + char *data; +}; +struct foo { + int b; + union node n; + int c; +}; + +struct foo f = { + .b = 1, + .n = { .next = 0, }, + .c = 1 +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init.c new file mode 100644 index 000000000000..36986e800ac4 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init.c @@ -0,0 +1,27 @@ +/* cast initialization */ +typedef unsigned char u_char; +typedef unsigned int size_t; +struct sockaddr_x25 { + u_char x25_len; + u_char x25_family; + short x25_net; + char x25_addr[16]; + struct x25opts { + char op_flags; + char op_psize; + char op_wsize; + char op_speed; + } x25_opts; + short x25_udlen; + char x25_udata[16]; +}; + +struct sockaddr_x25 x25_dgmask = { + (unsigned char)(unsigned char)(unsigned int)(unsigned long)(&((( struct sockaddr_x25 *)0)->x25_udata[1])) , + 0, + 0, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {0, 0, 0, 0}, + -1, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init2.c new file mode 100644 index 000000000000..9597d3580397 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init2.c @@ -0,0 +1,7 @@ +/* cast initialization as the rhs of a - operand */ +struct sockaddr_dl { + char sdl_data[2]; +}; + +int npdl_datasize = sizeof(struct sockaddr_dl) - +((int) ((unsigned long)&((struct sockaddr_dl *) 0)->sdl_data[0])); diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_lhs.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_lhs.c new file mode 100644 index 000000000000..eb865695535f --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_lhs.c @@ -0,0 +1,7 @@ +/* pointer casts are valid lhs lvalues */ +struct sockaddr { }; +void +foo() { + unsigned long p = 6; + ((struct sockaddr *)p) = 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals1.c new file mode 100644 index 000000000000..cd1987ae17de --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals1.c @@ -0,0 +1,11 @@ +/* compound literals */ + +struct p { + short a, b, c, d; +}; + +foo() +{ + struct p me = (struct p) {1, 2, 3, 4}; + me.a = me.b; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals2.c new file mode 100644 index 000000000000..e4ffb929873f --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals2.c @@ -0,0 +1,18 @@ +/* compound literals */ + +struct p { + short a, b, c, d; +} zz = { + 1, 2, 3, 4 +}; + +struct p *bar(int i) +{ + static struct p q[10]; + return &q[i]; +} + +foo() +{ + *bar(1) = (struct p) { 1, 2, 3, 4 }; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv1.c new file mode 100644 index 000000000000..53795c5fe858 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv1.c @@ -0,0 +1,9 @@ +/* Flag information-losing constant conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + f(-1); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv2.c new file mode 100644 index 000000000000..87066c96b5a8 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv2.c @@ -0,0 +1,9 @@ +/* Flag information-losing constant conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + f(2.1); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_constant.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_constant.c new file mode 100644 index 000000000000..aa74509fa42e --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_constant.c @@ -0,0 +1,8 @@ +/* the second assignment assumes failed before */ +int +main(void) { + double x = 1; + int foo = 0; + if (foo) + x = 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c new file mode 100644 index 000000000000..4a6149c67224 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c @@ -0,0 +1,13 @@ +/* CVT node handling in ?: operator */ +typedef unsigned long int size_t; +struct filecore_direntry { + unsigned len:32; +}; +int +main(void) +{ + struct filecore_direntry dirent = { 0 }; + size_t uio_resid = 0; + size_t bytelen = (((dirent.len)<(uio_resid))?(dirent.len):(uio_resid)); + return bytelen; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c new file mode 100644 index 000000000000..ba4a338d29ae --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c @@ -0,0 +1,11 @@ +int x(void) +{ + int i = 33; + switch (i) { + case 1 ... 40: + break; + default: + break; + } + return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c new file mode 100644 index 000000000000..d970be182648 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c @@ -0,0 +1,7 @@ +/* GCC compound statements */ + +foo(unsigned long z) +{ + z = ({ unsigned long tmp; tmp = 1; tmp; }); + foo(z); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c new file mode 100644 index 000000000000..fa1ee67302c5 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c @@ -0,0 +1,14 @@ +/* GCC compound statements with non-expressions */ +struct cpu_info { + int bar; +}; + +int +main(void) +{ + return ({ + struct cpu_info *__ci; + __asm__ volatile("movl %%fs:4,%0":"=r" (__ci)); + __ci; + })->bar; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c new file mode 100644 index 000000000000..29e9063dcf4a --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c @@ -0,0 +1,10 @@ +/* GCC compound statements with void type */ + +void +main(void) +{ + ({ + void *v; + __asm__ volatile("noop"); + }); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_extension.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_extension.c new file mode 100644 index 000000000000..d8bd8f5fe944 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_extension.c @@ -0,0 +1,6 @@ +/* extension */ +void a(void) { + double __logbw = 1; + if (__extension__(({ __typeof((__logbw)) x_ = (__logbw); !__builtin_isinf((x_)) && !__builtin_isnan((x_)); }))) + __logbw = 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_func.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_func.c new file mode 100644 index 000000000000..459919de2955 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_func.c @@ -0,0 +1,7 @@ +/* gcc __FUNCTION__ */ + +void +foo(const char *p) { + p = __FUNCTION__; + foo(p); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c new file mode 100644 index 000000000000..d5b01ad0c2d2 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c @@ -0,0 +1,7 @@ +/* gcc: variable array initializer */ +void foo(int i) +{ + int array[i]; + while (i--) + foo(array[i] = 0); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_incorrect_array_size.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_incorrect_array_size.c new file mode 100644 index 000000000000..c86c0d6b3b70 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_incorrect_array_size.c @@ -0,0 +1,3 @@ +struct foo { + int a[-1]; +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_long_double_int.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_long_double_int.c new file mode 100644 index 000000000000..a5a644e3e3d4 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_long_double_int.c @@ -0,0 +1,7 @@ +/* PR 39639: writing "long double" gave "long int" */ + +int +fail(long double *a, long int *b) +{ + return a == b; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nested_structs.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nested_structs.c new file mode 100644 index 000000000000..edd3396bd224 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nested_structs.c @@ -0,0 +1,21 @@ +/* Nested struct */ +typedef void *EditLine; +typedef void *History; + +typedef struct { + EditLine *el; + History *hist; +} el_mode_t; + +struct el_modes_s { + el_mode_t command; + el_mode_t string; + el_mode_t filec; + el_mode_t mime_enc; +}; + +struct el_modes_s elm = { + .command = { .el = 0, .hist = 0, }, + .string = { .el = 0, .hist = 0, }, + .filec = { .el = 0, .hist = 0, }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nolimit_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nolimit_init.c new file mode 100644 index 000000000000..68e71b4df050 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nolimit_init.c @@ -0,0 +1,4 @@ +/* no limit initializers */ +char foo[][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_packed_structs.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_packed_structs.c new file mode 100644 index 000000000000..71b438496f92 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_packed_structs.c @@ -0,0 +1,35 @@ +/* packed tests */ + +struct in_addr { + int x; +}; +struct ip_timestamp { + char ipt_code; + char ipt_len; + char ipt_ptr; + unsigned int ipt_flg:4, + ipt_oflw:4; + union ipt_timestamp { + int ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + int ipt_time; + } ipt_ta[1] __packed; + } ipt_timestamp __packed; +} __packed; + +typedef struct __packed { + int x; +} t; + +struct x { + char c; + long l; +} __packed; + +struct y { + char c; + long l; +}; + +int a[sizeof(struct y) - sizeof(struct x) - 1]; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c new file mode 100644 index 000000000000..0208944a2d12 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c @@ -0,0 +1,24 @@ +// Test that type shifts that result to narrower types don't produce warnings. + +void +foo(void) { + unsigned long l = 100; + unsigned long long ll = 100; + unsigned int i = 100; + unsigned short s = 100; + unsigned char c = 1; + + l = ll >> 32; +// i = ll >> 31; + i = ll >> 32; + s = ll >> 48; + c = ll >> 56; + s = i >> 16; + c = i >> 24; + c = s >> 8; + (void)≪ + (void)&l; + (void)&i; + (void)&s; + (void)&c; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv1.c new file mode 100644 index 000000000000..d9e470e941b9 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv1.c @@ -0,0 +1,11 @@ +/* Flag information-losing type conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + long long x = 20; + + f(x); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv2.c new file mode 100644 index 000000000000..7c2e1f478ecd --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv2.c @@ -0,0 +1,11 @@ +/* Flag information-losing type conversion in argument lists */ + +int f(float); + +void +should_fail() +{ + double x = 2.0; + + f(x); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv3.c new file mode 100644 index 000000000000..bc6a8e695ada --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv3.c @@ -0,0 +1,10 @@ +/* Flag information-losing type conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + + f(0x7fffffffffffffffLL); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typename_as_var.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typename_as_var.c new file mode 100644 index 000000000000..248dc7558b52 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typename_as_var.c @@ -0,0 +1,14 @@ +typedef char h[10]; + +typedef struct { + int i; + char *c; +} fh; + +struct foo { + fh h; + struct { + int x; + int y; + } fl; +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c new file mode 100644 index 000000000000..9c06c6b5e413 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c @@ -0,0 +1,3 @@ +struct foo { +int a[0]; +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh b/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh new file mode 100755 index 000000000000..9575f9664d3b --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh @@ -0,0 +1,132 @@ +# $NetBSD: t_integration.sh,v 1.4 2014/04/21 19:10:41 christos Exp $ +# +# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +LINT1=/usr/libexec/lint1 + +Names= + +check_valid() +{ + atf_check -s exit:0 ${LINT1} -g -S "$(atf_get_srcdir)/$1" /dev/null +} + +check_invalid() +{ + atf_check -s not-exit:0 -o ignore -e ignore ${LINT1} -g -S -w \ + "$(atf_get_srcdir)/$1" /dev/null +} + +test_case() +{ + local result="${1}"; shift + local name="${1}"; shift + local descr="${*}" + + atf_test_case ${name} + eval "${name}_head() { + atf_set \"descr\" \"${descr}\"; + atf_set \"require.progs\" \"${LINT1}\"; + }" + eval "${name}_body() { + ${result} d_${name}.c; + }" + + Names="${Names} ${name}" +} + +test_case check_valid c99_struct_init "Checks C99 struct initialization" +test_case check_valid c99_union_init1 "Checks C99 union initialization" +test_case check_valid c99_union_init2 "Checks C99 union initialization" +test_case check_valid c99_union_init3 "Checks C99 union initialization" +test_case check_valid c99_recursive_init "Checks C99 recursive struct/union" \ + "initialization" +test_case check_valid c9x_recursive_init "Checks C9X struct/union member" \ + "init, with nested union and trailing member" +test_case check_valid nested_structs "Checks nested structs" +test_case check_valid packed_structs "Checks packed structs" + +test_case check_valid cast_init "Checks cast initialization" +test_case check_valid cast_init2 "Checks cast initialization as the rhs of a" \ + "- operand" +test_case check_valid cast_lhs "Checks whether pointer casts are valid lhs" \ + "lvalues" + +test_case check_valid gcc_func "Checks GCC __FUNCTION__" +test_case check_valid c99_func "Checks C99 __func__" + +test_case check_valid gcc_variable_array_init "Checks GCC variable array" \ + "initializers" +test_case check_valid c9x_array_init "Checks C9X array initializers" +test_case check_valid c99_decls_after_stmt "Checks C99 decls after statements" +test_case check_valid c99_decls_after_stmt3 "Checks C99 decls after statements" +test_case check_valid nolimit_init "Checks no limit initializers" +test_case check_valid zero_sized_arrays "Checks zero sized arrays" + +test_case check_valid compound_literals1 "Checks compound literals" +test_case check_valid compound_literals2 "Checks compound literals" +test_case check_valid gcc_compound_statements1 "Checks GCC compound statements" +test_case check_valid gcc_compound_statements2 "Checks GCC compound" \ + "statements with non-expressions" +test_case check_valid gcc_compound_statements3 "Checks GCC compound" \ + "statements with void type" +# XXX: Because of polymorphic __builtin_isnan and expression has null effect +# test_case check_valid gcc_extension "Checks GCC __extension__ and __typeof__" + +test_case check_valid cvt_in_ternary "Checks CVT nodes handling in ?" \ +test_case check_valid cvt_constant "Checks constant conversion" +test_case check_valid ellipsis_in_switch "Checks ellipsis in switch()" +test_case check_valid c99_complex_num "Checks C99 complex numbers" +test_case check_valid c99_complex_split "Checks C99 complex access" +test_case check_valid c99_for_loops "Checks C99 for loops" +test_case check_valid alignof "Checks __alignof__" +test_case check_valid shift_to_narrower_type "Checks that type shifts that" \ + "result in narrower types do not produce warnings" + +test_case check_invalid constant_conv1 "Checks failing on information-losing" \ + "constant conversion in argument lists" +test_case check_invalid constant_conv2 "Checks failing on information-losing" \ + "constant conversion in argument lists" + +test_case check_invalid type_conv1 "Checks failing on information-losing" \ + "type conversion in argument lists" +test_case check_invalid type_conv2 "Checks failing on information-losing" \ + "type conversion in argument lists" +test_case check_invalid type_conv3 "Checks failing on information-losing" \ + "type conversion in argument lists" + +test_case check_invalid incorrect_array_size "Checks failing on incorrect" \ + "array sizes" + +test_case check_invalid long_double_int "Checks for confusion of 'long" \ + "double' with 'long int'; PR 39639" + +atf_init_test_cases() +{ + for name in ${Names}; do + atf_add_test_case ${name} + done +} diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert.in b/contrib/netbsd-tests/usr.sbin/mtree/d_convert.in new file mode 100644 index 000000000000..6a1abb07e1b0 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert.in @@ -0,0 +1,40 @@ +# Similar to d_create.out, but a few entries have been deleted; nlink, +# size and sha256 attributes have been removed; and the order has been +# changed to test sorting. + +# . +. type=dir + a.symlink.1 type=link link=a.file.1 + top.dangling type=link link=nonexistent + top.symlink.b \ + type=link link=b + +# ./b +b type=dir + b.file.2 type=file + b.file.1 type=file +# end ./b, up to "." +.. + + top.file.1 type=file + +# ./a +a type=dir + a.file.2 type=file + +# ./a/1 +1 type=dir + a1.file.1 type=file +# end ./a/1, up to "./a" +.. + + a.file.1 type=file + +# ./a/2 +2 type=dir +# end ./a/2, up to "./a" +.. + +# end ./a, up to "." +.. + diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C.out new file mode 100644 index 000000000000..de4d9f6e5a2d --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C.out @@ -0,0 +1,14 @@ +. type=dir +./a.symlink.1 type=link link=a.file.1 +./top.dangling type=link link=nonexistent +./top.symlink.b type=link link=b +./b type=dir +./b/b.file.2 type=file +./b/b.file.1 type=file +./top.file.1 type=file +./a type=dir +./a/a.file.2 type=file +./a/1 type=dir +./a/1/a1.file.1 type=file +./a/a.file.1 type=file +./a/2 type=dir diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C_S.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C_S.out new file mode 100644 index 000000000000..bd03cc458859 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C_S.out @@ -0,0 +1,14 @@ +. type=dir +./a.symlink.1 type=link link=a.file.1 +./top.dangling type=link link=nonexistent +./top.file.1 type=file +./top.symlink.b type=link link=b +./a type=dir +./a/a.file.1 type=file +./a/a.file.2 type=file +./a/1 type=dir +./a/1/a1.file.1 type=file +./a/2 type=dir +./b type=dir +./b/b.file.1 type=file +./b/b.file.2 type=file diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D.out new file mode 100644 index 000000000000..c059478131a0 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D.out @@ -0,0 +1,14 @@ +type=dir . +type=link link=a.file.1 ./a.symlink.1 +type=link link=nonexistent ./top.dangling +type=link link=b ./top.symlink.b +type=dir ./b +type=file ./b/b.file.2 +type=file ./b/b.file.1 +type=file ./top.file.1 +type=dir ./a +type=file ./a/a.file.2 +type=dir ./a/1 +type=file ./a/1/a1.file.1 +type=file ./a/a.file.1 +type=dir ./a/2 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D_S.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D_S.out new file mode 100644 index 000000000000..a777a0b0112f --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D_S.out @@ -0,0 +1,14 @@ +type=dir . +type=link link=a.file.1 ./a.symlink.1 +type=link link=nonexistent ./top.dangling +type=file ./top.file.1 +type=link link=b ./top.symlink.b +type=dir ./a +type=file ./a/a.file.1 +type=file ./a/a.file.2 +type=dir ./a/1 +type=file ./a/1/a1.file.1 +type=dir ./a/2 +type=dir ./b +type=file ./b/b.file.1 +type=file ./b/b.file.2 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_merge.in b/contrib/netbsd-tests/usr.sbin/mtree/d_merge.in new file mode 100644 index 000000000000..9efd04b018c8 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_merge.in @@ -0,0 +1,27 @@ +# The last entry for any duplicate node should take precedence. + +. type=dir + +# directory "a" with only one entry, changing from dir to link +./a type=dir +./a/change-dir-to-link type=dir mode=0755 +./a/change-dir-to-link type=link mode=0755 + +# directory "b" with only one entry, changing from link to dir +./b type=dir +./b/change-link-to-dir type=link mode=0755 +./b/change-link-to-dir type=dir mode=0755 + +# directory "c" with multiple entries, one changing from dir to link +./c type=dir +./c/aaa type=file +./c/zzz type=file +./c/change-dir-to-link type=dir mode=0755 +./c/change-dir-to-link type=link mode=0755 + +# directory "d" with multiple entries, one changing from link to dir +./d type=dir +./d/aaa type=file +./d/zzz type=file +./d/change-link-to-dir type=link mode=0755 +./d/change-link-to-dir type=dir mode=0755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M.out b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M.out new file mode 100644 index 000000000000..dea996699ffc --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M.out @@ -0,0 +1,13 @@ +. type=dir +./a type=dir +./a/change-dir-to-link type=link mode=0755 +./b type=dir +./b/change-link-to-dir type=dir mode=0755 +./c type=dir +./c/aaa type=file +./c/zzz type=file +./c/change-dir-to-link type=link mode=0755 +./d type=dir +./d/aaa type=file +./d/zzz type=file +./d/change-link-to-dir type=dir mode=0755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M_S.out b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M_S.out new file mode 100644 index 000000000000..9f02beae7a2b --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M_S.out @@ -0,0 +1,13 @@ +. type=dir +./a type=dir +./a/change-dir-to-link type=link mode=0755 +./b type=dir +./b/change-link-to-dir type=dir mode=0755 +./c type=dir +./c/aaa type=file +./c/change-dir-to-link type=link mode=0755 +./c/zzz type=file +./d type=dir +./d/aaa type=file +./d/zzz type=file +./d/change-link-to-dir type=dir mode=0755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/mtree_d_create.out b/contrib/netbsd-tests/usr.sbin/mtree/mtree_d_create.out new file mode 100644 index 000000000000..389ec653e076 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/mtree_d_create.out @@ -0,0 +1,55 @@ +# user: x +# machine: x +# tree: x +# date: x + +# . +/set type=file nlink=1 +. type=dir nlink=4 + a.symlink.1 type=link link=a.file.1 + top.dangling \ + type=link link=nonexistent + top.file.1 size=18 \ + sha256=74c53aaf0cd9543b7efad969de1058ee38859134ba467500b849811fc3513195 + top.symlink.b \ + type=link link=b + +# ./a +a type=dir nlink=4 + a.file.1 size=18 \ + sha256=bdbea62f7ccdf862f22254ea871d523845250010d5f233896e800142a859eef2 + a.file.2 size=18 \ + sha256=77876d113fe1b45a41f8d1d3e178aaad7f91fcd93d3df782690625b74ad90fe6 + a.hardlink.b2 \ + nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + +# ./a/1 +1 type=dir nlink=2 + a1.file.1 size=21 \ + sha256=a062cd272facdd38c4fdeff2a18947b28c99a28a8fe51f88468978740382e592 +# ./a/1 +.. + + +# ./a/2 +2 type=dir nlink=2 +# ./a/2 +.. + +# ./a +.. + + +# ./b +b type=dir nlink=2 + b.file.1 nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 + b.file.2 nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + b.hardlink.1 \ + nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 +# ./b +.. + diff --git a/contrib/netbsd-tests/usr.sbin/mtree/netbsd6_d_create.out b/contrib/netbsd-tests/usr.sbin/mtree/netbsd6_d_create.out new file mode 100644 index 000000000000..389ec653e076 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/netbsd6_d_create.out @@ -0,0 +1,55 @@ +# user: x +# machine: x +# tree: x +# date: x + +# . +/set type=file nlink=1 +. type=dir nlink=4 + a.symlink.1 type=link link=a.file.1 + top.dangling \ + type=link link=nonexistent + top.file.1 size=18 \ + sha256=74c53aaf0cd9543b7efad969de1058ee38859134ba467500b849811fc3513195 + top.symlink.b \ + type=link link=b + +# ./a +a type=dir nlink=4 + a.file.1 size=18 \ + sha256=bdbea62f7ccdf862f22254ea871d523845250010d5f233896e800142a859eef2 + a.file.2 size=18 \ + sha256=77876d113fe1b45a41f8d1d3e178aaad7f91fcd93d3df782690625b74ad90fe6 + a.hardlink.b2 \ + nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + +# ./a/1 +1 type=dir nlink=2 + a1.file.1 size=21 \ + sha256=a062cd272facdd38c4fdeff2a18947b28c99a28a8fe51f88468978740382e592 +# ./a/1 +.. + + +# ./a/2 +2 type=dir nlink=2 +# ./a/2 +.. + +# ./a +.. + + +# ./b +b type=dir nlink=2 + b.file.1 nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 + b.file.2 nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + b.hardlink.1 \ + nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 +# ./b +.. + diff --git a/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh b/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh new file mode 100755 index 000000000000..20fda75e02ea --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh @@ -0,0 +1,422 @@ +# $NetBSD: t_mtree.sh,v 1.6 2013/02/05 16:49:42 christos Exp $ +# +# Copyright (c) 2009, 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# Postprocess mtree output, canonicalising portions that +# are expected to differ from one run to another. +# + +h_postprocess() +{ + sed -e ' + /^# user: /s/:.*/: x/ + /^# machine: /s/:.*/: x/ + /^# tree: /s/:.*/: x/ + /^# date: /s/:.*/: x/ + ' \ + -e '/type=dir/s/ size=[0-9]*//' +} + +h_check() +{ + diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ" +} + + +atf_test_case mtree_create +atf_test_case netbsd6_create +create_head() +{ + atf_set "descr" "Create a specfile describing a directory tree" +} + +create_setup() +{ + # create some directories + rm -fr create + mkdir -p create/a/1 create/a/2 create/b + # create some files + for file in create/top.file.1 \ + create/a/a.file.1 \ + create/a/a.file.2 \ + create/a/1/a1.file.1 \ + create/b/b.file.1 \ + create/b/b.file.2 + do + echo "$file" >$file + done + # hard link to file in same dir + ln create/b/b.file.1 create/b/b.hardlink.1 + # hard link to file in another dir + ln create/b/b.file.2 create/a/a.hardlink.b2 + # symlink to file + ln -s a.file.1 create/a.symlink.1 + # symlink to dir + ln -s b create/top.symlink.b + # dangling symlink + ln -s nonexistent create/top.dangling +} + +create_body() +{ + create_setup + + # run mtree and check output + ( cd create && mtree -F ${FLAVOR} -c -k type,nlink,link,size,sha256 ) >output.raw \ + || atf_fail "mtree exit status $?" + h_postprocess output + h_check "$(atf_get_srcdir)/${FLAVOR}_d_create.out" output +} + +mtree_create_head() +{ + FLAVOR=mtree create_head +} +netbsd6_create_head() +{ + FLAVOR=netbsd6 create_head +} + +mtree_create_body() +{ + FLAVOR=mtree create_body +} +netbsd6_create_body() +{ + FLAVOR=netbsd6 create_body +} + + +atf_test_case mtree_check +atf_test_case netbsd6_check +check_head() +{ + atf_set "descr" "Check a directory tree against a specfile" +} + +check_body() +{ + # we use the same directory tree and specfile as in the "create" test + create_setup + + # run mtree and check output + ( cd create && mtree -F ${FLAVOR} ) <"$(atf_get_srcdir)/${FLAVOR}_d_create.out" >output \ + || atf_fail "mtree exit status $?" + h_check /dev/null output +} + +mtree_check_head() +{ + FLAVOR=mtree check_head +} +netbsd6_check_head() +{ + FLAVOR=netbsd6 check_head +} + +mtree_check_body() +{ + FLAVOR=mtree check_body +} +netbsd6_check_body() +{ + FLAVOR=netbsd6 check_body +} + + +atf_test_case mtree_convert_C +atf_test_case netbsd6_convert_C +convert_C_head() +{ + atf_set "descr" "Convert a specfile to mtree -C format, unsorted" +} + +convert_C_body() +{ + mtree -F ${FLAVOR} -C -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_C.out" output +} + +mtree_convert_C_head() +{ + FLAVOR=mtree convert_C_head +} +netbsd6_convert_C_head() +{ + FLAVOR=netbsd6 convert_C_head +} + +mtree_convert_C_body() +{ + FLAVOR=mtree convert_C_body +} +netbsd6_convert_C_body() +{ + FLAVOR=netbsd6 convert_C_body +} + + +atf_test_case mtree_convert_C_S +atf_test_case netbsd6_convert_C_S +convert_C_S_head() +{ + atf_set "descr" "Convert a specfile to mtree -C format, sorted" +} + +convert_C_S_body() +{ + mtree -F ${FLAVOR} -C -S -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_C_S.out" output +} + +mtree_convert_C_S_head() +{ + FLAVOR=mtree convert_C_S_head +} +netbsd6_convert_C_S_head() +{ + FLAVOR=netbsd6 convert_C_S_head +} + +mtree_convert_C_S_body() +{ + FLAVOR=mtree convert_C_S_body +} +netbsd6_convert_C_S_body() +{ + FLAVOR=netbsd6 convert_C_S_body +} + + +atf_test_case mtree_convert_D +atf_test_case netbsd6_convert_D +convert_D_head() +{ + atf_set "descr" "Convert a specfile to mtree -D format, unsorted" +} + +convert_D_body() +{ + mtree -F ${FLAVOR} -D -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_D.out" output +} + +mtree_convert_D_head() +{ + FLAVOR=mtree convert_D_head +} +netbsd6_convert_D_head() +{ + FLAVOR=netbsd6 convert_D_head +} + +mtree_convert_D_body() +{ + FLAVOR=mtree convert_D_body +} +netbsd6_convert_D_body() +{ + FLAVOR=netbsd6 convert_D_body +} + + +atf_test_case mtree_convert_D_S +atf_test_case netbsd6_convert_D_S +convert_D_S_head() +{ + atf_set "descr" "Convert a specfile to mtree -D format, sorted" +} + +convert_D_S_body() +{ + mtree -F ${FLAVOR} -D -S -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_D_S.out" output +} + +mtree_convert_D_S_head() +{ + FLAVOR=mtree convert_D_S_head +} +netbsd6_convert_D_S_head() +{ + FLAVOR=netbsd6 convert_D_S_head +} + +mtree_convert_D_S_body() +{ + FLAVOR=mtree convert_D_S_body +} +netbsd6_convert_D_S_body() +{ + FLAVOR=netbsd6 convert_D_S_body +} + + +atf_test_case mtree_ignore +atf_test_case netbs6_ignore +ignore_head() +{ + atf_set "descr" "Test that -d ignores symlinks (PR bin/41061)" +} + +ignore_body() +{ + mkdir newdir + mtree -F ${FLAVOR} -c | mtree -F ${FLAVOR} -Ck uid,gid,mode > mtree.spec + ln -s newdir otherdir + + # This yields "extra: otherdir" even with -d. + # (PR bin/41061) + atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec" + + # Delete the symlink and re-verify. + # + rm otherdir + atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec" +} + +mtree_ignore_head() +{ + FLAVOR=mtree ignore_head +} +netbsd6_ignore_head() +{ + FLAVOR=netbsd6 ignore_head +} + +mtree_ignore_body() +{ + FLAVOR=mtree ignore_body +} +netbsd6_ignore_body() +{ + FLAVOR=netbsd6 ignore_body +} + + +atf_test_case mtree_merge +atf_test_case netbsd6_merge +merge_head() +{ + atf_set "descr" "Merge records of different type" +} + +merge_body() +{ + mtree -F ${FLAVOR} -C -M -K all <"$(atf_get_srcdir)/d_merge.in" >output + h_check "$(atf_get_srcdir)/d_merge_C_M.out" output + # same again, with sorting + mtree -F ${FLAVOR} -C -M -S -K all <"$(atf_get_srcdir)/d_merge.in" >output + h_check "$(atf_get_srcdir)/d_merge_C_M_S.out" output +} + +mtree_merge_head() +{ + FLAVOR=mtree merge_head +} +netbsd6_merge_head() +{ + FLAVOR=netbsd6 merge_head +} + +mtree_merge_body() +{ + FLAVOR=mtree merge_body +} +netbsd6_merge_body() +{ + FLAVOR=netbsd6 merge_body +} + + +atf_test_case mtree_nonemptydir +atf_test_case netbsd6_nonemptydir +nonemptydir_head() +{ + atf_set "descr" "Test that new non-empty " \ + "directories are recorded (PR bin/25693)" +} + +nonemptydir_body() +{ + mkdir testdir + cd testdir + + mtree -F ${FLAVOR} -c > mtree.spec + + if [ ! -f mtree.spec ]; then + atf_fail "mtree failed" + fi + + touch bar + atf_check -s ignore -o save:output -x "mtree -F ${FLAVOR} -f mtree.spec" + + if [ ! -n "$(egrep "extra: bar" output)" ]; then + atf_fail "mtree did not record changes (PR bin/25693)" + fi +} + +mtree_nonemptydir_head() +{ + FLAVOR=mtree nonemptydir_head +} +netbsd6_nonemptydir_head() +{ + FLAVOR=netbsd6 nonemptydir_head +} + +mtree_nonemptydir_body() +{ + FLAVOR=mtree nonemptydir_body +} +netbsd6_nonemptydir_body() +{ + FLAVOR=netbsd6 nonemptydir_body +} + + +atf_init_test_cases() +{ + atf_add_test_case mtree_create + atf_add_test_case mtree_check + atf_add_test_case mtree_convert_C + atf_add_test_case mtree_convert_C_S + atf_add_test_case mtree_convert_D + atf_add_test_case mtree_convert_D_S + atf_add_test_case mtree_ignore + atf_add_test_case mtree_merge + atf_add_test_case mtree_nonemptydir + + atf_add_test_case netbsd6_create + atf_add_test_case netbsd6_check + atf_add_test_case netbsd6_convert_C + atf_add_test_case netbsd6_convert_C_S + atf_add_test_case netbsd6_convert_D + atf_add_test_case netbsd6_convert_D_S + atf_add_test_case netbsd6_ignore + atf_add_test_case netbsd6_merge + atf_add_test_case netbsd6_nonemptydir +} diff --git a/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh b/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh new file mode 100755 index 000000000000..5cd89b41abe4 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh @@ -0,0 +1,59 @@ +# $NetBSD: t_tcpdump.sh,v 1.4 2014/09/20 06:08:07 ozaki-r Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +prom() { + atf_check -s ignore -o ignore -e ignore -x "tcpdump -c 1 -i $1" & + sleep 2; kill $! >/dev/null 2>&1 +} + +atf_test_case promiscuous +promiscuous_head() { + atf_set "require.user" "root" + atf_set "descr" "Test that switching an interface into and out " \ + "of promiscuous mode does not lockup (PR kern/46328)" +} + +promiscuous_body() { + + for i in $(ifconfig -l); do + case $i in + bridge*) + echo "Skipping $i" + continue + ;; + esac + + echo "Testing $i" + prom $i + done +} + +atf_init_test_cases() { + atf_add_test_case promiscuous +} diff --git a/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh b/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh new file mode 100755 index 000000000000..cc2b2f40f89b --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh @@ -0,0 +1,128 @@ +# $NetBSD: t_traceroute.sh,v 1.5 2013/02/19 21:08:25 joerg Exp $ +# +# Copyright (c) 2010 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +netserver=\ +"rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" + +atf_test_case basic cleanup +basic_head() +{ + + atf_set "descr" "Does a simple three-hop traceroute" + atf_set "require.progs" "rump_server" +} + +cfgendpt () +{ + + sock=${1} + addr=${2} + route=${3} + bus=${4} + + export RUMP_SERVER=${sock} + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus} + atf_check -s exit:0 rump.ifconfig shmif0 inet ${addr} netmask 0xffffff00 + atf_check -s exit:0 -o ignore rump.route add default ${route} +} + +threeservers() +{ + + atf_check -s exit:0 ${netserver} unix://commsock1 + atf_check -s exit:0 ${netserver} unix://commsock2 + atf_check -s exit:0 ${netserver} unix://commsock3 + + # configure endpoints + cfgendpt unix://commsock1 1.2.3.4 1.2.3.1 bus1 + cfgendpt unix://commsock3 2.3.4.5 2.3.4.1 bus2 + + # configure the router + export RUMP_SERVER=unix://commsock2 + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + atf_check -s exit:0 rump.ifconfig shmif0 inet 1.2.3.1 netmask 0xffffff00 + + atf_check -s exit:0 rump.ifconfig shmif1 create + atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2 + atf_check -s exit:0 rump.ifconfig shmif1 inet 2.3.4.1 netmask 0xffffff00 +} + +threecleanup() +{ + env RUMP_SERVER=unix://commsock1 rump.halt + env RUMP_SERVER=unix://commsock2 rump.halt + env RUMP_SERVER=unix://commsock3 rump.halt +} + +threetests() +{ + + threeservers + export RUMP_SERVER=unix://commsock1 + atf_check -s exit:0 -o inline:'1.2.3.1\n2.3.4.5\n' -e ignore -x \ + "rump.traceroute ${1} -n 2.3.4.5 | awk '{print \$2}'" + export RUMP_SERVER=unix://commsock3 + atf_check -s exit:0 -o inline:'2.3.4.1\n1.2.3.4\n' -e ignore -x \ + "rump.traceroute ${1} -n 1.2.3.4 | awk '{print \$2}'" +} + +basic_body() +{ + threetests +} + +basic_cleanup() +{ + threecleanup +} + +atf_test_case basic_icmp cleanup +basic_icmp_head() +{ + + atf_set "descr" "Does an ICMP-based three-hop traceroute" + atf_set "require.progs" "rump_server" +} + +basic_icmp_body() +{ + threetests -I +} + +basic_icmp_cleanup() +{ + threecleanup +} + +atf_init_test_cases() +{ + + atf_add_test_case basic + atf_add_test_case basic_icmp +} diff --git a/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh b/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh new file mode 100755 index 000000000000..c55818e07f0b --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh @@ -0,0 +1,50 @@ +# $NetBSD: t_useradd.sh,v 1.1 2012/04/19 18:51:36 jruoho Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +username="test5678901234567" + +atf_test_case longname cleanup +longname_head() { + atf_set "require.user" "root" + atf_set "descr" "Test that usernames longer than 16 " \ + "characters are allowed (PR bin/39546)" +} + +longname_body() { + atf_expect_fail "PR bin/39546" + atf_check -s exit:0 -o ignore -e ignore -x "useradd $username" +} + +longname_cleanup() { + atf_check -s ignore -o ignore -e ignore -x "userdel $username" +} + +atf_init_test_cases() { + atf_add_test_case longname +} diff --git a/contrib/ofed/libibverbs/examples/asyncwatch.c b/contrib/ofed/libibverbs/examples/asyncwatch.c index da7ebd42a328..0c82dee0fb75 100644 --- a/contrib/ofed/libibverbs/examples/asyncwatch.c +++ b/contrib/ofed/libibverbs/examples/asyncwatch.c @@ -35,8 +35,6 @@ #endif /* HAVE_CONFIG_H */ #include -#include -#include #include diff --git a/contrib/ofed/libibverbs/examples/device_list.c b/contrib/ofed/libibverbs/examples/device_list.c index 70c3af51b6c3..d1b80517d195 100644 --- a/contrib/ofed/libibverbs/examples/device_list.c +++ b/contrib/ofed/libibverbs/examples/device_list.c @@ -36,9 +36,6 @@ #include -#include -#include - #include #include diff --git a/contrib/ofed/libibverbs/examples/devinfo.c b/contrib/ofed/libibverbs/examples/devinfo.c index 393ec042a5d8..4bcb91119839 100644 --- a/contrib/ofed/libibverbs/examples/devinfo.c +++ b/contrib/ofed/libibverbs/examples/devinfo.c @@ -41,8 +41,6 @@ #include #include #include -#include -#include #include #include diff --git a/contrib/ofed/libmlx4/src/mlx4-abi.h b/contrib/ofed/libmlx4/src/mlx4-abi.h index 1b1253c764d8..cc054e419579 100644 --- a/contrib/ofed/libmlx4/src/mlx4-abi.h +++ b/contrib/ofed/libmlx4/src/mlx4-abi.h @@ -36,7 +36,7 @@ #include #define MLX4_UVERBS_MIN_ABI_VERSION 2 -#define MLX4_UVERBS_MAX_ABI_VERSION 3 +#define MLX4_UVERBS_MAX_ABI_VERSION 4 struct mlx4_alloc_ucontext_resp { struct ibv_get_context_resp ibv_resp; diff --git a/contrib/one-true-awk/awk.1 b/contrib/one-true-awk/awk.1 index 6119613c1aae..b0d243b495cc 100644 --- a/contrib/one-true-awk/awk.1 +++ b/contrib/one-true-awk/awk.1 @@ -208,7 +208,7 @@ or of if no argument. .TP .B rand -random number on (0,1) +random number on [0,1) .TP .B srand sets seed for diff --git a/contrib/one-true-awk/main.c b/contrib/one-true-awk/main.c index ab01676f394e..ec7029454386 100644 --- a/contrib/one-true-awk/main.c +++ b/contrib/one-true-awk/main.c @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) signal(SIGFPE, fpecatch); srand_seed = 1; - srand(srand_seed); + srandom((unsigned long) srand_seed); yyin = NULL; symtab = makesymtab(NSYMTAB/NSYMTAB); diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c index cafaff3e4ad9..2bcd9dfa252a 100644 --- a/contrib/one-true-awk/run.c +++ b/contrib/one-true-awk/run.c @@ -1521,8 +1521,10 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */ break; case FRAND: - /* in principle, rand() returns something in 0..RAND_MAX */ - u = (Awkfloat) (rand() % RAND_MAX) / RAND_MAX; + /* random() returns numbers in [0..2^31-1] + * in order to get a number in [0, 1), divide it by 2^31 + */ + u = (Awkfloat) random() / (0x7fffffffL + 0x1UL); break; case FSRAND: if (isrec(x)) /* no argument provided */ @@ -1530,7 +1532,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis else u = getfval(x); tmp = u; - srand((unsigned int) u); + srandom((unsigned long) u); u = srand_seed; srand_seed = tmp; break; diff --git a/contrib/openbsm/bin/auditdistd/subr.c b/contrib/openbsm/bin/auditdistd/subr.c index e98ed1e74480..0f531cc22d0d 100644 --- a/contrib/openbsm/bin/auditdistd/subr.c +++ b/contrib/openbsm/bin/auditdistd/subr.c @@ -228,6 +228,11 @@ wait_for_file_init(int fd) PJDLOG_ASSERT(fd != -1); #ifdef HAVE_KQUEUE + if (wait_for_file_kq != -1) { + close(wait_for_file_kq); + wait_for_file_kq = -1; + } + kq = kqueue(); if (kq == -1) { pjdlog_errno(LOG_WARNING, "kqueue() failed"); diff --git a/contrib/openpam/CREDITS b/contrib/openpam/CREDITS index 8315415027cb..a2fc7d3407e8 100644 --- a/contrib/openpam/CREDITS +++ b/contrib/openpam/CREDITS @@ -15,6 +15,8 @@ directly or indirectly, with patches, criticism, suggestions, or ideas: Andrew Morgan + Ankita Pal + Baptiste Daroussin Brian Fundakowski Feldman Christos Zoulas Daniel Richard G. @@ -25,6 +27,7 @@ ideas: Eric Melville Espen Grøndahl Gary Winiger + Gavin Atkinson Gleb Smirnoff Hubert Feyrer Jason Evans @@ -46,5 +49,3 @@ ideas: Takanori Saneto Wojciech A. Koszek Yar Tikhiy - -$Id: CREDITS 648 2013-03-05 17:54:27Z des $ diff --git a/contrib/openpam/HISTORY b/contrib/openpam/HISTORY index ddb4d423459e..31a2c7125454 100644 --- a/contrib/openpam/HISTORY +++ b/contrib/openpam/HISTORY @@ -1,3 +1,24 @@ +OpenPAM Ourouparia 2014-09-12 + + - ENHANCE: When executing a chain, require at least one service + function to succeed. This mitigates fail-open scenarios caused by + misconfigurations or missing modules. + + - ENHANCE: Make sure to overwrite buffers which may have contained an + authentication token when they're no longer needed. + + - BUGFIX: Under certain circumstances, specifying a non-existent + module (or misspelling the name of a module) in a policy could + result in a fail-open scenario. (CVE-2014-3879) + + - FEATURE: Add a search path for modules. This was implemented in + Nummularia but inadvertently left out of the release notes. + + - BUGFIX: The is_upper() predicate only accepted the letter A as an + upper-case character instead of the entire A-Z range. As a result, + service and module names containing upper-case letters other than A + would be rejected. +============================================================================ OpenPAM Nummularia 2013-09-07 - ENHANCE: Rewrite the dynamic loader to improve readability and @@ -97,7 +118,7 @@ OpenPAM Lycopsida 2011-12-18 module before loading it. - ENHANCE: added / improved input validation in many cases, including - the policy file and some function arguments. + the policy file and some function arguments. (CVE-2011-4122) ============================================================================ OpenPAM Hydrangea 2007-12-21 @@ -427,5 +448,3 @@ Fixed a number of bugs in the previous release, including: OpenPAM Calamite 2002-02-09 First (beta) release. -============================================================================ -$Id: HISTORY 737 2013-09-07 12:53:55Z des $ diff --git a/contrib/openpam/INSTALL b/contrib/openpam/INSTALL index 8c27b932fc48..a88a8a4ab76b 100644 --- a/contrib/openpam/INSTALL +++ b/contrib/openpam/INSTALL @@ -54,5 +54,3 @@ directory: # make install - -$Id: INSTALL 648 2013-03-05 17:54:27Z des $ diff --git a/contrib/openpam/LICENSE b/contrib/openpam/LICENSE index a894e43a3953..18ff4890812d 100644 --- a/contrib/openpam/LICENSE +++ b/contrib/openpam/LICENSE @@ -31,5 +31,3 @@ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 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. - -$Id: LICENSE 648 2013-03-05 17:54:27Z des $ diff --git a/contrib/openpam/Makefile.am b/contrib/openpam/Makefile.am index 1c873117ce08..7640742ff194 100644 --- a/contrib/openpam/Makefile.am +++ b/contrib/openpam/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am 623 2013-02-25 07:24:51Z des $ +# $Id: Makefile.am 816 2014-09-12 07:50:22Z des $ ACLOCAL_AMFLAGS = -I m4 diff --git a/contrib/openpam/Makefile.in b/contrib/openpam/Makefile.in index c8e77d9a4305..963e9d4a6e2a 100644 --- a/contrib/openpam/Makefile.in +++ b/contrib/openpam/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -# $Id: Makefile.am 623 2013-02-25 07:24:51Z des $ +# $Id: Makefile.am 816 2014-09-12 07:50:22Z des $ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ @@ -84,13 +84,10 @@ subdir = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in $(srcdir)/pamgdb.in $(srcdir)/mkpkgng.in \ - INSTALL README TODO compile config.guess config.sub depcomp \ - install-sh missing ltmain.sh + INSTALL README TODO compile config.guess config.sub install-sh \ + missing ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ diff --git a/contrib/openpam/README b/contrib/openpam/README index 2fe00efe47ba..b0eb1a441740 100644 --- a/contrib/openpam/README +++ b/contrib/openpam/README @@ -23,5 +23,3 @@ These are some of OpenPAM's features: this will be made configurable in a future release. Please direct bug reports and inquiries to . - -$Id: README 648 2013-03-05 17:54:27Z des $ diff --git a/contrib/openpam/RELNOTES b/contrib/openpam/RELNOTES index 4518551c1e3d..fbd48d81bb7f 100644 --- a/contrib/openpam/RELNOTES +++ b/contrib/openpam/RELNOTES @@ -1,6 +1,6 @@ - Release notes for OpenPAM Nummularia - ==================================== + Release notes for OpenPAM Ourouparia + ==================================== This release corresponds to the code used in FreeBSD HEAD as of the release date, and is also expected to work on almost any POSIX-like @@ -20,5 +20,3 @@ The distribution consists of the following components: - Unit tests for limited portions of the libraries. Please direct bug reports and inquiries to . - -$Id: RELNOTES 741 2013-09-07 13:34:02Z des $ diff --git a/contrib/openpam/TODO b/contrib/openpam/TODO index d245361782bc..3790d6fd08e4 100644 --- a/contrib/openpam/TODO +++ b/contrib/openpam/TODO @@ -13,5 +13,3 @@ Before the next release: wrapper for) openpam_log() which respects the PAM_SILENT flag and the no_warn module option. This would eliminate the need for FreeBSD's _pam_verbose_error(). - -$Id: TODO 736 2013-09-07 12:52:42Z des $ diff --git a/contrib/openpam/aclocal.m4 b/contrib/openpam/aclocal.m4 index 9a730e043752..9fad4b40f5d5 100644 --- a/contrib/openpam/aclocal.m4 +++ b/contrib/openpam/aclocal.m4 @@ -20,6 +20,8593 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +]) + +# serial 57 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl + +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PREPARE_SED_QUOTE_VARS +# -------------------------- +# Define a few sed substitution that help us do robust quoting. +m4_defun([_LT_PREPARE_SED_QUOTE_VARS], +[# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' +]) + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$[]1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +_LT_OUTPUT_LIBTOOL_INIT +]) + +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) +# ------------------------------------ +# Generate a child script FILE with all initialization necessary to +# reuse the environment learned by the parent script, and make the +# file executable. If COMMENT is supplied, it is inserted after the +# `#!' sequence but before initialization text begins. After this +# macro, additional text can be appended to FILE to form the body of +# the child script. The macro ends with non-zero status if the +# file could not be fully written (such as if the disk is full). +m4_ifdef([AS_INIT_GENERATED], +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], +[m4_defun([_LT_GENERATED_FILE_INIT], +[m4_require([AS_PREPARE])]dnl +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl +[lt_write_fail=0 +cat >$1 <<_ASEOF || lt_write_fail=1 +#! $SHELL +# Generated by $as_me. +$2 +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$1 <<\_ASEOF || lt_write_fail=1 +AS_SHELL_SANITIZE +_AS_PREPARE +exec AS_MESSAGE_FD>&1 +_ASEOF +test $lt_write_fail = 0 && chmod +x $1[]dnl +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], +[# Run this file to recreate a libtool stub with the current configuration.]) + +cat >>"$CONFIG_LT" <<\_LTEOF +lt_cl_silent=false +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2011 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +lt_cl_success=: +test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" +exec AS_MESSAGE_LOG_FD>/dev/null +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false +exec AS_MESSAGE_LOG_FD>>config.log +$lt_cl_success || AS_EXIT(1) +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_REPLACE_SHELLFNS + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +m4_ifndef([AC_PROG_GO], [ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) +dnl AC_DEFUN([AC_LIBTOOL_RC], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], + [lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD + echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + if test "$lt_cv_ld_force_load" = "yes"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[m4_divert_text([M4SH-INIT], [$1 +])])# _LT_SHELL_INIT + + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script which will find a shell with a builtin +# printf (which we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +AC_MSG_CHECKING([how to print strings]) +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$[]1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +case "$ECHO" in + printf*) AC_MSG_RESULT([printf]) ;; + print*) AC_MSG_RESULT([print -r]) ;; + *) AC_MSG_RESULT([cat]) ;; +esac + +m4_ifdef([_AS_DETECT_SUGGESTED], +[_AS_DETECT_SUGGESTED([ + test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test "X`printf %s $ECHO`" = "X$ECHO" \ + || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) + +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[ --with-sysroot[=DIR] Search for dependent libraries within DIR + (or the compiler's sysroot if not specified).], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case ${with_sysroot} in #( + yes) + if test "$GCC" = yes; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([${with_sysroot}]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and in which our libraries should be installed.])]) + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" +])# _LT_ENABLE_LOCK + + +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -eq 0; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test "$ac_status" -ne 0; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test "x$lt_cv_ar_at_file" = xno; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[_LT_PROG_AR + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +_LT_DECL([], [lock_old_archive_extraction], [0], + [Whether to use a lock for old archive extraction]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisbility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; + *) lt_sed_strip_eq="s,=/,/,g" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + library_names_spec='${libname}.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec="$LIB" + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[23]].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=yes + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[[3-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], + [lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [lt_cv_shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + ]) + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [install_override_mode], [1], + [Permission mode override for installation of shared libraries]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi]) +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) + case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols" + ;; + *) + DUMPBIN=: + ;; + esac + fi + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh + # decide which to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd="$ECHO" + ;; +esac +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test "x$lt_cv_path_mainfest_tool" != xyes; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + case $cc_basename in + nvcc*) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; + *) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; + esac + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT@&t@_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + # Also, AIX nm treats weak defined symbols like other global defined + # symbols, whereas GNU nm marks them as "W". + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test "$with_gnu_ld" = yes; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; + *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test "$lt_use_gnu_ld_interface" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + # Also, AIX nm treats weak defined symbols like other global + # defined symbols, whereas GNU nm marks them as "W". + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + if test "$with_gnu_ld" = yes; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile="$lt_outputfile.exe" + lt_tool_outputfile="$lt_tool_outputfile.exe" + ;; + esac~ + if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes && test "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + m4_if($1, [], [ + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + _LT_LINKER_OPTION([if $CC understands -b], + _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS="$save_LDFLAGS"]) + if test "$lt_cv_irix_exported_symbol" = yes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + fi + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_CACHE_CHECK([whether -lc should be explicitly linked in], + [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), + [$RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + ]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting ${shlibpath_var} if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + if test "$with_gnu_ld" = yes; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile="$lt_outputfile.exe" + lt_tool_outputfile="$lt_tool_outputfile.exe" + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + gnu*) + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 and above use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + ;; + xl* | mpixl* | bgxl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ + '"$_LT_TAGVAR(old_archive_cmds, $1)" + _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ + '"$_LT_TAGVAR(reload_cmds, $1)" + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF +]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case ${prev}${p} in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + fi + + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac + if test "$pre_test_object_deps_done" = no; then + case ${prev} in + -L | -R) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + prev= + ;; + + *.lto.$objext) ;; # Ignore GCC LTO objects + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC* | sunCC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_LANG_PUSH(Fortran 77) +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${F77-"f77"} + CFLAGS=$FFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" + CFLAGS="$lt_save_CFLAGS" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_LANG_PUSH(Fortran) + +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${FC-"f95"} + CFLAGS=$FCFLAGS + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +CFLAGS= +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) +# ------------------------------------------------------ +# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and +# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. +m4_defun([_LT_PROG_FUNCTION_REPLACE], +[dnl { +sed -e '/^$1 ()$/,/^} # $1 /c\ +$1 ()\ +{\ +m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) +} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: +]) + + +# _LT_PROG_REPLACE_SHELLFNS +# ------------------------- +# Replace existing portable implementations of several shell functions with +# equivalent extended shell implementations where those features are available.. +m4_defun([_LT_PROG_REPLACE_SHELLFNS], +[if test x"$xsi_shell" = xyes; then + _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac]) + + _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl + func_basename_result="${1##*/}"]) + + _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}"]) + + _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"}]) + + _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl + func_split_long_opt_name=${1%%=*} + func_split_long_opt_arg=${1#*=}]) + + _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) + + _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac]) + + _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) + + _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) + + _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) +fi + +if test x"$lt_shell_append" = xyes; then + _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) + + _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl + func_quote_for_eval "${2}" +dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ + eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) + + # Save a `func_append' function call where possible by direct use of '+=' + sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +else + # Save a `func_append' function call even when '+=' is not available + sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +fi + +if test x"$_lt_function_replace_fail" = x":"; then + AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) +fi +]) + +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine which file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac +]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS + +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 7 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [1], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) + +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) + +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# @configure_input@ + +# serial 3337 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.2' +macro_revision='1.3337' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) + +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 5 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) +m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) +m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) +m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) +m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) + # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation @@ -1176,8 +9763,3 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR -m4_include([m4/libtool.m4]) -m4_include([m4/ltoptions.m4]) -m4_include([m4/ltsugar.m4]) -m4_include([m4/ltversion.m4]) -m4_include([m4/lt~obsolete.m4]) diff --git a/contrib/openpam/autogen.sh b/contrib/openpam/autogen.sh index 1958dfc958cf..ce42fd5eb330 100755 --- a/contrib/openpam/autogen.sh +++ b/contrib/openpam/autogen.sh @@ -1,10 +1,10 @@ #!/bin/sh # -# $Id: autogen.sh 709 2013-08-18 14:47:20Z des $ +# $Id: autogen.sh 815 2014-09-12 07:47:27Z des $ # aclocal -I m4 libtoolize --copy --force autoheader -automake -a -c --foreign +automake --add-missing --copy --foreign autoconf diff --git a/contrib/openpam/bin/Makefile.in b/contrib/openpam/bin/Makefile.in index 1df083a2498a..452bc64f8f27 100644 --- a/contrib/openpam/bin/Makefile.in +++ b/contrib/openpam/bin/Makefile.in @@ -84,10 +84,7 @@ host_triplet = @host@ subdir = bin DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/bin/openpam_dump_policy/Makefile.in b/contrib/openpam/bin/openpam_dump_policy/Makefile.in index 3bef96dce3c1..f40bd169b95a 100644 --- a/contrib/openpam/bin/openpam_dump_policy/Makefile.in +++ b/contrib/openpam/bin/openpam_dump_policy/Makefile.in @@ -85,10 +85,7 @@ subdir = bin/openpam_dump_policy DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/bin/openpam_dump_policy/openpam_dump_policy.c b/contrib/openpam/bin/openpam_dump_policy/openpam_dump_policy.c index d16289c07a4b..74129f33b139 100644 --- a/contrib/openpam/bin/openpam_dump_policy/openpam_dump_policy.c +++ b/contrib/openpam/bin/openpam_dump_policy/openpam_dump_policy.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openpam_dump_policy.c 648 2013-03-05 17:54:27Z des $ + * $Id: openpam_dump_policy.c 798 2014-06-10 21:28:14Z des $ */ #ifdef HAVE_CONFIG_H @@ -64,7 +64,7 @@ openpam_facility_index_name(pam_facility_t fclt) if (asprintf(&name, "PAM_%s", facility) == -1) return (NULL); for (p = name + 4; *p; ++p) - *p = toupper(*p); + *p = toupper((unsigned char)*p); return (name); } diff --git a/contrib/openpam/bin/pamtest/Makefile.in b/contrib/openpam/bin/pamtest/Makefile.in index c9b933f777ae..d628e7ead855 100644 --- a/contrib/openpam/bin/pamtest/Makefile.in +++ b/contrib/openpam/bin/pamtest/Makefile.in @@ -85,10 +85,7 @@ subdir = bin/pamtest DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(dist_man1_MANS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/bin/pamtest/pamtest.1 b/contrib/openpam/bin/pamtest/pamtest.1 index 76fc99ecd9e2..7fcaf66987d9 100644 --- a/contrib/openpam/bin/pamtest/pamtest.1 +++ b/contrib/openpam/bin/pamtest/pamtest.1 @@ -26,15 +26,15 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: pamtest.1 741 2013-09-07 13:34:02Z des $ +.\" $Id: pamtest.1 816 2014-09-12 07:50:22Z des $ .\" -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAMTEST 1 .Os .Sh NAME .Nm pamtest .Nd PAM policy tester -.Sh SYNOPSYS +.Sh SYNOPSIS .Nm .Op Fl dkMPsv .Op Fl H Ar rhost diff --git a/contrib/openpam/bin/su/Makefile.in b/contrib/openpam/bin/su/Makefile.in index 7a37fc7e4bd0..12a5234cf798 100644 --- a/contrib/openpam/bin/su/Makefile.in +++ b/contrib/openpam/bin/su/Makefile.in @@ -85,10 +85,7 @@ subdir = bin/su DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(dist_man1_MANS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/bin/su/su.1 b/contrib/openpam/bin/su/su.1 index 9d328e7fc996..41f270f4c8d6 100644 --- a/contrib/openpam/bin/su/su.1 +++ b/contrib/openpam/bin/su/su.1 @@ -26,15 +26,15 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: su.1 741 2013-09-07 13:34:02Z des $ +.\" $Id: su.1 816 2014-09-12 07:50:22Z des $ .\" -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt SU 1 .Os .Sh NAME .Nm su .Nd switch user identity -.Sh SYNOPSYS +.Sh SYNOPSIS .Nm .Op Ar login Op Ar ... .Sh DESCRIPTION diff --git a/contrib/openpam/config.h.in b/contrib/openpam/config.h.in index 780803efcd81..9eb76b5c94fb 100644 --- a/contrib/openpam/config.h.in +++ b/contrib/openpam/config.h.in @@ -60,6 +60,9 @@ /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY +/* Define to 1 if you have the `strlset' function. */ +#undef HAVE_STRLSET + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H diff --git a/contrib/openpam/configure b/contrib/openpam/configure index bad8c990942c..07e2a917e20f 100755 --- a/contrib/openpam/configure +++ b/contrib/openpam/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.ac Id: configure.ac 741 2013-09-07 13:34:02Z des . +# From configure.ac Id: configure.ac 816 2014-09-12 07:50:22Z des . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for OpenPAM 20130907. +# Generated by GNU Autoconf 2.69 for OpenPAM 20140912. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='OpenPAM' PACKAGE_TARNAME='openpam' -PACKAGE_VERSION='20130907' -PACKAGE_STRING='OpenPAM 20130907' +PACKAGE_VERSION='20140912' +PACKAGE_STRING='OpenPAM 20140912' PACKAGE_BUGREPORT='des@des.no' PACKAGE_URL='http://www.openpam.org/' @@ -1335,7 +1335,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures OpenPAM 20130907 to adapt to many kinds of systems. +\`configure' configures OpenPAM 20140912 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1405,7 +1405,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of OpenPAM 20130907:";; + short | recursive ) echo "Configuration of OpenPAM 20140912:";; esac cat <<\_ACEOF @@ -1524,7 +1524,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -OpenPAM configure 20130907 +OpenPAM configure 20140912 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1893,7 +1893,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by OpenPAM $as_me 20130907, which was +It was created by OpenPAM $as_me 20140912, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2758,7 +2758,7 @@ fi # Define the identity of the package. PACKAGE='openpam' - VERSION='20130907' + VERSION='20140912' cat >>confdefs.h <<_ACEOF @@ -8454,10 +8454,6 @@ _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= @@ -12181,7 +12177,7 @@ _ACEOF fi done -for ac_func in strlcat strlcmp strlcpy +for ac_func in strlcat strlcmp strlcpy strlset do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -12918,7 +12914,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by OpenPAM $as_me 20130907, which was +This file was extended by OpenPAM $as_me 20140912, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12985,7 +12981,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -OpenPAM config.status 20130907 +OpenPAM config.status 20140912 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/contrib/openpam/configure.ac b/contrib/openpam/configure.ac index 1dd0053747dc..1412b7a8e30b 100644 --- a/contrib/openpam/configure.ac +++ b/contrib/openpam/configure.ac @@ -1,8 +1,8 @@ -dnl $Id: configure.ac 741 2013-09-07 13:34:02Z des $ +dnl $Id: configure.ac 816 2014-09-12 07:50:22Z des $ AC_PREREQ([2.62]) -AC_REVISION([$Id: configure.ac 741 2013-09-07 13:34:02Z des $]) -AC_INIT([OpenPAM], [20130907], [des@des.no], [openpam], [http://www.openpam.org/]) +AC_REVISION([$Id: configure.ac 816 2014-09-12 07:50:22Z des $]) +AC_INIT([OpenPAM], [20140912], [des@des.no], [openpam], [http://www.openpam.org/]) AC_CONFIG_SRCDIR([lib/libpam/pam_start.c]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([foreign]) @@ -85,7 +85,7 @@ AC_CHECK_FUNCS([asprintf vasprintf]) AC_CHECK_FUNCS([dlfunc fdlopen]) AC_CHECK_FUNCS([fpurge]) AC_CHECK_FUNCS([setlogmask]) -AC_CHECK_FUNCS([strlcat strlcmp strlcpy]) +AC_CHECK_FUNCS([strlcat strlcmp strlcpy strlset]) saved_LIBS="${LIBS}" LIBS="" diff --git a/contrib/openpam/doc/Makefile.in b/contrib/openpam/doc/Makefile.in index 83070401d420..26ac55c8651e 100644 --- a/contrib/openpam/doc/Makefile.in +++ b/contrib/openpam/doc/Makefile.in @@ -82,10 +82,7 @@ host_triplet = @host@ subdir = doc DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/doc/man/Makefile.in b/contrib/openpam/doc/man/Makefile.in index efb43c1ed947..84236b7ea755 100644 --- a/contrib/openpam/doc/man/Makefile.in +++ b/contrib/openpam/doc/man/Makefile.in @@ -82,10 +82,7 @@ subdir = doc/man DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(dist_man3_MANS) $(dist_man5_MANS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/doc/man/openpam.3 b/contrib/openpam/doc/man/openpam.3 index f7b737386ff6..35f135dd11c6 100644 --- a/contrib/openpam/doc/man/openpam.3 +++ b/contrib/openpam/doc/man/openpam.3 @@ -1,5 +1,5 @@ .\" Generated by gendoc.pl -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_borrow_cred.3 b/contrib/openpam/doc/man/openpam_borrow_cred.3 index 57a1fe0a9e92..523ee634ce32 100644 --- a/contrib/openpam/doc/man/openpam_borrow_cred.3 +++ b/contrib/openpam/doc/man/openpam_borrow_cred.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_borrow_cred.c by gendoc.pl .\" $Id: openpam_borrow_cred.c 649 2013-03-05 17:58:33Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_BORROW_CRED 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_free_data.3 b/contrib/openpam/doc/man/openpam_free_data.3 index a0d72468063f..1010f023d245 100644 --- a/contrib/openpam/doc/man/openpam_free_data.3 +++ b/contrib/openpam/doc/man/openpam_free_data.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_free_data.c by gendoc.pl .\" $Id: openpam_free_data.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_FREE_DATA 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_free_envlist.3 b/contrib/openpam/doc/man/openpam_free_envlist.3 index f417278b3ed1..2bddfb1b9896 100644 --- a/contrib/openpam/doc/man/openpam_free_envlist.3 +++ b/contrib/openpam/doc/man/openpam_free_envlist.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_free_envlist.c by gendoc.pl .\" $Id: openpam_free_envlist.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_FREE_ENVLIST 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_get_feature.3 b/contrib/openpam/doc/man/openpam_get_feature.3 index 83e64e24557d..b001ce027874 100644 --- a/contrib/openpam/doc/man/openpam_get_feature.3 +++ b/contrib/openpam/doc/man/openpam_get_feature.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_get_feature.c by gendoc.pl .\" $Id: openpam_get_feature.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_GET_FEATURE 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_get_option.3 b/contrib/openpam/doc/man/openpam_get_option.3 index e986e7dc2487..7ff839b0bd15 100644 --- a/contrib/openpam/doc/man/openpam_get_option.3 +++ b/contrib/openpam/doc/man/openpam_get_option.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_get_option.c by gendoc.pl .\" $Id: openpam_get_option.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_GET_OPTION 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_log.3 b/contrib/openpam/doc/man/openpam_log.3 index 0ab721e7fcf5..18691fec8149 100644 --- a/contrib/openpam/doc/man/openpam_log.3 +++ b/contrib/openpam/doc/man/openpam_log.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_log.c by gendoc.pl .\" $Id: openpam_log.c 686 2013-07-11 16:36:02Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_LOG 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_nullconv.3 b/contrib/openpam/doc/man/openpam_nullconv.3 index 03cfe53b8408..1f657f5ea8ba 100644 --- a/contrib/openpam/doc/man/openpam_nullconv.3 +++ b/contrib/openpam/doc/man/openpam_nullconv.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_nullconv.c by gendoc.pl .\" $Id: openpam_nullconv.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_NULLCONV 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_readline.3 b/contrib/openpam/doc/man/openpam_readline.3 index 8916911fec37..c0ad9b82d847 100644 --- a/contrib/openpam/doc/man/openpam_readline.3 +++ b/contrib/openpam/doc/man/openpam_readline.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_readline.c by gendoc.pl .\" $Id: openpam_readline.c 703 2013-08-16 11:57:54Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_READLINE 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_readlinev.3 b/contrib/openpam/doc/man/openpam_readlinev.3 index 1ffe8afe9445..7801843a7920 100644 --- a/contrib/openpam/doc/man/openpam_readlinev.3 +++ b/contrib/openpam/doc/man/openpam_readlinev.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_readlinev.c by gendoc.pl .\" $Id: openpam_readlinev.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_READLINEV 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_readword.3 b/contrib/openpam/doc/man/openpam_readword.3 index d680e15049cf..39b4726b79ab 100644 --- a/contrib/openpam/doc/man/openpam_readword.3 +++ b/contrib/openpam/doc/man/openpam_readword.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_readword.c by gendoc.pl .\" $Id: openpam_readword.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_READWORD 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_restore_cred.3 b/contrib/openpam/doc/man/openpam_restore_cred.3 index 313626cc95aa..900bca6b71bd 100644 --- a/contrib/openpam/doc/man/openpam_restore_cred.3 +++ b/contrib/openpam/doc/man/openpam_restore_cred.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_restore_cred.c by gendoc.pl .\" $Id: openpam_restore_cred.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_RESTORE_CRED 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_set_feature.3 b/contrib/openpam/doc/man/openpam_set_feature.3 index 68eafa092ded..475a89bcde54 100644 --- a/contrib/openpam/doc/man/openpam_set_feature.3 +++ b/contrib/openpam/doc/man/openpam_set_feature.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_set_feature.c by gendoc.pl .\" $Id: openpam_set_feature.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_SET_FEATURE 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_set_option.3 b/contrib/openpam/doc/man/openpam_set_option.3 index cee2540c0e83..6ed8b1b0aa74 100644 --- a/contrib/openpam/doc/man/openpam_set_option.3 +++ b/contrib/openpam/doc/man/openpam_set_option.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_set_option.c by gendoc.pl .\" $Id: openpam_set_option.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_SET_OPTION 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_straddch.3 b/contrib/openpam/doc/man/openpam_straddch.3 index ec4f607a667c..3263ee11ca45 100644 --- a/contrib/openpam/doc/man/openpam_straddch.3 +++ b/contrib/openpam/doc/man/openpam_straddch.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_straddch.c by gendoc.pl .\" $Id: openpam_straddch.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_STRADDCH 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_subst.3 b/contrib/openpam/doc/man/openpam_subst.3 index 2ae0e27c2469..bc9c3a2953a4 100644 --- a/contrib/openpam/doc/man/openpam_subst.3 +++ b/contrib/openpam/doc/man/openpam_subst.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_subst.c by gendoc.pl .\" $Id: openpam_subst.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt OPENPAM_SUBST 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/openpam_ttyconv.3 b/contrib/openpam/doc/man/openpam_ttyconv.3 index f3ef85c8ec70..e7bd8b186ce5 100644 --- a/contrib/openpam/doc/man/openpam_ttyconv.3 +++ b/contrib/openpam/doc/man/openpam_ttyconv.3 @@ -1,6 +1,6 @@ .\" Generated from openpam_ttyconv.c by gendoc.pl -.\" $Id: openpam_ttyconv.c 688 2013-07-11 16:40:08Z des $ -.Dd September 7, 2013 +.\" $Id: openpam_ttyconv.c 807 2014-09-09 09:41:32Z des $ +.Dd September 12, 2014 .Dt OPENPAM_TTYCONV 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam.3 b/contrib/openpam/doc/man/pam.3 index 9ee08d17c309..20ff3950a464 100644 --- a/contrib/openpam/doc/man/pam.3 +++ b/contrib/openpam/doc/man/pam.3 @@ -1,5 +1,5 @@ .\" Generated by gendoc.pl -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam.conf.5 b/contrib/openpam/doc/man/pam.conf.5 index 9b4f4ce285d7..112762c2ada3 100644 --- a/contrib/openpam/doc/man/pam.conf.5 +++ b/contrib/openpam/doc/man/pam.conf.5 @@ -26,9 +26,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: pam.conf.5 741 2013-09-07 13:34:02Z des $ +.\" $Id: pam.conf.5 816 2014-09-12 07:50:22Z des $ .\" -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM.CONF 5 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_acct_mgmt.3 b/contrib/openpam/doc/man/pam_acct_mgmt.3 index 08cde6bcaa75..f5bea769644d 100644 --- a/contrib/openpam/doc/man/pam_acct_mgmt.3 +++ b/contrib/openpam/doc/man/pam_acct_mgmt.3 @@ -1,6 +1,6 @@ .\" Generated from pam_acct_mgmt.c by gendoc.pl .\" $Id: pam_acct_mgmt.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_ACCT_MGMT 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_authenticate.3 b/contrib/openpam/doc/man/pam_authenticate.3 index 6e5a4c39a259..4ba1d2b0d76c 100644 --- a/contrib/openpam/doc/man/pam_authenticate.3 +++ b/contrib/openpam/doc/man/pam_authenticate.3 @@ -1,6 +1,6 @@ .\" Generated from pam_authenticate.c by gendoc.pl .\" $Id: pam_authenticate.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_AUTHENTICATE 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_chauthtok.3 b/contrib/openpam/doc/man/pam_chauthtok.3 index 11cf878754aa..3ecf82276f1e 100644 --- a/contrib/openpam/doc/man/pam_chauthtok.3 +++ b/contrib/openpam/doc/man/pam_chauthtok.3 @@ -1,6 +1,6 @@ .\" Generated from pam_chauthtok.c by gendoc.pl .\" $Id: pam_chauthtok.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_CHAUTHTOK 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_close_session.3 b/contrib/openpam/doc/man/pam_close_session.3 index de922db177ab..32ba20085872 100644 --- a/contrib/openpam/doc/man/pam_close_session.3 +++ b/contrib/openpam/doc/man/pam_close_session.3 @@ -1,6 +1,6 @@ .\" Generated from pam_close_session.c by gendoc.pl .\" $Id: pam_close_session.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_CLOSE_SESSION 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_conv.3 b/contrib/openpam/doc/man/pam_conv.3 index bb77e74d8c9b..225df9670e71 100644 --- a/contrib/openpam/doc/man/pam_conv.3 +++ b/contrib/openpam/doc/man/pam_conv.3 @@ -32,9 +32,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: pam_conv.3 741 2013-09-07 13:34:02Z des $ +.\" $Id: pam_conv.3 816 2014-09-12 07:50:22Z des $ .\" -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_CONV 3 .Os .Sh NAME @@ -76,7 +76,7 @@ item. .Pp The conversation function's first argument specifies the number of messages (up to -.Dv PAM_NUM_MSG ) +.Dv PAM_MAX_NUM_MSG ) to process. The second argument is a pointer to an array of pointers to .Vt pam_message diff --git a/contrib/openpam/doc/man/pam_end.3 b/contrib/openpam/doc/man/pam_end.3 index a7f408bf6afa..2bb581e0a399 100644 --- a/contrib/openpam/doc/man/pam_end.3 +++ b/contrib/openpam/doc/man/pam_end.3 @@ -1,6 +1,6 @@ .\" Generated from pam_end.c by gendoc.pl .\" $Id: pam_end.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_END 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_error.3 b/contrib/openpam/doc/man/pam_error.3 index 5f9163ca769d..73ba5f64b776 100644 --- a/contrib/openpam/doc/man/pam_error.3 +++ b/contrib/openpam/doc/man/pam_error.3 @@ -1,6 +1,6 @@ .\" Generated from pam_error.c by gendoc.pl .\" $Id: pam_error.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_ERROR 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_get_authtok.3 b/contrib/openpam/doc/man/pam_get_authtok.3 index 64c98d4c1dcc..27bfb36d39bd 100644 --- a/contrib/openpam/doc/man/pam_get_authtok.3 +++ b/contrib/openpam/doc/man/pam_get_authtok.3 @@ -1,6 +1,6 @@ .\" Generated from pam_get_authtok.c by gendoc.pl -.\" $Id: pam_get_authtok.c 670 2013-03-17 19:26:07Z des $ -.Dd September 7, 2013 +.\" $Id: pam_get_authtok.c 807 2014-09-09 09:41:32Z des $ +.Dd September 12, 2014 .Dt PAM_GET_AUTHTOK 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_get_data.3 b/contrib/openpam/doc/man/pam_get_data.3 index f76213daeee7..f470d91eafb4 100644 --- a/contrib/openpam/doc/man/pam_get_data.3 +++ b/contrib/openpam/doc/man/pam_get_data.3 @@ -1,6 +1,6 @@ .\" Generated from pam_get_data.c by gendoc.pl .\" $Id: pam_get_data.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_GET_DATA 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_get_item.3 b/contrib/openpam/doc/man/pam_get_item.3 index 7ee6f0ba65a8..2e24405040d4 100644 --- a/contrib/openpam/doc/man/pam_get_item.3 +++ b/contrib/openpam/doc/man/pam_get_item.3 @@ -1,6 +1,6 @@ .\" Generated from pam_get_item.c by gendoc.pl .\" $Id: pam_get_item.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_GET_ITEM 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_get_user.3 b/contrib/openpam/doc/man/pam_get_user.3 index beed4a96aba9..fad7e5d80542 100644 --- a/contrib/openpam/doc/man/pam_get_user.3 +++ b/contrib/openpam/doc/man/pam_get_user.3 @@ -1,6 +1,6 @@ .\" Generated from pam_get_user.c by gendoc.pl .\" $Id: pam_get_user.c 670 2013-03-17 19:26:07Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_GET_USER 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_getenv.3 b/contrib/openpam/doc/man/pam_getenv.3 index f26cb81802e6..5302975e9a34 100644 --- a/contrib/openpam/doc/man/pam_getenv.3 +++ b/contrib/openpam/doc/man/pam_getenv.3 @@ -1,6 +1,6 @@ .\" Generated from pam_getenv.c by gendoc.pl .\" $Id: pam_getenv.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_GETENV 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_getenvlist.3 b/contrib/openpam/doc/man/pam_getenvlist.3 index dd01d2928011..b94087609c06 100644 --- a/contrib/openpam/doc/man/pam_getenvlist.3 +++ b/contrib/openpam/doc/man/pam_getenvlist.3 @@ -1,6 +1,6 @@ .\" Generated from pam_getenvlist.c by gendoc.pl .\" $Id: pam_getenvlist.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_GETENVLIST 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_info.3 b/contrib/openpam/doc/man/pam_info.3 index 1d14ec141a9c..018c98e9c9ee 100644 --- a/contrib/openpam/doc/man/pam_info.3 +++ b/contrib/openpam/doc/man/pam_info.3 @@ -1,6 +1,6 @@ .\" Generated from pam_info.c by gendoc.pl .\" $Id: pam_info.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_INFO 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_open_session.3 b/contrib/openpam/doc/man/pam_open_session.3 index 768629d1f612..1e80873ad2f5 100644 --- a/contrib/openpam/doc/man/pam_open_session.3 +++ b/contrib/openpam/doc/man/pam_open_session.3 @@ -1,6 +1,6 @@ .\" Generated from pam_open_session.c by gendoc.pl .\" $Id: pam_open_session.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_OPEN_SESSION 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_prompt.3 b/contrib/openpam/doc/man/pam_prompt.3 index 231e3b6ce6dd..8fcf93dd261c 100644 --- a/contrib/openpam/doc/man/pam_prompt.3 +++ b/contrib/openpam/doc/man/pam_prompt.3 @@ -1,6 +1,6 @@ .\" Generated from pam_prompt.c by gendoc.pl .\" $Id: pam_prompt.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_PROMPT 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_putenv.3 b/contrib/openpam/doc/man/pam_putenv.3 index 02f60155cf55..0043a7b42e0b 100644 --- a/contrib/openpam/doc/man/pam_putenv.3 +++ b/contrib/openpam/doc/man/pam_putenv.3 @@ -1,6 +1,6 @@ .\" Generated from pam_putenv.c by gendoc.pl .\" $Id: pam_putenv.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_PUTENV 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_set_data.3 b/contrib/openpam/doc/man/pam_set_data.3 index 29e4bf21e27d..85f77f29e3bb 100644 --- a/contrib/openpam/doc/man/pam_set_data.3 +++ b/contrib/openpam/doc/man/pam_set_data.3 @@ -1,6 +1,6 @@ .\" Generated from pam_set_data.c by gendoc.pl .\" $Id: pam_set_data.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SET_DATA 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_set_item.3 b/contrib/openpam/doc/man/pam_set_item.3 index b29e3a18a686..855ce542c850 100644 --- a/contrib/openpam/doc/man/pam_set_item.3 +++ b/contrib/openpam/doc/man/pam_set_item.3 @@ -1,6 +1,6 @@ .\" Generated from pam_set_item.c by gendoc.pl .\" $Id: pam_set_item.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SET_ITEM 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_setcred.3 b/contrib/openpam/doc/man/pam_setcred.3 index 5c9a57ed73b0..4b4833c8ccc8 100644 --- a/contrib/openpam/doc/man/pam_setcred.3 +++ b/contrib/openpam/doc/man/pam_setcred.3 @@ -1,6 +1,6 @@ .\" Generated from pam_setcred.c by gendoc.pl .\" $Id: pam_setcred.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SETCRED 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_setenv.3 b/contrib/openpam/doc/man/pam_setenv.3 index 2991e09d7fc9..40f7fde67f01 100644 --- a/contrib/openpam/doc/man/pam_setenv.3 +++ b/contrib/openpam/doc/man/pam_setenv.3 @@ -1,6 +1,6 @@ .\" Generated from pam_setenv.c by gendoc.pl .\" $Id: pam_setenv.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SETENV 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_sm_acct_mgmt.3 b/contrib/openpam/doc/man/pam_sm_acct_mgmt.3 index f5c04da672b3..cbf0e81404e8 100644 --- a/contrib/openpam/doc/man/pam_sm_acct_mgmt.3 +++ b/contrib/openpam/doc/man/pam_sm_acct_mgmt.3 @@ -1,6 +1,6 @@ .\" Generated from pam_sm_acct_mgmt.c by gendoc.pl .\" $Id: pam_sm_acct_mgmt.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SM_ACCT_MGMT 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_sm_authenticate.3 b/contrib/openpam/doc/man/pam_sm_authenticate.3 index d49936922b43..ed4db85d45ca 100644 --- a/contrib/openpam/doc/man/pam_sm_authenticate.3 +++ b/contrib/openpam/doc/man/pam_sm_authenticate.3 @@ -1,6 +1,6 @@ .\" Generated from pam_sm_authenticate.c by gendoc.pl .\" $Id: pam_sm_authenticate.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SM_AUTHENTICATE 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_sm_chauthtok.3 b/contrib/openpam/doc/man/pam_sm_chauthtok.3 index 289c34582e6d..a574ce3bf750 100644 --- a/contrib/openpam/doc/man/pam_sm_chauthtok.3 +++ b/contrib/openpam/doc/man/pam_sm_chauthtok.3 @@ -1,6 +1,6 @@ .\" Generated from pam_sm_chauthtok.c by gendoc.pl .\" $Id: pam_sm_chauthtok.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SM_CHAUTHTOK 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_sm_close_session.3 b/contrib/openpam/doc/man/pam_sm_close_session.3 index 3072ffe5c0df..ff39eb3f44b9 100644 --- a/contrib/openpam/doc/man/pam_sm_close_session.3 +++ b/contrib/openpam/doc/man/pam_sm_close_session.3 @@ -1,6 +1,6 @@ .\" Generated from pam_sm_close_session.c by gendoc.pl .\" $Id: pam_sm_close_session.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SM_CLOSE_SESSION 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_sm_open_session.3 b/contrib/openpam/doc/man/pam_sm_open_session.3 index 1da278674534..ffe6c2c44e7e 100644 --- a/contrib/openpam/doc/man/pam_sm_open_session.3 +++ b/contrib/openpam/doc/man/pam_sm_open_session.3 @@ -1,6 +1,6 @@ .\" Generated from pam_sm_open_session.c by gendoc.pl .\" $Id: pam_sm_open_session.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SM_OPEN_SESSION 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_sm_setcred.3 b/contrib/openpam/doc/man/pam_sm_setcred.3 index e4689d4e542f..0d532b9c1bf8 100644 --- a/contrib/openpam/doc/man/pam_sm_setcred.3 +++ b/contrib/openpam/doc/man/pam_sm_setcred.3 @@ -1,6 +1,6 @@ .\" Generated from pam_sm_setcred.c by gendoc.pl .\" $Id: pam_sm_setcred.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_SM_SETCRED 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_start.3 b/contrib/openpam/doc/man/pam_start.3 index 3d5a9d911852..3d1cee15bf9e 100644 --- a/contrib/openpam/doc/man/pam_start.3 +++ b/contrib/openpam/doc/man/pam_start.3 @@ -1,6 +1,6 @@ .\" Generated from pam_start.c by gendoc.pl .\" $Id: pam_start.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_START 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_strerror.3 b/contrib/openpam/doc/man/pam_strerror.3 index 2e16d8e8fa2a..8ac60be520c9 100644 --- a/contrib/openpam/doc/man/pam_strerror.3 +++ b/contrib/openpam/doc/man/pam_strerror.3 @@ -1,6 +1,6 @@ .\" Generated from pam_strerror.c by gendoc.pl .\" $Id: pam_strerror.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_STRERROR 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_verror.3 b/contrib/openpam/doc/man/pam_verror.3 index 6634cd16cc96..23c856a12205 100644 --- a/contrib/openpam/doc/man/pam_verror.3 +++ b/contrib/openpam/doc/man/pam_verror.3 @@ -1,6 +1,6 @@ .\" Generated from pam_verror.c by gendoc.pl .\" $Id: pam_verror.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_VERROR 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_vinfo.3 b/contrib/openpam/doc/man/pam_vinfo.3 index e0e08e0ed8d7..879963650950 100644 --- a/contrib/openpam/doc/man/pam_vinfo.3 +++ b/contrib/openpam/doc/man/pam_vinfo.3 @@ -1,6 +1,6 @@ .\" Generated from pam_vinfo.c by gendoc.pl .\" $Id: pam_vinfo.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_VINFO 3 .Os .Sh NAME diff --git a/contrib/openpam/doc/man/pam_vprompt.3 b/contrib/openpam/doc/man/pam_vprompt.3 index ae9801cc264b..fb4a8ac345d6 100644 --- a/contrib/openpam/doc/man/pam_vprompt.3 +++ b/contrib/openpam/doc/man/pam_vprompt.3 @@ -1,6 +1,6 @@ .\" Generated from pam_vprompt.c by gendoc.pl .\" $Id: pam_vprompt.c 648 2013-03-05 17:54:27Z des $ -.Dd September 7, 2013 +.Dd September 12, 2014 .Dt PAM_VPROMPT 3 .Os .Sh NAME diff --git a/contrib/openpam/include/Makefile.in b/contrib/openpam/include/Makefile.in index a8d4fa31ef8a..b8354681a94e 100644 --- a/contrib/openpam/include/Makefile.in +++ b/contrib/openpam/include/Makefile.in @@ -82,10 +82,7 @@ host_triplet = @host@ subdir = include DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/include/security/Makefile.in b/contrib/openpam/include/security/Makefile.in index b9e446127b99..b36341bc7fc3 100644 --- a/contrib/openpam/include/security/Makefile.in +++ b/contrib/openpam/include/security/Makefile.in @@ -84,10 +84,7 @@ subdir = include/security DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(security_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/include/security/openpam_version.h b/contrib/openpam/include/security/openpam_version.h index 8f1adc26651f..c5bf71dd6d97 100644 --- a/contrib/openpam/include/security/openpam_version.h +++ b/contrib/openpam/include/security/openpam_version.h @@ -32,14 +32,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openpam_version.h 737 2013-09-07 12:53:55Z des $ + * $Id: openpam_version.h 812 2014-09-12 07:24:23Z des $ */ #ifndef SECURITY_OPENPAM_VERSION_H_INCLUDED #define SECURITY_OPENPAM_VERSION_H_INCLUDED #define OPENPAM -#define OPENPAM_VERSION 20130907 -#define OPENPAM_RELEASE "Nummularia" +#define OPENPAM_VERSION 20140912 +#define OPENPAM_RELEASE "Ourouparia" #endif /* !SECURITY_OPENPAM_VERSION_H_INCLUDED */ diff --git a/contrib/openpam/lib/Makefile.am b/contrib/openpam/lib/Makefile.am index 4cd38c2e5cf9..9f2d21d7a44f 100644 --- a/contrib/openpam/lib/Makefile.am +++ b/contrib/openpam/lib/Makefile.am @@ -1,3 +1,3 @@ -# $Id: Makefile.am 255376 2013-09-07 19:43:39Z des $ +# $Id: Makefile.am 714 2013-08-19 15:30:21Z des $ SUBDIRS = libpam diff --git a/contrib/openpam/lib/Makefile.in b/contrib/openpam/lib/Makefile.in index 3ea0f711e7d3..198e909926da 100644 --- a/contrib/openpam/lib/Makefile.in +++ b/contrib/openpam/lib/Makefile.in @@ -82,10 +82,7 @@ host_triplet = @host@ subdir = lib DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/lib/libpam/Makefile.am b/contrib/openpam/lib/libpam/Makefile.am index 99c37f00ee6b..a7781d656786 100644 --- a/contrib/openpam/lib/libpam/Makefile.am +++ b/contrib/openpam/lib/libpam/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am 660 2013-03-11 15:08:52Z des $ +# $Id: Makefile.am 807 2014-09-09 09:41:32Z des $ NULL = @@ -18,6 +18,7 @@ noinst_HEADERS = \ openpam_strlcat.h \ openpam_strlcmp.h \ openpam_strlcpy.h \ + openpam_strlset.h \ openpam_vasprintf.h libpam_la_SOURCES = \ @@ -44,9 +45,10 @@ libpam_la_SOURCES = \ openpam_set_option.c \ openpam_set_feature.c \ openpam_static.c \ + openpam_straddch.c \ openpam_strlcat.c \ openpam_strlcpy.c \ - openpam_straddch.c \ + openpam_strlset.c \ openpam_subst.c \ openpam_vasprintf.c \ openpam_ttyconv.c \ diff --git a/contrib/openpam/lib/libpam/Makefile.in b/contrib/openpam/lib/libpam/Makefile.in index b84d4793f05c..f2971163e0ed 100644 --- a/contrib/openpam/lib/libpam/Makefile.in +++ b/contrib/openpam/lib/libpam/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -# $Id: Makefile.am 660 2013-03-11 15:08:52Z des $ +# $Id: Makefile.am 807 2014-09-09 09:41:32Z des $ VPATH = @srcdir@ @@ -85,10 +85,7 @@ subdir = lib/libpam DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(noinst_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -135,10 +132,10 @@ am_libpam_la_OBJECTS = openpam_asprintf.lo openpam_borrow_cred.lo \ openpam_nullconv.lo openpam_readline.lo openpam_readlinev.lo \ openpam_readword.lo openpam_restore_cred.lo \ openpam_set_option.lo openpam_set_feature.lo openpam_static.lo \ - openpam_strlcat.lo openpam_strlcpy.lo openpam_straddch.lo \ - openpam_subst.lo openpam_vasprintf.lo openpam_ttyconv.lo \ - pam_acct_mgmt.lo pam_authenticate.lo pam_chauthtok.lo \ - pam_close_session.lo pam_end.lo pam_error.lo \ + openpam_straddch.lo openpam_strlcat.lo openpam_strlcpy.lo \ + openpam_strlset.lo openpam_subst.lo openpam_vasprintf.lo \ + openpam_ttyconv.lo pam_acct_mgmt.lo pam_authenticate.lo \ + pam_chauthtok.lo pam_close_session.lo pam_end.lo pam_error.lo \ pam_get_authtok.lo pam_get_data.lo pam_get_item.lo \ pam_get_user.lo pam_getenv.lo pam_getenvlist.lo pam_info.lo \ pam_open_session.lo pam_prompt.lo pam_putenv.lo \ @@ -349,6 +346,7 @@ noinst_HEADERS = \ openpam_strlcat.h \ openpam_strlcmp.h \ openpam_strlcpy.h \ + openpam_strlset.h \ openpam_vasprintf.h libpam_la_SOURCES = \ @@ -375,9 +373,10 @@ libpam_la_SOURCES = \ openpam_set_option.c \ openpam_set_feature.c \ openpam_static.c \ + openpam_straddch.c \ openpam_strlcat.c \ openpam_strlcpy.c \ - openpam_straddch.c \ + openpam_strlset.c \ openpam_subst.c \ openpam_vasprintf.c \ openpam_ttyconv.c \ @@ -534,6 +533,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_straddch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_strlcat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_strlcpy.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_strlset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_subst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_ttyconv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openpam_vasprintf.Plo@am__quote@ diff --git a/contrib/openpam/lib/libpam/openpam_configure.c b/contrib/openpam/lib/libpam/openpam_configure.c index 4e3de577dcdb..5a4ca620222f 100644 --- a/contrib/openpam/lib/libpam/openpam_configure.c +++ b/contrib/openpam/lib/libpam/openpam_configure.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openpam_configure.c 667 2013-03-17 14:24:00Z des $ + * $Id: openpam_configure.c 796 2014-06-03 21:30:08Z des $ */ #ifdef HAVE_CONFIG_H diff --git a/contrib/openpam/lib/libpam/openpam_ctype.h b/contrib/openpam/lib/libpam/openpam_ctype.h index 38016227a687..d99d34b4dacf 100644 --- a/contrib/openpam/lib/libpam/openpam_ctype.h +++ b/contrib/openpam/lib/libpam/openpam_ctype.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openpam_ctype.h 666 2013-03-17 14:22:17Z des $ + * $Id: openpam_ctype.h 763 2014-02-26 16:29:16Z des $ */ #ifndef OPENPAM_CTYPE_H_INCLUDED diff --git a/contrib/openpam/lib/libpam/openpam_dispatch.c b/contrib/openpam/lib/libpam/openpam_dispatch.c index 0dcc73223ce3..5fa068f8e261 100644 --- a/contrib/openpam/lib/libpam/openpam_dispatch.c +++ b/contrib/openpam/lib/libpam/openpam_dispatch.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openpam_dispatch.c 649 2013-03-05 17:58:33Z des $ + * $Id: openpam_dispatch.c 807 2014-09-09 09:41:32Z des $ */ #ifdef HAVE_CONFIG_H @@ -63,7 +63,7 @@ openpam_dispatch(pam_handle_t *pamh, int flags) { pam_chain_t *chain; - int err, fail, r; + int err, fail, nsuccess, r; int debug; ENTER(); @@ -101,7 +101,9 @@ openpam_dispatch(pam_handle_t *pamh, } /* execute */ - for (err = fail = 0; chain != NULL; chain = chain->next) { + err = PAM_SUCCESS; + fail = nsuccess = 0; + for (; chain != NULL; chain = chain->next) { if (chain->module->func[primitive] == NULL) { openpam_log(PAM_LOG_ERROR, "%s: no %s()", chain->module->path, pam_sm_func_name[primitive]); @@ -126,7 +128,8 @@ openpam_dispatch(pam_handle_t *pamh, if (r == PAM_IGNORE) continue; - if (r == PAM_SUCCESS) { + if (r == PAM_SUCCESS) { + ++nsuccess; /* * For pam_setcred() and pam_chauthtok() with the * PAM_PRELIM_CHECK flag, treat "sufficient" as @@ -148,7 +151,7 @@ openpam_dispatch(pam_handle_t *pamh, * fail. If a required module fails, record the * return code from the first required module to fail. */ - if (err == 0) + if (err == PAM_SUCCESS) err = r; if ((chain->flag == PAM_REQUIRED || chain->flag == PAM_BINDING) && !fail) { @@ -170,6 +173,18 @@ openpam_dispatch(pam_handle_t *pamh, if (!fail && err != PAM_NEW_AUTHTOK_REQD) err = PAM_SUCCESS; + + /* + * Require the chain to be non-empty, and at least one module + * in the chain to be successful, so that we don't fail open. + */ + if (err == PAM_SUCCESS && nsuccess < 1) { + openpam_log(PAM_LOG_ERROR, + "all modules were unsuccessful for %s()", + pam_sm_func_name[primitive]); + err = PAM_SYSTEM_ERR; + } + RETURNC(err); } diff --git a/lib/libproc/test/t1-bkpt/t1-bkpt.c b/contrib/openpam/lib/libpam/openpam_strlset.c similarity index 51% rename from lib/libproc/test/t1-bkpt/t1-bkpt.c rename to contrib/openpam/lib/libpam/openpam_strlset.c index 1cd4d17f5612..2f4c4fa7e188 100644 --- a/lib/libproc/test/t1-bkpt/t1-bkpt.c +++ b/contrib/openpam/lib/libpam/openpam_strlset.c @@ -1,71 +1,58 @@ -/* - * Copyright (c) 2010 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Rui Paulo under sponsorship from the - * FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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. +/*- + * Copyright (c) 2011-2012 Dag-Erling Smørgrav + * All rights reserved. * - * $FreeBSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. 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. + * + * $Id: openpam_strlset.c 807 2014-09-09 09:41:32Z des $ */ -#include -#include -#include -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -int __noinline -t1_bkpt_t() +#ifndef HAVE_STRLSET + +#include + +#include "openpam_strlset.h" + +/* + * like memset(3), but stops at the first NUL byte and NUL-terminates the + * result. Returns the number of bytes that were written, not including + * the terminating NUL. + */ +size_t +openpam_strlset(char *str, int ch, size_t size) { - printf("TEST OK\n"); -} - -int -t1_bkpt_d() -{ - struct proc_handle *phdl; - char *targv[] = { "t1-bkpt-t", NULL}; - unsigned long saved; - - proc_create("./t1-bkpt", targv, NULL, NULL, &phdl); - assert(proc_bkptset(phdl, (uintptr_t)t1_bkpt_t, &saved) == 0); - proc_continue(phdl); - assert(proc_wstatus(phdl) == PS_STOP); - proc_bkptexec(phdl, saved); - proc_continue(phdl); - proc_wstatus(phdl); - proc_free(phdl); -} - - -int -main(int argc, char **argv) -{ - if (!strcmp(argv[0], "t1-bkpt-t")) - t1_bkpt_t(); - else - t1_bkpt_d(); + size_t len; + + for (len = 0; *str && size > 1; ++len, --size) + *str++ = ch; + *str = '\0'; + return (++len); } +#endif diff --git a/contrib/openpam/lib/libpam/openpam_strlset.h b/contrib/openpam/lib/libpam/openpam_strlset.h new file mode 100644 index 000000000000..4bb0bb6404d0 --- /dev/null +++ b/contrib/openpam/lib/libpam/openpam_strlset.h @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. 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. + * + * $Id: openpam_strlset.h 807 2014-09-09 09:41:32Z des $ + */ + +#ifndef OPENPAM_STRLSET_H_INCLUDED +#define OPENPAM_STRLSET_H_INCLUDED + +#ifndef HAVE_STRLSET +size_t openpam_strlset(char *, int, size_t); +#undef strlset +#define strlset(arg, ...) openpam_strlset(arg, __VA_ARGS__) +#endif + +#endif diff --git a/contrib/openpam/lib/libpam/openpam_ttyconv.c b/contrib/openpam/lib/libpam/openpam_ttyconv.c index 01e61810ccff..d21320ca7228 100644 --- a/contrib/openpam/lib/libpam/openpam_ttyconv.c +++ b/contrib/openpam/lib/libpam/openpam_ttyconv.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: openpam_ttyconv.c 688 2013-07-11 16:40:08Z des $ + * $Id: openpam_ttyconv.c 807 2014-09-09 09:41:32Z des $ */ #ifdef HAVE_CONFIG_H @@ -55,6 +55,7 @@ #include #include "openpam_impl.h" +#include "openpam_strlset.h" int openpam_ttyconv_timeout = 0; @@ -366,7 +367,7 @@ openpam_ttyconv(int n, fail: for (i = 0; i < n; ++i) { if (aresp[i].resp != NULL) { - memset(aresp[i].resp, 0, strlen(aresp[i].resp)); + strlset(aresp[i].resp, 0, PAM_MAX_RESP_SIZE); FREE(aresp[i].resp); } } diff --git a/contrib/openpam/lib/libpam/pam_get_authtok.c b/contrib/openpam/lib/libpam/pam_get_authtok.c index a0629341c22a..36382f5d8690 100644 --- a/contrib/openpam/lib/libpam/pam_get_authtok.c +++ b/contrib/openpam/lib/libpam/pam_get_authtok.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pam_get_authtok.c 670 2013-03-17 19:26:07Z des $ + * $Id: pam_get_authtok.c 807 2014-09-09 09:41:32Z des $ */ #ifdef HAVE_CONFIG_H @@ -48,6 +48,7 @@ #include #include "openpam_impl.h" +#include "openpam_strlset.h" static const char authtok_prompt[] = "Password:"; static const char authtok_prompt_remote[] = "Password for %u@%h:"; @@ -140,16 +141,21 @@ pam_get_authtok(pam_handle_t *pamh, if (twice) { r = pam_prompt(pamh, style, &resp2, "Retype %s", prompt); if (r != PAM_SUCCESS) { + strlset(resp, 0, PAM_MAX_RESP_SIZE); FREE(resp); RETURNC(r); } - if (strcmp(resp, resp2) != 0) + if (strcmp(resp, resp2) != 0) { + strlset(resp, 0, PAM_MAX_RESP_SIZE); FREE(resp); + } + strlset(resp2, 0, PAM_MAX_RESP_SIZE); FREE(resp2); } if (resp == NULL) RETURNC(PAM_TRY_AGAIN); r = pam_set_item(pamh, item, resp); + strlset(resp, 0, PAM_MAX_RESP_SIZE); FREE(resp); if (r != PAM_SUCCESS) RETURNC(r); diff --git a/contrib/openpam/ltmain.sh b/contrib/openpam/ltmain.sh index 16ddbf884b67..dc8e388a6340 100755 --- a/contrib/openpam/ltmain.sh +++ b/contrib/openpam/ltmain.sh @@ -1377,8 +1377,8 @@ func_infer_tag () $opt_debug # FreeBSD-specific: where we install compilers with non-standard names - tag_compilers_CC="*cc cc* *gcc gcc* clang" - tag_compilers_CXX="*c++ c++* *g++ g++* clang++" + tag_compilers_CC="*cc cc* *gcc gcc* clang*" + tag_compilers_CXX="*c++ c++* *g++ g++* clang++*" base_compiler=`set -- "$@"; echo $1` # If $tagname isn't set, then try to infer if the default "CC" tag applies diff --git a/contrib/openpam/m4/libtool.m4 b/contrib/openpam/m4/libtool.m4 deleted file mode 100644 index 44e0ecff11e3..000000000000 --- a/contrib/openpam/m4/libtool.m4 +++ /dev/null @@ -1,7982 +0,0 @@ -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -]) - -# serial 57 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl - -_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl -dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_WITH_SYSROOT])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PREPARE_SED_QUOTE_VARS -# -------------------------- -# Define a few sed substitution that help us do robust quoting. -m4_defun([_LT_PREPARE_SED_QUOTE_VARS], -[# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' -]) - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" -])# _LT_PROG_LTMAIN - - -## ------------------------------------- ## -## Accumulate code for creating libtool. ## -## ------------------------------------- ## - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - -## ------------------------ ## -## FIXME: Eliminate VARNAME ## -## ------------------------ ## - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$[]1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -_LT_OUTPUT_LIBTOOL_INIT -]) - -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) -# ------------------------------------ -# Generate a child script FILE with all initialization necessary to -# reuse the environment learned by the parent script, and make the -# file executable. If COMMENT is supplied, it is inserted after the -# `#!' sequence but before initialization text begins. After this -# macro, additional text can be appended to FILE to form the body of -# the child script. The macro ends with non-zero status if the -# file could not be fully written (such as if the disk is full). -m4_ifdef([AS_INIT_GENERATED], -[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], -[m4_defun([_LT_GENERATED_FILE_INIT], -[m4_require([AS_PREPARE])]dnl -[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl -[lt_write_fail=0 -cat >$1 <<_ASEOF || lt_write_fail=1 -#! $SHELL -# Generated by $as_me. -$2 -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$1 <<\_ASEOF || lt_write_fail=1 -AS_SHELL_SANITIZE -_AS_PREPARE -exec AS_MESSAGE_FD>&1 -_ASEOF -test $lt_write_fail = 0 && chmod +x $1[]dnl -m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], -[# Run this file to recreate a libtool stub with the current configuration.]) - -cat >>"$CONFIG_LT" <<\_LTEOF -lt_cl_silent=false -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2011 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test $[#] != 0 -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -lt_cl_success=: -test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" -exec AS_MESSAGE_LOG_FD>/dev/null -$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false -exec AS_MESSAGE_LOG_FD>>config.log -$lt_cl_success || AS_EXIT(1) -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -_LT_COPYING -_LT_LIBTOOL_TAGS - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_REPLACE_SHELLFNS - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Go], [_LT_LANG(GO)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -m4_ifndef([AC_PROG_GO], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_GO. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ -m4_defun([AC_PROG_GO], -[AC_LANG_PUSH(Go)dnl -AC_ARG_VAR([GOC], [Go compiler command])dnl -AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl -_AC_ARG_VAR_LDFLAGS()dnl -AC_CHECK_TOOL(GOC, gccgo) -if test -z "$GOC"; then - if test -n "$ac_tool_prefix"; then - AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) - fi -fi -if test -z "$GOC"; then - AC_CHECK_PROG(GOC, gccgo, gccgo, false) -fi -])#m4_defun -])#m4_ifndef - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([AC_PROG_GO], - [LT_LANG(GO)], - [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) -dnl AC_DEFUN([AC_LIBTOOL_RC], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" - ]) - - AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], - [lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD - echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD - $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES([TAG]) -# --------------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], - [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) -# ---------------------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -# Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ - lt_aix_libpath_sed='[ - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }]' - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi],[]) - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" - fi - ]) - aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) -fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[m4_divert_text([M4SH-INIT], [$1 -])])# _LT_SHELL_INIT - - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Find how we can fake an echo command that does not interpret backslash. -# In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script which will find a shell with a builtin -# printf (which we can use as an echo command). -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -AC_MSG_CHECKING([how to print strings]) -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$[]1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -case "$ECHO" in - printf*) AC_MSG_RESULT([printf]) ;; - print*) AC_MSG_RESULT([print -r]) ;; - *) AC_MSG_RESULT([cat]) ;; -esac - -m4_ifdef([_AS_DETECT_SUGGESTED], -[_AS_DETECT_SUGGESTED([ - test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test "X`printf %s $ECHO`" = "X$ECHO" \ - || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) - -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_WITH_SYSROOT -# ---------------- -AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) -AC_ARG_WITH([sysroot], -[ --with-sysroot[=DIR] Search for dependent libraries within DIR - (or the compiler's sysroot if not specified).], -[], [with_sysroot=no]) - -dnl lt_sysroot will always be passed unquoted. We quote it here -dnl in case the user passed a directory name. -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - AC_MSG_RESULT([${with_sysroot}]) - AC_MSG_ERROR([The sysroot must be an absolute path.]) - ;; -esac - - AC_MSG_RESULT([${lt_sysroot:-no}]) -_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl -[dependent libraries, and in which our libraries should be installed.])]) - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" -])# _LT_ENABLE_LOCK - - -# _LT_PROG_AR -# ----------- -m4_defun([_LT_PROG_AR], -[AC_CHECK_TOOLS(AR, [ar], false) -: ${AR=ar} -: ${AR_FLAGS=cru} -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) - -AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], - [lt_cv_ar_at_file=no - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - ]) - ]) - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi -_LT_DECL([], [archiver_list_spec], [1], - [How to feed a file listing to the archiver]) -])# _LT_PROG_AR - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[_LT_PROG_AR - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -_LT_DECL([], [lock_old_archive_extraction], [0], - [Whether to use a lock for old archive extraction]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test x"[$]$2" = xyes; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[[4-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[23]].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[[3-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], - [lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [lt_cv_shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - ]) - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [install_override_mode], [1], - [Permission mode override for installation of shared libraries]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PROG_ECHO_BACKSLASH])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc*) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` - fi - ;; - esac -fi - -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method = "file_magic"]) -_LT_DECL([], [file_magic_glob], [1], - [How to find potential files when deplibs_check_method = "file_magic"]) -_LT_DECL([], [want_nocaseglob], [1], - [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi - AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB -# -------------------------------- -# how to determine the name of the shared library -# associated with a specific link library. -# -- PORTME fill in with the dynamic library characteristics -m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], -[m4_require([_LT_DECL_EGREP]) -m4_require([_LT_DECL_OBJDUMP]) -m4_require([_LT_DECL_DLLTOOL]) -AC_CACHE_CHECK([how to associate runtime and link libraries], -lt_cv_sharedlib_from_linklib_cmd, -[lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac -]) -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - -_LT_DECL([], [sharedlib_from_linklib_cmd], [1], - [Command to associate shared and link libraries]) -])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB - - -# _LT_PATH_MANIFEST_TOOL -# ---------------------- -# locate the manifest tool -m4_defun([_LT_PATH_MANIFEST_TOOL], -[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], - [lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&AS_MESSAGE_LOG_FD - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest*]) -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi -_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl -])# _LT_PATH_MANIFEST_TOOL - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - case $cc_basename in - nvcc*) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; - *) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; - esac - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT@&t@_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT@&t@_DLSYM_CONST -#else -# define LT@&t@_DLSYM_CONST const -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -LT@&t@_DLSYM_CONST struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -_LT_DECL([], [nm_file_list_spec], [1], - [Specify filename containing input files for $NM]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" - fi - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - nagfor*) - # NAG Fortran compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - *Sun\ F* | *Sun*Fortran*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Intel*\ [[CF]]*Compiler*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - *Portland\ Group*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac - -AC_CACHE_CHECK([for $compiler option to produce PIC], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - case $cc_basename in - cl*) - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - ;; - esac - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; - *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.19, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag=' $pic_flag' - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf* | bgf* | bgxlf* | mpixlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - esac - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - m4_if($1, [], [ - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - _LT_LINKER_OPTION([if $CC understands -b], - _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], - [lt_cv_irix_exported_symbol], - [save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE( - [AC_LANG_SOURCE( - [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], - [C++], [[int foo (void) { return 0; }]], - [Fortran 77], [[ - subroutine foo - end]], - [Fortran], [[ - subroutine foo - end]])])], - [lt_cv_irix_exported_symbol=yes], - [lt_cv_irix_exported_symbol=no]) - LDFLAGS="$save_LDFLAGS"]) - if test "$lt_cv_irix_exported_symbol" = yes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_CACHE_CHECK([whether -lc should be explicitly linked in], - [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), - [$RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - ]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [postlink_cmds], [2], - [Commands necessary for finishing linking programs]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report which library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC="$lt_save_CC" -])# _LT_LANG_C_CONFIG - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_CFLAGS=$CFLAGS - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - CFLAGS=$CXXFLAGS - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd2.*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - gnu*) - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 and above use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' - ;; - xl* | mpixl* | bgxl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=func_echo_all - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ - '"$_LT_TAGVAR(old_archive_cmds, $1)" - _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ - '"$_LT_TAGVAR(reload_cmds, $1)" - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_FUNC_STRIPNAME_CNF -# ---------------------- -# func_stripname_cnf prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# -# This function is identical to the (non-XSI) version of func_stripname, -# except this one can be used by m4 code that may be executed by configure, -# rather than the libtool script. -m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl -AC_REQUIRE([_LT_DECL_SED]) -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) -func_stripname_cnf () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname_cnf -])# _LT_FUNC_STRIPNAME_CNF - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF -package foo -func foo() { -} -_LT_EOF -]) - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - fi - - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} in - -L | -R) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" - fi - fi - prev= - ;; - - *.lto.$objext) ;; # Ignore GCC LTO objects - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext -CFLAGS=$_lt_libdeps_save_CFLAGS - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC* | sunCC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_LANG_PUSH(Fortran 77) -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS - CC=${F77-"f77"} - CFLAGS=$FFLAGS - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" - CFLAGS="$lt_save_CFLAGS" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_LANG_PUSH(Fortran) - -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS - CC=${FC-"f95"} - CFLAGS=$FCFLAGS - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS -fi # test "$_lt_disable_FC" != yes - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -CFLAGS=$GCJFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_GO_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Go compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GO_CONFIG], -[AC_REQUIRE([LT_PROG_GO])dnl -AC_LANG_SAVE - -# Source file extension for Go test sources. -ac_ext=go - -# Object file extension for compiled Go test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="package main; func main() { }" - -# Code to be used in simple link tests -lt_simple_link_test_code='package main; func main() { }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GOC-"gccgo"} -CFLAGS=$GOFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# Go did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GO_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -CFLAGS= -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_GO -# ---------- -AC_DEFUN([LT_PROG_GO], -[AC_CHECK_TOOL(GOC, gccgo,) -]) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - -# _LT_DECL_DLLTOOL -# ---------------- -# Ensure DLLTOOL variable is set. -m4_defun([_LT_DECL_DLLTOOL], -[AC_CHECK_TOOL(DLLTOOL, dlltool, false) -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) -AC_SUBST([DLLTOOL]) -]) - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) -# ------------------------------------------------------ -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. -m4_defun([_LT_PROG_FUNCTION_REPLACE], -[dnl { -sed -e '/^$1 ()$/,/^} # $1 /c\ -$1 ()\ -{\ -m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) -} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: -]) - - -# _LT_PROG_REPLACE_SHELLFNS -# ------------------------- -# Replace existing portable implementations of several shell functions with -# equivalent extended shell implementations where those features are available.. -m4_defun([_LT_PROG_REPLACE_SHELLFNS], -[if test x"$xsi_shell" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) - - _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) - - _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) - - _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) -fi - -if test x"$lt_shell_append" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) - - _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl - func_quote_for_eval "${2}" -dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ - eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) -fi -]) - -# _LT_PATH_CONVERSION_FUNCTIONS -# ----------------------------- -# Determine which file name conversion functions should be used by -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed -# for certain cross-compile configurations and native mingw. -m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_MSG_CHECKING([how to convert $build file names to $host format]) -AC_CACHE_VAL(lt_cv_to_host_file_cmd, -[case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac -]) -to_host_file_cmd=$lt_cv_to_host_file_cmd -AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) -_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], - [0], [convert $build file names to $host format])dnl - -AC_MSG_CHECKING([how to convert $build file names to toolchain format]) -AC_CACHE_VAL(lt_cv_to_tool_file_cmd, -[#assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac -]) -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) -_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], - [0], [convert $build files to toolchain format])dnl -])# _LT_PATH_CONVERSION_FUNCTIONS diff --git a/contrib/openpam/m4/ltoptions.m4 b/contrib/openpam/m4/ltoptions.m4 deleted file mode 100644 index 5d9acd8e23bc..000000000000 --- a/contrib/openpam/m4/ltoptions.m4 +++ /dev/null @@ -1,384 +0,0 @@ -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 7 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ -m4_define([_LT_MANGLE_OPTION], -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. -m4_define([_LT_SET_OPTION], -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), - _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option `$2'])])[]dnl -]) - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -m4_define([_LT_IF_OPTION], -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. -m4_define([_LT_UNLESS_OPTIONS], -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), - [m4_define([$0_found])])])[]dnl -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 -])[]dnl -]) - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -m4_defun([_LT_SET_OPTIONS], -[# Set options -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [_LT_SET_OPTION([$1], _LT_Option)]) - -m4_if([$1],[LT_INIT],[ - dnl - dnl Simply set some default values (i.e off) if boolean options were not - dnl specified: - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no - ]) - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no - ]) - dnl - dnl If no reference was made to various pairs of opposing options, then - dnl we run the default mode handler for the pair. For example, if neither - dnl `shared' nor `disable-shared' was passed, we enable building of shared - dnl archives by default: - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) - ]) -])# _LT_SET_OPTIONS - - -## --------------------------------- ## -## Macros to handle LT_INIT options. ## -## --------------------------------- ## - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- -m4_define([_LT_MANGLE_DEFUN], -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -m4_define([LT_OPTION_DEFINE], -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl -])# LT_OPTION_DEFINE - - -# dlopen -# ------ -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes -]) - -AU_DEFUN([AC_LIBTOOL_DLOPEN], -[_LT_SET_OPTION([LT_INIT], [dlopen]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `dlopen' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -LT_OPTION_DEFINE([LT_INIT], [win32-dll], -[enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -esac - -test -z "$AS" && AS=as -_LT_DECL([], [AS], [1], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl -])# win32-dll - -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -_LT_SET_OPTION([LT_INIT], [win32-dll]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `win32-dll' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_SHARED], -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) - - _LT_DECL([build_libtool_libs], [enable_shared], [0], - [Whether or not to build shared libraries]) -])# _LT_ENABLE_SHARED - -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) -]) - -AC_DEFUN([AC_DISABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], [disable-shared]) -]) - -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_SHARED], []) -dnl AC_DEFUN([AM_DISABLE_SHARED], []) - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_STATIC], -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) - - _LT_DECL([build_old_libs], [enable_static], [0], - [Whether or not to build static libraries]) -])# _LT_ENABLE_STATIC - -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) -]) - -AC_DEFUN([AC_DISABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], [disable-static]) -]) - -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_STATIC], []) -dnl AC_DEFUN([AM_DISABLE_STATIC], []) - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_FAST_INSTALL], -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([fast-install], - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) - -_LT_DECL([fast_install], [enable_fast_install], [0], - [Whether or not to optimize for fast installation])dnl -])# _LT_ENABLE_FAST_INSTALL - -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) - -# Old names: -AU_DEFUN([AC_ENABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `fast-install' option into LT_INIT's first parameter.]) -]) - -AU_DEFUN([AC_DISABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `disable-fast-install' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' -# LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [pic_mode=default]) - -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) - -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl -])# _LT_WITH_PIC - -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) - -# Old name: -AU_DEFUN([AC_LIBTOOL_PICMODE], -[_LT_SET_OPTION([LT_INIT], [pic-only]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `pic-only' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) - -## ----------------- ## -## LTDL_INIT Options ## -## ----------------- ## - -m4_define([_LTDL_MODE], []) -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], - [m4_define([_LTDL_MODE], [nonrecursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [recursive], - [m4_define([_LTDL_MODE], [recursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [subproject], - [m4_define([_LTDL_MODE], [subproject])]) - -m4_define([_LTDL_TYPE], []) -LT_OPTION_DEFINE([LTDL_INIT], [installable], - [m4_define([_LTDL_TYPE], [installable])]) -LT_OPTION_DEFINE([LTDL_INIT], [convenience], - [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/contrib/openpam/m4/ltsugar.m4 b/contrib/openpam/m4/ltsugar.m4 deleted file mode 100644 index 9000a057d31d..000000000000 --- a/contrib/openpam/m4/ltsugar.m4 +++ /dev/null @@ -1,123 +0,0 @@ -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) diff --git a/contrib/openpam/m4/ltversion.m4 b/contrib/openpam/m4/ltversion.m4 deleted file mode 100644 index 07a8602d48d6..000000000000 --- a/contrib/openpam/m4/ltversion.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# @configure_input@ - -# serial 3337 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.4.2]) -m4_define([LT_PACKAGE_REVISION], [1.3337]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.2' -macro_revision='1.3337' -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) -_LT_DECL(, macro_revision, 0) -]) diff --git a/contrib/openpam/m4/lt~obsolete.m4 b/contrib/openpam/m4/lt~obsolete.m4 deleted file mode 100644 index c573da90c5cc..000000000000 --- a/contrib/openpam/m4/lt~obsolete.m4 +++ /dev/null @@ -1,98 +0,0 @@ -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 5 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) - -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) -m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) -m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) -m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) -m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) -m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) -m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) diff --git a/contrib/openpam/mkpkgng.in b/contrib/openpam/mkpkgng.in index 31efc84a6026..5c14c1848909 100644 --- a/contrib/openpam/mkpkgng.in +++ b/contrib/openpam/mkpkgng.in @@ -27,7 +27,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: mkpkgng.in 740 2013-09-07 13:03:20Z des $ +# $Id: mkpkgng.in 816 2014-09-12 07:50:22Z des $ # # Print an informational message @@ -69,9 +69,9 @@ cd "$srcdir" # # Determine pkgng version and ABI # -pkgver=$(pkg -vv | awk '$1 == "Version:" { print $2 }') +pkgver=$(pkg -v) [ -n "$pkgver" ] || error "Unable to determine pkgng version." -pkgabi=$(pkg -vv | awk '$1 == "ABI:" { print $2 }') +pkgabi=$(pkg config abi) [ -n "$pkgabi" ] || error "Unable to determine package ABI." # diff --git a/contrib/openpam/modules/Makefile.in b/contrib/openpam/modules/Makefile.in index 2b88ac696bf2..412068ab0afd 100644 --- a/contrib/openpam/modules/Makefile.in +++ b/contrib/openpam/modules/Makefile.in @@ -83,10 +83,7 @@ host_triplet = @host@ subdir = modules DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/modules/pam_deny/Makefile.in b/contrib/openpam/modules/pam_deny/Makefile.in index 7369bdbc0bca..f38452ac0a99 100644 --- a/contrib/openpam/modules/pam_deny/Makefile.in +++ b/contrib/openpam/modules/pam_deny/Makefile.in @@ -84,10 +84,7 @@ subdir = modules/pam_deny DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/modules/pam_permit/Makefile.in b/contrib/openpam/modules/pam_permit/Makefile.in index f84e317dc0dd..9949ebdf6ed0 100644 --- a/contrib/openpam/modules/pam_permit/Makefile.in +++ b/contrib/openpam/modules/pam_permit/Makefile.in @@ -84,10 +84,7 @@ subdir = modules/pam_permit DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/modules/pam_unix/Makefile.in b/contrib/openpam/modules/pam_unix/Makefile.in index 022e833a3a60..b5d116a07d3f 100644 --- a/contrib/openpam/modules/pam_unix/Makefile.in +++ b/contrib/openpam/modules/pam_unix/Makefile.in @@ -84,10 +84,7 @@ subdir = modules/pam_unix DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d diff --git a/contrib/openpam/pamgdb.in b/contrib/openpam/pamgdb.in index 5b463900ff08..7667e0b45173 100644 --- a/contrib/openpam/pamgdb.in +++ b/contrib/openpam/pamgdb.in @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: pamgdb.in 648 2013-03-05 17:54:27Z des $ +# $Id: pamgdb.in 816 2014-09-12 07:50:22Z des $ # srcdir="@abs_top_srcdir@" diff --git a/contrib/openpam/t/Makefile.am b/contrib/openpam/t/Makefile.am index fd9a3e21eb3e..bf3801b5417b 100644 --- a/contrib/openpam/t/Makefile.am +++ b/contrib/openpam/t/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am 714 2013-08-19 15:30:21Z des $ +# $Id: Makefile.am 763 2014-02-26 16:29:16Z des $ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/libpam diff --git a/contrib/openpam/t/Makefile.in b/contrib/openpam/t/Makefile.in index 2e7eda7622d0..756951eced11 100644 --- a/contrib/openpam/t/Makefile.in +++ b/contrib/openpam/t/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -# $Id: Makefile.am 714 2013-08-19 15:30:21Z des $ +# $Id: Makefile.am 763 2014-02-26 16:29:16Z des $ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' @@ -80,17 +80,15 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -TESTS = t_openpam_readword$(EXEEXT) t_openpam_readlinev$(EXEEXT) +TESTS = t_openpam_ctype$(EXEEXT) t_openpam_readword$(EXEEXT) \ + t_openpam_readlinev$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) subdir = t DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(noinst_HEADERS) \ $(top_srcdir)/test-driver ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -106,17 +104,22 @@ libt_a_AR = $(AR) $(ARFLAGS) libt_a_LIBADD = am_libt_a_OBJECTS = t_main.$(OBJEXT) t_file.$(OBJEXT) libt_a_OBJECTS = $(am_libt_a_OBJECTS) -am__EXEEXT_1 = t_openpam_readword$(EXEEXT) \ +am__EXEEXT_1 = t_openpam_ctype$(EXEEXT) t_openpam_readword$(EXEEXT) \ t_openpam_readlinev$(EXEEXT) -t_openpam_readlinev_SOURCES = t_openpam_readlinev.c -t_openpam_readlinev_OBJECTS = t_openpam_readlinev.$(OBJEXT) -t_openpam_readlinev_LDADD = $(LDADD) -t_openpam_readlinev_DEPENDENCIES = libt.a \ +t_openpam_ctype_SOURCES = t_openpam_ctype.c +t_openpam_ctype_OBJECTS = t_openpam_ctype.$(OBJEXT) +t_openpam_ctype_LDADD = $(LDADD) +t_openpam_ctype_DEPENDENCIES = libt.a \ $(top_builddir)/lib/libpam/libpam.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = +t_openpam_readlinev_SOURCES = t_openpam_readlinev.c +t_openpam_readlinev_OBJECTS = t_openpam_readlinev.$(OBJEXT) +t_openpam_readlinev_LDADD = $(LDADD) +t_openpam_readlinev_DEPENDENCIES = libt.a \ + $(top_builddir)/lib/libpam/libpam.la t_openpam_readword_SOURCES = t_openpam_readword.c t_openpam_readword_OBJECTS = t_openpam_readword.$(OBJEXT) t_openpam_readword_LDADD = $(LDADD) @@ -156,9 +159,10 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libt_a_SOURCES) t_openpam_readlinev.c t_openpam_readword.c -DIST_SOURCES = $(libt_a_SOURCES) t_openpam_readlinev.c \ +SOURCES = $(libt_a_SOURCES) t_openpam_ctype.c t_openpam_readlinev.c \ t_openpam_readword.c +DIST_SOURCES = $(libt_a_SOURCES) t_openpam_ctype.c \ + t_openpam_readlinev.c t_openpam_readword.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -569,6 +573,10 @@ clean-checkPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +t_openpam_ctype$(EXEEXT): $(t_openpam_ctype_OBJECTS) $(t_openpam_ctype_DEPENDENCIES) $(EXTRA_t_openpam_ctype_DEPENDENCIES) + @rm -f t_openpam_ctype$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_openpam_ctype_OBJECTS) $(t_openpam_ctype_LDADD) $(LIBS) + t_openpam_readlinev$(EXEEXT): $(t_openpam_readlinev_OBJECTS) $(t_openpam_readlinev_DEPENDENCIES) $(EXTRA_t_openpam_readlinev_DEPENDENCIES) @rm -f t_openpam_readlinev$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t_openpam_readlinev_OBJECTS) $(t_openpam_readlinev_LDADD) $(LIBS) @@ -585,6 +593,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_ctype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_readlinev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_readword.Po@am__quote@ @@ -808,6 +817,13 @@ recheck: all $(check_LIBRARIES) $(check_PROGRAMS) am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? +t_openpam_ctype.log: t_openpam_ctype$(EXEEXT) + @p='t_openpam_ctype$(EXEEXT)'; \ + b='t_openpam_ctype'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) t_openpam_readword.log: t_openpam_readword$(EXEEXT) @p='t_openpam_readword$(EXEEXT)'; \ b='t_openpam_readword'; \ diff --git a/contrib/pjdfstest/FREEBSD-upgrade b/contrib/pjdfstest/FREEBSD-upgrade new file mode 100644 index 000000000000..eff295fbfdc0 --- /dev/null +++ b/contrib/pjdfstest/FREEBSD-upgrade @@ -0,0 +1,25 @@ +$FreeBSD$ + +This document contains a collection of notes specific to the import +of pjdfstest into head. These notes are built on the instructions in +the FreeBSD Subversion Primer that detail how to deal with vendor +branches and you are supposed to follow those: + + http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html + +The pjdfstest source code is hosted on GitHub: + + https://github.com/pjd/pjdfstest + +and is imported into the pjdfstest vendor branch (see base/vendor/pjdfstest/). + +To merge the vendor branch into head do something like this: + + cd .../base/head/contrib/pjdfstest + svn merge --accept=postpone \ + svn+ssh://svn.freebsd.org/base/vendor/pjdfstest/dist . + +and resolve any conflicts that may arise at this point. + +Lastly, with the list of old and new files in this import, make sure +to update the reachover Makefiles accordingly. diff --git a/tools/regression/pjdfstest/LICENSE b/contrib/pjdfstest/LICENSE similarity index 89% rename from tools/regression/pjdfstest/LICENSE rename to contrib/pjdfstest/LICENSE index bde2232c223f..f91e71b37bf4 100644 --- a/tools/regression/pjdfstest/LICENSE +++ b/contrib/pjdfstest/LICENSE @@ -1,8 +1,8 @@ -$FreeBSD$ +$FreeBSD: head/tools/regression/pjdfstest/LICENSE 211354 2010-08-15 21:29:03Z pjd $ License for all regression tests available with pjdfstest: -Copyright (c) 2006-2010 Pawel Jakub Dawidek +Copyright (c) 2006-2012 Pawel Jakub Dawidek All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/tools/regression/pjdfstest/Makefile b/contrib/pjdfstest/Makefile similarity index 100% rename from tools/regression/pjdfstest/Makefile rename to contrib/pjdfstest/Makefile diff --git a/tools/regression/pjdfstest/README b/contrib/pjdfstest/README similarity index 81% rename from tools/regression/pjdfstest/README rename to contrib/pjdfstest/README index fb1cda52ab62..dcc5a64ba3f4 100644 --- a/tools/regression/pjdfstest/README +++ b/contrib/pjdfstest/README @@ -1,4 +1,4 @@ -$FreeBSD$ +$FreeBSD: head/tools/regression/pjdfstest/README 211354 2010-08-15 21:29:03Z pjd $ Few notes on how to use pjdfstest in short steps: @@ -19,4 +19,4 @@ Currently supported operating systems: FreeBSD, Solaris. Currently supported file system types: UFS, ZFS. -- -Pawel Jakub Dawidek +Pawel Jakub Dawidek diff --git a/tools/regression/pjdfstest/pjdfstest.c b/contrib/pjdfstest/pjdfstest.c similarity index 100% rename from tools/regression/pjdfstest/pjdfstest.c rename to contrib/pjdfstest/pjdfstest.c diff --git a/tools/regression/pjdfstest/tests/chflags/00.t b/contrib/pjdfstest/tests/chflags/00.t similarity index 97% rename from tools/regression/pjdfstest/tests/chflags/00.t rename to contrib/pjdfstest/tests/chflags/00.t index b233b8ea697c..4d7b4c9a3464 100644 --- a/tools/regression/pjdfstest/tests/chflags/00.t +++ b/contrib/pjdfstest/tests/chflags/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags changes flags" diff --git a/tools/regression/pjdfstest/tests/chflags/01.t b/contrib/pjdfstest/tests/chflags/01.t similarity index 80% rename from tools/regression/pjdfstest/tests/chflags/01.t rename to contrib/pjdfstest/tests/chflags/01.t index b71951bb71f0..62713fd0347a 100644 --- a/tools/regression/pjdfstest/tests/chflags/01.t +++ b/contrib/pjdfstest/tests/chflags/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="chflags returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/chflags/02.t b/contrib/pjdfstest/tests/chflags/02.t similarity index 86% rename from tools/regression/pjdfstest/tests/chflags/02.t rename to contrib/pjdfstest/tests/chflags/02.t index b64345b22ea9..d4a0b371b094 100644 --- a/tools/regression/pjdfstest/tests/chflags/02.t +++ b/contrib/pjdfstest/tests/chflags/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/chflags/03.t b/contrib/pjdfstest/tests/chflags/03.t similarity index 86% rename from tools/regression/pjdfstest/tests/chflags/03.t rename to contrib/pjdfstest/tests/chflags/03.t index 9552831b3846..87a62029509b 100644 --- a/tools/regression/pjdfstest/tests/chflags/03.t +++ b/contrib/pjdfstest/tests/chflags/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/chflags/04.t b/contrib/pjdfstest/tests/chflags/04.t similarity index 76% rename from tools/regression/pjdfstest/tests/chflags/04.t rename to contrib/pjdfstest/tests/chflags/04.t index 591ae69e130e..3d5aa3b42ba3 100644 --- a/tools/regression/pjdfstest/tests/chflags/04.t +++ b/contrib/pjdfstest/tests/chflags/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns ENOENT if the named file does not exist" diff --git a/tools/regression/pjdfstest/tests/chflags/05.t b/contrib/pjdfstest/tests/chflags/05.t similarity index 90% rename from tools/regression/pjdfstest/tests/chflags/05.t rename to contrib/pjdfstest/tests/chflags/05.t index 7409798f889e..cc3e04b3ec57 100644 --- a/tools/regression/pjdfstest/tests/chflags/05.t +++ b/contrib/pjdfstest/tests/chflags/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/chflags/06.t b/contrib/pjdfstest/tests/chflags/06.t similarity index 80% rename from tools/regression/pjdfstest/tests/chflags/06.t rename to contrib/pjdfstest/tests/chflags/06.t index ae5973e288b2..e4899eb7642e 100644 --- a/tools/regression/pjdfstest/tests/chflags/06.t +++ b/contrib/pjdfstest/tests/chflags/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/chflags/07.t b/contrib/pjdfstest/tests/chflags/07.t similarity index 91% rename from tools/regression/pjdfstest/tests/chflags/07.t rename to contrib/pjdfstest/tests/chflags/07.t index 5d898d849dd5..c2d0af2447b9 100644 --- a/tools/regression/pjdfstest/tests/chflags/07.t +++ b/contrib/pjdfstest/tests/chflags/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user" diff --git a/tools/regression/pjdfstest/tests/chflags/08.t b/contrib/pjdfstest/tests/chflags/08.t similarity index 93% rename from tools/regression/pjdfstest/tests/chflags/08.t rename to contrib/pjdfstest/tests/chflags/08.t index 18d593d035f5..62ed480feec0 100644 --- a/tools/regression/pjdfstest/tests/chflags/08.t +++ b/contrib/pjdfstest/tests/chflags/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user" diff --git a/tools/regression/pjdfstest/tests/chflags/09.t b/contrib/pjdfstest/tests/chflags/09.t similarity index 94% rename from tools/regression/pjdfstest/tests/chflags/09.t rename to contrib/pjdfstest/tests/chflags/09.t index e40d7a8e0793..e7bd5cc8d660 100644 --- a/tools/regression/pjdfstest/tests/chflags/09.t +++ b/contrib/pjdfstest/tests/chflags/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and securelevel is greater than 0" diff --git a/tools/regression/pjdfstest/tests/chflags/10.t b/contrib/pjdfstest/tests/chflags/10.t similarity index 92% rename from tools/regression/pjdfstest/tests/chflags/10.t rename to contrib/pjdfstest/tests/chflags/10.t index 55f0be6d68ef..11ce36b4d0ab 100644 --- a/tools/regression/pjdfstest/tests/chflags/10.t +++ b/contrib/pjdfstest/tests/chflags/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" diff --git a/tools/regression/pjdfstest/tests/chflags/11.t b/contrib/pjdfstest/tests/chflags/11.t similarity index 93% rename from tools/regression/pjdfstest/tests/chflags/11.t rename to contrib/pjdfstest/tests/chflags/11.t index 19af4115452e..33acca7f327a 100644 --- a/tools/regression/pjdfstest/tests/chflags/11.t +++ b/contrib/pjdfstest/tests/chflags/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EPERM if a user tries to set or remove the SF_SNAPSHOT flag" diff --git a/tools/regression/pjdfstest/tests/chflags/12.t b/contrib/pjdfstest/tests/chflags/12.t similarity index 84% rename from tools/regression/pjdfstest/tests/chflags/12.t rename to contrib/pjdfstest/tests/chflags/12.t index 950458e775c4..794139becf59 100644 --- a/tools/regression/pjdfstest/tests/chflags/12.t +++ b/contrib/pjdfstest/tests/chflags/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EROFS if the named file resides on a read-only file system" @@ -16,8 +16,8 @@ FreeBSD:UFS) n1=`namegen` expect 0 mkdir ${n0} 0755 - n=`mdconfig -a -n -t malloc -s 1m` - newfs /dev/md${n} >/dev/null + n=`mdconfig -a -n -t malloc -s 1m` || exit + newfs /dev/md${n} >/dev/null || exit mount /dev/md${n} ${n0} expect 0 create ${n0}/${n1} 0644 expect 0 chflags ${n0}/${n1} UF_IMMUTABLE @@ -34,7 +34,7 @@ FreeBSD:UFS) expect none stat ${n0}/${n1} flags expect 0 unlink ${n0}/${n1} umount /dev/md${n} - mdconfig -d -u ${n} + mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} ;; FreeBSD:ZFS) @@ -43,7 +43,7 @@ FreeBSD:ZFS) n0=`namegen` n1=`namegen` - n=`mdconfig -a -n -t malloc -s 128m` + n=`mdconfig -a -n -t malloc -s 128m` || exit zpool create ${n0} /dev/md${n} expect 0 create /${n0}/${n1} 0644 expect 0 chflags /${n0}/${n1} UF_NODUMP @@ -60,7 +60,7 @@ FreeBSD:ZFS) expect none stat /${n0}/${n1} flags expect 0 unlink /${n0}/${n1} zpool destroy ${n0} - mdconfig -d -u ${n} + mdconfig -d -u ${n} || exit ;; *) quick_exit diff --git a/tools/regression/pjdfstest/tests/chflags/13.t b/contrib/pjdfstest/tests/chflags/13.t similarity index 72% rename from tools/regression/pjdfstest/tests/chflags/13.t rename to contrib/pjdfstest/tests/chflags/13.t index 247246a6cc1d..981122c8b3be 100644 --- a/tools/regression/pjdfstest/tests/chflags/13.t +++ b/contrib/pjdfstest/tests/chflags/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="chflags returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/chmod/00.t b/contrib/pjdfstest/tests/chmod/00.t similarity index 97% rename from tools/regression/pjdfstest/tests/chmod/00.t rename to contrib/pjdfstest/tests/chmod/00.t index 311a8c8c56f8..d68d0cf4e652 100644 --- a/tools/regression/pjdfstest/tests/chmod/00.t +++ b/contrib/pjdfstest/tests/chmod/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod changes permission" diff --git a/tools/regression/pjdfstest/tests/chmod/01.t b/contrib/pjdfstest/tests/chmod/01.t similarity index 79% rename from tools/regression/pjdfstest/tests/chmod/01.t rename to contrib/pjdfstest/tests/chmod/01.t index 49164e71585e..85802fca2439 100644 --- a/tools/regression/pjdfstest/tests/chmod/01.t +++ b/contrib/pjdfstest/tests/chmod/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="chmod returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/chmod/02.t b/contrib/pjdfstest/tests/chmod/02.t similarity index 83% rename from tools/regression/pjdfstest/tests/chmod/02.t rename to contrib/pjdfstest/tests/chmod/02.t index ece2b6c23cb6..0cadec29bf0c 100644 --- a/tools/regression/pjdfstest/tests/chmod/02.t +++ b/contrib/pjdfstest/tests/chmod/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/chmod/03.t b/contrib/pjdfstest/tests/chmod/03.t similarity index 84% rename from tools/regression/pjdfstest/tests/chmod/03.t rename to contrib/pjdfstest/tests/chmod/03.t index 30261d53e38d..fa4580fbcfeb 100644 --- a/tools/regression/pjdfstest/tests/chmod/03.t +++ b/contrib/pjdfstest/tests/chmod/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/chmod/04.t b/contrib/pjdfstest/tests/chmod/04.t similarity index 85% rename from tools/regression/pjdfstest/tests/chmod/04.t rename to contrib/pjdfstest/tests/chmod/04.t index a125ae2ed9cb..9386c9a3e6ba 100644 --- a/tools/regression/pjdfstest/tests/chmod/04.t +++ b/contrib/pjdfstest/tests/chmod/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns ENOENT if the named file does not exist" diff --git a/tools/regression/pjdfstest/tests/chmod/05.t b/contrib/pjdfstest/tests/chmod/05.t similarity index 91% rename from tools/regression/pjdfstest/tests/chmod/05.t rename to contrib/pjdfstest/tests/chmod/05.t index c06895a86377..5648e46eef8b 100644 --- a/tools/regression/pjdfstest/tests/chmod/05.t +++ b/contrib/pjdfstest/tests/chmod/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/chmod/06.t b/contrib/pjdfstest/tests/chmod/06.t similarity index 85% rename from tools/regression/pjdfstest/tests/chmod/06.t rename to contrib/pjdfstest/tests/chmod/06.t index c06fe2bb59f6..d44b3cb1ea52 100644 --- a/tools/regression/pjdfstest/tests/chmod/06.t +++ b/contrib/pjdfstest/tests/chmod/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/06.t 211474 2010-08-18 22:06:43Z pjd $ desc="chmod returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/chmod/07.t b/contrib/pjdfstest/tests/chmod/07.t similarity index 94% rename from tools/regression/pjdfstest/tests/chmod/07.t rename to contrib/pjdfstest/tests/chmod/07.t index 519b7fdddbc1..012e59a97bb5 100644 --- a/tools/regression/pjdfstest/tests/chmod/07.t +++ b/contrib/pjdfstest/tests/chmod/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user" diff --git a/tools/regression/pjdfstest/tests/chmod/08.t b/contrib/pjdfstest/tests/chmod/08.t similarity index 96% rename from tools/regression/pjdfstest/tests/chmod/08.t rename to contrib/pjdfstest/tests/chmod/08.t index bf2713468694..5b37569a82d7 100644 --- a/tools/regression/pjdfstest/tests/chmod/08.t +++ b/contrib/pjdfstest/tests/chmod/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns EPERM if the named file has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/chmod/09.t b/contrib/pjdfstest/tests/chmod/09.t similarity index 76% rename from tools/regression/pjdfstest/tests/chmod/09.t rename to contrib/pjdfstest/tests/chmod/09.t index 18e4cdc4e23c..f4b911e2f15a 100644 --- a/tools/regression/pjdfstest/tests/chmod/09.t +++ b/contrib/pjdfstest/tests/chmod/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns EROFS if the named file resides on a read-only file system" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 expect 0 chmod ${n0}/${n1} 0640 expect 0640 stat ${n0}/${n1} mode @@ -33,5 +33,5 @@ expect 0 lchmod ${n0}/${n1} 0640 expect 0640 stat ${n0}/${n1} mode expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/chmod/10.t b/contrib/pjdfstest/tests/chmod/10.t similarity index 79% rename from tools/regression/pjdfstest/tests/chmod/10.t rename to contrib/pjdfstest/tests/chmod/10.t index b75b712ba8ca..1153429ac1dc 100644 --- a/tools/regression/pjdfstest/tests/chmod/10.t +++ b/contrib/pjdfstest/tests/chmod/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/chmod/11.t b/contrib/pjdfstest/tests/chmod/11.t similarity index 96% rename from tools/regression/pjdfstest/tests/chmod/11.t rename to contrib/pjdfstest/tests/chmod/11.t index 882989681677..94c5e5f4f319 100644 --- a/tools/regression/pjdfstest/tests/chmod/11.t +++ b/contrib/pjdfstest/tests/chmod/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="chmod returns EFTYPE if the effective user ID is not the super-user, the mode includes the sticky bit (S_ISVTX), and path does not refer to a directory" diff --git a/tools/regression/pjdfstest/tests/chmod/12.t b/contrib/pjdfstest/tests/chmod/12.t similarity index 90% rename from tools/regression/pjdfstest/tests/chmod/12.t rename to contrib/pjdfstest/tests/chmod/12.t index affa8de0fbeb..b7f7d67997fb 100644 --- a/tools/regression/pjdfstest/tests/chmod/12.t +++ b/contrib/pjdfstest/tests/chmod/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/12.t 219463 2011-03-10 20:59:02Z pjd $ desc="verify SUID/SGID bit behaviour" diff --git a/contrib/pjdfstest/tests/chmod/foo b/contrib/pjdfstest/tests/chmod/foo new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/tools/regression/pjdfstest/tests/chown/00.t b/contrib/pjdfstest/tests/chown/00.t similarity index 99% rename from tools/regression/pjdfstest/tests/chown/00.t rename to contrib/pjdfstest/tests/chown/00.t index a3ccbac6db25..5c6be97d66dd 100644 --- a/tools/regression/pjdfstest/tests/chown/00.t +++ b/contrib/pjdfstest/tests/chown/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/00.t 228975 2011-12-30 00:04:11Z uqs $ desc="chown changes ownership" diff --git a/tools/regression/pjdfstest/tests/chown/01.t b/contrib/pjdfstest/tests/chown/01.t similarity index 82% rename from tools/regression/pjdfstest/tests/chown/01.t rename to contrib/pjdfstest/tests/chown/01.t index 249ce4de4c93..1813394aee83 100644 --- a/tools/regression/pjdfstest/tests/chown/01.t +++ b/contrib/pjdfstest/tests/chown/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="chown returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/chown/02.t b/contrib/pjdfstest/tests/chown/02.t similarity index 84% rename from tools/regression/pjdfstest/tests/chown/02.t rename to contrib/pjdfstest/tests/chown/02.t index 2225f64dcd17..e110db8261ba 100644 --- a/tools/regression/pjdfstest/tests/chown/02.t +++ b/contrib/pjdfstest/tests/chown/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="chown returns ENAMETOOLONG if a component of a pathname exceeded ${NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/chown/03.t b/contrib/pjdfstest/tests/chown/03.t similarity index 85% rename from tools/regression/pjdfstest/tests/chown/03.t rename to contrib/pjdfstest/tests/chown/03.t index 6bb43a292ff5..031a878f3524 100644 --- a/tools/regression/pjdfstest/tests/chown/03.t +++ b/contrib/pjdfstest/tests/chown/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="chown returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/chown/04.t b/contrib/pjdfstest/tests/chown/04.t similarity index 84% rename from tools/regression/pjdfstest/tests/chown/04.t rename to contrib/pjdfstest/tests/chown/04.t index e66d936ed5c0..d6eac198ed1e 100644 --- a/tools/regression/pjdfstest/tests/chown/04.t +++ b/contrib/pjdfstest/tests/chown/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/04.t 211410 2010-08-17 06:08:09Z pjd $ desc="chown returns ENOENT if the named file does not exist" diff --git a/tools/regression/pjdfstest/tests/chown/05.t b/contrib/pjdfstest/tests/chown/05.t similarity index 91% rename from tools/regression/pjdfstest/tests/chown/05.t rename to contrib/pjdfstest/tests/chown/05.t index ec7cd5ccecec..5a27a9ca90fc 100644 --- a/tools/regression/pjdfstest/tests/chown/05.t +++ b/contrib/pjdfstest/tests/chown/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/05.t 211410 2010-08-17 06:08:09Z pjd $ desc="chown returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/chown/06.t b/contrib/pjdfstest/tests/chown/06.t similarity index 84% rename from tools/regression/pjdfstest/tests/chown/06.t rename to contrib/pjdfstest/tests/chown/06.t index 39ccac68e879..a7ac349c02f8 100644 --- a/tools/regression/pjdfstest/tests/chown/06.t +++ b/contrib/pjdfstest/tests/chown/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/06.t 211410 2010-08-17 06:08:09Z pjd $ desc="chown returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/chown/07.t b/contrib/pjdfstest/tests/chown/07.t similarity index 94% rename from tools/regression/pjdfstest/tests/chown/07.t rename to contrib/pjdfstest/tests/chown/07.t index 7f73cbe0ec09..f188080d05ec 100644 --- a/tools/regression/pjdfstest/tests/chown/07.t +++ b/contrib/pjdfstest/tests/chown/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/07.t 211410 2010-08-17 06:08:09Z pjd $ desc="chown returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user and the process is not an owner of the file" diff --git a/tools/regression/pjdfstest/tests/chown/08.t b/contrib/pjdfstest/tests/chown/08.t similarity index 95% rename from tools/regression/pjdfstest/tests/chown/08.t rename to contrib/pjdfstest/tests/chown/08.t index 9bff354e673f..a98f873ff91b 100644 --- a/tools/regression/pjdfstest/tests/chown/08.t +++ b/contrib/pjdfstest/tests/chown/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="chown returns EPERM if the named file has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/chown/09.t b/contrib/pjdfstest/tests/chown/09.t similarity index 73% rename from tools/regression/pjdfstest/tests/chown/09.t rename to contrib/pjdfstest/tests/chown/09.t index cc14328036f6..a99751e175c8 100644 --- a/tools/regression/pjdfstest/tests/chown/09.t +++ b/contrib/pjdfstest/tests/chown/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="chown returns EROFS if the named file resides on a read-only file system" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 expect 0 chown ${n0}/${n1} 65534 65534 expect 65534,65534 stat ${n0}/${n1} uid,gid @@ -28,5 +28,5 @@ expect 0 chown ${n0}/${n1} 65533 65533 expect 65533,65533 stat ${n0}/${n1} uid,gid expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/chown/10.t b/contrib/pjdfstest/tests/chown/10.t similarity index 77% rename from tools/regression/pjdfstest/tests/chown/10.t rename to contrib/pjdfstest/tests/chown/10.t index 961a5be27a78..e791008ee54e 100644 --- a/tools/regression/pjdfstest/tests/chown/10.t +++ b/contrib/pjdfstest/tests/chown/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/10.t 211410 2010-08-17 06:08:09Z pjd $ desc="chown returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/conf b/contrib/pjdfstest/tests/conf similarity index 90% rename from tools/regression/pjdfstest/tests/conf rename to contrib/pjdfstest/tests/conf index f914941482a8..adb6cd6fb9b5 100644 --- a/tools/regression/pjdfstest/tests/conf +++ b/contrib/pjdfstest/tests/conf @@ -1,4 +1,4 @@ -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/conf 211354 2010-08-15 21:29:03Z pjd $ # pjdfstest configuration file # Supported operating systems: FreeBSD, Darwin, SunOS, Linux diff --git a/tools/regression/pjdfstest/tests/ftruncate/00.t b/contrib/pjdfstest/tests/ftruncate/00.t similarity index 92% rename from tools/regression/pjdfstest/tests/ftruncate/00.t rename to contrib/pjdfstest/tests/ftruncate/00.t index 9028a296b5dd..0f253017f8f3 100644 --- a/tools/regression/pjdfstest/tests/ftruncate/00.t +++ b/contrib/pjdfstest/tests/ftruncate/00.t @@ -1,12 +1,12 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/ftruncate/00.t 219439 2011-03-09 23:11:30Z pjd $ desc="ftruncate descrease/increase file size" dir=`dirname $0` . ${dir}/../misc.sh -echo "1..21" +echo "1..26" n0=`namegen` n1=`namegen` diff --git a/tools/regression/pjdfstest/tests/truncate/01.t b/contrib/pjdfstest/tests/ftruncate/01.t similarity index 76% rename from tools/regression/pjdfstest/tests/truncate/01.t rename to contrib/pjdfstest/tests/ftruncate/01.t index ac504a1f5124..a8e95ac60181 100644 --- a/tools/regression/pjdfstest/tests/truncate/01.t +++ b/contrib/pjdfstest/tests/ftruncate/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/01.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/truncate/02.t b/contrib/pjdfstest/tests/ftruncate/02.t similarity index 77% rename from tools/regression/pjdfstest/tests/truncate/02.t rename to contrib/pjdfstest/tests/ftruncate/02.t index 3f3590f38c0e..83de38d3244f 100644 --- a/tools/regression/pjdfstest/tests/truncate/02.t +++ b/contrib/pjdfstest/tests/ftruncate/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/truncate/03.t b/contrib/pjdfstest/tests/ftruncate/03.t similarity index 79% rename from tools/regression/pjdfstest/tests/truncate/03.t rename to contrib/pjdfstest/tests/ftruncate/03.t index 0ed60a917474..41e98625ba4f 100644 --- a/tools/regression/pjdfstest/tests/truncate/03.t +++ b/contrib/pjdfstest/tests/ftruncate/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/truncate/04.t b/contrib/pjdfstest/tests/ftruncate/04.t similarity index 74% rename from tools/regression/pjdfstest/tests/truncate/04.t rename to contrib/pjdfstest/tests/ftruncate/04.t index 14f513c84795..cd1cfc66b2b0 100644 --- a/tools/regression/pjdfstest/tests/truncate/04.t +++ b/contrib/pjdfstest/tests/ftruncate/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns ENOENT if the named file does not exist" diff --git a/tools/regression/pjdfstest/tests/truncate/05.t b/contrib/pjdfstest/tests/ftruncate/05.t similarity index 89% rename from tools/regression/pjdfstest/tests/truncate/05.t rename to contrib/pjdfstest/tests/ftruncate/05.t index 9aa65c84afcb..f12881581bce 100644 --- a/tools/regression/pjdfstest/tests/truncate/05.t +++ b/contrib/pjdfstest/tests/ftruncate/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/truncate/06.t b/contrib/pjdfstest/tests/ftruncate/06.t similarity index 82% rename from tools/regression/pjdfstest/tests/truncate/06.t rename to contrib/pjdfstest/tests/ftruncate/06.t index 8e0ca5bd55c5..1ce516fa74a6 100644 --- a/tools/regression/pjdfstest/tests/truncate/06.t +++ b/contrib/pjdfstest/tests/ftruncate/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EACCES if the named file is not writable by the user" diff --git a/tools/regression/pjdfstest/tests/truncate/07.t b/contrib/pjdfstest/tests/ftruncate/07.t similarity index 78% rename from tools/regression/pjdfstest/tests/truncate/07.t rename to contrib/pjdfstest/tests/ftruncate/07.t index 60b8b907bf46..44f87e7ea859 100644 --- a/tools/regression/pjdfstest/tests/truncate/07.t +++ b/contrib/pjdfstest/tests/ftruncate/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/truncate/08.t b/contrib/pjdfstest/tests/ftruncate/08.t similarity index 94% rename from tools/regression/pjdfstest/tests/truncate/08.t rename to contrib/pjdfstest/tests/ftruncate/08.t index 75d6679e915e..6f205ef965f2 100644 --- a/tools/regression/pjdfstest/tests/truncate/08.t +++ b/contrib/pjdfstest/tests/ftruncate/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EPERM if the named file has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/truncate/09.t b/contrib/pjdfstest/tests/ftruncate/09.t similarity index 69% rename from tools/regression/pjdfstest/tests/truncate/09.t rename to contrib/pjdfstest/tests/ftruncate/09.t index 1d95c7fe918c..d7e082ddbe0e 100644 --- a/tools/regression/pjdfstest/tests/truncate/09.t +++ b/contrib/pjdfstest/tests/ftruncate/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EISDIR if the named file is a directory" diff --git a/tools/regression/pjdfstest/tests/truncate/10.t b/contrib/pjdfstest/tests/ftruncate/10.t similarity index 71% rename from tools/regression/pjdfstest/tests/truncate/10.t rename to contrib/pjdfstest/tests/ftruncate/10.t index 6fcd129573a4..ced3583ec21d 100644 --- a/tools/regression/pjdfstest/tests/truncate/10.t +++ b/contrib/pjdfstest/tests/ftruncate/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EROFS if the named file resides on a read-only file system" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 expect 0 truncate ${n0}/${n1} 123 expect 123 stat ${n0}/${n1} size @@ -28,5 +28,5 @@ expect 0 truncate ${n0}/${n1} 1234 expect 1234 stat ${n0}/${n1} size expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/truncate/11.t b/contrib/pjdfstest/tests/ftruncate/11.t similarity index 76% rename from tools/regression/pjdfstest/tests/truncate/11.t rename to contrib/pjdfstest/tests/ftruncate/11.t index 255fd19d5fca..b00d7b89c16d 100644 --- a/tools/regression/pjdfstest/tests/truncate/11.t +++ b/contrib/pjdfstest/tests/ftruncate/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns ETXTBSY the file is a pure procedure (shared text) file that is being executed" diff --git a/tools/regression/pjdfstest/tests/truncate/12.t b/contrib/pjdfstest/tests/ftruncate/12.t similarity index 82% rename from tools/regression/pjdfstest/tests/truncate/12.t rename to contrib/pjdfstest/tests/ftruncate/12.t index cf6a49743e49..1825456a7b13 100644 --- a/tools/regression/pjdfstest/tests/truncate/12.t +++ b/contrib/pjdfstest/tests/ftruncate/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EFBIG or EINVAL if the length argument was greater than the maximum file size" diff --git a/contrib/pjdfstest/tests/ftruncate/13.t b/contrib/pjdfstest/tests/ftruncate/13.t new file mode 100644 index 000000000000..28307ae40af7 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/13.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="ftruncate returns EINVAL if the length argument was less than 0" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EINVAL -- open ${n0} O_RDWR : ftruncate 0 -1 +expect EINVAL -- open ${n0} O_WRONLY : ftruncate 0 -999999 +expect 0 unlink ${n0} diff --git a/tools/regression/pjdfstest/tests/truncate/14.t b/contrib/pjdfstest/tests/ftruncate/14.t similarity index 70% rename from tools/regression/pjdfstest/tests/truncate/14.t rename to contrib/pjdfstest/tests/ftruncate/14.t index 53dca715237e..a238771264f9 100644 --- a/tools/regression/pjdfstest/tests/truncate/14.t +++ b/contrib/pjdfstest/tests/ftruncate/14.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/14.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/granular/00.t b/contrib/pjdfstest/tests/granular/00.t similarity index 97% rename from tools/regression/pjdfstest/tests/granular/00.t rename to contrib/pjdfstest/tests/granular/00.t index 4e0426092b42..629f66e419ac 100644 --- a/tools/regression/pjdfstest/tests/granular/00.t +++ b/contrib/pjdfstest/tests/granular/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="NFSv4 granular permissions checking - WRITE_DATA vs APPEND_DATA on directories" diff --git a/tools/regression/pjdfstest/tests/granular/01.t b/contrib/pjdfstest/tests/granular/01.t similarity index 90% rename from tools/regression/pjdfstest/tests/granular/01.t rename to contrib/pjdfstest/tests/granular/01.t index 1c6b3f3429fe..f6658cc5f840 100644 --- a/tools/regression/pjdfstest/tests/granular/01.t +++ b/contrib/pjdfstest/tests/granular/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/01.t 211352 2010-08-15 21:24:17Z pjd $ desc="NFSv4 granular permissions checking - ACL_READ_ATTRIBUTES and ACL_WRITE_ATTRIBUTES" diff --git a/tools/regression/pjdfstest/tests/granular/02.t b/contrib/pjdfstest/tests/granular/02.t similarity index 98% rename from tools/regression/pjdfstest/tests/granular/02.t rename to contrib/pjdfstest/tests/granular/02.t index 4a33dad99c2c..32a318cc0d90 100644 --- a/tools/regression/pjdfstest/tests/granular/02.t +++ b/contrib/pjdfstest/tests/granular/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="NFSv4 granular permissions checking - ACL_READ_ACL and ACL_WRITE_ACL" diff --git a/tools/regression/pjdfstest/tests/granular/03.t b/contrib/pjdfstest/tests/granular/03.t similarity index 97% rename from tools/regression/pjdfstest/tests/granular/03.t rename to contrib/pjdfstest/tests/granular/03.t index 195065f9c268..3b825ccef3a3 100644 --- a/tools/regression/pjdfstest/tests/granular/03.t +++ b/contrib/pjdfstest/tests/granular/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD" diff --git a/tools/regression/pjdfstest/tests/granular/04.t b/contrib/pjdfstest/tests/granular/04.t similarity index 96% rename from tools/regression/pjdfstest/tests/granular/04.t rename to contrib/pjdfstest/tests/granular/04.t index 9c0841ded9b7..a06b0d605ebd 100644 --- a/tools/regression/pjdfstest/tests/granular/04.t +++ b/contrib/pjdfstest/tests/granular/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="NFSv4 granular permissions checking - ACL_WRITE_OWNER" diff --git a/tools/regression/pjdfstest/tests/granular/05.t b/contrib/pjdfstest/tests/granular/05.t similarity index 98% rename from tools/regression/pjdfstest/tests/granular/05.t rename to contrib/pjdfstest/tests/granular/05.t index 8abf3578fc25..c42f51a90987 100644 --- a/tools/regression/pjdfstest/tests/granular/05.t +++ b/contrib/pjdfstest/tests/granular/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD with directories" diff --git a/tools/regression/pjdfstest/tests/link/00.t b/contrib/pjdfstest/tests/link/00.t similarity index 96% rename from tools/regression/pjdfstest/tests/link/00.t rename to contrib/pjdfstest/tests/link/00.t index b003d7867739..1bcb32ad17ac 100644 --- a/tools/regression/pjdfstest/tests/link/00.t +++ b/contrib/pjdfstest/tests/link/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="link creates hardlinks" diff --git a/tools/regression/pjdfstest/tests/link/01.t b/contrib/pjdfstest/tests/link/01.t similarity index 84% rename from tools/regression/pjdfstest/tests/link/01.t rename to contrib/pjdfstest/tests/link/01.t index 94009010d4d1..fe05aeba7119 100644 --- a/tools/regression/pjdfstest/tests/link/01.t +++ b/contrib/pjdfstest/tests/link/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="link returns ENOTDIR if a component of either path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/link/02.t b/contrib/pjdfstest/tests/link/02.t similarity index 83% rename from tools/regression/pjdfstest/tests/link/02.t rename to contrib/pjdfstest/tests/link/02.t index 32f78c451668..ca3e092edf99 100644 --- a/tools/regression/pjdfstest/tests/link/02.t +++ b/contrib/pjdfstest/tests/link/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns ENAMETOOLONG if a component of either pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/link/03.t b/contrib/pjdfstest/tests/link/03.t similarity index 86% rename from tools/regression/pjdfstest/tests/link/03.t rename to contrib/pjdfstest/tests/link/03.t index 0ad79c3d71e1..22f8e55e0cb3 100644 --- a/tools/regression/pjdfstest/tests/link/03.t +++ b/contrib/pjdfstest/tests/link/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/link/04.t b/contrib/pjdfstest/tests/link/04.t similarity index 79% rename from tools/regression/pjdfstest/tests/link/04.t rename to contrib/pjdfstest/tests/link/04.t index d27beef1760d..bb095396005e 100644 --- a/tools/regression/pjdfstest/tests/link/04.t +++ b/contrib/pjdfstest/tests/link/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns ENOENT if a component of either path prefix does not exist" diff --git a/tools/regression/pjdfstest/tests/link/05.t b/contrib/pjdfstest/tests/link/05.t similarity index 68% rename from tools/regression/pjdfstest/tests/link/05.t rename to contrib/pjdfstest/tests/link/05.t index ee63ef666056..c6f55fa957dd 100644 --- a/tools/regression/pjdfstest/tests/link/05.t +++ b/contrib/pjdfstest/tests/link/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EMLINK if the link count of the file named by name1 would exceed 32767" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs -i 1 /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs -i 1 /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 i=1 while :; do @@ -32,5 +32,5 @@ test_check $i -eq 32767 expect EMLINK link ${n0}/${n1} ${n0}/${n2} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/link/06.t b/contrib/pjdfstest/tests/link/06.t similarity index 90% rename from tools/regression/pjdfstest/tests/link/06.t rename to contrib/pjdfstest/tests/link/06.t index 3ce091918765..73ab01e9ae15 100644 --- a/tools/regression/pjdfstest/tests/link/06.t +++ b/contrib/pjdfstest/tests/link/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EACCES when a component of either path prefix denies search permission" diff --git a/tools/regression/pjdfstest/tests/link/07.t b/contrib/pjdfstest/tests/link/07.t similarity index 90% rename from tools/regression/pjdfstest/tests/link/07.t rename to contrib/pjdfstest/tests/link/07.t index f9d35e76f9ae..68495dd7c0b8 100644 --- a/tools/regression/pjdfstest/tests/link/07.t +++ b/contrib/pjdfstest/tests/link/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EACCES when the requested link requires writing in a directory with a mode that denies write permission" diff --git a/tools/regression/pjdfstest/tests/link/08.t b/contrib/pjdfstest/tests/link/08.t similarity index 84% rename from tools/regression/pjdfstest/tests/link/08.t rename to contrib/pjdfstest/tests/link/08.t index f9d9445db5f0..f4599d50f01b 100644 --- a/tools/regression/pjdfstest/tests/link/08.t +++ b/contrib/pjdfstest/tests/link/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns ELOOP if too many symbolic links were encountered in translating one of the pathnames" diff --git a/tools/regression/pjdfstest/tests/link/09.t b/contrib/pjdfstest/tests/link/09.t similarity index 74% rename from tools/regression/pjdfstest/tests/link/09.t rename to contrib/pjdfstest/tests/link/09.t index 224395f42187..5f89655d3610 100644 --- a/tools/regression/pjdfstest/tests/link/09.t +++ b/contrib/pjdfstest/tests/link/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns ENOENT if the source file does not exist" diff --git a/tools/regression/pjdfstest/tests/link/10.t b/contrib/pjdfstest/tests/link/10.t similarity index 81% rename from tools/regression/pjdfstest/tests/link/10.t rename to contrib/pjdfstest/tests/link/10.t index 725a020d7a2b..03ebbd25ffdb 100644 --- a/tools/regression/pjdfstest/tests/link/10.t +++ b/contrib/pjdfstest/tests/link/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/10.t 211474 2010-08-18 22:06:43Z pjd $ desc="link returns EEXIST if the destination file does exist" diff --git a/tools/regression/pjdfstest/tests/link/11.t b/contrib/pjdfstest/tests/link/11.t similarity index 87% rename from tools/regression/pjdfstest/tests/link/11.t rename to contrib/pjdfstest/tests/link/11.t index cf31c9ee31fd..260342cd1d31 100644 --- a/tools/regression/pjdfstest/tests/link/11.t +++ b/contrib/pjdfstest/tests/link/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EPERM if the source file is a directory" diff --git a/tools/regression/pjdfstest/tests/link/12.t b/contrib/pjdfstest/tests/link/12.t similarity index 95% rename from tools/regression/pjdfstest/tests/link/12.t rename to contrib/pjdfstest/tests/link/12.t index 8bf9510f7c7a..a5408b656418 100644 --- a/tools/regression/pjdfstest/tests/link/12.t +++ b/contrib/pjdfstest/tests/link/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EPERM if the source file has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/link/13.t b/contrib/pjdfstest/tests/link/13.t similarity index 95% rename from tools/regression/pjdfstest/tests/link/13.t rename to contrib/pjdfstest/tests/link/13.t index 9b35a4b430e5..2da8621f23cc 100644 --- a/tools/regression/pjdfstest/tests/link/13.t +++ b/contrib/pjdfstest/tests/link/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EPERM if the parent directory of the destination file has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/link/14.t b/contrib/pjdfstest/tests/link/14.t similarity index 67% rename from tools/regression/pjdfstest/tests/link/14.t rename to contrib/pjdfstest/tests/link/14.t index 4eb5a5629a53..aa587e5a6d67 100644 --- a/tools/regression/pjdfstest/tests/link/14.t +++ b/contrib/pjdfstest/tests/link/14.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/14.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EXDEV if the source and the destination files are on different file systems" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 expect EXDEV link ${n0}/${n1} ${n2} expect 0 unlink ${n0}/${n1} @@ -25,5 +25,5 @@ expect 0 create ${n1} 0644 expect EXDEV link ${n1} ${n0}/${n2} expect 0 unlink ${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/link/15.t b/contrib/pjdfstest/tests/link/15.t similarity index 71% rename from tools/regression/pjdfstest/tests/link/15.t rename to contrib/pjdfstest/tests/link/15.t index eea184443841..a740126a0d80 100644 --- a/tools/regression/pjdfstest/tests/link/15.t +++ b/contrib/pjdfstest/tests/link/15.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/15.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns ENOSPC if the directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 256k` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 i=0 while :; do @@ -29,5 +29,5 @@ while :; do done expect ENOSPC link ${n0}/${n1} ${n0}/${n2} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/link/16.t b/contrib/pjdfstest/tests/link/16.t similarity index 71% rename from tools/regression/pjdfstest/tests/link/16.t rename to contrib/pjdfstest/tests/link/16.t index df04521eafd4..2d67f30c2a55 100644 --- a/tools/regression/pjdfstest/tests/link/16.t +++ b/contrib/pjdfstest/tests/link/16.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/16.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EROFS if the requested link requires writing in a directory on a read-only file system" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 expect 0 link ${n0}/${n1} ${n0}/${n2} @@ -30,5 +30,5 @@ expect 0 unlink ${n0}/${n2} expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/link/17.t b/contrib/pjdfstest/tests/link/17.t similarity index 82% rename from tools/regression/pjdfstest/tests/link/17.t rename to contrib/pjdfstest/tests/link/17.t index cb56128642bc..9b7e6fc68366 100644 --- a/tools/regression/pjdfstest/tests/link/17.t +++ b/contrib/pjdfstest/tests/link/17.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/17.t 211352 2010-08-15 21:24:17Z pjd $ desc="link returns EFAULT if one of the pathnames specified is outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/misc.sh b/contrib/pjdfstest/tests/misc.sh old mode 100644 new mode 100755 similarity index 100% rename from tools/regression/pjdfstest/tests/misc.sh rename to contrib/pjdfstest/tests/misc.sh diff --git a/tools/regression/pjdfstest/tests/mkdir/00.t b/contrib/pjdfstest/tests/mkdir/00.t similarity index 95% rename from tools/regression/pjdfstest/tests/mkdir/00.t rename to contrib/pjdfstest/tests/mkdir/00.t index d640de9b1a2d..fa1cbc126ebe 100644 --- a/tools/regression/pjdfstest/tests/mkdir/00.t +++ b/contrib/pjdfstest/tests/mkdir/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir creates directories" diff --git a/tools/regression/pjdfstest/tests/mkdir/01.t b/contrib/pjdfstest/tests/mkdir/01.t similarity index 79% rename from tools/regression/pjdfstest/tests/mkdir/01.t rename to contrib/pjdfstest/tests/mkdir/01.t index c1de087079cd..c33ce1fe9a09 100644 --- a/tools/regression/pjdfstest/tests/mkdir/01.t +++ b/contrib/pjdfstest/tests/mkdir/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="mkdir returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/mkdir/02.t b/contrib/pjdfstest/tests/mkdir/02.t similarity index 74% rename from tools/regression/pjdfstest/tests/mkdir/02.t rename to contrib/pjdfstest/tests/mkdir/02.t index edb103d33517..e877f20f4c10 100644 --- a/tools/regression/pjdfstest/tests/mkdir/02.t +++ b/contrib/pjdfstest/tests/mkdir/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/mkdir/03.t b/contrib/pjdfstest/tests/mkdir/03.t similarity index 76% rename from tools/regression/pjdfstest/tests/mkdir/03.t rename to contrib/pjdfstest/tests/mkdir/03.t index aa3b44c5446e..57ddd20a8627 100644 --- a/tools/regression/pjdfstest/tests/mkdir/03.t +++ b/contrib/pjdfstest/tests/mkdir/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/mkdir/04.t b/contrib/pjdfstest/tests/mkdir/04.t similarity index 72% rename from tools/regression/pjdfstest/tests/mkdir/04.t rename to contrib/pjdfstest/tests/mkdir/04.t index cd6581964155..0917ef15516d 100644 --- a/tools/regression/pjdfstest/tests/mkdir/04.t +++ b/contrib/pjdfstest/tests/mkdir/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns ENOENT if a component of the path prefix does not exist" diff --git a/tools/regression/pjdfstest/tests/mkdir/05.t b/contrib/pjdfstest/tests/mkdir/05.t similarity index 87% rename from tools/regression/pjdfstest/tests/mkdir/05.t rename to contrib/pjdfstest/tests/mkdir/05.t index 7e97d9bc6ed6..de351ca37ca7 100644 --- a/tools/regression/pjdfstest/tests/mkdir/05.t +++ b/contrib/pjdfstest/tests/mkdir/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/mkdir/06.t b/contrib/pjdfstest/tests/mkdir/06.t similarity index 87% rename from tools/regression/pjdfstest/tests/mkdir/06.t rename to contrib/pjdfstest/tests/mkdir/06.t index 79aa5395615a..2d2b8c22234b 100644 --- a/tools/regression/pjdfstest/tests/mkdir/06.t +++ b/contrib/pjdfstest/tests/mkdir/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns EACCES when write permission is denied on the parent directory of the directory to be created" diff --git a/tools/regression/pjdfstest/tests/mkdir/07.t b/contrib/pjdfstest/tests/mkdir/07.t similarity index 79% rename from tools/regression/pjdfstest/tests/mkdir/07.t rename to contrib/pjdfstest/tests/mkdir/07.t index dbb00df16a87..72ac2b69499f 100644 --- a/tools/regression/pjdfstest/tests/mkdir/07.t +++ b/contrib/pjdfstest/tests/mkdir/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/mkdir/08.t b/contrib/pjdfstest/tests/mkdir/08.t similarity index 93% rename from tools/regression/pjdfstest/tests/mkdir/08.t rename to contrib/pjdfstest/tests/mkdir/08.t index ed6d92eb8cb2..366f223a8074 100644 --- a/tools/regression/pjdfstest/tests/mkdir/08.t +++ b/contrib/pjdfstest/tests/mkdir/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns EPERM if the parent directory of the directory to be created has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/mkdir/09.t b/contrib/pjdfstest/tests/mkdir/09.t similarity index 67% rename from tools/regression/pjdfstest/tests/mkdir/09.t rename to contrib/pjdfstest/tests/mkdir/09.t index ce4bc9d754e1..2035b31fbbf4 100644 --- a/tools/regression/pjdfstest/tests/mkdir/09.t +++ b/contrib/pjdfstest/tests/mkdir/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns EROFS if the named file resides on a read-only file system" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 mkdir ${n0}/${n1} 0755 expect 0 rmdir ${n0}/${n1} mount -ur /dev/md${n} @@ -25,5 +25,5 @@ mount -uw /dev/md${n} expect 0 mkdir ${n0}/${n1} 0755 expect 0 rmdir ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/mkdir/10.t b/contrib/pjdfstest/tests/mkdir/10.t similarity index 78% rename from tools/regression/pjdfstest/tests/mkdir/10.t rename to contrib/pjdfstest/tests/mkdir/10.t index f64b8fddfd38..732dcb882562 100644 --- a/tools/regression/pjdfstest/tests/mkdir/10.t +++ b/contrib/pjdfstest/tests/mkdir/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns EEXIST if the named file exists" diff --git a/tools/regression/pjdfstest/tests/mkdir/11.t b/contrib/pjdfstest/tests/mkdir/11.t similarity index 66% rename from tools/regression/pjdfstest/tests/mkdir/11.t rename to contrib/pjdfstest/tests/mkdir/11.t index 3943e61f7ddc..a0c905545c4a 100644 --- a/tools/regression/pjdfstest/tests/mkdir/11.t +++ b/contrib/pjdfstest/tests/mkdir/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns ENOSPC if there are no free inodes on the file system on which the directory is being created" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 256k` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit i=0 while :; do mkdir ${n0}/${i} >/dev/null 2>&1 @@ -27,5 +27,5 @@ while :; do done expect ENOSPC mkdir ${n0}/${n1} 0755 umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/mkdir/12.t b/contrib/pjdfstest/tests/mkdir/12.t similarity index 70% rename from tools/regression/pjdfstest/tests/mkdir/12.t rename to contrib/pjdfstest/tests/mkdir/12.t index af322c4247aa..7c27f74264f6 100644 --- a/tools/regression/pjdfstest/tests/mkdir/12.t +++ b/contrib/pjdfstest/tests/mkdir/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkdir returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/mkfifo/00.t b/contrib/pjdfstest/tests/mkfifo/00.t similarity index 95% rename from tools/regression/pjdfstest/tests/mkfifo/00.t rename to contrib/pjdfstest/tests/mkfifo/00.t index eda7b1789f73..ad88e2836fbb 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/00.t +++ b/contrib/pjdfstest/tests/mkfifo/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo creates fifo files" diff --git a/tools/regression/pjdfstest/tests/mkfifo/01.t b/contrib/pjdfstest/tests/mkfifo/01.t similarity index 79% rename from tools/regression/pjdfstest/tests/mkfifo/01.t rename to contrib/pjdfstest/tests/mkfifo/01.t index 1c6193b18679..fae5c23091bc 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/01.t +++ b/contrib/pjdfstest/tests/mkfifo/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="mkfifo returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/mkfifo/02.t b/contrib/pjdfstest/tests/mkfifo/02.t similarity index 76% rename from tools/regression/pjdfstest/tests/mkfifo/02.t rename to contrib/pjdfstest/tests/mkfifo/02.t index 8589e9db067f..e51bcd5fdff2 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/02.t +++ b/contrib/pjdfstest/tests/mkfifo/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/mkfifo/03.t b/contrib/pjdfstest/tests/mkfifo/03.t similarity index 77% rename from tools/regression/pjdfstest/tests/mkfifo/03.t rename to contrib/pjdfstest/tests/mkfifo/03.t index caf529f9da8d..06265293517b 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/03.t +++ b/contrib/pjdfstest/tests/mkfifo/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/mkfifo/04.t b/contrib/pjdfstest/tests/mkfifo/04.t similarity index 72% rename from tools/regression/pjdfstest/tests/mkfifo/04.t rename to contrib/pjdfstest/tests/mkfifo/04.t index d9ad95114418..981015808a18 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/04.t +++ b/contrib/pjdfstest/tests/mkfifo/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns ENOENT if a component of the path prefix does not exist" diff --git a/tools/regression/pjdfstest/tests/mkfifo/05.t b/contrib/pjdfstest/tests/mkfifo/05.t similarity index 87% rename from tools/regression/pjdfstest/tests/mkfifo/05.t rename to contrib/pjdfstest/tests/mkfifo/05.t index d93d568e733d..a9510e284841 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/05.t +++ b/contrib/pjdfstest/tests/mkfifo/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/mkfifo/06.t b/contrib/pjdfstest/tests/mkfifo/06.t similarity index 87% rename from tools/regression/pjdfstest/tests/mkfifo/06.t rename to contrib/pjdfstest/tests/mkfifo/06.t index 47f199b31118..a1fa76135152 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/06.t +++ b/contrib/pjdfstest/tests/mkfifo/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns EACCES when write permission is denied on the parent directory of the file to be created" diff --git a/tools/regression/pjdfstest/tests/mkfifo/07.t b/contrib/pjdfstest/tests/mkfifo/07.t similarity index 79% rename from tools/regression/pjdfstest/tests/mkfifo/07.t rename to contrib/pjdfstest/tests/mkfifo/07.t index 44271b6df534..0ba1ac4bde30 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/07.t +++ b/contrib/pjdfstest/tests/mkfifo/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/mkfifo/08.t b/contrib/pjdfstest/tests/mkfifo/08.t similarity index 67% rename from tools/regression/pjdfstest/tests/mkfifo/08.t rename to contrib/pjdfstest/tests/mkfifo/08.t index 0bdf430826e6..8e1bd2759524 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/08.t +++ b/contrib/pjdfstest/tests/mkfifo/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns EROFS if the named file resides on a read-only file system" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 mkfifo ${n0}/${n1} 0644 expect 0 unlink ${n0}/${n1} mount -ur /dev/md${n} @@ -25,5 +25,5 @@ mount -uw /dev/md${n} expect 0 mkfifo ${n0}/${n1} 0644 expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/mkfifo/09.t b/contrib/pjdfstest/tests/mkfifo/09.t similarity index 78% rename from tools/regression/pjdfstest/tests/mkfifo/09.t rename to contrib/pjdfstest/tests/mkfifo/09.t index 6b2015e28f3e..15af5d106180 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/09.t +++ b/contrib/pjdfstest/tests/mkfifo/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/09.t 211474 2010-08-18 22:06:43Z pjd $ desc="mkfifo returns EEXIST if the named file exists" diff --git a/tools/regression/pjdfstest/tests/mkfifo/10.t b/contrib/pjdfstest/tests/mkfifo/10.t similarity index 93% rename from tools/regression/pjdfstest/tests/mkfifo/10.t rename to contrib/pjdfstest/tests/mkfifo/10.t index e6aec4479ea8..4c8bcab5ff21 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/10.t +++ b/contrib/pjdfstest/tests/mkfifo/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns EPERM if the parent directory of the file to be created has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/mkfifo/11.t b/contrib/pjdfstest/tests/mkfifo/11.t similarity index 66% rename from tools/regression/pjdfstest/tests/mkfifo/11.t rename to contrib/pjdfstest/tests/mkfifo/11.t index 261a8a7e244a..8b2396f3be0e 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/11.t +++ b/contrib/pjdfstest/tests/mkfifo/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns ENOSPC if there are no free inodes on the file system on which the file is being created" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 256k` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit i=0 while :; do mkfifo ${n0}/${i} >/dev/null 2>&1 @@ -27,5 +27,5 @@ while :; do done expect ENOSPC mkfifo ${n0}/${n1} 0644 umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/mkfifo/12.t b/contrib/pjdfstest/tests/mkfifo/12.t similarity index 70% rename from tools/regression/pjdfstest/tests/mkfifo/12.t rename to contrib/pjdfstest/tests/mkfifo/12.t index 40c1455ad395..ad044b9f702c 100644 --- a/tools/regression/pjdfstest/tests/mkfifo/12.t +++ b/contrib/pjdfstest/tests/mkfifo/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/mknod/00.t b/contrib/pjdfstest/tests/mknod/00.t similarity index 95% rename from tools/regression/pjdfstest/tests/mknod/00.t rename to contrib/pjdfstest/tests/mknod/00.t index 13f017d429bb..67f4046a6ffb 100644 --- a/tools/regression/pjdfstest/tests/mknod/00.t +++ b/contrib/pjdfstest/tests/mknod/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod creates fifo files" diff --git a/tools/regression/pjdfstest/tests/mknod/01.t b/contrib/pjdfstest/tests/mknod/01.t similarity index 83% rename from tools/regression/pjdfstest/tests/mknod/01.t rename to contrib/pjdfstest/tests/mknod/01.t index bc2b658417b8..84a0a9731cd7 100644 --- a/tools/regression/pjdfstest/tests/mknod/01.t +++ b/contrib/pjdfstest/tests/mknod/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="mknod returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/mknod/02.t b/contrib/pjdfstest/tests/mknod/02.t similarity index 86% rename from tools/regression/pjdfstest/tests/mknod/02.t rename to contrib/pjdfstest/tests/mknod/02.t index 99e607f7554e..4e864fe69f69 100644 --- a/tools/regression/pjdfstest/tests/mknod/02.t +++ b/contrib/pjdfstest/tests/mknod/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/mknod/03.t b/contrib/pjdfstest/tests/mknod/03.t similarity index 86% rename from tools/regression/pjdfstest/tests/mknod/03.t rename to contrib/pjdfstest/tests/mknod/03.t index 10776c7a14c0..d5c572cbf460 100644 --- a/tools/regression/pjdfstest/tests/mknod/03.t +++ b/contrib/pjdfstest/tests/mknod/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/mknod/04.t b/contrib/pjdfstest/tests/mknod/04.t similarity index 73% rename from tools/regression/pjdfstest/tests/mknod/04.t rename to contrib/pjdfstest/tests/mknod/04.t index 6c303185fb6a..4b80208caffe 100644 --- a/tools/regression/pjdfstest/tests/mknod/04.t +++ b/contrib/pjdfstest/tests/mknod/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="mkfifo returns ENOENT if a component of the path prefix does not exist" diff --git a/tools/regression/pjdfstest/tests/mknod/05.t b/contrib/pjdfstest/tests/mknod/05.t similarity index 87% rename from tools/regression/pjdfstest/tests/mknod/05.t rename to contrib/pjdfstest/tests/mknod/05.t index 800354149612..deafda620750 100644 --- a/tools/regression/pjdfstest/tests/mknod/05.t +++ b/contrib/pjdfstest/tests/mknod/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/mknod/06.t b/contrib/pjdfstest/tests/mknod/06.t similarity index 87% rename from tools/regression/pjdfstest/tests/mknod/06.t rename to contrib/pjdfstest/tests/mknod/06.t index 180cb9a56945..da7a5497b5a6 100644 --- a/tools/regression/pjdfstest/tests/mknod/06.t +++ b/contrib/pjdfstest/tests/mknod/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns EACCES when write permission is denied on the parent directory of the file to be created" diff --git a/tools/regression/pjdfstest/tests/mknod/07.t b/contrib/pjdfstest/tests/mknod/07.t similarity index 79% rename from tools/regression/pjdfstest/tests/mknod/07.t rename to contrib/pjdfstest/tests/mknod/07.t index 855d990d1110..1b39cc7c6d94 100644 --- a/tools/regression/pjdfstest/tests/mknod/07.t +++ b/contrib/pjdfstest/tests/mknod/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/mknod/08.t b/contrib/pjdfstest/tests/mknod/08.t similarity index 81% rename from tools/regression/pjdfstest/tests/mknod/08.t rename to contrib/pjdfstest/tests/mknod/08.t index 47d001073c94..a8055629de07 100644 --- a/tools/regression/pjdfstest/tests/mknod/08.t +++ b/contrib/pjdfstest/tests/mknod/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/08.t 211474 2010-08-18 22:06:43Z pjd $ desc="mknod returns EEXIST if the named file exists" diff --git a/tools/regression/pjdfstest/tests/mknod/09.t b/contrib/pjdfstest/tests/mknod/09.t similarity index 93% rename from tools/regression/pjdfstest/tests/mknod/09.t rename to contrib/pjdfstest/tests/mknod/09.t index a12a02cfb4b0..00c2a2f6d8b5 100644 --- a/tools/regression/pjdfstest/tests/mknod/09.t +++ b/contrib/pjdfstest/tests/mknod/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns EPERM if the parent directory of the file to be created has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/mknod/10.t b/contrib/pjdfstest/tests/mknod/10.t similarity index 71% rename from tools/regression/pjdfstest/tests/mknod/10.t rename to contrib/pjdfstest/tests/mknod/10.t index fa6730f2532f..5bf18d37adc4 100644 --- a/tools/regression/pjdfstest/tests/mknod/10.t +++ b/contrib/pjdfstest/tests/mknod/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/mknod/11.t b/contrib/pjdfstest/tests/mknod/11.t similarity index 94% rename from tools/regression/pjdfstest/tests/mknod/11.t rename to contrib/pjdfstest/tests/mknod/11.t index da46cb9aacb4..309f71695f31 100644 --- a/tools/regression/pjdfstest/tests/mknod/11.t +++ b/contrib/pjdfstest/tests/mknod/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="mknod creates device files" diff --git a/tools/regression/pjdfstest/tests/open/00.t b/contrib/pjdfstest/tests/open/00.t similarity index 97% rename from tools/regression/pjdfstest/tests/open/00.t rename to contrib/pjdfstest/tests/open/00.t index caa24f0a8b13..cf11a9290e8e 100644 --- a/tools/regression/pjdfstest/tests/open/00.t +++ b/contrib/pjdfstest/tests/open/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="open opens (and eventually creates) a file" diff --git a/tools/regression/pjdfstest/tests/open/01.t b/contrib/pjdfstest/tests/open/01.t similarity index 82% rename from tools/regression/pjdfstest/tests/open/01.t rename to contrib/pjdfstest/tests/open/01.t index 6dfc6f54b2a9..df17590113ab 100644 --- a/tools/regression/pjdfstest/tests/open/01.t +++ b/contrib/pjdfstest/tests/open/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/01.t 211474 2010-08-18 22:06:43Z pjd $ desc="open returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/open/02.t b/contrib/pjdfstest/tests/open/02.t similarity index 77% rename from tools/regression/pjdfstest/tests/open/02.t rename to contrib/pjdfstest/tests/open/02.t index 44ca1d7a97a8..adb3bb09d39b 100644 --- a/tools/regression/pjdfstest/tests/open/02.t +++ b/contrib/pjdfstest/tests/open/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/open/03.t b/contrib/pjdfstest/tests/open/03.t similarity index 79% rename from tools/regression/pjdfstest/tests/open/03.t rename to contrib/pjdfstest/tests/open/03.t index c398be15f6cc..89e67bb46eb2 100644 --- a/tools/regression/pjdfstest/tests/open/03.t +++ b/contrib/pjdfstest/tests/open/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ENAMETOOLONG if an entire path name exceeded ${PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/open/04.t b/contrib/pjdfstest/tests/open/04.t similarity index 79% rename from tools/regression/pjdfstest/tests/open/04.t rename to contrib/pjdfstest/tests/open/04.t index 1ce99cbb6341..84b0441f11d8 100644 --- a/tools/regression/pjdfstest/tests/open/04.t +++ b/contrib/pjdfstest/tests/open/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ENOENT if a component of the path name that must exist does not exist or O_CREAT is not set and the named file does not exist" diff --git a/tools/regression/pjdfstest/tests/open/05.t b/contrib/pjdfstest/tests/open/05.t similarity index 87% rename from tools/regression/pjdfstest/tests/open/05.t rename to contrib/pjdfstest/tests/open/05.t index 25ad7daed165..1b69c61333c3 100644 --- a/tools/regression/pjdfstest/tests/open/05.t +++ b/contrib/pjdfstest/tests/open/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/open/06.t b/contrib/pjdfstest/tests/open/06.t similarity index 98% rename from tools/regression/pjdfstest/tests/open/06.t rename to contrib/pjdfstest/tests/open/06.t index 007e24a164cd..b33e6404e70b 100644 --- a/tools/regression/pjdfstest/tests/open/06.t +++ b/contrib/pjdfstest/tests/open/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags" diff --git a/tools/regression/pjdfstest/tests/open/07.t b/contrib/pjdfstest/tests/open/07.t similarity index 93% rename from tools/regression/pjdfstest/tests/open/07.t rename to contrib/pjdfstest/tests/open/07.t index a41d1933a810..edc4be13649b 100644 --- a/tools/regression/pjdfstest/tests/open/07.t +++ b/contrib/pjdfstest/tests/open/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EACCES when O_TRUNC is specified and write permission is denied" diff --git a/tools/regression/pjdfstest/tests/open/08.t b/contrib/pjdfstest/tests/open/08.t similarity index 80% rename from tools/regression/pjdfstest/tests/open/08.t rename to contrib/pjdfstest/tests/open/08.t index 22ea29be5631..f47ff8720419 100644 --- a/tools/regression/pjdfstest/tests/open/08.t +++ b/contrib/pjdfstest/tests/open/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EACCES when O_CREAT is specified, the file does not exist, and the directory in which it is to be created does not permit writing" diff --git a/tools/regression/pjdfstest/tests/open/09.t b/contrib/pjdfstest/tests/open/09.t similarity index 93% rename from tools/regression/pjdfstest/tests/open/09.t rename to contrib/pjdfstest/tests/open/09.t index 106e36fcdeb8..b76c70da8190 100644 --- a/tools/regression/pjdfstest/tests/open/09.t +++ b/contrib/pjdfstest/tests/open/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="O_CREAT is specified, the file does not exist, and the directory in which it is to be created has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/open/10.t b/contrib/pjdfstest/tests/open/10.t similarity index 92% rename from tools/regression/pjdfstest/tests/open/10.t rename to contrib/pjdfstest/tests/open/10.t index 2cc943f79a50..bd6fdd25241f 100644 --- a/tools/regression/pjdfstest/tests/open/10.t +++ b/contrib/pjdfstest/tests/open/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EPERM when the named file has its immutable flag set and the file is to be modified" diff --git a/tools/regression/pjdfstest/tests/open/11.t b/contrib/pjdfstest/tests/open/11.t similarity index 94% rename from tools/regression/pjdfstest/tests/open/11.t rename to contrib/pjdfstest/tests/open/11.t index c68bb251c4a1..e4a3a2d45e8f 100644 --- a/tools/regression/pjdfstest/tests/open/11.t +++ b/contrib/pjdfstest/tests/open/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EPERM when the named file has its append-only flag set, the file is to be modified, and O_TRUNC is specified or O_APPEND is not specified" diff --git a/tools/regression/pjdfstest/tests/open/12.t b/contrib/pjdfstest/tests/open/12.t similarity index 79% rename from tools/regression/pjdfstest/tests/open/12.t rename to contrib/pjdfstest/tests/open/12.t index 2726dc1f9fe9..d38309d4a118 100644 --- a/tools/regression/pjdfstest/tests/open/12.t +++ b/contrib/pjdfstest/tests/open/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/open/13.t b/contrib/pjdfstest/tests/open/13.t similarity index 82% rename from tools/regression/pjdfstest/tests/open/13.t rename to contrib/pjdfstest/tests/open/13.t index 77bc4c224934..64bb0b8f825f 100644 --- a/tools/regression/pjdfstest/tests/open/13.t +++ b/contrib/pjdfstest/tests/open/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EISDIR when trying to open a directory for writing" diff --git a/tools/regression/pjdfstest/tests/open/14.t b/contrib/pjdfstest/tests/open/14.t similarity index 73% rename from tools/regression/pjdfstest/tests/open/14.t rename to contrib/pjdfstest/tests/open/14.t index 3d81f3e5cb26..8d90065f7171 100644 --- a/tools/regression/pjdfstest/tests/open/14.t +++ b/contrib/pjdfstest/tests/open/14.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/14.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EROFS if the named file resides on a read-only file system, and the file is to be modified" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 expect 0 open ${n0}/${n1} O_WRONLY expect 0 open ${n0}/${n1} O_RDWR @@ -28,5 +28,5 @@ expect EROFS open ${n0}/${n1} O_RDONLY,O_TRUNC mount -uw /dev/md${n} expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/open/15.t b/contrib/pjdfstest/tests/open/15.t similarity index 67% rename from tools/regression/pjdfstest/tests/open/15.t rename to contrib/pjdfstest/tests/open/15.t index d90877b51fea..a8230d89e2f0 100644 --- a/tools/regression/pjdfstest/tests/open/15.t +++ b/contrib/pjdfstest/tests/open/15.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/15.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EROFS when O_CREAT is specified and the named file would reside on a read-only file system" @@ -14,14 +14,14 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 expect 0 unlink ${n0}/${n1} mount -ur /dev/md${n} expect EROFS open ${n0}/${n1} O_RDONLY,O_CREAT 0644 mount -uw /dev/md${n} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/16.t b/contrib/pjdfstest/tests/open/16.t new file mode 100644 index 000000000000..7f796d61a365 --- /dev/null +++ b/contrib/pjdfstest/tests/open/16.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/16.t 219621 2011-03-13 19:35:13Z pjd $ + +dir=`dirname $0` +. ${dir}/../misc.sh + +case "${os}" in +Darwin|Linux) + error=ELOOP + ;; +*) + error=EMLINK + ;; +esac +desc="open returns $error when O_NOFOLLOW was specified and the target is a symbolic link" + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect $error open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 +expect $error open ${n1} O_RDONLY,O_NOFOLLOW +expect $error open ${n1} O_WRONLY,O_NOFOLLOW +expect $error open ${n1} O_RDWR,O_NOFOLLOW +expect 0 unlink ${n1} diff --git a/tools/regression/pjdfstest/tests/open/17.t b/contrib/pjdfstest/tests/open/17.t similarity index 76% rename from tools/regression/pjdfstest/tests/open/17.t rename to contrib/pjdfstest/tests/open/17.t index 2224daf5ea59..e5888fc176f2 100644 --- a/tools/regression/pjdfstest/tests/open/17.t +++ b/contrib/pjdfstest/tests/open/17.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/17.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ENXIO when O_NONBLOCK is set, the named file is a fifo, O_WRONLY is set, and no process has the file open for reading" diff --git a/tools/regression/pjdfstest/tests/open/18.t b/contrib/pjdfstest/tests/open/18.t similarity index 87% rename from tools/regression/pjdfstest/tests/open/18.t rename to contrib/pjdfstest/tests/open/18.t index bd8eea47f891..6d0713b43a89 100644 --- a/tools/regression/pjdfstest/tests/open/18.t +++ b/contrib/pjdfstest/tests/open/18.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/18.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EWOULDBLOCK when O_NONBLOCK and one of O_SHLOCK or O_EXLOCK is specified and the file is locked" diff --git a/tools/regression/pjdfstest/tests/open/19.t b/contrib/pjdfstest/tests/open/19.t similarity index 69% rename from tools/regression/pjdfstest/tests/open/19.t rename to contrib/pjdfstest/tests/open/19.t index b1c3994b25bc..c9d98eb5480e 100644 --- a/tools/regression/pjdfstest/tests/open/19.t +++ b/contrib/pjdfstest/tests/open/19.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/19.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ENOSPC when O_CREAT is specified, the file does not exist, and there are no free inodes on the file system on which the file is being created" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 256k` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit i=0 while :; do touch ${n0}/${i} >/dev/null 2>&1 @@ -27,5 +27,5 @@ while :; do done expect ENOSPC open ${n0}/${i} O_RDONLY,O_CREAT 0644 umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/open/20.t b/contrib/pjdfstest/tests/open/20.t similarity index 82% rename from tools/regression/pjdfstest/tests/open/20.t rename to contrib/pjdfstest/tests/open/20.t index 736ad721bf81..de80b6122b7d 100644 --- a/tools/regression/pjdfstest/tests/open/20.t +++ b/contrib/pjdfstest/tests/open/20.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/20.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns ETXTBSY when the file is a pure procedure (shared text) file that is being executed and the open() system call requests write access" diff --git a/tools/regression/pjdfstest/tests/open/21.t b/contrib/pjdfstest/tests/open/21.t similarity index 71% rename from tools/regression/pjdfstest/tests/open/21.t rename to contrib/pjdfstest/tests/open/21.t index c43d7fd70faa..4a2422cfa6aa 100644 --- a/tools/regression/pjdfstest/tests/open/21.t +++ b/contrib/pjdfstest/tests/open/21.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/21.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/open/22.t b/contrib/pjdfstest/tests/open/22.t similarity index 80% rename from tools/regression/pjdfstest/tests/open/22.t rename to contrib/pjdfstest/tests/open/22.t index 464dae786566..55d4b9b3f8a3 100644 --- a/tools/regression/pjdfstest/tests/open/22.t +++ b/contrib/pjdfstest/tests/open/22.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/22.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EEXIST when O_CREAT and O_EXCL were specified and the file exists" diff --git a/tools/regression/pjdfstest/tests/open/23.t b/contrib/pjdfstest/tests/open/23.t similarity index 81% rename from tools/regression/pjdfstest/tests/open/23.t rename to contrib/pjdfstest/tests/open/23.t index fc2c6b9d7e91..4728c18896cd 100644 --- a/tools/regression/pjdfstest/tests/open/23.t +++ b/contrib/pjdfstest/tests/open/23.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/23.t 211352 2010-08-15 21:24:17Z pjd $ desc="open may return EINVAL when an attempt was made to open a descriptor with an illegal combination of O_RDONLY, O_WRONLY, and O_RDWR" diff --git a/tools/regression/pjdfstest/tests/open/24.t b/contrib/pjdfstest/tests/open/24.t similarity index 76% rename from tools/regression/pjdfstest/tests/open/24.t rename to contrib/pjdfstest/tests/open/24.t index d51d63277463..ca709f221214 100644 --- a/tools/regression/pjdfstest/tests/open/24.t +++ b/contrib/pjdfstest/tests/open/24.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/24.t 211352 2010-08-15 21:24:17Z pjd $ desc="open returns EOPNOTSUPP when trying to open UNIX domain socket" diff --git a/tools/regression/pjdfstest/tests/rename/00.t b/contrib/pjdfstest/tests/rename/00.t similarity index 96% rename from tools/regression/pjdfstest/tests/rename/00.t rename to contrib/pjdfstest/tests/rename/00.t index 49f7609e868f..2126a86a5488 100644 --- a/tools/regression/pjdfstest/tests/rename/00.t +++ b/contrib/pjdfstest/tests/rename/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename changes file name" diff --git a/tools/regression/pjdfstest/tests/rename/01.t b/contrib/pjdfstest/tests/rename/01.t similarity index 82% rename from tools/regression/pjdfstest/tests/rename/01.t rename to contrib/pjdfstest/tests/rename/01.t index 291216d56f4f..dbb9c0660d41 100644 --- a/tools/regression/pjdfstest/tests/rename/01.t +++ b/contrib/pjdfstest/tests/rename/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/01.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns ENAMETOOLONG if a component of either pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/rename/02.t b/contrib/pjdfstest/tests/rename/02.t similarity index 82% rename from tools/regression/pjdfstest/tests/rename/02.t rename to contrib/pjdfstest/tests/rename/02.t index 7557e89ce09e..23425bada559 100644 --- a/tools/regression/pjdfstest/tests/rename/02.t +++ b/contrib/pjdfstest/tests/rename/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/rename/03.t b/contrib/pjdfstest/tests/rename/03.t similarity index 80% rename from tools/regression/pjdfstest/tests/rename/03.t rename to contrib/pjdfstest/tests/rename/03.t index 8404dbe27d0f..fb1d16f10d10 100644 --- a/tools/regression/pjdfstest/tests/rename/03.t +++ b/contrib/pjdfstest/tests/rename/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns ENOENT if a component of the 'from' path does not exist, or a path prefix of 'to' does not exist" diff --git a/tools/regression/pjdfstest/tests/rename/04.t b/contrib/pjdfstest/tests/rename/04.t similarity index 90% rename from tools/regression/pjdfstest/tests/rename/04.t rename to contrib/pjdfstest/tests/rename/04.t index af3801f94983..19d1791a71a8 100644 --- a/tools/regression/pjdfstest/tests/rename/04.t +++ b/contrib/pjdfstest/tests/rename/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EACCES when a component of either path prefix denies search permission" diff --git a/tools/regression/pjdfstest/tests/rename/05.t b/contrib/pjdfstest/tests/rename/05.t similarity index 90% rename from tools/regression/pjdfstest/tests/rename/05.t rename to contrib/pjdfstest/tests/rename/05.t index 39aa28f2f54c..52deac153b8c 100644 --- a/tools/regression/pjdfstest/tests/rename/05.t +++ b/contrib/pjdfstest/tests/rename/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EACCES when the requested link requires writing in a directory with a mode that denies write permission" diff --git a/tools/regression/pjdfstest/tests/rename/06.t b/contrib/pjdfstest/tests/rename/06.t similarity index 94% rename from tools/regression/pjdfstest/tests/rename/06.t rename to contrib/pjdfstest/tests/rename/06.t index 2606c4e53e12..ffcf61e83a5c 100644 --- a/tools/regression/pjdfstest/tests/rename/06.t +++ b/contrib/pjdfstest/tests/rename/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EPERM if the file pointed at by the 'from' argument has its immutable, undeletable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/rename/07.t b/contrib/pjdfstest/tests/rename/07.t similarity index 94% rename from tools/regression/pjdfstest/tests/rename/07.t rename to contrib/pjdfstest/tests/rename/07.t index 450b653b4677..522e67df9181 100644 --- a/tools/regression/pjdfstest/tests/rename/07.t +++ b/contrib/pjdfstest/tests/rename/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EPERM if the parent directory of the file pointed at by the 'from' argument has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/rename/08.t b/contrib/pjdfstest/tests/rename/08.t similarity index 92% rename from tools/regression/pjdfstest/tests/rename/08.t rename to contrib/pjdfstest/tests/rename/08.t index 480672fd50cd..beffb41f8785 100644 --- a/tools/regression/pjdfstest/tests/rename/08.t +++ b/contrib/pjdfstest/tests/rename/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EPERM if the parent directory of the file pointed at by the 'to' argument has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/rename/09.t b/contrib/pjdfstest/tests/rename/09.t similarity index 98% rename from tools/regression/pjdfstest/tests/rename/09.t rename to contrib/pjdfstest/tests/rename/09.t index 91d16a6ff833..299ff64c57e0 100644 --- a/tools/regression/pjdfstest/tests/rename/09.t +++ b/contrib/pjdfstest/tests/rename/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EACCES or EPERM if the directory containing 'from' is marked sticky, and neither the containing directory nor 'from' are owned by the effective user ID" diff --git a/tools/regression/pjdfstest/tests/rename/10.t b/contrib/pjdfstest/tests/rename/10.t similarity index 98% rename from tools/regression/pjdfstest/tests/rename/10.t rename to contrib/pjdfstest/tests/rename/10.t index 3b48d1f22136..268c3b647de1 100644 --- a/tools/regression/pjdfstest/tests/rename/10.t +++ b/contrib/pjdfstest/tests/rename/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EACCES or EPERM if the file pointed at by the 'to' argument exists, the directory containing 'to' is marked sticky, and neither the containing directory nor 'to' are owned by the effective user ID" diff --git a/tools/regression/pjdfstest/tests/rename/11.t b/contrib/pjdfstest/tests/rename/11.t similarity index 84% rename from tools/regression/pjdfstest/tests/rename/11.t rename to contrib/pjdfstest/tests/rename/11.t index 6120e648120a..3bcd97ed18f3 100644 --- a/tools/regression/pjdfstest/tests/rename/11.t +++ b/contrib/pjdfstest/tests/rename/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns ELOOP if too many symbolic links were encountered in translating one of the pathnames" diff --git a/tools/regression/pjdfstest/tests/rename/12.t b/contrib/pjdfstest/tests/rename/12.t similarity index 84% rename from tools/regression/pjdfstest/tests/rename/12.t rename to contrib/pjdfstest/tests/rename/12.t index 4383d843b622..c8939fe85ebf 100644 --- a/tools/regression/pjdfstest/tests/rename/12.t +++ b/contrib/pjdfstest/tests/rename/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/12.t 211474 2010-08-18 22:06:43Z pjd $ desc="rename returns ENOTDIR if a component of either path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/rename/13.t b/contrib/pjdfstest/tests/rename/13.t similarity index 82% rename from tools/regression/pjdfstest/tests/rename/13.t rename to contrib/pjdfstest/tests/rename/13.t index 5e39698de421..00b0bfb6f577 100644 --- a/tools/regression/pjdfstest/tests/rename/13.t +++ b/contrib/pjdfstest/tests/rename/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns ENOTDIR when the 'from' argument is a directory, but 'to' is not a directory" diff --git a/tools/regression/pjdfstest/tests/rename/14.t b/contrib/pjdfstest/tests/rename/14.t similarity index 82% rename from tools/regression/pjdfstest/tests/rename/14.t rename to contrib/pjdfstest/tests/rename/14.t index 8133c9127718..251a1bd66393 100644 --- a/tools/regression/pjdfstest/tests/rename/14.t +++ b/contrib/pjdfstest/tests/rename/14.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/14.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EISDIR when the 'to' argument is a directory, but 'from' is not a directory" diff --git a/tools/regression/pjdfstest/tests/rename/15.t b/contrib/pjdfstest/tests/rename/15.t similarity index 70% rename from tools/regression/pjdfstest/tests/rename/15.t rename to contrib/pjdfstest/tests/rename/15.t index 46927bab8cc9..cd2e44b4830b 100644 --- a/tools/regression/pjdfstest/tests/rename/15.t +++ b/contrib/pjdfstest/tests/rename/15.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/15.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EXDEV if the link named by 'to' and the file named by 'from' are on different file systems" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit for type in regular dir fifo block char socket symlink; do create_file ${type} ${n0}/${n1} @@ -30,5 +30,5 @@ for type in regular dir fifo block char socket symlink; do done umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/rename/16.t b/contrib/pjdfstest/tests/rename/16.t similarity index 69% rename from tools/regression/pjdfstest/tests/rename/16.t rename to contrib/pjdfstest/tests/rename/16.t index b327f365eda5..102657d59cef 100644 --- a/tools/regression/pjdfstest/tests/rename/16.t +++ b/contrib/pjdfstest/tests/rename/16.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/16.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EROFS if the requested link requires writing in a directory on a read-only file system" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 mount -ur /dev/md${n} @@ -28,5 +28,5 @@ expect EROFS rename ${n2} ${n0}/${n2} expect 0 unlink ${n2} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/rename/17.t b/contrib/pjdfstest/tests/rename/17.t similarity index 82% rename from tools/regression/pjdfstest/tests/rename/17.t rename to contrib/pjdfstest/tests/rename/17.t index a3913499d44e..6deb7b704f06 100644 --- a/tools/regression/pjdfstest/tests/rename/17.t +++ b/contrib/pjdfstest/tests/rename/17.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/17.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EFAULT if one of the pathnames specified is outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/rename/18.t b/contrib/pjdfstest/tests/rename/18.t similarity index 79% rename from tools/regression/pjdfstest/tests/rename/18.t rename to contrib/pjdfstest/tests/rename/18.t index a69913bdc210..8a9594ec4127 100644 --- a/tools/regression/pjdfstest/tests/rename/18.t +++ b/contrib/pjdfstest/tests/rename/18.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/18.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EINVAL when the 'from' argument is a parent directory of 'to'" diff --git a/tools/regression/pjdfstest/tests/rename/19.t b/contrib/pjdfstest/tests/rename/19.t similarity index 80% rename from tools/regression/pjdfstest/tests/rename/19.t rename to contrib/pjdfstest/tests/rename/19.t index 7459523f02ba..2cd95615e42b 100644 --- a/tools/regression/pjdfstest/tests/rename/19.t +++ b/contrib/pjdfstest/tests/rename/19.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/19.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EINVAL/EBUSY when an attempt is made to rename '.' or '..'" diff --git a/tools/regression/pjdfstest/tests/rename/20.t b/contrib/pjdfstest/tests/rename/20.t similarity index 84% rename from tools/regression/pjdfstest/tests/rename/20.t rename to contrib/pjdfstest/tests/rename/20.t index 619fea3ecfb5..8ec37cf7d4cc 100644 --- a/tools/regression/pjdfstest/tests/rename/20.t +++ b/contrib/pjdfstest/tests/rename/20.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/20.t 211352 2010-08-15 21:24:17Z pjd $ desc="rename returns EEXIST or ENOTEMPTY if the 'to' argument is a directory and is not empty" diff --git a/tools/regression/pjdfstest/tests/rename/21.t b/contrib/pjdfstest/tests/rename/21.t similarity index 93% rename from tools/regression/pjdfstest/tests/rename/21.t rename to contrib/pjdfstest/tests/rename/21.t index 12d98e3c9656..bba1467069da 100644 --- a/tools/regression/pjdfstest/tests/rename/21.t +++ b/contrib/pjdfstest/tests/rename/21.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/21.t 211352 2010-08-15 21:24:17Z pjd $ desc="write access to subdirectory is required to move it to another directory" diff --git a/tools/regression/pjdfstest/tests/rmdir/00.t b/contrib/pjdfstest/tests/rmdir/00.t similarity index 84% rename from tools/regression/pjdfstest/tests/rmdir/00.t rename to contrib/pjdfstest/tests/rmdir/00.t index 4381e6643d79..9e75be6b9884 100644 --- a/tools/regression/pjdfstest/tests/rmdir/00.t +++ b/contrib/pjdfstest/tests/rmdir/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir removes directories" diff --git a/tools/regression/pjdfstest/tests/rmdir/01.t b/contrib/pjdfstest/tests/rmdir/01.t similarity index 85% rename from tools/regression/pjdfstest/tests/rmdir/01.t rename to contrib/pjdfstest/tests/rmdir/01.t index d2d407dd0e24..b89ffefbe763 100644 --- a/tools/regression/pjdfstest/tests/rmdir/01.t +++ b/contrib/pjdfstest/tests/rmdir/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/01.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns ENOTDIR if a component of the path is not a directory" diff --git a/tools/regression/pjdfstest/tests/rmdir/02.t b/contrib/pjdfstest/tests/rmdir/02.t similarity index 75% rename from tools/regression/pjdfstest/tests/rmdir/02.t rename to contrib/pjdfstest/tests/rmdir/02.t index 3daae4eb3d18..eb8a774bf240 100644 --- a/tools/regression/pjdfstest/tests/rmdir/02.t +++ b/contrib/pjdfstest/tests/rmdir/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/rmdir/03.t b/contrib/pjdfstest/tests/rmdir/03.t similarity index 79% rename from tools/regression/pjdfstest/tests/rmdir/03.t rename to contrib/pjdfstest/tests/rmdir/03.t index a7259e044533..3d5a11a3611d 100644 --- a/tools/regression/pjdfstest/tests/rmdir/03.t +++ b/contrib/pjdfstest/tests/rmdir/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns ENAMETOOLONG if an entire path name exceeded ${PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/rmdir/04.t b/contrib/pjdfstest/tests/rmdir/04.t similarity index 72% rename from tools/regression/pjdfstest/tests/rmdir/04.t rename to contrib/pjdfstest/tests/rmdir/04.t index 77e1d30e57c3..d5abc31cfd18 100644 --- a/tools/regression/pjdfstest/tests/rmdir/04.t +++ b/contrib/pjdfstest/tests/rmdir/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns ENOENT if the named directory does not exist" diff --git a/tools/regression/pjdfstest/tests/rmdir/05.t b/contrib/pjdfstest/tests/rmdir/05.t similarity index 78% rename from tools/regression/pjdfstest/tests/rmdir/05.t rename to contrib/pjdfstest/tests/rmdir/05.t index fd973a93af5f..eb984533d057 100644 --- a/tools/regression/pjdfstest/tests/rmdir/05.t +++ b/contrib/pjdfstest/tests/rmdir/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/rmdir/06.t b/contrib/pjdfstest/tests/rmdir/06.t similarity index 83% rename from tools/regression/pjdfstest/tests/rmdir/06.t rename to contrib/pjdfstest/tests/rmdir/06.t index 9de34b0e1d6b..64a6ac85fe49 100644 --- a/tools/regression/pjdfstest/tests/rmdir/06.t +++ b/contrib/pjdfstest/tests/rmdir/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/06.t 211474 2010-08-18 22:06:43Z pjd $ desc="rmdir returns EEXIST or ENOTEMPTY the named directory contains files other than '.' and '..' in it" diff --git a/tools/regression/pjdfstest/tests/rmdir/07.t b/contrib/pjdfstest/tests/rmdir/07.t similarity index 85% rename from tools/regression/pjdfstest/tests/rmdir/07.t rename to contrib/pjdfstest/tests/rmdir/07.t index 2528245c0a41..10a78a71e9d5 100644 --- a/tools/regression/pjdfstest/tests/rmdir/07.t +++ b/contrib/pjdfstest/tests/rmdir/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/rmdir/08.t b/contrib/pjdfstest/tests/rmdir/08.t similarity index 85% rename from tools/regression/pjdfstest/tests/rmdir/08.t rename to contrib/pjdfstest/tests/rmdir/08.t index c1fb819732c3..fe70c8683d0b 100644 --- a/tools/regression/pjdfstest/tests/rmdir/08.t +++ b/contrib/pjdfstest/tests/rmdir/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EACCES when write permission is denied on the directory containing the link to be removed" diff --git a/tools/regression/pjdfstest/tests/rmdir/09.t b/contrib/pjdfstest/tests/rmdir/09.t similarity index 93% rename from tools/regression/pjdfstest/tests/rmdir/09.t rename to contrib/pjdfstest/tests/rmdir/09.t index 240fd5c3f73f..8b0276c980ed 100644 --- a/tools/regression/pjdfstest/tests/rmdir/09.t +++ b/contrib/pjdfstest/tests/rmdir/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EPERM if the named directory has its immutable, undeletable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/rmdir/10.t b/contrib/pjdfstest/tests/rmdir/10.t similarity index 93% rename from tools/regression/pjdfstest/tests/rmdir/10.t rename to contrib/pjdfstest/tests/rmdir/10.t index 7bdc261487fe..5d2e37ef4557 100644 --- a/tools/regression/pjdfstest/tests/rmdir/10.t +++ b/contrib/pjdfstest/tests/rmdir/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EPERM if the parent directory of the named file has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/rmdir/11.t b/contrib/pjdfstest/tests/rmdir/11.t similarity index 94% rename from tools/regression/pjdfstest/tests/rmdir/11.t rename to contrib/pjdfstest/tests/rmdir/11.t index 6e4b0b1ebf85..b8e059135400 100644 --- a/tools/regression/pjdfstest/tests/rmdir/11.t +++ b/contrib/pjdfstest/tests/rmdir/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EACCES or EPERM if the directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID" diff --git a/tools/regression/pjdfstest/tests/rmdir/12.t b/contrib/pjdfstest/tests/rmdir/12.t similarity index 86% rename from tools/regression/pjdfstest/tests/rmdir/12.t rename to contrib/pjdfstest/tests/rmdir/12.t index 9ba45a4b372c..57d144da58f2 100644 --- a/tools/regression/pjdfstest/tests/rmdir/12.t +++ b/contrib/pjdfstest/tests/rmdir/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EINVAL if the last component of the path is '.' and EEXIST or ENOTEMPTY if the last component of the path is '..'" diff --git a/tools/regression/pjdfstest/tests/rmdir/13.t b/contrib/pjdfstest/tests/rmdir/13.t similarity index 56% rename from tools/regression/pjdfstest/tests/rmdir/13.t rename to contrib/pjdfstest/tests/rmdir/13.t index 6140e7b82390..4a1a88542d64 100644 --- a/tools/regression/pjdfstest/tests/rmdir/13.t +++ b/contrib/pjdfstest/tests/rmdir/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EBUSY if the directory to be removed is the mount point for a mounted file system" @@ -13,10 +13,10 @@ echo "1..3" n0=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect EBUSY rmdir ${n0} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/rmdir/14.t b/contrib/pjdfstest/tests/rmdir/14.t similarity index 64% rename from tools/regression/pjdfstest/tests/rmdir/14.t rename to contrib/pjdfstest/tests/rmdir/14.t index faa5d5e466d8..bdefeaedac08 100644 --- a/tools/regression/pjdfstest/tests/rmdir/14.t +++ b/contrib/pjdfstest/tests/rmdir/14.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/14.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EROFS if the named file resides on a read-only file system" @@ -14,14 +14,14 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 mkdir ${n0}/${n1} 0755 mount -ur /dev/md${n} expect EROFS rmdir ${n0}/${n1} mount -uw /dev/md${n} expect 0 rmdir ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/rmdir/15.t b/contrib/pjdfstest/tests/rmdir/15.t similarity index 69% rename from tools/regression/pjdfstest/tests/rmdir/15.t rename to contrib/pjdfstest/tests/rmdir/15.t index 8bfa1491f7ba..5390403bcb3e 100644 --- a/tools/regression/pjdfstest/tests/rmdir/15.t +++ b/contrib/pjdfstest/tests/rmdir/15.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/15.t 211352 2010-08-15 21:24:17Z pjd $ desc="rmdir returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/symlink/00.t b/contrib/pjdfstest/tests/symlink/00.t similarity index 87% rename from tools/regression/pjdfstest/tests/symlink/00.t rename to contrib/pjdfstest/tests/symlink/00.t index 6e6d46d918ff..1f2693938a35 100644 --- a/tools/regression/pjdfstest/tests/symlink/00.t +++ b/contrib/pjdfstest/tests/symlink/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink creates symbolic links" diff --git a/tools/regression/pjdfstest/tests/symlink/01.t b/contrib/pjdfstest/tests/symlink/01.t similarity index 77% rename from tools/regression/pjdfstest/tests/symlink/01.t rename to contrib/pjdfstest/tests/symlink/01.t index f19870cf31de..3a40b54a45c2 100644 --- a/tools/regression/pjdfstest/tests/symlink/01.t +++ b/contrib/pjdfstest/tests/symlink/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/01.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns ENOTDIR if a component of the name2 path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/symlink/02.t b/contrib/pjdfstest/tests/symlink/02.t similarity index 80% rename from tools/regression/pjdfstest/tests/symlink/02.t rename to contrib/pjdfstest/tests/symlink/02.t index e06b936fff8b..4b81f169f7a6 100644 --- a/tools/regression/pjdfstest/tests/symlink/02.t +++ b/contrib/pjdfstest/tests/symlink/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns ENAMETOOLONG if a component of the name2 pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/symlink/03.t b/contrib/pjdfstest/tests/symlink/03.t similarity index 81% rename from tools/regression/pjdfstest/tests/symlink/03.t rename to contrib/pjdfstest/tests/symlink/03.t index 38ebe5eebccf..68ecfbdfecbc 100644 --- a/tools/regression/pjdfstest/tests/symlink/03.t +++ b/contrib/pjdfstest/tests/symlink/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/symlink/04.t b/contrib/pjdfstest/tests/symlink/04.t similarity index 73% rename from tools/regression/pjdfstest/tests/symlink/04.t rename to contrib/pjdfstest/tests/symlink/04.t index cc5e7b7f3db1..ca1c8eedf48b 100644 --- a/tools/regression/pjdfstest/tests/symlink/04.t +++ b/contrib/pjdfstest/tests/symlink/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns ENOENT if a component of the name2 path prefix does not exist" diff --git a/tools/regression/pjdfstest/tests/symlink/05.t b/contrib/pjdfstest/tests/symlink/05.t similarity index 87% rename from tools/regression/pjdfstest/tests/symlink/05.t rename to contrib/pjdfstest/tests/symlink/05.t index c823a5940130..801e46714a96 100644 --- a/tools/regression/pjdfstest/tests/symlink/05.t +++ b/contrib/pjdfstest/tests/symlink/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns EACCES when a component of the name2 path prefix denies search permission" diff --git a/tools/regression/pjdfstest/tests/symlink/06.t b/contrib/pjdfstest/tests/symlink/06.t similarity index 87% rename from tools/regression/pjdfstest/tests/symlink/06.t rename to contrib/pjdfstest/tests/symlink/06.t index 1f2781865137..db61ad01c392 100644 --- a/tools/regression/pjdfstest/tests/symlink/06.t +++ b/contrib/pjdfstest/tests/symlink/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns EACCES if the parent directory of the file to be created denies write permission" diff --git a/tools/regression/pjdfstest/tests/symlink/07.t b/contrib/pjdfstest/tests/symlink/07.t similarity index 79% rename from tools/regression/pjdfstest/tests/symlink/07.t rename to contrib/pjdfstest/tests/symlink/07.t index aa60b771fe96..c6aedc0570e0 100644 --- a/tools/regression/pjdfstest/tests/symlink/07.t +++ b/contrib/pjdfstest/tests/symlink/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns ELOOP if too many symbolic links were encountered in translating the name2 path name" diff --git a/tools/regression/pjdfstest/tests/symlink/08.t b/contrib/pjdfstest/tests/symlink/08.t similarity index 78% rename from tools/regression/pjdfstest/tests/symlink/08.t rename to contrib/pjdfstest/tests/symlink/08.t index 9d539f166482..ef7915dbe72b 100644 --- a/tools/regression/pjdfstest/tests/symlink/08.t +++ b/contrib/pjdfstest/tests/symlink/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/08.t 211474 2010-08-18 22:06:43Z pjd $ desc="symlink returns EEXIST if the name2 argument already exists" diff --git a/tools/regression/pjdfstest/tests/symlink/09.t b/contrib/pjdfstest/tests/symlink/09.t similarity index 93% rename from tools/regression/pjdfstest/tests/symlink/09.t rename to contrib/pjdfstest/tests/symlink/09.t index 4807db4e3076..6292aaf7649f 100644 --- a/tools/regression/pjdfstest/tests/symlink/09.t +++ b/contrib/pjdfstest/tests/symlink/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns EPERM if the parent directory of the file named by name2 has its immutable flag set" diff --git a/tools/regression/pjdfstest/tests/symlink/10.t b/contrib/pjdfstest/tests/symlink/10.t similarity index 68% rename from tools/regression/pjdfstest/tests/symlink/10.t rename to contrib/pjdfstest/tests/symlink/10.t index b43da77ecc7e..47a6eb4b636a 100644 --- a/tools/regression/pjdfstest/tests/symlink/10.t +++ b/contrib/pjdfstest/tests/symlink/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns EROFS if the file name2 would reside on a read-only file system" @@ -15,9 +15,9 @@ n1=`namegen` n2=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 symlink test ${n0}/${n1} expect 0 unlink ${n0}/${n1} @@ -28,5 +28,5 @@ expect 0 symlink test ${n0}/${n1} expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/symlink/11.t b/contrib/pjdfstest/tests/symlink/11.t similarity index 66% rename from tools/regression/pjdfstest/tests/symlink/11.t rename to contrib/pjdfstest/tests/symlink/11.t index 2f04b7bf2fe1..e9f78e845c8b 100644 --- a/tools/regression/pjdfstest/tests/symlink/11.t +++ b/contrib/pjdfstest/tests/symlink/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns ENOSPC if there are no free inodes on the file system on which the symbolic link is being created" @@ -14,9 +14,9 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 256k` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit i=0 while :; do ln -s test ${n0}/${i} >/dev/null 2>&1 @@ -27,5 +27,5 @@ while :; do done expect ENOSPC symlink test ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/symlink/12.t b/contrib/pjdfstest/tests/symlink/12.t similarity index 80% rename from tools/regression/pjdfstest/tests/symlink/12.t rename to contrib/pjdfstest/tests/symlink/12.t index 8606a38acf35..2c699050e673 100644 --- a/tools/regression/pjdfstest/tests/symlink/12.t +++ b/contrib/pjdfstest/tests/symlink/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="symlink returns EFAULT if one of the pathnames specified is outside the process's allocated address space" diff --git a/tools/regression/pjdfstest/tests/truncate/00.t b/contrib/pjdfstest/tests/truncate/00.t similarity index 91% rename from tools/regression/pjdfstest/tests/truncate/00.t rename to contrib/pjdfstest/tests/truncate/00.t index c09f0680865d..6a77a8f796b0 100644 --- a/tools/regression/pjdfstest/tests/truncate/00.t +++ b/contrib/pjdfstest/tests/truncate/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate descrease/increase file size" diff --git a/contrib/pjdfstest/tests/truncate/01.t b/contrib/pjdfstest/tests/truncate/01.t new file mode 100644 index 000000000000..a8e95ac60181 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR truncate ${n0}/${n1}/test 123 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/02.t b/contrib/pjdfstest/tests/truncate/02.t new file mode 100644 index 000000000000..83de38d3244f --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/02.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect 123 stat ${nx} size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 diff --git a/contrib/pjdfstest/tests/truncate/03.t b/contrib/pjdfstest/tests/truncate/03.t new file mode 100644 index 000000000000..41e98625ba4f --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/03.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect regular,123 stat ${nx} type,size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/truncate/04.t b/contrib/pjdfstest/tests/truncate/04.t new file mode 100644 index 000000000000..cd1cfc66b2b0 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT truncate ${n0}/${n1}/test 123 +expect ENOENT truncate ${n0}/${n1} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/05.t b/contrib/pjdfstest/tests/truncate/05.t new file mode 100644 index 000000000000..f12881581bce --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/05.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..15" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 123 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 0 chmod ${n1} 0755 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 1234 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/06.t b/contrib/pjdfstest/tests/truncate/06.t new file mode 100644 index 000000000000..1ce516fa74a6 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/06.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES if the named file is not writable by the user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 create ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 chown ${n1} 65534 65534 +expect 0 chmod ${n1} 0444 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 unlink ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/07.t b/contrib/pjdfstest/tests/truncate/07.t new file mode 100644 index 000000000000..44f87e7ea859 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP truncate ${n0}/test 123 +expect ELOOP truncate ${n1}/test 123 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/truncate/08.t b/contrib/pjdfstest/tests/truncate/08.t new file mode 100644 index 000000000000..6f205ef965f2 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/08.t @@ -0,0 +1,78 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EPERM if the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..22" + ;; +FreeBSD:UFS) + echo "1..44" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM truncate ${n0} 123 +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect EPERM truncate ${n0} 123 +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/truncate/09.t b/contrib/pjdfstest/tests/truncate/09.t new file mode 100644 index 000000000000..d7e082ddbe0e --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/09.t @@ -0,0 +1,15 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EISDIR if the named file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +expect EISDIR truncate ${n0} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/10.t b/contrib/pjdfstest/tests/truncate/10.t new file mode 100644 index 000000000000..ced3583ec21d --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/10.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 truncate ${n0}/${n1} 123 +expect 123 stat ${n0}/${n1} size +mount -ur /dev/md${n} +expect EROFS truncate ${n0}/${n1} 1234 +expect 123 stat ${n0}/${n1} size +mount -uw /dev/md${n} +expect 0 truncate ${n0}/${n1} 1234 +expect 1234 stat ${n0}/${n1} size +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/11.t b/contrib/pjdfstest/tests/truncate/11.t new file mode 100644 index 000000000000..b00d7b89c16d --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/11.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ETXTBSY the file is a pure procedure (shared text) file that is being executed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..2" + +n0=`namegen` + +cp -pf `which sleep` ${n0} +./${n0} 3 & +expect ETXTBSY truncate ${n0} 123 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/12.t b/contrib/pjdfstest/tests/truncate/12.t new file mode 100644 index 000000000000..1825456a7b13 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/12.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFBIG or EINVAL if the length argument was greater than the maximum file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 create ${n0} 0644 +r=`${fstest} truncate ${n0} 999999999999999 2>/dev/null` +case "${r}" in +EFBIG|EINVAL) + expect 0 stat ${n0} size + ;; +0) + expect 999999999999999 stat ${n0} size + ;; +*) + echo "not ok ${ntest}" + ntest=`expr ${ntest} + 1` + ;; +esac +expect 0 unlink ${n0} diff --git a/tools/regression/pjdfstest/tests/truncate/13.t b/contrib/pjdfstest/tests/truncate/13.t similarity index 73% rename from tools/regression/pjdfstest/tests/truncate/13.t rename to contrib/pjdfstest/tests/truncate/13.t index 9e40928ebd07..7c9f0d4e14ec 100644 --- a/tools/regression/pjdfstest/tests/truncate/13.t +++ b/contrib/pjdfstest/tests/truncate/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="truncate returns EINVAL if the length argument was less than 0" diff --git a/contrib/pjdfstest/tests/truncate/14.t b/contrib/pjdfstest/tests/truncate/14.t new file mode 100644 index 000000000000..a238771264f9 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/14.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT truncate NULL 123 +expect EFAULT truncate DEADCODE 123 diff --git a/tools/regression/pjdfstest/tests/unlink/00.t b/contrib/pjdfstest/tests/unlink/00.t similarity index 98% rename from tools/regression/pjdfstest/tests/unlink/00.t rename to contrib/pjdfstest/tests/unlink/00.t index 9120a6244523..0b9b1f1b59cf 100644 --- a/tools/regression/pjdfstest/tests/unlink/00.t +++ b/contrib/pjdfstest/tests/unlink/00.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/00.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink removes regular files, symbolic links, fifos and sockets" diff --git a/tools/regression/pjdfstest/tests/unlink/01.t b/contrib/pjdfstest/tests/unlink/01.t similarity index 76% rename from tools/regression/pjdfstest/tests/unlink/01.t rename to contrib/pjdfstest/tests/unlink/01.t index 13fa0fe4eab6..7e29671ecb70 100644 --- a/tools/regression/pjdfstest/tests/unlink/01.t +++ b/contrib/pjdfstest/tests/unlink/01.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/01.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns ENOTDIR if a component of the path prefix is not a directory" diff --git a/tools/regression/pjdfstest/tests/unlink/02.t b/contrib/pjdfstest/tests/unlink/02.t similarity index 75% rename from tools/regression/pjdfstest/tests/unlink/02.t rename to contrib/pjdfstest/tests/unlink/02.t index 1324ba3f4df3..e624d987e813 100644 --- a/tools/regression/pjdfstest/tests/unlink/02.t +++ b/contrib/pjdfstest/tests/unlink/02.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/02.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/unlink/03.t b/contrib/pjdfstest/tests/unlink/03.t similarity index 77% rename from tools/regression/pjdfstest/tests/unlink/03.t rename to contrib/pjdfstest/tests/unlink/03.t index db4b4a49c9f3..f4c939e721e6 100644 --- a/tools/regression/pjdfstest/tests/unlink/03.t +++ b/contrib/pjdfstest/tests/unlink/03.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/03.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" diff --git a/tools/regression/pjdfstest/tests/unlink/04.t b/contrib/pjdfstest/tests/unlink/04.t similarity index 72% rename from tools/regression/pjdfstest/tests/unlink/04.t rename to contrib/pjdfstest/tests/unlink/04.t index 7885f27858ff..0717eaad01b9 100644 --- a/tools/regression/pjdfstest/tests/unlink/04.t +++ b/contrib/pjdfstest/tests/unlink/04.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/04.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns ENOENT if the named file does not exist" diff --git a/tools/regression/pjdfstest/tests/unlink/05.t b/contrib/pjdfstest/tests/unlink/05.t similarity index 85% rename from tools/regression/pjdfstest/tests/unlink/05.t rename to contrib/pjdfstest/tests/unlink/05.t index c30c3537e50d..91dccf90afea 100644 --- a/tools/regression/pjdfstest/tests/unlink/05.t +++ b/contrib/pjdfstest/tests/unlink/05.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/05.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EACCES when search permission is denied for a component of the path prefix" diff --git a/tools/regression/pjdfstest/tests/unlink/06.t b/contrib/pjdfstest/tests/unlink/06.t similarity index 85% rename from tools/regression/pjdfstest/tests/unlink/06.t rename to contrib/pjdfstest/tests/unlink/06.t index 3a64aa27509f..293742966c0e 100644 --- a/tools/regression/pjdfstest/tests/unlink/06.t +++ b/contrib/pjdfstest/tests/unlink/06.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/06.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EACCES when write permission is denied on the directory containing the link to be removed" diff --git a/tools/regression/pjdfstest/tests/unlink/07.t b/contrib/pjdfstest/tests/unlink/07.t similarity index 78% rename from tools/regression/pjdfstest/tests/unlink/07.t rename to contrib/pjdfstest/tests/unlink/07.t index ea9d2a345df1..e63eafa6e7a4 100644 --- a/tools/regression/pjdfstest/tests/unlink/07.t +++ b/contrib/pjdfstest/tests/unlink/07.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/07.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns ELOOP if too many symbolic links were encountered in translating the pathname" diff --git a/tools/regression/pjdfstest/tests/unlink/08.t b/contrib/pjdfstest/tests/unlink/08.t similarity index 82% rename from tools/regression/pjdfstest/tests/unlink/08.t rename to contrib/pjdfstest/tests/unlink/08.t index ac81bd66876e..666400cd2a2e 100644 --- a/tools/regression/pjdfstest/tests/unlink/08.t +++ b/contrib/pjdfstest/tests/unlink/08.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/08.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink may return EPERM if the named file is a directory" diff --git a/tools/regression/pjdfstest/tests/unlink/09.t b/contrib/pjdfstest/tests/unlink/09.t similarity index 93% rename from tools/regression/pjdfstest/tests/unlink/09.t rename to contrib/pjdfstest/tests/unlink/09.t index f3422a581ab8..dbc202a6954d 100644 --- a/tools/regression/pjdfstest/tests/unlink/09.t +++ b/contrib/pjdfstest/tests/unlink/09.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/09.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EPERM if the named file has its immutable, undeletable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/unlink/10.t b/contrib/pjdfstest/tests/unlink/10.t similarity index 93% rename from tools/regression/pjdfstest/tests/unlink/10.t rename to contrib/pjdfstest/tests/unlink/10.t index 84f3154a04a9..9ca1d5bc3fb1 100644 --- a/tools/regression/pjdfstest/tests/unlink/10.t +++ b/contrib/pjdfstest/tests/unlink/10.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/10.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EPERM if the parent directory of the named file has its immutable or append-only flag set" diff --git a/tools/regression/pjdfstest/tests/unlink/11.t b/contrib/pjdfstest/tests/unlink/11.t similarity index 95% rename from tools/regression/pjdfstest/tests/unlink/11.t rename to contrib/pjdfstest/tests/unlink/11.t index b0d27f9a9518..d7d71d842d0d 100644 --- a/tools/regression/pjdfstest/tests/unlink/11.t +++ b/contrib/pjdfstest/tests/unlink/11.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/11.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EACCES or EPERM if the directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID" diff --git a/tools/regression/pjdfstest/tests/unlink/12.t b/contrib/pjdfstest/tests/unlink/12.t similarity index 64% rename from tools/regression/pjdfstest/tests/unlink/12.t rename to contrib/pjdfstest/tests/unlink/12.t index b8116d6e7e0d..ae39724faeab 100644 --- a/tools/regression/pjdfstest/tests/unlink/12.t +++ b/contrib/pjdfstest/tests/unlink/12.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/12.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EROFS if the named file resides on a read-only file system" @@ -14,14 +14,14 @@ n0=`namegen` n1=`namegen` expect 0 mkdir ${n0} 0755 -n=`mdconfig -a -n -t malloc -s 1m` -newfs /dev/md${n} >/dev/null -mount /dev/md${n} ${n0} +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit expect 0 create ${n0}/${n1} 0644 mount -ur /dev/md${n} expect EROFS unlink ${n0}/${n1} mount -uw /dev/md${n} expect 0 unlink ${n0}/${n1} umount /dev/md${n} -mdconfig -d -u ${n} +mdconfig -d -u ${n} || exit expect 0 rmdir ${n0} diff --git a/tools/regression/pjdfstest/tests/unlink/13.t b/contrib/pjdfstest/tests/unlink/13.t similarity index 69% rename from tools/regression/pjdfstest/tests/unlink/13.t rename to contrib/pjdfstest/tests/unlink/13.t index da5e718d58de..c424b7ed0094 100644 --- a/tools/regression/pjdfstest/tests/unlink/13.t +++ b/contrib/pjdfstest/tests/unlink/13.t @@ -1,5 +1,5 @@ #!/bin/sh -# $FreeBSD$ +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/13.t 211352 2010-08-15 21:24:17Z pjd $ desc="unlink returns EFAULT if the path argument points outside the process's allocated address space" diff --git a/contrib/smbfs/lib/smb/ctx.c b/contrib/smbfs/lib/smb/ctx.c index c7b3ecaba663..2458607f2a65 100644 --- a/contrib/smbfs/lib/smb/ctx.c +++ b/contrib/smbfs/lib/smb/ctx.c @@ -191,10 +191,6 @@ smb_ctx_parseunc(struct smb_ctx *ctx, const char *unc, int sharetype, smb_error("no user name required", 0); return EINVAL; } - if (*p1 == 0) { - smb_error("empty user name", 0); - return EINVAL; - } error = smb_ctx_setuser(ctx, tmp); if (error) return error; @@ -521,11 +517,6 @@ smb_ctx_resolve(struct smb_ctx *ctx) smb_error("no server name specified", 0); return EINVAL; } - if (ssn->ioc_user[0] == 0) { - smb_error("no user name specified for server %s", - 0, ssn->ioc_srvname); - return EINVAL; - } if (ctx->ct_minlevel >= SMBL_SHARE && sh->ioc_share[0] == 0) { smb_error("no share name specified for %s@%s", 0, ssn->ioc_user, ssn->ioc_srvname); diff --git a/contrib/smbfs/mount_smbfs/mount_smbfs.c b/contrib/smbfs/mount_smbfs/mount_smbfs.c index 8f159ce68e00..99f1cee8ed2e 100644 --- a/contrib/smbfs/mount_smbfs/mount_smbfs.c +++ b/contrib/smbfs/mount_smbfs/mount_smbfs.c @@ -81,7 +81,7 @@ main(int argc, char *argv[]) #else struct xvfsconf vfc; #endif - char *next; + char *next, *p, *val; int opt, error, mntflags, caseopt, fd; uid_t uid; gid_t gid; @@ -194,6 +194,13 @@ main(int argc, char *argv[]) }; case 'o': getmntopts(optarg, mopts, &mntflags, 0); + p = strchr(optarg, '='); + val = NULL; + if (p != NULL) { + *p = '\0'; + val = p + 1; + } + build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); break; case 'c': switch (optarg[0]) { diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index b2124a65aa15..af34f88f8224 100644 --- a/contrib/tcpdump/tcpdump.c +++ b/contrib/tcpdump/tcpdump.c @@ -1533,7 +1533,12 @@ main(int argc, char **argv) if (RFileName == NULL && VFileName == NULL) { static const unsigned long cmds[] = { BIOCGSTATS }; - cap_rights_init(&rights, CAP_IOCTL, CAP_READ); + /* + * the various libpcap devices use a combination of + * read (bpf), ioctl (bpf, netmap), poll (netmap) + * so we add the relevant access rights. + */ + cap_rights_init(&rights, CAP_IOCTL, CAP_READ, CAP_EVENT); if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 && errno != ENOSYS) { error("unable to limit pcap descriptor"); diff --git a/crypto/heimdal/tools/krb5-config.in b/crypto/heimdal/tools/krb5-config.in index 317270e4263b..d1f1a3fdc37e 100755 --- a/crypto/heimdal/tools/krb5-config.in +++ b/crypto/heimdal/tools/krb5-config.in @@ -123,7 +123,7 @@ if test "$do_libs" = "yes"; then lib_flags="-L${libdir}" case $library in gssapi) - lib_flags="$lib_flags -lgssapi -lheimntlm" + lib_flags="$lib_flags -lgssapi -lgssapi_krb5 -lheimntlm" ;; kadm-client) lib_flags="$lib_flags -lkadm5clnt" diff --git a/etc/defaults/periodic.conf b/etc/defaults/periodic.conf index 8520fc5bbf35..bbf97d9a36b2 100644 --- a/etc/defaults/periodic.conf +++ b/etc/defaults/periodic.conf @@ -75,10 +75,6 @@ daily_backup_passwd_enable="YES" # Backup passwd & group # 210.backup-aliases daily_backup_aliases_enable="YES" # Backup mail aliases -# 220.backup-pkgdb -daily_backup_pkgdb_enable="YES" # Backup /var/db/pkg -daily_backup_pkgdb_dir="/var/backups" - # 300.calendar daily_calendar_enable="NO" # Run calendar -a @@ -257,10 +253,6 @@ security_status_passwdless_period="daily" security_status_logincheck_enable="YES" security_status_logincheck_period="daily" -# 460.chkportsum -security_status_chkportsum_enable="NO" # Check ports w/ wrong checksum -security_status_chkportsum_period="daily" - # 500.ipfwdenied security_status_ipfwdenied_enable="YES" security_status_ipfwdenied_period="daily" diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 190bb9c074bd..b24e869cdd43 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -110,6 +110,7 @@ synchronous_dhclient="NO" # Start dhclient directly on configured # interfaces during startup. defaultroute_delay="30" # Time to wait for a default route on a DHCP interface. defaultroute_carrier_delay="5" # Time to wait for carrier while waiting for a default route. +netif_ipexpand_max="2048" # Maximum number of IP addrs in a range spec. wpa_supplicant_program="/usr/sbin/wpa_supplicant" wpa_supplicant_flags="-s" # Extra flags to pass to wpa_supplicant wpa_supplicant_conf_file="/etc/wpa_supplicant.conf" @@ -292,7 +293,7 @@ ipropd_slave_enable="NO" # Run Heimdal incremental propagation daemon ipropd_slave_program="/usr/libexec/ipropd-slave" ipropd_slave_flags="" # Flags to ipropd-slave. ipropd_slave_keytab="/etc/krb5.keytab" # keytab for ipropd-slave. -ipropd_slave_masters="" # master node names. +ipropd_slave_master="" # master node name. gssd_enable="NO" # Run the gssd daemon (or NO). gssd_program="/usr/sbin/gssd" # Path to gssd. diff --git a/etc/devd/Makefile b/etc/devd/Makefile index 94cafdc66288..82a5000ff8ae 100644 --- a/etc/devd/Makefile +++ b/etc/devd/Makefile @@ -18,6 +18,10 @@ FILES+= uath.conf usb.conf FILES+= zfs.conf .endif +.if ${MK_HYPERV} != "no" +FILES+= hyperv.conf +.endif + NO_OBJ= FILESDIR= /etc/devd FILESMODE= 644 diff --git a/etc/devd/hyperv.conf b/etc/devd/hyperv.conf new file mode 100644 index 000000000000..bed7383d0816 --- /dev/null +++ b/etc/devd/hyperv.conf @@ -0,0 +1,19 @@ +# $FreeBSD$ +# +# Hyper-V specific events + +notify 10 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "hv_kvp_dev"; + action "/usr/sbin/hv_kvp_daemon"; +}; + +notify 10 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "DESTROY"; + match "cdev" "hv_kvp_dev"; + action "pkill -x hv_kvp_daemon"; +}; diff --git a/etc/devd/usb.conf b/etc/devd/usb.conf index c8d252abe387..7828a8561cfe 100644 --- a/etc/devd/usb.conf +++ b/etc/devd/usb.conf @@ -65,7 +65,23 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x03f0"; - match "product" "(0x2016|0x2116|0x2216|0x3016|0x3116)"; + match "product" "(0x2016|0x2116|0x2216)"; + action "kldload -n uipaq"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x03f0"; + match "product" "(0x241d|0x251d)"; + action "kldload -n u3g"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x03f0"; + match "product" "(0x3016|0x3116)"; action "kldload -n uipaq"; }; @@ -129,7 +145,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0403"; - match "product" "(0x6001|0x6004|0x6006|0x6006|0x6010|0x6011|0x6014|0x6015|0x8372|0x9378|0x9379|0x937a|0x937c|0x9868|0x9e90|0x9f80|0xa6d0|0xabb8|0xb810|0xb811|0xb812|0xbaf8|0xbbe2|0xbca0|0xbca1|0xbca2|0xbca4|0xbcd8|0xbcd9|0xbcda|0xbdc8|0xbfd8|0xbfd9|0xbfda|0xbfdb|0xbfdc|0xc7d0|0xc850|0xc991|0xcaa0|0xcc48|0xcc49|0xcc4a|0xd010|0xd011|0xd012|0xd013|0xd014|0xd015|0xd016|0xd017|0xd070|0xd071|0xd388|0xd389|0xd38a|0xd38b|0xd38c|0xd38d|0xd38e|0xd38f|0xd578|0xd678|0xd738|0xd780|0xdaf8|0xdaf9|0xdafa|0xdafb|0xdafc|0xdafd|0xdafe|0xdaff|0xdc00|0xdc01|0xdd20|0xdf28|0xdf30|0xdf31|0xdf32|0xdf33|0xdf35|0xe000|0xe001|0xe002|0xe004|0xe006|0xe008|0xe009|0xe00a|0xe050|0xe0e8|0xe0e9|0xe0ea|0xe0eb|0xe0ec|0xe0ed|0xe0ee|0xe0ef|0xe0f0|0xe0f1|0xe0f2|0xe0f3|0xe0f4|0xe0f5|0xe0f6|0xe0f7|0xe40b|0xe520|0xe548|0xe6c8|0xe700|0xe729|0xe808|0xe809|0xe80a|0xe80b|0xe80c|0xe80d|0xe80e|0xe80f|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xe88d|0xe88e|0xe88f|0xea90|0xebe0|0xec88|0xec89|0xed22|0xed71|0xed72|0xed73|0xed74|0xee18|0xeee8|0xeee9|0xeeea|0xeeeb|0xeeec|0xeeed|0xeeee|0xeeef|0xef50|0xef51|0xf068|0xf069|0xf06a|0xf06b|0xf06c|0xf06d|0xf06e|0xf06f|0xf070|0xf0c0|0xf0c8|0xf208|0xf2d0|0xf3c0|0xf3c1|0xf3c2|0xf448|0xf449|0xf44a|0xf44b|0xf44c|0xf460|0xf608|0xf60b|0xf680|0xf850|0xf857|0xf9d0|0xf9d1|0xf9d2|0xf9d3|0xf9d4|0xf9d5|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfa05|0xfa06|0xfa10|0xfa33|0xfa88|0xfad0|0xfaf0|0xfb58|0xfb59|0xfb5a|0xfb5b|0xfb5c|0xfb5d|0xfb5e|0xfb5f|0xfb80|0xfb99|0xfbfa|0xfc08|0xfc09|0xfc0a|0xfc0b|0xfc0c|0xfc0d|0xfc0e|0xfc0f|0xfc60|0xfc70|0xfc71|0xfc72|0xfc73|0xfc82|0xfd60|0xfe38|0xff00|0xff18|0xff1c|0xff1d|0xff20|0xff38|0xff39|0xff3a|0xff3b|0xff3c|0xff3d|0xff3e|0xff3f|0xffa8)"; + match "product" "(0x6001|0x6004|0x6006|0x6006|0x6010|0x6011|0x6014|0x6015|0x8372|0x9378|0x9379|0x937a|0x937c|0x9868|0x9e90|0x9f80|0xa6d0|0xa6d1|0xabb8|0xb810|0xb811|0xb812|0xbaf8|0xbbe2|0xbca0|0xbca1|0xbca2|0xbca4|0xbcd8|0xbcd9|0xbcda|0xbdc8|0xbfd8|0xbfd9|0xbfda|0xbfdb|0xbfdc|0xc7d0|0xc850|0xc991|0xcaa0|0xcc48|0xcc49|0xcc4a|0xd010|0xd011|0xd012|0xd013|0xd014|0xd015|0xd016|0xd017|0xd070|0xd071|0xd388|0xd389|0xd38a|0xd38b|0xd38c|0xd38d|0xd38e|0xd38f|0xd578|0xd678|0xd738|0xd780|0xdaf8|0xdaf9|0xdafa|0xdafb|0xdafc|0xdafd|0xdafe|0xdaff|0xdc00|0xdc01|0xdd20|0xdf28|0xdf30|0xdf31|0xdf32|0xdf33|0xdf35|0xe000|0xe001|0xe002|0xe004|0xe006|0xe008|0xe009|0xe00a|0xe050|0xe0e8|0xe0e9|0xe0ea|0xe0eb|0xe0ec|0xe0ed|0xe0ee|0xe0ef|0xe0f0|0xe0f1|0xe0f2|0xe0f3|0xe0f4|0xe0f5|0xe0f6|0xe0f7|0xe40b|0xe520|0xe548|0xe6c8|0xe700|0xe729|0xe808|0xe809|0xe80a|0xe80b|0xe80c|0xe80d|0xe80e|0xe80f|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xe88d|0xe88e|0xe88f|0xea90|0xebe0|0xec88|0xec89|0xed22|0xed71|0xed72|0xed73|0xed74|0xee18|0xeee8|0xeee9|0xeeea|0xeeeb|0xeeec|0xeeed|0xeeee|0xeeef|0xef50|0xef51|0xf068|0xf069|0xf06a|0xf06b|0xf06c|0xf06d|0xf06e|0xf06f|0xf070|0xf0c0|0xf0c8|0xf208|0xf2d0|0xf3c0|0xf3c1|0xf3c2|0xf448|0xf449|0xf44a|0xf44b|0xf44c|0xf460|0xf608|0xf60b|0xf680|0xf850|0xf857|0xf9d0|0xf9d1|0xf9d2|0xf9d3|0xf9d4|0xf9d5|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfa05|0xfa06|0xfa10|0xfa33|0xfa88|0xfad0|0xfaf0|0xfb58|0xfb59|0xfb5a|0xfb5b|0xfb5c|0xfb5d|0xfb5e|0xfb5f|0xfb80|0xfb99|0xfbfa|0xfc08|0xfc09|0xfc0a|0xfc0b|0xfc0c|0xfc0d|0xfc0e|0xfc0f|0xfc60|0xfc70|0xfc71|0xfc72|0xfc73|0xfc82|0xfd60|0xfe38|0xff00|0xff18|0xff1c|0xff1d|0xff20|0xff38|0xff39|0xff3a|0xff3b|0xff3c|0xff3d|0xff3e|0xff3f|0xffa8)"; action "kldload -n uftdi"; }; @@ -1057,7 +1073,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0586"; - match "product" "(0x3416|0x341a)"; + match "product" "(0x3416|0x341a|0x341e)"; action "kldload -n if_run"; }; @@ -1097,7 +1113,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x05ac"; - match "product" "(0x020d|0x020e|0x020f|0x0215|0x0217|0x0218|0x0219|0x021a|0x021b|0x021c)"; + match "product" "(0x020d|0x020e|0x020f|0x0210|0x0214|0x0215|0x0216|0x0217|0x0218|0x0219|0x021a|0x021b|0x021c)"; action "kldload -n atp"; }; @@ -2353,7 +2369,23 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0b05"; - match "product" "(0x17b5|0x17cb)"; + match "product" "0x17b5"; + action "kldload -n ng_ubt"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x0b05"; + match "product" "0x17ba"; + action "kldload -n if_urtwn"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x0b05"; + match "product" "0x17cb"; action "kldload -n ng_ubt"; }; @@ -2481,7 +2513,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0bda"; - match "product" "(0x018a|0x317f)"; + match "product" "(0x0179|0x018a|0x317f)"; action "kldload -n if_urtwn"; }; @@ -2513,7 +2545,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0bda"; - match "product" "(0x8176|0x8176|0x8177|0x8178|0x817a|0x817b|0x817c|0x817d|0x817e)"; + match "product" "(0x8176|0x8176|0x8177|0x8178|0x8179|0x817a|0x817b|0x817c|0x817d|0x817e)"; action "kldload -n if_urtwn"; }; @@ -2925,6 +2957,14 @@ nomatch 32 { action "kldload -n if_urtwn"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x0df6"; + match "product" "0x0072"; + action "kldload -n if_axge"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -3577,7 +3617,23 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x12d1"; - match "product" "(0x1001|0x1003|0x1004|0x1401|0x1402|0x1403|0x1404|0x1405|0x1406|0x1407|0x1408|0x1409|0x140a|0x140b|0x140c|0x140d|0x140e|0x140f|0x1410|0x1411|0x1412|0x1413|0x1414|0x1415|0x1416|0x1417|0x1418|0x1419|0x141a|0x141b|0x141c|0x141d|0x141e|0x141f|0x1420|0x1421|0x1422|0x1423|0x1424|0x1425|0x1426|0x1427|0x1428|0x1429|0x142a|0x142b|0x142c|0x142d|0x142e|0x142f|0x1430|0x1431|0x1432|0x1433|0x1434|0x1435|0x1436|0x1437|0x1438|0x1439|0x143a|0x143b|0x143c|0x143d|0x143e|0x143f|0x1446|0x1464|0x1465|0x14ac|0x14c9|0x14d1|0x14fe|0x1505|0x1506|0x1520|0x1521|0x1803|0x1c05|0x1c0b)"; + match "product" "(0x1001|0x1003|0x1004|0x1401|0x1402|0x1403|0x1404|0x1405|0x1406|0x1407|0x1408|0x1409|0x140a|0x140b|0x140c|0x140d|0x140e|0x140f|0x1410|0x1411|0x1412|0x1413|0x1414|0x1415|0x1416|0x1417|0x1418|0x1419|0x141a|0x141b|0x141c|0x141d|0x141e|0x141f|0x1420|0x1421|0x1422|0x1423|0x1424|0x1425|0x1426|0x1427|0x1428|0x1429|0x142a|0x142b|0x142c|0x142d|0x142e|0x142f|0x1430|0x1431|0x1432|0x1433|0x1434|0x1435|0x1436|0x1437|0x1438|0x1439|0x143a|0x143b|0x143c|0x143d|0x143e|0x143f|0x1446|0x1464|0x1465|0x14ac|0x14c9|0x14d1|0x14fe|0x1505|0x1506|0x1520|0x1521)"; + action "kldload -n u3g"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x12d1"; + match "product" "0x155b"; + action "kldload -n if_cdce"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x12d1"; + match "product" "(0x1803|0x1c05|0x1c0b)"; action "kldload -n u3g"; }; @@ -3753,7 +3809,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x1410"; - match "product" "(0x1100|0x1110|0x1120|0x1130|0x1400|0x1410|0x1420|0x1430|0x1450|0x2100|0x2110|0x2120|0x2130|0x2400|0x2410|0x2420|0x4100|0x4400|0x5010|0x5020|0x5041|0x5100|0x6000|0x6002|0x7042)"; + match "product" "(0x1100|0x1110|0x1120|0x1130|0x1400|0x1410|0x1420|0x1430|0x1450|0x2100|0x2110|0x2120|0x2130|0x2400|0x2410|0x2420|0x4100|0x4400|0x5010|0x5020|0x5041|0x5100|0x6000|0x6002|0x7001|0x7031|0x7042)"; action "kldload -n u3g"; }; @@ -4553,7 +4609,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x1cf1"; - match "product" "(0x0001|0x0004)"; + match "product" "(0x0001|0x0004|0x0022)"; action "kldload -n uftdi"; }; @@ -4565,6 +4621,14 @@ nomatch 32 { action "kldload -n u3g"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x1d34"; + match "product" "0x0004"; + action "kldload -n uled"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -4633,7 +4697,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x2001"; - match "product" "(0x3307|0x3308|0x3309|0x330a|0x330d)"; + match "product" "(0x3307|0x3308|0x3309|0x330a|0x330d|0x330f)"; action "kldload -n if_urtwn"; }; @@ -4665,7 +4729,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x2001"; - match "product" "(0x3c09|0x3c0a|0x3c15|0x3c1a|0x3c1b|0x3c1f)"; + match "product" "(0x3c09|0x3c0a|0x3c15|0x3c1a|0x3c1b|0x3c1f|0x3c20)"; action "kldload -n if_run"; }; @@ -4685,6 +4749,14 @@ nomatch 32 { action "kldload -n if_aue"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x2001"; + match "product" "0x4a00"; + action "kldload -n if_axge"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -5229,6 +5301,36 @@ nomatch 32 { action "kldload -n ng_ubt"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x12d1"; + match "intclass" "0xff"; + match "intsubclass" "0x02"; + match "intprotocol" "0x16"; + action "kldload -n if_cdce"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x12d1"; + match "intclass" "0xff"; + match "intsubclass" "0x02"; + match "intprotocol" "0x46"; + action "kldload -n if_cdce"; +}; + +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x12d1"; + match "intclass" "0xff"; + match "intsubclass" "0x02"; + match "intprotocol" "0x76"; + action "kldload -n if_cdce"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -5399,5 +5501,5 @@ nomatch 32 { action "kldload -n umass"; }; -# 2621 USB entries processed +# 2643 USB entries processed diff --git a/etc/mail/Makefile b/etc/mail/Makefile index 3f085cc2d780..510b0243f984 100644 --- a/etc/mail/Makefile +++ b/etc/mail/Makefile @@ -69,7 +69,7 @@ SENDMAIL_MC!= hostname SENDMAIL_MC:= ${SENDMAIL_MC}.mc ${SENDMAIL_MC}: - cp freebsd.mc ${SENDMAIL_MC} + cp -f freebsd.mc ${SENDMAIL_MC} .endif .ifndef SENDMAIL_SUBMIT_MC @@ -77,7 +77,7 @@ SENDMAIL_SUBMIT_MC!= hostname SENDMAIL_SUBMIT_MC:= ${SENDMAIL_SUBMIT_MC}.submit.mc ${SENDMAIL_SUBMIT_MC}: - cp freebsd.submit.mc ${SENDMAIL_SUBMIT_MC} + cp -f freebsd.submit.mc ${SENDMAIL_SUBMIT_MC} .endif INSTALL_CF= ${SENDMAIL_MC:R}.cf diff --git a/etc/motd b/etc/motd index 50ce29d4b344..e70e98d025c9 100644 --- a/etc/motd +++ b/etc/motd @@ -2,24 +2,20 @@ FreeBSD ?.?.? (UNKNOWN) Welcome to FreeBSD! -Before seeking technical support, please use the following resources: +Release Notes, Errata: https://www.FreeBSD.org/releases/ +Security Advisories: https://www.FreeBSD.org/security/ +FreeBSD Handbook: https://www.FreeBSD.org/handbook/ +FreeBSD FAQ: https://www.FreeBSD.org/faq/ +Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ +FreeBSD Forums: https://forums.FreeBSD.org/ -o Security advisories and updated errata information for all releases are - at http://www.FreeBSD.org/releases/ - always consult the ERRATA section - for your release first as it's updated frequently. +Documents installed with the system are in the /usr/local/share/doc/freebsd/ +directory, or can be installed later with: pkg install en-freebsd-doc +For other languages, replace "en" with a language code like de or fr. -o The Handbook and FAQ documents are at http://www.FreeBSD.org/ and, - along with the mailing lists, can be searched by going to - http://www.FreeBSD.org/search/. If the doc package has been installed - (or fetched via pkg install lang-freebsd-doc, where lang is the - 2-letter language code, e.g. en), they are also available formatted - in /usr/local/share/doc/freebsd. - -If you still have a question or problem, please take the output of -`uname -a', along with any relevant error messages, and email it -as a question to the questions@FreeBSD.org mailing list. If you are -unfamiliar with FreeBSD's directory layout, please refer to the hier(7) -manual page. If you are not familiar with manual pages, type `man man'. +Show the version of FreeBSD installed: uname -a +Please include that output and any error messages when posting questions. +Introduction to manual pages: man man +FreeBSD directory layout: man hier Edit /etc/motd to change this login announcement. - diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 5438176e0c5b..3a9d0e001db4 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -89,6 +89,8 @@ .. libnv .. + libproc + .. libutil .. .. @@ -253,6 +255,8 @@ .. m4 .. + mkimg + .. ncal .. printf @@ -283,6 +287,8 @@ .. newsyslog .. + pw + .. sa .. .. diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 084850014d04..977cf754d451 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -108,6 +108,8 @@ .. bsdinstall .. + hyperv + .. lpr ru .. diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist index 990c23c9abb3..7d4af0be5ab6 100644 --- a/etc/mtree/BSD.var.dist +++ b/etc/mtree/BSD.var.dist @@ -42,6 +42,8 @@ .. freebsd-update mode=0700 .. + hyperv mode=0700 + .. ipf mode=0700 .. pkg diff --git a/etc/network.subr b/etc/network.subr index f67622d51efd..520c9e86a7e5 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -25,9 +25,7 @@ # $FreeBSD$ # IFCONFIG_CMD="/sbin/ifconfig" - -# Maximum number of addresses expanded from a address range specification. -_IPEXPANDMAX=31 +: ${netif_ipexpand_max:=2048} # # Subroutines commonly used from network startup scripts. @@ -886,8 +884,8 @@ ifalias_expand_addr_inet() _ipcount=$_iplow while [ "$_ipcount" -le "$_iphigh" ]; do _retstr="${_retstr} ${_iphead}${_iphead:+.}${_ipcount}${_iptail:+.}${_iptail}${_plen:+/}${_plen}" - if [ $_ipcount -gt $(($_iplow + $_IPEXPANDMAX)) ]; then - warn "Range specification is too large (${_iphead}${_iphead:+.}${_iplow}${_iptail:+.}${_iptail}-${_iphead}${_iphead:+.}${_iphigh}${_iptail:+.}${_iptail}). ${_iphead}${_iphead:+.}${_iplow}${_iptail:+.}${_iptail}-${_iphead}${_iphead:+.}${_ipcount}${_iptail:+.}${_iptail} was processed." + if [ $_ipcount -gt $(($_iplow + $netif_ipexpand_max)) ]; then + warn "Range specification is too large (${_iphead}${_iphead:+.}${_iplow}${_iptail:+.}${_iptail}-${_iphead}${_iphead:+.}${_iphigh}${_iptail:+.}${_iptail}). ${_iphead}${_iphead:+.}${_iplow}${_iptail:+.}${_iptail}-${_iphead}${_iphead:+.}${_ipcount}${_iptail:+.}${_iptail} was processed. Increase \$netif_ipexpand_max in rc.conf." break else _ipcount=$(($_ipcount + 1)) @@ -976,9 +974,9 @@ ifalias_expand_addr_inet6() $_ipleft $_ipcount $_ipright \ ${_plen:+/}$_plen` _retstr="$_retstr $_r" - if [ $_ipcount -gt $(($_iplow + $_IPEXPANDMAX)) ] + if [ $_ipcount -gt $(($_iplow + $netif_ipexpand_max)) ] then - warn "Range specification is too large $(printf '(%s:%04x%s-%s:%04x%s)' $_ipleft $_iplow $_ipright $_ipleft $_iphigh $_ipright). $(printf '%s:%04x%s-%s:%04x%s' $_ipleft $_iplow $_ipright $_ipleft $_ipcount $_ipright) was processed." + warn "Range specification is too large $(printf '(%s:%x%s-%s:%x%s)' "$_ipleft" "$_iplow" "$_ipright" "$_ipleft" "$_iphigh" "$_ipright"). $(printf '%s:%x%s-%s:%x%s' "$_ipleft" "$_iplow" "$_ipright" "$_ipleft" "$_ipcount" "$_ipright") was processed. Increase \$netif_ipexpand_max in rc.conf." break else _ipcount=$(($_ipcount + 1)) diff --git a/etc/periodic/daily/110.clean-tmps b/etc/periodic/daily/110.clean-tmps index eef3bc6545b5..67bcec6f00d3 100755 --- a/etc/periodic/daily/110.clean-tmps +++ b/etc/periodic/daily/110.clean-tmps @@ -45,8 +45,8 @@ case "$daily_clean_tmps_enable" in rc=$(for dir in $daily_clean_tmps_dirs do [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { - find -d . -type f $args -delete $print - find -d . ! -name . -type d $dargs -delete $print + find -x -d . -type f $args -delete $print + find -x -d . ! -name . -type d $dargs -delete $print } | sed "s,^\\., $dir," done | tee /dev/stderr | wc -l) [ -z "$print" ] && rc=0 diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 64e83ac8ca50..12c87db584cd 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -44,7 +44,6 @@ FILES= DAEMON \ dumpon \ faith \ fsck \ - ftp-proxy \ ftpd \ gbde \ geli \ @@ -73,7 +72,6 @@ FILES= DAEMON \ jail \ kadmind \ kdc \ - keyserv \ kfd \ kld \ kldxref \ @@ -133,7 +131,6 @@ FILES= DAEMON \ rpcbind \ rtadvd \ rtsold \ - rwho \ savecore \ sdpd \ securelevel \ @@ -169,18 +166,6 @@ FILES= DAEMON \ zfs \ zvol -.if ${MK_OFED} != "no" -_opensm= opensm -.endif - -.if ${MK_OPENSSH} != "no" -_sshd= sshd -.endif - -.if ${MK_NS_CACHING} != "no" -_nscd= nscd -.endif - .if ${MK_BLUETOOTH} != "no" _bluetooth= bluetooth _bthidd= bthidd @@ -192,6 +177,30 @@ _ubthidhci= ubthidhci _casperd= casperd .endif +.if ${MK_NS_CACHING} != "no" +_nscd= nscd +.endif + +.if ${MK_OFED} != "no" +_opensm= opensm +.endif + +.if ${MK_OPENSSL} != "no" +FILES+= keyserv +.endif + +.if ${MK_OPENSSH} != "no" +_sshd= sshd +.endif + +.if ${MK_PF} != "no" +FILES+= ftp-proxy +.endif + +.if ${MK_RCMDS} != "no" +FILES+= rwho +.endif + .if ${MK_UNBOUND} != "no" _unbound= local_unbound .endif diff --git a/etc/rc.d/ipropd_slave b/etc/rc.d/ipropd_slave index 803281e0e9fe..70c4c70e98cc 100755 --- a/etc/rc.d/ipropd_slave +++ b/etc/rc.d/ipropd_slave @@ -17,15 +17,15 @@ start_precmd=${name}_start_precmd ipropd_slave_start_precmd() { - if [ -z "$ipropd_slave_masters" ]; then - warn "\$ipropd_slave_masters is empty." + if [ -z "$ipropd_slave_master" ]; then + warn "\$ipropd_slave_master is empty." return 1 fi command_args=" \ $command_args \ --keytab=\"$ipropd_slave_keytab\" \ --detach \ - $ipropd_slave_masters" + $ipropd_slave_master" } load_rc_config $name diff --git a/etc/rc.d/jail b/etc/rc.d/jail index cf1c6e2fae9d..0b886fd56b59 100755 --- a/etc/rc.d/jail +++ b/etc/rc.d/jail @@ -321,8 +321,6 @@ jail_extract_address() elif [ "${_type}" = "inet6" ]; then # In case _mask is not set for IPv6, use /128. _mask=${_mask:-/128} - warn "$_type $_addr: an IPv6 address should always be " \ - "specified with a prefix length. /128 is used." fi } diff --git a/etc/rc.d/syscons b/etc/rc.d/syscons index 0dc41ad5f0b8..a60ac4c7318d 100755 --- a/etc/rc.d/syscons +++ b/etc/rc.d/syscons @@ -167,7 +167,7 @@ syscons_configure_keyboard() # keymap # case ${keymap} in - [Nn][Oo] | '') + NO | '') ;; *) sc_init diff --git a/etc/rc.subr b/etc/rc.subr index ff4e898597ca..4b3fddf5d929 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -68,6 +68,39 @@ list_vars() done; } } +# set_rcvar [var] [defval] [desc] +# +# Echo or define a rc.conf(5) variable name. Global variable +# $rcvars is used. +# +# If no argument is specified, echo "${name}_enable". +# +# If only a var is specified, echo "${var}_enable". +# +# If var and defval are specified, the ${var} is defined as +# rc.conf(5) variable and the default value is ${defvar}. An +# optional argument $desc can also be specified to add a +# description for that. +# +set_rcvar() +{ + local _var + + case $# in + 0) echo ${name}_enable ;; + 1) echo ${1}_enable ;; + *) + debug "set_rcvar: \$$1=$2 is added" \ + " as a rc.conf(5) variable." + _var=$1 + rcvars="${rcvars# } $_var" + eval ${_var}_defval=\"$2\" + shift 2 + eval ${_var}_desc=\"$*\" + ;; + esac +} + # set_rcvar_obsolete oldvar [newvar] [msg] # Define obsolete variable. # Global variable $rcvars_obsolete is used. @@ -76,7 +109,7 @@ set_rcvar_obsolete() { local _var _var=$1 - debug "rcvar_obsolete: \$$1(old) -> \$$2(new) is defined" + debug "set_rcvar_obsolete: \$$1(old) -> \$$2(new) is defined" rcvars_obsolete="${rcvars_obsolete# } $1" eval ${1}_newvar=\"$2\" @@ -1091,8 +1124,8 @@ $command $rc_flags $command_args" echo "" fi echo "#" - # Get unique vars in $rcvar - for _v in $rcvar; do + # Get unique vars in $rcvar $rcvars + for _v in $rcvar $rcvars; do case $v in $_v\ *|\ *$_v|*\ $_v\ *) ;; *) v="${v# } $_v" ;; @@ -1238,7 +1271,7 @@ run_rc_script() unset name command command_args command_interpreter \ extra_commands pidfile procname \ - rcvar rcvars_obsolete required_dirs required_files \ + rcvar rcvars rcvars_obsolete required_dirs required_files \ required_vars eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd @@ -1306,7 +1339,7 @@ load_rc_config() done # Set defaults if defined. - for _var in $rcvar; do + for _var in $rcvar $rcvars; do eval _defval=\$${_var}_defval if [ -n "$_defval" ]; then eval : \${$_var:=\$${_var}_defval} @@ -1966,6 +1999,22 @@ check_required_after() return 0 } +# check_jail mib +# Return true if security.jail.$mib exists and set to 1. + +check_jail() +{ + local _mib _v + + _mib=$1 + if _v=$(${SYSCTL_N} "security.jail.$_mib" 2> /dev/null); then + case $_v in + 1) return 0;; + esac + fi + return 1 +} + # check_kern_features mib # Return existence of kern.features.* sysctl MIB as true or # false. The result will be cached in $_rc_cache_kern_features_ diff --git a/games/factor/factor.6 b/games/factor/factor.6 index a4d35e9fe78d..ba82f1407237 100644 --- a/games/factor/factor.6 +++ b/games/factor/factor.6 @@ -89,8 +89,7 @@ The value must not be greater than the maximum. The default and maximum value of .Ar stop -is 4294967295 on 32-bit architectures -and 18446744073709551615 on 64-bit ones. +is 3825123056546413050. .Pp When the .Nm primes @@ -120,3 +119,9 @@ cannot handle the factor list, .Nm primes will not get you a world record. +.Pp +.Nm primes +is unable to list primes between 3825123056546413050 and 18446744073709551615 +since it relies on strong pseudoprime tests after sieving, and nobody has +proven how many strong pseudoprime tests are required to prove primality for +integers larger than 3825123056546413050. diff --git a/games/factor/factor.c b/games/factor/factor.c index 8b76c175e2a8..19fe830ca59d 100644 --- a/games/factor/factor.c +++ b/games/factor/factor.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -227,7 +228,7 @@ pr_fact(BIGNUM *val) /* Divide factor out until none are left. */ do { - printf(hflag ? " 0x%lx" : " %lu", *fact); + printf(hflag ? " 0x%" PRIx64 "" : " %" PRIu64 "", *fact); BN_div_word(val, (BN_ULONG)*fact); } while (BN_mod_word(val, (BN_ULONG)*fact) == 0); diff --git a/games/primes/Makefile b/games/primes/Makefile index 13c9048a91cf..bfc4147883bf 100644 --- a/games/primes/Makefile +++ b/games/primes/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ PROG= primes -SRCS= pattern.c pr_tbl.c primes.c +SRCS= pattern.c pr_tbl.c primes.c spsp.c MAN= DPADD= ${LIBM} LDADD= -lm diff --git a/games/primes/primes.c b/games/primes/primes.c index 33838ee933da..a1c95c2a8a02 100644 --- a/games/primes/primes.c +++ b/games/primes/primes.c @@ -64,6 +64,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -111,10 +112,10 @@ main(int argc, char *argv[]) argv += optind; start = 0; - stop = BIG; + stop = SPSPMAX; /* - * Convert low and high args. Strtoul(3) sets errno to + * Convert low and high args. Strtoumax(3) sets errno to * ERANGE if the number is too large, but, if there's * a leading minus sign it returns the negation of the * result of the conversion, which we'd rather disallow. @@ -126,18 +127,20 @@ main(int argc, char *argv[]) errx(1, "negative numbers aren't permitted."); errno = 0; - start = strtoul(argv[0], &p, 0); + start = strtoumax(argv[0], &p, 0); if (errno) err(1, "%s", argv[0]); if (*p != '\0') errx(1, "%s: illegal numeric format.", argv[0]); errno = 0; - stop = strtoul(argv[1], &p, 0); + stop = strtoumax(argv[1], &p, 0); if (errno) err(1, "%s", argv[1]); if (*p != '\0') errx(1, "%s: illegal numeric format.", argv[1]); + if (stop > SPSPMAX) + errx(1, "%s: stop value too large.", argv[1]); break; case 1: /* Start on the command line. */ @@ -145,7 +148,7 @@ main(int argc, char *argv[]) errx(1, "negative numbers aren't permitted."); errno = 0; - start = strtoul(argv[0], &p, 0); + start = strtoumax(argv[0], &p, 0); if (errno) err(1, "%s", argv[0]); if (*p != '\0') @@ -186,7 +189,7 @@ read_num_buf(void) if (*p == '-') errx(1, "negative numbers aren't permitted."); errno = 0; - val = strtoul(buf, &p, 0); + val = strtoumax(buf, &p, 0); if (errno) err(1, "%s", buf); if (*p != '\n') @@ -241,7 +244,7 @@ primes(ubig start, ubig stop) for (p = &prime[0], factor = prime[0]; factor < stop && p <= pr_limit; factor = *(++p)) { if (factor >= start) { - printf(hflag ? "0x%lx\n" : "%lu\n", factor); + printf(hflag ? "%" PRIx64 "\n" : "%" PRIu64 "\n", factor); } } /* return early if we are done */ @@ -304,7 +307,11 @@ primes(ubig start, ubig stop) */ for (q = table; q < tab_lim; ++q, start+=2) { if (*q) { - printf(hflag ? "0x%lx\n" : "%lu\n", start); + if (start > SIEVEMAX) { + if (!isprime(start)) + continue; + } + printf(hflag ? "%" PRIx64 "\n" : "%" PRIu64 "\n", start); } } } diff --git a/games/primes/primes.h b/games/primes/primes.h index 0951bbf5ad9c..3a18fc7dd127 100644 --- a/games/primes/primes.h +++ b/games/primes/primes.h @@ -41,8 +41,10 @@ * chongo /\oo/\ */ +#include + /* ubig is the type that holds a large unsigned value */ -typedef unsigned long ubig; /* must be >=32 bit unsigned value */ +typedef uint64_t ubig; /* must be >=32 bit unsigned value */ #define BIG ULONG_MAX /* largest value will sieve */ /* bytes in sieve table (must be > 3*5*7*11) */ @@ -57,6 +59,9 @@ typedef unsigned long ubig; /* must be >=32 bit unsigned value */ extern const ubig prime[]; extern const ubig *const pr_limit; /* largest prime in the prime array */ +/* Maximum size sieving alone can handle. */ +#define SIEVEMAX 4295098368ULL + /* * To avoid excessive sieves for small factors, we use the table below to * setup our sieve blocks. Each element represents an odd number starting @@ -64,3 +69,9 @@ extern const ubig *const pr_limit; /* largest prime in the prime array */ */ extern const char pattern[]; extern const size_t pattern_size; /* length of pattern array */ + +/* Test for primality using strong pseudoprime tests. */ +int isprime(ubig); + +/* Maximum value which the SPSP code can handle. */ +#define SPSPMAX 3825123056546413050ULL diff --git a/games/primes/spsp.c b/games/primes/spsp.c new file mode 100644 index 000000000000..f61acd63b117 --- /dev/null +++ b/games/primes/spsp.c @@ -0,0 +1,181 @@ +/*- + * Copyright (c) 2014 Colin Percival + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 "primes.h" + +/* Return a * b % n, where 0 <= a, b < 2^63, 0 < n < 2^63. */ +static uint64_t +mulmod(uint64_t a, uint64_t b, uint64_t n) +{ + uint64_t x = 0; + + while (b != 0) { + if (b & 1) + x = (x + a) % n; + a = (a + a) % n; + b >>= 1; + } + + return (x); +} + +/* Return a^r % n, where 0 <= a < 2^63, 0 < n < 2^63. */ +static uint64_t +powmod(uint64_t a, uint64_t r, uint64_t n) +{ + uint64_t x = 1; + + while (r != 0) { + if (r & 1) + x = mulmod(a, x, n); + a = mulmod(a, a, n); + r >>= 1; + } + + return (x); +} + +/* Return non-zero if n is a strong pseudoprime to base p. */ +static int +spsp(uint64_t n, uint64_t p) +{ + uint64_t x; + uint64_t r = n - 1; + int k = 0; + + /* Compute n - 1 = 2^k * r. */ + while ((r & 1) == 0) { + k++; + r >>= 1; + } + + /* Compute x = p^r mod n. If x = 1, n is a p-spsp. */ + x = powmod(p, r, n); + if (x == 1) + return (1); + + /* Compute x^(2^i) for 0 <= i < n. If any are -1, n is a p-spsp. */ + while (k > 0) { + if (x == n - 1) + return (1); + x = powmod(x, 2, n); + k--; + } + + /* Not a p-spsp. */ + return (0); +} + +/* Test for primality using strong pseudoprime tests. */ +int +isprime(ubig _n) +{ + uint64_t n = _n; + + /* + * Values from: + * C. Pomerance, J.L. Selfridge, and S.S. Wagstaff, Jr., + * The pseudoprimes to 25 * 10^9, Math. Comp. 35(151):1003-1026, 1980. + */ + + /* No SPSPs to base 2 less than 2047. */ + if (!spsp(n, 2)) + return (0); + if (n < 2047ULL) + return (1); + + /* No SPSPs to bases 2,3 less than 1373653. */ + if (!spsp(n, 3)) + return (0); + if (n < 1373653ULL) + return (1); + + /* No SPSPs to bases 2,3,5 less than 25326001. */ + if (!spsp(n, 5)) + return (0); + if (n < 25326001ULL) + return (1); + + /* No SPSPs to bases 2,3,5,7 less than 3215031751. */ + if (!spsp(n, 7)) + return (0); + if (n < 3215031751ULL) + return (1); + + /* + * Values from: + * G. Jaeschke, On strong pseudoprimes to several bases, + * Math. Comp. 61(204):915-926, 1993. + */ + + /* No SPSPs to bases 2,3,5,7,11 less than 2152302898747. */ + if (!spsp(n, 11)) + return (0); + if (n < 2152302898747ULL) + return (1); + + /* No SPSPs to bases 2,3,5,7,11,13 less than 3474749660383. */ + if (!spsp(n, 13)) + return (0); + if (n < 3474749660383ULL) + return (1); + + /* No SPSPs to bases 2,3,5,7,11,13,17 less than 341550071728321. */ + if (!spsp(n, 17)) + return (0); + if (n < 341550071728321ULL) + return (1); + + /* No SPSPs to bases 2,3,5,7,11,13,17,19 less than 341550071728321. */ + if (!spsp(n, 19)) + return (0); + if (n < 341550071728321ULL) + return (1); + + /* + * Value from: + * Y. Jiang and Y. Deng, Strong pseudoprimes to the first eight prime + * bases, Math. Comp. 83(290):2915-2924, 2014. + */ + + /* No SPSPs to bases 2..23 less than 3825123056546413051. */ + if (!spsp(n, 23)) + return (0); + if (n < 3825123056546413051) + return (1); + + /* We can't handle values larger than this. */ + assert(n <= SPSPMAX); + + /* UNREACHABLE */ + return (0); +} diff --git a/gnu/lib/csu/Makefile b/gnu/lib/csu/Makefile index dee77dfe5349..e1224ca5d9f0 100644 --- a/gnu/lib/csu/Makefile +++ b/gnu/lib/csu/Makefile @@ -24,7 +24,7 @@ CFLAGS+= -I${GCCLIB}/include -I${GCCDIR}/config -I${GCCDIR} -I. \ CRTS_CFLAGS= -DCRTSTUFFS_O -DSHARED ${PICFLAG} MKDEP= -DCRT_BEGIN -.if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${TARGET_CPUARCH} == "arm" CFLAGS+= -DTARGET_ARM_EABI .endif diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile index 8480ef475070..4fd8b8d45147 100644 --- a/gnu/lib/libgcc/Makefile +++ b/gnu/lib/libgcc/Makefile @@ -15,7 +15,7 @@ MK_SSP= no .include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt" -.if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${TARGET_CPUARCH} == "arm" CFLAGS+= -DTARGET_ARM_EABI .endif @@ -56,7 +56,7 @@ LIB2FUNCS+= _fixuns${mode}si .endfor # Likewise double-word routines. -.if ${TARGET_CPUARCH} != "arm" || ${MK_ARM_EABI} == "no" +.if ${TARGET_CPUARCH} != "arm" # These are implemented in an ARM specific file but will not be filtered out .for mode in sf df xf tf LIB2FUNCS+= _fix${mode}di _fixuns${mode}di @@ -117,14 +117,10 @@ CFLAGS.clang+= -fheinous-gnu-extensions LIB1ASMSRC = lib1funcs.asm LIB1ASMFUNCS = _dvmd_tls _bb_init_func -.if ${MK_ARM_EABI} != "no" LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c # Some compilers generate __aeabi_ functions libgcc_s is missing DPADD+= ${LIBCOMPILER_RT} LDADD+= -lcompiler_rt -.else -LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c -.endif .endif .if ${TARGET_CPUARCH} == mips @@ -319,7 +315,7 @@ CLEANFILES += cs-*.h option* SHLIB_MKMAP = ${GCCDIR}/mkmap-symver.awk SHLIB_MKMAP_OPTS = SHLIB_MAPFILES = ${GCCDIR}/libgcc-std.ver -.if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${TARGET_CPUARCH} == "arm" SHLIB_MAPFILES += ${GCCDIR}/config/arm/libgcc-bpabi.ver .endif VERSION_MAP = libgcc.map diff --git a/gnu/lib/libgcov/Makefile b/gnu/lib/libgcov/Makefile index e2b80744cf5f..7582720f53b7 100644 --- a/gnu/lib/libgcov/Makefile +++ b/gnu/lib/libgcov/Makefile @@ -17,7 +17,7 @@ CFLAGS+= -D_PTHREADS -DGTHREAD_USE_WEAK CFLAGS+= -I${.CURDIR}/../../usr.bin/cc/cc_tools \ -I${GCCLIB}/include -I${GCCDIR}/config -I${GCCDIR} -I. -.if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${TARGET_CPUARCH} == "arm" CFLAGS+= -DTARGET_ARM_EABI .endif diff --git a/gnu/lib/libstdc++/Makefile b/gnu/lib/libstdc++/Makefile index fa1d67e7ce64..98a08f416499 100644 --- a/gnu/lib/libstdc++/Makefile +++ b/gnu/lib/libstdc++/Makefile @@ -16,9 +16,6 @@ LIB= stdc++ SHLIB_MAJOR= 6 CFLAGS+= -DIN_GLIBCPP_V3 -DHAVE_CONFIG_H -.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} == "no" -CFLAGS+= -D_GLIBCXX_SJLJ_EXCEPTIONS=1 -.endif CFLAGS+= -I${.CURDIR} -I${SUPDIR} -I${GCCDIR} -I${SRCDIR}/include CFLAGS+= -I${GCCLIB}/include -I${SRCDIR}/include -I. CFLAGS+= -frandom-seed=RepeatabilityConsideredGood @@ -596,7 +593,7 @@ gthr-default.h: ${GCCDIR}/gthr-posix.h CLEANFILES+= ${THRHDRS} -.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${MACHINE_CPUARCH} == "arm" unwind.h: ${GCCDIR}/config/arm/unwind-arm.h .else unwind.h: ${GCCDIR}/unwind-generic.h diff --git a/gnu/lib/libsupc++/Makefile b/gnu/lib/libsupc++/Makefile index c7cc30e53787..0531a73ae8ff 100644 --- a/gnu/lib/libsupc++/Makefile +++ b/gnu/lib/libsupc++/Makefile @@ -22,9 +22,6 @@ SRCS+= del_op.cc del_opnt.cc del_opv.cc del_opvnt.cc eh_alloc.cc eh_arm.cc \ SRCS+= cp-demangle.c CFLAGS+= -DIN_GLIBCPP_V3 -DHAVE_CONFIG_H -.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} == "no" -CFLAGS+= -D_GLIBCXX_SJLJ_EXCEPTIONS=1 -.endif CFLAGS+= -I${GCCLIB}/include -I${SRCDIR} -I${GCCDIR} CFLAGS+= -I${.CURDIR}/../libstdc++ -I. CFLAGS+= -frandom-seed=RepeatabilityConsideredGood @@ -35,7 +32,7 @@ HDRS= exception new typeinfo cxxabi.h exception_defines.h INCS= ${HDRS:S;^;${SRCDIR}/;} INCSDIR=${INCLUDEDIR}/c++/${GCCVER} -.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${MACHINE_CPUARCH} == "arm" unwind.h: ${GCCDIR}/config/arm/unwind-arm.h .else unwind.h: ${GCCDIR}/unwind-generic.h diff --git a/gnu/usr.bin/cc/Makefile.inc b/gnu/usr.bin/cc/Makefile.inc index dc9779973210..1d66b3dee7ff 100644 --- a/gnu/usr.bin/cc/Makefile.inc +++ b/gnu/usr.bin/cc/Makefile.inc @@ -27,7 +27,7 @@ CSTD?= gnu89 CFLAGS+= -DCROSS_DIRECTORY_STRUCTURE .endif -.if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${TARGET_CPUARCH} == "arm" CFLAGS+= -DTARGET_ARM_EABI .endif diff --git a/gnu/usr.bin/cc/cc_tools/Makefile b/gnu/usr.bin/cc/cc_tools/Makefile index ae7f8b82d17d..af731c13519b 100644 --- a/gnu/usr.bin/cc/cc_tools/Makefile +++ b/gnu/usr.bin/cc/cc_tools/Makefile @@ -51,10 +51,8 @@ TARGET_INC+= ${GCC_CPU}/elf.h .endif .if ${TARGET_CPUARCH} == "arm" TARGET_INC+= ${GCC_CPU}/aout.h -.if ${MK_ARM_EABI} != "no" TARGET_INC+= ${GCC_CPU}/bpabi.h .endif -.endif .if ${TARGET_ARCH} == "powerpc64" TARGET_INC+= ${GCC_CPU}/biarch64.h TARGET_INC+= ${GCC_CPU}/default64.h @@ -352,7 +350,7 @@ gthr-default.h: ${GCCDIR}/gthr-posix.h GENSRCS+= gthr-default.h -.if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${TARGET_CPUARCH} == "arm" unwind.h: ${GCCDIR}/config/arm/unwind-arm.h .else unwind.h: ${GCCDIR}/unwind-generic.h diff --git a/include/unistd.h b/include/unistd.h index f1913b693458..0329122f7e7c 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -453,7 +453,6 @@ int encrypt(char *, int); long gethostid(void); int lockf(int, int, off_t); int nice(int); -int setpgrp(pid_t _pid, pid_t _pgrp); /* obsoleted by setpgid() */ int setregid(gid_t, gid_t); int setreuid(uid_t, uid_t); @@ -567,6 +566,7 @@ int setkey(const char *); int setlogin(const char *); int setloginclass(const char *); void *setmode(const char *); +int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */ void setproctitle(const char *_fmt, ...) __printf0like(1, 2); int setresgid(gid_t, gid_t, gid_t); int setresuid(uid_t, uid_t, uid_t); diff --git a/kerberos5/lib/libasn1/Makefile b/kerberos5/lib/libasn1/Makefile index dc1de5c61506..02e6a4975fd4 100644 --- a/kerberos5/lib/libasn1/Makefile +++ b/kerberos5/lib/libasn1/Makefile @@ -112,10 +112,10 @@ ${GEN_KX509}: kx509.asn1 .SUFFIXES: .h .c .x .hx .x.c: - cp ${.IMPSRC} ${.TARGET} + cp -f ${.IMPSRC} ${.TARGET} .hx.h: - cp ${.IMPSRC} ${.TARGET} + cp -f ${.IMPSRC} ${.TARGET} .include diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk index 3b30fe7b9d56..241d15efa503 100644 --- a/lib/clang/clang.build.mk +++ b/lib/clang/clang.build.mk @@ -22,11 +22,10 @@ CFLAGS+= -fno-strict-aliasing TARGET_ARCH?= ${MACHINE_ARCH} BUILD_ARCH?= ${MACHINE_ARCH} -.if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \ - ${MK_ARM_EABI} != "no" -TARGET_ABI= gnueabi -.elif ${TARGET_ARCH} == "armv6hf" +.if ${TARGET_ARCH:Marm*hf*} != "" TARGET_ABI= gnueabihf +.elif ${TARGET_ARCH:Marm*} != "" +TARGET_ABI= gnueabi .else TARGET_ABI= unknown .endif diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 5a02e51b6ca4..ad3cc7415d7d 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -151,11 +151,11 @@ KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ libkern: libkern.gen libkern.${LIBC_ARCH} libkern.gen: ${KQSRCS} ${KSRCS} - cp -p ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern + cp -fp ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern libkern.${LIBC_ARCH}:: ${KMSRCS} .if defined(KMSRCS) && !empty(KMSRCS) - cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} + cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} .endif .include diff --git a/lib/libc/arm/Makefile.inc b/lib/libc/arm/Makefile.inc index 6e61dcd9e1c8..418f54d1d51a 100644 --- a/lib/libc/arm/Makefile.inc +++ b/lib/libc/arm/Makefile.inc @@ -9,10 +9,9 @@ SOFTFLOAT_BITS=32 MDSRCS+=machdep_ldisd.c SYM_MAPS+=${LIBC_SRCTOP}/arm/Symbol.map -.if ${MK_ARM_EABI} == "no" -# This contains the symbols that were removed when moving to the ARM EABI -SYM_MAPS+=${LIBC_SRCTOP}/arm/Symbol_oabi.map -.else .include "${LIBC_SRCTOP}/arm/aeabi/Makefile.inc" + +.if ${MACHINE_ARCH:Marm*hf*} != "" +SYM_MAPS+=${LIBC_SRCTOP}/arm/Symbol_vfp.map .endif diff --git a/lib/libc/arm/Symbol_oabi.map b/lib/libc/arm/Symbol_oabi.map deleted file mode 100644 index 0c22e4a5827d..000000000000 --- a/lib/libc/arm/Symbol_oabi.map +++ /dev/null @@ -1,16 +0,0 @@ -/* - * $FreeBSD$ - */ - -/* - * This only needs to contain symbols that are not listed in - * symbol maps from other parts of libc (i.e., not found in - * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...) - * and are not used in the ARM EABI. - */ -FBSDprivate_1.0 { - __umodsi3; - __modsi3; - __udivsi3; - __divsi3; -}; diff --git a/lib/libc/arm/Symbol_vfp.map b/lib/libc/arm/Symbol_vfp.map new file mode 100644 index 000000000000..82cfcfb574f5 --- /dev/null +++ b/lib/libc/arm/Symbol_vfp.map @@ -0,0 +1,10 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.0 { + fpgetmask; + fpgetround; + fpsetmask; + fpsetround; +}; diff --git a/lib/libc/arm/aeabi/Makefile.inc b/lib/libc/arm/aeabi/Makefile.inc index 0957c922e2d1..c0ce512c81e6 100644 --- a/lib/libc/arm/aeabi/Makefile.inc +++ b/lib/libc/arm/aeabi/Makefile.inc @@ -5,7 +5,7 @@ SRCS+= aeabi_atexit.c \ aeabi_unwind_cpp.c \ aeabi_unwind_exidx.c -.if ${MACHINE_ARCH} != "armv6hf" +.if ${MACHINE_ARCH:Marm*hf*} == "" SRCS+= aeabi_double.c \ aeabi_float.c .endif diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc index 5fd52c2fd589..8efde09ff3e0 100644 --- a/lib/libc/arm/gen/Makefile.inc +++ b/lib/libc/arm/gen/Makefile.inc @@ -6,10 +6,6 @@ SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \ __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \ arm_initfini.c -.if ${MK_ARM_EABI} == "no" -SRCS+= divsi3.S -.endif - .if ${MACHINE_ARCH} == "armv6hf" SRCS+= fpgetmask_vfp.c fpgetround_vfp.c fpgetsticky_vfp.c fpsetmask_vfp.c \ fpsetround_vfp.c fpsetsticky_vfp.c diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 159731c4337b..bdadd55389c3 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -268,7 +268,7 @@ __elf_fdnlist(fd, list) } /* mmap section header table */ - base = mmap(NULL, (size_t)shdr_size, PROT_READ, 0, fd, + base = mmap(NULL, (size_t)shdr_size, PROT_READ, MAP_PRIVATE, fd, (off_t)ehdr.e_shoff); if (base == MAP_FAILED) return (-1); @@ -301,7 +301,7 @@ __elf_fdnlist(fd, list) * making the memory allocation permanent as with malloc/free * (i.e., munmap will return it to the system). */ - base = mmap(NULL, (size_t)symstrsize, PROT_READ, 0, fd, + base = mmap(NULL, (size_t)symstrsize, PROT_READ, MAP_PRIVATE, fd, (off_t)symstroff); if (base == MAP_FAILED) goto done; diff --git a/lib/libc/powerpc/gen/_ctx_start.S b/lib/libc/powerpc/gen/_ctx_start.S index 2d3cfcfcf1ef..4b9fc1d53ae0 100644 --- a/lib/libc/powerpc/gen/_ctx_start.S +++ b/lib/libc/powerpc/gen/_ctx_start.S @@ -41,5 +41,6 @@ * above branch. */ bl PIC_PLT(CNAME(abort)) /* abort */ + END(_cts_start) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/gen/_setjmp.S b/lib/libc/powerpc/gen/_setjmp.S index bbf8644357ec..e28386c24b9c 100644 --- a/lib/libc/powerpc/gen/_setjmp.S +++ b/lib/libc/powerpc/gen/_setjmp.S @@ -58,6 +58,7 @@ ENTRY(_setjmp) stmw %r9,20(%r3) li %r3,0 blr +END(_setjmp) ENTRY(_longjmp) lmw %r9,20(%r3) @@ -68,5 +69,6 @@ ENTRY(_longjmp) bnelr li %r3,1 blr +END(_longjmp) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/gen/eabi.S b/lib/libc/powerpc/gen/eabi.S index 59c231123f20..3296af88a4d1 100644 --- a/lib/libc/powerpc/gen/eabi.S +++ b/lib/libc/powerpc/gen/eabi.S @@ -29,5 +29,6 @@ __FBSDID("$FreeBSD$"); ENTRY(__eabi) blr +END(__eabi) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/gen/fabs.S b/lib/libc/powerpc/gen/fabs.S index 7891012e281c..ac083ae636ac 100644 --- a/lib/libc/powerpc/gen/fabs.S +++ b/lib/libc/powerpc/gen/fabs.S @@ -33,5 +33,6 @@ __FBSDID("$FreeBSD$"); ENTRY(fabs) fabs %f1,%f1 blr +END(fabs) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/gen/setjmp.S b/lib/libc/powerpc/gen/setjmp.S index 6df4f937ff17..9325fc2378cb 100644 --- a/lib/libc/powerpc/gen/setjmp.S +++ b/lib/libc/powerpc/gen/setjmp.S @@ -68,6 +68,7 @@ ENTRY(setjmp) stmw %r9,20(%r6) li %r3,0 /* return (0) */ blr +END(setjmp) WEAK_REFERENCE(CNAME(__longjmp), longjmp) ENTRY(__longjmp) @@ -86,5 +87,6 @@ ENTRY(__longjmp) bnelr li %r3,1 blr +END(__longjmp) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/gen/sigsetjmp.S b/lib/libc/powerpc/gen/sigsetjmp.S index 9639dd11c81e..c67afc610316 100644 --- a/lib/libc/powerpc/gen/sigsetjmp.S +++ b/lib/libc/powerpc/gen/sigsetjmp.S @@ -73,6 +73,7 @@ ENTRY(sigsetjmp) stmw %r9,20(%r6) li %r3,0 blr +END(sigsetjmp) ENTRY(siglongjmp) lmw %r9,20(%r3) @@ -94,5 +95,6 @@ ENTRY(siglongjmp) bnelr li %r3,1 blr +END(siglongjmp) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/sys/brk.S b/lib/libc/powerpc/sys/brk.S index 018eec9ebf53..e14be1058b51 100644 --- a/lib/libc/powerpc/sys/brk.S +++ b/lib/libc/powerpc/sys/brk.S @@ -71,5 +71,6 @@ ENTRY(brk) 1: b PIC_PLT(HIDENAME(cerror)) +END(brk) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/sys/exect.S b/lib/libc/powerpc/sys/exect.S index 3c39b3c47e6b..701f5b00f45c 100644 --- a/lib/libc/powerpc/sys/exect.S +++ b/lib/libc/powerpc/sys/exect.S @@ -37,5 +37,6 @@ ENTRY(exect) blr 1: b PIC_PLT(HIDENAME(cerror)) +END(exect) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/sys/pipe.S b/lib/libc/powerpc/sys/pipe.S index 3f6d9a474353..1cbbef042751 100644 --- a/lib/libc/powerpc/sys/pipe.S +++ b/lib/libc/powerpc/sys/pipe.S @@ -41,5 +41,6 @@ ENTRY(pipe) blr /* and return 0 */ 1: b PIC_PLT(HIDENAME(cerror)) +END(pipe) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/sys/ptrace.S b/lib/libc/powerpc/sys/ptrace.S index 0bc25c91fa78..cff463dd009c 100644 --- a/lib/libc/powerpc/sys/ptrace.S +++ b/lib/libc/powerpc/sys/ptrace.S @@ -56,5 +56,6 @@ ENTRY(ptrace) blr 1: b PIC_PLT(HIDENAME(cerror)) +END(ptrace) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc/sys/sbrk.S b/lib/libc/powerpc/sys/sbrk.S index a5e402001334..f058d112e863 100644 --- a/lib/libc/powerpc/sys/sbrk.S +++ b/lib/libc/powerpc/sys/sbrk.S @@ -68,5 +68,6 @@ ENTRY(sbrk) blr 2: b PIC_PLT(HIDENAME(cerror)) +END(sbrk) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/gen/_ctx_start.S b/lib/libc/powerpc64/gen/_ctx_start.S index 79df0413d2e8..17ec44e739cd 100644 --- a/lib/libc/powerpc64/gen/_ctx_start.S +++ b/lib/libc/powerpc64/gen/_ctx_start.S @@ -46,5 +46,6 @@ nop bl CNAME(abort) /* abort */ nop + END(_ctx_start) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/gen/_setjmp.S b/lib/libc/powerpc64/gen/_setjmp.S index ac0555e28850..207c4f7d10d9 100644 --- a/lib/libc/powerpc64/gen/_setjmp.S +++ b/lib/libc/powerpc64/gen/_setjmp.S @@ -80,6 +80,7 @@ ENTRY(_setjmp) std %r31,40 + 22*8(%r3) li %r3,0 blr +END(_setjmp) ENTRY(_longjmp) ld %r9,40 + 0*8(%r3) @@ -113,5 +114,6 @@ ENTRY(_longjmp) bnelr li %r3,1 blr +END(_longjmp) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/gen/fabs.S b/lib/libc/powerpc64/gen/fabs.S index 7891012e281c..ac083ae636ac 100644 --- a/lib/libc/powerpc64/gen/fabs.S +++ b/lib/libc/powerpc64/gen/fabs.S @@ -33,5 +33,6 @@ __FBSDID("$FreeBSD$"); ENTRY(fabs) fabs %f1,%f1 blr +END(fabs) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/gen/setjmp.S b/lib/libc/powerpc64/gen/setjmp.S index 8fe285201dc2..14954667b9b4 100644 --- a/lib/libc/powerpc64/gen/setjmp.S +++ b/lib/libc/powerpc64/gen/setjmp.S @@ -92,6 +92,7 @@ ENTRY(setjmp) li %r3,0 /* return (0) */ blr +END(setjmp) WEAK_REFERENCE(__longjmp, longjmp) ENTRY(__longjmp) @@ -132,5 +133,6 @@ ENTRY(__longjmp) bnelr li %r3,1 blr +END(__longjmp) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/gen/sigsetjmp.S b/lib/libc/powerpc64/gen/sigsetjmp.S index d5341eaf47b9..5cfd684d38da 100644 --- a/lib/libc/powerpc64/gen/sigsetjmp.S +++ b/lib/libc/powerpc64/gen/sigsetjmp.S @@ -97,6 +97,7 @@ ENTRY(sigsetjmp) li %r3,0 blr +END(sigsetjmp) ENTRY(siglongjmp) ld %r9,40 + 0*8(%r3) @@ -141,5 +142,6 @@ ENTRY(siglongjmp) bnelr li %r3,1 blr +END(siglongjmp) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/sys/brk.S b/lib/libc/powerpc64/sys/brk.S index 675b400419e2..cbcecc7abb11 100644 --- a/lib/libc/powerpc64/sys/brk.S +++ b/lib/libc/powerpc64/sys/brk.S @@ -69,5 +69,6 @@ ENTRY(brk) ld %r0,16(%r1) mtlr %r0 blr +END(brk) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/sys/exect.S b/lib/libc/powerpc64/sys/exect.S index aa34b9e530f8..b6cda9c90773 100644 --- a/lib/libc/powerpc64/sys/exect.S +++ b/lib/libc/powerpc64/sys/exect.S @@ -45,5 +45,6 @@ ENTRY(exect) ld %r0,16(%r1) mtlr %r0 blr +END(exect) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/sys/pipe.S b/lib/libc/powerpc64/sys/pipe.S index efd3dd63a4e6..ee255a9867f1 100644 --- a/lib/libc/powerpc64/sys/pipe.S +++ b/lib/libc/powerpc64/sys/pipe.S @@ -49,5 +49,6 @@ ENTRY(pipe) ld %r0,16(%r1) mtlr %r0 blr +END(pipe) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/sys/ptrace.S b/lib/libc/powerpc64/sys/ptrace.S index ede00e7da269..69709dd936b5 100644 --- a/lib/libc/powerpc64/sys/ptrace.S +++ b/lib/libc/powerpc64/sys/ptrace.S @@ -63,5 +63,6 @@ ENTRY(ptrace) ld %r0,16(%r1) mtlr %r0 blr +END(ptrace) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/powerpc64/sys/sbrk.S b/lib/libc/powerpc64/sys/sbrk.S index e147493cf65c..4e3b57abf458 100644 --- a/lib/libc/powerpc64/sys/sbrk.S +++ b/lib/libc/powerpc64/sys/sbrk.S @@ -64,5 +64,6 @@ ENTRY(sbrk) ld %r0,16(%r1) mtlr %r0 blr +END(sbrk) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/quad/Makefile.inc b/lib/libc/quad/Makefile.inc index 1b1ab60234af..94697faf2fdd 100644 --- a/lib/libc/quad/Makefile.inc +++ b/lib/libc/quad/Makefile.inc @@ -8,7 +8,7 @@ SRCS+= cmpdi2.c divdi3.c moddi3.c qdivrem.c ucmpdi2.c udivdi3.c umoddi3.c -.elif ${LIBC_ARCH} == "arm" && ${MK_ARM_EABI} != "no" +.elif ${LIBC_ARCH} == "arm" SRCS+= adddi3.c anddi3.c floatunsdidf.c iordi3.c lshldi3.c notdi2.c \ qdivrem.c subdi3.c xordi3.c diff --git a/lib/libc/stdtime/strptime.3 b/lib/libc/stdtime/strptime.3 index 34d2b791e70c..27054460e03e 100644 --- a/lib/libc/stdtime/strptime.3 +++ b/lib/libc/stdtime/strptime.3 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" " -.Dd June 25, 2012 +.Dd October 2, 2014 .Dt STRPTIME 3 .Os .Sh NAME @@ -79,7 +79,11 @@ and .Fa \&%D , are now interpreted as beginning at 1969 per POSIX requirements. Years 69-00 are interpreted in the 20th century (1969-2000), years -01-68 in the 21st century (2001-2068). +01-68 in the 21st century (2001-2068). The +.Fa \&%U +and +.Fa %W +format specifiers accept any value within the range 00 to 53. .Pp If the .Fa format @@ -161,14 +165,6 @@ and 12PM is taken as noon. .Pp The -.Fa \&%U -and -.Fa %W -format specifiers accept any value within the range 00 to 53 -without validating against other values supplied (like month -or day of the year, for example). -.Pp -The .Fa %Z format specifier only accepts time zone abbreviations of the local time zone, or the value "GMT". diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 2333ab47e76e..8576bdb3750a 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -55,10 +55,32 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" #include "timelocal.h" +#include "tzfile.h" static char * _strptime(const char *, const char *, struct tm *, int *, locale_t); -#define asizeof(a) (sizeof (a) / sizeof ((a)[0])) +#define asizeof(a) (sizeof(a) / sizeof((a)[0])) + +#define FLAG_NONE (1 << 0) +#define FLAG_YEAR (1 << 1) +#define FLAG_MONTH (1 << 2) +#define FLAG_YDAY (1 << 3) +#define FLAG_MDAY (1 << 4) +#define FLAG_WDAY (1 << 5) + +/* + * Calculate the week day of the first day of a year. Valid for + * the Gregorian calendar, which began Sept 14, 1752 in the UK + * and its colonies. Ref: + * http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week + */ + +static int +first_wday_of(int year) +{ + return (((2 * (3 - (year / 100) % 4)) + (year % 100) + + ((year % 100) / 4) + (isleap(year) ? 6 : 0) + 1) % 7); +} static char * _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, @@ -66,9 +88,18 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, { char c; const char *ptr; + int day_offset = -1, wday_offset; + int week_offset; int i, len; + int flags; int Ealternative, Oalternative; - struct lc_time_T *tptr = __get_current_time_locale(locale); + const struct lc_time_T *tptr = __get_current_time_locale(locale); + static int start_of_month[2][13] = { + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} + }; + + flags = FLAG_NONE; ptr = fmt; while (*ptr != 0) { @@ -102,6 +133,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, buf = _strptime(buf, tptr->date_fmt, tm, GMTp, locale); if (buf == NULL) return (NULL); + flags |= FLAG_WDAY | FLAG_MONTH | FLAG_MDAY | FLAG_YEAR; break; case 'C': @@ -119,19 +151,23 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, if (i < 19) return (NULL); - tm->tm_year = i * 100 - 1900; + tm->tm_year = i * 100 - TM_YEAR_BASE; + flags |= FLAG_YEAR; + break; case 'c': buf = _strptime(buf, tptr->c_fmt, tm, GMTp, locale); if (buf == NULL) return (NULL); + flags |= FLAG_WDAY | FLAG_MONTH | FLAG_MDAY | FLAG_YEAR; break; case 'D': buf = _strptime(buf, "%m/%d/%y", tm, GMTp, locale); if (buf == NULL) return (NULL); + flags |= FLAG_MONTH | FLAG_MDAY | FLAG_YEAR; break; case 'E': @@ -150,6 +186,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, buf = _strptime(buf, "%Y-%m-%d", tm, GMTp, locale); if (buf == NULL) return (NULL); + flags |= FLAG_MONTH | FLAG_MDAY | FLAG_YEAR; break; case 'R': @@ -180,6 +217,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, buf = _strptime(buf, tptr->x_fmt, tm, GMTp, locale); if (buf == NULL) return (NULL); + flags |= FLAG_MONTH | FLAG_MDAY | FLAG_YEAR; break; case 'j': @@ -197,6 +235,8 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, return (NULL); tm->tm_yday = i - 1; + flags |= FLAG_YDAY; + break; case 'M': @@ -302,8 +342,9 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, if (i == asizeof(tptr->weekday)) return (NULL); - tm->tm_wday = i; buf += len; + tm->tm_wday = i; + flags |= FLAG_WDAY; break; case 'U': @@ -327,6 +368,14 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, if (i > 53) return (NULL); + if (c == 'U') + day_offset = TM_SUNDAY; + else + day_offset = TM_MONDAY; + + + week_offset = i; + break; case 'w': @@ -338,6 +387,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, return (NULL); tm->tm_wday = i; + flags |= FLAG_WDAY; break; @@ -374,6 +424,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, return (NULL); tm->tm_mday = i; + flags |= FLAG_MDAY; break; @@ -413,6 +464,8 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, tm->tm_mon = i; buf += len; + flags |= FLAG_MONTH; + break; case 'm': @@ -430,6 +483,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, return (NULL); tm->tm_mon = i - 1; + flags |= FLAG_MONTH; break; @@ -449,8 +503,11 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, } errno = sverrno; buf = cp; - gmtime_r(&t, tm); + if (gmtime_r(&t, tm) == NULL) + return (NULL); *GMTp = 1; + flags |= FLAG_YDAY | FLAG_WDAY | FLAG_MONTH | + FLAG_MDAY | FLAG_YEAR; } break; @@ -471,13 +528,14 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, len--; } if (c == 'Y') - i -= 1900; + i -= TM_YEAR_BASE; if (c == 'y' && i < 69) i += 100; if (i < 0) return (NULL); tm->tm_year = i; + flags |= FLAG_YEAR; break; @@ -543,10 +601,67 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, break; } } + + if (!(flags & FLAG_YDAY) && (flags & FLAG_YEAR)) { + if ((flags & (FLAG_MONTH | FLAG_MDAY)) == + (FLAG_MONTH | FLAG_MDAY)) { + tm->tm_yday = start_of_month[isleap(tm->tm_year + + TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1); + flags |= FLAG_YDAY; + } else if (day_offset != -1) { + /* Set the date to the first Sunday (or Monday) + * of the specified week of the year. + */ + if (!(flags & FLAG_WDAY)) { + tm->tm_wday = day_offset; + flags |= FLAG_WDAY; + } + tm->tm_yday = (7 - + first_wday_of(tm->tm_year + TM_YEAR_BASE) + + day_offset) % 7 + (week_offset - 1) * 7 + + tm->tm_wday - day_offset; + flags |= FLAG_YDAY; + } + } + + if ((flags & (FLAG_YEAR | FLAG_YDAY)) == (FLAG_YEAR | FLAG_YDAY)) { + if (!(flags & FLAG_MONTH)) { + i = 0; + while (tm->tm_yday >= + start_of_month[isleap(tm->tm_year + + TM_YEAR_BASE)][i]) + i++; + if (i > 12) { + i = 1; + tm->tm_yday -= + start_of_month[isleap(tm->tm_year + + TM_YEAR_BASE)][12]; + tm->tm_year++; + } + tm->tm_mon = i - 1; + flags |= FLAG_MONTH; + } + if (!(flags & FLAG_MDAY)) { + tm->tm_mday = tm->tm_yday - + start_of_month[isleap(tm->tm_year + TM_YEAR_BASE)] + [tm->tm_mon] + 1; + flags |= FLAG_MDAY; + } + if (!(flags & FLAG_WDAY)) { + i = 0; + wday_offset = first_wday_of(tm->tm_year); + while (i++ <= tm->tm_yday) { + if (wday_offset++ >= 6) + wday_offset = 0; + } + tm->tm_wday = wday_offset; + flags |= FLAG_WDAY; + } + } + return ((char *)buf); } - char * strptime_l(const char * __restrict buf, const char * __restrict fmt, struct tm * __restrict tm, locale_t loc) @@ -564,6 +679,7 @@ strptime_l(const char * __restrict buf, const char * __restrict fmt, return (ret); } + char * strptime(const char * __restrict buf, const char * __restrict fmt, struct tm * __restrict tm) diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2 index 65b8fb6bfbb1..46bf9488de81 100644 --- a/lib/libc/sys/access.2 +++ b/lib/libc/sys/access.2 @@ -28,7 +28,7 @@ .\" @(#)access.2 8.2 (Berkeley) 4/1/94 .\" $FreeBSD$ .\" -.Dd April 10, 2008 +.Dd September 15, 2014 .Dt ACCESS 2 .Os .Sh NAME @@ -133,8 +133,16 @@ and .Sh RETURN VALUES .Rv -std .Sh ERRORS -Access to the file is denied if: +.Fn access , +.Fn eaccess , +or +.Fn faccessat +will fail if: .Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa mode +argument is invalid. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG diff --git a/lib/libc/sys/connect.2 b/lib/libc/sys/connect.2 index 8ed3f12bc8a2..e3e57831475a 100644 --- a/lib/libc/sys/connect.2 +++ b/lib/libc/sys/connect.2 @@ -28,7 +28,7 @@ .\" @(#)connect.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 26, 2014 +.Dd September 29, 2014 .Dt CONNECT 2 .Os .Sh NAME @@ -160,6 +160,8 @@ Search permission is denied for a component of the path prefix. Write access to the named socket is denied. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +Write access to the named socket is denied. .El .Sh SEE ALSO .Xr accept 2 , diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index f84bc05ba293..9a7cc235e0c0 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -478,7 +478,6 @@ is in microseconds. .It Dv NOTE_NSECONDS .Va data is in nanoseconds. -.It .El .Pp If diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 3dd830326ad0..7380a7fb3f31 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -28,7 +28,7 @@ .\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 .\" $FreeBSD$ .\" -.Dd June 19, 2014 +.Dd September 17, 2014 .Dt MMAP 2 .Os .Sh NAME @@ -176,11 +176,6 @@ already exists within the range. .It Dv MAP_HASSEMAPHORE Notify the kernel that the region may contain semaphores and that special handling may be necessary. -.It Dv MAP_INHERIT -This flag never operated as advertised and is no longer supported. -Please refer to -.Xr minherit 2 -for further information. .It Dv MAP_NOCORE Region is not included in a core file. .It Dv MAP_NOSYNC @@ -300,14 +295,6 @@ The system call does not unmap pages, see .Xr munmap 2 for further information. -.Pp -The current design does not allow a process to specify the location of -swap space. -In the future we may define an additional mapping type, -.Dv MAP_SWAP , -in which -the file descriptor argument specifies a file or device to which swapping -should be done. .Sh NOTES Although this implementation does not impose any alignment restrictions on the @@ -372,6 +359,29 @@ The argument is not a valid open file descriptor. .It Bq Er EINVAL +An invalid value was passed in the +.Fa prot +argument. +.It Bq Er EINVAL +An undefined option was set in the +.Fa flags +argument. +.It Bq Er EINVAL +Both +.Dv MAP_PRIVATE +and +.Dv MAP_SHARED +were specified. +.It Bq Er EINVAL +None of +.Dv MAP_ANON , +.Dv MAP_PRIVATE , +.Dv MAP_SHARED , +or +.Dv MAP_STACK +was specified. +At least one of these flags must be included. +.It Bq Er EINVAL .Dv MAP_FIXED was specified and the .Fa addr diff --git a/lib/libc/sys/mq_open.2 b/lib/libc/sys/mq_open.2 index 5acc59beab95..ef6154b7ff5a 100644 --- a/lib/libc/sys/mq_open.2 +++ b/lib/libc/sys/mq_open.2 @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 29, 2005 +.Dd September 15, 2014 .Dt MQ_OPEN 2 .Os .Sh NAME @@ -223,6 +223,11 @@ The and .Xr kevent 2 system calls are supported for message queue descriptor. +.Pp +Please see the +.Xr mqueuefs 5 +man page for instructions on loading the module or compiling the service into +the kernel. .Sh RETURN VALUES Upon successful completion, the function returns a message queue descriptor; otherwise, the function returns @@ -294,7 +299,8 @@ There is insufficient space for the creation of the new message queue. .Xr mq_setattr 2 , .Xr mq_timedreceive 3 , .Xr mq_timedsend 3 , -.Xr mq_unlink 3 +.Xr mq_unlink 3 , +.Xr mqueuefs 5 .Sh STANDARDS The .Fn mq_open diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile index 91ce965739c9..c31eced57468 100644 --- a/lib/libcompiler_rt/Makefile +++ b/lib/libcompiler_rt/Makefile @@ -144,8 +144,7 @@ SRCF+= adddf3 \ truncdfsf2 .endif -.if ${MACHINE_CPUARCH} != "mips" && \ - (${MACHINE_CPUARCH} != "arm" || ${MK_ARM_EABI} != "no") +.if ${MACHINE_CPUARCH} != "mips" SRCF+= divsi3 \ modsi3 \ udivsi3 \ @@ -165,16 +164,16 @@ SRCF+= stdatomic .endif .for file in ${SRCF} -. if ${MACHINE_ARCH} == "armv6hf" && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S) +. if ${MACHINE_ARCH:Marm*hf*} != "" && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S) SRCS+= ${file}vfp.S -. elif (${MACHINE_CPUARCH} != "arm" || ${MACHINE_ARCH} == "armv6hf") && exists(${CRTSRC}/${CRTARCH}/${file}.S) +. elif !(${MACHINE_CPUARCH} == "arm" && ${MACHINE_ARCH:Marm*hf*} == "") && exists(${CRTSRC}/${CRTARCH}/${file}.S) SRCS+= ${file}.S . else SRCS+= ${file}.c . endif .endfor -.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${MACHINE_CPUARCH} == "arm" SRCS+= aeabi_idivmod.S \ aeabi_ldivmod.S \ aeabi_memcmp.S \ diff --git a/lib/libgeom/geom_stats.c b/lib/libgeom/geom_stats.c index 14f9b222123c..48f71609a4b6 100644 --- a/lib/libgeom/geom_stats.c +++ b/lib/libgeom/geom_stats.c @@ -68,7 +68,7 @@ geom_stats_resync(void) return; for (;;) { p = mmap(statp, (npages + 1) * pagesize, - PROT_READ, 0, statsfd, 0); + PROT_READ, MAP_SHARED, statsfd, 0); if (p == MAP_FAILED) break; else @@ -90,7 +90,7 @@ geom_stats_open(void) return (errno); pagesize = getpagesize(); spp = pagesize / sizeof(struct devstat); - p = mmap(NULL, pagesize, PROT_READ, 0, statsfd, 0); + p = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, statsfd, 0); if (p == MAP_FAILED) { error = errno; close(statsfd); diff --git a/lib/libnv/Makefile b/lib/libnv/Makefile index cad1ea4eba63..4a7c76a3114e 100644 --- a/lib/libnv/Makefile +++ b/lib/libnv/Makefile @@ -1,9 +1,10 @@ # $FreeBSD$ +SHLIBDIR?= /lib + .include LIB= nv -SHLIBDIR?= /lib SHLIB_MAJOR= 0 SRCS= dnvlist.c diff --git a/lib/libnv/msgio.c b/lib/libnv/msgio.c index 41292aa1b0c9..27620a184f9a 100644 --- a/lib/libnv/msgio.c +++ b/lib/libnv/msgio.c @@ -31,7 +31,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include #include #include @@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$"); #define PJDLOG_ABORT(...) abort() #endif +#define PKG_MAX_SIZE (MCLBYTES / CMSG_SPACE(sizeof(int)) - 1) + static int msghdr_add_fd(struct cmsghdr *cmsg, int fd) { @@ -234,22 +236,31 @@ cred_recv(int sock, struct cmsgcred *cred) return (0); } -int -fd_send(int sock, const int *fds, size_t nfds) +static int +fd_package_send(int sock, const int *fds, size_t nfds) { struct msghdr msg; struct cmsghdr *cmsg; + struct iovec iov; unsigned int i; int serrno, ret; + uint8_t dummy; - if (nfds == 0 || fds == NULL) { - errno = EINVAL; - return (-1); - } + PJDLOG_ASSERT(sock >= 0); + PJDLOG_ASSERT(fds != NULL); + PJDLOG_ASSERT(nfds > 0); bzero(&msg, sizeof(msg)); - msg.msg_iov = NULL; - msg.msg_iovlen = 0; + + /* + * XXX: Look into cred_send function for more details. + */ + dummy = 0; + iov.iov_base = &dummy; + iov.iov_len = sizeof(dummy); + + msg.msg_iov = &iov; + msg.msg_iovlen = 1; msg.msg_controllen = nfds * CMSG_SPACE(sizeof(int)); msg.msg_control = calloc(1, msg.msg_controllen); if (msg.msg_control == NULL) @@ -274,22 +285,32 @@ fd_send(int sock, const int *fds, size_t nfds) return (ret); } -int -fd_recv(int sock, int *fds, size_t nfds) +static int +fd_package_recv(int sock, int *fds, size_t nfds) { struct msghdr msg; struct cmsghdr *cmsg; unsigned int i; int serrno, ret; + struct iovec iov; + uint8_t dummy; - if (nfds == 0 || fds == NULL) { - errno = EINVAL; - return (-1); - } + PJDLOG_ASSERT(sock >= 0); + PJDLOG_ASSERT(nfds > 0); + PJDLOG_ASSERT(fds != NULL); + i = 0; bzero(&msg, sizeof(msg)); - msg.msg_iov = NULL; - msg.msg_iovlen = 0; + bzero(&iov, sizeof(iov)); + + /* + * XXX: Look into cred_send function for more details. + */ + iov.iov_base = &dummy; + iov.iov_len = sizeof(dummy); + + msg.msg_iov = &iov; + msg.msg_iovlen = 1; msg.msg_controllen = nfds * CMSG_SPACE(sizeof(int)); msg.msg_control = calloc(1, msg.msg_controllen); if (msg.msg_control == NULL) @@ -332,6 +353,64 @@ fd_recv(int sock, int *fds, size_t nfds) return (ret); } +int +fd_recv(int sock, int *fds, size_t nfds) +{ + unsigned int i, step, j; + int ret, serrno; + + if (nfds == 0 || fds == NULL) { + errno = EINVAL; + return (-1); + } + + ret = i = step = 0; + while (i < nfds) { + if (PKG_MAX_SIZE < nfds - i) + step = PKG_MAX_SIZE; + else + step = nfds - i; + ret = fd_package_recv(sock, fds + i, step); + if (ret != 0) { + /* Close all received descriptors. */ + serrno = errno; + for (j = 0; j < i; j++) + close(fds[j]); + errno = serrno; + break; + } + i += step; + } + + return (ret); +} + +int +fd_send(int sock, const int *fds, size_t nfds) +{ + unsigned int i, step; + int ret; + + if (nfds == 0 || fds == NULL) { + errno = EINVAL; + return (-1); + } + + ret = i = step = 0; + while (i < nfds) { + if (PKG_MAX_SIZE < nfds - i) + step = PKG_MAX_SIZE; + else + step = nfds - i; + ret = fd_package_send(sock, fds + i, step); + if (ret != 0) + break; + i += step; + } + + return (ret); +} + int buf_send(int sock, void *buf, size_t size) { diff --git a/lib/libnv/nv.3 b/lib/libnv/nv.3 index 63c8e8b0e202..29ba744389cb 100644 --- a/lib/libnv/nv.3 +++ b/lib/libnv/nv.3 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 21, 2014 +.Dd September 25, 2014 .Dt NV 3 .Os .Sh NAME @@ -150,6 +150,8 @@ .Fn nvlist_get_descriptor "const nvlist_t *nvl" "const char *name" .Ft "const void *" .Fn nvlist_get_binary "const nvlist_t *nvl" "const char *name" "size_t *sizep" +.Ft "const nvlist_t *" +.Fn nvlist_get_parent "const nvlist_t *nvl" .\" .Ft bool .Fn nvlist_take_bool "nvlist_t *nvl" "const char *name" @@ -437,6 +439,10 @@ extension, which allows to provide default value for a missing element. The nvlist must not be in error state. .Pp The +.Fn nvlist_get_parent +function allows to obtain the parent nvlist from the nested nvlist. +.Pp +The .Fn nvlist_take_bool , .Fn nvlist_take_number , .Fn nvlist_take_string , diff --git a/lib/libnv/nv.h b/lib/libnv/nv.h index e2d7030f665b..1b55be1fc2a0 100644 --- a/lib/libnv/nv.h +++ b/lib/libnv/nv.h @@ -83,6 +83,8 @@ nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl); const char *nvlist_next(const nvlist_t *nvl, int *typep, void **cookiep); +const nvlist_t *nvlist_get_parent(const nvlist_t *nvl); + /* * The nvlist_exists functions check if the given name (optionally of the given * type) exists on nvlist. diff --git a/lib/libnv/nv_impl.h b/lib/libnv/nv_impl.h index 32060061f413..3ed45b3c785d 100644 --- a/lib/libnv/nv_impl.h +++ b/lib/libnv/nv_impl.h @@ -39,6 +39,8 @@ struct nvpair; typedef struct nvpair nvpair_t; #endif +#define NV_TYPE_NVLIST_UP 255 + #define NV_TYPE_FIRST NV_TYPE_NULL #define NV_TYPE_LAST NV_TYPE_BINARY @@ -55,6 +57,8 @@ void nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp); void nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp); +void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent); + const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name); nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name); diff --git a/lib/libnv/nvlist.c b/lib/libnv/nvlist.c index 9534fea84d05..c7c3cb9a2862 100644 --- a/lib/libnv/nvlist.c +++ b/lib/libnv/nvlist.c @@ -73,10 +73,11 @@ __FBSDID("$FreeBSD$"); #define NVLIST_MAGIC 0x6e766c /* "nvl" */ struct nvlist { - int nvl_magic; - int nvl_error; - int nvl_flags; - struct nvl_head nvl_head; + int nvl_magic; + int nvl_error; + int nvl_flags; + nvpair_t *nvl_parent; + struct nvl_head nvl_head; }; #define NVLIST_ASSERT(nvl) do { \ @@ -106,6 +107,7 @@ nvlist_create(int flags) nvl = malloc(sizeof(*nvl)); nvl->nvl_error = 0; nvl->nvl_flags = flags; + nvl->nvl_parent = NULL; TAILQ_INIT(&nvl->nvl_head); nvl->nvl_magic = NVLIST_MAGIC; @@ -147,6 +149,36 @@ nvlist_error(const nvlist_t *nvl) return (nvl->nvl_error); } +nvpair_t * +nvlist_get_nvpair_parent(const nvlist_t *nvl) +{ + + NVLIST_ASSERT(nvl); + + return (nvl->nvl_parent); +} + +const nvlist_t * +nvlist_get_parent(const nvlist_t *nvl) +{ + + NVLIST_ASSERT(nvl); + + if (nvl->nvl_parent == NULL) + return (NULL); + + return (nvpair_nvlist(nvl->nvl_parent)); +} + +void +nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent) +{ + + NVLIST_ASSERT(nvl); + + nvl->nvl_parent = parent; +} + bool nvlist_empty(const nvlist_t *nvl) { @@ -301,24 +333,34 @@ nvlist_clone(const nvlist_t *nvl) return (newnvl); } -/* - * Dump content of nvlist. - */ -static void -nvlist_xdump(const nvlist_t *nvl, int fd, int level) +static bool +nvlist_dump_error_check(const nvlist_t *nvl, int fd, int level) { - nvpair_t *nvp; - - PJDLOG_ASSERT(level < 3); if (nvlist_error(nvl) != 0) { dprintf(fd, "%*serror: %d\n", level * 4, "", nvlist_error(nvl)); - return; + return (true); } - for (nvp = nvlist_first_nvpair(nvl); nvp != NULL; - nvp = nvlist_next_nvpair(nvl, nvp)) { + return (false); +} + +/* + * Dump content of nvlist. + */ +void +nvlist_dump(const nvlist_t *nvl, int fd) +{ + nvpair_t *nvp; + int level; + + level = 0; + if (nvlist_dump_error_check(nvl, fd, level)) + return; + + nvp = nvlist_first_nvpair(nvl); + while (nvp != NULL) { dprintf(fd, "%*s%s (%s):", level * 4, "", nvpair_name(nvp), nvpair_type_string(nvpair_type(nvp))); switch (nvpair_type(nvp)) { @@ -340,8 +382,14 @@ nvlist_xdump(const nvlist_t *nvl, int fd, int level) break; case NV_TYPE_NVLIST: dprintf(fd, "\n"); - nvlist_xdump(nvpair_get_nvlist(nvp), fd, level + 1); - break; + nvl = nvpair_get_nvlist(nvp); + if (nvlist_dump_error_check(nvl, fd, level + 1)) { + nvl = nvlist_get_parent(nvl); + break; + } + level += 1; + nvp = nvlist_first_nvpair(nvl); + continue; case NV_TYPE_DESCRIPTOR: dprintf(fd, " %d\n", nvpair_get_descriptor(nvp)); break; @@ -361,16 +409,17 @@ nvlist_xdump(const nvlist_t *nvl, int fd, int level) default: PJDLOG_ABORT("Unknown type: %d.", nvpair_type(nvp)); } + + while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) { + nvp = nvlist_get_nvpair_parent(nvl); + if (nvp == NULL) + return; + nvl = nvlist_get_parent(nvl); + level --; + } } } -void -nvlist_dump(const nvlist_t *nvl, int fd) -{ - - nvlist_xdump(nvl, fd, 0); -} - void nvlist_fdump(const nvlist_t *nvl, FILE *fp) { @@ -381,41 +430,44 @@ nvlist_fdump(const nvlist_t *nvl, FILE *fp) /* * The function obtains size of the nvlist after nvlist_pack(). - * Additional argument 'level' allows to track how deep are we as we obtain - * size of the NV_TYPE_NVLIST elements using recursion. We allow at most - * three levels of recursion. */ -static size_t -nvlist_xsize(const nvlist_t *nvl, int level) +size_t +nvlist_size(const nvlist_t *nvl) { const nvpair_t *nvp; size_t size; NVLIST_ASSERT(nvl); PJDLOG_ASSERT(nvl->nvl_error == 0); - PJDLOG_ASSERT(level < 3); size = sizeof(struct nvlist_header); - for (nvp = nvlist_first_nvpair(nvl); nvp != NULL; - nvp = nvlist_next_nvpair(nvl, nvp)) { + nvp = nvlist_first_nvpair(nvl); + while (nvp != NULL) { size += nvpair_header_size(); size += strlen(nvpair_name(nvp)) + 1; - if (nvpair_type(nvp) == NV_TYPE_NVLIST) - size += nvlist_xsize(nvpair_get_nvlist(nvp), level + 1); - else + if (nvpair_type(nvp) == NV_TYPE_NVLIST) { + size += sizeof(struct nvlist_header); + size += nvpair_header_size() + 1; + nvl = nvpair_get_nvlist(nvp); + PJDLOG_ASSERT(nvl->nvl_error == 0); + nvp = nvlist_first_nvpair(nvl); + continue; + } else { size += nvpair_size(nvp); + } + + while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) { + nvp = nvlist_get_nvpair_parent(nvl); + if (nvp == NULL) + goto out; + nvl = nvlist_get_parent(nvl); + } } +out: return (size); } -size_t -nvlist_size(const nvlist_t *nvl) -{ - - return (nvlist_xsize(nvl, 0)); -} - static int * nvlist_xdescriptors(const nvlist_t *nvl, int *descs, int level) { @@ -541,15 +593,59 @@ nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep) ptr = nvlist_pack_header(nvl, ptr, &left); - for (nvp = nvlist_first_nvpair(nvl); nvp != NULL; - nvp = nvlist_next_nvpair(nvl, nvp)) { - ptr = nvpair_pack(nvp, ptr, fdidxp, &left); + nvp = nvlist_first_nvpair(nvl); + while (nvp != NULL) { + NVPAIR_ASSERT(nvp); + + nvpair_init_datasize(nvp); + ptr = nvpair_pack_header(nvp, ptr, &left); if (ptr == NULL) { free(buf); return (NULL); } + switch (nvpair_type(nvp)) { + case NV_TYPE_NULL: + ptr = nvpair_pack_null(nvp, ptr, &left); + break; + case NV_TYPE_BOOL: + ptr = nvpair_pack_bool(nvp, ptr, &left); + break; + case NV_TYPE_NUMBER: + ptr = nvpair_pack_number(nvp, ptr, &left); + break; + case NV_TYPE_STRING: + ptr = nvpair_pack_string(nvp, ptr, &left); + break; + case NV_TYPE_NVLIST: + nvl = nvpair_get_nvlist(nvp); + nvp = nvlist_first_nvpair(nvl); + ptr = nvlist_pack_header(nvl, ptr, &left); + continue; + case NV_TYPE_DESCRIPTOR: + ptr = nvpair_pack_descriptor(nvp, ptr, fdidxp, &left); + break; + case NV_TYPE_BINARY: + ptr = nvpair_pack_binary(nvp, ptr, &left); + break; + default: + PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp)); + } + if (ptr == NULL) { + free(buf); + return (NULL); + } + while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) { + nvp = nvlist_get_nvpair_parent(nvl); + if (nvp == NULL) + goto out; + ptr = nvpair_pack_nvlist_up(ptr, &left); + if (ptr == NULL) + goto out; + nvl = nvlist_get_parent(nvl); + } } +out: if (sizep != NULL) *sizep = size; return (buf); @@ -600,7 +696,7 @@ nvlist_check_header(struct nvlist_header *nvlhdrp) return (true); } -static const unsigned char * +const unsigned char * nvlist_unpack_header(nvlist_t *nvl, const unsigned char *ptr, size_t nfds, int *flagsp, size_t *leftp) { @@ -642,7 +738,7 @@ nvlist_t * nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds) { const unsigned char *ptr; - nvlist_t *nvl; + nvlist_t *nvl, *retnvl, *tmpnvl; nvpair_t *nvp; size_t left; int flags; @@ -650,7 +746,8 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds) left = size; ptr = buf; - nvl = nvlist_create(0); + tmpnvl = NULL; + nvl = retnvl = nvlist_create(0); if (nvl == NULL) goto failed; @@ -659,15 +756,55 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds) goto failed; while (left > 0) { - ptr = nvpair_unpack(flags, ptr, &left, fds, nfds, &nvp); + ptr = nvpair_unpack(flags, ptr, &left, &nvp); + if (ptr == NULL) + goto failed; + switch (nvpair_type(nvp)) { + case NV_TYPE_NULL: + ptr = nvpair_unpack_null(flags, nvp, ptr, &left); + break; + case NV_TYPE_BOOL: + ptr = nvpair_unpack_bool(flags, nvp, ptr, &left); + break; + case NV_TYPE_NUMBER: + ptr = nvpair_unpack_number(flags, nvp, ptr, &left); + break; + case NV_TYPE_STRING: + ptr = nvpair_unpack_string(flags, nvp, ptr, &left); + break; + case NV_TYPE_NVLIST: + ptr = nvpair_unpack_nvlist(&flags, nvp, ptr, &left, + nfds, &tmpnvl); + nvlist_set_parent(tmpnvl, nvp); + break; + case NV_TYPE_DESCRIPTOR: + ptr = nvpair_unpack_descriptor(flags, nvp, ptr, &left, + fds, nfds); + break; + case NV_TYPE_BINARY: + ptr = nvpair_unpack_binary(flags, nvp, ptr, &left); + break; + case NV_TYPE_NVLIST_UP: + if (nvl->nvl_parent == NULL) + goto failed; + nvl = nvpair_nvlist(nvl->nvl_parent); + flags = nvl->nvl_flags; + continue; + default: + PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp)); + } if (ptr == NULL) goto failed; nvlist_move_nvpair(nvl, nvp); + if (tmpnvl != NULL) { + nvl = tmpnvl; + tmpnvl = NULL; + } } - return (nvl); + return (retnvl); failed: - nvlist_destroy(nvl); + nvlist_destroy(retnvl); return (NULL); } @@ -1331,7 +1468,8 @@ nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, nvpair_t *nvp; if (nvlist_error(nvl) != 0) { - nvlist_destroy(value); + if (value != NULL && nvlist_get_nvpair_parent(value) != NULL) + nvlist_destroy(value); errno = nvlist_error(nvl); return; } diff --git a/lib/libnv/nvlist_impl.h b/lib/libnv/nvlist_impl.h index 43a7bb0a80c1..28894c07d2b7 100644 --- a/lib/libnv/nvlist_impl.h +++ b/lib/libnv/nvlist_impl.h @@ -40,4 +40,8 @@ void *nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep); nvlist_t *nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds); +nvpair_t *nvlist_get_nvpair_parent(const nvlist_t *nvl); +const unsigned char *nvlist_unpack_header(nvlist_t *nvl, + const unsigned char *ptr, size_t nfds, int *flagsp, size_t *leftp); + #endif /* !_NVLIST_IMPL_H_ */ diff --git a/lib/libnv/nvpair.c b/lib/libnv/nvpair.c index 916444f76a60..8ff85388f8bb 100644 --- a/lib/libnv/nvpair.c +++ b/lib/libnv/nvpair.c @@ -67,7 +67,7 @@ struct nvpair { int nvp_type; uint64_t nvp_data; size_t nvp_datasize; - nvlist_t *nvp_list; /* Used for sanity checks. */ + nvlist_t *nvp_list; TAILQ_ENTRY(nvpair) nvp_next; }; @@ -90,7 +90,7 @@ nvpair_assert(const nvpair_t *nvp) NVPAIR_ASSERT(nvp); } -const nvlist_t * +nvlist_t * nvpair_nvlist(const nvpair_t *nvp) { @@ -131,6 +131,17 @@ nvpair_insert(struct nvl_head *head, nvpair_t *nvp, nvlist_t *nvl) nvp->nvp_list = nvl; } +static void +nvpair_remove_nvlist(nvpair_t *nvp) +{ + nvlist_t *nvl; + + /* XXX: DECONST is bad, mkay? */ + nvl = __DECONST(nvlist_t *, nvpair_get_nvlist(nvp)); + PJDLOG_ASSERT(nvl != NULL); + nvlist_set_parent(nvl, NULL); +} + void nvpair_remove(struct nvl_head *head, nvpair_t *nvp, const nvlist_t *nvl) { @@ -138,6 +149,9 @@ nvpair_remove(struct nvl_head *head, nvpair_t *nvp, const nvlist_t *nvl) NVPAIR_ASSERT(nvp); PJDLOG_ASSERT(nvp->nvp_list == nvl); + if (nvpair_type(nvp) == NV_TYPE_NVLIST) + nvpair_remove_nvlist(nvp); + TAILQ_REMOVE(head, nvp, nvp_next); nvp->nvp_list = NULL; } @@ -201,7 +215,7 @@ nvpair_size(const nvpair_t *nvp) return (nvp->nvp_datasize); } -static unsigned char * +unsigned char * nvpair_pack_header(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) { struct nvpair_header nvphdr; @@ -227,7 +241,7 @@ nvpair_pack_header(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) return (ptr); } -static unsigned char * +unsigned char * nvpair_pack_null(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp __unused) { @@ -238,7 +252,7 @@ nvpair_pack_null(const nvpair_t *nvp, unsigned char *ptr, return (ptr); } -static unsigned char * +unsigned char * nvpair_pack_bool(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) { uint8_t value; @@ -256,7 +270,7 @@ nvpair_pack_bool(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) return (ptr); } -static unsigned char * +unsigned char * nvpair_pack_number(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) { uint64_t value; @@ -274,7 +288,7 @@ nvpair_pack_number(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) return (ptr); } -static unsigned char * +unsigned char * nvpair_pack_string(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) { @@ -289,37 +303,31 @@ nvpair_pack_string(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) return (ptr); } -static unsigned char * -nvpair_pack_nvlist(const nvpair_t *nvp, unsigned char *ptr, int64_t *fdidxp, - size_t *leftp) +unsigned char * +nvpair_pack_nvlist_up(unsigned char *ptr, size_t *leftp) { - unsigned char *data; - size_t size; + struct nvpair_header nvphdr; + size_t namesize; + const char *name = ""; - NVPAIR_ASSERT(nvp); - PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NVLIST); + namesize = 1; + nvphdr.nvph_type = NV_TYPE_NVLIST_UP; + nvphdr.nvph_namesize = namesize; + nvphdr.nvph_datasize = 0; + PJDLOG_ASSERT(*leftp >= sizeof(nvphdr)); + memcpy(ptr, &nvphdr, sizeof(nvphdr)); + ptr += sizeof(nvphdr); + *leftp -= sizeof(nvphdr); - if (nvp->nvp_datasize == 0) - return (ptr); - - data = nvlist_xpack((const nvlist_t *)(intptr_t)nvp->nvp_data, fdidxp, - &size); - if (data == NULL) - return (NULL); - - PJDLOG_ASSERT(size == nvp->nvp_datasize); - PJDLOG_ASSERT(*leftp >= nvp->nvp_datasize); - - memcpy(ptr, data, nvp->nvp_datasize); - free(data); - - ptr += nvp->nvp_datasize; - *leftp -= nvp->nvp_datasize; + PJDLOG_ASSERT(*leftp >= namesize); + memcpy(ptr, name, namesize); + ptr += namesize; + *leftp -= namesize; return (ptr); } -static unsigned char * +unsigned char * nvpair_pack_descriptor(const nvpair_t *nvp, unsigned char *ptr, int64_t *fdidxp, size_t *leftp) { @@ -349,7 +357,7 @@ nvpair_pack_descriptor(const nvpair_t *nvp, unsigned char *ptr, int64_t *fdidxp, return (ptr); } -static unsigned char * +unsigned char * nvpair_pack_binary(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) { @@ -364,17 +372,12 @@ nvpair_pack_binary(const nvpair_t *nvp, unsigned char *ptr, size_t *leftp) return (ptr); } -unsigned char * -nvpair_pack(nvpair_t *nvp, unsigned char *ptr, int64_t *fdidxp, size_t *leftp) +void +nvpair_init_datasize(nvpair_t *nvp) { NVPAIR_ASSERT(nvp); - /* - * We have to update datasize for NV_TYPE_NVLIST on every pack, - * so that proper datasize is placed into nvpair_header - * during the nvpair_pack_header() call below. - */ if (nvp->nvp_type == NV_TYPE_NVLIST) { if (nvp->nvp_data == 0) { nvp->nvp_datasize = 0; @@ -383,41 +386,9 @@ nvpair_pack(nvpair_t *nvp, unsigned char *ptr, int64_t *fdidxp, size_t *leftp) nvlist_size((const nvlist_t *)(intptr_t)nvp->nvp_data); } } - - ptr = nvpair_pack_header(nvp, ptr, leftp); - if (ptr == NULL) - return (NULL); - - switch (nvp->nvp_type) { - case NV_TYPE_NULL: - ptr = nvpair_pack_null(nvp, ptr, leftp); - break; - case NV_TYPE_BOOL: - ptr = nvpair_pack_bool(nvp, ptr, leftp); - break; - case NV_TYPE_NUMBER: - ptr = nvpair_pack_number(nvp, ptr, leftp); - break; - case NV_TYPE_STRING: - ptr = nvpair_pack_string(nvp, ptr, leftp); - break; - case NV_TYPE_NVLIST: - ptr = nvpair_pack_nvlist(nvp, ptr, fdidxp, leftp); - break; - case NV_TYPE_DESCRIPTOR: - ptr = nvpair_pack_descriptor(nvp, ptr, fdidxp, leftp); - break; - case NV_TYPE_BINARY: - ptr = nvpair_pack_binary(nvp, ptr, leftp); - break; - default: - PJDLOG_ABORT("Invalid type (%d).", nvp->nvp_type); - } - - return (ptr); } -static const unsigned char * +const unsigned char * nvpair_unpack_header(int flags, nvpair_t *nvp, const unsigned char *ptr, size_t *leftp) { @@ -434,8 +405,10 @@ nvpair_unpack_header(int flags, nvpair_t *nvp, const unsigned char *ptr, if (nvphdr.nvph_type < NV_TYPE_FIRST) goto failed; #endif - if (nvphdr.nvph_type > NV_TYPE_LAST) + if (nvphdr.nvph_type > NV_TYPE_LAST && + nvphdr.nvph_type != NV_TYPE_NVLIST_UP) { goto failed; + } #if BYTE_ORDER == BIG_ENDIAN if ((flags & NV_FLAG_BIG_ENDIAN) == 0) { @@ -477,7 +450,7 @@ nvpair_unpack_header(int flags, nvpair_t *nvp, const unsigned char *ptr, return (NULL); } -static const unsigned char * +const unsigned char * nvpair_unpack_null(int flags __unused, nvpair_t *nvp, const unsigned char *ptr, size_t *leftp __unused) { @@ -492,7 +465,7 @@ nvpair_unpack_null(int flags __unused, nvpair_t *nvp, const unsigned char *ptr, return (ptr); } -static const unsigned char * +const unsigned char * nvpair_unpack_bool(int flags __unused, nvpair_t *nvp, const unsigned char *ptr, size_t *leftp) { @@ -523,9 +496,9 @@ nvpair_unpack_bool(int flags __unused, nvpair_t *nvp, const unsigned char *ptr, return (ptr); } -static const unsigned char * +const unsigned char * nvpair_unpack_number(int flags, nvpair_t *nvp, const unsigned char *ptr, - size_t *leftp) + size_t *leftp) { PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NUMBER); @@ -549,7 +522,7 @@ nvpair_unpack_number(int flags, nvpair_t *nvp, const unsigned char *ptr, return (ptr); } -static const unsigned char * +const unsigned char * nvpair_unpack_string(int flags __unused, nvpair_t *nvp, const unsigned char *ptr, size_t *leftp) { @@ -577,9 +550,9 @@ nvpair_unpack_string(int flags __unused, nvpair_t *nvp, return (ptr); } -static const unsigned char * -nvpair_unpack_nvlist(int flags __unused, nvpair_t *nvp, - const unsigned char *ptr, size_t *leftp, const int *fds, size_t nfds) +const unsigned char * +nvpair_unpack_nvlist(int *flagsp, nvpair_t *nvp, const unsigned char *ptr, + size_t *leftp, size_t nfds, nvlist_t **child) { nvlist_t *value; @@ -590,19 +563,21 @@ nvpair_unpack_nvlist(int flags __unused, nvpair_t *nvp, return (NULL); } - value = nvlist_xunpack(ptr, nvp->nvp_datasize, fds, nfds); + value = nvlist_create(0); if (value == NULL) return (NULL); - nvp->nvp_data = (uint64_t)(uintptr_t)value; + ptr = nvlist_unpack_header(value, ptr, nfds, flagsp, leftp); + if (ptr == NULL) + return (NULL); - ptr += nvp->nvp_datasize; - *leftp -= nvp->nvp_datasize; + nvp->nvp_data = (uint64_t)(uintptr_t)value; + *child = value; return (ptr); } -static const unsigned char * +const unsigned char * nvpair_unpack_descriptor(int flags, nvpair_t *nvp, const unsigned char *ptr, size_t *leftp, const int *fds, size_t nfds) { @@ -642,7 +617,7 @@ nvpair_unpack_descriptor(int flags, nvpair_t *nvp, const unsigned char *ptr, return (ptr); } -static const unsigned char * +const unsigned char * nvpair_unpack_binary(int flags __unused, nvpair_t *nvp, const unsigned char *ptr, size_t *leftp) { @@ -670,7 +645,7 @@ nvpair_unpack_binary(int flags __unused, nvpair_t *nvp, const unsigned char * nvpair_unpack(int flags, const unsigned char *ptr, size_t *leftp, - const int *fds, size_t nfds, nvpair_t **nvpp) + nvpair_t **nvpp) { nvpair_t *nvp, *tmp; @@ -686,40 +661,10 @@ nvpair_unpack(int flags, const unsigned char *ptr, size_t *leftp, if (tmp == NULL) goto failed; nvp = tmp; + /* Update nvp_name after realloc(). */ nvp->nvp_name = (char *)(nvp + 1); - - switch (nvp->nvp_type) { - case NV_TYPE_NULL: - ptr = nvpair_unpack_null(flags, nvp, ptr, leftp); - break; - case NV_TYPE_BOOL: - ptr = nvpair_unpack_bool(flags, nvp, ptr, leftp); - break; - case NV_TYPE_NUMBER: - ptr = nvpair_unpack_number(flags, nvp, ptr, leftp); - break; - case NV_TYPE_STRING: - ptr = nvpair_unpack_string(flags, nvp, ptr, leftp); - break; - case NV_TYPE_NVLIST: - ptr = nvpair_unpack_nvlist(flags, nvp, ptr, leftp, fds, - nfds); - break; - case NV_TYPE_DESCRIPTOR: - ptr = nvpair_unpack_descriptor(flags, nvp, ptr, leftp, fds, - nfds); - break; - case NV_TYPE_BINARY: - ptr = nvpair_unpack_binary(flags, nvp, ptr, leftp); - break; - default: - PJDLOG_ABORT("Invalid type (%d).", nvp->nvp_type); - } - - if (ptr == NULL) - goto failed; - + nvp->nvp_data = 0x00; nvp->nvp_magic = NVPAIR_MAGIC; *nvpp = nvp; return (ptr); @@ -1018,6 +963,8 @@ nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt, namefmt, nameap); if (nvp == NULL) nvlist_destroy(nvl); + else + nvlist_set_parent(nvl, nvp); return (nvp); } @@ -1172,7 +1119,7 @@ nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap) { nvpair_t *nvp; - if (value == NULL) { + if (value == NULL || nvlist_get_nvpair_parent(value) != NULL) { errno = EINVAL; return (NULL); } @@ -1181,6 +1128,8 @@ nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap) namefmt, nameap); if (nvp == NULL) nvlist_destroy(value); + else + nvlist_set_parent(value, nvp); return (nvp); } diff --git a/lib/libnv/nvpair_impl.h b/lib/libnv/nvpair_impl.h index aa4046c2c3b8..70dbbc09ad99 100644 --- a/lib/libnv/nvpair_impl.h +++ b/lib/libnv/nvpair_impl.h @@ -41,18 +41,52 @@ TAILQ_HEAD(nvl_head, nvpair); void nvpair_assert(const nvpair_t *nvp); -const nvlist_t *nvpair_nvlist(const nvpair_t *nvp); +nvlist_t *nvpair_nvlist(const nvpair_t *nvp); nvpair_t *nvpair_next(const nvpair_t *nvp); nvpair_t *nvpair_prev(const nvpair_t *nvp); void nvpair_insert(struct nvl_head *head, nvpair_t *nvp, nvlist_t *nvl); void nvpair_remove(struct nvl_head *head, nvpair_t *nvp, const nvlist_t *nvl); size_t nvpair_header_size(void); size_t nvpair_size(const nvpair_t *nvp); -unsigned char *nvpair_pack(nvpair_t *nvp, unsigned char *ptr, int64_t *fdidxp, - size_t *leftp); const unsigned char *nvpair_unpack(int flags, const unsigned char *ptr, - size_t *leftp, const int *fds, size_t nfds, nvpair_t **nvpp); + size_t *leftp, nvpair_t **nvpp); void nvpair_free_structure(nvpair_t *nvp); +void nvpair_init_datasize(nvpair_t *nvp); const char *nvpair_type_string(int type); +/* Pack functions. */ +unsigned char *nvpair_pack_header(const nvpair_t *nvp, unsigned char *ptr, + size_t *leftp); +unsigned char *nvpair_pack_null(const nvpair_t *nvp, unsigned char *ptr, + size_t *leftp); +unsigned char *nvpair_pack_bool(const nvpair_t *nvp, unsigned char *ptr, + size_t *leftp); +unsigned char *nvpair_pack_number(const nvpair_t *nvp, unsigned char *ptr, + size_t *leftp); +unsigned char *nvpair_pack_string(const nvpair_t *nvp, unsigned char *ptr, + size_t *leftp); +unsigned char *nvpair_pack_descriptor(const nvpair_t *nvp, unsigned char *ptr, + int64_t *fdidxp, size_t *leftp); +unsigned char *nvpair_pack_binary(const nvpair_t *nvp, unsigned char *ptr, + size_t *leftp); +unsigned char *nvpair_pack_nvlist_up(unsigned char *ptr, size_t *leftp); + +/* Unpack data functions. */ +const unsigned char *nvpair_unpack_header(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp); +const unsigned char *nvpair_unpack_null(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp); +const unsigned char *nvpair_unpack_bool(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp); +const unsigned char *nvpair_unpack_number(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp); +const unsigned char *nvpair_unpack_string(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp); +const unsigned char *nvpair_unpack_nvlist(int *flagsp, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp, size_t nvlist, nvlist_t **child); +const unsigned char *nvpair_unpack_descriptor(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp, const int *fds, size_t nfds); +const unsigned char *nvpair_unpack_binary(int flags, nvpair_t *nvp, + const unsigned char *ptr, size_t *leftp); + #endif /* !_NVPAIR_IMPL_H_ */ diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile index 7b6c9adba76b..f6c90633723d 100644 --- a/lib/libpam/libpam/Makefile +++ b/lib/libpam/libpam/Makefile @@ -66,6 +66,7 @@ SRCS= openpam_asprintf.c \ openpam_straddch.c \ openpam_strlcat.c \ openpam_strlcpy.c \ + openpam_strlset.c \ openpam_subst.c \ openpam_ttyconv.c \ openpam_vasprintf.c \ diff --git a/lib/libpam/modules/pam_login_access/pam_login_access.c b/lib/libpam/modules/pam_login_access/pam_login_access.c index 945d5eb913a7..fe16662dd722 100644 --- a/lib/libpam/modules/pam_login_access/pam_login_access.c +++ b/lib/libpam/modules/pam_login_access/pam_login_access.c @@ -79,20 +79,27 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, gethostname(hostname, sizeof hostname); - if (rhost == NULL || *(const char *)rhost == '\0') { - PAM_LOG("Checking login.access for user %s on tty %s", - (const char *)user, (const char *)tty); - if (login_access(user, tty) != 0) - return (PAM_SUCCESS); - PAM_VERBOSE_ERROR("%s is not allowed to log in on %s", - user, tty); - } else { + if (rhost != NULL && *(const char *)rhost != '\0') { PAM_LOG("Checking login.access for user %s from host %s", (const char *)user, (const char *)rhost); if (login_access(user, rhost) != 0) return (PAM_SUCCESS); PAM_VERBOSE_ERROR("%s is not allowed to log in from %s", - user, rhost); + (const char *)user, (const char *)rhost); + } else if (tty != NULL && *(const char *)tty != '\0') { + PAM_LOG("Checking login.access for user %s on tty %s", + (const char *)user, (const char *)tty); + if (login_access(user, tty) != 0) + return (PAM_SUCCESS); + PAM_VERBOSE_ERROR("%s is not allowed to log in on %s", + (const char *)user, (const char *)tty); + } else { + PAM_LOG("Checking login.access for user %s", + (const char *)user); + if (login_access(user, "***unknown***") != 0) + return (PAM_SUCCESS); + PAM_VERBOSE_ERROR("%s is not allowed to log in", + (const char *)user); } return (PAM_AUTH_ERR); diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile index dafe10df7134..8a0f4b2a702c 100644 --- a/lib/libproc/Makefile +++ b/lib/libproc/Makefile @@ -25,8 +25,23 @@ LDADD+= -lsupc++ DPADD+= ${LIBSTDCPLUSPLUS} .endif -SHLIB_MAJOR= 2 +.if ${MK_CDDL} != "no" +LDADD+= -lctf +DPADD+= ${LIBCTF} +IGNORE_PRAGMA= YES +CFLAGS+= -I${.CURDIR}/../../cddl/contrib/opensolaris/lib/libctf/common \ + -I${.CURDIR}/../../sys/cddl/contrib/opensolaris/uts/common \ + -I${.CURDIR}/../../sys/cddl/compat/opensolaris +.else +CFLAGS+= -DNO_CTF +.endif + +SHLIB_MAJOR= 3 MAN= +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include diff --git a/lib/libproc/libproc.h b/lib/libproc/libproc.h index be77e4b59214..5d81c2bf4505 100644 --- a/lib/libproc/libproc.h +++ b/lib/libproc/libproc.h @@ -37,6 +37,7 @@ #include #include +struct ctf_file; struct proc_handle; typedef void (*proc_child_func)(void *); @@ -67,6 +68,11 @@ typedef struct prmap { #define MA_NOCOREDUMP 0x20 } prmap_t; +typedef struct prsyminfo { + u_int prs_lmid; /* Map id. */ + u_int prs_id; /* Symbol id. */ +} prsyminfo_t; + typedef int proc_map_f(void *, const prmap_t *, const char *); typedef int proc_sym_f(void *, const GElf_Sym *, const char *); @@ -125,7 +131,9 @@ int proc_create(const char *, char * const *, proc_child_func *, void *, struct proc_handle **); int proc_detach(struct proc_handle *, int); int proc_getflags(struct proc_handle *); -int proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *); +int proc_name2sym(struct proc_handle *, const char *, const char *, + GElf_Sym *, prsyminfo_t *); +struct ctf_file *proc_name2ctf(struct proc_handle *, const char *); int proc_setflags(struct proc_handle *, int); int proc_state(struct proc_handle *); pid_t proc_getpid(struct proc_handle *); @@ -133,8 +141,7 @@ int proc_wstatus(struct proc_handle *); int proc_getwstat(struct proc_handle *); char * proc_signame(int, char *, size_t); int proc_read(struct proc_handle *, void *, size_t, size_t); -const lwpstatus_t * - proc_getlwpstatus(struct proc_handle *); +const lwpstatus_t *proc_getlwpstatus(struct proc_handle *); void proc_free(struct proc_handle *); rd_agent_t *proc_rdagent(struct proc_handle *); void proc_updatesyms(struct proc_handle *); diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c index aa879ec128e1..766ff73446e2 100644 --- a/lib/libproc/proc_sym.c +++ b/lib/libproc/proc_sym.c @@ -26,26 +26,37 @@ * LIABILITY, OR 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 +__FBSDID("$FreeBSD$"); + #include +#ifndef NO_CTF +#include +#include +#endif #include #include #include -#include -#include -#include -#include #include +#include +#include +#include #include #include +#ifndef NO_CTF +#include +#endif #include #include "_libproc.h" +#ifdef NO_CTF +typedef struct ctf_file ctf_file_t; +#endif + #ifndef NO_CXA_DEMANGLE extern char *__cxa_demangle(const char *, char *, size_t *, int *); #endif /* NO_CXA_DEMANGLE */ @@ -228,22 +239,56 @@ proc_addr2map(struct proc_handle *p, uintptr_t addr) return (NULL); } +/* + * Look up the symbol at addr, returning a copy of the symbol and its name. + */ +static int +lookup_addr(Elf *e, Elf_Scn *scn, u_long stridx, uintptr_t off, uintptr_t addr, + const char **name, GElf_Sym *symcopy) +{ + GElf_Sym sym; + Elf_Data *data; + const char *s; + uint64_t rsym; + int i; + + if ((data = elf_getdata(scn, NULL)) == NULL) { + DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); + return (1); + } + for (i = 0; gelf_getsym(data, i, &sym) != NULL; i++) { + rsym = off + sym.st_value; + if (addr >= rsym && addr < rsym + sym.st_size) { + s = elf_strptr(e, stridx, sym.st_name); + if (s != NULL) { + *name = s; + memcpy(symcopy, &sym, sizeof(*symcopy)); + /* + * DTrace expects the st_value to contain + * only the address relative to the start of + * the function. + */ + symcopy->st_value = rsym; + return (0); + } + } + } + return (1); +} + int proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name, size_t namesz, GElf_Sym *symcopy) { + GElf_Ehdr ehdr; + GElf_Shdr shdr; Elf *e; Elf_Scn *scn, *dynsymscn = NULL, *symtabscn = NULL; - Elf_Data *data; - GElf_Shdr shdr; - GElf_Sym sym; - GElf_Ehdr ehdr; - int fd, error = -1; - size_t i; - uint64_t rsym; prmap_t *map; - char *s; - unsigned long symtabstridx = 0, dynsymstridx = 0; + const char *s; + uintptr_t off; + u_long symtabstridx = 0, dynsymstridx = 0; + int fd, error = -1; if ((map = proc_addr2map(p, addr)) == NULL) return (-1); @@ -259,6 +304,7 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name, DPRINTFX("ERROR: gelf_getehdr() failed: %s", elf_errmsg(-1)); goto err2; } + /* * Find the index of the STRTAB and SYMTAB sections to locate * symbol names. @@ -275,80 +321,25 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name, dynsymscn = scn; dynsymstridx = shdr.sh_link; break; - default: - break; } } + + off = ehdr.e_type == ET_EXEC ? 0 : map->pr_vaddr; + /* - * Iterate over the Dynamic Symbols table to find the symbol. - * Then look up the string name in STRTAB (.dynstr) + * First look up the symbol in the dynsymtab, and fall back to the + * symtab if the lookup fails. */ - if ((data = elf_getdata(dynsymscn, NULL)) == NULL) { - DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); - goto symtab; - } - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - /* - * Calculate the address mapped to the virtual memory - * by rtld. - */ - if (ehdr.e_type != ET_EXEC) - rsym = map->pr_vaddr + sym.st_value; - else - rsym = sym.st_value; - if (addr >= rsym && addr < rsym + sym.st_size) { - s = elf_strptr(e, dynsymstridx, sym.st_name); - if (s) { - demangle(s, name, namesz); - memcpy(symcopy, &sym, sizeof(sym)); - /* - * DTrace expects the st_value to contain - * only the address relative to the start of - * the function. - */ - symcopy->st_value = rsym; - error = 0; - goto out; - } - } - } -symtab: - /* - * Iterate over the Symbols Table to find the symbol. - * Then look up the string name in STRTAB (.dynstr) - */ - if ((data = elf_getdata(symtabscn, NULL)) == NULL) { - DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); - goto err2; - } - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - /* - * Calculate the address mapped to the virtual memory - * by rtld. - */ - if (ehdr.e_type != ET_EXEC) - rsym = map->pr_vaddr + sym.st_value; - else - rsym = sym.st_value; - if (addr >= rsym && addr < rsym + sym.st_size) { - s = elf_strptr(e, symtabstridx, sym.st_name); - if (s) { - demangle(s, name, namesz); - memcpy(symcopy, &sym, sizeof(sym)); - /* - * DTrace expects the st_value to contain - * only the address relative to the start of - * the function. - */ - symcopy->st_value = rsym; - error = 0; - goto out; - } - } - } + error = lookup_addr(e, dynsymscn, dynsymstridx, off, addr, &s, symcopy); + if (error == 0) + goto out; + + error = lookup_addr(e, symtabscn, symtabstridx, off, addr, &s, symcopy); + if (error == 0) + goto out; + out: + demangle(s, name, namesz); err2: elf_end(e); err1: @@ -363,7 +354,7 @@ proc_name2map(struct proc_handle *p, const char *name) { size_t i; int cnt; - prmap_t *map; + prmap_t *map = NULL; char tmppath[MAXPATHLEN]; struct kinfo_vmentry *kves, *kve; rd_loadobj_t *rdl; @@ -382,47 +373,68 @@ proc_name2map(struct proc_handle *p, const char *name) basename_r(kve->kve_path, tmppath); if (strcmp(tmppath, name) == 0) { map = proc_addr2map(p, kve->kve_start); - free(kves); - return (map); + break; } } free(kves); - return (NULL); - } - if ((name == NULL || strcmp(name, "a.out") == 0) && - p->rdexec != NULL) { + } else + for (i = 0; i < p->nobjs; i++) { + rdl = &p->rdobjs[i]; + basename_r(rdl->rdl_path, tmppath); + if (strcmp(tmppath, name) == 0) { + if ((map = malloc(sizeof(*map))) == NULL) + return (NULL); + proc_rdl2prmap(rdl, map); + break; + } + } + + if (map == NULL && strcmp(name, "a.out") == 0 && p->rdexec != NULL) map = proc_addr2map(p, p->rdexec->rdl_saddr); - return (map); + + return (map); +} + +/* + * Look up the symbol with the given name and return a copy of it. + */ +static int +lookup_name(Elf *e, Elf_Scn *scn, u_long stridx, const char *symbol, + GElf_Sym *symcopy, prsyminfo_t *si) +{ + GElf_Sym sym; + Elf_Data *data; + char *s; + int i; + + if ((data = elf_getdata(scn, NULL)) == NULL) { + DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); + return (1); } - for (i = 0; i < p->nobjs; i++) { - rdl = &p->rdobjs[i]; - basename_r(rdl->rdl_path, tmppath); - if (strcmp(tmppath, name) == 0) { - if ((map = malloc(sizeof(*map))) == NULL) - return (NULL); - proc_rdl2prmap(rdl, map); - return (map); + for (i = 0; gelf_getsym(data, i, &sym) != NULL; i++) { + s = elf_strptr(e, stridx, sym.st_name); + if (s != NULL && strcmp(s, symbol) == 0) { + memcpy(symcopy, &sym, sizeof(*symcopy)); + if (si != NULL) + si->prs_id = i; + return (0); } } - - return (NULL); + return (1); } int proc_name2sym(struct proc_handle *p, const char *object, const char *symbol, - GElf_Sym *symcopy) + GElf_Sym *symcopy, prsyminfo_t *si) { Elf *e; Elf_Scn *scn, *dynsymscn = NULL, *symtabscn = NULL; - Elf_Data *data; GElf_Shdr shdr; - GElf_Sym sym; GElf_Ehdr ehdr; - int fd, error = -1; - size_t i; prmap_t *map; - char *s; - unsigned long symtabstridx = 0, dynsymstridx = 0; + uintptr_t off; + u_long symtabstridx = 0, dynsymstridx = 0; + int fd, error = -1; if ((map = proc_name2map(p, object)) == NULL) { DPRINTFX("ERROR: couldn't find object %s", object); @@ -456,46 +468,25 @@ proc_name2sym(struct proc_handle *p, const char *object, const char *symbol, dynsymscn = scn; dynsymstridx = shdr.sh_link; break; - default: - break; } } + /* - * Iterate over the Dynamic Symbols table to find the symbol. - * Then look up the string name in STRTAB (.dynstr) + * First look up the symbol in the dynsymtab, and fall back to the + * symtab if the lookup fails. */ - if ((data = elf_getdata(dynsymscn, NULL))) { - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - s = elf_strptr(e, dynsymstridx, sym.st_name); - if (s && strcmp(s, symbol) == 0) { - memcpy(symcopy, &sym, sizeof(sym)); - if (ehdr.e_type != ET_EXEC) - symcopy->st_value += map->pr_vaddr; - error = 0; - goto out; - } - } - } - /* - * Iterate over the Symbols Table to find the symbol. - * Then look up the string name in STRTAB (.dynstr) - */ - if ((data = elf_getdata(symtabscn, NULL))) { - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - s = elf_strptr(e, symtabstridx, sym.st_name); - if (s && strcmp(s, symbol) == 0) { - memcpy(symcopy, &sym, sizeof(sym)); - if (ehdr.e_type != ET_EXEC) - symcopy->st_value += map->pr_vaddr; - error = 0; - goto out; - } - } - } + error = lookup_name(e, dynsymscn, dynsymstridx, symbol, symcopy, si); + if (error == 0) + goto out; + + error = lookup_name(e, symtabscn, symtabstridx, symbol, symcopy, si); + if (error == 0) + goto out; + out: - DPRINTFX("found addr 0x%lx for %s", symcopy->st_value, symbol); + off = ehdr.e_type == ET_EXEC ? 0 : map->pr_vaddr; + symcopy->st_value += off; + err2: elf_end(e); err1: @@ -506,6 +497,23 @@ proc_name2sym(struct proc_handle *p, const char *object, const char *symbol, return (error); } +ctf_file_t * +proc_name2ctf(struct proc_handle *p, const char *name) +{ +#ifndef NO_CTF + prmap_t *map; + int error; + + if ((map = proc_name2map(p, name)) == NULL) + return (NULL); + + return (ctf_open(map->pr_mapname, &error)); +#else + (void)p; + (void)name; + return (NULL); +#endif +} int proc_iter_symbyaddr(struct proc_handle *p, const char *object, int which, @@ -543,7 +551,7 @@ proc_iter_symbyaddr(struct proc_handle *p, const char *object, int which, scn = NULL; while ((scn = elf_nextscn(e, scn)) != NULL) { gelf_getshdr(scn, &shdr); - if (which == PR_SYMTAB && + if (which == PR_SYMTAB && shdr.sh_type == SHT_SYMTAB) { foundscn = scn; break; @@ -560,8 +568,7 @@ proc_iter_symbyaddr(struct proc_handle *p, const char *object, int which, DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); goto err2; } - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { + for (i = 0; gelf_getsym(data, i, &sym) != NULL; i++) { if (GELF_ST_BIND(sym.st_info) == STB_LOCAL && (mask & BIND_LOCAL) == 0) continue; diff --git a/lib/libproc/test/Makefile b/lib/libproc/test/Makefile deleted file mode 100644 index e4d33f82ce44..000000000000 --- a/lib/libproc/test/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -SUBDIR= t1-bkpt t2-name2map t3-name2sym - -.include diff --git a/lib/libproc/test/t1-bkpt/Makefile b/lib/libproc/test/t1-bkpt/Makefile deleted file mode 100644 index eb5b37f94936..000000000000 --- a/lib/libproc/test/t1-bkpt/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -PROG= t1-bkpt - -SRCS= t1-bkpt.c - -LDADD= -lproc -lelf -lrtld_db -lutil -DPADD= ${LIBPROC} ${LIBELF} - -MAN= - -.include diff --git a/lib/libproc/test/t2-name2map/Makefile b/lib/libproc/test/t2-name2map/Makefile deleted file mode 100644 index 9002accf6904..000000000000 --- a/lib/libproc/test/t2-name2map/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -PROG= t2-name2map - -SRCS= t2-name2map.c - -LDADD= -lproc -lelf -lrtld_db -lutil -DPADD= ${LIBPROC} ${LIBELF} - -MAN= - -.include diff --git a/lib/libproc/test/t3-name2sym/Makefile b/lib/libproc/test/t3-name2sym/Makefile deleted file mode 100644 index 68e23c6199d9..000000000000 --- a/lib/libproc/test/t3-name2sym/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -PROG= t3-name2sym - -SRCS= t3-name2sym.c - -LDADD= -lproc -lelf -lrtld_db -lutil -DPADD= ${LIBPROC} ${LIBELF} - -MAN= - -.include diff --git a/lib/libproc/tests/Makefile b/lib/libproc/tests/Makefile new file mode 100644 index 000000000000..1f98467df24f --- /dev/null +++ b/lib/libproc/tests/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/lib/libproc + +ATF_TESTS_C+= proc_test + +PROGS= target_prog +SRCS_target_prog= target_prog.c +BINDIR_target_prog= ${TESTSDIR} + +LDADD+= -lelf -lproc -lrtld_db -lutil +DPADD+= ${LIBELF} ${LIBPROC} ${LIBRTLD_DB} ${LIBUTIL} + +# Ensure that symbols aren't stripped from the test program, as they're needed +# for testing symbol lookup. +STRIP= + +MAN= +WARNS?= 6 + +.include diff --git a/lib/libproc/tests/proc_test.c b/lib/libproc/tests/proc_test.c new file mode 100644 index 000000000000..0242b5b5ee96 --- /dev/null +++ b/lib/libproc/tests/proc_test.c @@ -0,0 +1,349 @@ +/*- + * Copyright (c) 2014 Mark Johnston + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 + +static const char *aout_object = "a.out"; +static const char *ldelf_object = "ld-elf.so.1"; +static const char *target_prog_file = "target_prog"; + +/* + * Run the test program. If the sig parameter is set to true, the test program + * will deliver SIGUSR1 to itself during execution. + */ +static struct proc_handle * +start_prog(const struct atf_tc *tc, bool sig) +{ + char *argv[3]; + struct proc_handle *phdl; + int error; + + asprintf(&argv[0], "%s/%s", atf_tc_get_config_var(tc, "srcdir"), + target_prog_file); + ATF_REQUIRE(argv[0] != NULL); + + if (sig) { + argv[1] = strdup("-s"); + argv[2] = NULL; + } else { + argv[1] = NULL; + } + + error = proc_create(argv[0], argv, NULL, NULL, &phdl); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to run '%s'", target_prog_file); + ATF_REQUIRE(phdl != NULL); + + free(argv[0]); + free(argv[1]); + + return (phdl); +} + +static void +set_bkpt(struct proc_handle *phdl, uintptr_t addr, u_long *saved) +{ + int error; + + error = proc_bkptset(phdl, addr, saved); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to set breakpoint at 0x%jx", + (uintmax_t)addr); +} + +static void +remove_bkpt(struct proc_handle *phdl, uintptr_t addr, u_long val) +{ + int error; + + error = proc_bkptdel(phdl, addr, val); + ATF_REQUIRE_EQ_MSG(error, 0, + "failed to delete breakpoint at 0x%jx", (uintmax_t)addr); + + error = proc_regset(phdl, REG_PC, addr); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to reset program counter"); +} + +/* + * Wait for the specified process to hit a breakpoint at the specified symbol. + */ +static void +verify_bkpt(struct proc_handle *phdl, GElf_Sym *sym, const char *symname, + const char *mapname) +{ + char mapbname[MAXPATHLEN], *name; + GElf_Sym tsym; + prmap_t *map; + size_t namesz; + u_long addr; + int error, state; + + state = proc_wstatus(phdl); + ATF_REQUIRE_EQ_MSG(state, PS_STOP, "process has state %d", state); + + /* Get the program counter and decrement it. */ + error = proc_regget(phdl, REG_PC, &addr); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to obtain PC for '%s'", + target_prog_file); + proc_bkptregadj(&addr); + + /* + * Make sure the PC matches the expected value obtained from the symbol + * definition we looked up earlier. + */ + ATF_CHECK_EQ_MSG(addr, sym->st_value, + "program counter 0x%lx doesn't match expected value 0x%jx", + addr, (uintmax_t)sym->st_value); + + /* + * Ensure we can look up the r_debug_state symbol using its starting + * address and that the resulting symbol matches the one we found using + * a name lookup. + */ + namesz = strlen(symname) + 1; + name = malloc(namesz); + ATF_REQUIRE(name != NULL); + + error = proc_addr2sym(phdl, addr, name, namesz, &tsym); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to look up symbol at 0x%lx", addr); + ATF_REQUIRE_EQ(memcmp(sym, &tsym, sizeof(*sym)), 0); + ATF_REQUIRE_EQ(strcmp(symname, name), 0); + free(name); + + map = proc_addr2map(phdl, addr); + ATF_REQUIRE_MSG(map != NULL, "failed to look up map for address 0x%lx", + addr); + basename_r(map->pr_mapname, mapbname); + ATF_REQUIRE_EQ_MSG(strcmp(mapname, mapbname), 0, + "expected map name '%s' doesn't match '%s'", mapname, mapbname); +} + +ATF_TC(map_alias_obj2map); +ATF_TC_HEAD(map_alias_obj2map, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Callers are supposed to be able to use \"a.out\" as an alias for " + "the program executable. Make sure that proc_obj2map() handles " + "this properly."); +} +ATF_TC_BODY(map_alias_obj2map, tc) +{ + struct proc_handle *phdl; + prmap_t *map1, *map2; + + phdl = start_prog(tc, false); + + /* Initialize the rtld_db handle. */ + (void)proc_rdagent(phdl); + + /* Ensure that "target_prog" and "a.out" return the same map. */ + map1 = proc_obj2map(phdl, target_prog_file); + ATF_REQUIRE_MSG(map1 != NULL, "failed to look up map for '%s'", + target_prog_file); + map2 = proc_obj2map(phdl, aout_object); + ATF_REQUIRE_MSG(map2 != NULL, "failed to look up map for '%s'", + aout_object); + ATF_CHECK_EQ(strcmp(map1->pr_mapname, map2->pr_mapname), 0); + + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + + proc_free(phdl); +} + +ATF_TC(map_alias_name2map); +ATF_TC_HEAD(map_alias_name2map, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Callers are supposed to be able to use \"a.out\" as an alias for " + "the program executable. Make sure that proc_name2map() handles " + "this properly."); +} +ATF_TC_BODY(map_alias_name2map, tc) +{ + struct proc_handle *phdl; + prmap_t *map1, *map2; + + phdl = start_prog(tc, false); + + /* Initialize the rtld_db handle. */ + (void)proc_rdagent(phdl); + + /* Ensure that "target_prog" and "a.out" return the same map. */ + map1 = proc_name2map(phdl, target_prog_file); + ATF_REQUIRE_MSG(map1 != NULL, "failed to look up map for '%s'", + target_prog_file); + map2 = proc_name2map(phdl, aout_object); + ATF_REQUIRE_MSG(map2 != NULL, "failed to look up map for '%s'", + aout_object); + ATF_CHECK_EQ(strcmp(map1->pr_mapname, map2->pr_mapname), 0); + + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + + proc_free(phdl); +} + +ATF_TC(map_alias_name2sym); +ATF_TC_HEAD(map_alias_name2sym, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Callers are supposed to be able to use \"a.out\" as an alias for " + "the program executable. Make sure that proc_name2sym() handles " + "this properly."); +} +ATF_TC_BODY(map_alias_name2sym, tc) +{ + GElf_Sym sym1, sym2; + prsyminfo_t si1, si2; + struct proc_handle *phdl; + int error; + + phdl = start_prog(tc, false); + + /* Initialize the rtld_db handle. */ + (void)proc_rdagent(phdl); + + /* + * Make sure that "target_prog:main" and "a.out:main" return the same + * symbol. + */ + error = proc_name2sym(phdl, target_prog_file, "main", &sym1, &si1); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to look up 'main' via %s", + target_prog_file); + error = proc_name2sym(phdl, aout_object, "main", &sym2, &si2); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to look up 'main' via %s", + aout_object); + + ATF_CHECK_EQ(memcmp(&sym1, &sym2, sizeof(sym1)), 0); + ATF_CHECK_EQ(si1.prs_id, si2.prs_id); + + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + + proc_free(phdl); +} + +ATF_TC(symbol_lookup); +ATF_TC_HEAD(symbol_lookup, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Look up a couple of well-known symbols in the test program, place " + "breakpoints on them, and verify that we hit the breakpoints. Also " + "make sure that we can use the breakpoint address to look up the " + "corresponding symbol."); +} +ATF_TC_BODY(symbol_lookup, tc) +{ + GElf_Sym main_sym, r_debug_state_sym; + struct proc_handle *phdl; + u_long saved; + int error; + + phdl = start_prog(tc, false); + + error = proc_name2sym(phdl, target_prog_file, "main", &main_sym, NULL); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to look up 'main'"); + + error = proc_name2sym(phdl, ldelf_object, "r_debug_state", + &r_debug_state_sym, NULL); + ATF_REQUIRE_EQ_MSG(error, 0, "failed to look up 'r_debug_state'"); + + set_bkpt(phdl, r_debug_state_sym.st_value, &saved); + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + verify_bkpt(phdl, &r_debug_state_sym, "r_debug_state", ldelf_object); + remove_bkpt(phdl, r_debug_state_sym.st_value, saved); + + set_bkpt(phdl, main_sym.st_value, &saved); + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + verify_bkpt(phdl, &main_sym, "main", target_prog_file); + remove_bkpt(phdl, main_sym.st_value, saved); + + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + + proc_free(phdl); +} + +ATF_TC(signal_forward); +ATF_TC_HEAD(signal_forward, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Run the test program in a mode which causes it to send a signal " + "to itself. Make sure that we intercept the signal and that " + "proc_continue() forwards it to the process."); +} +ATF_TC_BODY(signal_forward, tc) +{ + struct proc_handle *phdl; + int state, status; + + phdl = start_prog(tc, true); + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + + /* The process should have been interrupted by a signal. */ + state = proc_wstatus(phdl); + ATF_REQUIRE_EQ_MSG(state, PS_STOP, "process has unexpected state %d", + state); + + /* Continue execution and allow the signal to be delivered. */ + ATF_CHECK_EQ_MSG(proc_continue(phdl), 0, "failed to resume execution"); + + /* + * Make sure the process exited with status 0. If it didn't receive the + * SIGUSR1 that it sent to itself, it'll exit with a non-zero exit + * status, causing the test to fail. + */ + state = proc_wstatus(phdl); + ATF_REQUIRE_EQ_MSG(state, PS_UNDEAD, "process has unexpected state %d", + state); + + status = proc_getwstat(phdl); + ATF_REQUIRE(status >= 0); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE_EQ(WEXITSTATUS(status), 0); + + proc_free(phdl); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, map_alias_obj2map); + ATF_TP_ADD_TC(tp, map_alias_name2map); + ATF_TP_ADD_TC(tp, map_alias_name2sym); + ATF_TP_ADD_TC(tp, symbol_lookup); + ATF_TP_ADD_TC(tp, signal_forward); + + return (atf_no_error()); +} diff --git a/lib/libproc/test/t3-name2sym/t3-name2sym.c b/lib/libproc/tests/target_prog.c similarity index 55% rename from lib/libproc/test/t3-name2sym/t3-name2sym.c rename to lib/libproc/tests/target_prog.c index 0be8653d4a49..1edf0ded6122 100644 --- a/lib/libproc/test/t3-name2sym/t3-name2sym.c +++ b/lib/libproc/tests/target_prog.c @@ -1,51 +1,59 @@ -/* - * Copyright (c) 2010 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Rui Paulo under sponsorship from the - * FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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. +/*- + * Copyright (c) 2014 Mark Johnston + * All rights reserved. * - * $FreeBSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 -#include -#include -#include -#include + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include #include +#include + +static volatile sig_atomic_t saw; + +static void +usr1(int sig __unused) +{ + + saw = 1; +} int -main(int argc, char *argv[]) +main(int argc, char **argv) { - prmap_t *map = NULL; - struct proc_handle *phdl; - GElf_Sym sym; - proc_create("./t3-name2sym", argv, NULL, NULL, &phdl); - memset(&sym, 0, sizeof(sym)); - assert(proc_name2sym(phdl, "ld-elf.so.1", "r_debug_state", &sym) == 0); - printf("0x%lx\n", sym.st_value); - assert(proc_name2sym(phdl, "t3-name2sym", "main", &sym) == 0); - printf("0x%lx\n", sym.st_value); + if (argc == 1) + return (EXIT_SUCCESS); + if (argc == 2 && strcmp(argv[1], "-s") == 0) { + if (signal(SIGUSR1, usr1) == SIG_ERR) + err(1, "signal"); + if (kill(getpid(), SIGUSR1) != 0) + err(1, "kill"); + return (saw == 1 ? EXIT_SUCCESS : EXIT_FAILURE); + } + return (EXIT_FAILURE); } diff --git a/lib/librtld_db/rtld_db.c b/lib/librtld_db/rtld_db.c index 2d1f6e697fac..cd4377e12904 100644 --- a/lib/librtld_db/rtld_db.c +++ b/lib/librtld_db/rtld_db.c @@ -237,14 +237,14 @@ rd_reset(rd_agent_t *rdap) GElf_Sym sym; if (proc_name2sym(rdap->rda_php, "ld-elf.so.1", "r_debug_state", - &sym) < 0) + &sym, NULL) < 0) return (RD_ERR); DPRINTF("found r_debug_state at 0x%lx\n", (unsigned long)sym.st_value); rdap->rda_preinit_addr = sym.st_value; rdap->rda_dlactivity_addr = sym.st_value; if (proc_name2sym(rdap->rda_php, "ld-elf.so.1", "_r_debug_postinit", - &sym) < 0) + &sym, NULL) < 0) return (RD_ERR); DPRINTF("found _r_debug_postinit at 0x%lx\n", (unsigned long)sym.st_value); diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index ebf5c300811e..e57407fb4094 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -64,9 +64,6 @@ SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ .if ${MACHINE_CPUARCH} == "arm" .PATH: ${.CURDIR}/../libc/arm/gen -.if ${MK_ARM_EABI} == "no" -SRCS+= divsi3.S -.else # Compiler support functions .PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/ # __clzsi2 and ctzsi2 for various builtin functions @@ -78,7 +75,6 @@ SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c .PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/arm/ SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S -.endif .endif .if ${MACHINE_CPUARCH} == "powerpc" diff --git a/lib/libthr/libthr.3 b/lib/libthr/libthr.3 index bfbebec340bd..4b636ce3fb6c 100644 --- a/lib/libthr/libthr.3 +++ b/lib/libthr/libthr.3 @@ -1,6 +1,11 @@ .\" Copyright (c) 2005 Robert N. M. Watson +.\" Copyright (c) 2014 The FreeBSD Foundation, Inc. .\" All rights reserved. .\" +.\" Part of this documentation was written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -24,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 19, 2007 +.Dd September 26, 2014 .Dt LIBTHR 3 .Os .Sh NAME @@ -45,8 +50,222 @@ has been optimized for use by applications expecting system scope thread semantics, and can provide significant performance improvements compared to .Lb libkse . +.Pp +The library is tightly integrated with the run-time link editor +.Xr ld-elf.so.1 1 +and +.Lb libc ; +all three components must be built from the same source tree. +Mixing +.Li libc +and +.Nm +libraries from different versions of +.Fx +is not supported. +The run-time linker +.Xr ld-elf.so.1 1 +has some code to ensure backward-compatibility with older versions of +.Nm . +.Pp +The man page documents the quirks and tunables of the +.Nm . +When linking with +.Li -lpthread , +the run-time dependency +.Li libthr.so.3 +is recorded in the produced object. +.Sh MUTEX ACQUISITION +A locked mutex (see +.Xr pthread_mutex_lock 3 ) +is represented by a volatile variable of type +.Dv lwpid_t , +which records the global system identifier of the thread +owning the lock. +.Nm +performs a contested mutex acquisition in three stages, each of which +is more resource-consuming than the previous. +The first two stages are only applied for a mutex of +.Dv PTHREAD_MUTEX_ADAPTIVE_NP +type and +.Dv PTHREAD_PRIO_NONE +protocol (see +.Xr pthread_mutexattr 3 ) . +.Pp +First, on SMP systems, a spin loop +is performed, where the library attempts to acquire the lock by +.Xr atomic 9 +operations. +The loop count is controlled by the +.Ev LIBPTHREAD_SPINLOOPS +environment variable, with a default value of 2000. +.Pp +If the spin loop +was unable to acquire the mutex, a yield loop +is executed, performing the same +.Xr atomic 9 +acquisition attempts as the spin loop, +but each attempt is followed by a yield of the CPU time +of the thread using the +.Xr sched_yield 2 +syscall. +By default, the yield loop +is not executed. +This is controlled by the +.Ev LIBPTHREAD_YIELDLOOPS +environment variable. +.Pp +If both the spin and yield loops +failed to acquire the lock, the thread is taken off the CPU and +put to sleep in the kernel with the +.Xr umtx 2 +syscall. +The kernel wakes up a thread and hands the ownership of the lock to +the woken thread when the lock becomes available. +.Sh THREAD STACKS +Each thread is provided with a private user-mode stack area +used by the C runtime. +The size of the main (initial) thread stack is set by the kernel, and is +controlled by the +.Dv RLIMIT_STACK +process resource limit (see +.Xr getrlimit 2 ) . +.Pp +By default, the main thread's stack size is equal to the value of +.Dv RLIMIT_STACK +for the process. +If the +.Ev LIBPTHREAD_SPLITSTACK_MAIN +environment variable is present in the process environment +(its value does not matter), +the main thread's stack is reduced to 4MB on 64bit architectures, and to +2MB on 32bit architectures, when the threading library is initialized. +The rest of the address space area which has been reserved by the +kernel for the initial process stack is used for non-initial thread stacks +in this case. +The presence of the +.Ev LIBPTHREAD_BIGSTACK_MAIN +environment variable overrides +.Ev LIBPTHREAD_SPLITSTACK_MAIN ; +it is kept for backward-compatibility. +.Pp +The size of stacks for threads created by the process at run-time +with the +.Xr pthread_create 3 +call is controlled by thread attributes: see +.Xr pthread_attr 3 , +in particular, the +.Xr pthread_attr_setstacksize 3 , +.Xr pthread_attr_setguardsize 3 +and +.Xr pthread_attr_setstackaddr 3 +functions. +If no attributes for the thread stack size are specified, the default +non-initial thread stack size is 2MB for 64bit architectures, and 1MB +for 32bit architectures. +.Sh RUN-TIME SETTINGS +The following environment variables are recognized by +.Nm +and adjust the operation of the library at run-time: +.Bl -tag -width LIBPTHREAD_SPLITSTACK_MAIN +.It Ev LIBPTHREAD_BIGSTACK_MAIN +Disables the reduction of the initial thread stack enabled by +.Ev LIBPTHREAD_SPLITSTACK_MAIN . +.It Ev LIBPTHREAD_SPLITSTACK_MAIN +Causes a reduction of the initial thread stack, as described in the +section +.Sx THREAD STACKS . +This was the default behaviour of +.Nm +before +.Fx 11.0 . +.It Ev LIBPTHREAD_SPINLOOPS +The integer value of the variable overrides the default count of +iterations in the +.Li spin loop +of the mutex acquisition. +The default count is 2000, set by the +.Dv MUTEX_ADAPTIVE_SPINS +constant in the +.Nm +sources. +.It Ev LIBPTHREAD_YIELDLOOPS +A non-zero integer value enables the yield loop +in the process of the mutex acquisition. +The value is the count of loop operations. +.It Ev LIBPTHREAD_QUEUE_FIFO +The integer value of the variable specifies how often blocked +threads are inserted at the head of the sleep queue, instead of its tail. +Bigger values reduce the frequency of the FIFO discipline. +The value must be between 0 and 255. +.El +.Sh INTERACTION WITH RUN-TIME LINKER +The +.Nm +library must appear before +.Li libc +in the global order of depended objects. +.Pp +Loading +.Nm +with the +.Xr dlopen 3 +call in the process after the program binary is activated +is not supported, and causes miscellaneous and hard-to-diagnose misbehaviour. +This is due to +.Nm +interposing several important +.Li libc +symbols to provide thread-safe services. +In particular, +.Dv errno +and the locking stubs from +.Li libc +are affected. +This requirement is currently not enforced. +.Pp +If the program loads any modules at run-time, and those modules may require +threading services, the main program binary must be linked with +.Li libpthread , +even if it does not require any services from the library. +.Pp +.Nm +cannot be unloaded; the +.Xr dlclose 3 +function does not perform any action when called with a handle for +.Nm . +One of the reasons is that the interposing of +.Li libc +functions cannot be undone. +.Sh SIGNALS +The implementation also interposes the user-installed +.Xr signal 3 +handlers. +This interposing is done to postpone signal delivery to threads which +entered (libthr-internal) critical sections, where the calling +of the user-provided signal handler is unsafe. +An example of such a situation is owning the internal library lock. +When a signal is delivered while the signal handler cannot be safely +called, the call is postponed and performed until after the exit from +the critical section. +This should be taken into account when interpreting +.Xr ktrace 1 +logs. .Sh SEE ALSO -.Xr pthread 3 +.Xr ktrace 1 , +.Xr ld-elf.so.1 1 , +.Xr getrlimit 2 , +.Xr umtx 2 , +.Xr dlclose 3 , +.Xr dlopen 3 , +.Xr errno 3 , +.Xr getenv 3 , +.Xr libc 3 , +.Xr pthread_attr 3 , +.Xr pthread_attr_setstacksize 3 , +.Xr pthread_create 3 , +.Xr signal 3 , +.Xr atomic 9 .Sh AUTHORS .An -nosplit The diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 9bf0e2955158..6d6a53215b8c 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -445,7 +445,7 @@ init_private(void) struct rlimit rlim; size_t len; int mib[2]; - char *env; + char *env, *env_bigstack, *env_splitstack; _thr_umutex_init(&_mutex_static_lock); _thr_umutex_init(&_cond_static_lock); @@ -473,8 +473,9 @@ init_private(void) len = sizeof (_usrstack); if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1) PANIC("Cannot get kern.usrstack from sysctl"); - env = getenv("LIBPTHREAD_BIGSTACK_MAIN"); - if (env != NULL) { + env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN"); + env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN"); + if (env_bigstack != NULL || env_splitstack == NULL) { if (getrlimit(RLIMIT_STACK, &rlim) == -1) PANIC("Cannot get stack rlimit"); _thr_stack_initial = rlim.rlim_cur; diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile index c6bbedead598..aca30237ad1e 100644 --- a/lib/libunbound/Makefile +++ b/lib/libunbound/Makefile @@ -33,7 +33,7 @@ LDADD+= -lssl -lcrypto -lpthread # Misnamed file in upstream source configlexer.l: configlexer.lex - cp -p ${.ALLSRC} ${.TARGET} + cp -fp ${.ALLSRC} ${.TARGET} CLEANFILES+= configlexer.l # Symbol prefix for lex and yacc diff --git a/lib/msun/Makefile b/lib/msun/Makefile index 654d0f5500ba..e8277676818c 100644 --- a/lib/msun/Makefile +++ b/lib/msun/Makefile @@ -98,6 +98,7 @@ COMMON_SRCS+= s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c # If long double != double use these; otherwise, we alias the double versions. COMMON_SRCS+= e_acoshl.c e_acosl.c e_asinl.c e_atan2l.c e_atanhl.c \ e_coshl.c e_fmodl.c e_hypotl.c \ + e_lgammal.c e_lgammal_r.c \ e_remainderl.c e_sinhl.c e_sqrtl.c \ invtrig.c k_cosl.c k_sinl.c k_tanl.c \ s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \ @@ -188,7 +189,8 @@ MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3 \ ilogb.3 logb.3 ilogb.3 logbf.3 ilogb.3 logbl.3 MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3 MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3 -MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 \ +MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 \ + lgamma.3 lgammaf.3 lgamma.3 lgammal.3 \ lgamma.3 tgamma.3 lgamma.3 tgammaf.3 MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log10l.3 \ log.3 log1p.3 log.3 log1pf.3 log.3 log1pl.3 \ diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map index e53ca07118fd..d5b7f4699f10 100644 --- a/lib/msun/Symbol.map +++ b/lib/msun/Symbol.map @@ -269,6 +269,7 @@ FBSD_1.3 { erfl; expl; expm1l; + lgammal; log10l; log1pl; log2l; @@ -276,7 +277,11 @@ FBSD_1.3 { sinhl; tanhl; /* Implemented as weak aliases for imprecise versions */ - lgammal; powl; tgammal; }; + +/* First added in 11.0-CURRENT */ +FBSD_1.4 { + lgammal_r; +}; diff --git a/lib/msun/ld128/e_lgammal_r.c b/lib/msun/ld128/e_lgammal_r.c new file mode 100644 index 000000000000..13f8f75a46c6 --- /dev/null +++ b/lib/msun/ld128/e_lgammal_r.c @@ -0,0 +1,333 @@ +/* @(#)e_lgamma_r.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * See e_lgamma_r.c for complete comments. + * + * Converted to long double by Steven G. Kargl. + */ + +#include "fpmath.h" +#include "math.h" +#include "math_private.h" + +static const volatile double vzero = 0; + +static const double +zero= 0, +half= 0.5, +one = 1; + +static const long double +pi = 3.14159265358979323846264338327950288e+00L; +/* + * Domain y in [0x1p-119, 0.28], range ~[-1.4065e-36, 1.4065e-36]: + * |(lgamma(2 - y) + y / 2) / y - a(y)| < 2**-119.1 + */ +static const long double +a0 = 7.72156649015328606065120900824024296e-02L, +a1 = 3.22467033424113218236207583323018498e-01L, +a2 = 6.73523010531980951332460538330282217e-02L, +a3 = 2.05808084277845478790009252803463129e-02L, +a4 = 7.38555102867398526627292839296001626e-03L, +a5 = 2.89051033074152328576829509522483468e-03L, +a6 = 1.19275391170326097618357349881842913e-03L, +a7 = 5.09669524743042462515256340206203019e-04L, +a8 = 2.23154758453578096143609255559576017e-04L, +a9 = 9.94575127818397632126978731542755129e-05L, +a10 = 4.49262367375420471287545895027098145e-05L, +a11 = 2.05072127845117995426519671481628849e-05L, +a12 = 9.43948816959096748454087141447939513e-06L, +a13 = 4.37486780697359330303852050718287419e-06L, +a14 = 2.03920783892362558276037363847651809e-06L, +a15 = 9.55191070057967287877923073200324649e-07L, +a16 = 4.48993286185740853170657139487620560e-07L, +a17 = 2.13107543597620911675316728179563522e-07L, +a18 = 9.70745379855304499867546549551023473e-08L, +a19 = 5.61889970390290257926487734695402075e-08L, +a20 = 6.42739653024130071866684358960960951e-09L, +a21 = 3.34491062143649291746195612991870119e-08L, +a22 = -1.57068547394315223934653011440641472e-08L, +a23 = 1.30812825422415841213733487745200632e-08L; +/* + * Domain x in [tc-0.24, tc+0.28], range ~[-6.3201e-37, 6.3201e-37]: + * |(lgamma(x) - tf) - t(x - tc)| < 2**-120.3. + */ +static const long double +tc = 1.46163214496836234126265954232572133e+00L, +tf = -1.21486290535849608095514557177691584e-01L, +tt = 1.57061739945077675484237837992951704e-36L, +t0 = -1.99238329499314692728655623767019240e-36L, +t1 = -6.08453430711711404116887457663281416e-35L, +t2 = 4.83836122723810585213722380854828904e-01L, +t3 = -1.47587722994530702030955093950668275e-01L, +t4 = 6.46249402389127526561003464202671923e-02L, +t5 = -3.27885410884813055008502586863748063e-02L, +t6 = 1.79706751152103942928638276067164935e-02L, +t7 = -1.03142230366363872751602029672767978e-02L, +t8 = 6.10053602051788840313573150785080958e-03L, +t9 = -3.68456960831637325470641021892968954e-03L, +t10 = 2.25976482322181046611440855340968560e-03L, +t11 = -1.40225144590445082933490395950664961e-03L, +t12 = 8.78232634717681264035014878172485575e-04L, +t13 = -5.54194952796682301220684760591403899e-04L, +t14 = 3.51912956837848209220421213975000298e-04L, +t15 = -2.24653443695947456542669289367055542e-04L, +t16 = 1.44070395420840737695611929680511823e-04L, +t17 = -9.27609865550394140067059487518862512e-05L, +t18 = 5.99347334438437081412945428365433073e-05L, +t19 = -3.88458388854572825603964274134801009e-05L, +t20 = 2.52476631610328129217896436186551043e-05L, +t21 = -1.64508584981658692556994212457518536e-05L, +t22 = 1.07434583475987007495523340296173839e-05L, +t23 = -7.03070407519397260929482550448878399e-06L, +t24 = 4.60968590693753579648385629003100469e-06L, +t25 = -3.02765473778832036018438676945512661e-06L, +t26 = 1.99238771545503819972741288511303401e-06L, +t27 = -1.31281299822614084861868817951788579e-06L, +t28 = 8.60844432267399655055574642052370223e-07L, +t29 = -5.64535486432397413273248363550536374e-07L, +t30 = 3.99357783676275660934903139592727737e-07L, +t31 = -2.95849029193433121795495215869311610e-07L, +t32 = 1.37790144435073124976696250804940384e-07L; +/* + * Domain y in [-0.1, 0.232], range ~[-1.4046e-37, 1.4181e-37]: + * |(lgamma(1 + y) + 0.5 * y) / y - u(y) / v(y)| < 2**-122.8 + */ +static const long double +u0 = -7.72156649015328606065120900824024311e-02L, +u1 = 4.24082772271938167430983113242482656e-01L, +u2 = 2.96194003481457101058321977413332171e+00L, +u3 = 6.49503267711258043997790983071543710e+00L, +u4 = 7.40090051288150177152835698948644483e+00L, +u5 = 4.94698036296756044610805900340723464e+00L, +u6 = 2.00194224610796294762469550684947768e+00L, +u7 = 4.82073087750608895996915051568834949e-01L, +u8 = 6.46694052280506568192333848437585427e-02L, +u9 = 4.17685526755100259316625348933108810e-03L, +u10 = 9.06361003550314327144119307810053410e-05L, +v1 = 5.15937098592887275994320496999951947e+00L, +v2 = 1.14068418766251486777604403304717558e+01L, +v3 = 1.41164839437524744055723871839748489e+01L, +v4 = 1.07170702656179582805791063277960532e+01L, +v5 = 5.14448694179047879915042998453632434e+00L, +v6 = 1.55210088094585540637493826431170289e+00L, +v7 = 2.82975732849424562719893657416365673e-01L, +v8 = 2.86424622754753198010525786005443539e-02L, +v9 = 1.35364253570403771005922441442688978e-03L, +v10 = 1.91514173702398375346658943749580666e-05L, +v11 = -3.25364686890242327944584691466034268e-08L; +/* + * Domain x in (2, 3], range ~[-1.3341e-36, 1.3536e-36]: + * |(lgamma(y+2) - 0.5 * y) / y - s(y)/r(y)| < 2**-120.1 + * with y = x - 2. + */ +static const long double +s0 = -7.72156649015328606065120900824024297e-02L, +s1 = 1.23221687850916448903914170805852253e-01L, +s2 = 5.43673188699937239808255378293820020e-01L, +s3 = 6.31998137119005233383666791176301800e-01L, +s4 = 3.75885340179479850993811501596213763e-01L, +s5 = 1.31572908743275052623410195011261575e-01L, +s6 = 2.82528453299138685507186287149699749e-02L, +s7 = 3.70262021550340817867688714880797019e-03L, +s8 = 2.83374000312371199625774129290973648e-04L, +s9 = 1.15091830239148290758883505582343691e-05L, +s10 = 2.04203474281493971326506384646692446e-07L, +s11 = 9.79544198078992058548607407635645763e-10L, +r1 = 2.58037466655605285937112832039537492e+00L, +r2 = 2.86289413392776399262513849911531180e+00L, +r3 = 1.78691044735267497452847829579514367e+00L, +r4 = 6.89400381446725342846854215600008055e-01L, +r5 = 1.70135865462567955867134197595365343e-01L, +r6 = 2.68794816183964420375498986152766763e-02L, +r7 = 2.64617234244861832870088893332006679e-03L, +r8 = 1.52881761239180800640068128681725702e-04L, +r9 = 4.63264813762296029824851351257638558e-06L, +r10 = 5.89461519146957343083848967333671142e-08L, +r11 = 1.79027678176582527798327441636552968e-10L; +/* + * Domain z in [8, 0x1p70], range ~[-9.8214e-35, 9.8214e-35]: + * |lgamma(x) - (x - 0.5) * (log(x) - 1) - w(1/x)| < 2**-113.0 + */ +static const long double +w0 = 4.18938533204672741780329736405617738e-01L, +w1 = 8.33333333333333333333333333332852026e-02L, +w2 = -2.77777777777777777777777727810123528e-03L, +w3 = 7.93650793650793650791708939493907380e-04L, +w4 = -5.95238095238095234390450004444370959e-04L, +w5 = 8.41750841750837633887817658848845695e-04L, +w6 = -1.91752691752396849943172337347259743e-03L, +w7 = 6.41025640880333069429106541459015557e-03L, +w8 = -2.95506530801732133437990433080327074e-02L, +w9 = 1.79644237328444101596766586979576927e-01L, +w10 = -1.39240539108367641920172649259736394e+00L, +w11 = 1.33987701479007233325288857758641761e+01L, +w12 = -1.56363596431084279780966590116006255e+02L, +w13 = 2.14830978044410267201172332952040777e+03L, +w14 = -3.28636067474227378352761516589092334e+04L, +w15 = 5.06201257747865138432663574251462485e+05L, +w16 = -6.79720123352023636706247599728048344e+06L, +w17 = 6.57556601705472106989497289465949255e+07L, +w18 = -3.26229058141181783534257632389415580e+08L; + +static long double +sin_pil(long double x) +{ + volatile long double vz; + long double y,z; + uint64_t lx, n; + uint16_t hx; + + y = -x; + + vz = y+0x1.p112; + z = vz-0x1.p112; + if (z == y) + return zero; + + vz = y+0x1.p110; + EXTRACT_LDBL128_WORDS(hx,lx,n,vz); + z = vz-0x1.p110; + if (z > y) { + z -= 0.25; + n--; + } + n &= 7; + y = y - z + n * 0.25L; + + switch (n) { + case 0: y = __kernel_sinl(pi*y,zero,0); break; + case 1: + case 2: y = __kernel_cosl(pi*(0.5-y),zero); break; + case 3: + case 4: y = __kernel_sinl(pi*(one-y),zero,0); break; + case 5: + case 6: y = -__kernel_cosl(pi*(y-1.5),zero); break; + default: y = __kernel_sinl(pi*(y-2.0),zero,0); break; + } + return -y; +} + + +long double +lgammal_r(long double x, int *signgamp) +{ + long double nadj,p,p1,p2,p3,q,r,t,w,y,z; + uint64_t llx,lx; + int i; + uint16_t hx; + + EXTRACT_LDBL128_WORDS(hx, lx, llx, x); + + if((hx & 0x7fff) == 0x7fff) { /* erfl(nan)=nan */ + i = (hx>>15)<<1; + return (1-i)+one/x; /* erfl(+-inf)=+-1 */ + } + + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ + *signgamp = 1; + if((hx & 0x7fff) == 0x7fff) /* x is +-Inf or NaN */ + return x*x; + if((hx==0||hx==0x8000)&&lx==0) { + if (hx&0x8000) + *signgamp = -1; + return one/vzero; + } + + /* purge off tiny and negative arguments */ + if(fabsl(x)<0x1p-119L) { + if(hx&0x8000) { + *signgamp = -1; + return -logl(-x); + } else return -logl(x); + } + if(hx&0x8000) { + if(fabsl(x)>=0x1p112) + return one/vzero; + t = sin_pil(x); + if(t==zero) return one/vzero; + nadj = logl(pi/fabsl(t*x)); + if(t=0.7315998077392578) {y = 1-x; i= 0;} + else if(x>=0.2316399812698364) {y= x-(tc-1); i=1;} + else {y = x; i=2;} + } else { + r = 0; + if(x>=1.7316312789916992) {y=2-x;i=0;} + else if(x>=1.2316322326660156) {y=x-tc;i=1;} + else {y=x-1;i=2;} + } + switch(i) { + case 0: + z = y*y; + p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*(a10+z*(a12+z*(a14+z*(a16+ + z*(a18+z*(a20+z*a22)))))))))); + p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*(a11+z*(a13+z*(a15+ + z*(a17+z*(a19+z*(a21+z*a23))))))))))); + p = y*p1+p2; + r += (p-y/2); break; + case 1: + p = t0+y*t1+tt+y*y*(t2+y*(t3+y*(t4+y*(t5+y*(t6+y*(t7+y*(t8+ + y*(t9+y*(t10+y*(t11+y*(t12+y*(t13+y*(t14+y*(t15+y*(t16+ + y*(t17+y*(t18+y*(t19+y*(t20+y*(t21+y*(t22+y*(t23+ + y*(t24+y*(t25+y*(t26+y*(t27+y*(t28+y*(t29+y*(t30+ + y*(t31+y*t32)))))))))))))))))))))))))))))); + r += (tf + p); break; + case 2: + p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*(u5+y*(u6+y*(u7+ + y*(u8+y*(u9+y*u10)))))))))); + p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*(v5+y*(v6+y*(v7+ + y*(v8+y*(v9+y*(v10+y*v11)))))))))); + r += (-y/2 + p1/p2); + } + } + else if(x<8) { + i = x; + y = x-i; + p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*(s6+y*(s7+y*(s8+ + y*(s9+y*(s10+y*s11))))))))))); + q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*(r6+y*(r7+y*(r8+ + y*(r9+y*(r10+y*r11)))))))))); + r = y/2+p/q; + z = 1; /* lgamma(1+s) = log(s) + lgamma(s) */ + switch(i) { + case 7: z *= (y+6); /* FALLTHRU */ + case 6: z *= (y+5); /* FALLTHRU */ + case 5: z *= (y+4); /* FALLTHRU */ + case 4: z *= (y+3); /* FALLTHRU */ + case 3: z *= (y+2); /* FALLTHRU */ + r += logl(z); break; + } + } else if (x < 0x1p119L) { + t = logl(x); + z = one/x; + y = z*z; + w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*(w6+y*(w7+y*(w8+ + y*(w9+y*(w10+y*(w11+y*(w12+y*(w13+y*(w14+y*(w15+y*(w16+ + y*(w17+y*w18))))))))))))))))); + r = (x-half)*(t-one)+w; + } else + r = x*(logl(x)-1); + if(hx&0x8000) r = nadj - r; + return r; +} diff --git a/lib/msun/ld80/e_lgammal_r.c b/lib/msun/ld80/e_lgammal_r.c new file mode 100644 index 000000000000..621b04e74022 --- /dev/null +++ b/lib/msun/ld80/e_lgammal_r.c @@ -0,0 +1,349 @@ +/* @(#)e_lgamma_r.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * See s_lgamma_r.c for complete comments. + * + * Converted to long double by Steven G. Kargl. + */ + +#include +#ifdef __i386__ +#include +#endif + +#include "fpmath.h" +#include "math.h" +#include "math_private.h" + +static const volatile double vzero = 0; + +static const double +zero= 0, +half= 0.5, +one = 1; + +static const union IEEEl2bits +piu = LD80C(0xc90fdaa22168c235, 1, 3.14159265358979323851e+00L); +#define pi (piu.e) +/* + * Domain y in [0x1p-70, 0.27], range ~[-4.5264e-22, 4.5264e-22]: + * |(lgamma(2 - y) + y / 2) / y - a(y)| < 2**-70.9 + */ +static const union IEEEl2bits +a0u = LD80C(0x9e233f1bed863d26, -4, 7.72156649015328606028e-02L), +a1u = LD80C(0xa51a6625307d3249, -2, 3.22467033424113218889e-01L), +a2u = LD80C(0x89f000d2abafda8c, -4, 6.73523010531979398946e-02L), +a3u = LD80C(0xa8991563eca75f26, -6, 2.05808084277991211934e-02L), +a4u = LD80C(0xf2027e10634ce6b6, -8, 7.38555102796070454026e-03L), +a5u = LD80C(0xbd6eb76dd22187f4, -9, 2.89051035162703932972e-03L), +a6u = LD80C(0x9c562ab05e0458ed, -10, 1.19275351624639999297e-03L), +a7u = LD80C(0x859baed93ee48e46, -11, 5.09674593842117925320e-04L), +a8u = LD80C(0xe9f28a4432949af2, -13, 2.23109648015769155122e-04L), +a9u = LD80C(0xd12ad0d9b93c6bb0, -14, 9.97387167479808509830e-05L), +a10u= LD80C(0xb7522643c78a219b, -15, 4.37071076331030136818e-05L), +a11u= LD80C(0xca024dcdece2cb79, -16, 2.40813493372040143061e-05L), +a12u= LD80C(0xbb90fb6968ebdbf9, -19, 2.79495621083634031729e-06L), +a13u= LD80C(0xba1c9ffeeae07b37, -17, 1.10931287015513924136e-05L); +#define a0 (a0u.e) +#define a1 (a1u.e) +#define a2 (a2u.e) +#define a3 (a3u.e) +#define a4 (a4u.e) +#define a5 (a5u.e) +#define a6 (a6u.e) +#define a7 (a7u.e) +#define a8 (a8u.e) +#define a9 (a9u.e) +#define a10 (a10u.e) +#define a11 (a11u.e) +#define a12 (a12u.e) +#define a13 (a13u.e) +/* + * Domain x in [tc-0.24, tc+0.28], range ~[-6.1205e-22, 6.1205e-22]: + * |(lgamma(x) - tf) - t(x - tc)| < 2**-70.5 + */ +static const union IEEEl2bits +tcu = LD80C(0xbb16c31ab5f1fb71, 0, 1.46163214496836234128e+00L), +tfu = LD80C(0xf8cdcde61c520e0f, -4, -1.21486290535849608093e-01L), +ttu = LD80C(0xd46ee54b27d4de99, -69, -2.81152980996018785880e-21L), +t0u = LD80C(0x80b9406556a62a6b, -68, 3.40728634996055147231e-21L), +t1u = LD80C(0xc7e9c6f6df3f8c39, -67, -1.05833162742737073665e-20L), +t2u = LD80C(0xf7b95e4771c55d51, -2, 4.83836122723810583532e-01L), +t3u = LD80C(0x97213c6e35e119ff, -3, -1.47587722994530691476e-01L), +t4u = LD80C(0x845a14a6a81dc94b, -4, 6.46249402389135358063e-02L), +t5u = LD80C(0x864d46fa89997796, -5, -3.27885410884846056084e-02L), +t6u = LD80C(0x93373cbd00297438, -6, 1.79706751150707171293e-02L), +t7u = LD80C(0xa8fcfca7eddc8d1d, -7, -1.03142230361450732547e-02L), +t8u = LD80C(0xc7e7015ff4bc45af, -8, 6.10053603296546099193e-03L), +t9u = LD80C(0xf178d2247adc5093, -9, -3.68456964904901200152e-03L), +t10u = LD80C(0x94188d58f12e5e9f, -9, 2.25976420273774583089e-03L), +t11u = LD80C(0xb7cbaef14e1406f1, -10, -1.40224943666225639823e-03L), +t12u = LD80C(0xe63a671e6704ea4d, -11, 8.78250640744776944887e-04L), +t13u = LD80C(0x914b6c9cae61783e, -11, -5.54255012657716808811e-04L), +t14u = LD80C(0xb858f5bdb79276fe, -12, 3.51614951536825927370e-04L), +t15u = LD80C(0xea73e744c34b9591, -13, -2.23591563824520112236e-04L), +t16u = LD80C(0x99aeabb0d67ba835, -13, 1.46562869351659194136e-04L), +t17u = LD80C(0xd7c6938325db2024, -14, -1.02889866046435680588e-04L), +t18u = LD80C(0xe24cb1e3b0474775, -15, 5.39540265505221957652e-05L); +#define tc (tcu.e) +#define tf (tfu.e) +#define tt (ttu.e) +#define t0 (t0u.e) +#define t1 (t1u.e) +#define t2 (t2u.e) +#define t3 (t3u.e) +#define t4 (t4u.e) +#define t5 (t5u.e) +#define t6 (t6u.e) +#define t7 (t7u.e) +#define t8 (t8u.e) +#define t9 (t9u.e) +#define t10 (t10u.e) +#define t11 (t11u.e) +#define t12 (t12u.e) +#define t13 (t13u.e) +#define t14 (t14u.e) +#define t15 (t15u.e) +#define t16 (t16u.e) +#define t17 (t17u.e) +#define t18 (t18u.e) +/* + * Domain y in [-0.1, 0.232], range ~[-8.1938e-22, 8.3815e-22]: + * |(lgamma(1 + y) + 0.5 * y) / y - u(y) / v(y)| < 2**-71.2 + */ +static const union IEEEl2bits +u0u = LD80C(0x9e233f1bed863d27, -4, -7.72156649015328606095e-02L), +u1u = LD80C(0x98280ee45e4ddd3d, -1, 5.94361239198682739769e-01L), +u2u = LD80C(0xe330c8ead4130733, 0, 1.77492629495841234275e+00L), +u3u = LD80C(0xd4a213f1a002ec52, 0, 1.66119622514818078064e+00L), +u4u = LD80C(0xa5a9ca6f5bc62163, -1, 6.47122051417476492989e-01L), +u5u = LD80C(0xc980e49cd5b019e6, -4, 9.83903751718671509455e-02L), +u6u = LD80C(0xff636a8bdce7025b, -9, 3.89691687802305743450e-03L), +v1u = LD80C(0xbd109c533a19fbf5, 1, 2.95413883330948556544e+00L), +v2u = LD80C(0xd295cbf96f31f099, 1, 3.29039286955665403176e+00L), +v3u = LD80C(0xdab8bcfee40496cb, 0, 1.70876276441416471410e+00L), +v4u = LD80C(0xd2f2dc3638567e9f, -2, 4.12009126299534668571e-01L), +v5u = LD80C(0xa07d9b0851070f41, -5, 3.91822868305682491442e-02L), +v6u = LD80C(0xe3cd8318f7adb2c4, -11, 8.68998648222144351114e-04L); +#define u0 (u0u.e) +#define u1 (u1u.e) +#define u2 (u2u.e) +#define u3 (u3u.e) +#define u4 (u4u.e) +#define u5 (u5u.e) +#define u6 (u6u.e) +#define v1 (v1u.e) +#define v2 (v2u.e) +#define v3 (v3u.e) +#define v4 (v4u.e) +#define v5 (v5u.e) +#define v6 (v6u.e) +/* + * Domain x in (2, 3], range ~[-3.3648e-22, 3.4416e-22]: + * |(lgamma(y+2) - 0.5 * y) / y - s(y)/r(y)| < 2**-72.3 + * with y = x - 2. + */ +static const union IEEEl2bits +s0u = LD80C(0x9e233f1bed863d27, -4, -7.72156649015328606095e-02L), +s1u = LD80C(0xd3ff0dcc7fa91f94, -3, 2.07027640921219389860e-01L), +s2u = LD80C(0xb2bb62782478ef31, -2, 3.49085881391362090549e-01L), +s3u = LD80C(0xb49f7438c4611a74, -3, 1.76389518704213357954e-01L), +s4u = LD80C(0x9a957008fa27ecf9, -5, 3.77401710862930008071e-02L), +s5u = LD80C(0xda9b389a6ca7a7ac, -9, 3.33566791452943399399e-03L), +s6u = LD80C(0xbc7a2263faf59c14, -14, 8.98728786745638844395e-05L), +r1u = LD80C(0xbf5cff5b11477d4d, 0, 1.49502555796294337722e+00L), +r2u = LD80C(0xd9aec89de08e3da6, -1, 8.50323236984473285866e-01L), +r3u = LD80C(0xeab7ae5057c443f9, -3, 2.29216312078225806131e-01L), +r4u = LD80C(0xf29707d9bd2b1e37, -6, 2.96130326586640089145e-02L), +r5u = LD80C(0xd376c2f09736c5a3, -10, 1.61334161411590662495e-03L), +r6u = LD80C(0xc985983d0cd34e3d, -16, 2.40232770710953450636e-05L), +r7u = LD80C(0xe5c7a4f7fc2ef13d, -25, -5.34997929289167573510e-08L); +#define s0 (s0u.e) +#define s1 (s1u.e) +#define s2 (s2u.e) +#define s3 (s3u.e) +#define s4 (s4u.e) +#define s5 (s5u.e) +#define s6 (s6u.e) +#define r1 (r1u.e) +#define r2 (r2u.e) +#define r3 (r3u.e) +#define r4 (r4u.e) +#define r5 (r5u.e) +#define r6 (r6u.e) +#define r7 (r7u.e) +/* + * Domain z in [8, 0x1p70], range ~[-3.0235e-22, 3.0563e-22]: + * |lgamma(x) - (x - 0.5) * (log(x) - 1) - w(1/x)| < 2**-71.7 + */ +static const union IEEEl2bits +w0u = LD80C(0xd67f1c864beb4a69, -2, 4.18938533204672741776e-01L), +w1u = LD80C(0xaaaaaaaaaaaaaaa1, -4, 8.33333333333333332678e-02L), +w2u = LD80C(0xb60b60b60b5491c9, -9, -2.77777777777760927870e-03L), +w3u = LD80C(0xd00d00cf58aede4c, -11, 7.93650793490637233668e-04L), +w4u = LD80C(0x9c09bf626783d4a5, -11, -5.95238023926039051268e-04L), +w5u = LD80C(0xdca7cadc5baa517b, -11, 8.41733700408000822962e-04L), +w6u = LD80C(0xfb060e361e1ffd07, -10, -1.91515849570245136604e-03L), +w7u = LD80C(0xcbd5101bb58d1f2b, -8, 6.22046743903262649294e-03L), +w8u = LD80C(0xad27a668d32c821b, -6, -2.11370706734662081843e-02L); +#define w0 (w0u.e) +#define w1 (w1u.e) +#define w2 (w2u.e) +#define w3 (w3u.e) +#define w4 (w4u.e) +#define w5 (w5u.e) +#define w6 (w6u.e) +#define w7 (w7u.e) +#define w8 (w8u.e) + +static long double +sin_pil(long double x) +{ + volatile long double vz; + long double y,z; + uint64_t n; + uint16_t hx; + + y = -x; + + vz = y+0x1p63L; + z = vz-0x1p63L; + if (z == y) + return zero; + + vz = y+0x1p61; + EXTRACT_LDBL80_WORDS(hx,n,vz); + z = vz-0x1p61; + if (z > y) { + z -= 0.25; /* adjust to round down */ + n--; + } + n &= 7; /* octant of y mod 2 */ + y = y - z + n * 0.25; /* y mod 2 */ + + switch (n) { + case 0: y = __kernel_sinl(pi*y,zero,0); break; + case 1: + case 2: y = __kernel_cosl(pi*(0.5-y),zero); break; + case 3: + case 4: y = __kernel_sinl(pi*(one-y),zero,0); break; + case 5: + case 6: y = -__kernel_cosl(pi*(y-1.5),zero); break; + default: y = __kernel_sinl(pi*(y-2.0),zero,0); break; + } + return -y; +} + +long double +lgammal_r(long double x, int *signgamp) +{ + long double nadj,p,p1,p2,p3,q,r,t,w,y,z; + uint64_t lx; + int i; + uint16_t hx; + + EXTRACT_LDBL80_WORDS(hx,lx,x); + + /* purge off +-inf, NaN, +-0 */ + *signgamp = 1; + if((hx & 0x7fff) == 0x7fff) /* x is +-Inf or NaN */ + return x*x; + if((hx==0||hx==0x8000)&&lx==0) { + if (hx&0x8000) + *signgamp = -1; + return one/vzero; + } + + ENTERI(); + + /* purge off tiny and negative arguments */ + if(fabsl(x)<0x1p-70L) { /* |x|<2**-70, return -log(|x|) */ + if(hx&0x8000) { + *signgamp = -1; + RETURNI(-logl(-x)); + } else RETURNI(-logl(x)); + } + if(hx&0x8000) { + if(fabsl(x)>=0x1p63) /* |x|>=2**(p-1), must be -integer */ + RETURNI(one/vzero); + t = sin_pil(x); + if(t==zero) RETURNI(one/vzero); /* -integer */ + nadj = logl(pi/fabsl(t*x)); + if(t=0.7315998077392578) {y = 1-x; i= 0;} + else if(x>=0.2316399812698364) {y= x-(tc-1); i=1;} + else {y = x; i=2;} + } else { + r = 0; + if(x>=1.7316312789916992) {y=2-x;i=0;} + else if(x>=1.2316322326660156) {y=x-tc;i=1;} + else {y=x-1;i=2;} + } + switch(i) { + case 0: + z = y*y; + p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*(a10+z*a12))))); + p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*(a11+z*a13)))))); + p = y*p1+p2; + r += (p-y/2); break; + case 1: + p = t0+y*t1+tt+y*y*(t2+y*(t3+y*(t4+y*(t5+y*(t6+y*(t7+y*(t8+ + y*(t9+y*(t10+y*(t11+y*(t12+y*(t13+y*(t14+y*(t15+y*(t16+ + y*(t17+y*t18)))))))))))))))); + r += (tf + p); break; + case 2: + p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*(u5+y*u6)))))); + p2 = 1+y*(v1+y*(v2+y*(v3+y*(v4+y*(v5+y*v6))))); + r += (-y/2 + p1/p2); + } + } + else if(x<8) { + i = x; + y = x-i; + p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); + q = 1+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*(r6+y*r7)))))); + r = y/2+p/q; + z = 1; /* lgamma(1+s) = log(s) + lgamma(s) */ + switch(i) { + case 7: z *= (y+6); /* FALLTHRU */ + case 6: z *= (y+5); /* FALLTHRU */ + case 5: z *= (y+4); /* FALLTHRU */ + case 4: z *= (y+3); /* FALLTHRU */ + case 3: z *= (y+2); /* FALLTHRU */ + r += logl(z); break; + } + /* 8.0 <= x < 2**70 */ + } else if (x < 0x1p70L) { + t = logl(x); + z = one/x; + y = z*z; + w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*(w6+y*(w7+y*w8))))))); + r = (x-half)*(t-one)+w; + } else + /* 2**70 <= x <= inf */ + r = x*(logl(x)-1); + if(hx&0x8000) r = nadj - r; + RETURNI(r); +} diff --git a/lib/msun/man/lgamma.3 b/lib/msun/man/lgamma.3 index ea6eb6f76f9b..d244722a0c15 100644 --- a/lib/msun/man/lgamma.3 +++ b/lib/msun/man/lgamma.3 @@ -28,7 +28,7 @@ .\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 .\" $FreeBSD$ .\" -.Dd January 14, 2005 +.Dd September 12, 2014 .Dt LGAMMA 3 .Os .Sh NAME @@ -36,6 +36,8 @@ .Nm lgamma_r , .Nm lgammaf , .Nm lgammaf_r , +.Nm lgammal , +.Nm lgammal_r , .Nm gamma , .Nm gamma_r , .Nm gammaf , @@ -58,6 +60,10 @@ .Fn lgammaf "float x" .Ft float .Fn lgammaf_r "float x" "int *signgamp" +.Ft "long double" +.Fn lgammal "long double x" +.Ft "long double" +.Fn lgammal_r "long double x" "int *signgamp" .Ft double .Fn gamma "double x" .Ft double @@ -66,14 +72,15 @@ .Fn gammaf "float x" .Ft float .Fn gammaf_r "float x" "int *signgamp" -.Ft double +.Ft "long double" .Fn tgamma "double x" .Ft float .Fn tgammaf "float x" .Sh DESCRIPTION -.Fn lgamma x +.Fn lgamma x , +.Fn lgammaf x , and -.Fn lgammaf x +.Fn lgammal x .if t \{\ return ln\||\(*G(x)| where .Bd -unfilled -offset indent @@ -87,13 +94,15 @@ The external integer .Fa signgam returns the sign of \(*G(x). .Pp -.Fn lgamma_r x signgamp +.Fn lgamma_r x signgamp , +.Fn lgammaf_r x signgamp , and -.Fn lgammaf_r x signgamp +.Fn lgammal_r x signgamp provide the same functionality as -.Fn lgamma x +.Fn lgamma x , +.Fn lgammaf x , and -.Fn lgammaf x +.Fn lgammal x , but the caller must provide an integer to store the sign of \(*G(x). .Pp The @@ -115,6 +124,7 @@ are deprecated aliases for and .Fn lgammaf_r , respectively. + .Sh IDIOSYNCRASIES Do not use the expression .Dq Li signgam\(**exp(lgamma(x)) @@ -139,14 +149,18 @@ Exponentiation of will lose up to 10 significant bits. .Sh RETURN VALUES .Fn gamma , -.Fn gamma_r , .Fn gammaf , +.Fn gammal , +.Fn gamma_r , .Fn gammaf_r , +.Fn gammal_r , .Fn lgamma , -.Fn lgamma_r , .Fn lgammaf , +.Fn lgammal , +.Fn lgamma_r , +.Fn lgammaf_r , and -.Fn lgammaf_r +.Fn lgammal_r return appropriate values unless an argument is out of range. Overflow will occur for sufficiently large positive values, and non-positive integers. @@ -159,6 +173,7 @@ will underflow. The .Fn lgamma , .Fn lgammaf , +.Fn lgammal , .Fn tgamma , and .Fn tgammaf diff --git a/lib/msun/src/e_lgamma.c b/lib/msun/src/e_lgamma.c index 4674d9bf0a64..43f5175603ec 100644 --- a/lib/msun/src/e_lgamma.c +++ b/lib/msun/src/e_lgamma.c @@ -21,6 +21,8 @@ __FBSDID("$FreeBSD$"); * Method: call __ieee754_lgamma_r */ +#include + #include "math.h" #include "math_private.h" @@ -31,3 +33,7 @@ __ieee754_lgamma(double x) { return __ieee754_lgamma_r(x,&signgam); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(lgamma, lgammal); +#endif diff --git a/lib/msun/src/e_lgamma_r.c b/lib/msun/src/e_lgamma_r.c index 7a95ea47f016..a0bd31096bdd 100644 --- a/lib/msun/src/e_lgamma_r.c +++ b/lib/msun/src/e_lgamma_r.c @@ -1,4 +1,3 @@ - /* @(#)e_lgamma_r.c 1.3 95/01/18 */ /* * ==================================================== @@ -6,22 +5,21 @@ * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice + * software is freely granted, provided that this notice * is preserved. * ==================================================== - * */ #include __FBSDID("$FreeBSD$"); /* __ieee754_lgamma_r(x, signgamp) - * Reentrant version of the logarithm of the Gamma function - * with user provide pointer for the sign of Gamma(x). + * Reentrant version of the logarithm of the Gamma function + * with user provide pointer for the sign of Gamma(x). * * Method: * 1. Argument Reduction for 0 < x <= 8 - * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may + * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may * reduce x to a number in [1.5,2.5] by * lgamma(1+s) = log(s) + lgamma(s) * for example, @@ -59,20 +57,20 @@ __FBSDID("$FreeBSD$"); * by * 3 5 11 * w = w0 + w1*z + w2*z + w3*z + ... + w6*z - * where + * where * |w - f(z)| < 2**-58.74 - * + * * 4. For negative x, since (G is gamma function) * -x*G(-x)*G(x) = pi/sin(pi*x), * we have * G(x) = pi/(sin(pi*x)*(-x)*G(-x)) * since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0 - * Hence, for x<0, signgam = sign(sin(pi*x)) and + * Hence, for x<0, signgam = sign(sin(pi*x)) and * lgamma(x) = log(|Gamma(x)|) * = log(pi/(|x*sin(pi*x)|)) - lgamma(-x); - * Note: one should avoid compute pi*(-x) directly in the + * Note: one should avoid compute pi*(-x) directly in the * computation of sin(pi*(-x)). - * + * * 5. Special Cases * lgamma(2+s) ~ s*(1-Euler) for tiny s * lgamma(1) = lgamma(2) = 0 @@ -80,9 +78,10 @@ __FBSDID("$FreeBSD$"); * lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero * lgamma(inf) = inf * lgamma(-inf) = inf (bug for bug compatible with C99!?) - * */ +#include + #include "math.h" #include "math_private.h" @@ -187,9 +186,9 @@ sin_pi(double x) switch (n) { case 0: y = __kernel_sin(pi*y,zero,0); break; - case 1: + case 1: case 2: y = __kernel_cos(pi*(0.5-y),zero); break; - case 3: + case 3: case 4: y = __kernel_sin(pi*(one-y),zero,0); break; case 5: case 6: y = -__kernel_cos(pi*(y-1.5),zero); break; @@ -212,7 +211,11 @@ __ieee754_lgamma_r(double x, int *signgamp) *signgamp = 1; ix = hx&0x7fffffff; if(ix>=0x7ff00000) return x*x; - if((ix|lx)==0) return one/vzero; + if((ix|lx)==0) { + if(hx<0) + *signgamp = -1; + return one/vzero; + } if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */ if(hx<0) { *signgamp = -1; @@ -250,7 +253,7 @@ __ieee754_lgamma_r(double x, int *signgamp) p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); p = y*p1+p2; - r += (p-0.5*y); break; + r += (p-y/2); break; case 1: z = y*y; w = z*y; @@ -259,7 +262,7 @@ __ieee754_lgamma_r(double x, int *signgamp) p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); p = z*p1-(tt-w*(p2+y*p3)); r += (tf + p); break; - case 2: + case 2: p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); r += (-0.5*y + p1/p2); @@ -273,11 +276,11 @@ __ieee754_lgamma_r(double x, int *signgamp) r = half*y+p/q; z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ switch(i) { - case 7: z *= (y+6.0); /* FALLTHRU */ - case 6: z *= (y+5.0); /* FALLTHRU */ - case 5: z *= (y+4.0); /* FALLTHRU */ - case 4: z *= (y+3.0); /* FALLTHRU */ - case 3: z *= (y+2.0); /* FALLTHRU */ + case 7: z *= (y+6); /* FALLTHRU */ + case 6: z *= (y+5); /* FALLTHRU */ + case 5: z *= (y+4); /* FALLTHRU */ + case 4: z *= (y+3); /* FALLTHRU */ + case 3: z *= (y+2); /* FALLTHRU */ r += __ieee754_log(z); break; } /* 8.0 <= x < 2**58 */ @@ -287,9 +290,13 @@ __ieee754_lgamma_r(double x, int *signgamp) y = z*z; w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); r = (x-half)*(t-one)+w; - } else + } else /* 2**58 <= x <= inf */ r = x*(__ieee754_log(x)-one); if(hx<0) r = nadj - r; return r; } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(lgamma_r, lgammal_r); +#endif diff --git a/lib/msun/src/e_lgammaf_r.c b/lib/msun/src/e_lgammaf_r.c index 9a7ab39dca4b..9d23053b1f3b 100644 --- a/lib/msun/src/e_lgammaf_r.c +++ b/lib/msun/src/e_lgammaf_r.c @@ -1,5 +1,6 @@ /* e_lgammaf_r.c -- float version of e_lgamma_r.c. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + * Conversion to float fixed By Steven G. Kargl. */ /* @@ -22,72 +23,63 @@ __FBSDID("$FreeBSD$"); static const volatile float vzero = 0; static const float -zero= 0.0000000000e+00, -half= 5.0000000000e-01, /* 0x3f000000 */ -one = 1.0000000000e+00, /* 0x3f800000 */ +zero= 0, +half= 0.5, +one = 1, pi = 3.1415927410e+00, /* 0x40490fdb */ -a0 = 7.7215664089e-02, /* 0x3d9e233f */ -a1 = 3.2246702909e-01, /* 0x3ea51a66 */ -a2 = 6.7352302372e-02, /* 0x3d89f001 */ -a3 = 2.0580807701e-02, /* 0x3ca89915 */ -a4 = 7.3855509982e-03, /* 0x3bf2027e */ -a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */ -a6 = 1.1927076848e-03, /* 0x3a9c54a1 */ -a7 = 5.1006977446e-04, /* 0x3a05b634 */ -a8 = 2.2086278477e-04, /* 0x39679767 */ -a9 = 1.0801156895e-04, /* 0x38e28445 */ -a10 = 2.5214456400e-05, /* 0x37d383a2 */ -a11 = 4.4864096708e-05, /* 0x383c2c75 */ -tc = 1.4616321325e+00, /* 0x3fbb16c3 */ -tf = -1.2148628384e-01, /* 0xbdf8cdcd */ -/* tt = -(tail of tf) */ -tt = 6.6971006518e-09, /* 0x31e61c52 */ -t0 = 4.8383611441e-01, /* 0x3ef7b95e */ -t1 = -1.4758771658e-01, /* 0xbe17213c */ -t2 = 6.4624942839e-02, /* 0x3d845a15 */ -t3 = -3.2788541168e-02, /* 0xbd064d47 */ -t4 = 1.7970675603e-02, /* 0x3c93373d */ -t5 = -1.0314224288e-02, /* 0xbc28fcfe */ -t6 = 6.1005386524e-03, /* 0x3bc7e707 */ -t7 = -3.6845202558e-03, /* 0xbb7177fe */ -t8 = 2.2596477065e-03, /* 0x3b141699 */ -t9 = -1.4034647029e-03, /* 0xbab7f476 */ -t10 = 8.8108185446e-04, /* 0x3a66f867 */ -t11 = -5.3859531181e-04, /* 0xba0d3085 */ -t12 = 3.1563205994e-04, /* 0x39a57b6b */ -t13 = -3.1275415677e-04, /* 0xb9a3f927 */ -t14 = 3.3552918467e-04, /* 0x39afe9f7 */ -u0 = -7.7215664089e-02, /* 0xbd9e233f */ -u1 = 6.3282704353e-01, /* 0x3f2200f4 */ -u2 = 1.4549225569e+00, /* 0x3fba3ae7 */ -u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */ -u4 = 2.2896373272e-01, /* 0x3e6a7578 */ -u5 = 1.3381091878e-02, /* 0x3c5b3c5e */ -v1 = 2.4559779167e+00, /* 0x401d2ebe */ -v2 = 2.1284897327e+00, /* 0x4008392d */ -v3 = 7.6928514242e-01, /* 0x3f44efdf */ -v4 = 1.0422264785e-01, /* 0x3dd572af */ -v5 = 3.2170924824e-03, /* 0x3b52d5db */ -s0 = -7.7215664089e-02, /* 0xbd9e233f */ -s1 = 2.1498242021e-01, /* 0x3e5c245a */ -s2 = 3.2577878237e-01, /* 0x3ea6cc7a */ -s3 = 1.4635047317e-01, /* 0x3e15dce6 */ -s4 = 2.6642270386e-02, /* 0x3cda40e4 */ -s5 = 1.8402845599e-03, /* 0x3af135b4 */ -s6 = 3.1947532989e-05, /* 0x3805ff67 */ -r1 = 1.3920053244e+00, /* 0x3fb22d3b */ -r2 = 7.2193557024e-01, /* 0x3f38d0c5 */ -r3 = 1.7193385959e-01, /* 0x3e300f6e */ -r4 = 1.8645919859e-02, /* 0x3c98bf54 */ -r5 = 7.7794247773e-04, /* 0x3a4beed6 */ -r6 = 7.3266842264e-06, /* 0x36f5d7bd */ -w0 = 4.1893854737e-01, /* 0x3ed67f1d */ -w1 = 8.3333335817e-02, /* 0x3daaaaab */ -w2 = -2.7777778450e-03, /* 0xbb360b61 */ -w3 = 7.9365057172e-04, /* 0x3a500cfd */ -w4 = -5.9518753551e-04, /* 0xba1c065c */ -w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */ -w6 = -1.6309292987e-03; /* 0xbad5c4e8 */ +/* + * Domain y in [0x1p-27, 0.27], range ~[-3.4599e-10, 3.4590e-10]: + * |(lgamma(2 - y) + 0.5 * y) / y - a(y)| < 2**-31.4 + */ +a0 = 7.72156641e-02, /* 0x3d9e233f */ +a1 = 3.22467119e-01, /* 0x3ea51a69 */ +a2 = 6.73484802e-02, /* 0x3d89ee00 */ +a3 = 2.06395667e-02, /* 0x3ca9144f */ +a4 = 6.98275631e-03, /* 0x3be4cf9b */ +a5 = 4.11768444e-03, /* 0x3b86eda4 */ +/* + * Domain x in [tc-0.24, tc+0.28], range ~[-5.6577e-10, 5.5677e-10]: + * |(lgamma(x) - tf) - t(x - tc)| < 2**-30.8. + */ +tc = 1.46163213e+00, /* 0x3fbb16c3 */ +tf = -1.21486291e-01, /* 0xbdf8cdce */ +t0 = -2.94064460e-11, /* 0xae0154b7 */ +t1 = -2.35939837e-08, /* 0xb2caabb8 */ +t2 = 4.83836412e-01, /* 0x3ef7b968 */ +t3 = -1.47586212e-01, /* 0xbe1720d7 */ +t4 = 6.46013096e-02, /* 0x3d844db1 */ +t5 = -3.28450352e-02, /* 0xbd068884 */ +t6 = 1.86483748e-02, /* 0x3c98c47a */ +t7 = -9.89206228e-03, /* 0xbc221251 */ +/* + * Domain y in [-0.1, 0.232], range ~[-8.4931e-10, 8.7794e-10]: + * |(lgamma(1 + y) + 0.5 * y) / y - u(y) / v(y)| < 2**-31.2 + */ +u0 = -7.72156641e-02, /* 0xbd9e233f */ +u1 = 7.36789703e-01, /* 0x3f3c9e40 */ +u2 = 4.95649040e-01, /* 0x3efdc5b6 */ +v1 = 1.10958421e+00, /* 0x3f8e06db */ +v2 = 2.10598111e-01, /* 0x3e57a708 */ +v3 = -1.02995494e-02, /* 0xbc28bf71 */ +/* + * Domain x in (2, 3], range ~[-5.5189e-11, 5.2317e-11]: + * |(lgamma(y+2) - 0.5 * y) / y - s(y)/r(y)| < 2**-35.0 + * with y = x - 2. + */ +s0 = -7.72156641e-02, /* 0xbd9e233f */ +s1 = 2.69987404e-01, /* 0x3e8a3bca */ +s2 = 1.42851010e-01, /* 0x3e124789 */ +s3 = 1.19389519e-02, /* 0x3c439b98 */ +r1 = 6.79650068e-01, /* 0x3f2dfd8c */ +r2 = 1.16058730e-01, /* 0x3dedb033 */ +r3 = 3.75673687e-03, /* 0x3b763396 */ +/* + * Domain z in [8, 0x1p24], range ~[-1.2640e-09, 1.2640e-09]: + * |lgamma(x) - (x - 0.5) * (log(x) - 1) - w(1/x)| < 2**-29.6. + */ +w0 = 4.18938547e-01, /* 0x3ed67f1d */ +w1 = 8.33332464e-02, /* 0x3daaaa9f */ +w2 = -2.76129087e-03; /* 0xbb34f6c6 */ static float sin_pif(float x) @@ -140,7 +132,11 @@ __ieee754_lgammaf_r(float x, int *signgamp) *signgamp = 1; ix = hx&0x7fffffff; if(ix>=0x7f800000) return x*x; - if(ix==0) return one/vzero; + if(ix==0) { + if(hx<0) + *signgamp = -1; + return one/vzero; + } if(ix<0x35000000) { /* |x|<2**-21, return -log(|x|) */ if(hx<0) { *signgamp = -1; @@ -168,55 +164,50 @@ __ieee754_lgammaf_r(float x, int *signgamp) else {y = x; i=2;} } else { r = zero; - if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */ + if(ix>=0x3fdda618) {y=2-x;i=0;} /* [1.7316,2] */ else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */ else {y=x-one;i=2;} } switch(i) { case 0: z = y*y; - p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); - p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); + p1 = a0+z*(a2+z*a4); + p2 = z*(a1+z*(a3+z*a5)); p = y*p1+p2; - r += (p-(float)0.5*y); break; + r += (p-y/2); break; case 1: - z = y*y; - w = z*y; - p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ - p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); - p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); - p = z*p1-(tt-w*(p2+y*p3)); + p = t0+y*t1+y*y*(t2+y*(t3+y*(t4+y*(t5+y*(t6+y*t7))))); r += (tf + p); break; case 2: - p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); - p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); - r += (-(float)0.5*y + p1/p2); + p1 = y*(u0+y*(u1+y*u2)); + p2 = one+y*(v1+y*(v2+y*v3)); + r += (p1/p2-y/2); } } else if(ix<0x41000000) { /* x < 8.0 */ - i = (int)x; - y = x-(float)i; - p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); - q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); - r = half*y+p/q; + i = x; + y = x-i; + p = y*(s0+y*(s1+y*(s2+y*s3))); + q = one+y*(r1+y*(r2+y*r3)); + r = y/2+p/q; z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ switch(i) { - case 7: z *= (y+(float)6.0); /* FALLTHRU */ - case 6: z *= (y+(float)5.0); /* FALLTHRU */ - case 5: z *= (y+(float)4.0); /* FALLTHRU */ - case 4: z *= (y+(float)3.0); /* FALLTHRU */ - case 3: z *= (y+(float)2.0); /* FALLTHRU */ + case 7: z *= (y+6); /* FALLTHRU */ + case 6: z *= (y+5); /* FALLTHRU */ + case 5: z *= (y+4); /* FALLTHRU */ + case 4: z *= (y+3); /* FALLTHRU */ + case 3: z *= (y+2); /* FALLTHRU */ r += __ieee754_logf(z); break; } - /* 8.0 <= x < 2**58 */ - } else if (ix < 0x5c800000) { + /* 8.0 <= x < 2**24 */ + } else if (ix < 0x4b800000) { t = __ieee754_logf(x); z = one/x; y = z*z; - w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); + w = w0+z*(w1+y*w2); r = (x-half)*(t-one)+w; } else - /* 2**58 <= x <= inf */ + /* 2**24 <= x <= inf */ r = x*(__ieee754_logf(x)-one); if(hx<0) r = nadj - r; return r; diff --git a/lib/msun/src/e_lgammal.c b/lib/msun/src/e_lgammal.c new file mode 100644 index 000000000000..ebc2fc78cbb1 --- /dev/null +++ b/lib/msun/src/e_lgammal.c @@ -0,0 +1,25 @@ +/* @(#)e_lgamma.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +long double +lgammal(long double x) +{ + return lgammal_r(x,&signgam); +} diff --git a/lib/msun/src/imprecise.c b/lib/msun/src/imprecise.c index 92fb2d06e98a..08cd23980603 100644 --- a/lib/msun/src/imprecise.c +++ b/lib/msun/src/imprecise.c @@ -60,5 +60,4 @@ DECLARE_WEAK(powl); long double imprecise_ ## f ## l(long double v) { return f(v); }\ DECLARE_WEAK(f ## l) -DECLARE_IMPRECISE(lgamma); DECLARE_IMPRECISE(tgamma); diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h index e4e5682c7d0f..2ff1731054be 100644 --- a/lib/msun/src/math.h +++ b/lib/msun/src/math.h @@ -496,8 +496,12 @@ long double tanhl(long double); long double tanl(long double); long double tgammal(long double); long double truncl(long double); - #endif /* __ISO_C_VISIBLE >= 1999 */ + +#if __BSD_VISIBLE +long double lgammal_r(long double, int *); +#endif + __END_DECLS #endif /* !_MATH_H_ */ diff --git a/libexec/Makefile b/libexec/Makefile index 8a32694d4050..74cc6d8fb27f 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -13,6 +13,7 @@ SUBDIR= ${_atf} \ fingerd \ ftpd \ getty \ + ${_hyperv} \ ${_mail.local} \ ${_mknetid} \ ${_pppoed} \ @@ -54,6 +55,10 @@ _dma= dma _dma-mbox-create= dma-mbox-create .endif +.if ${MK_HYPERV} != "no" +_hyperv= hyperv +.endif + .if ${MK_NIS} != "no" _mknetid= mknetid _ypxfr= ypxfr diff --git a/libexec/hyperv/Makefile b/libexec/hyperv/Makefile new file mode 100644 index 000000000000..37abdf5b8b3b --- /dev/null +++ b/libexec/hyperv/Makefile @@ -0,0 +1,10 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../contrib/hyperv/tools/scripts + +BINDIR= /usr/libexec/hyperv + +SCRIPTS= hv_set_ifconfig hv_get_dns_info hv_get_dhcp_info +NO_OBJ= + +.include diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index 67544512715f..cc301328fb39 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -46,7 +46,7 @@ LDFLAGS+= -shared -Wl,-Bsymbolic DPADD= ${LIBC_PIC} LDADD= -lc_pic -.if ${MACHINE_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no" +.if ${MACHINE_CPUARCH} == "arm" # Some of the required math functions (div & mod) are implemented in # libcompiler_rt on ARM. The library also needs to be placed first to be # correctly linked. As some of the functions are used before we have diff --git a/release/Makefile b/release/Makefile index 6b4517dc4377..8a6ece7d1b58 100644 --- a/release/Makefile +++ b/release/Makefile @@ -23,6 +23,9 @@ # WITH_DVD: if set, generate dvd1.iso # WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1) # (uncompressed images are not removed) +# WITH_VMIMAGES: if set, build virtual machine images with the release +# WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images +# with xz(1) (extremely time consuming) # TARGET/TARGET_ARCH: architecture of built release # @@ -94,6 +97,11 @@ IMAGES+= memstick.img IMAGES+= mini-memstick.img .endif +VMTARGETS= vm-base vm-image +VMFORMATS?= vhd vmdk qcow2 raw +VMSIZE?= 20G +VMBASE?= vm + CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES} .if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) . for I in ${IMAGES} @@ -103,7 +111,16 @@ CLEANFILES+= ${I}.xz .if defined(WITH_DVD) && !empty(WITH_DVD) CLEANFILES+= pkg-stage .endif +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) +CLEANFILES+= ${VMBASE}.img +. for FORMAT in ${VMFORMATS} +CLEANFILES+= ${VMBASE}.${FORMAT} +. endfor +.endif CLEANDIRS= dist ftp release bootonly dvd +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) +CLEANDIRS+= ${VMTARGETS} +.endif beforeclean: chflags -R noschg . .include @@ -263,6 +280,9 @@ ftp: packagesystem release: ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) + ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS} +.endif install: .if defined(DESTDIR) && !empty(DESTDIR) @@ -277,3 +297,44 @@ install: .endfor cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5 +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) + mkdir -p ${DESTDIR}/vmimages +. for FORMAT in ${VMFORMATS} + cp -p ${VMBASE}.${FORMAT} \ + ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} +. endfor +. if defined(WITH_COMPRESSED_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES) +# This is very time consuming, so defer it after the images are moved to +# the DESTDIR. +. for FORMAT in ${VMFORMATS} + # Don't keep the originals. There is a copy in ${.OBJDIR} if needed. + ${XZCMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT} +. endfor +. endif + cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \ + ${DESTDIR}/vmimages/CHECKSUM.SHA256 + cd ${DESTDIR}/vmimages && md5 ${OSRELEASE}* > \ + ${DESTDIR}/vmimages/CHECKSUM.MD5 +.endif + +vm-base: +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) +. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh) + env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ + ${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \ + ${VMBASE}.img ${WORLDDIR} ${.OBJDIR}/${.TARGET} ${VMSIZE} +. endif +.endif + touch ${.TARGET} + +vm-image: vm-base +.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES) +. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh) +. for FORMAT in ${VMFORMATS} + env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ + ${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \ + ${VMBASE}.img ${FORMAT} ${VMBASE}.${FORMAT} +. endfor +. endif +.endif + touch ${.TARGET} diff --git a/release/amd64/mk-vmimage.sh b/release/amd64/mk-vmimage.sh new file mode 100755 index 000000000000..6ee148248cd5 --- /dev/null +++ b/release/amd64/mk-vmimage.sh @@ -0,0 +1,188 @@ +#!/bin/sh +#- +# Copyright (c) 2014 The FreeBSD Foundation +# All rights reserved. +# +# This software was developed by Glen Barber under sponsorship +# from the FreeBSD Foundation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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. +# +# mk-vmimage.sh: Create virtual machine disk images in various formats. +# +# $FreeBSD$ +# + +PATH="/bin:/usr/bin:/sbin:/usr/sbin" +export PATH + +usage_vm_base() { + echo -n "$(basename ${0}) vm-base " + echo " " + return 0 +} + +usage_vm_image() { + echo -n "$(basename ${0}) vm-image " + echo " " + return 0 +} + +usage() { + echo "Usage:" + echo "$(basename ${0}) [vm-base|vm-image] [...]" + echo + usage_vm_base + echo + usage_vm_image + exit 1 +} + +panic() { + rc="${1}" + shift 1 + msg="${@}" + printf "${msg}\n" + if [ ! -z "${mddev}" ]; then + mdconfig -d -u ${mddev} + fi + # Do not allow one failure case to chain through any remaining image + # builds. + exit 0 +} + +vm_create_baseimage() { + # Creates the UFS root filesystem for the virtual machine disk, + # written to the formatted disk image with mkimg(1). + # + # Arguments: + # vm-base + + VMBASE="${1}" + WORLDDIR="${2}" + DESTDIR="${3}" + VMSIZE="${4}" + + if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \ + -o -z "${VMSIZE}" ]; then + usage + fi + + i=0 + mkdir -p ${DESTDIR} + truncate -s ${VMSIZE} ${VMBASE} + mddev=$(mdconfig -f ${VMBASE}) + newfs -j /dev/${mddev} + mount /dev/${mddev} ${DESTDIR} + cd ${WORLDDIR} && \ + make DESTDIR=${DESTDIR} \ + installworld installkernel distribution || \ + panic 1 "\n\nCannot install the base system to ${DESTDIR}." + chroot ${DESTDIR} /usr/bin/newaliases + echo '# Custom /etc/fstab for FreeBSD VM images' \ + > ${DESTDIR}/etc/fstab + echo '/dev/gpt/rootfs / ufs rw 2 2' \ + >> ${DESTDIR}/etc/fstab + echo '/dev/gpt/swapfs none swap sw 0 0' \ + >> ${DESTDIR}/etc/fstab + sync + while ! umount ${DESTDIR}; do + i=$(( $i + 1 )) + if [ $i -ge 10 ]; then + # This should never happen. But, it has happened. + msg="Cannot umount(8) ${DESTDIR}\n" + msg="${msg}Something has gone horribly wrong." + panic 1 "${msg}" + fi + sleep 1 + done + + return 0 +} + +vm_create_vmdisk() { + # Creates the virtual machine disk image from the raw disk image. + # + # Arguments: + # vm-image " + + VMBASE="${1}" + FORMAT="${2}" + VMIMAGE="${3}" + + if [ -z "${VMBASE}" -o -z "${FORMAT}" -o -z "${VMIMAGE}" ]; then + usage + fi + + mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}') + + # We need mkimg(1) '--version' output, at minimum, to be able to + # tell what virtual machine disk image formats are available. + # Bail if mkimg(1) reports an empty '--version' value. + if [ -z "${mkimg_version}" ]; then + msg="Cannot determine mkimg(1) version.\n" + msg="${msg}Cannot continue without a known mkimg(1) version." + panic 0 "${msg}" + fi + + if ! mkimg --formats 2>/dev/null | grep -q ${FORMAT}; then + panic 0 "'${FORMAT}' is not supported by this mkimg(1).\n" + fi + + case ${FORMAT} in + vhd) + mkimg_format=vhdf + ;; + *) + mkimg_format=${FORMAT} + ;; + esac + + mkimg -f ${mkimg_format} -s gpt \ + -b /boot/pmbr -p freebsd-boot/bootfs:=/boot/gptboot \ + -p freebsd-swap/swapfs::1G \ + -p freebsd-ufs/rootfs:=${VMBASE} \ + -o ${VMIMAGE} + + return 0 +} + +main() { + cmd="${1}" + shift 1 + + case ${cmd} in + vm-base) + eval vm_create_baseimage "$@" || return 0 + ;; + vm-image) + eval vm_create_vmdisk "$@" || return 0 + ;; + *|\?) + usage + ;; + esac + + return 0 +} + +main "$@" diff --git a/release/arm/BEAGLEBONE.conf b/release/arm/BEAGLEBONE.conf index 025bcb7725c8..28e084d808a7 100644 --- a/release/arm/BEAGLEBONE.conf +++ b/release/arm/BEAGLEBONE.conf @@ -33,5 +33,5 @@ load_target_env() { export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no" export KERNEL="BEAGLEBONE" export CROCHETSRC="https://github.com/kientzle/crochet-freebsd" - export CROCHETBRANCH="trunk" + export CROCHETBRANCH="trunk@r744" } diff --git a/release/arm/PANDABOARD.conf b/release/arm/PANDABOARD.conf index afc53d56f18d..a9fbb6f4f57f 100644 --- a/release/arm/PANDABOARD.conf +++ b/release/arm/PANDABOARD.conf @@ -33,5 +33,5 @@ load_target_env() { export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no" export KERNEL="PANDABOARD" export CROCHETSRC="https://github.com/kientzle/crochet-freebsd" - export CROCHETBRANCH="trunk" + export CROCHETBRANCH="trunk@r744" } diff --git a/release/arm/RPI-B.conf b/release/arm/RPI-B.conf index 22ffb2b10a1a..d9ab15638afe 100644 --- a/release/arm/RPI-B.conf +++ b/release/arm/RPI-B.conf @@ -33,7 +33,7 @@ load_target_env() { export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no" export KERNEL="RPI-B" export CROCHETSRC="https://github.com/kientzle/crochet-freebsd" - export CROCHETBRANCH="trunk" + export CROCHETBRANCH="trunk@r744" export UBOOTSRC="https://github.com/gonzoua/u-boot-pi" export UBOOTBRANCH="trunk" export UBOOTDIR="/tmp/crochet/u-boot-rpi" diff --git a/release/arm/WANDBOARD-QUAD.conf b/release/arm/WANDBOARD-QUAD.conf index 67933df57aed..4249bf65219e 100644 --- a/release/arm/WANDBOARD-QUAD.conf +++ b/release/arm/WANDBOARD-QUAD.conf @@ -33,5 +33,5 @@ load_target_env() { export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no" export KERNEL="WANDBOARD-QUAD" export CROCHETSRC="https://github.com/kientzle/crochet-freebsd" - export CROCHETBRANCH="trunk" + export CROCHETBRANCH="trunk@r744" } diff --git a/release/arm/ZEDBOARD.conf b/release/arm/ZEDBOARD.conf index c35d692d346e..a6d1de0b4a4e 100644 --- a/release/arm/ZEDBOARD.conf +++ b/release/arm/ZEDBOARD.conf @@ -32,5 +32,5 @@ load_target_env() { export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no" export KERNEL="ZEDBOARD" export CROCHETSRC="https://github.com/kientzle/crochet-freebsd" - export CROCHETBRANCH="trunk" + export CROCHETBRANCH="trunk@r744" } diff --git a/release/arm/release.sh b/release/arm/release.sh index 0dc8de7ada85..020583fdc25c 100755 --- a/release/arm/release.sh +++ b/release/arm/release.sh @@ -44,8 +44,8 @@ before_build() { case ${KERNEL} in BEAGLEBONE) WANT_UBOOT=1 - KNOWNHASH="4150e5a4480707c55a8d5b4570262e43af68d8ed3bdc0a433d8e7df47989a69e" - UBOOT_VERSION="u-boot-2013.04" + KNOWNHASH="7b6444bd23eb61068c43bd1d44ec7e7bfdbce5cadeca20c833eee186b4d3fd31" + UBOOT_VERSION="u-boot-2014.04" ;; PANDABOARD) WANT_UBOOT=1 @@ -54,8 +54,8 @@ before_build() { ;; WANDBOARD-QUAD) WANT_UBOOT=1 - KNOWNHASH="0d71e62beb952b41ebafb20a7ee4df2f960db64c31b054721ceb79ff14014c55" - UBOOT_VERSION="u-boot-2013.10" + KNOWNHASH="b4f83b8db325c21671a997198ec3a373e2e00dde2fcf17be9b9afd7cfd727f56" + UBOOT_VERSION="u-boot-2014.07" ;; *) # Fallthrough. diff --git a/release/doc/en_US.ISO8859-1/hardware/article.xml b/release/doc/en_US.ISO8859-1/hardware/article.xml index 8919eefd7de1..444e3cab796a 100644 --- a/release/doc/en_US.ISO8859-1/hardware/article.xml +++ b/release/doc/en_US.ISO8859-1/hardware/article.xml @@ -837,6 +837,8 @@ &hwlist.igb; + &hwlist.ipheth; + &hwlist.ixgb; &hwlist.ixgbe; @@ -885,6 +887,8 @@ &hwlist.sk; + &hwlist.smsc; + &hwlist.sn; &hwlist.snc; diff --git a/release/doc/en_US.ISO8859-1/share/xml/release.xsl b/release/doc/en_US.ISO8859-1/share/xml/release.xsl index f1d14795f794..a854cd903bc5 100644 --- a/release/doc/en_US.ISO8859-1/share/xml/release.xsl +++ b/release/doc/en_US.ISO8859-1/share/xml/release.xsl @@ -8,6 +8,7 @@ +

All users of FreeBSD should - subscribe to the <current@FreeBSD.org> + subscribe to the <@FreeBSD.org> mailing list.

For questions about this documentation, diff --git a/release/doc/share/mk/doc.relnotes.mk b/release/doc/share/mk/doc.relnotes.mk index 8034c6315d3d..8ae9fd0e92c0 100644 --- a/release/doc/share/mk/doc.relnotes.mk +++ b/release/doc/share/mk/doc.relnotes.mk @@ -6,6 +6,7 @@ DOC_PREFIX?= ${RELN_ROOT}/../../../doc RELEASETYPE!= grep -o 'release.type "[a-z]*"' ${RELN_ROOT}/share/xml/release.ent | sed 's|[a-z.]* "\([a-z]*\)"|\1|' RELEASEURL!= grep -o 'release.url \"[^\"]*\"' ${RELN_ROOT}/share/xml/release.ent | sed 's|[^ ]* "\([^"]*\)"|\1|' RELEASEBRANCH!= grep -o 'release.branch "\([^"]*\)"' ${RELN_ROOT}/share/xml/release.ent | sed 's|[^ ]* "\([^"]*\)"|\1|' +RELEASEMAILLIST!= grep -o 'release.maillist "\([^"]*\)"' ${RELN_ROOT}/share/xml/release.ent | sed 's|[^ ]* "\([^"]*\)"|\1|' .if ${RELEASETYPE} == "current" PROFILING+= --param profile.attribute "'releasetype'" --param profile.value "'current'" .elif ${RELEASETYPE} == "snapshot" @@ -15,6 +16,7 @@ PROFILING+= --param profile.attribute "'releasetype'" --param profile.value "'re .endif XSLTPROCFLAGS+= --param release.url "'${RELEASEURL}'" XSLTPROCFLAGS+= --param release.branch "'${RELEASEBRANCH}'" +XSLTPROCFLAGS+= --param release.maillist "'${RELEASEMAILLIST}'" # Find the RELNOTESng document catalogs EXTRA_CATALOGS+= file://${RELN_ROOT}/${LANGCODE}/share/xml/catalog.xml \ diff --git a/release/doc/share/xml/release.ent b/release/doc/share/xml/release.ent index bdd58b70bd6a..4e7709ab1304 100644 --- a/release/doc/share/xml/release.ent +++ b/release/doc/share/xml/release.ent @@ -27,6 +27,9 @@ + + + diff --git a/release/doc/share/xml/release.xsl b/release/doc/share/xml/release.xsl index d3616a0c2beb..f76ae683d8a5 100644 --- a/release/doc/share/xml/release.xsl +++ b/release/doc/share/xml/release.xsl @@ -12,6 +12,7 @@ + diff --git a/release/i386/mk-vmimage.sh b/release/i386/mk-vmimage.sh new file mode 100755 index 000000000000..6ee148248cd5 --- /dev/null +++ b/release/i386/mk-vmimage.sh @@ -0,0 +1,188 @@ +#!/bin/sh +#- +# Copyright (c) 2014 The FreeBSD Foundation +# All rights reserved. +# +# This software was developed by Glen Barber under sponsorship +# from the FreeBSD Foundation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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. +# +# mk-vmimage.sh: Create virtual machine disk images in various formats. +# +# $FreeBSD$ +# + +PATH="/bin:/usr/bin:/sbin:/usr/sbin" +export PATH + +usage_vm_base() { + echo -n "$(basename ${0}) vm-base " + echo " " + return 0 +} + +usage_vm_image() { + echo -n "$(basename ${0}) vm-image " + echo " " + return 0 +} + +usage() { + echo "Usage:" + echo "$(basename ${0}) [vm-base|vm-image] [...]" + echo + usage_vm_base + echo + usage_vm_image + exit 1 +} + +panic() { + rc="${1}" + shift 1 + msg="${@}" + printf "${msg}\n" + if [ ! -z "${mddev}" ]; then + mdconfig -d -u ${mddev} + fi + # Do not allow one failure case to chain through any remaining image + # builds. + exit 0 +} + +vm_create_baseimage() { + # Creates the UFS root filesystem for the virtual machine disk, + # written to the formatted disk image with mkimg(1). + # + # Arguments: + # vm-base + + VMBASE="${1}" + WORLDDIR="${2}" + DESTDIR="${3}" + VMSIZE="${4}" + + if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \ + -o -z "${VMSIZE}" ]; then + usage + fi + + i=0 + mkdir -p ${DESTDIR} + truncate -s ${VMSIZE} ${VMBASE} + mddev=$(mdconfig -f ${VMBASE}) + newfs -j /dev/${mddev} + mount /dev/${mddev} ${DESTDIR} + cd ${WORLDDIR} && \ + make DESTDIR=${DESTDIR} \ + installworld installkernel distribution || \ + panic 1 "\n\nCannot install the base system to ${DESTDIR}." + chroot ${DESTDIR} /usr/bin/newaliases + echo '# Custom /etc/fstab for FreeBSD VM images' \ + > ${DESTDIR}/etc/fstab + echo '/dev/gpt/rootfs / ufs rw 2 2' \ + >> ${DESTDIR}/etc/fstab + echo '/dev/gpt/swapfs none swap sw 0 0' \ + >> ${DESTDIR}/etc/fstab + sync + while ! umount ${DESTDIR}; do + i=$(( $i + 1 )) + if [ $i -ge 10 ]; then + # This should never happen. But, it has happened. + msg="Cannot umount(8) ${DESTDIR}\n" + msg="${msg}Something has gone horribly wrong." + panic 1 "${msg}" + fi + sleep 1 + done + + return 0 +} + +vm_create_vmdisk() { + # Creates the virtual machine disk image from the raw disk image. + # + # Arguments: + # vm-image " + + VMBASE="${1}" + FORMAT="${2}" + VMIMAGE="${3}" + + if [ -z "${VMBASE}" -o -z "${FORMAT}" -o -z "${VMIMAGE}" ]; then + usage + fi + + mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}') + + # We need mkimg(1) '--version' output, at minimum, to be able to + # tell what virtual machine disk image formats are available. + # Bail if mkimg(1) reports an empty '--version' value. + if [ -z "${mkimg_version}" ]; then + msg="Cannot determine mkimg(1) version.\n" + msg="${msg}Cannot continue without a known mkimg(1) version." + panic 0 "${msg}" + fi + + if ! mkimg --formats 2>/dev/null | grep -q ${FORMAT}; then + panic 0 "'${FORMAT}' is not supported by this mkimg(1).\n" + fi + + case ${FORMAT} in + vhd) + mkimg_format=vhdf + ;; + *) + mkimg_format=${FORMAT} + ;; + esac + + mkimg -f ${mkimg_format} -s gpt \ + -b /boot/pmbr -p freebsd-boot/bootfs:=/boot/gptboot \ + -p freebsd-swap/swapfs::1G \ + -p freebsd-ufs/rootfs:=${VMBASE} \ + -o ${VMIMAGE} + + return 0 +} + +main() { + cmd="${1}" + shift 1 + + case ${cmd} in + vm-base) + eval vm_create_baseimage "$@" || return 0 + ;; + vm-image) + eval vm_create_vmdisk "$@" || return 0 + ;; + *|\?) + usage + ;; + esac + + return 0 +} + +main "$@" diff --git a/release/picobsd/tinyware/simple_httpd/simple_httpd.c b/release/picobsd/tinyware/simple_httpd/simple_httpd.c index 0d53a09910e8..58d4febe0fe9 100644 --- a/release/picobsd/tinyware/simple_httpd/simple_httpd.c +++ b/release/picobsd/tinyware/simple_httpd/simple_httpd.c @@ -160,8 +160,8 @@ http_date(void) void http_output(const char *html) { - write(con_sock, html, strlen(html)); - write(con_sock, "\r\n", 2); + write(con_sock, html, strlen(html)); + write(con_sock, "\r\n", 2); } @@ -172,30 +172,30 @@ http_output(const char *html) void log_line(char *req) { - char log_buff[256]; - char msg[1024]; - char env_host[80], env_addr[80]; - long addr; - FILE *log; + char log_buff[256]; + char msg[1024]; + char env_host[80], env_addr[80]; + long addr; + FILE *log; strcpy(log_buff,inet_ntoa(source.sin_addr)); sprintf(env_addr, "REMOTE_ADDR=%s",log_buff); - addr=inet_addr(log_buff); - - strcpy(msg,adate()); - strcat(msg," "); - hst=gethostbyaddr((char*) &addr, 4, AF_INET); + addr=inet_addr(log_buff); + + strcpy(msg,adate()); + strcat(msg," "); + hst=gethostbyaddr((char*) &addr, 4, AF_INET); /* If DNS hostname exists */ - if (hst) { + if (hst) { strcat(msg,hst->h_name); sprintf(env_host, "REMOTE_HOST=%s",hst->h_name); } - strcat(msg," ("); - strcat(msg,log_buff); - strcat(msg,") "); - strcat(msg,req); + strcat(msg," ("); + strcat(msg,log_buff); + strcat(msg,") "); + strcat(msg,req); if (daemonize) { log=fopen(logfile,"a"); @@ -226,8 +226,8 @@ http_request(void) lg = read(con_sock, req, 1024); - if ((p=strstr(req,"\n"))) *p=0; - if ((p=strstr(req,"\r"))) *p=0; + if ((p=strstr(req,"\n"))) *p=0; + if ((p=strstr(req,"\r"))) *p=0; log_line(req); @@ -253,40 +253,40 @@ http_request(void) filename = strtok(NULL, " "); c = strtok(NULL, " "); - if (fetch_mode != NULL) filename=fetch_mode; - if (filename == NULL || - strlen(filename)==1) filename="/index.html"; + if (fetch_mode != NULL) filename=fetch_mode; + if (filename == NULL || + strlen(filename)==1) filename="/index.html"; - while (filename[0]== '/') filename++; + while (filename[0]== '/') filename++; - /* CGI handling. Untested */ - if (!strncmp(filename,"cgi-bin/",8)) - { - par=0; - if ((par=strstr(filename,"?"))) - { - *par=0; - par++; - } - if (access(filename,X_OK)) goto conti; - stat (filename,&file_status); - if (setuid(file_status.st_uid)) return; - if (seteuid(file_status.st_uid)) return; - if (!fork()) - { - close(1); - dup(con_sock); - /*printf("HTTP/1.0 200 OK\nContent-type: text/html\n\n\n");*/ + /* CGI handling. Untested */ + if (!strncmp(filename,"cgi-bin/",8)) + { + par=0; + if ((par=strstr(filename,"?"))) + { + *par=0; + par++; + } + if (access(filename,X_OK)) goto conti; + stat (filename,&file_status); + if (setuid(file_status.st_uid)) return; + if (seteuid(file_status.st_uid)) return; + if (!fork()) + { + close(1); + dup(con_sock); + /*printf("HTTP/1.0 200 OK\nContent-type: text/html\n\n\n");*/ printf("HTTP/1.0 200 OK\r\n"); - /* Plug in environment variable, others in log_line */ + /* Plug in environment variable, others in log_line */ setenv("SERVER_SOFTWARE", "FreeBSD/PicoBSD", 1); execlp (filename,filename,par,(char *)0); - } - wait(&i); - return; - } - conti: + } + wait(&i); + return; + } + conti: if (filename == NULL) { http_output(http_405[0]); http_output(http_405[1]); @@ -307,8 +307,8 @@ http_request(void) /* Open filename */ fd = open(filename, O_RDONLY); if (fd < 0) { - http_output(http_404[0]); - http_output(http_404[1]); + http_output(http_404[0]); + http_output(http_404[1]); goto end_request; } @@ -325,7 +325,7 @@ http_request(void) http_output(http_404[1]); goto end_request2; } - + /* Past this point we are serving either a GET or HEAD */ /* Print all the header info */ http_output(http_200); @@ -371,14 +371,14 @@ http_request(void) int main(int argc, char *argv[]) { - int ch, ld; - int httpd_group = 65534; - pid_t server_pid; - + int ch, ld; + pid_t httpd_group = 65534; + pid_t server_pid; + /* Default for html directory */ strcpy (homedir,getenv("HOME")); - if (!geteuid()) strcpy (homedir,"/httphome"); - else strcat (homedir,"/httphome"); + if (!geteuid()) strcpy (homedir,"/httphome"); + else strcat (homedir,"/httphome"); /* Defaults for log file */ if (geteuid()) { @@ -420,10 +420,10 @@ main(int argc, char *argv[]) printf("usage: simple_httpd [[-d directory][-g grpid][-l logfile][-p port][-vD]]\n"); exit(1); /* NOTREACHED */ - } + } /* Not running as root and no port supplied, assume 1080 */ - if ((http_port == 80) && geteuid()) { + if ((http_port == 80) && geteuid()) { http_port = 1080; } @@ -437,15 +437,15 @@ main(int argc, char *argv[]) } /* Create log file if it doesn't exit */ - if ((access(logfile,W_OK)) && daemonize) { - ld = open (logfile,O_WRONLY); + if ((access(logfile,W_OK)) && daemonize) { + ld = open (logfile,O_WRONLY); chmod (logfile,00600); close(ld); } - init_servconnection(); + init_servconnection(); - if (verbose) { + if (verbose) { printf("Server started with options \n"); printf("port: %d\n",http_port); if (fetch_mode == NULL) printf("html home: %s\n",homedir); @@ -453,7 +453,7 @@ main(int argc, char *argv[]) } /* httpd is spawned */ - if (daemonize) { + if (daemonize) { if ((server_pid = fork()) != 0) { wait3(0,WNOHANG,0); if (verbose) printf("pid: %d\n",server_pid); @@ -462,16 +462,17 @@ main(int argc, char *argv[]) wait3(0,WNOHANG,0); } - if (fetch_mode == NULL) setpgrp(0,httpd_group); + if (fetch_mode == NULL) + setpgrp((pid_t)0, httpd_group); /* How many connections do you want? * Keep this lower than the available number of processes */ - if (listen(http_sock,15) < 0) exit(1); + if (listen(http_sock,15) < 0) exit(1); - label: + label: wait_connection(); - + if (fork()) { wait3(0,WNOHANG,0); close(con_sock); @@ -488,13 +489,13 @@ main(int argc, char *argv[]) char * adate(void) { - static char out[50]; - time_t now; - struct tm *t; - time(&now); - t = localtime(&now); - sprintf(out, "%02d:%02d:%02d %02d/%02d/%02d", - t->tm_hour, t->tm_min, t->tm_sec, - t->tm_mday, t->tm_mon+1, t->tm_year ); - return out; + static char out[50]; + time_t now; + struct tm *t; + time(&now); + t = localtime(&now); + sprintf(out, "%02d:%02d:%02d %02d/%02d/%02d", + t->tm_hour, t->tm_min, t->tm_sec, + t->tm_mday, t->tm_mon+1, t->tm_year ); + return out; } diff --git a/release/rc.local b/release/rc.local index 2c846c4e384d..cb442273c303 100755 --- a/release/rc.local +++ b/release/rc.local @@ -10,6 +10,9 @@ MACHINE=`uname -m` +# resolv.conf from DHCP ends up in here, so make sure the directory exists +mkdir /tmp/bsdinstall_etc + kbdcontrol -d >/dev/null 2>&1 if [ $? -eq 0 ]; then # Syscons: use xterm, start interesting things on other VTYs diff --git a/release/release.conf.sample b/release/release.conf.sample index bdd5a8a05d91..c79ed9f87003 100644 --- a/release/release.conf.sample +++ b/release/release.conf.sample @@ -77,3 +77,24 @@ PORTBRANCH="ports/head@rHEAD" ## as TARGET/TARGET_ARCH. #CHROOT_MAKEENV= +## Set to a non-empty value to build virtual machine images as part of the +## release build. +#WITH_VMIMAGES= + +## Set to a non-empty value to compress virtual machine images with xz(1) +## as part of the release build. +#WITH_COMPRESSED_VMIMAGES= + +## If WITH_VMIMAGES is set to a non-empty value, this is the name of the +## file to use for the installed userland/kernel. +#VMBASE="vm" + +## If WITH_VMIMAGES is set to a non-empty value, this is the size of the +## virtual machine disk filesystem. Valid size values are described in +## the truncate(1) manual page. +#VMSIZE="20G" + +## If WITH_VMIMAGES is set to a non-empty value, this is a list of disk +## image formats to create. Valid values are listed in the mkimg(1) +## manual page, as well as 'mkimg --formats' output. +#VMFORMATS="vhdf vmdk qcow2 raw" diff --git a/release/release.sh b/release/release.sh index e99c403d22b0..87b36974070a 100755 --- a/release/release.sh +++ b/release/release.sh @@ -89,6 +89,11 @@ NOPORTS= WITH_DVD= WITH_COMPRESSED_IMAGES= +# Set to non-empty value to build virtual machine images as part of +# the release. +WITH_VMIMAGES= +WITH_COMPRESSED_VMIMAGES= + usage() { echo "Usage: $0 [-c release.conf]" exit 1 @@ -169,7 +174,7 @@ CHROOT_DMAKEFLAGS="${CONF_FILES}" RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}" RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}" RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \ - ${DOCPORTS} WITH_DVD=${WITH_DVD}" + ${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES}" # Force src checkout if configured FORCE_SRC_KEY= @@ -274,4 +279,5 @@ eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \ release eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \ - install DESTDIR=/R WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} + install DESTDIR=/R WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \ + WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES} diff --git a/release/scripts/pkg-stage.sh b/release/scripts/pkg-stage.sh index 6d02ac630f21..0b9963284d60 100755 --- a/release/scripts/pkg-stage.sh +++ b/release/scripts/pkg-stage.sh @@ -40,20 +40,23 @@ if [ ! -x /usr/local/sbin/pkg ]; then /usr/bin/make -C /usr/ports/ports-mgmt/pkg install clean fi -PKG_ABI=$(pkg -vv | grep ^ABI | awk '{print $3}') -PKG_ABI="${PKG_ABI%\";}" -PKG_ABI="${PKG_ABI#\"}" -export PKG_ABI -export PKG_CACHEDIR="dvd/packages/${PKG_ABI}" +export PKG_ABI=$(pkg config ABI) +export PKG_REPODIR="dvd/packages/${PKG_ABI}" -/bin/mkdir -p ${PKG_CACHEDIR} +/bin/mkdir -p ${PKG_REPODIR} # Print pkg(8) information to make debugging easier. ${PKGCMD} -vv ${PKGCMD} update -f -${PKGCMD} fetch -d ${DVD_PACKAGES} +${PKGCMD} fetch -o ${PKG_REPODIR} -d ${DVD_PACKAGES} -${PKGCMD} repo ${PKG_CACHEDIR} +# Create the 'Latest/pkg.txz' symlink so 'pkg bootstrap' works +# using the on-disc packages. +mkdir -p ${PKG_REPODIR}/Latest +(cd ${PKG_REPODIR}/Latest && \ + ln -s ../All/$(${PKGCMD} rquery %n-%v pkg).txz pkg.txz) + +${PKGCMD} repo ${PKG_REPODIR} # Always exit '0', even if pkg(8) complains about conflicts. exit 0 diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile index e991fbbc0109..7445f29b8140 100644 --- a/rescue/rescue/Makefile +++ b/rescue/rescue/Makefile @@ -137,7 +137,6 @@ CRUNCH_ALIAS_bsdlabel= disklabel .endif .if ${MACHINE} == "pc98" -CRUNCH_PROGS_sbin+= bsdlabel CRUNCH_SRCDIR_fdisk= $(.CURDIR)/../../sbin/fdisk_pc98 .endif diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index 12a0e5c56849..4129cf4c2724 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -4469,9 +4469,9 @@ tagcontrol(struct cam_device *device, int argc, char **argv, fprintf(stdout, "%s", pathstr); fprintf(stdout, "dev_active %d\n", ccb->cgds.dev_active); fprintf(stdout, "%s", pathstr); - fprintf(stdout, "devq_openings %d\n", ccb->cgds.devq_openings); + fprintf(stdout, "allocated %d\n", ccb->cgds.allocated); fprintf(stdout, "%s", pathstr); - fprintf(stdout, "devq_queued %d\n", ccb->cgds.devq_queued); + fprintf(stdout, "queued %d\n", ccb->cgds.queued); fprintf(stdout, "%s", pathstr); fprintf(stdout, "held %d\n", ccb->cgds.held); fprintf(stdout, "%s", pathstr); diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c index f79ca2f7b95b..859f48b1a66a 100644 --- a/sbin/dhclient/packet.c +++ b/sbin/dhclient/packet.c @@ -127,17 +127,6 @@ assemble_udp_ip_header(unsigned char *buf, int *bufix, u_int32_t from, ip.ip_dst.s_addr = to; ip.ip_sum = wrapsum(checksum((unsigned char *)&ip, sizeof(ip), 0)); - - /* - * While the BPF -- used for broadcasts -- expects a "true" IP header - * with all the bytes in network byte order, the raw socket interface - * which is used for unicasts expects the ip_len field to be in host - * byte order. In both cases, the checksum has to be correct, so this - * is as good a place as any to turn the bytes around again. - */ - if (to != INADDR_BROADCAST) - ip.ip_len = ntohs(ip.ip_len); - memcpy(&buf[*bufix], &ip, sizeof(ip)); *bufix += sizeof(ip); diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index 8258f079c0ed..8a9a378dfc40 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -673,7 +673,12 @@ ufs2_blksout(union dinode *dp, ufs2_daddr_t *blkp, int frags, ino_t ino, */ blks = howmany(frags * sblock->fs_fsize, TP_BSIZE); if (last) { - resid = howmany(fragoff(sblock, dp->dp2.di_size), TP_BSIZE); + if (writingextdata) + resid = howmany(fragoff(sblock, spcl.c_extsize), + TP_BSIZE); + else + resid = howmany(fragoff(sblock, dp->dp2.di_size), + TP_BSIZE); if (resid > 0) blks -= howmany(sblock->fs_fsize, TP_BSIZE) - resid; } diff --git a/sbin/fdisk_pc98/Makefile b/sbin/fdisk_pc98/Makefile index e5932f8a2d36..6961d31d58a8 100644 --- a/sbin/fdisk_pc98/Makefile +++ b/sbin/fdisk_pc98/Makefile @@ -7,7 +7,7 @@ MAN= fdisk.8 .PATH: ${.CURDIR}/../../sys/geom -DPADD += ${LIBGEOM} -LDADD += -lgeom +DPADD+= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} +LDADD+= -lgeom -lbsdxml -lsbuf .include diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index d2e65e4dc96f..0f8688a8b3e1 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -254,6 +254,8 @@ in6_status(int s __unused, const struct ifaddrs *ifa) printf("autoconf "); if ((flags6 & IN6_IFF_TEMPORARY) != 0) printf("temporary "); + if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0) + printf("prefer_source "); if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) printf("scopeid 0x%x ", @@ -465,6 +467,8 @@ static struct cmd inet6_cmds[] = { DEF_CMD("-deprecated", -IN6_IFF_DEPRECATED, setip6flags), DEF_CMD("autoconf", IN6_IFF_AUTOCONF, setip6flags), DEF_CMD("-autoconf", -IN6_IFF_AUTOCONF, setip6flags), + DEF_CMD("prefer_source",IN6_IFF_PREFER_SOURCE, setip6flags), + DEF_CMD("-prefer_source",-IN6_IFF_PREFER_SOURCE,setip6flags), DEF_CMD("accept_rtadv", ND6_IFF_ACCEPT_RTADV, setnd6flags), DEF_CMD("-accept_rtadv",-ND6_IFF_ACCEPT_RTADV, setnd6flags), DEF_CMD("no_radr", ND6_IFF_NO_RADR, setnd6flags), diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 5bf590d047d6..02766a142fea 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd June 5, 2014 +.Dd October 1, 2014 .Dt IFCONFIG 8 .Os .Sh NAME @@ -679,7 +679,7 @@ Set a flag to enable Neighbor Unreachability Detection. Clear a flag .Cm nud . .It Cm no_prefer_iface -Set a flag to not honor rule 5 of source address selection in RFC 3484. +Set a flag to not honor rule 5 of source address selection in RFC 3484. In practice this means the address on the outgoing interface will not be preferred, effectively yielding the decision to the address selection policy table, configurable with @@ -689,6 +689,19 @@ Clear a flag .Cm no_prefer_iface . .El .Pp +The following parameters are specific for IPv6 addresses. +Note that the address family keyword +.Dq Li inet6 +is needed for them: +.Bl -tag -width indent +.It Cm prefer_source +Set a flag to prefer address as a candidate of the source address for +outgoing packets. +.It Cm -prefer_source +Clear a flag +.Cm prefer_source . +.El +.Pp The following parameters are specific to cloning IEEE 802.11 wireless interfaces with the .Cm create @@ -2318,9 +2331,16 @@ Remove the interface named by from the aggregation interface. .It Cm laggproto Ar proto Set the aggregation protocol. -The default is failover. -The available options are failover, fec, lacp, loadbalance, roundrobin and -none. +The default is +.Li failover . +The available options are +.Li failover , +.Li lacp , +.Li loadbalance , +.Li roundrobin , +.Li broadcast +and +.Li none . .It Cm lagghash Ar option Ns Oo , Ns Ar option Oc Set the packet layers to hash for aggregation protocols which load balance. The default is @@ -2335,6 +2355,34 @@ src/dst address for IPv4 or IPv6. .It Cm l4 src/dst port for TCP/UDP/SCTP. .El +.It Cm use_flowid +Enable local hash computation for RSS hash on the interface. +The +.Li loadbalance +and +.Li lacp +modes will use the RSS hash from the network card if available +to avoid computing one, this may give poor traffic distribution +if the hash is invalid or uses less of the protocol header information. +.Cm use_flowid +disables use of RSS hash from the network card. +The default value can be set via the +.Va net.link.lagg.default_use_flowid +.Xr sysctl 8 +variable. +.Li 0 +means +.Dq disabled +and +.Li 1 +means +.Dq enabled . +.It Cm -use_flowid +Disable local hash computation for RSS hash on the interface. +.It Cm flowid_shift Ar number +Set a shift parameter for RSS local hash computation. +Hash is calculated by using flowid bits in a packet header mbuf +which are shifted by the number of this parameter. .El .Pp The following parameters are specific to IP tunnel interfaces, diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index e449c1d4ccbd..6df9acf97313 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -74,6 +74,7 @@ void callback_register(callback_func *, void *); #define DEF_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func }, 0, NULL } #define DEF_CLONE_CMD(name, param, func) { name, param, { .c_func = func }, 1, NULL } #define DEF_CLONE_CMD_ARG(name, func) { name, NEXTARG, { .c_func = func }, 1, NULL } +#define DEF_CLONE_CMD_ARG2(name, func) { name, NEXTARG2, { .c_func2 = func }, 1, NULL } struct ifaddrs; struct addrinfo; diff --git a/sbin/ifconfig/iflagg.c b/sbin/ifconfig/iflagg.c index 29b8574f4b1a..9c478b3dfc5f 100644 --- a/sbin/ifconfig/iflagg.c +++ b/sbin/ifconfig/iflagg.c @@ -68,7 +68,7 @@ setlaggproto(const char *val, int d, int s, const struct afswtch *afp) bzero(&ra, sizeof(ra)); ra.ra_proto = LAGG_PROTO_MAX; - for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++) { + for (i = 0; i < nitems(lpr); i++) { if (strcmp(val, lpr[i].lpr_name) == 0) { ra.ra_proto = lpr[i].lpr_proto; break; @@ -82,6 +82,48 @@ setlaggproto(const char *val, int d, int s, const struct afswtch *afp) err(1, "SIOCSLAGG"); } +static void +setlaggflowidshift(const char *val, int d, int s, const struct afswtch *afp) +{ + struct lagg_reqopts ro; + + bzero(&ro, sizeof(ro)); + ro.ro_opts = LAGG_OPT_FLOWIDSHIFT; + strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname)); + ro.ro_flowid_shift = (int)strtol(val, NULL, 10); + if (ro.ro_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK) + errx(1, "Invalid flowid_shift option: %s", val); + + if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0) + err(1, "SIOCSLAGGOPTS"); +} + +static void +setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp) +{ + struct lagg_reqopts ro; + + bzero(&ro, sizeof(ro)); + ro.ro_opts = d; + switch (ro.ro_opts) { + case LAGG_OPT_USE_FLOWID: + case -LAGG_OPT_USE_FLOWID: + case LAGG_OPT_LACP_STRICT: + case -LAGG_OPT_LACP_STRICT: + case LAGG_OPT_LACP_TXTEST: + case -LAGG_OPT_LACP_TXTEST: + case LAGG_OPT_LACP_RXTEST: + case -LAGG_OPT_LACP_RXTEST: + break; + default: + err(1, "Invalid lagg option"); + } + strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname)); + + if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0) + err(1, "SIOCSLAGGOPTS"); +} + static void setlagghash(const char *val, int d, int s, const struct afswtch *afp) { @@ -144,6 +186,7 @@ lagg_status(int s) struct lagg_protos lpr[] = LAGG_PROTOS; struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS]; struct lagg_reqall ra; + struct lagg_reqopts ro; struct lagg_reqflags rf; struct lacp_opreq *lp; const char *proto = ""; @@ -151,6 +194,7 @@ lagg_status(int s) bzero(&rp, sizeof(rp)); bzero(&ra, sizeof(ra)); + bzero(&ro, sizeof(ro)); strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname)); strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname)); @@ -162,6 +206,9 @@ lagg_status(int s) ra.ra_size = sizeof(rpbuf); ra.ra_port = rpbuf; + strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname)); + ioctl(s, SIOCGLAGGOPTS, &ro); + strlcpy(rf.rf_ifname, name, sizeof(rf.rf_ifname)); if (ioctl(s, SIOCGLAGGFLAGS, &rf) != 0) rf.rf_flags = 0; @@ -169,7 +216,7 @@ lagg_status(int s) if (ioctl(s, SIOCGLAGG, &ra) == 0) { lp = (struct lacp_opreq *)&ra.ra_lacpreq; - for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++) { + for (i = 0; i < nitems(lpr); i++) { if (ra.ra_proto == lpr[i].lpr_proto) { proto = lpr[i].lpr_name; break; @@ -197,9 +244,28 @@ lagg_status(int s) if (isport) printf(" laggdev %s", rp.rp_ifname); putchar('\n'); - if (verbose && ra.ra_proto == LAGG_PROTO_LACP) - printf("\tlag id: %s\n", - lacp_format_peer(lp, "\n\t\t ")); + if (verbose) { + printf("\tlagg options:\n"); + printf("\t\tuse_flowid: %d\n", + (ro.ro_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0); + printf("\t\tflowid_shift: %d\n", ro.ro_flowid_shift); + switch (ra.ra_proto) { + case LAGG_PROTO_LACP: + printf("\t\tlacp_strict: %d\n", + (ro.ro_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0); + printf("\t\tlacp_rxtest: %d\n", + (ro.ro_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0); + printf("\t\tlacp_txtest: %d\n", + (ro.ro_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0); + } + printf("\tlagg statistics:\n"); + printf("\t\tactive ports: %d\n", ro.ro_active); + printf("\t\tflapping: %u\n", ro.ro_flapping); + if (ra.ra_proto == LAGG_PROTO_LACP) { + printf("\tlag id: %s\n", + lacp_format_peer(lp, "\n\t\t ")); + } + } for (i = 0; i < ra.ra_ports; i++) { lp = (struct lacp_opreq *)&rpbuf[i].rp_lacpreq; @@ -226,6 +292,15 @@ static struct cmd lagg_cmds[] = { DEF_CMD_ARG("-laggport", unsetlaggport), DEF_CMD_ARG("laggproto", setlaggproto), DEF_CMD_ARG("lagghash", setlagghash), + DEF_CMD("use_flowid", LAGG_OPT_USE_FLOWID, setlaggsetopt), + DEF_CMD("-use_flowid", -LAGG_OPT_USE_FLOWID, setlaggsetopt), + DEF_CMD("lacp_strict", LAGG_OPT_LACP_STRICT, setlaggsetopt), + DEF_CMD("-lacp_strict", -LAGG_OPT_LACP_STRICT, setlaggsetopt), + DEF_CMD("lacp_txtest", LAGG_OPT_LACP_TXTEST, setlaggsetopt), + DEF_CMD("-lacp_txtest", -LAGG_OPT_LACP_TXTEST, setlaggsetopt), + DEF_CMD("lacp_rxtest", LAGG_OPT_LACP_RXTEST, setlaggsetopt), + DEF_CMD("-lacp_rxtest", -LAGG_OPT_LACP_RXTEST, setlaggsetopt), + DEF_CMD_ARG("flowid_shift", setlaggflowidshift), }; static struct afswtch af_lagg = { .af_name = "af_lagg", diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c index 2e8039d8d363..abe71d69b9a1 100644 --- a/sbin/ifconfig/sfp.c +++ b/sbin/ifconfig/sfp.c @@ -764,11 +764,13 @@ sfp_status(int s, struct ifreq *ifr, int verbose) /* * Try to read byte 0 from i2c: * Both SFF-8472 and SFF-8436 use it as - * 'identification byte' + * 'identification byte'. + * Stop reading status on zero as value - + * this might happen in case of empty transceiver slot. */ id_byte = 0; ii.f(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte); - if (ii.error != 0) + if (ii.error != 0 || id_byte == 0) return; switch (id_byte) { diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile index 89e7fbe2c6ae..7f3a00884977 100644 --- a/sbin/ping6/Makefile +++ b/sbin/ping6/Makefile @@ -4,7 +4,7 @@ PROG= ping6 MAN= ping6.8 CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS \ - -DHAVE_POLL_H -DHAVE_ARC4RANDOM + -DHAVE_ARC4RANDOM WARNS?= 2 BINOWN= root diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index b963de176892..14f689d82630 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -125,10 +125,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#ifdef HAVE_POLL_H -#include -#endif #ifdef IPSEC #include @@ -207,7 +205,6 @@ u_int options; int mx_dup_ck = MAX_DUP_CHK; char rcvd_tbl[MAX_DUP_CHK / 8]; -struct addrinfo *res = NULL; struct sockaddr_in6 dst; /* who to ping6 */ struct sockaddr_in6 src; /* src addr of this packet */ socklen_t srclen; @@ -223,12 +220,6 @@ u_int8_t nonce[8]; /* nonce field for node information */ int hoplimit = -1; /* hoplimit */ int pathmtu = 0; /* path MTU for the destination. 0 = unspec. */ u_char *packet = NULL; -#ifdef HAVE_POLL_H -struct pollfd fdmaskp[1]; -#else -fd_set *fdmaskp = NULL; -int fdmasks; -#endif /* counters */ long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ @@ -236,7 +227,7 @@ long npackets; /* max packets to transmit */ long nreceived; /* # of packets we got back */ long nrepeats; /* number of duplicates */ long ntransmitted; /* sequence # for outbound packets = #sent */ -struct timeval interval = {1, 0}; /* interval between packets */ +int interval = 1000; /* interval between packets in ms */ /* timing */ int timing; /* flag to do timing */ @@ -253,7 +244,6 @@ struct msghdr smsghdr; struct iovec smsgiov; char *scmsg = 0; -volatile sig_atomic_t seenalrm; volatile sig_atomic_t seenint; #ifdef SIGINFO volatile sig_atomic_t seeninfo; @@ -265,7 +255,6 @@ int get_hoplim(struct msghdr *); int get_pathmtu(struct msghdr *); struct in6_pktinfo *get_rcvpktinfo(struct msghdr *); void onsignal(int); -void retransmit(void); void onint(int); size_t pingerlen(void); int pinger(void); @@ -293,19 +282,15 @@ void usage(void); int main(int argc, char *argv[]) { - struct itimerval itimer; - struct sockaddr_in6 from; + struct timeval last, intvl; + struct sockaddr_in6 from, *sin6; #ifndef HAVE_ARC4RANDOM struct timeval seed; #endif -#ifdef HAVE_POLL_H - int timeout; -#else - struct timeval timeout, *tv; -#endif - struct addrinfo hints; + struct addrinfo hints, *res; + struct sigaction si_sa; int cc, i; - int ch, hold, packlen, preload, optval, ret_ga; + int almost_done, ch, hold, packlen, preload, optval, error; int nig_oldmcprefix = -1; u_char *datap; char *e, *target, *ifname = NULL, *gateway = NULL; @@ -326,7 +311,7 @@ main(int argc, char *argv[]) char *policy_in = NULL; char *policy_out = NULL; #endif - double intval; + double t; size_t rthlen; #ifdef IPV6_USE_MIN_MTU int mflag = 0; @@ -450,22 +435,22 @@ main(int argc, char *argv[]) #endif break; case 'i': /* wait between sending packets */ - intval = strtod(optarg, &e); + t = strtod(optarg, &e); if (*optarg == '\0' || *e != '\0') errx(1, "illegal timing interval %s", optarg); - if (intval < 1 && getuid()) { + if (t < 1 && getuid()) { errx(1, "%s: only root may use interval < 1s", strerror(EPERM)); } - interval.tv_sec = (long)intval; - interval.tv_usec = - (long)((intval - interval.tv_sec) * 1000000); - if (interval.tv_sec < 0) + intvl.tv_sec = (long)t; + intvl.tv_usec = + (long)((t - intvl.tv_sec) * 1000000); + if (intvl.tv_sec < 0) errx(1, "illegal timing interval %s", optarg); /* less than 1/hz does not make sense */ - if (interval.tv_sec == 0 && interval.tv_usec < 1) { + if (intvl.tv_sec == 0 && intvl.tv_usec < 1) { warnx("too small interval, raised to .000001"); - interval.tv_usec = 1; + intvl.tv_usec = 1; } options |= F_INTERVAL; break; @@ -516,10 +501,10 @@ main(int argc, char *argv[]) hints.ai_socktype = SOCK_RAW; hints.ai_protocol = IPPROTO_ICMPV6; - ret_ga = getaddrinfo(optarg, NULL, &hints, &res); - if (ret_ga) { + error = getaddrinfo(optarg, NULL, &hints, &res); + if (error) { errx(1, "invalid source address: %s", - gai_strerror(ret_ga)); + gai_strerror(error)); } /* * res->ai_family must be AF_INET6 and res->ai_addrlen @@ -622,9 +607,9 @@ main(int argc, char *argv[]) hints.ai_socktype = SOCK_RAW; hints.ai_protocol = IPPROTO_ICMPV6; - ret_ga = getaddrinfo(target, NULL, &hints, &res); - if (ret_ga) - errx(1, "%s", gai_strerror(ret_ga)); + error = getaddrinfo(target, NULL, &hints, &res); + if (error) + errx(1, "%s", gai_strerror(error)); if (res->ai_canonname) hostname = res->ai_canonname; else @@ -647,28 +632,25 @@ main(int argc, char *argv[]) /* set the gateway (next hop) if specified */ if (gateway) { - struct addrinfo ghints, *gres; - int error; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_RAW; + hints.ai_protocol = IPPROTO_ICMPV6; - memset(&ghints, 0, sizeof(ghints)); - ghints.ai_family = AF_INET6; - ghints.ai_socktype = SOCK_RAW; - ghints.ai_protocol = IPPROTO_ICMPV6; - - error = getaddrinfo(gateway, NULL, &hints, &gres); + error = getaddrinfo(gateway, NULL, &hints, &res); if (error) { errx(1, "getaddrinfo for the gateway %s: %s", gateway, gai_strerror(error)); } - if (gres->ai_next && (options & F_VERBOSE)) + if (res->ai_next && (options & F_VERBOSE)) warnx("gateway resolves to multiple addresses"); if (setsockopt(s, IPPROTO_IPV6, IPV6_NEXTHOP, - gres->ai_addr, gres->ai_addrlen)) { + res->ai_addr, res->ai_addrlen)) { err(1, "setsockopt(IPV6_NEXTHOP)"); } - freeaddrinfo(gres); + freeaddrinfo(res); } /* @@ -898,7 +880,7 @@ main(int argc, char *argv[]) } if (argc > 1) { /* some intermediate addrs are specified */ - int hops, error; + int hops; #ifdef USE_RFC2292BIS int rthdrlen; #endif @@ -920,26 +902,25 @@ main(int argc, char *argv[]) #endif /* USE_RFC2292BIS */ for (hops = 0; hops < argc - 1; hops++) { - struct addrinfo *iaip; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET6; if ((error = getaddrinfo(argv[hops], NULL, &hints, - &iaip))) + &res))) errx(1, "%s", gai_strerror(error)); - if (SIN6(iaip->ai_addr)->sin6_family != AF_INET6) + if (res->ai_addr->sa_family != AF_INET6) errx(1, "bad addr family of an intermediate addr"); - + sin6 = (struct sockaddr_in6 *)(void *)res->ai_addr; #ifdef USE_RFC2292BIS - if (inet6_rth_add(rthdr, - &(SIN6(iaip->ai_addr))->sin6_addr)) + if (inet6_rth_add(rthdr, &sin6->sin6_addr)) errx(1, "can't add an intermediate node"); #else /* old advanced API */ - if (inet6_rthdr_add(scmsgp, - &(SIN6(iaip->ai_addr))->sin6_addr, + if (inet6_rthdr_add(scmsg, &sin6->sin6_addr, IPV6_RTHDR_LOOSE)) errx(1, "can't add an intermediate node"); #endif /* USE_RFC2292BIS */ - freeaddrinfo(iaip); + freeaddrinfo(res); } #ifndef USE_RFC2292BIS @@ -1055,58 +1036,46 @@ main(int argc, char *argv[]) printf("%s --> ", pr_addr((struct sockaddr *)&src, sizeof(src))); printf("%s\n", pr_addr((struct sockaddr *)&dst, sizeof(dst))); - while (preload--) /* Fire off them quickies. */ - (void)pinger(); - - (void)signal(SIGINT, onsignal); -#ifdef SIGINFO - (void)signal(SIGINFO, onsignal); -#endif - - if ((options & F_FLOOD) == 0) { - (void)signal(SIGALRM, onsignal); - itimer.it_interval = interval; - itimer.it_value = interval; - (void)setitimer(ITIMER_REAL, &itimer, NULL); - if (ntransmitted == 0) - retransmit(); + if (preload == 0) + pinger(); + else { + if (npackets != 0 && preload > npackets) + preload = npackets; + while (preload--) + pinger(); } + gettimeofday(&last, NULL); -#ifndef HAVE_POLL_H - fdmasks = howmany(s + 1, NFDBITS) * sizeof(fd_mask); - if ((fdmaskp = malloc(fdmasks)) == NULL) - err(1, "malloc"); -#endif - - seenalrm = seenint = 0; + sigemptyset(&si_sa.sa_mask); + si_sa.sa_flags = 0; + si_sa.sa_handler = onsignal; + if (sigaction(SIGINT, &si_sa, 0) == -1) + err(EX_OSERR, "sigaction SIGINT"); + seenint = 0; #ifdef SIGINFO + if (sigaction(SIGINFO, &si_sa, 0) == -1) + err(EX_OSERR, "sigaction SIGINFO"); seeninfo = 0; #endif + if (options & F_FLOOD) { + intvl.tv_sec = 0; + intvl.tv_usec = 10000; + } else if ((options & F_INTERVAL) == 0) { + intvl.tv_sec = interval / 1000; + intvl.tv_usec = interval % 1000 * 1000; + } - for (;;) { + almost_done = 0; + while (seenint == 0) { + struct timeval now, timeout; struct msghdr m; struct iovec iov[2]; + fd_set rfds; + int n; /* signal handling */ - if (seenalrm) { - /* last packet sent, timeout reached? */ - if (npackets && ntransmitted >= npackets) { - struct timeval zerotime = {0, 0}; - itimer.it_value = zerotime; - itimer.it_interval = zerotime; - (void)setitimer(ITIMER_REAL, &itimer, NULL); - seenalrm = 0; /* clear flag */ - continue; - } - retransmit(); - seenalrm = 0; - continue; - } - if (seenint) { + if (seenint) onint(SIGINT); - seenint = 0; - continue; - } #ifdef SIGINFO if (seeninfo) { summary(); @@ -1114,93 +1083,104 @@ main(int argc, char *argv[]) continue; } #endif - - if (options & F_FLOOD) { - (void)pinger(); -#ifdef HAVE_POLL_H - timeout = 10; -#else - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - tv = &timeout; -#endif - } else { -#ifdef HAVE_POLL_H - timeout = INFTIM; -#else - tv = NULL; -#endif + FD_ZERO(&rfds); + FD_SET(s, &rfds); + gettimeofday(&now, NULL); + timeout.tv_sec = last.tv_sec + intvl.tv_sec - now.tv_sec; + timeout.tv_usec = last.tv_usec + intvl.tv_usec - now.tv_usec; + while (timeout.tv_usec < 0) { + timeout.tv_usec += 1000000; + timeout.tv_sec--; } -#ifdef HAVE_POLL_H - fdmaskp[0].fd = s; - fdmaskp[0].events = POLLIN; - cc = poll(fdmaskp, 1, timeout); -#else - memset(fdmaskp, 0, fdmasks); - FD_SET(s, fdmaskp); - cc = select(s + 1, fdmaskp, NULL, NULL, tv); -#endif - if (cc < 0) { - if (errno != EINTR) { -#ifdef HAVE_POLL_H - warn("poll"); -#else - warn("select"); -#endif - sleep(1); - } - continue; - } else if (cc == 0) - continue; + while (timeout.tv_usec > 1000000) { + timeout.tv_usec -= 1000000; + timeout.tv_sec++; + } + if (timeout.tv_sec < 0) + timeout.tv_sec = timeout.tv_usec = 0; - m.msg_name = (caddr_t)&from; - m.msg_namelen = sizeof(from); - memset(&iov, 0, sizeof(iov)); - iov[0].iov_base = (caddr_t)packet; - iov[0].iov_len = packlen; - m.msg_iov = iov; - m.msg_iovlen = 1; - memset(cm, 0, CONTROLLEN); - m.msg_control = (void *)cm; - m.msg_controllen = CONTROLLEN; + n = select(s + 1, &rfds, NULL, NULL, &timeout); + if (n < 0) + continue; /* EINTR */ + if (n == 1) { + m.msg_name = (caddr_t)&from; + m.msg_namelen = sizeof(from); + memset(&iov, 0, sizeof(iov)); + iov[0].iov_base = (caddr_t)packet; + iov[0].iov_len = packlen; + m.msg_iov = iov; + m.msg_iovlen = 1; + memset(cm, 0, CONTROLLEN); + m.msg_control = (void *)cm; + m.msg_controllen = CONTROLLEN; - cc = recvmsg(s, &m, 0); - if (cc < 0) { - if (errno != EINTR) { - warn("recvmsg"); - sleep(1); - } - continue; - } else if (cc == 0) { - int mtu; - - /* - * receive control messages only. Process the - * exceptions (currently the only possibility is - * a path MTU notification.) - */ - if ((mtu = get_pathmtu(&m)) > 0) { - if ((options & F_VERBOSE) != 0) { - printf("new path MTU (%d) is " - "notified\n", mtu); + cc = recvmsg(s, &m, 0); + if (cc < 0) { + if (errno != EINTR) { + warn("recvmsg"); + sleep(1); } + continue; + } else if (cc == 0) { + int mtu; + + /* + * receive control messages only. Process the + * exceptions (currently the only possibility is + * a path MTU notification.) + */ + if ((mtu = get_pathmtu(&m)) > 0) { + if ((options & F_VERBOSE) != 0) { + printf("new path MTU (%d) is " + "notified\n", mtu); + } + } + continue; + } else { + /* + * an ICMPv6 message (probably an echoreply) + * arrived. + */ + pr_pack(packet, cc, &m); } - continue; - } else { - /* - * an ICMPv6 message (probably an echoreply) arrived. - */ - pr_pack(packet, cc, &m); + if (((options & F_ONCE) != 0 && nreceived > 0) || + (npackets > 0 && nreceived >= npackets)) + break; } - if (((options & F_ONCE) != 0 && nreceived > 0) || - (npackets > 0 && nreceived >= npackets)) - break; - if (ntransmitted - nreceived - 1 > nmissedmax) { - nmissedmax = ntransmitted - nreceived - 1; - if (options & F_MISSED) - (void)write(STDOUT_FILENO, &BBELL, 1); + if (n == 0 || (options & F_FLOOD)) { + if (npackets == 0 || ntransmitted < npackets) + pinger(); + else { + if (almost_done) + break; + almost_done = 1; + /* + * If we're not transmitting any more packets, + * change the timer to wait two round-trip times + * if we've received any packets or ten seconds + * if we haven't. + */ +#define MAXWAIT 10 + intvl.tv_usec = 0; + if (nreceived) { + intvl.tv_sec = 2 * tmax / 1000; + if (intvl.tv_sec == 0) + intvl.tv_sec = 1; + } else + intvl.tv_sec = MAXWAIT; + } + gettimeofday(&last, NULL); + if (ntransmitted - nreceived - 1 > nmissedmax) { + nmissedmax = ntransmitted - nreceived - 1; + if (options & F_MISSED) + (void)write(STDOUT_FILENO, &BBELL, 1); + } } } + sigemptyset(&si_sa.sa_mask); + si_sa.sa_flags = 0; + si_sa.sa_handler = SIG_IGN; + sigaction(SIGINT, &si_sa, 0); summary(); if (res != NULL) @@ -1209,11 +1189,6 @@ main(int argc, char *argv[]) if(packet != NULL) free(packet); -#ifndef HAVE_POLL_H - if(fdmaskp != NULL) - free(fdmaskp); -#endif - exit(nreceived == 0 ? 2 : 0); } @@ -1222,9 +1197,6 @@ onsignal(int sig) { switch (sig) { - case SIGALRM: - seenalrm++; - break; case SIGINT: seenint++; break; @@ -1236,38 +1208,6 @@ onsignal(int sig) } } -/* - * retransmit -- - * This routine transmits another ping6. - */ -void -retransmit(void) -{ - struct itimerval itimer; - - if (pinger() == 0) - return; - - /* - * If we're not transmitting any more packets, change the timer - * to wait two round-trip times if we've received any packets or - * ten seconds if we haven't. - */ -#define MAXWAIT 10 - if (nreceived) { - itimer.it_value.tv_sec = 2 * tmax / 1000; - if (itimer.it_value.tv_sec == 0) - itimer.it_value.tv_sec = 1; - } else - itimer.it_value.tv_sec = MAXWAIT; - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_usec = 0; - - (void)signal(SIGALRM, onsignal); - (void)setitimer(ITIMER_REAL, &itimer, NULL); -} - /* * pinger -- * Compose and transmit an ICMP ECHO REQUEST packet. The IP packet @@ -2247,24 +2187,12 @@ tvsub(struct timeval *out, struct timeval *in) void onint(int notused __unused) { - summary(); - - if (res != NULL) - freeaddrinfo(res); - - if(packet != NULL) - free(packet); - -#ifndef HAVE_POLL_H - if(fdmaskp != NULL) - free(fdmaskp); -#endif - - (void)signal(SIGINT, SIG_DFL); - (void)kill(getpid(), SIGINT); - - /* NOTREACHED */ - exit(1); + /* + * When doing reverse DNS lookups, the seenint flag might not + * be noticed for a while. Just exit if we get a second SIGINT. + */ + if ((options & F_HOSTNAME) && seenint != 0) + _exit(nreceived ? 0 : 2); } /* diff --git a/sbin/routed/defs.h b/sbin/routed/defs.h index c42cd806e150..a31d6f596e96 100644 --- a/sbin/routed/defs.h +++ b/sbin/routed/defs.h @@ -462,6 +462,7 @@ extern int ridhosts; /* 1=reduce host routes */ extern int mhome; /* 1=want multi-homed host route */ extern int advertise_mhome; /* 1=must continue advertising it */ extern int auth_ok; /* 1=ignore auth if we do not care */ +extern int insecure; /* Reply to special queries or not */ extern struct timeval clk; /* system clock's idea of time */ extern struct timeval epoch; /* system clock when started */ diff --git a/sbin/routed/input.c b/sbin/routed/input.c index 8f8eefc5614c..901c4f3e6b9e 100644 --- a/sbin/routed/input.c +++ b/sbin/routed/input.c @@ -289,8 +289,19 @@ input(struct sockaddr_in *from, /* received from this IP address */ * with all we know. */ if (from->sin_port != htons(RIP_PORT)) { - supply(from, aifp, OUT_QUERY, 0, - rip->rip_vers, ap != 0); + /* + * insecure: query from non-router node + * > 1: allow from distant node + * > 0: allow from neighbor node + * == 0: deny + */ + if ((aifp != NULL && insecure > 0) || + (aifp == NULL && insecure > 1)) + supply(from, aifp, OUT_QUERY, 0, + rip->rip_vers, ap != 0); + else + trace_pkt("Warning: " + "possible attack detected"); return; } diff --git a/sbin/routed/main.c b/sbin/routed/main.c index 1658d2e48cd8..5ebd7ec03a67 100644 --- a/sbin/routed/main.c +++ b/sbin/routed/main.c @@ -68,6 +68,7 @@ int ridhosts; /* 1=reduce host routes */ int mhome; /* 1=want multi-homed host route */ int advertise_mhome; /* 1=must continue advertising it */ int auth_ok = 1; /* 1=ignore auth if we do not care */ +int insecure; /* Reply to special queries or not */ struct timeval epoch; /* when started */ struct timeval clk; @@ -136,8 +137,11 @@ main(int argc, (void)gethostname(myname, sizeof(myname)-1); (void)gethost(myname, &myaddr); - while ((n = getopt(argc, argv, "sqdghmAtvT:F:P:")) != -1) { + while ((n = getopt(argc, argv, "isqdghmAtvT:F:P:")) != -1) { switch (n) { + case 'i': + insecure++; + break; case 's': supplier = 1; supplier_set = 1; diff --git a/sbin/routed/output.c b/sbin/routed/output.c index 53eb4a5cff99..c2ed468c12c9 100644 --- a/sbin/routed/output.c +++ b/sbin/routed/output.c @@ -673,8 +673,6 @@ supply(struct sockaddr_in *dst, struct rt_entry *rt; int def_metric; - assert(ifp != NULL); - ws.state = 0; ws.gen_limit = 1024; diff --git a/sbin/routed/routed.8 b/sbin/routed/routed.8 index 2f8a02176d3d..ca5250b21efa 100644 --- a/sbin/routed/routed.8 +++ b/sbin/routed/routed.8 @@ -30,7 +30,7 @@ .\" @(#)routed.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd June 1, 1996 +.Dd August 26, 2014 .Dt ROUTED 8 .Os .Sh NAME @@ -39,7 +39,7 @@ .Nd network RIP and router discovery routing daemon .Sh SYNOPSIS .Nm -.Op Fl sqdghmpAtv +.Op Fl isqdghmpAtv .Op Fl T Ar tracefile .Oo .Fl F @@ -250,6 +250,20 @@ to infer the netmask used by the remote system when RIPv1 is used. .Pp The following options are available: .Bl -tag -width indent +.It Fl i +allow +.Nm +to accept a RIP request from non-router node. +When specified once, +.Nm +replies to a route information query from neighbor nodes. +When specified twice, +it replies to a query from remote nodes in addition. +.Xr rtquery 8 +utility can be used to send a request. +.Pp +This feature is disabled by default because of a risk of reflection attack +though it is useful for debugging purpose. .It Fl s force .Nm diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 0f1d41ea83c1..7a5fc4c937da 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -151,7 +151,10 @@ getbounds(void) { } if (fgets(buf, sizeof buf, fp) == NULL) { - syslog(LOG_WARNING, "unable to read from bounds, using 0"); + if (feof(fp)) + syslog(LOG_WARNING, "bounds file is empty, using 0"); + else + syslog(LOG_WARNING, "bounds file: %s", strerror(errno)); fclose(fp); return (ret); } @@ -160,6 +163,7 @@ getbounds(void) { ret = (int)strtol(buf, NULL, 10); if (ret == 0 && (errno == EINVAL || errno == ERANGE)) syslog(LOG_WARNING, "invalid value found in bounds, using 0"); + fclose(fp); return (ret); } diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 578260d63185..a6ea9f9891a5 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -48,10 +48,16 @@ static const char rcsid[] = #include #include +#ifdef __amd64__ +#include +#include +#endif + #if defined(__amd64__) || defined(__i386__) #include #endif +#include #include #include #include @@ -73,9 +79,33 @@ static int parsefile(const char *); static int parse(const char *, int); static int show_var(int *, int); static int sysctl_all(int *oid, int len); -static int name2oid(char *, int *); +static int name2oid(const char *, int *); -static int set_IK(const char *, int *); +static int strIKtoi(const char *, char **); + +static int ctl_sign[CTLTYPE+1] = { + [CTLTYPE_INT] = 1, + [CTLTYPE_LONG] = 1, + [CTLTYPE_S64] = 1, +}; + +static int ctl_size[CTLTYPE+1] = { + [CTLTYPE_INT] = sizeof(int), + [CTLTYPE_UINT] = sizeof(u_int), + [CTLTYPE_LONG] = sizeof(long), + [CTLTYPE_ULONG] = sizeof(u_long), + [CTLTYPE_S64] = sizeof(int64_t), + [CTLTYPE_U64] = sizeof(uint64_t), +}; + +static const char *ctl_typename[CTLTYPE+1] = { + [CTLTYPE_INT] = "integer", + [CTLTYPE_UINT] = "unsigned integer", + [CTLTYPE_LONG] = "long integer", + [CTLTYPE_ULONG] = "unsigned long", + [CTLTYPE_S64] = "int64_t", + [CTLTYPE_U64] = "uint64_t", +}; static void usage(void) @@ -186,7 +216,8 @@ static int parse(const char *string, int lineno) { int len, i, j; - void *newval = 0; + const void *newval; + const char *newvalstr = NULL; int intval; unsigned int uintval; long longval; @@ -195,7 +226,7 @@ parse(const char *string, int lineno) int64_t i64val; uint64_t u64val; int mib[CTL_MAXNAME]; - char *cp, *bufp, buf[BUFSIZ], *endptr, fmt[BUFSIZ], line[BUFSIZ]; + char *cp, *bufp, buf[BUFSIZ], *endptr = NULL, fmt[BUFSIZ], line[BUFSIZ]; u_int kind; if (lineno) @@ -225,7 +256,7 @@ parse(const char *string, int lineno) cp[strlen(cp) - 1] = '\0'; cp++; } - newval = cp; + newvalstr = cp; newsize = strlen(cp); } len = name2oid(bufp, mib); @@ -249,7 +280,7 @@ parse(const char *string, int lineno) exit(1); } - if (newval == NULL || dflag) { + if (newvalstr == NULL || dflag) { if ((kind & CTLTYPE) == CTLTYPE_NODE) { if (dflag) { i = show_var(mib, len); @@ -277,97 +308,77 @@ parse(const char *string, int lineno) return (1); } - if ((kind & CTLTYPE) == CTLTYPE_INT || - (kind & CTLTYPE) == CTLTYPE_UINT || - (kind & CTLTYPE) == CTLTYPE_LONG || - (kind & CTLTYPE) == CTLTYPE_ULONG || - (kind & CTLTYPE) == CTLTYPE_S64 || - (kind & CTLTYPE) == CTLTYPE_U64) { - if (strlen(newval) == 0) { + switch (kind & CTLTYPE) { + case CTLTYPE_INT: + case CTLTYPE_UINT: + case CTLTYPE_LONG: + case CTLTYPE_ULONG: + case CTLTYPE_S64: + case CTLTYPE_U64: + if (strlen(newvalstr) == 0) { warnx("empty numeric value"); return (1); } + /* FALLTHROUGH */ + case CTLTYPE_STRING: + break; + default: + warnx("oid '%s' is type %d," + " cannot set that%s", bufp, + kind & CTLTYPE, line); + return (1); } + errno = 0; + switch (kind & CTLTYPE) { case CTLTYPE_INT: - if (strcmp(fmt, "IK") == 0) { - if (!set_IK(newval, &intval)) { - warnx("invalid value '%s'%s", - (char *)newval, line); - return (1); - } - } else { - intval = (int)strtol(newval, &endptr, + if (strcmp(fmt, "IK") == 0) + intval = strIKtoi(newvalstr, &endptr); + else + intval = (int)strtol(newvalstr, &endptr, 0); - if (endptr == newval || *endptr != '\0') { - warnx("invalid integer '%s'%s", - (char *)newval, line); - return (1); - } - } newval = &intval; newsize = sizeof(intval); break; case CTLTYPE_UINT: - uintval = (int) strtoul(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { - warnx("invalid unsigned integer '%s'%s", - (char *)newval, line); - return (1); - } + uintval = (int) strtoul(newvalstr, &endptr, 0); newval = &uintval; newsize = sizeof(uintval); break; case CTLTYPE_LONG: - longval = strtol(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { - warnx("invalid long integer '%s'%s", - (char *)newval, line); - return (1); - } + longval = strtol(newvalstr, &endptr, 0); newval = &longval; newsize = sizeof(longval); break; case CTLTYPE_ULONG: - ulongval = strtoul(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { - warnx("invalid unsigned long integer" - " '%s'%s", (char *)newval, line); - return (1); - } + ulongval = strtoul(newvalstr, &endptr, 0); newval = &ulongval; newsize = sizeof(ulongval); break; case CTLTYPE_STRING: + newval = newvalstr; break; case CTLTYPE_S64: - i64val = strtoimax(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { - warnx("invalid int64_t '%s'%s", - (char *)newval, line); - return (1); - } + i64val = strtoimax(newvalstr, &endptr, 0); newval = &i64val; newsize = sizeof(i64val); break; case CTLTYPE_U64: - u64val = strtoumax(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { - warnx("invalid uint64_t '%s'%s", - (char *)newval, line); - return (1); - } + u64val = strtoumax(newvalstr, &endptr, 0); newval = &u64val; newsize = sizeof(u64val); break; - case CTLTYPE_OPAQUE: - /* FALLTHROUGH */ default: - warnx("oid '%s' is type %d," - " cannot set that%s", bufp, - kind & CTLTYPE, line); - return (1); + /* NOTREACHED */ + abort(); + } + + if (errno != 0 || endptr == newvalstr || + (endptr != NULL && *endptr != '\0')) { + warnx("invalid %s '%s'%s", ctl_typename[kind & CTLTYPE], + newvalstr, line); + return (1); } i = show_var(mib, len); @@ -458,12 +469,12 @@ parsefile(const char *filename) /* These functions will dump out various interesting structures. */ static int -S_clockinfo(int l2, void *p) +S_clockinfo(size_t l2, void *p) { struct clockinfo *ci = (struct clockinfo*)p; if (l2 != sizeof(*ci)) { - warnx("S_clockinfo %d != %zu", l2, sizeof(*ci)); + warnx("S_clockinfo %zu != %zu", l2, sizeof(*ci)); return (1); } printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz = %'d }" : @@ -473,12 +484,12 @@ S_clockinfo(int l2, void *p) } static int -S_loadavg(int l2, void *p) +S_loadavg(size_t l2, void *p) { struct loadavg *tv = (struct loadavg*)p; if (l2 != sizeof(*tv)) { - warnx("S_loadavg %d != %zu", l2, sizeof(*tv)); + warnx("S_loadavg %zu != %zu", l2, sizeof(*tv)); return (1); } printf(hflag ? "{ %'.2f %'.2f %'.2f }" : "{ %.2f %.2f %.2f }", @@ -489,14 +500,14 @@ S_loadavg(int l2, void *p) } static int -S_timeval(int l2, void *p) +S_timeval(size_t l2, void *p) { struct timeval *tv = (struct timeval*)p; time_t tv_sec; char *p1, *p2; if (l2 != sizeof(*tv)) { - warnx("S_timeval %d != %zu", l2, sizeof(*tv)); + warnx("S_timeval %zu != %zu", l2, sizeof(*tv)); return (1); } printf(hflag ? "{ sec = %'jd, usec = %'ld } " : @@ -513,13 +524,13 @@ S_timeval(int l2, void *p) } static int -S_vmtotal(int l2, void *p) +S_vmtotal(size_t l2, void *p) { struct vmtotal *v = (struct vmtotal *)p; int pageKilo = getpagesize() / 1024; if (l2 != sizeof(*v)) { - warnx("S_vmtotal %d != %zu", l2, sizeof(*v)); + warnx("S_vmtotal %zu != %zu", l2, sizeof(*v)); return (1); } @@ -540,19 +551,104 @@ S_vmtotal(int l2, void *p) v->t_vmshr * pageKilo, v->t_avmshr * pageKilo); printf("Shared Real Memory:\t(Total: %dK Active: %dK)\n", v->t_rmshr * pageKilo, v->t_armshr * pageKilo); - printf("Free Memory:\t%dK\n", v->t_free * pageKilo); + printf("Free Memory:\t%dK", v->t_free * pageKilo); return (0); } +#ifdef __amd64__ +#define efi_next_descriptor(ptr, size) \ + ((struct efi_md *)(((uint8_t *) ptr) + size)) + +static int +S_efi_map(size_t l2, void *p) +{ + struct efi_map_header *efihdr; + struct efi_md *map; + const char *type; + size_t efisz; + int ndesc, i; + + static const char *types[] = { + "Reserved", + "LoaderCode", + "LoaderData", + "BootServicesCode", + "BootServicesData", + "RuntimeServicesCode", + "RuntimeServicesData", + "ConventionalMemory", + "UnusableMemory", + "ACPIReclaimMemory", + "ACPIMemoryNVS", + "MemoryMappedIO", + "MemoryMappedIOPortSpace", + "PalCode" + }; + + /* + * Memory map data provided by UEFI via the GetMemoryMap + * Boot Services API. + */ + if (l2 < sizeof(*efihdr)) { + warnx("S_efi_map length less than header"); + return (1); + } + efihdr = p; + efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf; + map = (struct efi_md *)((uint8_t *)efihdr + efisz); + + if (efihdr->descriptor_size == 0) + return (0); + if (l2 != efisz + efihdr->memory_size) { + warnx("S_efi_map length mismatch %zu vs %zu", l2, efisz + + efihdr->memory_size); + return (1); + } + ndesc = efihdr->memory_size / efihdr->descriptor_size; + + printf("\n%23s %12s %12s %8s %4s", + "Type", "Physical", "Virtual", "#Pages", "Attr"); + + for (i = 0; i < ndesc; i++, + map = efi_next_descriptor(map, efihdr->descriptor_size)) { + if (map->md_type <= EFI_MD_TYPE_PALCODE) + type = types[map->md_type]; + else + type = ""; + printf("\n%23s %012lx %12p %08lx ", type, map->md_phys, + map->md_virt, map->md_pages); + if (map->md_attr & EFI_MD_ATTR_UC) + printf("UC "); + if (map->md_attr & EFI_MD_ATTR_WC) + printf("WC "); + if (map->md_attr & EFI_MD_ATTR_WT) + printf("WT "); + if (map->md_attr & EFI_MD_ATTR_WB) + printf("WB "); + if (map->md_attr & EFI_MD_ATTR_UCE) + printf("UCE "); + if (map->md_attr & EFI_MD_ATTR_WP) + printf("WP "); + if (map->md_attr & EFI_MD_ATTR_RP) + printf("RP "); + if (map->md_attr & EFI_MD_ATTR_XP) + printf("XP "); + if (map->md_attr & EFI_MD_ATTR_RT) + printf("RUNTIME"); + } + return (0); +} +#endif + #if defined(__amd64__) || defined(__i386__) static int -S_bios_smap_xattr(int l2, void *p) +S_bios_smap_xattr(size_t l2, void *p) { struct bios_smap_xattr *smap, *end; if (l2 % sizeof(*smap) != 0) { - warnx("S_bios_smap_xattr %d is not a multiple of %zu", l2, + warnx("S_bios_smap_xattr %zu is not a multiple of %zu", l2, sizeof(*smap)); return (1); } @@ -567,30 +663,35 @@ S_bios_smap_xattr(int l2, void *p) #endif static int -set_IK(const char *str, int *val) +strIKtoi(const char *str, char **endptrp) { + int kelv; float temp; - int len, kelv; + size_t len; const char *p; - char *endptr; - if ((len = strlen(str)) == 0) - return (0); + assert(errno == 0); + + len = strlen(str); + /* caller already checked this */ + assert(len > 0); + p = &str[len - 1]; if (*p == 'C' || *p == 'F') { - temp = strtof(str, &endptr); - if (endptr == str || endptr != p) - return (0); - if (*p == 'F') - temp = (temp - 32) * 5 / 9; - kelv = temp * 10 + 2732; + temp = strtof(str, endptrp); + if (*endptrp != str && *endptrp == p && errno != 0) { + if (*p == 'F') + temp = (temp - 32) * 5 / 9; + return (temp * 10 + 2732); + } } else { - kelv = (int)strtol(str, &endptr, 10); - if (endptr == str || *endptr != '\0') - return (0); + kelv = (int)strtol(str, endptrp, 10); + if (*endptrp != str && *endptrp == p && errno != 0) + return (kelv); } - *val = kelv; - return (1); + + errno = ERANGE; + return (0); } /* @@ -603,7 +704,7 @@ set_IK(const char *str, int *val) */ static int -name2oid(char *name, int *oidp) +name2oid(const char *name, int *oidp) { int oid[2]; int i; @@ -645,21 +746,6 @@ oidfmt(int *oid, int len, char *fmt, u_int *kind) return (0); } -static int ctl_sign[CTLTYPE+1] = { - [CTLTYPE_INT] = 1, - [CTLTYPE_LONG] = 1, - [CTLTYPE_S64] = 1, -}; - -static int ctl_size[CTLTYPE+1] = { - [CTLTYPE_INT] = sizeof(int), - [CTLTYPE_UINT] = sizeof(u_int), - [CTLTYPE_LONG] = sizeof(long), - [CTLTYPE_ULONG] = sizeof(u_long), - [CTLTYPE_S64] = sizeof(int64_t), - [CTLTYPE_U64] = sizeof(int64_t), -}; - /* * This formats and outputs the value of one variable * @@ -680,7 +766,7 @@ show_var(int *oid, int nlen) size_t intlen; size_t j, len; u_int kind; - int (*func)(int, void *); + int (*func)(size_t, void *); /* Silence GCC. */ umv = mv = intlen = 0; @@ -818,6 +904,10 @@ show_var(int *oid, int nlen) func = S_loadavg; else if (strcmp(fmt, "S,vmtotal") == 0) func = S_vmtotal; +#ifdef __amd64__ + else if (strcmp(fmt, "S,efi_map_header") == 0) + func = S_efi_map; +#endif #if defined(__amd64__) || defined(__i386__) else if (strcmp(fmt, "S,bios_smap_xattr") == 0) func = S_bios_smap_xattr; diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh index 793a63d426f0..f7bb2a01a9d5 100755 --- a/share/examples/bhyve/vmrun.sh +++ b/share/examples/bhyve/vmrun.sh @@ -196,7 +196,7 @@ while [ 1 ]; do exit 1 fi BOOTDISK=${isofile} - installer_opt="-s 31:0,virtio-blk,${BOOTDISK}" + installer_opt="-s 31:0,ahci-cd,${BOOTDISK}" else BOOTDISK=${virtio_diskdev} installer_opt="" @@ -204,7 +204,8 @@ while [ 1 ]; do ${LOADER} -c ${console} -m ${memsize} -d ${BOOTDISK} ${loader_opt} \ ${vmname} - if [ $? -ne 0 ]; then + bhyve_exit=$? + if [ $bhyve_exit -ne 0 ]; then break fi @@ -239,6 +240,7 @@ while [ 1 ]; do ${installer_opt} \ ${vmname} + bhyve_exit=$? # bhyve returns the following status codes: # 0 - VM has been reset # 1 - VM has been powered off @@ -246,9 +248,18 @@ while [ 1 ]; do # 3 - VM generated a triple fault # all other non-zero status codes are errors # - if [ $? -ne 0 ]; then + if [ $bhyve_exit -ne 0 ]; then break fi done -exit 99 + +case $bhyve_exit in + 0|1|2) + # Cleanup /dev/vmm entry when bhyve did not exit + # due to an error. + ${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1 + ;; +esac + +exit $bhyve_exit diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 6a8d382ca26b..8200441d2b0e 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -200,12 +200,14 @@ MAN= aac.4 \ ip.4 \ ip6.4 \ ipfirewall.4 \ + ipheth.4 \ ${_ipmi.4} \ ips.4 \ ipsec.4 \ ipw.4 \ ipwfw.4 \ isci.4 \ + iscsi.4 \ iscsi_initiator.4 \ ismt.4 \ isp.4 \ @@ -437,6 +439,7 @@ MAN= aac.4 \ smb.4 \ smbus.4 \ smp.4 \ + smsc.4 \ sn.4 \ snd_ad1816.4 \ snd_als4000.4 \ @@ -657,6 +660,7 @@ MLINKS+=ip.4 rawip.4 MLINKS+=ipfirewall.4 ipaccounting.4 \ ipfirewall.4 ipacct.4 \ ipfirewall.4 ipfw.4 +MLINKS+=ipheth.4 if_ipheth.4 MLINKS+=ipw.4 if_ipw.4 MLINKS+=iwi.4 if_iwi.4 MLINKS+=iwn.4 if_iwn.4 @@ -711,6 +715,7 @@ MLINKS+=sge.4 if_sge.4 MLINKS+=sis.4 if_sis.4 MLINKS+=sk.4 if_sk.4 MLINKS+=smp.4 SMP.4 +MLINKS+=smsc.4 if_smsc.4 MLINKS+=sn.4 if_sn.4 MLINKS+=snd_envy24.4 snd_ak452x.4 MLINKS+=snd_sbc.4 snd_sb16.4 \ diff --git a/share/man/man4/ada.4 b/share/man/man4/ada.4 index 433a5476244d..10897cf0b0bd 100644 --- a/share/man/man4/ada.4 +++ b/share/man/man4/ada.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 21, 2014 +.Dd September 21, 2014 .Dt ADA 4 .Os .Sh NAME @@ -123,11 +123,13 @@ seconds. This variable determines whether to spin-down disks when shutting down. Set to 1 to enable spin-down, 0 to disable. The default is currently enabled. +.It Va kern.cam.ada.read_ahead +.It Va kern.cam.ada. Ns Ar X Ns Va .read_ahead .It Va kern.cam.ada.write_cache .It Va kern.cam.ada. Ns Ar X Ns Va .write_cache .Pp -These variables determine whether device write cache should be enabled -globally or per-device or disabled. +These variables determine whether device read-ahead and write caches +should be enabled globally or per-device or disabled. Set to 1 to enable write cache, 0 to disable, -1 to leave it as-is. Values modified at runtime take effect only after device reset .Pq using the reset subcommand of Xr camcontrol 8 . diff --git a/share/man/man4/cdce.4 b/share/man/man4/cdce.4 index d38a9698f593..fa921b6aacfa 100644 --- a/share/man/man4/cdce.4 +++ b/share/man/man4/cdce.4 @@ -28,7 +28,7 @@ .\" $NetBSD: cdce.4,v 1.4 2004/12/08 18:35:56 peter Exp $ .\" $FreeBSD$ .\" -.Dd September 17, 2005 +.Dd September 25, 2014 .Dt CDCE 4 .Os .Sh NAME @@ -114,9 +114,10 @@ is running low on mbufs. .Sh SEE ALSO .Xr arp 4 , .Xr intro 4 , +.Xr ipheth 4 , .Xr netintro 4 , +.Xr urndis 4 , .Xr usb 4 , -.\" .Xr hostname.if 5 , .Xr ifconfig 8 .Rs .%T "Universal Serial Bus Class Definitions for Communication Devices" diff --git a/share/man/man4/cxgbe.4 b/share/man/man4/cxgbe.4 index 215a1948381b..9a9f86850c56 100644 --- a/share/man/man4/cxgbe.4 +++ b/share/man/man4/cxgbe.4 @@ -240,8 +240,19 @@ The default is -1 which lets the driver pick a pad boundary. Controls the hardware response to congestion. -1 disables congestion feedback and is not recommended. 0 instructs the hardware to backpressure its pipeline on congestion. -This usually results in the port emitting pause frames. +This usually results in the port emitting PAUSE frames. 1 instructs the hardware to drop frames destined for congested queues. +.It Va hw.cxgbe.pause_settings +PAUSE frame settings. +Bit 0 is rx_pause, bit 1 is tx_pause. +rx_pause = 1 instructs the hardware to heed incoming PAUSE frames, 0 instructs +it to ignore them. +tx_pause = 1 allows the hardware to emit PAUSE frames when its receive FIFO +reaches a high threshold, 0 prohibits the hardware from emitting PAUSE frames. +The default is 3 (both rx_pause and tx_pause = 1). +This tunable establishes the default PAUSE settings for all ports. +Settings can be displayed and controlled on a per-port basis via the +dev.cxgbe.X.pause_settings (dev.cxl.X.pause_settings for T5 cards) sysctl. .It Va hw.cxgbe.buffer_packing Allow the hardware to deliver multiple frames in the same receive buffer opportunistically. diff --git a/share/man/man4/icmp.4 b/share/man/man4/icmp.4 index 6b7f78eae926..c0f51b3e1de1 100644 --- a/share/man/man4/icmp.4 +++ b/share/man/man4/icmp.4 @@ -28,7 +28,7 @@ .\" @(#)icmp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd February 9, 2007 +.Dd September 30, 2014 .Dt ICMP 4 .Os .Sh NAME @@ -216,6 +216,10 @@ instead of the possibly different return path. Number of bytes from original packet to quote in ICMP reply. This number is internally enforced to be at least 8 bytes (per RFC792) and at most the maximal space left in the ICMP reply mbuf. +.It Va tstamprepl +.Pq Vt boolean +Enable/disable replies to ICMP Timestamp packets. +Defaults to true. .El .Sh ERRORS A socket operation may fail with one of the following errors returned: diff --git a/share/man/man4/ipheth.4 b/share/man/man4/ipheth.4 new file mode 100644 index 000000000000..50491fb2f270 --- /dev/null +++ b/share/man/man4/ipheth.4 @@ -0,0 +1,106 @@ +.\" Copyright (c) 2014 Gavin Atkinson +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" - Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" - 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 COPYRIGHT HOLDERS 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 +.\" COPYRIGHT HOLDERS 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 September 30, 2014 +.Dt IPHETH 4 +.Os +.Sh NAME +.Nm ipheth +.Nd "USB Apple iPhone/iPad tethered Ethernet driver" +.Sh SYNOPSIS +To load the driver as a module at boot time, place the +following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_ipheth_load="YES" +.Ed +.Pp +Alternatively, to compile this driver into the kernel, place the +following lines in your kernel configuration file: +.Bd -ragged -offset indent +.Cd "device uhci" +.Cd "device ohci" +.Cd "device usb" +.Cd "device ipheth" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for network access through Apple +iPhone and iPad devices, often referred to as USB tethering. +.Pp +.Nm +should work with any Apple iPhone or iPad device. +In most cases this must be explicitly enabled on the device first. +.Pp +For more information on configuring this device, see +.Xr ifconfig 8 . +The device does not support different media types or options. +.Sh HARDWARE +The following devices are supported by the +.Nm +driver: +.Pp +.Bl -bullet -compact +.It +Apple iPhone tethering (all models) +.It +Apple iPad tethering (all models) +.El +.Sh SEE ALSO +.Xr arp 4 , +.Xr cdce 4 , +.Xr intro 4 , +.Xr netintro 4 , +.Xr urndis 4 , +.Xr usb 4 , +.Xr ifconfig 8 +.Xr usbconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 8.2 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org . +.Sh BUGS +Some devices may need to be manually configured to use an alternative +configuration with the +.Xr usbconfig 8 +utility. +A command similar to +.Dl usbconfig -u 1 -a 2 set_config 3 +may be required if the device is not recognised automatically by +.Nm +after it is connected. + diff --git a/share/man/man4/iscsi.4 b/share/man/man4/iscsi.4 new file mode 100755 index 000000000000..2b0db75a2989 --- /dev/null +++ b/share/man/man4/iscsi.4 @@ -0,0 +1,111 @@ +.\" Copyright (c) 2014 Edward Tomasz Napierala +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that 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 September 11, 2014 +.Dt ISCSI 4 +.Os +.Sh NAME +.Nm iscsi +.Nd iSCSI initiator +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following line in the +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device iscsi" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +iscsi_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +subsystem provides the kernel component of an iSCSI initiator. +The initiator is the iSCSI client, which connects to an iSCSI target, +providing local access to a remote block device. +The userland component is provided by +.Xr iscsid 8 +and both the kernel and userland are configured using +.Xr iscsictl 8 . +The +.Nm +subsystem is responsible for implementing the +.Qq Full Feature Phase +of the iSCSI protocol. +.Sh SYSCTL VARIABLES +The following variables are available as both +.Xr sysctl 8 +variables and +.Xr loader 8 +tunables: +.Bl -tag -width indent +.It Va kern.iscsi.ping_timeout +The number of seconds to wait for the target to respond to a NOP-Out +PDU. +In the event that there is no response within that time the session gets +forcibly restarted. +.It Va kern.iscsi.iscsid_timeout +The number of seconds to wait for +.Xr ctld 8 +to establish a session. +After that time +.Nm +will abort and retry. +.It Va kern.iscsi.login_timeout +The number of seconds to wait for a login attempt to succeed. +After that time +.Nm +will abort and retry. +.It Va kern.iscsi.maxtags +The maximum number of outstanding IO requests. +.It Va kern.iscsi.fail_on_disconnection +Controls the behavior after an iSCSI connection has been dropped due to +network problems. +When set to 1, a dropped connection causes the iSCSI device nodes +to be destroyed. +After reconnecting, they will be created again. +By default, the device nodes are left intact. +While the connection is down all input/output operations are suspended, to be +retried after the connection is reestablished. +.El +.Sh SEE ALSO +.Xr iscsi.conf 5 , +.Xr iscsictl 8 , +.Xr iscsid 8 +.Sh HISTORY +The +.Nm +subsystem first appeared in +.Fx 10.0 . +.Sh AUTHORS +The +.Nm +subsystem was developed by +.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org +under sponsorship from the FreeBSD Foundation. diff --git a/share/man/man4/lagg.4 b/share/man/man4/lagg.4 index 392f5f73cdc6..1b4031593155 100644 --- a/share/man/man4/lagg.4 +++ b/share/man/man4/lagg.4 @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 23, 2012 +.Dd October 1, 2014 .Dt LAGG 4 .Os .Sh NAME @@ -61,10 +61,10 @@ option. The driver currently supports the aggregation protocols .Ic failover (the default), -.Ic fec , .Ic lacp , .Ic loadbalance , .Ic roundrobin , +.Ic broadcast , and .Ic none . The protocols determine which ports are used for outgoing traffic @@ -86,9 +86,6 @@ This constraint can be relaxed by setting the .Xr sysctl 8 variable to a nonzero value, which is useful for certain bridged network setups. -.It Ic fec -Supports Cisco EtherChannel. -This is an alias for .Ic loadbalance mode. .It Ic lacp @@ -113,6 +110,9 @@ available, the VLAN tag, and the IP source and destination address. Distributes outgoing traffic using a round-robin scheduler through all active ports and accepts incoming traffic from any active port. +.It Ic broadcast +Sends frames to all ports of the LAG and receives frames on +any port of the LAG. .It Ic none This protocol is intended to do nothing: it disables any traffic without disabling the @@ -143,9 +143,9 @@ modes will use the RSS hash from the network card if available to avoid computing one, this may give poor traffic distribution if the hash is invalid or uses less of the protocol header information. Local hash computation can be forced per interface by setting the -.Va net.link.lagg.X.use_flowid -.Xr sysctl 8 -variable to zero where X is the interface number. +.Cm use_flowid +.Xr ifconfig 8 +flag. The default for new interfaces is set via the .Va net.link.lagg.default_use_flowid .Xr sysctl 8 . diff --git a/share/man/man4/malo.4 b/share/man/man4/malo.4 index 22cc47142fbd..7f8a03631ff0 100644 --- a/share/man/man4/malo.4 +++ b/share/man/man4/malo.4 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\"/ -.Dd October 21, 2009 +.Dd September 20, 2014 .Dt MALO 4 .Os .Sh NAME @@ -49,7 +49,7 @@ kernel configuration file: .Ed .Pp Alternatively, to load the driver as a -module at boot time, place the following lines in +module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent if_malo_load="YES" @@ -84,6 +84,15 @@ the archive and running in the .Pa malo-firmware-1.4 directory. +.Pp +To load the +.Nm malofw +firmware kernel module at boot time, place the following +line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +malofw_load="YES" +.Ed .Sh HARDWARE The following cards are among those supported by the .Nm diff --git a/share/man/man4/man4.arm/Makefile b/share/man/man4/man4.arm/Makefile index 73e7bf72fc54..0e5b576f4c44 100644 --- a/share/man/man4/man4.arm/Makefile +++ b/share/man/man4/man4.arm/Makefile @@ -1,11 +1,13 @@ # $FreeBSD$ -MAN= devcfg.4 \ +MAN= cgem.4 \ + devcfg.4 \ mge.4 \ npe.4 \ ti_adc.4 -MLINKS= mge.4 if_mge.4 +MLINKS= cgem.4 if_cgem.4 +MLINKS+= mge.4 if_mge.4 MLINKS+=npe.4 if_npe.4 MANSUBDIR=/arm diff --git a/share/man/man4/man4.arm/cgem.4 b/share/man/man4/man4.arm/cgem.4 new file mode 100644 index 000000000000..8af1b2ab90c4 --- /dev/null +++ b/share/man/man4/man4.arm/cgem.4 @@ -0,0 +1,297 @@ +.\" +.\" Copyright (c) 2014 Thomas Skibo +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that 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. 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. +.\" +.\" $FreeBSD$ +.\" +.Dd August 26, 2014 +.Dt CGEM 4 +.Os +.Sh NAME +.Nm cgem +.Nd "Cadence GEM Gigabit Ethernet driver" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device ether" +.Cd "device miibus" +.Cd "device cgem" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for the Cadence GEM (Gigabit Ethernet MAC). +The Cadence GEM is used in some SoC (System on a Chip) devices such as +the Xilinx Zynq-7000 and the Atmel SAMA5D3. +.Pp +The +.Nm +driver supports the following media types: +.Bl -tag -width ".Cm 10baseT/UTP" +.It Cm autoselect +Enable autoselection of the media type and options. +The user can manually override +the autoselected mode using +.Xr ifconfig 8 +or by adding media options to +.Xr rc.conf 5 . +.It Cm 10baseT/UTP +Set 10Mbps operation. +The +.Xr ifconfig 8 +.Cm mediaopt +option can also be used to select either +.Cm full-duplex +or +.Cm half-duplex +modes. +.It Cm 100baseTX +Set 100Mbps (Fast Ethernet) operation. +The +.Xr ifconfig 8 +.Cm mediaopt +option can also be used to select either +.Cm full-duplex +or +.Cm half-duplex +modes. +.It Cm 1000baseT +Set 1000Mbps (Gigabit Ethernet) operation over twisted pair. +The GEM supports 1000Mbps in +.Cm full-duplex +mode only. +.El +.Pp +The +.Nm +driver supports the following media options: +.Bl -tag -width ".Cm full-duplex" +.It Cm full-duplex +Force full-duplex operation. +.It Cm half-duplex +Force half-duplex operation. +.El +.Pp +The driver provides support for TCP/UDP/IP checksum offloading (although +disabled by default). +The device and driver also support 1536-byte frames for VLANs (vlanmtu). +.Sh SYSCTL VARIABLES +The following variables are available as both +.Xr sysctl 8 +variables and +.Xr loader 8 +tunables: +.Bl -tag -width "xxxxxxxx" +.It Va dev.cgem.%d.rxbufs +The number of receive buffers allocated to the hardware. +The default value is 256. +The maximum value is 511. +If this number is increased while the interface is UP, it will not +take effect until the next packet is received. +If this number is decreased while the interface is UP, buffers will +not be immediately removed from the receive buffer ring but the +number of buffers will decrease as packets are received until it +reaches the new value. +.It Va dev.cgem.%d.rxhangwar +This tunable enables a work-around to recover from receive hangs. +The default value is 1. +Set to 0 to disable the work-around. +.El +.Pp +The following read-only variables are available as +.Xr sysctl 8 +variables: +.Bl -tag -width "xxxxxxxx" +.It Va dev.cgem.%d._rxoverruns +This variable counts the number of receive packet buffer overrun interrupts. +.It Va dev.cgem.%d._rxnobufs +This variable counts the number of interrupts due to the GEM buffer ring +going empty. +.It Va dev.cgem.%d._rxdmamapfails +This variable is the number of times bus_dmamap_load_mbuf_sg(9) failed in +the receive path. +.It Va dev.cgem.%d._txfull +The number of times the GEM's transmit ring was full. +.It Va dev.cgem.%d._txdmamapfails +This variable is the number of times bus_dmamap_load_mbuf_sg(9) failed in +the transmit path. +.It Va dev.cgem.%d._txdefrags +This variable is the number of times the driver needed to call m_defrag(9) +because a packet queued for transmit had too many DMA segments. +.It Va dev.cgem.%d._txdefragfails +This variable is the number of times +.Xr m_defrag 9 +failed. +.It Va dev.cgem.%d.stats.* +The following variables are useful MAC counters supplied by the hardware: +.It Va dev.cgem.%d.stats.tx_bytes +A 64-bit counter of the number of bytes transmitted in frames without error. +.It Va dev.cgem.%d.stats.tx_frames +Counter of frames transmitted without error excluding pause frames. +.It Va dev.cgem.%d.stats.tx_frames_bcast +Counter of broadcast frames transmitted without error excluding +pause frames. +.It Va dev.cgem.%d.stats.tx_frames_multi +Counter of multicast frames transmitted without error excluding +pause frames. +.It Va dev.cgem.%d.stats.tx_frames_pause +Counter of pause frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_frames_64b +Counter of 64 byte frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_frames_65to127b +Counter of 65 to 127 byte frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_frames_128to255b +Counter of 128 to 255 byte frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_frames_256to511b +Counter of 256 to 511 byte frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_frames_512to1023b +Counter of 512 to 1023 byte frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_frames_1024to1536b +Counter of 1024 to 1536 byte frames transmitted without error. +.It Va dev.cgem.%d.stats.tx_under_runs +Counter of frames not transmitted due to a transmit underrun. +.It Va dev.cgem.%d.stats.tx_single_collisn +Counter of frames experiencing a single collision before being successfully +transmitted. +.It Va dev.cgem.%d.stats.tx_multi_collisn +Counter of frames experiencing between 2 and 15 collisions before +being successfully transmitted. +.It Va dev.cgem.%d.stats.tx_excsv_collisn +Counter of frames that failed to transmit because they experienced 16 +collisions. +.It Va dev.cgem.%d.stats.tx_late_collisn +Counter of frames that experienced a late collision. +.It Va dev.cgem.%d.stats.tx_deferred_frames +Counter of frames experiencing deferral due to carrier sense being +active on their first attempt at transmission. +.It Va dev.cgem.%d.stats.tx_carrier_sense_errs +Counter of frames transmitted where carrier sense was not seen during +transmission or where carrier sense was deasserted after being asserted +in a transmit frame without collision. +.It Va dev.cgem.%d.stats.rx_bytes +A 64-bit counter of bytes received without error excluding pause +frames. +.It Va dev.cgem.%d.stats.rx_frames +Counter of frames received without error excluding pause frames. +.It Va dev.cgem.%d.stats.rx_frames_bcast +Counter of broadcast frames receive without error excluding pause frames. +.It Va dev.cgem.%d.stats.rx_frames_multi +Counter of multicast frames receive without error excluding pause frames. +.It Va dev.cgem.%d.stats.rx_frames_pause +Counter of pause frames recevied without error. +.It Va dev.cgem.%d.stats.rx_frames_64b +Counter of 64-byte frames received without error. +.It Va dev.cgem.%d.stats.rx_frames_65to127b +Counter of 65 to 127 byte frames received without error. +.It Va dev.cgem.%d.stats.rx_frames_128to255b +Counter of 128 to 255 byte frames received without error. +.It Va dev.cgem.%d.stats.rx_frames_256to511b +Counter of 256 to 511 byte frames received without error. +.It Va dev.cgem.%d.stats.rx_frames_512to1023b +Counter of 512 to 1023 byte frames received without error. +.It Va dev.cgem.%d.stats.rx_frames_1024to1536b +Counter of 1024 to 1536 byte frames received without error. +.It Va dev.cgem.%d.stats.rx_frames_undersize +Counter of frames received less than 64 bytes in length that +do not also have either a CRC error or an alignment error. +.It Va dev.cgem.%d.stats.rx_frames_oversize +Counter of frames received exceeding 1536 bytes and do not also have either +a CRC error or an alignment error. +.It Va dev.cgem.%d.stats.rx_frames_jabber +Counter of frames received exceeding 1536 bytes and also have either a CRC +error, an alignment error, or a receive symbol error. +.It Va dev.cgem.%d.stats.rx_frames_fcs_errs +Counter of frames received with a bad CRC and are between 64 +and 1536 bytes. +.It Va dev.cgem.%d.stats.rx_frames_length_errs +Counter of frames received that are shorter than that extracted +from the length field. +.It Va dev.cgem.%d.stats.rx_symbol_errs +Counter of receive symbol errors. +.It Va dev.cgem.%d.stats.rx_align_errs +Counter of received frames that are not an integral number of bytes. +.It Va dev.cgem.%d.stats.rx_resource_errs +Counter of frames successfully receive by the MAC but could not be +copied to memory because no receive buffer was available. +.It Va dev.cgem.%d.stats.rx_overrun_errs +Counter of frames that are address recognized but were not copied +to memory due to a receive overrun. +.It Va dev.cgem.%d.stats.rx_frames_ip_hdr_csum_errs +Counter of frames discarded due to an incorrect IP header checksum when +checksum offloading is enabled. +.It Va dev.cgem.%d.stats.rx_frames_tcp_csum_errs +Counter of frames discarded due to an incorrect TCP checksum when +checksum offloading is enabled. +.It Va dev.cgem.%d.stats.rx_frames_udp_csum_errs +Counter of frames discarded due to an incorrect UDP checksum when +checksum offloading is enabled. +.El +.Sh BUGS +The GEM can perform TCP/UDP/IP checksum offloading. +However, when transmit checksum offloading is enabled, the GEM generates and +replaces checksums for all packets it transmits. +In a system that is forwarding packets, the device could potentially correct +the checksum of packet that was corrupted in transit. +For this reason, checksum offloading is disabled by default but can be +enabled using ifconfig(8). +.Pp +When receive checksum offloading is enabled, the device will discard packets +with bad TCP/UDP/IP checksums. +The bad packets will not be counted in any +.Xr netstat 1 +statistics. There are +.Xr sysctl 8 +variables that count +packets discarded by the hardware (see below). +.Pp +The GEM used in the Zynq-7000 has a bug such that the receiver can +potentially freeze up under a high load. The issue is described in sec. 16.7 +"Known Issues" of the Zynq-7000 SoC Technical Reference Manual (Xilinx +UG585 v1.7). +The +.Nm +driver implements the work-around suggested in the manual. +If the bug does not exist in other versions of this device, the +work-around can be disabled by setting the dev.cgem.%d.rxhangwar +.Xr sysctl 8 +variable to 0. +.Pp +.Sh SEE ALSO +.Xr miibus 4 , +.Xr ifconfig 8 +.Rs +.%T "Zynq-7000 SoC Technical Reference Manual (Xilinx doc UG585)" +.%U http://www.xilinx.com/support/documentation/user_guides/\:ug585-Zynq-7000-TRM.pdf +.Re +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 10.0 . +.Sh AUTHORS +The +.Nm +driver and this manual page was written by +.An Thomas Skibo Aq Mt thomasskibo@yahoo.com . diff --git a/share/man/man4/miibus.4 b/share/man/man4/miibus.4 index 6152095fc3b8..a04e7a83f523 100644 --- a/share/man/man4/miibus.4 +++ b/share/man/man4/miibus.4 @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 15, 2011 +.Dd September 26, 2014 .Dt MIIBUS 4 .Os .Sh NAME @@ -103,6 +103,8 @@ Silicon Integrated Systems SiS190/191 Ethernet Silicon Integrated Systems SiS 900/SiS 7016 .It Xr sk 4 SysKonnect SK-984x and SK-982x Gigabit Ethernet +.It Xr smsc 4 +SMSC LAN9xxx USB Fast Ethernet .It Xr ste 4 Sundance ST201 (D-Link DFE-550TX) .It Xr stge 4 @@ -166,6 +168,7 @@ but as a result are not well behaved newbus device drivers. .Xr sge 4 , .Xr sis 4 , .Xr sk 4 , +.Xr smsc 4 , .Xr ste 4 , .Xr stge 4 , .Xr tl 4 , diff --git a/share/man/man4/sfxge.4 b/share/man/man4/sfxge.4 index 5e4935d465ee..7930fcf6e1e7 100644 --- a/share/man/man4/sfxge.4 +++ b/share/man/man4/sfxge.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd September 30, 2014 .Dt SFXGE 4 .Os .Sh NAME @@ -76,6 +76,39 @@ The .Nm driver supports all 10Gb Ethernet adapters based on Solarflare SFC9000 family controllers. +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +Actual values can be obtained using +.Xr sysctl 8 . +.Bl -tag -width indent +.It Va hw.sfxge.rx_ring +The maximum number of descriptors in a receive queue ring. +Supported values are: 512, 1024, 2048 and 4096. +.It Va hw.sfxge.tx_ring +The maximum number of descriptors in a transmit queue ring. +Supported values are: 512, 1024, 2048 and 4096. +.It Va hw.sfxge.tx_dpl_get_max +The maximum length of the deferred packet +.Dq get-list +for queued transmit +packets, used only if the transmit queue lock can be acquired. +If a packet is dropped, the +.Va tx_early_drops +counter is incremented and the local sender receives ENOBUFS. +The value must be greater than 0. +.It Va hw.sfxge.tx_dpl_put_max +The maximum length of the deferred packet +.Dq put-list +for queued transmit +packets, used if the transmit queue lock cannot be acquired. +If a packet is dropped, the +.Va tx_early_drops +counter is incremented and the local sender receives ENOBUFS. +The value must be greater than or equal to 0. +.El .Sh SUPPORT For general information and support, go to the Solarflare support website at: diff --git a/share/man/man4/smsc.4 b/share/man/man4/smsc.4 new file mode 100644 index 000000000000..fb375390632f --- /dev/null +++ b/share/man/man4/smsc.4 @@ -0,0 +1,91 @@ +.\" Copyright (c) 2014 Gavin Atkinson +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" - Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" - 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 COPYRIGHT HOLDERS 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 +.\" COPYRIGHT HOLDERS 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 September 26, 2014 +.Dt SMSC 4 +.Os +.Sh NAME +.Nm smsc +.Nd "USB SMSC LAN9xxx Fast Ethernet driver" +.Sh SYNOPSIS +To load the driver as a module at boot time, place the +following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_smsc_load="YES" +.Ed +.Pp +Alternatively, to compile this driver into the kernel, place the +following lines in your kernel configuration file: +.Bd -ragged -offset indent +.Cd "device uhci" +.Cd "device ohci" +.Cd "device usb" +.Cd "device miibus" +.Cd "device smsc" +.Ed +.Sh DESCRIPTION +The +.Nm +device driver provides support for USB Fast Ethernet adapters based +on the SMSC LAN9xxx chipsets. +.Pp +For more information on configuring this device, see +.Xr ifconfig 8 . +.Sh HARDWARE +The following devices are supported by the +.Nm +driver: +.Pp +.Bl -bullet -compact +.It +SMSC LAN9500, LAN9500A, LAN9505 and LAN9505A based Ethernet adapters +.It +SMSC LAN89530, LAN9530 and LAN9730 based Ethernet adapters +.It +SMSC LAN951x Ethernet adapters with integrated USB hub +.El +.Sh SEE ALSO +.Xr arp 4 , +.Xr intro 4 , +.Xr miibus 4 , +.Xr netintro 4 , +.Xr usb 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 10.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Ben Gray Aq Mt bgray@FreeBSD.org . diff --git a/share/man/man4/ucom.4 b/share/man/man4/ucom.4 index 9be029424322..a13d4d939b25 100644 --- a/share/man/man4/ucom.4 +++ b/share/man/man4/ucom.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 1, 2008 +.Dd October 3, 2014 .Dt UCOM 4 .Os .Sh NAME @@ -81,8 +81,10 @@ multiple external ports. .Xr umcs 4 , .Xr umct 4 , .Xr umodem 4 , +.Xr umoscom 4 , .Xr uplcom 4 , .Xr usb 4 , +.Xr uslcom 4 , .Xr uvisor 4 , .Xr uvscom 4 .Sh HISTORY diff --git a/share/man/man4/udplite.4 b/share/man/man4/udplite.4 index 5d06b1440984..859c9667629e 100644 --- a/share/man/man4/udplite.4 +++ b/share/man/man4/udplite.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 7, 2014 +.Dd October 1, 2014 .Dt UDPLITE 4 .Os .Sh NAME @@ -55,16 +55,16 @@ and tested with .Bl -tag -width ".Dv UDPLITE_SEND_CSCOV" .It Dv UDPLITE_SEND_CSCOV This option sets the sender checksum coverage. -A value of zero indicates that the entire packet -is covered by the checksum. -A value of 1 to 7 must be discarded by the receiver. +A value of zero indicates that all sent packets will have +full checksum coverage. +A value of 8 to 65535 limits the checksum coverage of all sent packets +to the value given. .It Dv UDPLITE_RECV_CSCOV This option is the receiver-side analogue. -It is truly optional, i.e. not required to enable traffic -with partial checksum coverage. -Its function is that of a traffic filter: -when enabled, it instructs the kernel to drop -all packets which have a coverage less than this value. +A value of zero instructs the kernel to drop all received packets +not having full checksum coverage. +A value of 8 to 65535 instructs the kernel to drop all received +packets with a partial checksum coverage smaller than the value specified. .El .Sh ERRORS A socket operation may fail with one of the following errors returned: diff --git a/share/man/man4/uled.4 b/share/man/man4/uled.4 index 28b8623daedb..16b24baaa04d 100644 --- a/share/man/man4/uled.4 +++ b/share/man/man4/uled.4 @@ -73,7 +73,6 @@ struct uled_color { uint8_t blue; }; .Ed -.Pp .It Dv ULED_SET_COLOR The command sets LED colors with values for RGB. It uses the same structure as above. diff --git a/share/man/man4/urndis.4 b/share/man/man4/urndis.4 index 9d126bd3fc77..ee367b7d5115 100644 --- a/share/man/man4/urndis.4 +++ b/share/man/man4/urndis.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 21, 2014 +.Dd October 2, 2014 .Dt URNDIS 4 .Os .Sh NAME @@ -68,8 +68,16 @@ such as those commonly found on Android devices. It does not support different media types or options. For more information on configuring this device, see .Xr ifconfig 8 . +.Sh HARDWARE +The +.Nm +driver supports the +.Qq tethering +functionality of many Android devices. .Sh SEE ALSO .Xr arp 4 , +.Xr cdce 4 , +.Xr ipheth 4 , .Xr netintro 4 , .Xr usb 4 , .Xr ifconfig 8 diff --git a/share/man/man4/urtwn.4 b/share/man/man4/urtwn.4 index d63d00c031cf..de4ef6dba0da 100644 --- a/share/man/man4/urtwn.4 +++ b/share/man/man4/urtwn.4 @@ -19,7 +19,7 @@ .Os .Sh NAME .Nm urtwn -.Nd Realtek RTL8188CU/RTL8188EU/RTL8192CU USB IEEE 802.11b/g/n wireless network device +.Nd Realtek RTL8188CU/RTL8188RU/RTL8188EU/RTL8192CU USB IEEE 802.11b/g/n wireless network device .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -82,10 +82,11 @@ firmware license .Sh HARDWARE The .Nm -driver supports Realtek RTL8188CU/RTL8188EU/RTL8192CU based USB +driver supports Realtek RTL8188CU/RTL8188RU/RTL8188EU/RTL8192CU based USB IEEE 802.11b/g/n wireless network adapters, including: .Pp .Bl -tag -width Ds -offset indent -compact +.It Alfa AWUS036NHR v2 .It ASUS USB-N10 NANO .It Belkin F7D1102 Surf Wireless Micro .It D-Link DWA-125 rev D1 diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 669e773bac64..47d9ef8e5520 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -1199,6 +1199,19 @@ or .Li inet6 2001:db8:1-f::1/64 . This notation allows address and prefix length part only, not the other address modifiers. +Note that the maximum number of the generated addresses from a range +specification is limited to an integer value specified in +.Va netif_ipexpand_max +in +.Xr rc.conf 5 +because a small typo can unexpectedly generate a large number of addresses. +The default value is +.Li 2048 . +It can be increased by adding the following line into +.Xr rc.conf 5 : +.Bd -literal +netif_ipexpand_max="4096" +.Ed .Pp In the case of .Li 192.0.2.5-23/24 , diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 2a20d7bad078..5997846cc330 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 255964 2013-10-01 07:22:04Z des .\" $FreeBSD$ -.Dd August 19, 2014 +.Dd September 12, 2014 .Dt SRC.CONF 5 .Os .Sh NAME @@ -522,6 +522,18 @@ Set to build Hesiod support. .It Va WITHOUT_HTML .\" from FreeBSD: head/tools/build/options/WITHOUT_HTML 156932 2006-03-21 07:50:50Z ru Set to not build HTML docs. +.It Va WITHOUT_HYPERV +.\" from FreeBSD: head/tools/build/options/WITHOUT_HYPERV 271493 2014-09-13 02:15:31Z delphij +Set to not build or install HyperV utilities. +.Pp +It is a default setting on +arm/arm, arm/armeb, arm/armv6, arm/armv6hf, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64. +.It Va WITH_HYPERV +.\" from FreeBSD: head/tools/build/options/WITH_HYPERV 271493 2014-09-13 02:15:31Z delphij +Set to build and install HyperV utilities. +.Pp +It is a default setting on +amd64/amd64, i386/i386 and pc98/i386. .It Va WITHOUT_ICONV .\" from FreeBSD: head/tools/build/options/WITHOUT_ICONV 254919 2013-08-26 17:15:56Z antoine Set to not build iconv as part of libc. @@ -926,10 +938,12 @@ This includes .Xr rsh 1 , etc. .It Va WITHOUT_RCS -.\" from FreeBSD: head/tools/build/options/WITHOUT_RCS 256198 2013-10-09 17:07:20Z gjb +.\" from FreeBSD: head/tools/build/options/WITHOUT_RCS 271401 2014-09-10 19:00:17Z asomers Set to not build .Xr rcs 1 -and related utilities. +, +.Xr etcupdate 8 +, and related utilities. .It Va WITHOUT_RESCUE .\" from FreeBSD: head/tools/build/options/WITHOUT_RESCUE 156932 2006-03-21 07:50:50Z ru Set to not build diff --git a/share/man/man7/release.7 b/share/man/man7/release.7 index 8fc75f3da4eb..93aec89618a9 100644 --- a/share/man/man7/release.7 +++ b/share/man/man7/release.7 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 11, 2014 +.Dd October 2, 2014 .Dt RELEASE 7 .Os .Sh NAME @@ -351,6 +351,61 @@ Set to the target directory within to check out .Va ${UBOOTSRC}/${UBOOTBRANCH} . .El +.Sh VIRTUAL MACHINE DISK IMAGES +The following +.Fa release.conf +variables are relevant only to virtual machine disk image builds: +.Bl -tag -width Ev +.It Va WITH_VMIMAGES +Set to a non-null value to build virtual machine disk images as part +of the release build. +.Va WITH_VMIMAGES +may also be specified as an envirionment variable passed to +.Xr make 1 . +.Pp +The option requires +.Xr mkimg 1 +version 20140927 or later. +.It Va WITH_COMPRESSED_VMIMAGES +Set to a non-null value to compress the virtual machine disk images with +.Xr xz 1 +as part of the +.Cm install +.Xr make 1 +target. +Note that compressing virtual machine disk images may take a very long +time on some systems. +.It Va VMBASE +Set to change the name of the resulting virtual machine disk image file. +The default value is +.Va vm . +.It Va VMSIZE +Set to change the size of the virtual machine disk capacity. +The default value is +.Va 20G . +See +.Xr truncate 1 +for valid values. +.Pp +Virtual machine disk images are, by default, created as sparse images. +When +.Va WITH_COMPRESSED_VMIMAGES +is used, the resulting files compressed with +.Xr xz 1 +compress to roughly the same size, regardless of the specified disk image +size. +.It Va VMFORMATS +Set to the target virtual disk image format(s) to create. +By default, the +.Va vhdf , Va vmdk , Va qcow2 , +and +.Va raw +formats are created. +See +.Xr mkimg 1 +for valid format values +.Pq requires version 20140927 or later . +.El .Sh MAKEFILE TARGETS The release makefile .Pq Pa src/release/Makefile @@ -407,6 +462,14 @@ Creates a directory named .Pa ftp containing the distribution files used in network installations and suitable for upload to an FTP mirror. +.It Cm vm-image +Creates virtual machine disk images in various formats. +The +.Cm vm-image +target requires the +.Va WITH_VMIMAGES +.Xr make 1 +envirionment variable to be set to a non-null value. .El .Pp Major subtargets called by targets above: diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index b6fcb80021d3..9e8297aa965f 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -391,13 +391,21 @@ MLINKS= unr.9 alloc_unr.9 \ unr.9 delete_unrhdr.9 \ unr.9 free_unr.9 \ unr.9 new_unrhdr.9 +MLINKS+=accept_filter.9 accept_filt_add.9 \ + accept_filter.9 accept_filt_del.9 \ + accept_filter.9 accept_filt_generic_mod_event.9 \ + accept_filter.9 accept_filt_get.9 MLINKS+=alq.9 ALQ.9 \ alq.9 alq_close.9 \ alq.9 alq_flush.9 \ alq.9 alq_get.9 \ + alq.9 alq_getn.9 \ alq.9 alq_open.9 \ + alq.9 alq_open_flags.9 \ alq.9 alq_post.9 \ - alq.9 alq_write.9 + alq.9 alq_post_flags.9 \ + alq.9 alq_write.9 \ + alq.9 alq_writen.9 MLINKS+=altq.9 ALTQ.9 MLINKS+=atomic.9 atomic_add.9 \ atomic.9 atomic_clear.9 \ @@ -407,7 +415,9 @@ MLINKS+=atomic.9 atomic_add.9 \ atomic.9 atomic_readandclear.9 \ atomic.9 atomic_set.9 \ atomic.9 atomic_store.9 \ - atomic.9 atomic_subtract.9 + atomic.9 atomic_subtract.9 \ + atomic.9 atomic_swap.9 \ + atomic.9 atomic_testandset.9 MLINKS+=bpf.9 bpfattach.9 \ bpf.9 bpfattach2.9 \ bpf.9 bpfdetach.9 \ @@ -435,6 +445,8 @@ MLINKS+=bus_dma.9 busdma.9 \ bus_dma.9 bus_dmamap_create.9 \ bus_dma.9 bus_dmamap_destroy.9 \ bus_dma.9 bus_dmamap_load.9 \ + bus_dma.9 bus_dmamap_load_bio.9 \ + bus_dma.9 bus_dmamap_load_ccb.9 \ bus_dma.9 bus_dmamap_load_mbuf.9 \ bus_dma.9 bus_dmamap_load_mbuf_sg.9 \ bus_dma.9 bus_dmamap_load_uio.9 \ @@ -449,7 +461,8 @@ MLINKS+=BUS_READ_IVAR.9 BUS_WRITE_IVAR.9 MLINKS+=BUS_SETUP_INTR.9 bus_setup_intr.9 \ BUS_SETUP_INTR.9 BUS_TEARDOWN_INTR.9 \ BUS_SETUP_INTR.9 bus_teardown_intr.9 -MLINKS+=bus_space.9 bus_space_barrier.9 \ +MLINKS+=bus_space.9 bus_space_alloc.9 \ + bus_space.9 bus_space_barrier.9 \ bus_space.9 bus_space_copy_region_1.9 \ bus_space.9 bus_space_copy_region_2.9 \ bus_space.9 bus_space_copy_region_4.9 \ @@ -560,6 +573,7 @@ MLINKS+=condvar.9 cv_broadcast.9 \ condvar.9 cv_signal.9 \ condvar.9 cv_timedwait.9 \ condvar.9 cv_timedwait_sig.9 \ + condvar.9 cv_timedwait_sig_sbt.9 \ condvar.9 cv_wait.9 \ condvar.9 cv_wait_sig.9 \ condvar.9 cv_wait_unlock.9 \ @@ -664,12 +678,21 @@ MLINKS+=eventtimers.9 et_register.9 \ eventtimers.9 ET_UNLOCK.9 \ eventtimers.9 et_start.9 \ eventtimers.9 et_stop.9 +MLINKS+=fail.9 KFAIL_POINT_CODE.9 \ + fail.9 KFAIL_POINT_ERROR.9 \ + fail.9 KFAIL_POINT_GOTO.9 \ + fail.9 KFAIL_POINT_RETURN.9 \ + fail.9 KFAIL_POINT_RETURN_VOID.9 MLINKS+=fetch.9 fubyte.9 \ fetch.9 fuswintr.9 \ fetch.9 fuword.9 \ fetch.9 fuword16.9 \ fetch.9 fuword32.9 \ fetch.9 fuword64.9 +MLINKS+=firmware.9 firmware_get.9 \ + firmware.9 firmware_put.9 \ + firmware.9 firmware_register.9 \ + firmware.9 firmware_unregister.9 MLINKS+=fpu_kern.9 fpu_kern_alloc_ctx.9 \ fpu_kern.9 fpu_kern_free_ctx.9 \ fpu_kern.9 fpu_kern_enter.9 \ @@ -677,8 +700,10 @@ MLINKS+=fpu_kern.9 fpu_kern_alloc_ctx.9 \ fpu_kern.9 fpu_kern_thread.9 \ fpu_kern.9 is_fpu_kern_thread.9 MLINKS+=g_attach.9 g_detach.9 -MLINKS+=g_bio.9 g_clone_bio.9 \ +MLINKS+=g_bio.9 g_alloc_bio.9 \ + g_bio.9 g_clone_bio.9 \ g_bio.9 g_destroy_bio.9 \ + g_bio.9 g_duplicate_bio.9 \ g_bio.9 g_new_bio.9 \ g_bio.9 g_print_bio.9 MLINKS+=g_consumer.9 g_destroy_consumer.9 \ @@ -692,7 +717,9 @@ MLINKS+=getenv.9 freeenv.9 \ getenv.9 getenv_quad.9 \ getenv.9 getenv_uint.9 \ getenv.9 getenv_ulong.9 \ - getenv.9 testenv.9 + getenv.9 setenv.9 \ + getenv.9 testenv.9 \ + getenv.9 unsetenv.9 MLINKS+=g_event.9 g_cancel_event.9 \ g_event.9 g_post_event.9 \ g_event.9 g_waitfor_event.9 @@ -706,13 +733,22 @@ MLINKS+=hash.9 hash32.9 \ hash.9 hash32_str.9 \ hash.9 hash32_stre.9 \ hash.9 hash32_strn.9 \ - hash.9 hash32_strne.9 + hash.9 hash32_strne.9 \ + hash.9 jenkins_hash.9 \ + hash.9 jenkins_hash32.9 MLINKS+=hashinit.9 hashdestroy.9 \ hashinit.9 hashinit_flags.9 \ hashinit.9 phashinit.9 +MLINKS+=hhook.9 hhook_head_register.9 \ + hhook.9 hhook_head_deregister.9 \ + hhook.9 hhook_head_deregister_lookup.9 \ + hhook.9 hhook_run_hooks.9 \ + hhook.9 HHOOKS_RUN_IF.9 \ + hhook.9 HHOOKS_RUN_LOOKUP_IF.9 MLINKS+=ieee80211.9 ieee80211_ifattach.9 \ ieee80211.9 ieee80211_ifdetach.9 -MLINKS+=ieee80211_amrr.9 ieee80211_amrr_cleanup.9 \ +MLINKS+=ieee80211_amrr.9 ieee80211_amrr_choose.9 \ + ieee80211_amrr.9 ieee80211_amrr_cleanup.9 \ ieee80211_amrr.9 ieee80211_amrr_init.9 \ ieee80211_amrr.9 ieee80211_amrr_node_init.9 \ ieee80211_amrr.9 ieee80211_amrr_setinterval.9 \ @@ -725,6 +761,7 @@ MLINKS+=ieee80211_bmiss.9 ieee80211_beacon_miss.9 MLINKS+=ieee80211_crypto.9 ieee80211_crypto_available.9 \ ieee80211_crypto.9 ieee80211_crypto_decap.9 \ ieee80211_crypto.9 ieee80211_crypto_delglobalkeys.9 \ + ieee80211_crypto.9 ieee80211_crypto_delkey.9 \ ieee80211_crypto.9 ieee80211_crypto_demic.9 \ ieee80211_crypto.9 ieee80211_crypto_encap.9 \ ieee80211_crypto.9 ieee80211_crypto_enmic.9 \ @@ -763,12 +800,55 @@ MLINKS+=ieee80211_radiotap.9 ieee80211_radiotap_active.9 \ MLINKS+=ieee80211_regdomain.9 ieee80211_alloc_countryie.9 \ ieee80211_regdomain.9 ieee80211_init_channels.9 \ ieee80211_regdomain.9 ieee80211_sort_channels.9 +MLINKS+=ieee80211_scan.9 ieee80211_add_scan.9 \ + ieee80211_scan.9 ieee80211_bg_scan.9 \ + ieee80211_scan.9 ieee80211_cancel_scan.9 \ + ieee80211_scan.9 ieee80211_cancel_scan_any.9 \ + ieee80211_scan.9 ieee80211_check_scan.9 \ + ieee80211_scan.9 ieee80211_check_scan_current.9 \ + ieee80211_scan.9 ieee80211_flush.9 \ + ieee80211_scan.9 ieee80211_probe_curchan.9 \ + ieee80211_scan.9 ieee80211_scan_assoc_fail.9 \ + ieee80211_scan.9 ieee80211_scan_done.9 \ + ieee80211_scan.9 ieee80211_scan_dump_channels.9 \ + ieee80211_scan.9 ieee80211_scan_flush.9 \ + ieee80211_scan.9 ieee80211_scan_iterate.9 \ + ieee80211_scan.9 ieee80211_scan_next.9 \ + ieee80211_scan.9 ieee80211_scan_timeout.9 \ + ieee80211_scan.9 ieee80211_scanner_get.9 \ + ieee80211_scan.9 ieee80211_scanner_register.9 \ + ieee80211_scan.9 ieee80211_scanner_unregister.9 \ + ieee80211_scan.9 ieee80211_scanner_unregister_all.9 \ + ieee80211_scan.9 ieee80211_start_scan.9 MLINKS+=ieee80211_vap.9 ieee80211_vap_attach.9 \ ieee80211_vap.9 ieee80211_vap_detach.9 \ ieee80211_vap.9 ieee80211_vap_setup.9 -MLINKS+=ifnet.9 ifaddr.9 \ +MLINKS+=ifnet.9 if_addmulti.9 \ + ifnet.9 if_alloc.9 \ + ifnet.9 if_allmulti.9 \ + ifnet.9 if_attach.9 \ ifnet.9 if_data.9 \ - ifnet.9 ifqueue.9 + ifnet.9 IF_DEQUEUE.9 \ + ifnet.9 if_delmulti.9 \ + ifnet.9 if_detach.9 \ + ifnet.9 if_down.9 \ + ifnet.9 if_findmulti.9 \ + ifnet.9 if_free.9 \ + ifnet.9 if_free_type.9 \ + ifnet.9 if_up.9 \ + ifnet.9 ifa_free.9 \ + ifnet.9 ifa_ifwithaddr.9 \ + ifnet.9 ifa_ifwithdstaddr.9 \ + ifnet.9 ifa_ifwithnet.9 \ + ifnet.9 ifa_ref.9 \ + ifnet.9 ifaddr.9 \ + ifnet.9 ifaddr_byindex.9 \ + ifnet.9 ifaof_ifpforaddr.9 \ + ifnet.9 ifioctl.9 \ + ifnet.9 ifpromisc.9 \ + ifnet.9 ifqueue.9 \ + ifnet.9 ifunit.9 \ + ifnet.9 ifunit_ref.9 MLINKS+=insmntque.9 insmntque1.9 MLINKS+=ithread.9 ithread_add_handler.9 \ ithread.9 ithread_create.9 \ @@ -783,6 +863,14 @@ MLINKS+=kernel_mount.9 free_mntarg.9 \ kernel_mount.9 mount_argb.9 \ kernel_mount.9 mount_argf.9 \ kernel_mount.9 mount_argsu.9 +MLINKS+=khelp.9 khelp_add_hhook.9 \ + khelp.9 KHELP_DECLARE_MOD.9 \ + khelp.9 KHELP_DECLARE_MOD_UMA.9 \ + khelp.9 khelp_destroy_osd.9 \ + khelp.9 khelp_get_id.9 \ + khelp.9 khelp_get_osd.9 \ + khelp.9 khelp_init_osd.9 \ + khelp.9 khelp_remove_hhook.9 MLINKS+=kobj.9 DEFINE_CLASS.9 \ kobj.9 kobj_class_compile.9 \ kobj.9 kobj_class_compile_static.9 \ @@ -793,6 +881,7 @@ MLINKS+=kobj.9 DEFINE_CLASS.9 \ kobj.9 kobj_init_static.9 MLINKS+=kproc.9 kproc_create.9 \ kproc.9 kproc_exit.9 \ + kproc.9 kproc_kthread_add.9 \ kproc.9 kproc_resume.9 \ kproc.9 kproc_shutdown.9 \ kproc.9 kproc_start.9 \ @@ -827,7 +916,8 @@ MLINKS+=ktr.9 CTR0.9 \ ktr.9 CTR2.9 \ ktr.9 CTR3.9 \ ktr.9 CTR4.9 \ - ktr.9 CTR5.9 + ktr.9 CTR5.9 \ + ktr.9 CTR6.9 MLINKS+=lock.9 lockdestroy.9 \ lock.9 lockinit.9 \ lock.9 lockmgr.9 \ @@ -884,6 +974,7 @@ MLINKS+=mbpool.9 mbp_alloc.9 \ mbpool.9 mbp_sync.9 MLINKS+=\ mbuf.9 m_adj.9 \ + mbuf.9 m_align.9 \ mbuf.9 M_ALIGN.9 \ mbuf.9 m_append.9 \ mbuf.9 m_apply.9 \ @@ -894,6 +985,7 @@ MLINKS+=\ mbuf.9 m_copydata.9 \ mbuf.9 m_copym.9 \ mbuf.9 m_copypacket.9 \ + mbuf.9 m_copyup.9 \ mbuf.9 m_defrag.9 \ mbuf.9 m_devget.9 \ mbuf.9 m_dup.9 \ @@ -1009,9 +1101,38 @@ MLINKS+=mutex.9 mtx_assert.9 \ MLINKS+=namei.9 NDFREE.9 \ namei.9 NDHASGIANT.9 \ namei.9 NDINIT.9 +MLINKS+=netisr.9 netisr_clearqdrops.9 \ + netisr.9 netisr_default_flow2cpu.9 \ + netisr.9 netisr_dispatch.9 \ + netisr.9 netisr_dispatch_src.9 \ + netisr.9 netisr_get_cpucount.9 \ + netisr.9 netisr_get_cpuid.9 \ + netisr.9 netisr_getqdrops.9 \ + netisr.9 netisr_getqlimit.9 \ + netisr.9 netisr_queue.9 \ + netisr.9 netisr_queue_src.9 \ + netisr.9 netisr_register.9 \ + netisr.9 netisr_setqlimit.9 \ + netisr.9 netisr_unregister.9 +MLINKS+=osd.9 osd_call.9 \ + osd.9 osd_del.9 \ + osd.9 osd_deregister.9 \ + osd.9 osd_exit.9 \ + osd.9 osd_get.9 \ + osd.9 osd_register.9 \ + osd.9 osd_set.9 MLINKS+=pbuf.9 getpbuf.9 \ pbuf.9 relpbuf.9 \ pbuf.9 trypbuf.9 +MLINKS+=PCBGROUP.9 in_pcbgroup_byhash.9 \ + PCBGROUP.9 in_pcbgroup_byinpcb.9 \ + PCBGROUP.9 in_pcbgroup_destroy.9 \ + PCBGROUP.9 in_pcbgroup_enabled.9 \ + PCBGROUP.9 in_pcbgroup_init.9 \ + PCBGROUP.9 in_pcbgroup_remove.9 \ + PCBGROUP.9 in_pcbgroup_update.9 \ + PCBGROUP.9 in_pcbgroup_update_mbuf.9 \ + PCBGROUP.9 in6_pcbgroup_byhash.9 MLINKS+=pci.9 pci_alloc_msi.9 \ pci.9 pci_alloc_msix.9 \ pci.9 pci_disable_busmaster.9 \ @@ -1040,8 +1161,15 @@ MLINKS+=pci.9 pci_alloc_msi.9 \ pci.9 pci_set_max_read_req.9 \ pci.9 pci_write_config.9 MLINKS+=pfil.9 pfil_add_hook.9 \ + pfil.9 pfil_head_register.9 \ + pfil.9 pfil_head_unregister.9 \ pfil.9 pfil_hook_get.9 \ - pfil.9 pfil_remove_hook.9 + pfil.9 pfil_remove_hook.9 \ + pfil.9 pfil_rlock.9 \ + pfil.9 pfil_run_hooks.9 \ + pfil.9 pfil_runlock.9 \ + pfil.9 pfil_wlock.9 \ + pfil.9 pfil_wunlock.9 MLINKS+=pfind.9 zpfind.9 MLINKS+=pmap_copy.9 pmap_copy_page.9 MLINKS+=pmap_extract.9 pmap_extract_and_hold.9 @@ -1114,6 +1242,11 @@ MLINKS+=rmlock.9 rm_assert.9 \ rmlock.9 rm_wunlock.9 MLINKS+=rtalloc.9 rtalloc1.9 \ rtalloc.9 rtalloc_ign.9 \ + rtalloc.9 RT_ADDREF.9 \ + rtalloc.9 RT_LOCK.9 \ + rtalloc.9 RT_REMREF.9 \ + rtalloc.9 RT_RTFREE.9 \ + rtalloc.9 RT_UNLOCK.9 \ rtalloc.9 RTFREE_LOCKED.9 \ rtalloc.9 RTFREE.9 \ rtalloc.9 rtfree.9 \ @@ -1128,6 +1261,7 @@ MLINKS+=rwlock.9 rw_assert.9 \ rwlock.9 rw_destroy.9 \ rwlock.9 rw_downgrade.9 \ rwlock.9 rw_init.9 \ + rwlock.9 rw_init_flags.9 \ rwlock.9 rw_initialized.9 \ rwlock.9 rw_rlock.9 \ rwlock.9 rw_runlock.9 \ @@ -1165,6 +1299,7 @@ MLINKS+=sbuf.9 sbuf_bcat.9 \ sbuf.9 sbuf_vprintf.9 MLINKS+=scheduler.9 curpriority_cmp.9 \ scheduler.9 maybe_resched.9 \ + scheduler.9 propagate_priority.9 \ scheduler.9 resetpriority.9 \ scheduler.9 roundrobin.9 \ scheduler.9 roundrobin_interval.9 \ @@ -1253,17 +1388,18 @@ MLINKS+=sleepqueue.9 init_sleepqueues.9 \ sleepqueue.9 sleepq_add.9 \ sleepqueue.9 sleepq_alloc.9 \ sleepqueue.9 sleepq_broadcast.9 \ - sleepqueue.9 sleepq_calc_signal_retval.9 \ - sleepqueue.9 sleepq_catch_signals.9 \ sleepqueue.9 sleepq_free.9 \ sleepqueue.9 sleepq_lookup.9 \ + sleepqueue.9 sleepq_lock.9 \ sleepqueue.9 sleepq_release.9 \ sleepqueue.9 sleepq_remove.9 \ sleepqueue.9 sleepq_set_timeout.9 \ sleepqueue.9 sleepq_set_timeout_sbt.9 \ sleepqueue.9 sleepq_signal.9 \ + sleepqueue.9 sleepq_sleepcnt.9 \ sleepqueue.9 sleepq_timedwait.9 \ sleepqueue.9 sleepq_timedwait_sig.9 \ + sleepqueue.9 sleepq_type.9 \ sleepqueue.9 sleepq_wait.9 \ sleepqueue.9 sleepq_wait_sig.9 MLINKS+=socket.9 soabort.9 \ @@ -1318,6 +1454,8 @@ MLINKS+=stack.9 stack_copy.9 \ stack.9 stack_destroy.9 \ stack.9 stack_print.9 \ stack.9 stack_print_ddb.9 \ + stack.9 stack_print_short.9 \ + stack.9 stack_print_short_ddb.9 \ stack.9 stack_put.9 \ stack.9 stack_save.9 \ stack.9 stack_sbuf_print.9 \ @@ -1339,6 +1477,7 @@ MLINKS+=sx.9 sx_assert.9 \ sx.9 sx_init_flags.9 \ sx.9 sx_sleep.9 \ sx.9 sx_slock.9 \ + sx.9 sx_slock_sig.9 \ sx.9 sx_sunlock.9 \ sx.9 SX_SYSINIT.9 \ sx.9 sx_try_slock.9 \ @@ -1347,6 +1486,7 @@ MLINKS+=sx.9 sx_assert.9 \ sx.9 sx_unlock.9 \ sx.9 sx_xholder.9 \ sx.9 sx_xlock.9 \ + sx.9 sx_xlock_sig.9 \ sx.9 sx_xlocked.9 \ sx.9 sx_xunlock.9 MLINKS+=sysctl.9 SYSCTL_DECL.9 \ @@ -1390,6 +1530,7 @@ MLINKS+=taskqueue.9 TASK_INIT.9 \ taskqueue.9 TASK_INITIALIZER.9 \ taskqueue.9 taskqueue_block.9 \ taskqueue.9 taskqueue_cancel.9 \ + taskqueue.9 taskqueue_cancel_timeout.9 \ taskqueue.9 taskqueue_create.9 \ taskqueue.9 taskqueue_create_fast.9 \ taskqueue.9 TASKQUEUE_DECLARE.9 \ @@ -1397,14 +1538,20 @@ MLINKS+=taskqueue.9 TASK_INIT.9 \ taskqueue.9 TASKQUEUE_DEFINE_THREAD.9 \ taskqueue.9 taskqueue_drain.9 \ taskqueue.9 taskqueue_drain_all.9 \ + taskqueue.9 taskqueue_drain_timeout.9 \ taskqueue.9 taskqueue_enqueue.9 \ taskqueue.9 taskqueue_enqueue_fast.9 \ + taskqueue.9 taskqueue_enqueue_timeout.9 \ taskqueue.9 TASKQUEUE_FAST_DEFINE.9 \ taskqueue.9 TASKQUEUE_FAST_DEFINE_THREAD.9 \ taskqueue.9 taskqueue_free.9 \ taskqueue.9 taskqueue_member.9 \ taskqueue.9 taskqueue_run.9 \ - taskqueue.9 taskqueue_unblock.9 + taskqueue.9 taskqueue_set_callback.9 \ + taskqueue.9 taskqueue_start_threads.9 \ + taskqueue.9 taskqueue_start_threads_pinned.9 \ + taskqueue.9 taskqueue_unblock.9 \ + taskqueue.9 TIMEOUT_TASK_INIT.9 MLINKS+=time.9 boottime.9 \ time.9 time_second.9 \ time.9 time_uptime.9 @@ -1415,20 +1562,27 @@ MLINKS+=timeout.9 callout.9 \ timeout.9 callout_handle_init.9 \ timeout.9 callout_init.9 \ timeout.9 callout_init_mtx.9 \ + timeout.9 callout_init_rm.9 \ timeout.9 callout_init_rw.9 \ timeout.9 callout_pending.9 \ timeout.9 callout_reset.9 \ + timeout.9 callout_reset_curcpu.9 \ timeout.9 callout_reset_sbt.9 \ timeout.9 callout_reset_on.9 \ timeout.9 callout_reset_sbt_on.9 \ timeout.9 callout_schedule.9 \ + timeout.9 callout_schedule_curcpu.9 \ + timeout.9 callout_schedule_on.9 \ timeout.9 callout_stop.9 \ timeout.9 untimeout.9 -MLINKS+=ucred.9 crcopy.9 \ +MLINKS+=ucred.9 cred_update_thread.9 \ + ucred.9 crcopy.9 \ + ucred.9 crcopysafe.9 \ ucred.9 crdup.9 \ ucred.9 crfree.9 \ ucred.9 crget.9 \ ucred.9 crhold.9 \ + ucred.9 crsetgroups.9 \ ucred.9 crshared.9 \ ucred.9 cru2x.9 MLINKS+=uidinfo.9 uifind.9 \ @@ -1575,6 +1729,7 @@ MLINKS+=vrele.9 vput.9 \ vrele.9 vunref.9 MLINKS+=vslock.9 vsunlock.9 MLINKS+=zone.9 uma.9 \ + zone.9 uma_find_refcnt.9 \ zone.9 uma_zalloc.9 \ zone.9 uma_zalloc_arg.9 \ zone.9 uma_zcreate.9 \ @@ -1583,6 +1738,7 @@ MLINKS+=zone.9 uma.9 \ zone.9 uma_zfree_arg.9 \ zone.9 uma_zone_get_cur.9 \ zone.9 uma_zone_get_max.9 \ - zone.9 uma_zone_set_max.9 + zone.9 uma_zone_set_max.9 \ + zone.9 uma_zone_set_warning.9 .include diff --git a/share/man/man9/SDT.9 b/share/man/man9/SDT.9 index 91bf4b1caf70..c65b82402ba6 100644 --- a/share/man/man9/SDT.9 +++ b/share/man/man9/SDT.9 @@ -24,13 +24,15 @@ .\" .\" $FreeBSD$ .\" -.Dd August 17, 2013 +.Dd September 18, 2014 .Dt SDT 9 .Os .Sh NAME .Nm SDT .Nd a DTrace framework for adding statically-defined tracing probes .Sh SYNOPSIS +.In sys/param.h +.In sys/queue.h .In sys/sdt.h .Fn SDT_PROVIDER_DECLARE prov .Fn SDT_PROVIDER_DEFINE prov diff --git a/share/man/man9/VOP_GETPAGES.9 b/share/man/man9/VOP_GETPAGES.9 index 7869d45474cd..2cc5b7acff10 100644 --- a/share/man/man9/VOP_GETPAGES.9 +++ b/share/man/man9/VOP_GETPAGES.9 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 27, 2003 +.Dd September 12, 2014 .Dt VOP_GETPAGES 9 .Os .Sh NAME @@ -41,9 +41,9 @@ .In sys/vnode.h .In vm/vm.h .Ft int -.Fn VOP_GETPAGES "struct vnode *vp" "vm_page_t *ma" "int count" "int reqpage" "vm_ooffset_t offset" +.Fn VOP_GETPAGES "struct vnode *vp" "vm_page_t *ma" "int count" "int reqpage" .Ft int -.Fn VOP_PUTPAGES "struct vnode *vp" "vm_page_t *ma" "int count" "int sync" "int *rtvals" "vm_ooffset_t offset" +.Fn VOP_PUTPAGES "struct vnode *vp" "vm_page_t *ma" "int count" "int sync" "int *rtvals" .Sh DESCRIPTION The .Fn VOP_GETPAGES @@ -81,8 +81,6 @@ page written by .It Fa reqpage The index in the page array of the requested page; i.e., the one page which the implementation of this method must handle. -.It Fa offset -Offset in the file at which the mapped pages begin. .El .Pp The status of the @@ -156,7 +154,7 @@ is .Sh SEE ALSO .Xr vm_object_pip_wakeup 9 , .Xr vm_page_free 9 , -.Xr vm_pagge_sunbusy 9 , +.Xr vm_page_sunbusy 9 , .Xr vm_page_undirty 9 , .Xr vm_page_xunbusy 9 , .Xr vnode 9 diff --git a/share/man/man9/altq.9 b/share/man/man9/altq.9 index fd9440420a98..e718027a5107 100644 --- a/share/man/man9/altq.9 +++ b/share/man/man9/altq.9 @@ -256,7 +256,6 @@ still work with struct mbuf *ifq_tail; | struct mbuf *ifq_tail; int ifq_len; | int ifq_len; int ifq_maxlen; | int ifq_maxlen; - int ifq_drops; | int ifq_drops; }; | /* driver queue fields */ | ...... | /* altq related fields */ diff --git a/share/man/man9/ifnet.9 b/share/man/man9/ifnet.9 index ae210726e792..7aef4def5176 100644 --- a/share/man/man9/ifnet.9 +++ b/share/man/man9/ifnet.9 @@ -77,9 +77,9 @@ .Ft "struct ifaddr *" .Fn ifa_ifwithaddr "struct sockaddr *addr" .Ft "struct ifaddr *" -.Fn ifa_ifwithdstaddr "struct sockaddr *addr" +.Fn ifa_ifwithdstaddr "struct sockaddr *addr" "int fib" .Ft "struct ifaddr *" -.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp" +.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp" "int fib" .Ft "struct ifaddr *" .Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp" .Ft void @@ -1389,7 +1389,16 @@ returns an interface address for a point-to-point interface whose remote .Pq Dq destination address is -.Fa addr . +.Fa addr +and a fib is +.Fa fib . +If +.Fa fib +is +.Dv RT_ALL_FIBS , +then the first interface address matching +.Fa addr +will be returned. .Pp .Fn ifa_ifwithnet returns the most specific interface address which matches the @@ -1401,7 +1410,10 @@ address whose remote address is if one is found. If .Fa ignore_ptp -is true, skip point-to-point interface addresses. +is true, skip point-to-point interface addresses. The +.Fa fib +parameter is handled the same way as by +.Fn ifa_ifwithdstaddr . .Pp .Fn ifaof_ifpforaddr returns the most specific address configured on interface diff --git a/share/man/man9/sleepqueue.9 b/share/man/man9/sleepqueue.9 index 8557b9f3e8e7..7f6269b95ed9 100644 --- a/share/man/man9/sleepqueue.9 +++ b/share/man/man9/sleepqueue.9 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 19, 2013 +.Dd September 22, 2014 .Dt SLEEPQUEUE 9 .Os .Sh NAME @@ -32,8 +32,6 @@ .Nm sleepq_add , .Nm sleepq_alloc , .Nm sleepq_broadcast , -.Nm sleepq_calc_signal_retval , -.Nm sleepq_catch_signals , .Nm sleepq_free , .Nm sleepq_lock , .Nm sleepq_lookup , @@ -62,10 +60,6 @@ .Fn sleepq_alloc "void" .Ft int .Fn sleepq_broadcast "void *wchan" "int flags" "int pri" "int queue" -.Ft int -.Fn sleepq_calc_signal_retval "int sig" -.Ft int -.Fn sleepq_catch_signals "void *wchan" .Ft void .Fn sleepq_free "struct sleepqueue *sq" .Ft struct sleepqueue * @@ -86,15 +80,15 @@ .Ft u_int .Fn sleepq_sleepcnt "void *wchan" "int queue" .Ft int -.Fn sleepq_timedwait "void *wchan" +.Fn sleepq_timedwait "void *wchan" "int pri" .Ft int -.Fn sleepq_timedwait_sig "void *wchan" "int signal_caught" +.Fn sleepq_timedwait_sig "void *wchan" "int pri" .Ft int .Fn sleepq_type "void *wchan" .Ft void -.Fn sleepq_wait "void *wchan" +.Fn sleepq_wait "void *wchan" "int pri" .Ft int -.Fn sleepq_wait_sig "void *wchan" +.Fn sleepq_wait_sig "void *wchan" "int pri" .Sh DESCRIPTION Sleep queues provide a mechanism for suspending execution of a thread until some condition is met. @@ -252,17 +246,6 @@ allows to pass additional .Fn callout_reset_sbt flags. .Pp -The current thread may be marked interruptible by calling -.Fn sleepq_catch_signals -with -.Fa wchan -set to the wait channel. -This function returns a signal number if there are any pending signals for -the current thread and 0 if there is not a pending signal. -The sleep queue chain associated with argument -.Fa wchan -should have been locked by a prior call to -.Fn sleepq_lock . .Pp Once the thread is ready to suspend, one of the wait functions is called to put the current thread to sleep @@ -289,12 +272,9 @@ The sleep queue chain associated with argument needs to have been locked with a prior call to .Fn sleepq_lock . The -.Fa signal_caught -parameter to -.Fn sleepq_timedwait_sig -specifies if a previous call to -.Fn sleepq_catch_signals -found a pending signal. +.Fa pri +argument is used to set the priority of the thread when it is awakened. +If it is set to zero, the thread's priority is left alone. .Pp When the thread is resumed, the wait functions return a non-zero value if the thread was awakened due to @@ -304,20 +284,6 @@ If the sleep timed out, then is returned. If the sleep was interrupted by something other than a signal, then some other return value will be returned. -If zero is returned after resuming from an interruptible sleep, -then -.Fn sleepq_calc_signal_retval -should be called to determine if the sleep was interrupted by a signal. -If so, -.Fn sleepq_calc_signal_retval -returns -.Er ERESTART -if the interrupting signal is restartable and -.Er EINTR -otherwise. -If the sleep was not interrupted by a signal, -.Fn sleepq_calc_signal_retval -will return 0. .Pp A sleeping thread is normally resumed by the .Fn sleepq_broadcast diff --git a/share/man/man9/sysctl.9 b/share/man/man9/sysctl.9 index 8bc92e49bf57..e645046b34e6 100644 --- a/share/man/man9/sysctl.9 +++ b/share/man/man9/sysctl.9 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 31, 2014 +.Dd September 15, 2014 .Dt SYSCTL 9 .Os .Sh NAME @@ -105,7 +105,7 @@ .Fa "void *ptr" .Fa "intptr_t len" .Fa "const char *format" -.Fa "const char *descr +.Fa "const char *descr" .Fc .Ft struct sysctl_oid * .Fo SYSCTL_ADD_PROC @@ -504,49 +504,8 @@ The initial sysctl value is tried fetched once from the system enviroment early during module load or system boot. .It Dv CTLFLAG_DYN Dynamically created OIDs automatically get this flag set. -.El -.Sh SECURITY CONSIDERATIONS -When creating new sysctls, careful attention should be paid to the security -implications of the monitoring or management interface being created. -Most sysctls present in the kernel are read-only or writable only by the -superuser. -Sysctls exporting extensive information on system data structures and -operation, especially those implemented using procedures, will wish to -implement access control to limit the undesired exposure of information about -other processes, network connections, etc. -.Pp -The following top level sysctl name spaces are commonly used: -.Bl -tag -width ".Va regression" -.It Va compat -Compatibility layer information. -.It Va debug -Debugging information. -Various name spaces exist under -.Va debug . -.It Va hw -Hardware and device driver information. -.It Va kern -Kernel behavior tuning; generally deprecated in favor of more specific -name spaces. -.It Va machdep -Machine-dependent configuration parameters. -.It Va net -Network subsystem. -Various protocols have name spaces under -.Va net . -.It Va regression -Regression test configuration and information. -.It Va security -Security and security-policy configuration and information. -.It Va sysctl -Reserved name space for the implementation of sysctl. -.It Va user -Configuration settings relating to user application behavior. -Generally, configuring applications using kernel sysctls is discouraged. -.It Va vfs -Virtual file system configuration and information. -.It Va vm -Virtual memory subsystem configuration and information. +.It Dv CTLFLAG_VNET +OID references a VIMAGE-enabled variable. .El .Sh EXAMPLES Sample use of @@ -702,3 +661,46 @@ addition of MIB nodes. .Pp This man page was written by .An Robert N. M. Watson . +.Sh SECURITY CONSIDERATIONS +When creating new sysctls, careful attention should be paid to the security +implications of the monitoring or management interface being created. +Most sysctls present in the kernel are read-only or writable only by the +superuser. +Sysctls exporting extensive information on system data structures and +operation, especially those implemented using procedures, will wish to +implement access control to limit the undesired exposure of information about +other processes, network connections, etc. +.Pp +The following top level sysctl name spaces are commonly used: +.Bl -tag -width ".Va regression" +.It Va compat +Compatibility layer information. +.It Va debug +Debugging information. +Various name spaces exist under +.Va debug . +.It Va hw +Hardware and device driver information. +.It Va kern +Kernel behavior tuning; generally deprecated in favor of more specific +name spaces. +.It Va machdep +Machine-dependent configuration parameters. +.It Va net +Network subsystem. +Various protocols have name spaces under +.Va net . +.It Va regression +Regression test configuration and information. +.It Va security +Security and security-policy configuration and information. +.It Va sysctl +Reserved name space for the implementation of sysctl. +.It Va user +Configuration settings relating to user application behavior. +Generally, configuring applications using kernel sysctls is discouraged. +.It Va vfs +Virtual file system configuration and information. +.It Va vm +Virtual memory subsystem configuration and information. +.El diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot index 100a0ce656c1..07d6aa7ad229 100644 --- a/share/misc/committers-src.dot +++ b/share/misc/committers-src.dot @@ -179,6 +179,7 @@ ivoras [label="Ivan Voras\nivoras@FreeBSD.org\n2008/06/10"] jamie [label="Jamie Gritton\njamie@FreeBSD.org\n2009/01/28"] jasone [label="Jason Evans\njasone@FreeBSD.org\n1999/03/03"] jceel [label="Jakub Klama\njceel@FreeBSD.org\n2011/09/25"] +jch [label="Julien Charbon\njch@FreeBSD.org\n2014/09/24"] jchandra [label="Jayachandran C.\njchandra@FreeBSD.org\n2010/05/19"] jeff [label="Jeff Roberson\njeff@FreeBSD.org\n2002/02/21"] jh [label="Jaakko Heinonen\njh@FreeBSD.org\n2009/10/02"] @@ -484,6 +485,7 @@ jdp -> fjoe jhb -> arr jhb -> avg +jhb -> jch jhb -> jeff jhb -> kbyanc jhb -> peterj diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index 509c17f5823e..afc8ecb5c392 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -123,8 +123,8 @@ ${_YC:R}.o: ${_YC} # DTrace probe definitions # libelf is currently needed for drti.o .if ${SRCS:M*.d} -LDFLAGS+= -lelf -LDADD+= ${LIBELF} +LDADD+= -lelf +DPADD+= ${LIBELF} CFLAGS+= -I${.OBJDIR} .endif .for _DSRC in ${SRCS:M*.d:N*/*} @@ -215,8 +215,10 @@ cleandepend: .endif .if !target(checkdpadd) && (defined(DPADD) || defined(LDADD)) -_LDADD_FROM_DPADD= ${DPADD:C;^/usr/lib/lib(.*)\.a$;-l\1;} -_LDADD_CANONICALIZED= ${LDADD:S/$//} +_LDADD_FROM_DPADD= ${DPADD:R:T:C;^lib(.*)$;-l\1;g} +# Ignore -Wl,--start-group/-Wl,--end-group as it might be required in the +# LDADD list due to unresolved symbols +_LDADD_CANONICALIZED= ${LDADD:N:R:T:C;^lib(.*)$;-l\1;g:N-Wl,--[es]*-group} checkdpadd: .if ${_LDADD_FROM_DPADD} != ${_LDADD_CANONICALIZED} @echo ${.CURDIR} diff --git a/share/mk/bsd.endian.mk b/share/mk/bsd.endian.mk index 565d1aa04790..c82c37f6945a 100644 --- a/share/mk/bsd.endian.mk +++ b/share/mk/bsd.endian.mk @@ -2,16 +2,13 @@ .if ${MACHINE_ARCH} == "amd64" || \ ${MACHINE_ARCH} == "i386" || \ - ${MACHINE_ARCH} == "arm" || \ - ${MACHINE_ARCH} == "armv6" || \ - ${MACHINE_ARCH} == "armv6hf" || \ + (${MACHINE} == "arm" && ${MACHINE_ARCH:Marm*eb*} == "") || \ ${MACHINE_ARCH:Mmips*el} != "" TARGET_ENDIANNESS= 1234 .elif ${MACHINE_ARCH} == "powerpc" || \ ${MACHINE_ARCH} == "powerpc64" || \ ${MACHINE_ARCH} == "sparc64" || \ - ${MACHINE_ARCH} == "armeb" || \ - ${MACHINE_ARCH} == "armv6eb" || \ + (${MACHINE} == "arm" && ${MACHINE_ARCH:Marm*eb*} != "") || \ ${MACHINE_ARCH:Mmips*} != "" TARGET_ENDIANNESS= 4321 .endif diff --git a/share/mk/bsd.port.mk b/share/mk/bsd.port.mk index 87e49352f95d..4f73d12a926d 100644 --- a/share/mk/bsd.port.mk +++ b/share/mk/bsd.port.mk @@ -1,6 +1,18 @@ # $FreeBSD$ -PORTSDIR?= /usr/ports +.if !defined(PORTSDIR) +# Autodetect if the command is being run in a ports tree that's not rooted +# in the default /usr/ports. The ../../.. case is in case ports ever grows +# a third level. +.for RELPATH in . .. ../.. ../../.. +.if !defined(_PORTSDIR) && exists(${.CURDIR}/${RELPATH}/Mk/bsd.port.mk) +_PORTSDIR= ${.CURDIR}/${RELPATH} +.endif +.endfor +_PORTSDIR?= /usr/ports +PORTSDIR!= realpath ${_PORTSDIR} +.endif + BSDPORTMK?= ${PORTSDIR}/Mk/bsd.port.mk # Needed to keep bsd.own.mk from reading in /etc/src.conf diff --git a/share/mk/bsd.port.subdir.mk b/share/mk/bsd.port.subdir.mk index 51156023efff..8e608a127aa7 100644 --- a/share/mk/bsd.port.subdir.mk +++ b/share/mk/bsd.port.subdir.mk @@ -1,6 +1,18 @@ # $FreeBSD$ -PORTSDIR?= /usr/ports +.if !defined(PORTSDIR) +# Autodetect if the command is being run in a ports tree that's not rooted +# in the default /usr/ports. The ../../.. case is in case ports ever grows +# a third level. +.for RELPATH in . .. ../.. ../../.. +.if !defined(_PORTSDIR) && exists(${.CURDIR}/${RELPATH}/Mk/bsd.port.mk) +_PORTSDIR= ${.CURDIR}/${RELPATH} +.endif +.endfor +_PORTSDIR?= /usr/ports +PORTSDIR!= realpath ${_PORTSDIR} +.endif + BSDPORTSUBDIRMK?= ${PORTSDIR}/Mk/bsd.port.subdir.mk .include "${BSDPORTSUBDIRMK}" diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk index c5e8c3d85adc..5ca1e458026f 100644 --- a/share/mk/bsd.progs.mk +++ b/share/mk/bsd.progs.mk @@ -42,10 +42,15 @@ PROG ?= $t .if defined(PROG) # just one of many -PROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS +PROG_OVERRIDE_VARS += BINDIR MAN SRCS +PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD ${PROG_OVERRIDE_VARS} .for v in ${PROG_VARS:O:u} -.if defined(${v}.${PROG}) || defined(${v}_${PROG}) -$v += ${${v}_${PROG}:U${${v}.${PROG}}} +.if empty(${PROG_OVERRIDE_VARS:M$v}) +.if defined(${v}.${PROG}) +$v += ${${v}.${PROG}} +.elif defined(${v}_${PROG}) +$v += ${${v}_${PROG}} +.endif .else $v ?= .endif @@ -61,7 +66,7 @@ UPDATE_DEPENDFILE ?= NO DEPENDFILE?= .depend.${PROG} # prog.mk will do the rest .else -all: ${PROGS} +all: ${FILES} ${PROGS} ${SCRIPTS} # We cannot capture dependencies for meta mode here UPDATE_DEPENDFILE = NO @@ -75,7 +80,7 @@ UPDATE_DEPENDFILE = NO .ifndef _RECURSING_PROGS # tell progs.mk we might want to install things -PROGS_TARGETS+= cleandepend cleandir cleanobj depend install +PROGS_TARGETS+= checkdpadd clean cleandepend cleandir cleanobj depend install .for p in ${PROGS} .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) @@ -98,18 +103,15 @@ $p.$t: .PHONY .MAKE $t: ${PROGS:%=%.$t} .endfor -SCRIPTS_TARGETS+= cleandepend cleandir cleanobj depend install +.if empty(PROGS) && !empty(SCRIPTS) -.for p in ${SCRIPTS} -.for t in ${SCRIPTS_TARGETS:O:u} -$p.$t: .PHONY .MAKE - (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \ - SUBDIR= SCRIPT=$p ${x.$p} ${@:E}) -.endfor -.endfor - -.for t in ${SCRIPTS_TARGETS:O:u} -$t: ${SCRIPTS:%=%.$t} +.for t in ${PROGS_TARGETS:O:u} +scripts.$t: .PHONY .MAKE + (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} SUBDIR= _RECURSING_PROGS= \ + $t) +$t: scripts.$t .endfor .endif + +.endif diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index a4f3e25ce5cc..a852d3d7cee2 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -48,7 +48,6 @@ __DEFAULT_YES_OPTIONS = \ ACPI \ AMD \ APM \ - ARM_EABI \ AT \ ATM \ AUDIT \ @@ -194,7 +193,7 @@ __TT=${MACHINE} # Clang is only for x86, powerpc and little-endian arm right now, by default. .if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*} __DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL CLANG_BOOTSTRAP -.elif ${__T} == "arm" || ${__T} == "armv6" || ${__T} == "armv6hf" +.elif ${__TT} == "arm" && ${__T:Marm*eb*} == "" __DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP # GCC is unable to build the full clang on arm, disable it by default. __DEFAULT_NO_OPTIONS+=CLANG_FULL @@ -202,8 +201,8 @@ __DEFAULT_NO_OPTIONS+=CLANG_FULL __DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL CLANG_BOOTSTRAP .endif # Clang the default system compiler only on little-endian arm and x86. -.if ${__T} == "amd64" || ${__T} == "arm" || ${__T} == "armv6" || \ - ${__T} == "armv6hf" || ${__T} == "i386" +.if ${__T} == "amd64" || (${__TT} == "arm" && ${__T:Marm*eb*} == "") || \ + ${__T} == "i386" __DEFAULT_YES_OPTIONS+=CLANG_IS_CC __DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX .else @@ -212,6 +211,13 @@ __DEFAULT_NO_OPTIONS+=CLANG_IS_CC CLANG CLANG_BOOTSTRAP __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX .endif +# HyperV is only available for x86 and amd64. +.if ${__T} == "amd64" || ${__T} == "i386" +__DEFAULT_YES_OPTIONS+=HYPERV +.else +__DEFAULT_NO_OPTIONS+=HYPERV +.endif + .include # diff --git a/share/vt/keymaps/Makefile b/share/vt/keymaps/Makefile index 4e0b64c5e1e3..762cb17d8f41 100644 --- a/share/vt/keymaps/Makefile +++ b/share/vt/keymaps/Makefile @@ -31,8 +31,10 @@ FILES= INDEX.keymaps \ es.dvorak.kbd \ es.kbd \ fi.kbd \ + fr.acc.kbd \ fr.dvorak.acc.kbd \ fr.dvorak.kbd \ + fr.kbd \ fr.macbook.kbd \ gr.101.acc.kbd \ gr.elot.acc.kbd \ diff --git a/sys/Makefile b/sys/Makefile index dc1d5e984327..46d883e1e74d 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -5,7 +5,7 @@ CSCOPEDIRS= boot bsm cam cddl compat conf contrib crypto ddb dev fs gdb \ geom gnu isa kern libkern modules net net80211 \ netgraph netinet netinet6 netipsec netnatm netpfil \ netsmb nfs nfsclient nfsserver nlm ofed opencrypto \ - pci rpc security sys ufs vm xdr xen ${CSCOPE_ARCHDIR} + rpc security sys ufs vm xdr xen ${CSCOPE_ARCHDIR} .if !defined(CSCOPE_ARCHDIR) .if defined(ALL_ARCH) CSCOPE_ARCHDIR = amd64 arm i386 mips pc98 powerpc sparc64 x86 diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S index 7c37a41054ec..eb0ee8b5fdd5 100644 --- a/sys/amd64/amd64/cpu_switch.S +++ b/sys/amd64/amd64/cpu_switch.S @@ -399,10 +399,6 @@ ENTRY(savectx) rdmsr movl %eax,PCB_SFMASK(%rdi) movl %edx,PCB_SFMASK+4(%rdi) - movl xsave_mask,%eax - movl %eax,PCB_XSMASK(%rdi) - movl xsave_mask+4,%eax - movl %eax,PCB_XSMASK+4(%rdi) sgdt PCB_GDT(%rdi) sidt PCB_IDT(%rdi) @@ -467,12 +463,9 @@ ENTRY(resumectx) movl PCB_SFMASK(%rdi),%eax wrmsr - /* Restore CR0 except for FPU mode. */ + /* Restore CR0, CR2, CR4 and CR3. */ movq PCB_CR0(%rdi),%rax - andq $~(CR0_EM | CR0_TS),%rax movq %rax,%cr0 - - /* Restore CR2, CR4 and CR3. */ movq PCB_CR2(%rdi),%rax movq %rax,%cr2 movq PCB_CR4(%rdi),%rax @@ -510,26 +503,6 @@ ENTRY(resumectx) movq PCB_DR7(%rdi),%rax movq %rax,%dr7 - /* Restore FPU state. */ - fninit - movq PCB_FPUSUSPEND(%rdi),%rbx - movq PCB_XSMASK(%rdi),%rax - testq %rax,%rax - jz 1f - movq %rax,%rdx - shrq $32,%rdx - movl $XCR0,%ecx - xsetbv - xrstor (%rbx) - jmp 2f -1: - fxrstor (%rbx) -2: - - /* Reload CR0. */ - movq PCB_CR0(%rdi),%rax - movq %rax,%cr0 - /* Restore other callee saved registers. */ movq PCB_R15(%rdi),%r15 movq PCB_R14(%rdi),%r14 diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 0f4b2b52aeef..5c61859fd902 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -173,6 +173,20 @@ fpususpend(void *addr) load_cr0(cr0); } +void +fpuresume(void *addr) +{ + u_long cr0; + + cr0 = rcr0(); + stop_emulating(); + fninit(); + if (use_xsave) + load_xcr(XCR0, xsave_mask); + fpurestore(addr); + load_cr0(cr0); +} + /* * Enable XSAVE if supported and allowed by user. * Calculate the xsave_mask. @@ -348,7 +362,7 @@ fpuexit(struct thread *td) stop_emulating(); fpusave(curpcb->pcb_save); start_emulating(); - PCPU_SET(fpcurthread, 0); + PCPU_SET(fpcurthread, NULL); } critical_exit(); } @@ -589,33 +603,37 @@ fputrap_sse(void) } /* - * Implement device not available (DNA) exception + * Device Not Available (DNA, #NM) exception handler. * - * It would be better to switch FP context here (if curthread != fpcurthread) - * and not necessarily for every context switch, but it is too hard to - * access foreign pcb's. + * It would be better to switch FP context here (if curthread != + * fpcurthread) and not necessarily for every context switch, but it + * is too hard to access foreign pcb's. */ - -static int err_count = 0; - void fpudna(void) { + /* + * This handler is entered with interrupts enabled, so context + * switches may occur before critical_enter() is executed. If + * a context switch occurs, then when we regain control, our + * state will have been completely restored. The CPU may + * change underneath us, but the only part of our context that + * lives in the CPU is CR0.TS and that will be "restored" by + * setting it on the new CPU. + */ critical_enter(); + if (PCPU_GET(fpcurthread) == curthread) { - printf("fpudna: fpcurthread == curthread %d times\n", - ++err_count); + printf("fpudna: fpcurthread == curthread\n"); stop_emulating(); critical_exit(); return; } if (PCPU_GET(fpcurthread) != NULL) { - printf("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", - PCPU_GET(fpcurthread), - PCPU_GET(fpcurthread)->td_proc->p_pid, - curthread, curthread->td_proc->p_pid); - panic("fpudna"); + panic("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", + PCPU_GET(fpcurthread), PCPU_GET(fpcurthread)->td_tid, + curthread, curthread->td_tid); } stop_emulating(); /* diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index ff1f28287b88..c4b1c2878497 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -163,8 +163,6 @@ ASSYM(PCB_STAR, offsetof(struct pcb, pcb_star)); ASSYM(PCB_LSTAR, offsetof(struct pcb, pcb_lstar)); ASSYM(PCB_CSTAR, offsetof(struct pcb, pcb_cstar)); ASSYM(PCB_SFMASK, offsetof(struct pcb, pcb_sfmask)); -ASSYM(PCB_XSMASK, offsetof(struct pcb, pcb_xsmask)); -ASSYM(PCB_FPUSUSPEND, offsetof(struct pcb, pcb_fpususpend)); ASSYM(PCB_SIZE, sizeof(struct pcb)); ASSYM(PCB_FULL_IRET, PCB_FULL_IRET); ASSYM(PCB_DBREGS, PCB_DBREGS); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index afd008688ae4..ab827718d764 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -177,6 +177,7 @@ struct init_ops init_ops = { .mp_bootaddress = mp_bootaddress, .start_all_aps = native_start_all_aps, #endif + .msi_init = msi_init, }; /* @@ -184,9 +185,6 @@ struct init_ops init_ops = { * the physical address at which the kernel is loaded. */ extern char kernphys[]; -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif struct msgbuf *msgbufp; @@ -1823,6 +1821,10 @@ static caddr_t native_parse_preload_data(u_int64_t modulep) { caddr_t kmdp; +#ifdef DDB + vm_offset_t ksym_start; + vm_offset_t ksym_end; +#endif preload_metadata = (caddr_t)(uintptr_t)(modulep + KERNBASE); preload_bootstrap_relocate(KERNBASE); @@ -1834,6 +1836,7 @@ native_parse_preload_data(u_int64_t modulep) #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); + db_fetch_ksymtab(ksym_start, ksym_end); #endif return (kmdp); @@ -2124,6 +2127,26 @@ smap_sysctl_handler(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_machdep, OID_AUTO, smap, CTLTYPE_OPAQUE|CTLFLAG_RD, NULL, 0, smap_sysctl_handler, "S,bios_smap_xattr", "Raw BIOS SMAP data"); +static int +efi_map_sysctl_handler(SYSCTL_HANDLER_ARGS) +{ + struct efi_map_header *efihdr; + caddr_t kmdp; + uint32_t efisize; + + kmdp = preload_search_by_type("elf kernel"); + if (kmdp == NULL) + kmdp = preload_search_by_type("elf64 kernel"); + efihdr = (struct efi_map_header *)preload_search_info(kmdp, + MODINFO_METADATA | MODINFOMD_EFI_MAP); + if (efihdr == NULL) + return (0); + efisize = *((uint32_t *)efihdr - 1); + return (SYSCTL_OUT(req, efihdr, efisize)); +} +SYSCTL_PROC(_machdep, OID_AUTO, efi_map, CTLTYPE_OPAQUE|CTLFLAG_RD, NULL, 0, + efi_map_sysctl_handler, "S,efi_map_header", "Raw EFI Memory Map"); + void spinlock_enter(void) { diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 9b12449ef196..3184f1325374 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -102,7 +102,7 @@ char *nmi_stack; void *dpcpu; struct pcb stoppcbs[MAXCPU]; -struct pcb **susppcbs; +struct susppcb **susppcbs; /* Variables needed for SMP tlb shootdown. */ vm_offset_t smp_tlb_addr2; @@ -721,7 +721,7 @@ init_secondary(void) /* set up CPU registers and state */ cpu_setregs(); - /* set up SSE/NX registers */ + /* set up SSE/NX */ initializecpu(); /* set up FPU state on the AP */ @@ -1461,11 +1461,12 @@ cpususpend_handler(void) mtx_assert(&smp_ipi_mtx, MA_NOTOWNED); cpu = PCPU_GET(cpuid); - if (savectx(susppcbs[cpu])) { - fpususpend(susppcbs[cpu]->pcb_fpususpend); + if (savectx(&susppcbs[cpu]->sp_pcb)) { + fpususpend(susppcbs[cpu]->sp_fpususpend); wbinvd(); CPU_SET_ATOMIC(cpu, &suspended_cpus); } else { + fpuresume(susppcbs[cpu]->sp_fpususpend); pmap_init_pat(); initializecpu(); PCPU_SET(switchtime, 0); diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index f0ea75c18a5b..3344b35c281c 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -3845,7 +3845,8 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) pt_entry_t *pte, PG_G, PG_M, PG_RW, PG_V; boolean_t anychanged, pv_lists_locked; - if ((prot & VM_PROT_READ) == VM_PROT_NONE) { + KASSERT((prot & ~VM_PROT_ALL) == 0, ("invalid prot %x", prot)); + if (prot == VM_PROT_NONE) { pmap_remove(pmap, sva, eva); return; } diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index f6459f48cf81..4880c9135520 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -436,8 +436,8 @@ trap(struct trapframe *frame) case T_XMMFLT: /* SIMD floating-point exception */ case T_FPOPFLT: /* FPU operand fetch fault */ /* - * XXXKIB for now disable any FPU traps in kernel - * handler registration seems to be overkill + * For now, supporting kernel handler + * registration for FPU traps is overkill. */ trap_fatal(frame, 0); goto out; diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 698f510113d4..cf4fb46747ee 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -216,6 +216,8 @@ device de # DEC/Intel DC21x4x (``Tulip'') device em # Intel PRO/1000 Gigabit Ethernet Family device igb # Intel PRO/1000 PCIE Server Gigabit Family device ixgbe # Intel PRO/10GbE PCIE Ethernet Family +device ixl # Intel XL710 40Gbe PCIE Ethernet +device ixlv # Intel XL710 40Gbe VF PCIE Ethernet device le # AMD Am7900 LANCE and Am79C9xx PCnet device ti # Alteon Networks Tigon I/II gigabit Ethernet device txp # 3Com 3cR990 (``Typhoon'') diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 1262af3b87f4..a946c0587703 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -310,6 +310,8 @@ options DRM_DEBUG # Include debug printfs (slow) # iwn: Intel Wireless WiFi Link 1000/105/135/2000/4965/5000/6000/6050 abgn # 802.11 network adapters # Requires the iwn firmware module +# ixl: Intel XL710 40Gbe PCIE Ethernet +# ixlv: Intel XL710 40Gbe VF PCIE Ethernet # mlx4ib: Mellanox ConnectX HCA InfiniBand # mlxen: Mellanox ConnectX HCA Ethernet # mthca: Mellanox HCA InfiniBand @@ -327,6 +329,8 @@ options ED_SIC device ipw # Intel 2100 wireless NICs. device iwi # Intel 2200BG/2225BG/2915ABG wireless NICs. device iwn # Intel 4965/1000/5000/6000 wireless NICs. +device ixl # Intel XL710 40Gbe PCIE Ethernet +device ixlv # Intel XL710 40Gbe VF PCIE Ethernet device mlx4ib # Mellanox ConnectX HCA InfiniBand device mlxen # Mellanox ConnectX HCA Ethernet device mthca # Mellanox HCA InfiniBand diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h index be1bdc6c5d7f..78d2fee2714d 100644 --- a/sys/amd64/include/fpu.h +++ b/sys/amd64/include/fpu.h @@ -58,6 +58,7 @@ int fpuformat(void); int fpugetregs(struct thread *td); void fpuinit(void); void fpurestore(void *addr); +void fpuresume(void *addr); void fpusave(void *addr); int fpusetregs(struct thread *td, struct savefpu *addr, char *xfpustate, size_t xfpustate_size); diff --git a/sys/amd64/include/pcb.h b/sys/amd64/include/pcb.h index 80aff86eb685..153393ffc15b 100644 --- a/sys/amd64/include/pcb.h +++ b/sys/amd64/include/pcb.h @@ -97,14 +97,18 @@ struct pcb { register_t pcb_lstar; register_t pcb_cstar; register_t pcb_sfmask; - register_t pcb_xsmask; - - /* fpu context for suspend/resume */ - void *pcb_fpususpend; struct savefpu *pcb_save; - uint64_t pcb_pad[3]; + uint64_t pcb_pad[5]; +}; + +/* Per-CPU state saved during suspend and resume. */ +struct susppcb { + struct pcb sp_pcb; + + /* fpu context for suspend/resume */ + void *sp_fpususpend; }; #endif diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h index 58af2a5abfe3..b0d451d3b7f2 100644 --- a/sys/amd64/include/vmm.h +++ b/sys/amd64/include/vmm.h @@ -82,6 +82,7 @@ enum vm_reg_name { VM_REG_GUEST_PDPTE1, VM_REG_GUEST_PDPTE2, VM_REG_GUEST_PDPTE3, + VM_REG_GUEST_INTR_SHADOW, VM_REG_LAST }; @@ -194,7 +195,6 @@ void vm_nmi_clear(struct vm *vm, int vcpuid); int vm_inject_extint(struct vm *vm, int vcpu); int vm_extint_pending(struct vm *vm, int vcpuid); void vm_extint_clear(struct vm *vm, int vcpuid); -uint64_t *vm_guest_msrs(struct vm *vm, int cpu); struct vlapic *vm_lapic(struct vm *vm, int cpu); struct vioapic *vm_ioapic(struct vm *vm); struct vhpet *vm_hpet(struct vm *vm); diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 7b52a64cf0eb..39c17c8d2135 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -61,6 +61,11 @@ MALLOC_DECLARE(M_LINUX); #define PTRIN(v) (void *)(uintptr_t)(v) #define PTROUT(v) (l_uintptr_t)(uintptr_t)(v) +#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0) +#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0) +#define PTRIN_CP(src,dst,fld) \ + do { (dst).fld = PTRIN((src).fld); } while (0) + /* * Provide a separate set of types for the Linux types. */ diff --git a/sys/amd64/linux32/linux32_dummy.c b/sys/amd64/linux32/linux32_dummy.c index 411c4d556fc4..ecf516830811 100644 --- a/sys/amd64/linux32/linux32_dummy.c +++ b/sys/amd64/linux32/linux32_dummy.c @@ -73,11 +73,6 @@ DUMMY(epoll_create); DUMMY(epoll_ctl); DUMMY(epoll_wait); DUMMY(remap_file_pages); -DUMMY(timer_create); -DUMMY(timer_settime); -DUMMY(timer_gettime); -DUMMY(timer_getoverrun); -DUMMY(timer_delete); DUMMY(fstatfs64); DUMMY(mbind); DUMMY(get_mempolicy); diff --git a/sys/amd64/linux32/linux32_proto.h b/sys/amd64/linux32/linux32_proto.h index 6bd0dffc5f57..8260a6cc278c 100644 --- a/sys/amd64/linux32/linux32_proto.h +++ b/sys/amd64/linux32/linux32_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 271743 2014-09-18 08:36:45Z bz */ #ifndef _LINUX_SYSPROTO_H_ @@ -781,19 +781,25 @@ struct linux_set_tid_address_args { char tidptr_l_[PADL_(int *)]; int * tidptr; char tidptr_r_[PADR_(int *)]; }; struct linux_timer_create_args { - register_t dummy; + char clock_id_l_[PADL_(clockid_t)]; clockid_t clock_id; char clock_id_r_[PADR_(clockid_t)]; + char evp_l_[PADL_(struct sigevent *)]; struct sigevent * evp; char evp_r_[PADR_(struct sigevent *)]; + char timerid_l_[PADL_(l_timer_t *)]; l_timer_t * timerid; char timerid_r_[PADR_(l_timer_t *)]; }; struct linux_timer_settime_args { - register_t dummy; + char timerid_l_[PADL_(l_timer_t)]; l_timer_t timerid; char timerid_r_[PADR_(l_timer_t)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; + char new_l_[PADL_(const struct itimerspec *)]; const struct itimerspec * new; char new_r_[PADR_(const struct itimerspec *)]; + char old_l_[PADL_(struct itimerspec *)]; struct itimerspec * old; char old_r_[PADR_(struct itimerspec *)]; }; struct linux_timer_gettime_args { - register_t dummy; + char timerid_l_[PADL_(l_timer_t)]; l_timer_t timerid; char timerid_r_[PADR_(l_timer_t)]; + char setting_l_[PADL_(struct itimerspec *)]; struct itimerspec * setting; char setting_r_[PADR_(struct itimerspec *)]; }; struct linux_timer_getoverrun_args { - register_t dummy; + char timerid_l_[PADL_(l_timer_t)]; l_timer_t timerid; char timerid_r_[PADR_(l_timer_t)]; }; struct linux_timer_delete_args { - register_t dummy; + char timerid_l_[PADL_(l_timer_t)]; l_timer_t timerid; char timerid_r_[PADR_(l_timer_t)]; }; struct linux_clock_settime_args { char which_l_[PADL_(clockid_t)]; clockid_t which; char which_r_[PADR_(clockid_t)]; diff --git a/sys/amd64/linux32/linux32_syscall.h b/sys/amd64/linux32/linux32_syscall.h index 31455fee7d98..8056a9f520d9 100644 --- a/sys/amd64/linux32/linux32_syscall.h +++ b/sys/amd64/linux32/linux32_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 271743 2014-09-18 08:36:45Z bz */ #define LINUX_SYS_exit 1 diff --git a/sys/amd64/linux32/linux32_syscalls.c b/sys/amd64/linux32/linux32_syscalls.c index 0d1e092e7cf9..002a0e540ecd 100644 --- a/sys/amd64/linux32/linux32_syscalls.c +++ b/sys/amd64/linux32/linux32_syscalls.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 271743 2014-09-18 08:36:45Z bz */ const char *linux_syscallnames[] = { diff --git a/sys/amd64/linux32/linux32_sysent.c b/sys/amd64/linux32/linux32_sysent.c index bdcbf13564aa..717161137be3 100644 --- a/sys/amd64/linux32/linux32_sysent.c +++ b/sys/amd64/linux32/linux32_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 271743 2014-09-18 08:36:45Z bz */ #include "opt_compat.h" @@ -278,11 +278,11 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_epoll_wait, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 256 = linux_epoll_wait */ { 0, (sy_call_t *)linux_remap_file_pages, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 257 = linux_remap_file_pages */ { AS(linux_set_tid_address_args), (sy_call_t *)linux_set_tid_address, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 258 = linux_set_tid_address */ - { 0, (sy_call_t *)linux_timer_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 259 = linux_timer_create */ - { 0, (sy_call_t *)linux_timer_settime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 260 = linux_timer_settime */ - { 0, (sy_call_t *)linux_timer_gettime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 261 = linux_timer_gettime */ - { 0, (sy_call_t *)linux_timer_getoverrun, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 262 = linux_timer_getoverrun */ - { 0, (sy_call_t *)linux_timer_delete, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 263 = linux_timer_delete */ + { AS(linux_timer_create_args), (sy_call_t *)linux_timer_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 259 = linux_timer_create */ + { AS(linux_timer_settime_args), (sy_call_t *)linux_timer_settime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 260 = linux_timer_settime */ + { AS(linux_timer_gettime_args), (sy_call_t *)linux_timer_gettime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 261 = linux_timer_gettime */ + { AS(linux_timer_getoverrun_args), (sy_call_t *)linux_timer_getoverrun, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 262 = linux_timer_getoverrun */ + { AS(linux_timer_delete_args), (sy_call_t *)linux_timer_delete, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 263 = linux_timer_delete */ { AS(linux_clock_settime_args), (sy_call_t *)linux_clock_settime, AUE_CLOCK_SETTIME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 264 = linux_clock_settime */ { AS(linux_clock_gettime_args), (sy_call_t *)linux_clock_gettime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 265 = linux_clock_gettime */ { AS(linux_clock_getres_args), (sy_call_t *)linux_clock_getres, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 266 = linux_clock_getres */ diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c index 0b020a7350ef..dcaeb7d1c254 100644 --- a/sys/amd64/linux32/linux32_systrace_args.c +++ b/sys/amd64/linux32/linux32_systrace_args.c @@ -1720,27 +1720,43 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_timer_create */ case 259: { - *n_args = 0; + struct linux_timer_create_args *p = params; + iarg[0] = p->clock_id; /* clockid_t */ + uarg[1] = (intptr_t) p->evp; /* struct sigevent * */ + uarg[2] = (intptr_t) p->timerid; /* l_timer_t * */ + *n_args = 3; break; } /* linux_timer_settime */ case 260: { - *n_args = 0; + struct linux_timer_settime_args *p = params; + iarg[0] = p->timerid; /* l_timer_t */ + iarg[1] = p->flags; /* l_int */ + uarg[2] = (intptr_t) p->new; /* const struct itimerspec * */ + uarg[3] = (intptr_t) p->old; /* struct itimerspec * */ + *n_args = 4; break; } /* linux_timer_gettime */ case 261: { - *n_args = 0; + struct linux_timer_gettime_args *p = params; + iarg[0] = p->timerid; /* l_timer_t */ + uarg[1] = (intptr_t) p->setting; /* struct itimerspec * */ + *n_args = 2; break; } /* linux_timer_getoverrun */ case 262: { - *n_args = 0; + struct linux_timer_getoverrun_args *p = params; + iarg[0] = p->timerid; /* l_timer_t */ + *n_args = 1; break; } /* linux_timer_delete */ case 263: { - *n_args = 0; + struct linux_timer_delete_args *p = params; + iarg[0] = p->timerid; /* l_timer_t */ + *n_args = 1; break; } /* linux_clock_settime */ @@ -4829,18 +4845,71 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_timer_create */ case 259: + switch(ndx) { + case 0: + p = "clockid_t"; + break; + case 1: + p = "struct sigevent *"; + break; + case 2: + p = "l_timer_t *"; + break; + default: + break; + }; break; /* linux_timer_settime */ case 260: + switch(ndx) { + case 0: + p = "l_timer_t"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "const struct itimerspec *"; + break; + case 3: + p = "struct itimerspec *"; + break; + default: + break; + }; break; /* linux_timer_gettime */ case 261: + switch(ndx) { + case 0: + p = "l_timer_t"; + break; + case 1: + p = "struct itimerspec *"; + break; + default: + break; + }; break; /* linux_timer_getoverrun */ case 262: + switch(ndx) { + case 0: + p = "l_timer_t"; + break; + default: + break; + }; break; /* linux_timer_delete */ case 263: + switch(ndx) { + case 0: + p = "l_timer_t"; + break; + default: + break; + }; break; /* linux_clock_settime */ case 264: @@ -6413,14 +6482,29 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_timer_create */ case 259: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_timer_settime */ case 260: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_timer_gettime */ case 261: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_timer_getoverrun */ case 262: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_timer_delete */ case 263: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_clock_settime */ case 264: if (ndx == 0 || ndx == 1) diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index c3a10afeb0a3..00002a40d447 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -435,11 +435,13 @@ 256 AUE_NULL STD { int linux_epoll_wait(void); } 257 AUE_NULL STD { int linux_remap_file_pages(void); } 258 AUE_NULL STD { int linux_set_tid_address(int *tidptr); } -259 AUE_NULL STD { int linux_timer_create(void); } -260 AUE_NULL STD { int linux_timer_settime(void); } -261 AUE_NULL STD { int linux_timer_gettime(void); } -262 AUE_NULL STD { int linux_timer_getoverrun(void); } -263 AUE_NULL STD { int linux_timer_delete(void); } +259 AUE_NULL STD { int linux_timer_create(clockid_t clock_id, \ + struct sigevent *evp, l_timer_t *timerid); } +260 AUE_NULL STD { int linux_timer_settime(l_timer_t timerid, l_int flags, \ + const struct itimerspec *new, struct itimerspec *old); } +261 AUE_NULL STD { int linux_timer_gettime(l_timer_t timerid, struct itimerspec *setting); } +262 AUE_NULL STD { int linux_timer_getoverrun(l_timer_t timerid); } +263 AUE_NULL STD { int linux_timer_delete(l_timer_t timerid); } 264 AUE_CLOCK_SETTIME STD { int linux_clock_settime(clockid_t which, struct l_timespec *tp); } 265 AUE_NULL STD { int linux_clock_gettime(clockid_t which, struct l_timespec *tp); } 266 AUE_NULL STD { int linux_clock_getres(clockid_t which, struct l_timespec *tp); } diff --git a/sys/amd64/vmm/intel/ept.c b/sys/amd64/vmm/intel/ept.c index 5f6c4d017916..13c9788842ef 100644 --- a/sys/amd64/vmm/intel/ept.c +++ b/sys/amd64/vmm/intel/ept.c @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include "vmx_cpufunc.h" #include "vmm_ipi.h" -#include "vmx_msr.h" #include "ept.h" #define EPT_SUPPORTS_EXEC_ONLY(cap) ((cap) & (1UL << 0)) diff --git a/sys/amd64/vmm/intel/vmcs.h b/sys/amd64/vmm/intel/vmcs.h index 4e9557c39b9b..6122de581fac 100644 --- a/sys/amd64/vmm/intel/vmcs.h +++ b/sys/amd64/vmm/intel/vmcs.h @@ -54,6 +54,10 @@ int vmcs_getdesc(struct vmcs *vmcs, int running, int ident, int vmcs_setdesc(struct vmcs *vmcs, int running, int ident, struct seg_desc *desc); +/* + * Avoid header pollution caused by inline use of 'vtophys()' in vmx_cpufunc.h + */ +#ifdef _VMX_CPUFUNC_H_ static __inline uint64_t vmcs_read(uint32_t encoding) { @@ -73,6 +77,7 @@ vmcs_write(uint32_t encoding, uint64_t val) error = vmwrite(encoding, val); KASSERT(error == 0, ("vmcs_write(%u) error %d", encoding, error)); } +#endif /* _VMX_CPUFUNC_H_ */ #define vmexit_instruction_length() vmcs_read(VMCS_EXIT_INSTRUCTION_LENGTH) #define vmcs_guest_rip() vmcs_read(VMCS_GUEST_RIP) diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index b2c570216a78..00c85d734961 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -52,20 +52,20 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "vmm_lapic.h" #include "vmm_host.h" #include "vmm_ioport.h" #include "vmm_ipi.h" -#include "vmm_msr.h" #include "vmm_ktr.h" #include "vmm_stat.h" #include "vatpic.h" #include "vlapic.h" #include "vlapic_priv.h" -#include "vmx_msr.h" #include "ept.h" #include "vmx_cpufunc.h" #include "vmx.h" +#include "vmx_msr.h" #include "x86.h" #include "vmx_controls.h" @@ -94,34 +94,23 @@ __FBSDID("$FreeBSD$"); #define PROCBASED_CTLS2_ONE_SETTING PROCBASED2_ENABLE_EPT #define PROCBASED_CTLS2_ZERO_SETTING 0 -#define VM_EXIT_CTLS_ONE_SETTING_NO_PAT \ +#define VM_EXIT_CTLS_ONE_SETTING \ (VM_EXIT_HOST_LMA | \ VM_EXIT_SAVE_EFER | \ - VM_EXIT_LOAD_EFER) - -#define VM_EXIT_CTLS_ONE_SETTING \ - (VM_EXIT_CTLS_ONE_SETTING_NO_PAT | \ + VM_EXIT_LOAD_EFER | \ VM_EXIT_ACKNOWLEDGE_INTERRUPT | \ VM_EXIT_SAVE_PAT | \ VM_EXIT_LOAD_PAT) + #define VM_EXIT_CTLS_ZERO_SETTING VM_EXIT_SAVE_DEBUG_CONTROLS -#define VM_ENTRY_CTLS_ONE_SETTING_NO_PAT VM_ENTRY_LOAD_EFER +#define VM_ENTRY_CTLS_ONE_SETTING (VM_ENTRY_LOAD_EFER | VM_ENTRY_LOAD_PAT) -#define VM_ENTRY_CTLS_ONE_SETTING \ - (VM_ENTRY_CTLS_ONE_SETTING_NO_PAT | \ - VM_ENTRY_LOAD_PAT) #define VM_ENTRY_CTLS_ZERO_SETTING \ (VM_ENTRY_LOAD_DEBUG_CONTROLS | \ VM_ENTRY_INTO_SMM | \ VM_ENTRY_DEACTIVATE_DUAL_MONITOR) -#define guest_msr_rw(vmx, msr) \ - msr_bitmap_change_access((vmx)->msr_bitmap, (msr), MSR_BITMAP_ACCESS_RW) - -#define guest_msr_ro(vmx, msr) \ - msr_bitmap_change_access((vmx)->msr_bitmap, (msr), MSR_BITMAP_ACCESS_READ) - #define HANDLED 1 #define UNHANDLED 0 @@ -158,10 +147,6 @@ SYSCTL_INT(_hw_vmm_vmx, OID_AUTO, initialized, CTLFLAG_RD, */ static SYSCTL_NODE(_hw_vmm_vmx, OID_AUTO, cap, CTLFLAG_RW, NULL, NULL); -static int vmx_patmsr; -SYSCTL_INT(_hw_vmm_vmx_cap, OID_AUTO, patmsr, CTLFLAG_RD, &vmx_patmsr, 0, - "PAT MSR saved and restored in VCMS"); - static int cap_halt_exit; SYSCTL_INT(_hw_vmm_vmx_cap, OID_AUTO, halt_exit, CTLFLAG_RD, &cap_halt_exit, 0, "HLT triggers a VM-exit"); @@ -208,6 +193,7 @@ SYSCTL_UINT(_hw_vmm_vmx, OID_AUTO, vpid_alloc_failed, CTLFLAG_RD, static int vmx_getdesc(void *arg, int vcpu, int reg, struct seg_desc *desc); static int vmx_getreg(void *arg, int vcpu, int reg, uint64_t *retval); +static int vmxctx_setreg(struct vmxctx *vmxctx, int reg, uint64_t val); static void vmx_inject_pir(struct vlapic *vlapic); #ifdef KTR @@ -474,22 +460,6 @@ vpid_init(void) vpid_unr = new_unrhdr(VM_MAXCPU + 1, 0xffff, NULL); } -static void -msr_save_area_init(struct msr_entry *g_area, int *g_count) -{ - int cnt; - - static struct msr_entry guest_msrs[] = { - { MSR_KGSBASE, 0, 0 }, - }; - - cnt = sizeof(guest_msrs) / sizeof(guest_msrs[0]); - if (cnt > GUEST_MSR_MAX_ENTRIES) - panic("guest msr save area overrun"); - bcopy(guest_msrs, g_area, sizeof(guest_msrs)); - *g_count = cnt; -} - static void vmx_disable(void *arg __unused) { @@ -636,49 +606,24 @@ vmx_init(int ipinum) } /* Check support for VM-exit controls */ - vmx_patmsr = 1; error = vmx_set_ctlreg(MSR_VMX_EXIT_CTLS, MSR_VMX_TRUE_EXIT_CTLS, VM_EXIT_CTLS_ONE_SETTING, VM_EXIT_CTLS_ZERO_SETTING, &exit_ctls); if (error) { - /* Try again without the PAT MSR bits */ - error = vmx_set_ctlreg(MSR_VMX_EXIT_CTLS, - MSR_VMX_TRUE_EXIT_CTLS, - VM_EXIT_CTLS_ONE_SETTING_NO_PAT, - VM_EXIT_CTLS_ZERO_SETTING, - &exit_ctls); - if (error) { - printf("vmx_init: processor does not support desired " - "exit controls\n"); - return (error); - } else { - if (bootverbose) - printf("vmm: PAT MSR access not supported\n"); - guest_msr_valid(MSR_PAT); - vmx_patmsr = 0; - } + printf("vmx_init: processor does not support desired " + "exit controls\n"); + return (error); } /* Check support for VM-entry controls */ - if (vmx_patmsr) { - error = vmx_set_ctlreg(MSR_VMX_ENTRY_CTLS, - MSR_VMX_TRUE_ENTRY_CTLS, - VM_ENTRY_CTLS_ONE_SETTING, - VM_ENTRY_CTLS_ZERO_SETTING, - &entry_ctls); - } else { - error = vmx_set_ctlreg(MSR_VMX_ENTRY_CTLS, - MSR_VMX_TRUE_ENTRY_CTLS, - VM_ENTRY_CTLS_ONE_SETTING_NO_PAT, - VM_ENTRY_CTLS_ZERO_SETTING, - &entry_ctls); - } - + error = vmx_set_ctlreg(MSR_VMX_ENTRY_CTLS, MSR_VMX_TRUE_ENTRY_CTLS, + VM_ENTRY_CTLS_ONE_SETTING, VM_ENTRY_CTLS_ZERO_SETTING, + &entry_ctls); if (error) { printf("vmx_init: processor does not support desired " - "entry controls\n"); - return (error); + "entry controls\n"); + return (error); } /* @@ -800,6 +745,8 @@ vmx_init(int ipinum) vpid_init(); + vmx_msr_init(); + /* enable VMX operation */ smp_rendezvous(NULL, vmx_enable, NULL, NULL); @@ -869,7 +816,7 @@ static void * vmx_vminit(struct vm *vm, pmap_t pmap) { uint16_t vpid[VM_MAXCPU]; - int i, error, guest_msr_count; + int i, error; struct vmx *vmx; struct vmcs *vmcs; @@ -905,16 +852,14 @@ vmx_vminit(struct vm *vm, pmap_t pmap) * how they are saved/restored so can be directly accessed by the * guest. * - * Guest KGSBASE is saved and restored in the guest MSR save area. - * Host KGSBASE is restored before returning to userland from the pcb. - * There will be a window of time when we are executing in the host - * kernel context with a value of KGSBASE from the guest. This is ok - * because the value of KGSBASE is inconsequential in kernel context. - * * MSR_EFER is saved and restored in the guest VMCS area on a * VM exit and entry respectively. It is also restored from the * host VMCS area on a VM exit. * + * MSR_PAT is saved and restored in the guest VMCS are on a VM exit + * and entry respectively. It is also restored from the host VMCS + * area on a VM exit. + * * The TSC MSR is exposed read-only. Writes are disallowed as that * will impact the host TSC. * XXX Writes would be implemented with a wrmsr trap, and @@ -925,21 +870,11 @@ vmx_vminit(struct vm *vm, pmap_t pmap) guest_msr_rw(vmx, MSR_SYSENTER_CS_MSR) || guest_msr_rw(vmx, MSR_SYSENTER_ESP_MSR) || guest_msr_rw(vmx, MSR_SYSENTER_EIP_MSR) || - guest_msr_rw(vmx, MSR_KGSBASE) || guest_msr_rw(vmx, MSR_EFER) || + guest_msr_rw(vmx, MSR_PAT) || guest_msr_ro(vmx, MSR_TSC)) panic("vmx_vminit: error setting guest msr access"); - /* - * MSR_PAT is saved and restored in the guest VMCS are on a VM exit - * and entry respectively. It is also restored from the host VMCS - * area on a VM exit. However, if running on a system with no - * MSR_PAT save/restore support, leave access disabled so accesses - * will be trapped. - */ - if (vmx_patmsr && guest_msr_rw(vmx, MSR_PAT)) - panic("vmx_vminit: error setting guest pat msr access"); - vpid_alloc(vpid, VM_MAXCPU); if (virtual_interrupt_delivery) { @@ -958,6 +893,8 @@ vmx_vminit(struct vm *vm, pmap_t pmap) error, i); } + vmx_msr_guest_init(vmx, i); + error = vmcs_init(vmcs); KASSERT(error == 0, ("vmcs_init error %d", error)); @@ -996,13 +933,6 @@ vmx_vminit(struct vm *vm, pmap_t pmap) vmx->state[i].lastcpu = NOCPU; vmx->state[i].vpid = vpid[i]; - msr_save_area_init(vmx->guest_msrs[i], &guest_msr_count); - - error = vmcs_set_msr_save(vmcs, vtophys(vmx->guest_msrs[i]), - guest_msr_count); - if (error != 0) - panic("vmcs_set_msr_save error %d", error); - /* * Set up the CR0/4 shadows, and init the read shadow * to the power-on register value from the Intel Sys Arch. @@ -2077,6 +2007,46 @@ vmx_task_switch_reason(uint64_t qual) } } +static int +emulate_wrmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t val, bool *retu) +{ + int error; + + if (lapic_msr(num)) + error = lapic_wrmsr(vmx->vm, vcpuid, num, val, retu); + else + error = vmx_wrmsr(vmx, vcpuid, num, val, retu); + + return (error); +} + +static int +emulate_rdmsr(struct vmx *vmx, int vcpuid, u_int num, bool *retu) +{ + struct vmxctx *vmxctx; + uint64_t result; + uint32_t eax, edx; + int error; + + if (lapic_msr(num)) + error = lapic_rdmsr(vmx->vm, vcpuid, num, &result, retu); + else + error = vmx_rdmsr(vmx, vcpuid, num, &result, retu); + + if (error == 0) { + eax = result; + vmxctx = &vmx->ctx[vcpuid]; + error = vmxctx_setreg(vmxctx, VM_REG_GUEST_RAX, eax); + KASSERT(error == 0, ("vmxctx_setreg(rax) error %d", error)); + + edx = result >> 32; + error = vmxctx_setreg(vmxctx, VM_REG_GUEST_RDX, edx); + KASSERT(error == 0, ("vmxctx_setreg(rdx) error %d", error)); + } + + return (error); +} + static int vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit) { @@ -2215,7 +2185,7 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit) retu = false; ecx = vmxctx->guest_rcx; VCPU_CTR1(vmx->vm, vcpu, "rdmsr 0x%08x", ecx); - error = emulate_rdmsr(vmx->vm, vcpu, ecx, &retu); + error = emulate_rdmsr(vmx, vcpu, ecx, &retu); if (error) { vmexit->exitcode = VM_EXITCODE_RDMSR; vmexit->u.msr.code = ecx; @@ -2224,7 +2194,7 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit) } else { /* Return to userspace with a valid exitcode */ KASSERT(vmexit->exitcode != VM_EXITCODE_BOGUS, - ("emulate_wrmsr retu with bogus exitcode")); + ("emulate_rdmsr retu with bogus exitcode")); } break; case EXIT_REASON_WRMSR: @@ -2235,7 +2205,7 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit) edx = vmxctx->guest_rdx; VCPU_CTR2(vmx->vm, vcpu, "wrmsr 0x%08x value 0x%016lx", ecx, (uint64_t)edx << 32 | eax); - error = emulate_wrmsr(vmx->vm, vcpu, ecx, + error = emulate_wrmsr(vmx, vcpu, ecx, (uint64_t)edx << 32 | eax, &retu); if (error) { vmexit->exitcode = VM_EXITCODE_WRMSR; @@ -2523,6 +2493,8 @@ vmx_run(void *arg, int vcpu, register_t startrip, pmap_t pmap, KASSERT(vmxctx->pmap == pmap, ("pmap %p different than ctx pmap %p", pmap, vmxctx->pmap)); + vmx_msr_guest_enter(vmx, vcpu); + VMPTRLD(vmcs); /* @@ -2624,6 +2596,8 @@ vmx_run(void *arg, int vcpu, register_t startrip, pmap_t pmap, vmexit->exitcode); VMCLEAR(vmcs); + vmx_msr_guest_exit(vmx, vcpu); + return (0); } @@ -2711,6 +2685,46 @@ vmxctx_setreg(struct vmxctx *vmxctx, int reg, uint64_t val) return (EINVAL); } +static int +vmx_get_intr_shadow(struct vmx *vmx, int vcpu, int running, uint64_t *retval) +{ + uint64_t gi; + int error; + + error = vmcs_getreg(&vmx->vmcs[vcpu], running, + VMCS_IDENT(VMCS_GUEST_INTERRUPTIBILITY), &gi); + *retval = (gi & HWINTR_BLOCKING) ? 1 : 0; + return (error); +} + +static int +vmx_modify_intr_shadow(struct vmx *vmx, int vcpu, int running, uint64_t val) +{ + struct vmcs *vmcs; + uint64_t gi; + int error, ident; + + /* + * Forcing the vcpu into an interrupt shadow is not supported. + */ + if (val) { + error = EINVAL; + goto done; + } + + vmcs = &vmx->vmcs[vcpu]; + ident = VMCS_IDENT(VMCS_GUEST_INTERRUPTIBILITY); + error = vmcs_getreg(vmcs, running, ident, &gi); + if (error == 0) { + gi &= ~HWINTR_BLOCKING; + error = vmcs_setreg(vmcs, running, ident, gi); + } +done: + VCPU_CTR2(vmx->vm, vcpu, "Setting intr_shadow to %#lx %s", val, + error ? "failed" : "succeeded"); + return (error); +} + static int vmx_shadow_reg(int reg) { @@ -2742,6 +2756,9 @@ vmx_getreg(void *arg, int vcpu, int reg, uint64_t *retval) if (running && hostcpu != curcpu) panic("vmx_getreg: %s%d is running", vm_name(vmx->vm), vcpu); + if (reg == VM_REG_GUEST_INTR_SHADOW) + return (vmx_get_intr_shadow(vmx, vcpu, running, retval)); + if (vmxctx_getreg(&vmx->ctx[vcpu], reg, retval) == 0) return (0); @@ -2760,6 +2777,9 @@ vmx_setreg(void *arg, int vcpu, int reg, uint64_t val) if (running && hostcpu != curcpu) panic("vmx_setreg: %s%d is running", vm_name(vmx->vm), vcpu); + if (reg == VM_REG_GUEST_INTR_SHADOW) + return (vmx_modify_intr_shadow(vmx, vcpu, running, val)); + if (vmxctx_setreg(&vmx->ctx[vcpu], reg, val) == 0) return (0); diff --git a/sys/amd64/vmm/intel/vmx.h b/sys/amd64/vmm/intel/vmx.h index 208fceed9b28..2124554887dc 100644 --- a/sys/amd64/vmm/intel/vmx.h +++ b/sys/amd64/vmm/intel/vmx.h @@ -33,8 +33,6 @@ struct pmap; -#define GUEST_MSR_MAX_ENTRIES 64 /* arbitrary */ - struct vmxctx { register_t guest_rdi; /* Guest state */ register_t guest_rsi; @@ -97,13 +95,23 @@ struct pir_desc { } __aligned(64); CTASSERT(sizeof(struct pir_desc) == 64); +/* Index into the 'guest_msrs[]' array */ +enum { + IDX_MSR_LSTAR, + IDX_MSR_CSTAR, + IDX_MSR_STAR, + IDX_MSR_SF_MASK, + IDX_MSR_KGSBASE, + GUEST_MSR_NUM /* must be the last enumeration */ +}; + /* virtual machine softc */ struct vmx { struct vmcs vmcs[VM_MAXCPU]; /* one vmcs per virtual cpu */ struct apic_page apic_page[VM_MAXCPU]; /* one apic page per vcpu */ char msr_bitmap[PAGE_SIZE]; struct pir_desc pir_desc[VM_MAXCPU]; - struct msr_entry guest_msrs[VM_MAXCPU][GUEST_MSR_MAX_ENTRIES]; + uint64_t guest_msrs[VM_MAXCPU][GUEST_MSR_NUM]; struct vmxctx ctx[VM_MAXCPU]; struct vmxcap cap[VM_MAXCPU]; struct vmxstate state[VM_MAXCPU]; @@ -113,7 +121,6 @@ struct vmx { }; CTASSERT((offsetof(struct vmx, vmcs) & PAGE_MASK) == 0); CTASSERT((offsetof(struct vmx, msr_bitmap) & PAGE_MASK) == 0); -CTASSERT((offsetof(struct vmx, guest_msrs) & 15) == 0); CTASSERT((offsetof(struct vmx, pir_desc[0]) & 63) == 0); #define VMX_GUEST_VMEXIT 0 diff --git a/sys/amd64/vmm/intel/vmx_msr.c b/sys/amd64/vmm/intel/vmx_msr.c index a3428db8a87d..94d52e306cea 100644 --- a/sys/amd64/vmm/intel/vmx_msr.c +++ b/sys/amd64/vmm/intel/vmx_msr.c @@ -31,10 +31,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include +#include "vmx.h" #include "vmx_msr.h" static boolean_t @@ -171,3 +174,115 @@ msr_bitmap_change_access(char *bitmap, u_int msr, int access) return (0); } + +static uint64_t misc_enable; +static uint64_t host_msrs[GUEST_MSR_NUM]; + +void +vmx_msr_init(void) +{ + /* + * It is safe to cache the values of the following MSRs because + * they don't change based on curcpu, curproc or curthread. + */ + host_msrs[IDX_MSR_LSTAR] = rdmsr(MSR_LSTAR); + host_msrs[IDX_MSR_CSTAR] = rdmsr(MSR_CSTAR); + host_msrs[IDX_MSR_STAR] = rdmsr(MSR_STAR); + host_msrs[IDX_MSR_SF_MASK] = rdmsr(MSR_SF_MASK); + + /* + * Initialize emulated MSRs + */ + misc_enable = rdmsr(MSR_IA32_MISC_ENABLE); + /* + * Set mandatory bits + * 11: branch trace disabled + * 12: PEBS unavailable + * Clear unsupported features + * 16: SpeedStep enable + * 18: enable MONITOR FSM + */ + misc_enable |= (1 << 12) | (1 << 11); + misc_enable &= ~((1 << 18) | (1 << 16)); +} + +void +vmx_msr_guest_init(struct vmx *vmx, int vcpuid) +{ + /* + * The permissions bitmap is shared between all vcpus so initialize it + * once when initializing the vBSP. + */ + if (vcpuid == 0) { + guest_msr_rw(vmx, MSR_LSTAR); + guest_msr_rw(vmx, MSR_CSTAR); + guest_msr_rw(vmx, MSR_STAR); + guest_msr_rw(vmx, MSR_SF_MASK); + guest_msr_rw(vmx, MSR_KGSBASE); + } + return; +} + +void +vmx_msr_guest_enter(struct vmx *vmx, int vcpuid) +{ + uint64_t *guest_msrs = vmx->guest_msrs[vcpuid]; + + /* Save host MSRs (if any) and restore guest MSRs */ + wrmsr(MSR_LSTAR, guest_msrs[IDX_MSR_LSTAR]); + wrmsr(MSR_CSTAR, guest_msrs[IDX_MSR_CSTAR]); + wrmsr(MSR_STAR, guest_msrs[IDX_MSR_STAR]); + wrmsr(MSR_SF_MASK, guest_msrs[IDX_MSR_SF_MASK]); + wrmsr(MSR_KGSBASE, guest_msrs[IDX_MSR_KGSBASE]); +} + +void +vmx_msr_guest_exit(struct vmx *vmx, int vcpuid) +{ + uint64_t *guest_msrs = vmx->guest_msrs[vcpuid]; + + /* Save guest MSRs */ + guest_msrs[IDX_MSR_LSTAR] = rdmsr(MSR_LSTAR); + guest_msrs[IDX_MSR_CSTAR] = rdmsr(MSR_CSTAR); + guest_msrs[IDX_MSR_STAR] = rdmsr(MSR_STAR); + guest_msrs[IDX_MSR_SF_MASK] = rdmsr(MSR_SF_MASK); + guest_msrs[IDX_MSR_KGSBASE] = rdmsr(MSR_KGSBASE); + + /* Restore host MSRs */ + wrmsr(MSR_LSTAR, host_msrs[IDX_MSR_LSTAR]); + wrmsr(MSR_CSTAR, host_msrs[IDX_MSR_CSTAR]); + wrmsr(MSR_STAR, host_msrs[IDX_MSR_STAR]); + wrmsr(MSR_SF_MASK, host_msrs[IDX_MSR_SF_MASK]); + + /* MSR_KGSBASE will be restored on the way back to userspace */ +} + +int +vmx_rdmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t *val, bool *retu) +{ + int error = 0; + + switch (num) { + case MSR_IA32_MISC_ENABLE: + *val = misc_enable; + break; + default: + error = EINVAL; + break; + } + return (error); +} + +int +vmx_wrmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t val, bool *retu) +{ + int error = 0; + + switch (num) { + default: + error = EINVAL; + break; + } + + return (error); +} diff --git a/sys/amd64/vmm/intel/vmx_msr.h b/sys/amd64/vmm/intel/vmx_msr.h index 340b0f7ab436..e77881c75e8f 100644 --- a/sys/amd64/vmm/intel/vmx_msr.h +++ b/sys/amd64/vmm/intel/vmx_msr.h @@ -29,6 +29,15 @@ #ifndef _VMX_MSR_H_ #define _VMX_MSR_H_ +struct vmx; + +void vmx_msr_init(void); +void vmx_msr_guest_init(struct vmx *vmx, int vcpuid); +void vmx_msr_guest_enter(struct vmx *vmx, int vcpuid); +void vmx_msr_guest_exit(struct vmx *vmx, int vcpuid); +int vmx_rdmsr(struct vmx *, int vcpuid, u_int num, uint64_t *val, bool *retu); +int vmx_wrmsr(struct vmx *, int vcpuid, u_int num, uint64_t val, bool *retu); + uint32_t vmx_revision(void); int vmx_set_ctlreg(int ctl_reg, int true_ctl_reg, uint32_t ones_mask, @@ -52,4 +61,10 @@ int vmx_set_ctlreg(int ctl_reg, int true_ctl_reg, uint32_t ones_mask, void msr_bitmap_initialize(char *bitmap); int msr_bitmap_change_access(char *bitmap, u_int msr, int access); +#define guest_msr_rw(vmx, msr) \ + msr_bitmap_change_access((vmx)->msr_bitmap, (msr), MSR_BITMAP_ACCESS_RW) + +#define guest_msr_ro(vmx, msr) \ + msr_bitmap_change_access((vmx)->msr_bitmap, (msr), MSR_BITMAP_ACCESS_READ) + #endif diff --git a/sys/amd64/vmm/io/vatpic.c b/sys/amd64/vmm/io/vatpic.c index d8ccebdeaa11..b710a8455aea 100644 --- a/sys/amd64/vmm/io/vatpic.c +++ b/sys/amd64/vmm/io/vatpic.c @@ -606,20 +606,19 @@ vatpic_write(struct vatpic *vatpic, struct atpic *atpic, bool in, int port, VATPIC_LOCK(vatpic); if (port & ICU_IMR_OFFSET) { - if (atpic->ready) { + switch (atpic->icw_num) { + case 2: + error = vatpic_icw2(vatpic, atpic, val); + break; + case 3: + error = vatpic_icw3(vatpic, atpic, val); + break; + case 4: + error = vatpic_icw4(vatpic, atpic, val); + break; + default: error = vatpic_ocw1(vatpic, atpic, val); - } else { - switch (atpic->icw_num) { - case 2: - error = vatpic_icw2(vatpic, atpic, val); - break; - case 3: - error = vatpic_icw3(vatpic, atpic, val); - break; - case 4: - error = vatpic_icw4(vatpic, atpic, val); - break; - } + break; } } else { if (val & (1 << 4)) diff --git a/sys/amd64/vmm/io/vlapic.c b/sys/amd64/vmm/io/vlapic.c index 3c9346334f5a..d684dbade70a 100644 --- a/sys/amd64/vmm/io/vlapic.c +++ b/sys/amd64/vmm/io/vlapic.c @@ -633,6 +633,7 @@ vlapic_fire_timer(struct vlapic *vlapic) // The timer LVT always uses the fixed delivery mode. lvt = vlapic_get_lvt(vlapic, APIC_OFFSET_TIMER_LVT); if (vlapic_fire_lvt(vlapic, lvt | APIC_LVT_DM_FIXED)) { + VLAPIC_CTR0(vlapic, "vlapic timer fired"); vmm_stat_incr(vlapic->vm, vlapic->vcpuid, VLAPIC_INTR_TIMER, 1); } } diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index ae67c58962eb..7fc3a9bbdd10 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$"); #include "vhpet.h" #include "vioapic.h" #include "vlapic.h" -#include "vmm_msr.h" #include "vmm_ipi.h" #include "vmm_stat.h" #include "vmm_lapic.h" @@ -105,7 +104,6 @@ struct vcpu { struct savefpu *guestfpu; /* (a,i) guest fpu state */ uint64_t guest_xcr0; /* (i) guest %xcr0 register */ void *stats; /* (a,i) statistics */ - uint64_t guest_msrs[VMM_MSR_NUM]; /* (i) emulated MSRs */ struct vm_exit exitinfo; /* (x) exit reason and collateral */ }; @@ -188,7 +186,6 @@ static struct vmm_ops *ops; #define fpu_stop_emulating() clts() static MALLOC_DEFINE(M_VM, "vm", "vm"); -CTASSERT(VMM_MSR_NUM <= 64); /* msr_mask can keep track of up to 64 msrs */ /* statistics */ static VMM_STAT(VCPU_TOTAL_RUNTIME, "vcpu total runtime"); @@ -249,7 +246,6 @@ vcpu_init(struct vm *vm, int vcpu_id, bool create) vcpu->guest_xcr0 = XFEATURE_ENABLED_X87; fpu_save_area_reset(vcpu->guestfpu); vmm_stat_init(vcpu->stats); - guest_msrs_init(vm, vcpu_id); } struct vm_exit * @@ -293,7 +289,6 @@ vmm_init(void) else return (ENXIO); - vmm_msr_init(); vmm_resume_p = vmm_resume; return (VMM_INIT(vmm_ipinum)); @@ -1090,7 +1085,7 @@ vm_handle_hlt(struct vm *vm, int vcpuid, bool intr_disabled, bool *retu) { struct vcpu *vcpu; const char *wmesg; - int t, vcpu_halted, vm_halted; + int error, t, vcpu_halted, vm_halted; KASSERT(!CPU_ISSET(vcpuid, &vm->halted_cpus), ("vcpu already halted")); @@ -1098,6 +1093,22 @@ vm_handle_hlt(struct vm *vm, int vcpuid, bool intr_disabled, bool *retu) vcpu_halted = 0; vm_halted = 0; + /* + * The typical way to halt a cpu is to execute: "sti; hlt" + * + * STI sets RFLAGS.IF to enable interrupts. However, the processor + * remains in an "interrupt shadow" for an additional instruction + * following the STI. This guarantees that "sti; hlt" sequence is + * atomic and a pending interrupt will be recognized after the HLT. + * + * After the HLT emulation is done the vcpu is no longer in an + * interrupt shadow and a pending interrupt can be injected on + * the next entry into the guest. + */ + error = vm_set_register(vm, vcpuid, VM_REG_GUEST_INTR_SHADOW, 0); + KASSERT(error == 0, ("%s: error %d clearing interrupt shadow", + __func__, error)); + vcpu_lock(vcpu); while (1) { /* @@ -1186,8 +1197,12 @@ vm_handle_paging(struct vm *vm, int vcpuid, bool *retu) if (ftype == VM_PROT_READ || ftype == VM_PROT_WRITE) { rv = pmap_emulate_accessed_dirty(vmspace_pmap(vm->vmspace), vme->u.paging.gpa, ftype); - if (rv == 0) + if (rv == 0) { + VCPU_CTR2(vm, vcpuid, "%s bit emulation for gpa %#lx", + ftype == VM_PROT_READ ? "accessed" : "dirty", + vme->u.paging.gpa); goto done; + } } map = &vm->vmspace->vm_map; @@ -1228,6 +1243,8 @@ vm_handle_inst_emul(struct vm *vm, int vcpuid, bool *retu) paging = &vme->u.inst_emul.paging; cpu_mode = paging->cpu_mode; + VCPU_CTR1(vm, vcpuid, "inst_emul fault accessing gpa %#lx", gpa); + vie_init(vie); /* Fetch, decode and emulate the faulting instruction */ @@ -1424,7 +1441,6 @@ vm_run(struct vm *vm, struct vm_run *vmrun) pcb = PCPU_GET(curpcb); set_pcb_flags(pcb, PCB_FULL_IRET); - restore_guest_msrs(vm, vcpuid); restore_guest_fpustate(vcpu); vcpu_require_state(vm, vcpuid, VCPU_RUNNING); @@ -1432,7 +1448,6 @@ vm_run(struct vm *vm, struct vm_run *vmrun) vcpu_require_state(vm, vcpuid, VCPU_FROZEN); save_guest_fpustate(vcpu); - restore_host_msrs(vm, vcpuid); vmm_stat_incr(vm, vcpuid, VCPU_TOTAL_RUNTIME, rdtsc() - tscval); @@ -1874,12 +1889,6 @@ vm_set_capability(struct vm *vm, int vcpu, int type, int val) return (VMSETCAP(vm->cookie, vcpu, type, val)); } -uint64_t * -vm_guest_msrs(struct vm *vm, int cpu) -{ - return (vm->vcpu[cpu].guest_msrs); -} - struct vlapic * vm_lapic(struct vm *vm, int cpu) { diff --git a/sys/amd64/vmm/vmm_msr.c b/sys/amd64/vmm/vmm_msr.c deleted file mode 100644 index 03e0071c311c..000000000000 --- a/sys/amd64/vmm/vmm_msr.c +++ /dev/null @@ -1,273 +0,0 @@ -/*- - * Copyright (c) 2011 NetApp, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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 NETAPP, INC ``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 NETAPP, INC 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -#include -#include "vmm_lapic.h" -#include "vmm_msr.h" - -#define VMM_MSR_F_EMULATE 0x01 -#define VMM_MSR_F_READONLY 0x02 -#define VMM_MSR_F_INVALID 0x04 /* guest_msr_valid() can override this */ - -struct vmm_msr { - int num; - int flags; - uint64_t hostval; -}; - -static struct vmm_msr vmm_msr[] = { - { MSR_LSTAR, 0 }, - { MSR_CSTAR, 0 }, - { MSR_STAR, 0 }, - { MSR_SF_MASK, 0 }, - { MSR_PAT, VMM_MSR_F_EMULATE | VMM_MSR_F_INVALID }, - { MSR_BIOS_SIGN,VMM_MSR_F_EMULATE }, - { MSR_MCG_CAP, VMM_MSR_F_EMULATE | VMM_MSR_F_READONLY }, - { MSR_IA32_PLATFORM_ID, VMM_MSR_F_EMULATE | VMM_MSR_F_READONLY }, - { MSR_IA32_MISC_ENABLE, VMM_MSR_F_EMULATE | VMM_MSR_F_READONLY }, -}; - -#define vmm_msr_num (sizeof(vmm_msr) / sizeof(vmm_msr[0])) -CTASSERT(VMM_MSR_NUM >= vmm_msr_num); - -#define readonly_msr(idx) \ - ((vmm_msr[(idx)].flags & VMM_MSR_F_READONLY) != 0) - -#define emulated_msr(idx) \ - ((vmm_msr[(idx)].flags & VMM_MSR_F_EMULATE) != 0) - -#define invalid_msr(idx) \ - ((vmm_msr[(idx)].flags & VMM_MSR_F_INVALID) != 0) - -void -vmm_msr_init(void) -{ - int i; - - for (i = 0; i < vmm_msr_num; i++) { - if (emulated_msr(i)) - continue; - /* - * XXX this assumes that the value of the host msr does not - * change after we have cached it. - */ - vmm_msr[i].hostval = rdmsr(vmm_msr[i].num); - } -} - -void -guest_msrs_init(struct vm *vm, int cpu) -{ - int i; - uint64_t *guest_msrs, misc; - - guest_msrs = vm_guest_msrs(vm, cpu); - - for (i = 0; i < vmm_msr_num; i++) { - switch (vmm_msr[i].num) { - case MSR_LSTAR: - case MSR_CSTAR: - case MSR_STAR: - case MSR_SF_MASK: - case MSR_BIOS_SIGN: - case MSR_MCG_CAP: - guest_msrs[i] = 0; - break; - case MSR_PAT: - guest_msrs[i] = PAT_VALUE(0, PAT_WRITE_BACK) | - PAT_VALUE(1, PAT_WRITE_THROUGH) | - PAT_VALUE(2, PAT_UNCACHED) | - PAT_VALUE(3, PAT_UNCACHEABLE) | - PAT_VALUE(4, PAT_WRITE_BACK) | - PAT_VALUE(5, PAT_WRITE_THROUGH) | - PAT_VALUE(6, PAT_UNCACHED) | - PAT_VALUE(7, PAT_UNCACHEABLE); - break; - case MSR_IA32_MISC_ENABLE: - misc = rdmsr(MSR_IA32_MISC_ENABLE); - /* - * Set mandatory bits - * 11: branch trace disabled - * 12: PEBS unavailable - * Clear unsupported features - * 16: SpeedStep enable - * 18: enable MONITOR FSM - */ - misc |= (1 << 12) | (1 << 11); - misc &= ~((1 << 18) | (1 << 16)); - guest_msrs[i] = misc; - break; - case MSR_IA32_PLATFORM_ID: - guest_msrs[i] = 0; - break; - default: - panic("guest_msrs_init: missing initialization for msr " - "0x%0x", vmm_msr[i].num); - } - } -} - -static int -msr_num_to_idx(u_int num) -{ - int i; - - for (i = 0; i < vmm_msr_num; i++) - if (vmm_msr[i].num == num) - return (i); - - return (-1); -} - -int -emulate_wrmsr(struct vm *vm, int cpu, u_int num, uint64_t val, bool *retu) -{ - int idx; - uint64_t *guest_msrs; - - if (lapic_msr(num)) - return (lapic_wrmsr(vm, cpu, num, val, retu)); - - idx = msr_num_to_idx(num); - if (idx < 0 || invalid_msr(idx)) - return (EINVAL); - - if (!readonly_msr(idx)) { - guest_msrs = vm_guest_msrs(vm, cpu); - - /* Stash the value */ - guest_msrs[idx] = val; - - /* Update processor state for non-emulated MSRs */ - if (!emulated_msr(idx)) - wrmsr(vmm_msr[idx].num, val); - } - - return (0); -} - -int -emulate_rdmsr(struct vm *vm, int cpu, u_int num, bool *retu) -{ - int error, idx; - uint32_t eax, edx; - uint64_t result, *guest_msrs; - - if (lapic_msr(num)) { - error = lapic_rdmsr(vm, cpu, num, &result, retu); - goto done; - } - - idx = msr_num_to_idx(num); - if (idx < 0 || invalid_msr(idx)) { - error = EINVAL; - goto done; - } - - guest_msrs = vm_guest_msrs(vm, cpu); - result = guest_msrs[idx]; - - /* - * If this is not an emulated msr register make sure that the processor - * state matches our cached state. - */ - if (!emulated_msr(idx) && (rdmsr(num) != result)) { - panic("emulate_rdmsr: msr 0x%0x has inconsistent cached " - "(0x%016lx) and actual (0x%016lx) values", num, - result, rdmsr(num)); - } - - error = 0; - -done: - if (error == 0) { - eax = result; - edx = result >> 32; - error = vm_set_register(vm, cpu, VM_REG_GUEST_RAX, eax); - if (error) - panic("vm_set_register(rax) error %d", error); - error = vm_set_register(vm, cpu, VM_REG_GUEST_RDX, edx); - if (error) - panic("vm_set_register(rdx) error %d", error); - } - return (error); -} - -void -restore_guest_msrs(struct vm *vm, int cpu) -{ - int i; - uint64_t *guest_msrs; - - guest_msrs = vm_guest_msrs(vm, cpu); - - for (i = 0; i < vmm_msr_num; i++) { - if (emulated_msr(i)) - continue; - else - wrmsr(vmm_msr[i].num, guest_msrs[i]); - } -} - -void -restore_host_msrs(struct vm *vm, int cpu) -{ - int i; - - for (i = 0; i < vmm_msr_num; i++) { - if (emulated_msr(i)) - continue; - else - wrmsr(vmm_msr[i].num, vmm_msr[i].hostval); - } -} - -/* - * Must be called by the CPU-specific code before any guests are - * created - */ -void -guest_msr_valid(int msr) -{ - int i; - - for (i = 0; i < vmm_msr_num; i++) { - if (vmm_msr[i].num == msr && invalid_msr(i)) { - vmm_msr[i].flags &= ~VMM_MSR_F_INVALID; - } - } -} diff --git a/sys/arm/allwinner/a10_clk.c b/sys/arm/allwinner/a10_clk.c index 2bb683e015c8..af7e87588197 100644 --- a/sys/arm/allwinner/a10_clk.c +++ b/sys/arm/allwinner/a10_clk.c @@ -132,7 +132,7 @@ a10_clk_usb_activate(void) /* Gating AHB clock for USB */ reg_value = ccm_read_4(sc, CCM_AHB_GATING0); reg_value |= CCM_AHB_GATING_USB0; /* AHB clock gate usb0 */ - reg_value |= CCM_AHB_GATING_EHCI0; /* AHB clock gate ehci1 */ + reg_value |= CCM_AHB_GATING_EHCI0; /* AHB clock gate ehci0 */ reg_value |= CCM_AHB_GATING_EHCI1; /* AHB clock gate ehci1 */ ccm_write_4(sc, CCM_AHB_GATING0, reg_value); @@ -167,6 +167,7 @@ a10_clk_usb_deactivate(void) /* Disable gating AHB clock for USB */ reg_value = ccm_read_4(sc, CCM_AHB_GATING0); reg_value &= ~CCM_AHB_GATING_USB0; /* disable AHB clock gate usb0 */ + reg_value &= ~CCM_AHB_GATING_EHCI0; /* disable AHB clock gate ehci0 */ reg_value &= ~CCM_AHB_GATING_EHCI1; /* disable AHB clock gate ehci1 */ ccm_write_4(sc, CCM_AHB_GATING0, reg_value); diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index 88be55a90e02..7828661c82a3 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -260,7 +260,7 @@ emac_txeof(struct emac_softc *sc) EMAC_ASSERT_LOCKED(sc); ifp = sc->emac_ifp; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; /* Unarm watchdog timer if no TX */ @@ -340,12 +340,12 @@ emac_rxeof(struct emac_softc *sc, int count) if_printf(ifp, "bad packet: len = %i status = %i\n", len, status); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } #if 0 if (status & (EMAC_CRCERR | EMAC_LENERR)) { good_packet = 0; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (status & EMAC_CRCERR) if_printf(ifp, "crc error\n"); if (status & EMAC_LENERR) @@ -393,18 +393,18 @@ emac_rxeof(struct emac_softc *sc, int count) m0->m_next = m; m = m0; } else { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); m = NULL; continue; } } else if (m->m_len > EMAC_MAC_MAXF) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); m = NULL; continue; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); EMAC_UNLOCK(sc); (*ifp->if_input)(ifp, m); EMAC_LOCK(sc); @@ -431,7 +431,7 @@ emac_watchdog(struct emac_softc *sc) } else if_printf(sc->emac_ifp, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; emac_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) diff --git a/sys/arm/allwinner/timer.c b/sys/arm/allwinner/timer.c index 5ab6d9d97f3d..a04fafac60c8 100644 --- a/sys/arm/allwinner/timer.c +++ b/sys/arm/allwinner/timer.c @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$"); #define TIMER_ENABLE (1<<0) #define TIMER_AUTORELOAD (1<<1) #define TIMER_OSC24M (1<<2) /* oscillator = 24mhz */ -#define TIMER_PRESCALAR (4<<4) /* prescalar = 16 */ +#define TIMER_PRESCALAR (0<<4) /* prescalar = 1 */ #define SYS_TIMER_CLKSRC 24000000 /* clock source */ diff --git a/sys/arm/altera/socfpga/files.socfpga b/sys/arm/altera/socfpga/files.socfpga index 654462d0d1fc..c420617fa614 100644 --- a/sys/arm/altera/socfpga/files.socfpga +++ b/sys/arm/altera/socfpga/files.socfpga @@ -15,3 +15,7 @@ arm/arm/mpcore_timer.c standard arm/altera/socfpga/socfpga_common.c standard arm/altera/socfpga/socfpga_machdep.c standard +arm/altera/socfpga/socfpga_manager.c standard +arm/altera/socfpga/socfpga_rstmgr.c standard + +dev/dwc/if_dwc.c optional dwc diff --git a/sys/arm/altera/socfpga/socfpga_common.c b/sys/arm/altera/socfpga/socfpga_common.c index 86d46e3f2dff..6531a416c1a9 100644 --- a/sys/arm/altera/socfpga/socfpga_common.c +++ b/sys/arm/altera/socfpga/socfpga_common.c @@ -42,20 +42,31 @@ __FBSDID("$FreeBSD$"); #include #include -#define RESMAN_BASE 0xFFD05000 -#define RESMAN_CTRL 0x4 -#define SWWARMRSTREQ (1 << 1) +#include void cpu_reset(void) { + uint32_t addr, paddr; bus_addr_t vaddr; + phandle_t node; - if (bus_space_map(fdtbus_bs_tag, RESMAN_BASE, 0x10, 0, &vaddr) == 0) { - bus_space_write_4(fdtbus_bs_tag, vaddr, - RESMAN_CTRL, SWWARMRSTREQ); + if (rstmgr_warmreset() == 0) + goto end; + + node = OF_finddevice("rstmgr"); + if (node == -1) + goto end; + + if ((OF_getprop(node, "reg", &paddr, sizeof(paddr))) > 0) { + addr = fdt32_to_cpu(paddr); + if (bus_space_map(fdtbus_bs_tag, addr, 0x8, 0, &vaddr) == 0) { + bus_space_write_4(fdtbus_bs_tag, vaddr, + RSTMGR_CTRL, CTRL_SWWARMRSTREQ); + } } +end: while (1); } diff --git a/sys/arm/altera/socfpga/socfpga_common.h b/sys/arm/altera/socfpga/socfpga_common.h new file mode 100644 index 000000000000..2b4e97bbb462 --- /dev/null +++ b/sys/arm/altera/socfpga/socfpga_common.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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$ + */ + +#define READ4(_sc, _reg) bus_read_4((_sc)->res[0], _reg) +#define READ2(_sc, _reg) bus_read_2((_sc)->res[0], _reg) +#define READ1(_sc, _reg) bus_read_1((_sc)->res[0], _reg) +#define WRITE4(_sc, _reg, _val) bus_write_4((_sc)->res[0], _reg, _val) +#define WRITE2(_sc, _reg, _val) bus_write_2((_sc)->res[0], _reg, _val) +#define WRITE1(_sc, _reg, _val) bus_write_1((_sc)->res[0], _reg, _val) diff --git a/sys/arm/altera/socfpga/socfpga_l3regs.h b/sys/arm/altera/socfpga/socfpga_l3regs.h new file mode 100644 index 000000000000..b4ef6f6d980d --- /dev/null +++ b/sys/arm/altera/socfpga/socfpga_l3regs.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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$ + */ + +#define L3REGS_REMAP 0x0 /* Remap */ +#define REMAP_LWHPS2FPGA (1 << 4) +#define REMAP_HPS2FPGA (1 << 3) +#define REMAP_MPUZERO (1 << 0) +#define L3REGS_L4MAIN 0x8 /* L4 main peripherals security */ +#define L3REGS_L4SP 0xC /* L4 SP Peripherals Security */ +#define L3REGS_L4MP 0x10 /* L4 MP Peripherals Security */ +#define L3REGS_L4OSC1 0x14 /* L4 OSC1 Peripherals Security */ +#define L3REGS_L4SPIM 0x18 /* L4 SPIM Peripherals Security */ +#define L3REGS_STM 0x1C /* STM Peripheral Security */ +#define L3REGS_LWHPS2FPGAREGS 0x20 /* LWHPS2FPGA AXI Bridge Security */ +#define L3REGS_USB1 0x28 /* USB1 Peripheral Security */ +#define L3REGS_NANDDATA 0x2C /* NAND Flash Controller Data Sec */ +#define L3REGS_USB0 0x80 /* USB0 Peripheral Security */ +#define L3REGS_NANDREGS 0x84 /* NAND Flash Controller Security */ +#define L3REGS_QSPIDATA 0x88 /* QSPI Flash Controller Data Sec */ +#define L3REGS_FPGAMGRDATA 0x8C /* FPGA Manager Data Peripheral Sec */ +#define L3REGS_HPS2FPGAREGS 0x90 /* HPS2FPGA AXI Bridge Perip. Sec */ +#define L3REGS_ACP 0x94 /* MPU ACP Peripheral Security */ +#define L3REGS_ROM 0x98 /* ROM Peripheral Security */ +#define L3REGS_OCRAM 0x9C /* On-chip RAM Peripheral Security */ +#define L3REGS_SDRDATA 0xA0 /* SDRAM Data Peripheral Security */ diff --git a/sys/arm/altera/socfpga/socfpga_manager.c b/sys/arm/altera/socfpga/socfpga_manager.c new file mode 100644 index 000000000000..47fd23fe0c7e --- /dev/null +++ b/sys/arm/altera/socfpga/socfpga_manager.c @@ -0,0 +1,433 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +/* + * Altera FPGA Manager. + * Chapter 4, Cyclone V Device Handbook (CV-5V2 2014.07.22) + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +/* FPGA Manager Module Registers */ +#define FPGAMGR_STAT 0x0 /* Status Register */ +#define STAT_MSEL_MASK 0x1f +#define STAT_MSEL_SHIFT 3 +#define STAT_MODE_SHIFT 0 +#define STAT_MODE_MASK 0x7 +#define FPGAMGR_CTRL 0x4 /* Control Register */ +#define CTRL_AXICFGEN (1 << 8) +#define CTRL_CDRATIO_MASK 0x3 +#define CTRL_CDRATIO_SHIFT 6 +#define CTRL_CFGWDTH_MASK 1 +#define CTRL_CFGWDTH_SHIFT 9 +#define CTRL_NCONFIGPULL (1 << 2) +#define CTRL_NCE (1 << 1) +#define CTRL_EN (1 << 0) +#define FPGAMGR_DCLKCNT 0x8 /* DCLK Count Register */ +#define FPGAMGR_DCLKSTAT 0xC /* DCLK Status Register */ +#define FPGAMGR_GPO 0x10 /* General-Purpose Output Register */ +#define FPGAMGR_GPI 0x14 /* General-Purpose Input Register */ +#define FPGAMGR_MISCI 0x18 /* Miscellaneous Input Register */ + +/* Configuration Monitor (MON) Registers */ +#define GPIO_INTEN 0x830 /* Interrupt Enable Register */ +#define GPIO_INTMASK 0x834 /* Interrupt Mask Register */ +#define GPIO_INTTYPE_LEVEL 0x838 /* Interrupt Level Register */ +#define GPIO_INT_POLARITY 0x83C /* Interrupt Polarity Register */ +#define GPIO_INTSTATUS 0x840 /* Interrupt Status Register */ +#define GPIO_RAW_INTSTATUS 0x844 /* Raw Interrupt Status Register */ +#define GPIO_PORTA_EOI 0x84C /* Clear Interrupt Register */ +#define PORTA_EOI_NS (1 << 0) +#define GPIO_EXT_PORTA 0x850 /* External Port A Register */ +#define EXT_PORTA_CDP (1 << 10) /* Configuration done */ +#define GPIO_LS_SYNC 0x860 /* Synchronization Level Register */ +#define GPIO_VER_ID_CODE 0x86C /* GPIO Version Register */ +#define GPIO_CONFIG_REG2 0x870 /* Configuration Register 2 */ +#define GPIO_CONFIG_REG1 0x874 /* Configuration Register 1 */ + +#define MSEL_PP16_FAST_NOAES_NODC 0x0 +#define MSEL_PP16_FAST_AES_NODC 0x1 +#define MSEL_PP16_FAST_AESOPT_DC 0x2 +#define MSEL_PP16_SLOW_NOAES_NODC 0x4 +#define MSEL_PP16_SLOW_AES_NODC 0x5 +#define MSEL_PP16_SLOW_AESOPT_DC 0x6 +#define MSEL_PP32_FAST_NOAES_NODC 0x8 +#define MSEL_PP32_FAST_AES_NODC 0x9 +#define MSEL_PP32_FAST_AESOPT_DC 0xa +#define MSEL_PP32_SLOW_NOAES_NODC 0xc +#define MSEL_PP32_SLOW_AES_NODC 0xd +#define MSEL_PP32_SLOW_AESOPT_DC 0xe + +#define CFGWDTH_16 0 +#define CFGWDTH_32 1 + +#define CDRATIO_1 0 +#define CDRATIO_2 1 +#define CDRATIO_4 2 +#define CDRATIO_8 3 + +#define FPGAMGR_MODE_POWEROFF 0x0 +#define FPGAMGR_MODE_RESET 0x1 +#define FPGAMGR_MODE_CONFIG 0x2 +#define FPGAMGR_MODE_INIT 0x3 +#define FPGAMGR_MODE_USER 0x4 + +struct cfgmgr_mode { + int msel; + int cfgwdth; + int cdratio; +}; + +static struct cfgmgr_mode cfgmgr_modes[] = { + { MSEL_PP16_FAST_NOAES_NODC, CFGWDTH_16, CDRATIO_1 }, + { MSEL_PP16_FAST_AES_NODC, CFGWDTH_16, CDRATIO_2 }, + { MSEL_PP16_FAST_AESOPT_DC, CFGWDTH_16, CDRATIO_4 }, + { MSEL_PP16_SLOW_NOAES_NODC, CFGWDTH_16, CDRATIO_1 }, + { MSEL_PP16_SLOW_AES_NODC, CFGWDTH_16, CDRATIO_2 }, + { MSEL_PP16_SLOW_AESOPT_DC, CFGWDTH_16, CDRATIO_4 }, + { MSEL_PP32_FAST_NOAES_NODC, CFGWDTH_32, CDRATIO_1 }, + { MSEL_PP32_FAST_AES_NODC, CFGWDTH_32, CDRATIO_4 }, + { MSEL_PP32_FAST_AESOPT_DC, CFGWDTH_32, CDRATIO_8 }, + { MSEL_PP32_SLOW_NOAES_NODC, CFGWDTH_32, CDRATIO_1 }, + { MSEL_PP32_SLOW_AES_NODC, CFGWDTH_32, CDRATIO_4 }, + { MSEL_PP32_SLOW_AESOPT_DC, CFGWDTH_32, CDRATIO_8 }, + { -1, -1, -1 }, +}; + +struct fpgamgr_softc { + struct resource *res[3]; + bus_space_tag_t bst_data; + bus_space_handle_t bsh_data; + struct cdev *mgr_cdev; + device_t dev; +}; + +static struct resource_spec fpgamgr_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_MEMORY, 1, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int +fpgamgr_state_get(struct fpgamgr_softc *sc) +{ + int reg; + + reg = READ4(sc, FPGAMGR_STAT); + reg >>= STAT_MODE_SHIFT; + reg &= STAT_MODE_MASK; + + return reg; +} + +static int +fpgamgr_state_wait(struct fpgamgr_softc *sc, int state) +{ + int tout; + + tout = 1000; + while (tout > 0) { + if (fpgamgr_state_get(sc) == state) + break; + tout--; + DELAY(10); + } + if (tout == 0) { + return (1); + } + + return (0); +} + +static int +fpga_open(struct cdev *dev, int flags __unused, + int fmt __unused, struct thread *td __unused) +{ + struct fpgamgr_softc *sc; + struct cfgmgr_mode *mode; + int msel; + int reg; + int i; + + sc = dev->si_drv1; + + msel = READ4(sc, FPGAMGR_STAT); + msel >>= STAT_MSEL_SHIFT; + msel &= STAT_MSEL_MASK; + + mode = NULL; + for (i = 0; cfgmgr_modes[i].msel != -1; i++) { + if (msel == cfgmgr_modes[i].msel) { + mode = &cfgmgr_modes[i]; + break; + } + } + if (mode == NULL) { + device_printf(sc->dev, "Can't configure: unknown mode\n"); + return (ENXIO); + } + + reg = READ4(sc, FPGAMGR_CTRL); + reg &= ~(CTRL_CDRATIO_MASK << CTRL_CDRATIO_SHIFT); + reg |= (mode->cdratio << CTRL_CDRATIO_SHIFT); + reg &= ~(CTRL_CFGWDTH_MASK << CTRL_CFGWDTH_SHIFT); + reg |= (mode->cfgwdth << CTRL_CFGWDTH_SHIFT); + reg &= ~(CTRL_NCE); + WRITE4(sc, FPGAMGR_CTRL, reg); + + /* Enable configuration */ + reg = READ4(sc, FPGAMGR_CTRL); + reg |= (CTRL_EN); + WRITE4(sc, FPGAMGR_CTRL, reg); + + /* Reset FPGA */ + reg = READ4(sc, FPGAMGR_CTRL); + reg |= (CTRL_NCONFIGPULL); + WRITE4(sc, FPGAMGR_CTRL, reg); + + /* Wait reset state */ + if (fpgamgr_state_wait(sc, FPGAMGR_MODE_RESET)) { + device_printf(sc->dev, "Can't get RESET state\n"); + return (ENXIO); + } + + /* Release from reset */ + reg = READ4(sc, FPGAMGR_CTRL); + reg &= ~(CTRL_NCONFIGPULL); + WRITE4(sc, FPGAMGR_CTRL, reg); + + if (fpgamgr_state_wait(sc, FPGAMGR_MODE_CONFIG)) { + device_printf(sc->dev, "Can't get CONFIG state\n"); + return (ENXIO); + } + + /* Clear nSTATUS edge interrupt */ + WRITE4(sc, GPIO_PORTA_EOI, PORTA_EOI_NS); + + /* Enter configuration state */ + reg = READ4(sc, FPGAMGR_CTRL); + reg |= (CTRL_AXICFGEN); + WRITE4(sc, FPGAMGR_CTRL, reg); + + return (0); +} + +static int +fpga_wait_dclk_pulses(struct fpgamgr_softc *sc, int npulses) +{ + int tout; + + /* Clear done bit, if any */ + if (READ4(sc, FPGAMGR_DCLKSTAT) != 0) + WRITE4(sc, FPGAMGR_DCLKSTAT, 0x1); + + /* Request DCLK pulses */ + WRITE4(sc, FPGAMGR_DCLKCNT, npulses); + + /* Wait finish */ + tout = 1000; + while (tout > 0) { + if (READ4(sc, FPGAMGR_DCLKSTAT) == 1) { + WRITE4(sc, FPGAMGR_DCLKSTAT, 0x1); + break; + } + tout--; + DELAY(10); + } + if (tout == 0) { + return (1); + } + + return (0); +} + +static int +fpga_close(struct cdev *dev, int flags __unused, + int fmt __unused, struct thread *td __unused) +{ + struct fpgamgr_softc *sc; + int reg; + + sc = dev->si_drv1; + + reg = READ4(sc, GPIO_EXT_PORTA); + if ((reg & EXT_PORTA_CDP) == 0) { + device_printf(sc->dev, "Err: configuration failed\n"); + return (ENXIO); + } + + /* Exit configuration state */ + reg = READ4(sc, FPGAMGR_CTRL); + reg &= ~(CTRL_AXICFGEN); + WRITE4(sc, FPGAMGR_CTRL, reg); + + /* Wait dclk pulses */ + if (fpga_wait_dclk_pulses(sc, 4)) { + device_printf(sc->dev, "Can't proceed 4 dclk pulses\n"); + return (ENXIO); + } + + if (fpgamgr_state_wait(sc, FPGAMGR_MODE_USER)) { + device_printf(sc->dev, "Can't get USER mode\n"); + return (ENXIO); + } + + /* Disable configuration */ + reg = READ4(sc, FPGAMGR_CTRL); + reg &= ~(CTRL_EN); + WRITE4(sc, FPGAMGR_CTRL, reg); + + return (0); +} + +static int +fpga_write(struct cdev *dev, struct uio *uio, int ioflag) +{ + struct fpgamgr_softc *sc; + int buffer; + + sc = dev->si_drv1; + + /* + * Device supports 4-byte copy only. + * TODO: add padding for <4 bytes. + */ + + while (uio->uio_resid > 0) { + uiomove(&buffer, 4, uio); + bus_space_write_4(sc->bst_data, sc->bsh_data, + 0x0, buffer); + } + + return (0); +} + +static int +fpga_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, + struct thread *td) +{ + + return (0); +} + +static struct cdevsw fpga_cdevsw = { + .d_version = D_VERSION, + .d_open = fpga_open, + .d_close = fpga_close, + .d_write = fpga_write, + .d_ioctl = fpga_ioctl, + .d_name = "FPGA Manager", +}; + +static int +fpgamgr_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "altr,fpga-mgr")) + return (ENXIO); + + device_set_desc(dev, "FPGA Manager"); + return (BUS_PROBE_DEFAULT); +} + +static int +fpgamgr_attach(device_t dev) +{ + struct fpgamgr_softc *sc; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (bus_alloc_resources(dev, fpgamgr_spec, sc->res)) { + device_printf(dev, "could not allocate resources\n"); + return (ENXIO); + } + + /* Memory interface */ + sc->bst_data = rman_get_bustag(sc->res[1]); + sc->bsh_data = rman_get_bushandle(sc->res[1]); + + sc->mgr_cdev = make_dev(&fpga_cdevsw, 0, UID_ROOT, GID_WHEEL, + 0600, "fpga%d", device_get_unit(sc->dev)); + + if (sc->mgr_cdev == NULL) { + device_printf(dev, "Failed to create character device.\n"); + return (ENXIO); + } + + sc->mgr_cdev->si_drv1 = sc; + + return (0); +} + +static device_method_t fpgamgr_methods[] = { + DEVMETHOD(device_probe, fpgamgr_probe), + DEVMETHOD(device_attach, fpgamgr_attach), + { 0, 0 } +}; + +static driver_t fpgamgr_driver = { + "fpgamgr", + fpgamgr_methods, + sizeof(struct fpgamgr_softc), +}; + +static devclass_t fpgamgr_devclass; + +DRIVER_MODULE(fpgamgr, simplebus, fpgamgr_driver, fpgamgr_devclass, 0, 0); diff --git a/sys/arm/altera/socfpga/socfpga_rstmgr.c b/sys/arm/altera/socfpga/socfpga_rstmgr.c new file mode 100644 index 000000000000..36a1d7558210 --- /dev/null +++ b/sys/arm/altera/socfpga/socfpga_rstmgr.c @@ -0,0 +1,259 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +/* + * SOCFPGA Reset Manager. + * Chapter 3, Cyclone V Device Handbook (CV-5V2 2014.07.22) + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +struct rstmgr_softc { + struct resource *res[1]; + bus_space_tag_t bst; + bus_space_handle_t bsh; + device_t dev; +}; + +struct rstmgr_softc *rstmgr_sc; + +static struct resource_spec rstmgr_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +enum { + RSTMGR_SYSCTL_FPGA2HPS, + RSTMGR_SYSCTL_LWHPS2FPGA, + RSTMGR_SYSCTL_HPS2FPGA +}; + +static int +l3remap(struct rstmgr_softc *sc, int remap, int enable) +{ + uint32_t addr, paddr; + bus_addr_t vaddr; + phandle_t node; + int reg; + + /* + * Control whether bridge is visible to L3 masters or not. + * Register is write-only. + */ + + reg = REMAP_MPUZERO; + if (enable) + reg |= (remap); + else + reg &= ~(remap); + + node = OF_finddevice("l3regs"); + if (node == -1) { + device_printf(sc->dev, "Can't find l3regs node\n"); + return (1); + } + + if ((OF_getprop(node, "reg", &paddr, sizeof(paddr))) > 0) { + addr = fdt32_to_cpu(paddr); + if (bus_space_map(fdtbus_bs_tag, addr, 0x4, 0, &vaddr) == 0) { + bus_space_write_4(fdtbus_bs_tag, vaddr, + L3REGS_REMAP, reg); + return (0); + } + } + + return (1); +} + +static int +rstmgr_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct rstmgr_softc *sc; + int enable; + int remap; + int err; + int reg; + int bit; + + sc = arg1; + + switch (arg2) { + case RSTMGR_SYSCTL_FPGA2HPS: + bit = BRGMODRST_FPGA2HPS; + remap = 0; + break; + case RSTMGR_SYSCTL_LWHPS2FPGA: + bit = BRGMODRST_LWHPS2FPGA; + remap = REMAP_LWHPS2FPGA; + break; + case RSTMGR_SYSCTL_HPS2FPGA: + bit = BRGMODRST_HPS2FPGA; + remap = REMAP_HPS2FPGA; + break; + default: + return (1); + }; + + reg = READ4(sc, RSTMGR_BRGMODRST); + enable = reg & bit ? 0 : 1; + + err = sysctl_handle_int(oidp, &enable, 0, req); + if (err || !req->newptr) + return (err); + + if (enable == 1) + reg &= ~(bit); + else if (enable == 0) + reg |= (bit); + else + return (EINVAL); + + WRITE4(sc, RSTMGR_BRGMODRST, reg); + l3remap(sc, remap, enable); + + return (0); +} + +int +rstmgr_warmreset(void) +{ + struct rstmgr_softc *sc; + + sc = rstmgr_sc; + if (sc == NULL) + return (1); + + /* Request warm reset */ + WRITE4(sc, RSTMGR_CTRL, + CTRL_SWWARMRSTREQ); + + return (0); +} + +static int +rstmgr_add_sysctl(struct rstmgr_softc *sc) +{ + struct sysctl_oid_list *children; + struct sysctl_ctx_list *ctx; + + ctx = device_get_sysctl_ctx(sc->dev); + children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "fpga2hps", + CTLTYPE_UINT | CTLFLAG_RW, sc, RSTMGR_SYSCTL_FPGA2HPS, + rstmgr_sysctl, "I", "Enable fpga2hps bridge"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "lwhps2fpga", + CTLTYPE_UINT | CTLFLAG_RW, sc, RSTMGR_SYSCTL_LWHPS2FPGA, + rstmgr_sysctl, "I", "Enable lwhps2fpga bridge"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "hps2fpga", + CTLTYPE_UINT | CTLFLAG_RW, sc, RSTMGR_SYSCTL_HPS2FPGA, + rstmgr_sysctl, "I", "Enable hps2fpga bridge"); + + return (0); +} + +static int +rstmgr_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "altr,rst-mgr")) + return (ENXIO); + + device_set_desc(dev, "Reset Manager"); + return (BUS_PROBE_DEFAULT); +} + +static int +rstmgr_attach(device_t dev) +{ + struct rstmgr_softc *sc; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (bus_alloc_resources(dev, rstmgr_spec, sc->res)) { + device_printf(dev, "could not allocate resources\n"); + return (ENXIO); + } + + /* Memory interface */ + sc->bst = rman_get_bustag(sc->res[0]); + sc->bsh = rman_get_bushandle(sc->res[0]); + + rstmgr_sc = sc; + rstmgr_add_sysctl(sc); + + return (0); +} + +static device_method_t rstmgr_methods[] = { + DEVMETHOD(device_probe, rstmgr_probe), + DEVMETHOD(device_attach, rstmgr_attach), + { 0, 0 } +}; + +static driver_t rstmgr_driver = { + "rstmgr", + rstmgr_methods, + sizeof(struct rstmgr_softc), +}; + +static devclass_t rstmgr_devclass; + +DRIVER_MODULE(rstmgr, simplebus, rstmgr_driver, rstmgr_devclass, 0, 0); diff --git a/sys/arm/altera/socfpga/socfpga_rstmgr.h b/sys/arm/altera/socfpga/socfpga_rstmgr.h new file mode 100644 index 000000000000..db7d2a088b40 --- /dev/null +++ b/sys/arm/altera/socfpga/socfpga_rstmgr.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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$ + */ + +#define RSTMGR_STAT 0x0 /* Status */ +#define RSTMGR_CTRL 0x4 /* Control */ +#define CTRL_SWWARMRSTREQ (1 << 1) /* Trigger warm reset */ +#define RSTMGR_COUNTS 0x8 /* Reset Cycles Count */ +#define RSTMGR_MPUMODRST 0x10 /* MPU Module Reset */ +#define RSTMGR_PERMODRST 0x14 /* Peripheral Module Reset */ +#define RSTMGR_PER2MODRST 0x18 /* Peripheral 2 Module Reset */ +#define RSTMGR_BRGMODRST 0x1C /* Bridge Module Reset */ +#define BRGMODRST_FPGA2HPS (1 << 2) +#define BRGMODRST_LWHPS2FPGA (1 << 1) +#define BRGMODRST_HPS2FPGA (1 << 0) +#define RSTMGR_MISCMODRST 0x20 /* Miscellaneous Module Reset */ + +int rstmgr_warmreset(void); diff --git a/sys/arm/arm/cpufunc_asm_armv7.S b/sys/arm/arm/cpufunc_asm_armv7.S index 93896d219c75..9fe6aa5c90d7 100644 --- a/sys/arm/arm/cpufunc_asm_armv7.S +++ b/sys/arm/arm/cpufunc_asm_armv7.S @@ -33,6 +33,8 @@ #include __FBSDID("$FreeBSD$"); +#include + .cpu cortex-a8 .Lcoherency_level: @@ -70,12 +72,12 @@ ENTRY(armv7_setttb) dsb orr r0, r0, #PT_ATTR - mcr p15, 0, r0, c2, c0, 0 /* Translation Table Base Register 0 (TTBR0) */ + mcr CP15_TTBR0(r0) isb #ifdef SMP - mcr p15, 0, r0, c8, c3, 0 /* invalidate I+D TLBs Inner Shareable*/ + mcr CP15_TLBIALLIS #else - mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */ + mcr CP15_TLBIALL #endif dsb isb @@ -85,11 +87,11 @@ END(armv7_setttb) ENTRY(armv7_tlb_flushID) dsb #ifdef SMP - mcr p15, 0, r0, c8, c3, 0 /* flush Unified TLB all entries Inner Shareable */ - mcr p15, 0, r0, c7, c1, 6 /* flush BTB Inner Shareable */ + mcr CP15_TLBIALLIS + mcr CP15_BPIALLIS #else - mcr p15, 0, r0, c8, c7, 0 /* flush Unified TLB all entries */ - mcr p15, 0, r0, c7, c5, 6 /* flush BTB */ + mcr CP15_TLBIALL + mcr CP15_BPIALL #endif dsb isb @@ -100,11 +102,11 @@ ENTRY(armv7_tlb_flushID_SE) ldr r1, .Lpage_mask bic r0, r0, r1 #ifdef SMP - mcr p15, 0, r0, c8, c3, 3 /* flush Unified TLB single entry Inner Shareable */ - mcr p15, 0, r0, c7, c1, 6 /* flush BTB Inner Shareable */ + mcr CP15_TLBIMVAAIS(r0) + mcr CP15_BPIALLIS #else - mcr p15, 0, r0, c8, c7, 1 /* flush Unified TLB single entry */ - mcr p15, 0, r0, c7, c5, 6 /* flush BTB */ + mcr CP15_TLBIMVA(r0) + mcr CP15_BPIALL #endif dsb isb @@ -149,7 +151,7 @@ Loop3: orr r6, r6, r7, lsl r2 /* Clean and invalidate data cache by way/index */ - mcr p15, 0, r6, c7, c14, 2 + mcr CP15_DCCISW(r6) subs r9, r9, #1 bge Loop3 subs r7, r7, #1 @@ -168,9 +170,9 @@ ENTRY(armv7_idcache_wbinv_all) stmdb sp!, {lr} bl armv7_dcache_wbinv_all #ifdef SMP - mcr p15, 0, r0, c7, c1, 0 /* Invalidate all I caches to PoU (ICIALLUIS) */ + mcr CP15_ICIALLUIS #else - mcr p15, 0, r0, c7, c5, 0 /* Invalidate all I caches to PoU (ICIALLU) */ + mcr CP15_ICIALLU #endif dsb isb @@ -191,7 +193,7 @@ ENTRY(armv7_dcache_wb_range) add r1, r1, r2 bic r0, r0, r3 .Larmv7_wb_next: - mcr p15, 0, r0, c7, c10, 1 /* Clean D cache SE with VA */ + mcr CP15_DCCMVAC(r0) add r0, r0, ip subs r1, r1, ip bhi .Larmv7_wb_next @@ -206,7 +208,7 @@ ENTRY(armv7_dcache_wbinv_range) add r1, r1, r2 bic r0, r0, r3 .Larmv7_wbinv_next: - mcr p15, 0, r0, c7, c14, 1 /* Purge D cache SE with VA */ + mcr CP15_DCCIMVAC(r0) add r0, r0, ip subs r1, r1, ip bhi .Larmv7_wbinv_next @@ -225,7 +227,7 @@ ENTRY(armv7_dcache_inv_range) add r1, r1, r2 bic r0, r0, r3 .Larmv7_inv_next: - mcr p15, 0, r0, c7, c6, 1 /* Invalidate D cache SE with VA */ + mcr CP15_DCIMVAC(r0) add r0, r0, ip subs r1, r1, ip bhi .Larmv7_inv_next @@ -240,8 +242,8 @@ ENTRY(armv7_idcache_wbinv_range) add r1, r1, r2 bic r0, r0, r3 .Larmv7_id_wbinv_next: - mcr p15, 0, r0, c7, c5, 1 /* Invalidate I cache SE with VA */ - mcr p15, 0, r0, c7, c14, 1 /* Purge D cache SE with VA */ + mcr CP15_ICIMVAU(r0) + mcr CP15_DCCIMVAC(r0) add r0, r0, ip subs r1, r1, ip bhi .Larmv7_id_wbinv_next @@ -252,9 +254,9 @@ END(armv7_idcache_wbinv_range) ENTRY_NP(armv7_icache_sync_all) #ifdef SMP - mcr p15, 0, r0, c7, c1, 0 /* Invalidate all I cache to PoU Inner Shareable */ + mcr CP15_ICIALLUIS #else - mcr p15, 0, r0, c7, c5, 0 /* Invalidate all I cache to PoU (ICIALLU) */ + mcr CP15_ICIALLU #endif isb /* instruction synchronization barrier */ dsb /* data synchronization barrier */ @@ -264,8 +266,8 @@ END(armv7_icache_sync_all) ENTRY_NP(armv7_icache_sync_range) ldr ip, .Larmv7_line_size .Larmv7_sync_next: - mcr p15, 0, r0, c7, c5, 1 /* Invalidate I cache SE with VA */ - mcr p15, 0, r0, c7, c10, 1 /* Clean D cache SE with VA */ + mcr CP15_ICIMVAU(r0) + mcr CP15_DCCMVAC(r0) add r0, r0, ip subs r1, r1, ip bhi .Larmv7_sync_next @@ -283,13 +285,13 @@ END(armv7_cpu_sleep) ENTRY(armv7_context_switch) dsb orr r0, r0, #PT_ATTR - - mcr p15, 0, r0, c2, c0, 0 /* set the new TTB */ + + mcr CP15_TTBR0(r0) isb #ifdef SMP - mcr p15, 0, r0, c8, c3, 0 /* and flush the I+D tlbs Inner Sharable */ + mcr CP15_TLBIALLIS #else - mcr p15, 0, r0, c8, c7, 0 /* and flush the I+D tlbs */ + mcr CP15_TLBIALL #endif dsb isb @@ -309,12 +311,12 @@ ENTRY(armv7_sev) END(armv7_sev) ENTRY(armv7_auxctrl) - mrc p15, 0, r2, c1, c0, 1 + mrc CP15_ACTLR(r2) bic r3, r2, r0 /* Clear bits */ eor r3, r3, r1 /* XOR bits */ teq r2, r3 - mcrne p15, 0, r3, c1, c0, 1 + mcrne CP15_ACTLR(r3) mov r0, r2 RET END(armv7_auxctrl) @@ -325,8 +327,8 @@ END(armv7_auxctrl) */ ENTRY(armv7_idcache_inv_all) mov r0, #0 - mcr p15, 2, r0, c0, c0, 0 @ set cache level to L1 - mrc p15, 1, r0, c0, c0, 0 @ read CCSIDR + mcr CP15_CSSELR(r0) @ set cache level to L1 + mrc CP15_CCSIDR(r0) ubfx r2, r0, #13, #15 @ get num sets - 1 from CCSIDR ubfx r3, r0, #3, #10 @ get numways - 1 from CCSIDR @@ -345,7 +347,7 @@ ENTRY(armv7_idcache_inv_all) mov r2, ip @ r2 now contains set way decr /* r3 = ways/sets, r2 = way decr, r1 = set decr, r0 and ip are free */ -1: mcr p15, 0, r3, c7, c6, 2 @ invalidate line +1: mcr CP15_DCISW(r3) @ invalidate line movs r0, r3 @ get current way/set beq 2f @ at 0 means we are done. movs r0, r0, lsl #10 @ clear way bits leaving only set bits @@ -355,7 +357,7 @@ ENTRY(armv7_idcache_inv_all) 2: dsb @ wait for stores to finish mov r0, #0 @ and ... - mcr p15, 0, r0, c7, c5, 0 @ invalidate instruction+branch cache + mcr CP15_ICIALLU @ invalidate instruction+branch cache isb @ instruction sync barrier bx lr @ return END(armv7_idcache_inv_all) diff --git a/sys/arm/arm/cpufunc_asm_sheeva.S b/sys/arm/arm/cpufunc_asm_sheeva.S index bd731fbddfe8..99b09a959c06 100644 --- a/sys/arm/arm/cpufunc_asm_sheeva.S +++ b/sys/arm/arm/cpufunc_asm_sheeva.S @@ -29,6 +29,7 @@ * SUCH DAMAGE. */ +#include #include __FBSDID("$FreeBSD$"); @@ -42,7 +43,7 @@ __FBSDID("$FreeBSD$"); ENTRY(sheeva_setttb) /* Disable irqs */ mrs r2, cpsr - orr r3, r2, #I32_bit | F32_bit + orr r3, r2, #PSR_I | PSR_F msr cpsr_c, r3 mov r1, #0 @@ -87,7 +88,7 @@ ENTRY(sheeva_dcache_wbinv_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 5, r0, c15, c15, 0 /* Clean and inv zone start address */ mcr p15, 5, r2, c15, c15, 1 /* Clean and inv zone end address */ @@ -130,7 +131,7 @@ ENTRY(sheeva_idcache_wbinv_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 5, r0, c15, c15, 0 /* Clean and inv zone start address */ mcr p15, 5, r2, c15, c15, 1 /* Clean and inv zone end address */ @@ -182,7 +183,7 @@ ENTRY(sheeva_dcache_inv_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 5, r0, c15, c14, 0 /* Inv zone start address */ mcr p15, 5, r2, c15, c14, 1 /* Inv zone end address */ @@ -225,7 +226,7 @@ ENTRY(sheeva_dcache_wb_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 5, r0, c15, c13, 0 /* Clean zone start address */ mcr p15, 5, r2, c15, c13, 1 /* Clean zone end address */ @@ -268,7 +269,7 @@ ENTRY(sheeva_l2cache_wbinv_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 1, r0, c15, c9, 4 /* Clean L2 zone start address */ mcr p15, 1, r2, c15, c9, 5 /* Clean L2 zone end address */ @@ -313,7 +314,7 @@ ENTRY(sheeva_l2cache_inv_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 1, r0, c15, c11, 4 /* Inv L2 zone start address */ mcr p15, 1, r2, c15, c11, 5 /* Inv L2 zone end address */ @@ -356,7 +357,7 @@ ENTRY(sheeva_l2cache_wb_range) add r3, r0, ip sub r2, r3, #1 /* Disable irqs */ - orr r3, lr, #I32_bit | F32_bit + orr r3, lr, #PSR_I | PSR_F msr cpsr_c, r3 mcr p15, 1, r0, c15, c9, 4 /* Clean L2 zone start address */ mcr p15, 1, r2, c15, c9, 5 /* Clean L2 zone end address */ @@ -379,7 +380,7 @@ END(sheeva_l2cache_wb_range) ENTRY(sheeva_l2cache_wbinv_all) /* Disable irqs */ mrs r1, cpsr - orr r2, r1, #I32_bit | F32_bit + orr r2, r1, #PSR_I | PSR_F msr cpsr_c, r2 mov r0, #0 diff --git a/sys/arm/arm/cpufunc_asm_xscale.S b/sys/arm/arm/cpufunc_asm_xscale.S index fb99dea7cce4..3031b8c150f9 100644 --- a/sys/arm/arm/cpufunc_asm_xscale.S +++ b/sys/arm/arm/cpufunc_asm_xscale.S @@ -71,7 +71,7 @@ * * XScale assembly functions for CPU / MMU / TLB specific operations */ - +#include #include __FBSDID("$FreeBSD$"); @@ -135,7 +135,7 @@ END(xscale_control) ENTRY(xscale_setttb) #ifdef CACHE_CLEAN_BLOCK_INTR mrs r3, cpsr - orr r1, r3, #(I32_bit | F32_bit) + orr r1, r3, #(PSR_I | PSR_F) msr cpsr_fsxc, r1 #else ldr r3, .Lblock_userspace_access @@ -267,7 +267,7 @@ _C_LABEL(xscale_minidata_clean_size): #ifdef CACHE_CLEAN_BLOCK_INTR #define XSCALE_CACHE_CLEAN_BLOCK \ mrs r3, cpsr ; \ - orr r0, r3, #(I32_bit | F32_bit) ; \ + orr r0, r3, #(PSR_I | PSR_F) ; \ msr cpsr_fsxc, r0 #define XSCALE_CACHE_CLEAN_UNBLOCK \ diff --git a/sys/arm/arm/cpufunc_asm_xscale_c3.S b/sys/arm/arm/cpufunc_asm_xscale_c3.S index 0fdb39c2cd64..6766a327156a 100644 --- a/sys/arm/arm/cpufunc_asm_xscale_c3.S +++ b/sys/arm/arm/cpufunc_asm_xscale_c3.S @@ -73,6 +73,7 @@ * XScale core 3 assembly functions for CPU / MMU / TLB specific operations */ +#include #include __FBSDID("$FreeBSD$"); @@ -122,7 +123,7 @@ __FBSDID("$FreeBSD$"); #define XSCALE_CACHE_CLEAN_BLOCK \ stmfd sp!, {r4} ; \ mrs r4, cpsr ; \ - orr r0, r4, #(I32_bit | F32_bit) ; \ + orr r0, r4, #(PSR_I | PSR_F) ; \ msr cpsr_fsxc, r0 #define XSCALE_CACHE_CLEAN_UNBLOCK \ @@ -350,7 +351,7 @@ END(xscalec3_l2cache_flush_rng) ENTRY(xscalec3_setttb) #ifdef CACHE_CLEAN_BLOCK_INTR mrs r3, cpsr - orr r1, r3, #(I32_bit | F32_bit) + orr r1, r3, #(PSR_I | PSR_F) msr cpsr_fsxc, r1 #else ldr r3, .Lblock_userspace_access diff --git a/sys/arm/arm/exception.S b/sys/arm/arm/exception.S index 7f79654d3719..5cef9657600c 100644 --- a/sys/arm/arm/exception.S +++ b/sys/arm/arm/exception.S @@ -244,12 +244,12 @@ __FBSDID("$FreeBSD$"); #define DO_AST \ ldr r0, [sp] /* Get the SPSR from stack */ ;\ mrs r4, cpsr /* save CPSR */ ;\ - orr r1, r4, #(I32_bit|F32_bit) ;\ + orr r1, r4, #(PSR_I|PSR_F) ;\ msr cpsr_c, r1 /* Disable interrupts */ ;\ and r0, r0, #(PSR_MODE) /* Returning to USR mode? */ ;\ teq r0, #(PSR_USR32_MODE) ;\ bne 2f /* Nope, get out now */ ;\ - bic r4, r4, #(I32_bit|F32_bit) ;\ + bic r4, r4, #(PSR_I|PSR_F) ;\ 1: GET_CURTHREAD_PTR(r5) ;\ ldr r1, [r5, #(TD_FLAGS)] ;\ and r1, r1, #(TDF_ASTPENDING|TDF_NEEDRESCHED) ;\ @@ -258,7 +258,7 @@ __FBSDID("$FreeBSD$"); msr cpsr_c, r4 /* Restore interrupts */ ;\ mov r0, sp ;\ bl _C_LABEL(ast) /* ast(frame) */ ;\ - orr r0, r4, #(I32_bit|F32_bit) ;\ + orr r0, r4, #(PSR_I|PSR_F) ;\ msr cpsr_c, r0 ;\ b 1b ;\ 2: @@ -382,7 +382,7 @@ END(irq_entry) */ ASENTRY_NP(fiq_entry) mrs r8, cpsr /* FIQ handling isn't supported, */ - bic r8, #(F32_bit) /* just disable FIQ and return. */ + bic r8, #(PSR_F) /* just disable FIQ and return. */ msr cpsr_c, r8 /* The r8 we trash here is the */ subs pc, lr, #4 /* banked FIQ-mode r8. */ END(fiq_entry) diff --git a/sys/arm/arm/fiq.c b/sys/arm/arm/fiq.c index d9dbb5e155f9..08f867083e9e 100644 --- a/sys/arm/arm/fiq.c +++ b/sys/arm/arm/fiq.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -54,9 +55,6 @@ TAILQ_HEAD(, fiqhandler) fiqhandler_stack = extern char *fiq_nullhandler_code; extern uint32_t fiq_nullhandler_size; -#define IRQ_BIT I32_bit -#define FIQ_BIT F32_bit - /* * fiq_installhandler: * @@ -102,7 +100,7 @@ fiq_claim(struct fiqhandler *fh) if (fh->fh_size > 0x100) return (EFBIG); - oldirqstate = disable_interrupts(FIQ_BIT); + oldirqstate = disable_interrupts(PSR_F); if ((ofh = TAILQ_FIRST(&fiqhandler_stack)) != NULL) { if ((ofh->fh_flags & FH_CANPUSH) == 0) { @@ -125,7 +123,7 @@ fiq_claim(struct fiqhandler *fh) fiq_installhandler(fh->fh_func, fh->fh_size); /* Make sure FIQs are enabled when we return. */ - oldirqstate &= ~FIQ_BIT; + oldirqstate &= ~PSR_F; out: restore_interrupts(oldirqstate); @@ -143,7 +141,7 @@ fiq_release(struct fiqhandler *fh) u_int oldirqstate; struct fiqhandler *ofh; - oldirqstate = disable_interrupts(FIQ_BIT); + oldirqstate = disable_interrupts(PSR_F); /* * If we are the currently active FIQ handler, then we @@ -167,7 +165,7 @@ fiq_release(struct fiqhandler *fh) fiq_installhandler(fiq_nullhandler_code, fiq_nullhandler_size); /* Make sure FIQs are disabled when we return. */ - oldirqstate |= FIQ_BIT; + oldirqstate |= PSR_F; } restore_interrupts(oldirqstate); diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c index df7d0cd0b9b7..d9b42fcedae0 100644 --- a/sys/arm/arm/generic_timer.c +++ b/sys/arm/arm/generic_timer.c @@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$"); #define GT_CNTKCTL_PL0PTEN (1 << 9) /* PL0 Physical timer reg access */ #define GT_CNTKCTL_PL0VTEN (1 << 8) /* PL0 Virtual timer reg access */ -#define GT_CNTKCTL_EVNTI (1 << 4) /* Virtual counter event bits */ +#define GT_CNTKCTL_EVNTI (0xf << 4) /* Virtual counter event bits */ #define GT_CNTKCTL_EVNTDIR (1 << 3) /* Virtual counter event transition */ #define GT_CNTKCTL_EVNTEN (1 << 2) /* Enables virtual counter events */ #define GT_CNTKCTL_PL0VCTEN (1 << 1) /* PL0 CNTVCT and CNTFRQ access */ @@ -78,6 +78,7 @@ struct arm_tmr_softc { void *ihl[4]; uint32_t clkfreq; struct eventtimer et; + bool physical; }; static struct arm_tmr_softc *arm_tmr_sc = NULL; @@ -101,81 +102,83 @@ static struct timecounter arm_tmr_timecount = { .tc_quality = 1000, }; -static inline int +static int get_freq(void) { uint32_t val; + /* cntfrq */ __asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (val)); return (val); } -static inline int -set_freq(uint32_t val) -{ - - __asm volatile("mcr p15, 0, %[val], c14, c0, 0" : : - [val] "r" (val)); - isb(); - - return (val); -} - - -static inline long -get_cntpct(void) +static long +get_cntxct(bool physical) { uint64_t val; - __asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (val)); + isb(); + if (physical) + /* cntpct */ + __asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (val)); + else + /* cntvct */ + __asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (val)); return (val); } -static inline int -set_ctrl(uint32_t val) +static int +set_ctrl(uint32_t val, bool physical) { - __asm volatile("mcr p15, 0, %[val], c14, c2, 1" : : - [val] "r" (val)); + if (physical) + /* cntp_ctl */ + __asm volatile("mcr p15, 0, %[val], c14, c2, 1" : : + [val] "r" (val)); + else + /* cntv_ctl */ + __asm volatile("mcr p15, 0, %[val], c14, c3, 1" : : + [val] "r" (val)); isb(); return (0); } -static inline int -set_tval(uint32_t val) +static int +set_tval(uint32_t val, bool physical) { - __asm volatile("mcr p15, 0, %[val], c14, c2, 0" : : - [val] "r" (val)); + if (physical) + /* cntp_tval */ + __asm volatile("mcr p15, 0, %[val], c14, c2, 0" : : + [val] "r" (val)); + else + /* cntv_tval */ + __asm volatile("mcr p15, 0, %[val], c14, c3, 0" : : + [val] "r" (val)); isb(); return (0); } -static inline int -get_ctrl(void) +static int +get_ctrl(bool physical) { uint32_t val; - __asm volatile("mrc p15, 0, %0, c14, c2, 1" : "=r" (val)); + if (physical) + /* cntp_ctl */ + __asm volatile("mrc p15, 0, %0, c14, c2, 1" : "=r" (val)); + else + /* cntv_ctl */ + __asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r" (val)); return (val); } -static inline int -get_tval(void) -{ - uint32_t val; - - __asm volatile("mrc p15, 0, %0, c14, c2, 0" : "=r" (val)); - - return (val); -} - -static inline void +static void disable_user_access(void) { uint32_t cntkctl; @@ -191,7 +194,7 @@ static unsigned arm_tmr_get_timecount(struct timecounter *tc) { - return (get_cntpct()); + return (get_cntxct(arm_tmr_sc->physical)); } static int @@ -204,11 +207,11 @@ arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period) if (first != 0) { counts = ((uint32_t)et->et_frequency * first) >> 32; - ctrl = get_ctrl(); + ctrl = get_ctrl(sc->physical); ctrl &= ~GT_CTRL_INT_MASK; ctrl |= GT_CTRL_ENABLE; - set_tval(counts); - set_ctrl(ctrl); + set_tval(counts, sc->physical); + set_ctrl(ctrl, sc->physical); return (0); } @@ -219,11 +222,14 @@ arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period) static int arm_tmr_stop(struct eventtimer *et) { + struct arm_tmr_softc *sc; int ctrl; - ctrl = get_ctrl(); + sc = (struct arm_tmr_softc *)et->et_priv; + + ctrl = get_ctrl(sc->physical); ctrl &= GT_CTRL_ENABLE; - set_ctrl(ctrl); + set_ctrl(ctrl, sc->physical); return (0); } @@ -235,10 +241,10 @@ arm_tmr_intr(void *arg) int ctrl; sc = (struct arm_tmr_softc *)arg; - ctrl = get_ctrl(); + ctrl = get_ctrl(sc->physical); if (ctrl & GT_CTRL_INT_STAT) { ctrl |= GT_CTRL_INT_MASK; - set_ctrl(ctrl); + set_ctrl(ctrl, sc->physical); } if (sc->et.et_active) @@ -295,12 +301,14 @@ arm_tmr_attach(device_t dev) if (bus_alloc_resources(dev, timer_spec, sc->res)) { device_printf(dev, "could not allocate resources\n"); return (ENXIO); - }; + } + + sc->physical = true; arm_tmr_sc = sc; - /* Setup secure and non-secure IRQs handler */ - for (i = 0; i < 2; i++) { + /* Setup secure, non-secure and virtual IRQs handler */ + for (i = 0; i < 3; i++) { error = bus_setup_intr(dev, sc->res[i], INTR_TYPE_CLK, arm_tmr_intr, NULL, sc, &sc->ihl[i]); if (error) { @@ -381,10 +389,10 @@ DELAY(int usec) else counts = usec * counts_per_usec; - first = get_cntpct(); + first = get_cntxct(arm_tmr_sc->physical); while (counts > 0) { - last = get_cntpct(); + last = get_cntxct(arm_tmr_sc->physical); counts -= (int32_t)(last - first); first = last; } diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c index 9a9275b08d6a..9e15f8bc2858 100644 --- a/sys/arm/arm/gic.c +++ b/sys/arm/arm/gic.c @@ -83,7 +83,11 @@ __FBSDID("$FreeBSD$"); #define GICC_ABPR 0x001C /* v1 ICCABPR */ #define GICC_IIDR 0x00FC /* v1 ICCIIDR*/ -#define GIC_LAST_IPI 15 /* Irqs 0-15 are IPIs. */ +#define GIC_FIRST_IPI 0 /* Irqs 0-15 are SGIs/IPIs. */ +#define GIC_LAST_IPI 15 +#define GIC_FIRST_PPI 16 /* Irqs 16-31 are private (per */ +#define GIC_LAST_PPI 31 /* core) peripheral interrupts. */ +#define GIC_FIRST_SPI 32 /* Irqs 32+ are shared peripherals. */ /* First bit is a polarity bit (0 - low, 1 - high) */ #define GICD_ICFGR_POL_LOW (0 << 0) @@ -127,6 +131,17 @@ static int gic_config_irq(int irq, enum intr_trigger trig, enum intr_polarity pol); static void gic_post_filter(void *); +static struct ofw_compat_data compat_data[] = { + {"arm,gic", true}, /* Non-standard, used in FreeBSD dts. */ + {"arm,gic-400", true}, + {"arm,cortex-a15-gic", true}, + {"arm,cortex-a9-gic", true}, + {"arm,cortex-a7-gic", true}, + {"arm,arm11mp-gic", true}, + {"brcm,brahma-b15-gic", true}, + {NULL, false} +}; + static int arm_gic_probe(device_t dev) { @@ -134,7 +149,7 @@ arm_gic_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "arm,gic")) + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) return (ENXIO); device_set_desc(dev, "ARM Generic Interrupt Controller"); return (BUS_PROBE_DEFAULT); @@ -166,11 +181,59 @@ gic_init_secondary(void) /* Enable interrupt distribution */ gic_d_write_4(GICD_CTLR, 0x01); - /* Activate IRQ 29-30, ie private timer (secure & non-secure) IRQs */ + /* + * Activate the timer interrupts: virtual, secure, and non-secure. + */ + gic_d_write_4(GICD_ISENABLER(27 >> 5), (1UL << (27 & 0x1F))); gic_d_write_4(GICD_ISENABLER(29 >> 5), (1UL << (29 & 0x1F))); gic_d_write_4(GICD_ISENABLER(30 >> 5), (1UL << (30 & 0x1F))); } +int +gic_decode_fdt(uint32_t iparent, uint32_t *intr, int *interrupt, + int *trig, int *pol) +{ + static u_int num_intr_cells; + + if (num_intr_cells == 0) { + if (OF_searchencprop(OF_node_from_xref(iparent), + "#interrupt-cells", &num_intr_cells, + sizeof(num_intr_cells)) == -1) { + num_intr_cells = 1; + } + } + + if (num_intr_cells == 1) { + *interrupt = fdt32_to_cpu(intr[0]); + *trig = INTR_TRIGGER_CONFORM; + *pol = INTR_POLARITY_CONFORM; + } else { + if (intr[0] == 0) + *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_SPI; + else + *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_PPI; + /* + * In intr[2], bits[3:0] are trigger type and level flags. + * 1 = low-to-high edge triggered + * 2 = high-to-low edge triggered + * 4 = active high level-sensitive + * 8 = active low level-sensitive + * The hardware only supports active-high-level or rising-edge. + */ + if (intr[2] & 0x0a) { + printf("unsupported trigger/polarity configuration " + "0x%2x\n", intr[2] & 0x0f); + return (ENOTSUP); + } + *pol = INTR_POLARITY_CONFORM; + if (intr[2] & 0x01) + *trig = INTR_TRIGGER_EDGE; + else + *trig = INTR_TRIGGER_LEVEL; + } + return (0); +} + static int arm_gic_attach(device_t dev) { @@ -266,6 +329,8 @@ static devclass_t arm_gic_devclass; EARLY_DRIVER_MODULE(gic, simplebus, arm_gic_driver, arm_gic_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); +EARLY_DRIVER_MODULE(gic, ofwbus, arm_gic_driver, arm_gic_devclass, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); static void gic_post_filter(void *arg) diff --git a/sys/arm/arm/locore.S b/sys/arm/arm/locore.S index ff2ae1b36f1d..d245e2a9f07d 100644 --- a/sys/arm/arm/locore.S +++ b/sys/arm/arm/locore.S @@ -88,7 +88,7 @@ ASENTRY_NP(_start) /* Make sure interrupts are disabled. */ mrs r7, cpsr - orr r7, r7, #(I32_bit|F32_bit) + orr r7, r7, #(PSR_I | PSR_F) msr cpsr_c, r7 #if defined (FLASHADDR) && defined(LOADERRAMADDR) @@ -127,10 +127,6 @@ Lram_offset: .word from_ram-_C_LABEL(_start) from_ram: nop #endif - adr r7, Lunmapped - bic r7, r7, #0xf0000000 - orr r7, r7, #PHYSADDR - disable_mmu: /* Disable MMU for a while */ @@ -144,7 +140,8 @@ disable_mmu: nop nop nop - mov pc, r7 + CPWAIT(r0) + Lunmapped: /* * Build page table from scratch. @@ -152,21 +149,7 @@ Lunmapped: /* Find the delta between VA and PA */ adr r0, Lpagetable - ldr r1, [r0] - sub r2, r1, r0 - /* At this point: r2 = VA - PA */ - - /* - * Find the physical address of the table. After these two - * instructions: - * r1 = va(pagetable) - * - * r0 = va(pagetable) - (VA - PA) - * = va(pagetable) - VA + PA - * = pa(pagetable) - */ - ldr r1, [r0, #4] - sub r0, r1, r2 + bl translate_va_to_pa #ifndef _ARM_ARCH_6 /* @@ -289,6 +272,41 @@ virt_done: /* NOTREACHED */ END(_start) +#define VA_TO_PA_POINTER(name, table) \ +name: ;\ + .word . ;\ + .word table + +/* + * Returns the physical address of a magic va to pa pointer. + * r0 - The pagetable data pointer. This must be built using the + * VA_TO_PA_POINTER macro. + * e.g. + * VA_TO_PA_POINTER(Lpagetable, pagetable) + * ... + * adr r0, Lpagetable + * bl translate_va_to_pa + * r0 will now contain the physical address of pagetable + * r1, r2 - Trashed + */ +translate_va_to_pa: + ldr r1, [r0] + sub r2, r1, r0 + /* At this point: r2 = VA - PA */ + + /* + * Find the physical address of the table. After these two + * instructions: + * r1 = va(pagetable) + * + * r0 = va(pagetable) - (VA - PA) + * = va(pagetable) - VA + PA + * = pa(pagetable) + */ + ldr r1, [r0, #4] + sub r0, r1, r2 + RET + /* * Builds the page table * r0 - The table base address @@ -320,14 +338,8 @@ build_pagetables: RET -Lpagetable: - .word . - .word pagetable +VA_TO_PA_POINTER(Lpagetable, pagetable) -Lvirtaddr: - .word KERNVIRTADDR -Lphysaddr: - .word KERNPHYSADDR Lreal_start: .word _start Lend: @@ -368,14 +380,13 @@ pagetable: .Lmpvirt_done: .word mpvirt_done -Lstartup_pagetable_secondary: - .word temp_pagetable +VA_TO_PA_POINTER(Lstartup_pagetable_secondary, temp_pagetable) ASENTRY_NP(mpentry) /* Make sure interrupts are disabled. */ mrs r7, cpsr - orr r7, r7, #(I32_bit|F32_bit) + orr r7, r7, #(PSR_I | PSR_F) msr cpsr_c, r7 /* Disable MMU. It should be disabled already, but make sure. */ @@ -396,10 +407,12 @@ ASENTRY_NP(mpentry) bl armv7_idcache_inv_all /* Modifies r0-r3, ip */ #endif - ldr r0, Lstartup_pagetable_secondary - bic r0, r0, #0xf0000000 - orr r0, r0, #PHYSADDR + /* Load the page table physical address */ + adr r0, Lstartup_pagetable_secondary + bl translate_va_to_pa + /* Load the address the secondary page table */ ldr r0, [r0] + orr r0, r0, #2 /* Set TTB shared memory flag */ mcr p15, 0, r0, c2, c0, 0 /* Set TTB */ mcr p15, 0, r0, c8, c7, 0 /* Flush TLB */ @@ -453,7 +466,7 @@ ENTRY_NP(cpu_halt) mrs r2, cpsr bic r2, r2, #(PSR_MODE) orr r2, r2, #(PSR_SVC32_MODE) - orr r2, r2, #(I32_bit | F32_bit) + orr r2, r2, #(PSR_I | PSR_F) msr cpsr_fsxc, r2 ldr r4, .Lcpu_reset_address diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 94d708163446..98c424e21953 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -111,6 +111,10 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef DDB +#include +#endif + #ifdef DEBUG #define debugf(fmt, args...) printf(fmt, ##args) #else @@ -131,9 +135,6 @@ int _min_memcpy_size = 0; int _min_bzero_size = 0; extern int *end; -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif #ifdef FDT /* @@ -620,7 +621,7 @@ spinlock_enter(void) td = curthread; if (td->td_md.md_spinlock_count == 0) { - cspr = disable_interrupts(I32_bit | F32_bit); + cspr = disable_interrupts(PSR_I | PSR_F); td->td_md.md_spinlock_count = 1; td->td_md.md_saved_cspr = cspr; } else @@ -747,7 +748,7 @@ sys_sigreturn(td, uap) */ spsr = uc.uc_mcontext.__gregs[_REG_CPSR]; if ((spsr & PSR_MODE) != PSR_USR32_MODE || - (spsr & (I32_bit | F32_bit)) != 0) + (spsr & (PSR_I | PSR_F)) != 0) return (EINVAL); /* Restore register context. */ set_mcontext(td, &uc.uc_mcontext); @@ -817,8 +818,7 @@ fake_preload_metadata(struct arm_boot_params *abp __unused) lastaddr = *(uint32_t *)(KERNVIRTADDR + 8); zend = lastaddr; zstart = *(uint32_t *)(KERNVIRTADDR + 4); - ksym_start = zstart; - ksym_end = zend; + db_fetch_ksymtab(zstart, zend); } else #endif lastaddr = (vm_offset_t)&end; @@ -912,6 +912,10 @@ freebsd_parse_boot_param(struct arm_boot_params *abp) vm_offset_t lastaddr = 0; void *mdp; void *kmdp; +#ifdef DDB + vm_offset_t ksym_start; + vm_offset_t ksym_end; +#endif /* * Mask metadata pointer: it is supposed to be on page boundary. If @@ -934,6 +938,7 @@ freebsd_parse_boot_param(struct arm_boot_params *abp) #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); + db_fetch_ksymtab(ksym_start, ksym_end); #endif preload_addr_relocate = KERNVIRTADDR - abp->abp_physaddr; return lastaddr; diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index 85ea2827c25c..13f32428b65d 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -154,7 +154,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) sz -= len; } else { for (i = 0; i < len; i += PAGE_SIZE) - dump_va = pmap_kenter_temp(pa + i, + dump_va = pmap_kenter_temporary(pa + i, (i + fragsz) >> PAGE_SHIFT); fragsz += len; pa += len; @@ -244,7 +244,7 @@ minidumpsys(struct dumperinfo *di) } if (pmap_pde_v(pdp) && pmap_pde_page(pdp)) { /* Set bit for each valid page in this 1MB block */ - addr = pmap_kenter_temp(*pdp & L1_C_ADDR_MASK, 0); + addr = pmap_kenter_temporary(*pdp & L1_C_ADDR_MASK, 0); pt = (pt_entry_t*)(addr + (((uint32_t)*pdp & L1_C_ADDR_MASK) & PAGE_MASK)); for (k = 0; k < 256; k++) { diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 6b16ad3fb26b..a1b29c112cb4 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -236,7 +237,7 @@ init_secondary(int cpu) for (int i = start; i <= end; i++) arm_unmask_irq(i); - enable_interrupts(I32_bit); + enable_interrupts(PSR_I); loop_counter = 0; while (smp_started == 0) { diff --git a/sys/arm/arm/mpcore_timer.c b/sys/arm/arm/mpcore_timer.c index 3f87a2a94452..62c5344a0069 100644 --- a/sys/arm/arm/mpcore_timer.c +++ b/sys/arm/arm/mpcore_timer.c @@ -97,36 +97,25 @@ __FBSDID("$FreeBSD$"); #define GBL_TIMER_INTR_EVENT (1UL << 0) struct arm_tmr_softc { - struct resource * tmr_res[4]; - bus_space_tag_t prv_bst; - bus_space_tag_t gbl_bst; - bus_space_handle_t prv_bsh; - bus_space_handle_t gbl_bsh; + device_t dev; + int irqrid; + int memrid; + struct resource * gbl_mem; + struct resource * prv_mem; + struct resource * prv_irq; uint64_t clkfreq; struct eventtimer et; }; -static struct resource_spec arm_tmr_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Global registers */ - { SYS_RES_IRQ, 0, RF_ACTIVE }, /* Global timer interrupt (unused) */ - { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* Private (per-CPU) registers */ - { SYS_RES_IRQ, 1, RF_ACTIVE }, /* Private timer interrupt */ - { -1, 0 } -}; - -static struct arm_tmr_softc *arm_tmr_sc = NULL; - -static uint64_t platform_arm_tmr_freq = 0; - -#define tmr_prv_read_4(reg) \ - bus_space_read_4(arm_tmr_sc->prv_bst, arm_tmr_sc->prv_bsh, reg) -#define tmr_prv_write_4(reg, val) \ - bus_space_write_4(arm_tmr_sc->prv_bst, arm_tmr_sc->prv_bsh, reg, val) -#define tmr_gbl_read_4(reg) \ - bus_space_read_4(arm_tmr_sc->gbl_bst, arm_tmr_sc->gbl_bsh, reg) -#define tmr_gbl_write_4(reg, val) \ - bus_space_write_4(arm_tmr_sc->gbl_bst, arm_tmr_sc->gbl_bsh, reg, val) +static struct eventtimer *arm_tmr_et; +static struct timecounter *arm_tmr_tc; +static uint64_t arm_tmr_freq; +static boolean_t arm_tmr_freq_varies; +#define tmr_prv_read_4(sc, reg) bus_read_4((sc)->prv_mem, reg) +#define tmr_prv_write_4(sc, reg, val) bus_write_4((sc)->prv_mem, reg, val) +#define tmr_gbl_read_4(sc, reg) bus_read_4((sc)->gbl_mem, reg) +#define tmr_gbl_write_4(sc, reg, val) bus_write_4((sc)->gbl_mem, reg, val) static timecounter_get_t arm_tmr_get_timecount; @@ -139,6 +128,21 @@ static struct timecounter arm_tmr_timecount = { .tc_quality = 800, }; +#define TMR_GBL 0x01 +#define TMR_PRV 0x02 +#define TMR_BOTH (TMR_GBL | TMR_PRV) +#define TMR_NONE 0 + +static struct ofw_compat_data compat_data[] = { + {"arm,mpcore-timers", TMR_BOTH}, /* Non-standard, FreeBSD. */ + {"arm,cortex-a9-global-timer", TMR_GBL}, + {"arm,cortex-a5-global-timer", TMR_GBL}, + {"arm,cortex-a9-twd-timer", TMR_PRV}, + {"arm,cortex-a5-twd-timer", TMR_PRV}, + {"arm,arm11mp-twd-timer", TMR_PRV}, + {NULL, TMR_NONE} +}; + /** * arm_tmr_get_timecount - reads the timecount (global) timer * @tc: pointer to arm_tmr_timecount struct @@ -152,7 +156,10 @@ static struct timecounter arm_tmr_timecount = { static unsigned arm_tmr_get_timecount(struct timecounter *tc) { - return (tmr_gbl_read_4(GBL_TIMER_COUNT_LOW)); + struct arm_tmr_softc *sc; + + sc = tc->tc_priv; + return (tmr_gbl_read_4(sc, GBL_TIMER_COUNT_LOW)); } /** @@ -172,11 +179,13 @@ arm_tmr_get_timecount(struct timecounter *tc) static int arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period) { + struct arm_tmr_softc *sc; uint32_t load, count; uint32_t ctrl; - tmr_prv_write_4(PRV_TIMER_CTRL, 0); - tmr_prv_write_4(PRV_TIMER_INTR, PRV_TIMER_INTR_EVENT); + sc = et->et_priv; + tmr_prv_write_4(sc, PRV_TIMER_CTRL, 0); + tmr_prv_write_4(sc, PRV_TIMER_INTR, PRV_TIMER_INTR_EVENT); ctrl = PRV_TIMER_CTRL_IRQ_ENABLE | PRV_TIMER_CTRL_TIMER_ENABLE; @@ -191,9 +200,9 @@ arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period) else count = load; - tmr_prv_write_4(PRV_TIMER_LOAD, load); - tmr_prv_write_4(PRV_TIMER_COUNT, count); - tmr_prv_write_4(PRV_TIMER_CTRL, ctrl); + tmr_prv_write_4(sc, PRV_TIMER_LOAD, load); + tmr_prv_write_4(sc, PRV_TIMER_COUNT, count); + tmr_prv_write_4(sc, PRV_TIMER_CTRL, ctrl); return (0); } @@ -210,8 +219,11 @@ arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period) static int arm_tmr_stop(struct eventtimer *et) { - tmr_prv_write_4(PRV_TIMER_CTRL, 0); - tmr_prv_write_4(PRV_TIMER_INTR, PRV_TIMER_INTR_EVENT); + struct arm_tmr_softc *sc; + + sc = et->et_priv; + tmr_prv_write_4(sc, PRV_TIMER_CTRL, 0); + tmr_prv_write_4(sc, PRV_TIMER_INTR, PRV_TIMER_INTR_EVENT); return (0); } @@ -227,13 +239,12 @@ arm_tmr_stop(struct eventtimer *et) static int arm_tmr_intr(void *arg) { - struct arm_tmr_softc *sc = (struct arm_tmr_softc *)arg; - - tmr_prv_write_4(PRV_TIMER_INTR, PRV_TIMER_INTR_EVENT); + struct arm_tmr_softc *sc; + sc = arg; + tmr_prv_write_4(sc, PRV_TIMER_INTR, PRV_TIMER_INTR_EVENT); if (sc->et.et_active) sc->et.et_event_cb(&sc->et, sc->et.et_arg); - return (FILTER_HANDLED); } @@ -257,94 +268,74 @@ arm_tmr_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "arm,mpcore-timers")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == TMR_NONE) return (ENXIO); device_set_desc(dev, "ARM MPCore Timers"); return (BUS_PROBE_DEFAULT); } -/** - * arm_tmr_attach - attaches the timer to the simplebus - * @dev: new device - * - * Reserves memory and interrupt resources, stores the softc structure - * globally and registers both the timecount and eventtimer objects. - * - * RETURNS - * Zero on sucess or ENXIO if an error occuried. - */ static int -arm_tmr_attach(device_t dev) +attach_tc(struct arm_tmr_softc *sc) +{ + int rid; + + if (arm_tmr_tc != NULL) + return (EBUSY); + + rid = sc->memrid; + sc->gbl_mem = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->gbl_mem == NULL) { + device_printf(sc->dev, "could not allocate gbl mem resources\n"); + return (ENXIO); + } + tmr_gbl_write_4(sc, GBL_TIMER_CTRL, 0x00000000); + + arm_tmr_timecount.tc_frequency = sc->clkfreq; + arm_tmr_timecount.tc_priv = sc; + tc_init(&arm_tmr_timecount); + arm_tmr_tc = &arm_tmr_timecount; + + tmr_gbl_write_4(sc, GBL_TIMER_CTRL, GBL_TIMER_CTRL_TIMER_ENABLE); + + return (0); +} + +static int +attach_et(struct arm_tmr_softc *sc) { - struct arm_tmr_softc *sc = device_get_softc(dev); - phandle_t node; - pcell_t clock; void *ihl; - boolean_t fixed_freq; + int irid, mrid; - if (arm_tmr_sc) + if (arm_tmr_et != NULL) + return (EBUSY); + + mrid = sc->memrid; + sc->prv_mem = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, &mrid, + RF_ACTIVE); + if (sc->prv_mem == NULL) { + device_printf(sc->dev, "could not allocate prv mem resources\n"); return (ENXIO); - - if (platform_arm_tmr_freq == ARM_TMR_FREQUENCY_VARIES) { - fixed_freq = false; - } else { - fixed_freq = true; - if (platform_arm_tmr_freq != 0) { - sc->clkfreq = platform_arm_tmr_freq; - } else { - /* Get the base clock frequency */ - node = ofw_bus_get_node(dev); - if ((OF_getencprop(node, "clock-frequency", &clock, - sizeof(clock))) <= 0) { - device_printf(dev, "missing clock-frequency " - "attribute in FDT\n"); - return (ENXIO); - } - sc->clkfreq = clock; - } } + tmr_prv_write_4(sc, PRV_TIMER_CTRL, 0x00000000); - if (bus_alloc_resources(dev, arm_tmr_spec, sc->tmr_res)) { - device_printf(dev, "could not allocate resources\n"); + irid = sc->irqrid; + sc->prv_irq = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, &irid, RF_ACTIVE); + if (sc->prv_irq == NULL) { + bus_release_resource(sc->dev, SYS_RES_MEMORY, mrid, sc->prv_mem); + device_printf(sc->dev, "could not allocate prv irq resources\n"); return (ENXIO); } - /* Global timer interface */ - sc->gbl_bst = rman_get_bustag(sc->tmr_res[0]); - sc->gbl_bsh = rman_get_bushandle(sc->tmr_res[0]); - - /* Private per-CPU timer interface */ - sc->prv_bst = rman_get_bustag(sc->tmr_res[2]); - sc->prv_bsh = rman_get_bushandle(sc->tmr_res[2]); - - arm_tmr_sc = sc; - - /* Disable both timers to start off */ - tmr_prv_write_4(PRV_TIMER_CTRL, 0x00000000); - tmr_gbl_write_4(GBL_TIMER_CTRL, 0x00000000); - - if (bus_setup_intr(dev, sc->tmr_res[3], INTR_TYPE_CLK, arm_tmr_intr, + if (bus_setup_intr(sc->dev, sc->prv_irq, INTR_TYPE_CLK, arm_tmr_intr, NULL, sc, &ihl) != 0) { - bus_release_resources(dev, arm_tmr_spec, sc->tmr_res); - device_printf(dev, "Unable to setup the clock irq handler.\n"); + bus_release_resource(sc->dev, SYS_RES_MEMORY, mrid, sc->prv_mem); + bus_release_resource(sc->dev, SYS_RES_IRQ, irid, sc->prv_irq); + device_printf(sc->dev, "unable to setup the et irq handler.\n"); return (ENXIO); } - /* - * If the clock is fixed-frequency, setup and enable the global timer to - * use as the timecounter. If it's variable frequency it won't work as - * a timecounter. We also can't use it for DELAY(), so hopefully the - * platform provides its own implementation. If it doesn't, ours will - * get used, but since the frequency isn't set, it will only use the - * bogus loop counter. - */ - if (fixed_freq) { - tmr_gbl_write_4(GBL_TIMER_CTRL, GBL_TIMER_CTRL_TIMER_ENABLE); - arm_tmr_timecount.tc_frequency = sc->clkfreq; - tc_init(&arm_tmr_timecount); - } - /* * Setup and register the eventtimer. Most event timers set their min * and max period values to some value calculated from the clock @@ -364,10 +355,87 @@ arm_tmr_attach(device_t dev) sc->et.et_stop = arm_tmr_stop; sc->et.et_priv = sc; et_register(&sc->et); + arm_tmr_et = &sc->et; return (0); } +/** + * arm_tmr_attach - attaches the timer to the simplebus + * @dev: new device + * + * Reserves memory and interrupt resources, stores the softc structure + * globally and registers both the timecount and eventtimer objects. + * + * RETURNS + * Zero on sucess or ENXIO if an error occuried. + */ +static int +arm_tmr_attach(device_t dev) +{ + struct arm_tmr_softc *sc; + phandle_t node; + pcell_t clock; + int et_err, tc_err, tmrtype; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (arm_tmr_freq_varies) { + sc->clkfreq = arm_tmr_freq; + } else { + if (arm_tmr_freq != 0) { + sc->clkfreq = arm_tmr_freq; + } else { + /* Get the base clock frequency */ + node = ofw_bus_get_node(dev); + if ((OF_getencprop(node, "clock-frequency", &clock, + sizeof(clock))) <= 0) { + device_printf(dev, "missing clock-frequency " + "attribute in FDT\n"); + return (ENXIO); + } + sc->clkfreq = clock; + } + } + + tmrtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + tc_err = ENXIO; + et_err = ENXIO; + + /* + * If we're handling the global timer and it is fixed-frequency, set it + * up to use as a timecounter. If it's variable frequency it won't work + * as a timecounter. We also can't use it for DELAY(), so hopefully the + * platform provides its own implementation. If it doesn't, ours will + * get used, but since the frequency isn't set, it will only use the + * bogus loop counter. + */ + if (tmrtype & TMR_GBL) { + if (!arm_tmr_freq_varies) + tc_err = attach_tc(sc); + else if (bootverbose) + device_printf(sc->dev, + "not using variable-frequency device as timecounter"); + sc->memrid++; + sc->irqrid++; + } + + /* If we are handling the private timer, set it up as an eventtimer. */ + if (tmrtype & TMR_PRV) { + et_err = attach_et(sc); + } + + /* + * If we didn't successfully set up a timecounter or eventtimer then we + * didn't actually attach at all, return error. + */ + if (tc_err != 0 && et_err != 0) { + return (ENXIO); + } + return (0); +} + static device_method_t arm_tmr_methods[] = { DEVMETHOD(device_probe, arm_tmr_probe), DEVMETHOD(device_attach, arm_tmr_attach), @@ -384,6 +452,8 @@ static devclass_t arm_tmr_devclass; EARLY_DRIVER_MODULE(mp_tmr, simplebus, arm_tmr_driver, arm_tmr_devclass, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); +EARLY_DRIVER_MODULE(mp_tmr, ofwbus, arm_tmr_driver, arm_tmr_devclass, 0, 0, + BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); /* * Handle a change in clock frequency. The mpcore timer runs at half the CPU @@ -404,10 +474,14 @@ void arm_tmr_change_frequency(uint64_t newfreq) { - if (arm_tmr_sc == NULL) - platform_arm_tmr_freq = newfreq; - else - et_change_frequency(&arm_tmr_sc->et, newfreq); + if (newfreq == ARM_TMR_FREQUENCY_VARIES) { + arm_tmr_freq_varies = true; + return; + } + + arm_tmr_freq = newfreq; + if (arm_tmr_et != NULL) + et_change_frequency(arm_tmr_et, newfreq); } /** @@ -424,12 +498,13 @@ arm_tmr_change_frequency(uint64_t newfreq) static void __used /* Must emit function code for the weak ref below. */ arm_tmr_DELAY(int usec) { + struct arm_tmr_softc *sc; int32_t counts_per_usec; int32_t counts; uint32_t first, last; /* Check the timers are setup, if not just use a for loop for the meantime */ - if (arm_tmr_sc == NULL || arm_tmr_timecount.tc_frequency == 0) { + if (arm_tmr_tc == NULL || arm_tmr_timecount.tc_frequency == 0) { for (; usec > 0; usec--) for (counts = 200; counts > 0; counts--) cpufunc_nullop(); /* Prevent gcc from optimizing @@ -438,6 +513,8 @@ arm_tmr_DELAY(int usec) return; } + sc = arm_tmr_tc->tc_priv; + /* Get the number of times to count */ counts_per_usec = ((arm_tmr_timecount.tc_frequency / 1000000) + 1); @@ -452,10 +529,10 @@ arm_tmr_DELAY(int usec) else counts = usec * counts_per_usec; - first = tmr_gbl_read_4(GBL_TIMER_COUNT_LOW); + first = tmr_gbl_read_4(sc, GBL_TIMER_COUNT_LOW); while (counts > 0) { - last = tmr_gbl_read_4(GBL_TIMER_COUNT_LOW); + last = tmr_gbl_read_4(sc, GBL_TIMER_COUNT_LOW); counts -= (int32_t)(last - first); first = last; } diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c index 9725f6480e7d..8b2d609ebb18 100644 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -90,6 +90,8 @@ static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig, enum intr_polarity pol); static int nexus_deactivate_resource(device_t, device_t, int, int, struct resource *); +static int nexus_release_resource(device_t, device_t, int, int, + struct resource *); static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); @@ -111,6 +113,7 @@ static device_method_t nexus_methods[] = { DEVMETHOD(bus_activate_resource, nexus_activate_resource), DEVMETHOD(bus_config_intr, nexus_config_intr), DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), + DEVMETHOD(bus_release_resource, nexus_release_resource), DEVMETHOD(bus_setup_intr, nexus_setup_intr), DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), #ifdef FDT @@ -205,6 +208,8 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, struct rman *rm; int needactivate = flags & RF_ACTIVE; + flags &= ~RF_ACTIVE; + switch (type) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: @@ -212,15 +217,14 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, break; default: - return (0); + return (NULL); } rv = rman_reserve_resource(rm, start, end, count, flags, child); if (rv == 0) - return (0); + return (NULL); rman_set_rid(rv, *rid); - rman_set_bushandle(rv, rman_get_start(rv)); if (needactivate) { if (bus_activate_resource(child, type, *rid, rv)) { @@ -232,6 +236,20 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, return (rv); } +static int +nexus_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *res) +{ + int error; + + if (rman_get_flags(res) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, res); + if (error) + return (error); + } + return (rman_release_resource(res)); +} + static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig, enum intr_polarity pol) @@ -338,16 +356,16 @@ nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells, pcell_t *intr) { fdt_pic_decode_t intr_decode; - phandle_t intr_offset; + phandle_t intr_parent; int i, rv, interrupt, trig, pol; - intr_offset = OF_node_from_xref(iparent); + intr_parent = OF_node_from_xref(iparent); for (i = 0; i < icells; i++) intr[i] = cpu_to_fdt32(intr[i]); for (i = 0; fdt_pic_table[i] != NULL; i++) { intr_decode = fdt_pic_table[i]; - rv = intr_decode(intr_offset, intr, &interrupt, &trig, &pol); + rv = intr_decode(intr_parent, intr, &interrupt, &trig, &pol); if (rv == 0) { /* This was recognized as our PIC and decoded. */ diff --git a/sys/arm/arm/physmem.c b/sys/arm/arm/physmem.c index d42cac481ace..8618e46e27ae 100644 --- a/sys/arm/arm/physmem.c +++ b/sys/arm/arm/physmem.c @@ -168,6 +168,12 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags) end = hwp->size + start; realmem += arm32_btop(end - start); for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) { + /* + * If the excluded region does not match given flags, + * continue checking with the next excluded region. + */ + if ((exp->flags & exflags) == 0) + continue; xstart = exp->addr; xend = exp->size + xstart; /* diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c index 1be98885ec73..c0d5a2ebf629 100644 --- a/sys/arm/arm/pmap-v6.c +++ b/sys/arm/arm/pmap-v6.c @@ -2369,7 +2369,7 @@ pmap_kenter_section(vm_offset_t va, vm_offset_t pa, int flags) * to be used for panic dumps. */ void * -pmap_kenter_temp(vm_paddr_t pa, int i) +pmap_kenter_temporary(vm_paddr_t pa, int i) { vm_offset_t va; diff --git a/sys/arm/arm/pmap.c b/sys/arm/arm/pmap.c index ec0d236fa978..61afb4d72106 100644 --- a/sys/arm/arm/pmap.c +++ b/sys/arm/arm/pmap.c @@ -2663,7 +2663,7 @@ pmap_kenter_section(vm_offset_t va, vm_offset_t pa, int flags) * to be used for panic dumps. */ void * -pmap_kenter_temp(vm_paddr_t pa, int i) +pmap_kenter_temporary(vm_paddr_t pa, int i) { vm_offset_t va; diff --git a/sys/arm/arm/syscall.c b/sys/arm/arm/syscall.c new file mode 100644 index 000000000000..94a028a12407 --- /dev/null +++ b/sys/arm/arm/syscall.c @@ -0,0 +1,196 @@ +/* $NetBSD: fault.c,v 1.45 2003/11/20 14:44:36 scw Exp $ */ + +/*- + * Copyright 2004 Olivier Houchard + * Copyright 2003 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Steve C. Woodford for Wasabi Systems, 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * 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. + */ +/*- + * Copyright (c) 1994-1997 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * fault.c + * + * Fault handlers + * + * Created : 28/11/94 + */ + + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +void swi_handler(struct trapframe *); + +static __inline void +call_trapsignal(struct thread *td, int sig, u_long code) +{ + ksiginfo_t ksi; + + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = sig; + ksi.ksi_code = (int)code; + trapsignal(td, &ksi); +} + +int +cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa) +{ + struct proc *p; + register_t *ap; + int error; + + sa->code = td->td_frame->tf_r7; + ap = &td->td_frame->tf_r0; + if (sa->code == SYS_syscall) { + sa->code = *ap++; + sa->nap--; + } else if (sa->code == SYS___syscall) { + sa->code = ap[_QUAD_LOWWORD]; + sa->nap -= 2; + ap += 2; + } + p = td->td_proc; + if (p->p_sysent->sv_mask) + sa->code &= p->p_sysent->sv_mask; + if (sa->code >= p->p_sysent->sv_size) + sa->callp = &p->p_sysent->sv_table[0]; + else + sa->callp = &p->p_sysent->sv_table[sa->code]; + sa->narg = sa->callp->sy_narg; + error = 0; + memcpy(sa->args, ap, sa->nap * sizeof(register_t)); + if (sa->narg > sa->nap) { + error = copyin((void *)td->td_frame->tf_usr_sp, sa->args + + sa->nap, (sa->narg - sa->nap) * sizeof(register_t)); + } + if (error == 0) { + td->td_retval[0] = 0; + td->td_retval[1] = 0; + } + return (error); +} + +#include "../../kern/subr_syscall.c" + +static void +syscall(struct thread *td, struct trapframe *frame) +{ + struct syscall_args sa; + int error; + + sa.nap = 4; + + error = syscallenter(td, &sa); + KASSERT(error != 0 || td->td_ar == NULL, + ("returning from syscall with td_ar set!")); + syscallret(td, error, &sa); +} + +void +swi_handler(struct trapframe *frame) +{ + struct thread *td = curthread; + + td->td_frame = frame; + + td->td_pticks = 0; + /* + * Make sure the program counter is correctly aligned so we + * don't take an alignment fault trying to read the opcode. + * XXX: Fix for Thumb mode + */ + if (__predict_false(((frame->tf_pc - INSN_SIZE) & 3) != 0)) { + call_trapsignal(td, SIGILL, 0); + userret(td, frame); + return; + } + /* + * Enable interrupts if they were enabled before the exception. + * Since all syscalls *should* come from user mode it will always + * be safe to enable them, but check anyway. + */ + if (td->td_md.md_spinlock_count == 0) { + if (__predict_true(frame->tf_spsr & PSR_I) == 0) + enable_interrupts(PSR_I); + if (__predict_true(frame->tf_spsr & PSR_F) == 0) + enable_interrupts(PSR_F); + } + + syscall(td, frame); +} diff --git a/sys/arm/arm/trap.c b/sys/arm/arm/trap.c index 32624e3b0373..ec14feb16476 100644 --- a/sys/arm/arm/trap.c +++ b/sys/arm/arm/trap.c @@ -79,28 +79,15 @@ */ -#include "opt_ktrace.h" - #include __FBSDID("$FreeBSD$"); #include -#include #include #include -#include #include #include -#include -#include #include -#include -#ifdef KTRACE -#include -#include -#endif -#include -#include #include #include @@ -108,28 +95,16 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include -#include #include -#include +#include +#include #include -#include -#include - -#include +#include #ifdef KDB #include #endif - -void swi_handler(struct trapframe *); - -#include -#include - extern char fusubailout[]; #ifdef DEBUG @@ -241,10 +216,10 @@ data_abort_handler(struct trapframe *tf) pcb = td->td_pcb; /* Re-enable interrupts if they were enabled previously */ if (td->td_md.md_spinlock_count == 0) { - if (__predict_true(tf->tf_spsr & I32_bit) == 0) - enable_interrupts(I32_bit); - if (__predict_true(tf->tf_spsr & F32_bit) == 0) - enable_interrupts(F32_bit); + if (__predict_true(tf->tf_spsr & PSR_I) == 0) + enable_interrupts(PSR_I); + if (__predict_true(tf->tf_spsr & PSR_F) == 0) + enable_interrupts(PSR_F); } @@ -451,7 +426,7 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, struct thread *td, mode = TRAP_USERMODE(tf) ? "user" : "kernel"; - disable_interrupts(I32_bit|F32_bit); + disable_interrupts(PSR_I|PSR_F); if (td != NULL) { printf("Fatal %s mode data abort: '%s'\n", mode, data_aborts[fsr & FAULT_TYPE_MASK].desc); @@ -661,10 +636,10 @@ prefetch_abort_handler(struct trapframe *tf) } fault_pc = tf->tf_pc; if (td->td_md.md_spinlock_count == 0) { - if (__predict_true(tf->tf_spsr & I32_bit) == 0) - enable_interrupts(I32_bit); - if (__predict_true(tf->tf_spsr & F32_bit) == 0) - enable_interrupts(F32_bit); + if (__predict_true(tf->tf_spsr & PSR_I) == 0) + enable_interrupts(PSR_I); + if (__predict_true(tf->tf_spsr & PSR_F) == 0) + enable_interrupts(PSR_F); } /* Prefetch aborts cannot happen in kernel mode */ @@ -775,106 +750,4 @@ badaddr_read(void *addr, size_t size, void *rptr) /* Return EFAULT if the address was invalid, else zero */ return (rv); -} - -int -cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa) -{ - struct proc *p; - register_t *ap; - int error; - -#ifdef __ARM_EABI__ - sa->code = td->td_frame->tf_r7; -#else - sa->code = sa->insn & 0x000fffff; -#endif - ap = &td->td_frame->tf_r0; - if (sa->code == SYS_syscall) { - sa->code = *ap++; - sa->nap--; - } else if (sa->code == SYS___syscall) { - sa->code = ap[_QUAD_LOWWORD]; - sa->nap -= 2; - ap += 2; - } - p = td->td_proc; - if (p->p_sysent->sv_mask) - sa->code &= p->p_sysent->sv_mask; - if (sa->code >= p->p_sysent->sv_size) - sa->callp = &p->p_sysent->sv_table[0]; - else - sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; - error = 0; - memcpy(sa->args, ap, sa->nap * sizeof(register_t)); - if (sa->narg > sa->nap) { - error = copyin((void *)td->td_frame->tf_usr_sp, sa->args + - sa->nap, (sa->narg - sa->nap) * sizeof(register_t)); - } - if (error == 0) { - td->td_retval[0] = 0; - td->td_retval[1] = 0; - } - return (error); -} - -#include "../../kern/subr_syscall.c" - -static void -syscall(struct thread *td, struct trapframe *frame) -{ - struct syscall_args sa; - int error; - -#ifndef __ARM_EABI__ - sa.insn = *(uint32_t *)(frame->tf_pc - INSN_SIZE); - switch (sa.insn & SWI_OS_MASK) { - case 0: /* XXX: we need our own one. */ - break; - default: - call_trapsignal(td, SIGILL, 0); - userret(td, frame); - return; - } -#endif - sa.nap = 4; - - error = syscallenter(td, &sa); - KASSERT(error != 0 || td->td_ar == NULL, - ("returning from syscall with td_ar set!")); - syscallret(td, error, &sa); -} - -void -swi_handler(struct trapframe *frame) -{ - struct thread *td = curthread; - - td->td_frame = frame; - - td->td_pticks = 0; - /* - * Make sure the program counter is correctly aligned so we - * don't take an alignment fault trying to read the opcode. - */ - if (__predict_false(((frame->tf_pc - INSN_SIZE) & 3) != 0)) { - call_trapsignal(td, SIGILL, 0); - userret(td, frame); - return; - } - /* - * Enable interrupts if they were enabled before the exception. - * Since all syscalls *should* come from user mode it will always - * be safe to enable them, but check anyway. - */ - if (td->td_md.md_spinlock_count == 0) { - if (__predict_true(frame->tf_spsr & I32_bit) == 0) - enable_interrupts(I32_bit); - if (__predict_true(frame->tf_spsr & F32_bit) == 0) - enable_interrupts(F32_bit); - } - - syscall(td, frame); -} - +} \ No newline at end of file diff --git a/sys/arm/arm/undefined.c b/sys/arm/arm/undefined.c index 5b7b91780871..d82fdd3048a6 100644 --- a/sys/arm/arm/undefined.c +++ b/sys/arm/arm/undefined.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -180,8 +181,10 @@ undefinedinstruction(struct trapframe *frame) ksiginfo_t ksi; /* Enable interrupts if they were enabled before the exception. */ - if (!(frame->tf_spsr & I32_bit)) - enable_interrupts(I32_bit|F32_bit); + if (__predict_true(frame->tf_spsr & PSR_I) == 0) + enable_interrupts(PSR_I); + if (__predict_true(frame->tf_spsr & PSR_F) == 0) + enable_interrupts(PSR_F); PCPU_INC(cnt.v_trap); diff --git a/sys/arm/arm/vm_machdep.c b/sys/arm/arm/vm_machdep.c index 4a9cf3f6a595..7758a22f5ee6 100644 --- a/sys/arm/arm/vm_machdep.c +++ b/sys/arm/arm/vm_machdep.c @@ -120,7 +120,7 @@ cpu_fork(register struct thread *td1, register struct proc *p2, sf->sf_r4 = (u_int)fork_return; sf->sf_r5 = (u_int)td2; sf->sf_pc = (u_int)fork_trampoline; - tf->tf_spsr &= ~PSR_C_bit; + tf->tf_spsr &= ~PSR_C; tf->tf_r0 = 0; tf->tf_r1 = 0; pcb2->un_32.pcb32_sp = (u_int)sf; @@ -190,7 +190,7 @@ cpu_set_syscall_retval(struct thread *td, int error) frame->tf_r0 = td->td_retval[0]; frame->tf_r1 = td->td_retval[1]; } - frame->tf_spsr &= ~PSR_C_bit; /* carry bit */ + frame->tf_spsr &= ~PSR_C; /* carry bit */ break; case ERESTART: /* @@ -203,7 +203,7 @@ cpu_set_syscall_retval(struct thread *td, int error) break; default: frame->tf_r0 = error; - frame->tf_spsr |= PSR_C_bit; /* carry bit */ + frame->tf_spsr |= PSR_C; /* carry bit */ break; } } @@ -228,7 +228,7 @@ cpu_set_upcall(struct thread *td, struct thread *td0) sf->sf_r4 = (u_int)fork_return; sf->sf_r5 = (u_int)td; sf->sf_pc = (u_int)fork_trampoline; - tf->tf_spsr &= ~PSR_C_bit; + tf->tf_spsr &= ~PSR_C; tf->tf_r0 = 0; td->td_pcb->un_32.pcb32_sp = (u_int)sf; KASSERT((td->td_pcb->un_32.pcb32_sp & 7) == 0, diff --git a/sys/arm/at91/at91.c b/sys/arm/at91/at91.c index 56b32bdbaab0..1942389738b2 100644 --- a/sys/arm/at91/at91.c +++ b/sys/arm/at91/at91.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #define _ARM32_BUS_DMA_PRIVATE #include #include @@ -303,7 +304,7 @@ at91_attach(device_t dev) bus_generic_probe(dev); bus_generic_attach(dev); - enable_interrupts(I32_bit | F32_bit); + enable_interrupts(PSR_I | PSR_F); return (0); } diff --git a/sys/arm/at91/at91_aic.c b/sys/arm/at91/at91_aic.c index f7489de2c4b4..300c99aea3d3 100644 --- a/sys/arm/at91/at91_aic.c +++ b/sys/arm/at91/at91_aic.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -149,7 +150,7 @@ at91_aic_attach(device_t dev) /* Disable and clear all interrupts. */ WR4(sc, IC_IDCR, 0xffffffff); WR4(sc, IC_ICCR, 0xffffffff); - enable_interrupts(I32_bit | F32_bit); + enable_interrupts(PSR_I | PSR_F); return (err); } diff --git a/sys/arm/at91/at91_pinctrl.c b/sys/arm/at91/at91_pinctrl.c index 31140da603a8..7a90f0f80d15 100644 --- a/sys/arm/at91/at91_pinctrl.c +++ b/sys/arm/at91/at91_pinctrl.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -250,6 +251,8 @@ at91_pinctrl_attach(device_t dev) device_set_ivars(cdev, di); } + fdt_pinctrl_register(dev, "atmel,pins"); + return (bus_generic_attach(dev)); } @@ -370,93 +373,70 @@ pinctrl_print_child(device_t bus, device_t child) const char *periphs[] = {"gpio", "periph A", "periph B", "periph C", "periph D", "periph E" }; -static void -pinctrl_walk_tree(device_t bus, phandle_t node) +struct pincfg { + uint32_t unit; + uint32_t pin; + uint32_t periph; + uint32_t flags; +}; + +static int +pinctrl_configure_pins(device_t bus, phandle_t cfgxref) { struct pinctrl_softc *sc; - char status[10]; + struct pincfg *cfg, *cfgdata; char name[32]; - phandle_t pinctrl[32], pins[32 * 4], scratch; - ssize_t len, npins; - int i, j; + phandle_t node; + ssize_t npins; + int i; sc = device_get_softc(bus); - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - pinctrl_walk_tree(bus, node); - memset(status, 0, sizeof(status)); - memset(name, 0, sizeof(name)); - OF_getprop(node, "status", status, sizeof(status)); - OF_getprop(node, "name", name, sizeof(name)); - if (strcmp(status, "okay") != 0) { -// printf("pinctrl: skipping node %s status %s\n", name, -// status); - continue; - } - len = OF_getencprop(node, "pinctrl-0", pinctrl, sizeof(pinctrl)); - if (len <= 0) { -// printf("pinctrl: skipping node %s no pinctrl-0\n", -// name, status); - continue; - } - len /= sizeof(phandle_t); - printf("pinctrl: Found active node %s\n", name); - for (i = 0; i < len; i++) { - scratch = OF_node_from_xref(pinctrl[i]); - npins = OF_getencprop(scratch, "atmel,pins", pins, - sizeof(pins)); - if (npins <= 0) { - printf("We're doing it wrong %s\n", name); - continue; - } - memset(name, 0, sizeof(name)); - OF_getprop(scratch, "name", name, sizeof(name)); - npins /= (4 * 4); - printf("----> need to cope with %d more pins for %s\n", - npins, name); - for (j = 0; j < npins; j++) { - uint32_t unit = pins[j * 4]; - uint32_t pin = pins[j * 4 + 1]; - uint32_t periph = pins[j * 4 + 2]; - uint32_t flags = pins[j * 4 + 3]; - uint32_t pio; - - pio = (0xfffffff & sc->ranges[0].bus) + - 0x200 * unit; - printf("P%c%d %s %#x\n", unit + 'A', pin, - periphs[periph], flags); - switch (periph) { - case 0: - at91_pio_use_gpio(pio, 1u << pin); - at91_pio_gpio_pullup(pio, 1u << pin, - !!(flags & 1)); - at91_pio_gpio_high_z(pio, 1u << pin, - !!(flags & 2)); - at91_pio_gpio_set_deglitch(pio, - 1u << pin, !!(flags & 4)); -// at91_pio_gpio_pulldown(pio, 1u << pin, -// !!(flags & 8)); -// at91_pio_gpio_dis_schmidt(pio, -// 1u << pin, !!(flags & 16)); - break; - case 1: - at91_pio_use_periph_a(pio, 1u << pin, - flags); - break; - case 2: - at91_pio_use_periph_b(pio, 1u << pin, - flags); - break; - } - } + node = OF_node_from_xref(cfgxref); + memset(name, 0, sizeof(name)); + OF_getprop(node, "name", name, sizeof(name)); + npins = OF_getencprop_alloc(node, "atmel,pins", sizeof(*cfgdata), + (void **)&cfgdata); + if (npins < 0) { + printf("We're doing it wrong %s\n", name); + return (ENXIO); + } + if (npins == 0) + return (0); + for (i = 0, cfg = cfgdata; i < npins; i++, cfg++) { + uint32_t pio; + pio = (0xfffffff & sc->ranges[0].bus) + 0x200 * cfg->unit; + printf("P%c%d %s %#x\n", cfg->unit + 'A', cfg->pin, + periphs[cfg->periph], cfg->flags); + switch (cfg->periph) { + case 0: + at91_pio_use_gpio(pio, 1u << cfg->pin); + at91_pio_gpio_pullup(pio, 1u << cfg->pin, + !!(cfg->flags & 1)); + at91_pio_gpio_high_z(pio, 1u << cfg->pin, + !!(cfg->flags & 2)); + at91_pio_gpio_set_deglitch(pio, + 1u << cfg->pin, !!(cfg->flags & 4)); +// at91_pio_gpio_pulldown(pio, 1u << cfg->pin, +// !!(cfg->flags & 8)); +// at91_pio_gpio_dis_schmidt(pio, +// 1u << cfg->pin, !!(cfg->flags & 16)); + break; + case 1: + at91_pio_use_periph_a(pio, 1u << cfg->pin, cfg->flags); + break; + case 2: + at91_pio_use_periph_b(pio, 1u << cfg->pin, cfg->flags); + break; } } + free(cfgdata, M_OFWPROP); + return (0); } static void pinctrl_new_pass(device_t bus) { struct pinctrl_softc *sc; - phandle_t node; sc = device_get_softc(bus); @@ -466,10 +446,7 @@ pinctrl_new_pass(device_t bus) return; sc->done_pinmux++; - node = OF_peer(0); - if (node == -1) - return; - pinctrl_walk_tree(bus, node); + fdt_pinctrl_configure_tree(bus); } static device_method_t at91_pinctrl_methods[] = { @@ -496,6 +473,8 @@ static device_method_t at91_pinctrl_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), + /* fdt_pintrl interface */ + DEVMETHOD(fdt_pinctrl_configure,pinctrl_configure_pins), DEVMETHOD_END }; diff --git a/sys/arm/at91/at91rm9200.c b/sys/arm/at91/at91rm9200.c index 2cc0c9cfcb6d..d350117f1dad 100644 --- a/sys/arm/at91/at91rm9200.c +++ b/sys/arm/at91/at91rm9200.c @@ -105,7 +105,7 @@ static const uint32_t at91_pio_base[] = { static const struct cpu_devs at91_devs[] = { - DEVICE("at91_aic", AIC, 0), + DEVICE("at91_aic", AIC, 0), DEVICE("at91_pmc", PMC, 0), DEVICE("at91_st", ST, 0), DEVICE("at91_pio", PIOA, 0), @@ -128,7 +128,6 @@ static const struct cpu_devs at91_devs[] = DEVICE("uart", USART1, 2), DEVICE("uart", USART2, 3), DEVICE("uart", USART3, 4), - DEVICE("at91_aic", AIC, 0), DEVICE("at91_mc", MC, 0), DEVICE("at91_tc", TC0, 0), DEVICE("at91_tc", TC1, 1), diff --git a/sys/arm/at91/at91rm92reg.h b/sys/arm/at91/at91rm92reg.h index 5db3d7e2fb7a..16fc82c06ebb 100644 --- a/sys/arm/at91/at91rm92reg.h +++ b/sys/arm/at91/at91rm92reg.h @@ -124,7 +124,7 @@ * 9: USART 3 * 10: MMC Interface * 11: USB device port - * 12: Two-wirte interface + * 12: Two-wire interface * 13: SPI * 14: SSC * 15: SSC @@ -134,7 +134,7 @@ * 19: Timer Counter 2 * 20: Timer Counter 3 * 21: Timer Counter 4 - * 22: Timer Counter 6 + * 22: Timer Counter 5 * 23: USB Host port * 24: Ethernet * 25: AIC diff --git a/sys/arm/at91/at91sam9260reg.h b/sys/arm/at91/at91sam9260reg.h index 839b7147ac93..1609ed17e869 100644 --- a/sys/arm/at91/at91sam9260reg.h +++ b/sys/arm/at91/at91sam9260reg.h @@ -164,7 +164,7 @@ * 8: USART 2 * 9: MMC Interface * 10: USB device port - * 11: Two-wirte interface + * 11: Two-wire interface * 12: SPI 0 * 13: SPI 1 * 14: SSC @@ -231,7 +231,7 @@ #define AT91SAM9260_WDT_SIZE 0x10 #define AT91SAM9260_PIT_BASE 0xffffd30 -#define AT91SAM9260_PIT_SIZE 10 +#define AT91SAM9260_PIT_SIZE 0x10 #define AT91SAM9260_SMC_BASE 0xfffec00 #define AT91SAM9260_SMC_SIZE 0x200 diff --git a/sys/arm/at91/at91sam9g20reg.h b/sys/arm/at91/at91sam9g20reg.h index 59f6099b3ac3..d29dfa5ef57c 100644 --- a/sys/arm/at91/at91sam9g20reg.h +++ b/sys/arm/at91/at91sam9g20reg.h @@ -165,7 +165,7 @@ * 8: USART 2 * 9: MMC Interface * 10: USB device port - * 11: Two-wirte interface + * 11: Two-wire interface * 12: SPI 0 * 13: SPI 1 * 14: SSC diff --git a/sys/arm/at91/at91sam9g45reg.h b/sys/arm/at91/at91sam9g45reg.h index a92e3b950f69..0dc31beea9be 100644 --- a/sys/arm/at91/at91sam9g45reg.h +++ b/sys/arm/at91/at91sam9g45reg.h @@ -142,13 +142,13 @@ * 9: USART 2 * 10: USART 3 * 11: Multimedia Card interface 0 - * 12: Two-wirte interface 0 - * 13: Two-wirte interface 1 + * 12: Two-wire interface 0 + * 13: Two-wire interface 1 * 14: SPI 0 * 15: SPI 1 * 16: SSC 0 - * 17: SSC 0 - * 18: Timer Counter 0, 2, 3, 4, 5 + * 17: SSC 1 + * 18: Timer Counter 0, 1, 2, 3, 4, 5 * 19: PWM * 20: Touch Screen ADC * 21: DMA @@ -168,8 +168,8 @@ #define AT91SAM9G45_IRQ_PIOA 2 #define AT91SAM9G45_IRQ_PIOB 3 #define AT91SAM9G45_IRQ_PIOC 4 -#define AT91SAM9G45_IRQ_PIOD 5 -#define AT91SAM9G45_IRQ_PIOE 6 +#define AT91SAM9G45_IRQ_PIODE 5 +#define AT91SAM9G45_IRQ_TRNG 6 #define AT91SAM9G45_IRQ_USART0 7 #define AT91SAM9G45_IRQ_USART1 8 #define AT91SAM9G45_IRQ_USART2 9 @@ -202,6 +202,8 @@ #define AT91SAM9G45_IRQ_WDT AT91SAM9G45_IRQ_SYSTEM #define AT91SAM9G45_IRQ_PIT AT91SAM9G45_IRQ_SYSTEM #define AT91SAM9G45_IRQ_RSTC AT91SAM9G45_IRQ_SYSTEM +#define AT91SAM9G45_IRQ_PIOD AT91SAM9G45_IRQ_PIODE +#define AT91SAM9G45_IRQ_PIOE AT91SAM9G45_IRQ_PIODE #define AT91SAM9G45_IRQ_OHCI AT91SAM9G45_IRQ_UHP #define AT91SAM9G45_IRQ_TC0 AT91SAM9G45_IRQ_TC0_TC5 #define AT91SAM9G45_IRQ_TC1 AT91SAM9G45_IRQ_TC0_TC5 @@ -225,9 +227,6 @@ #define AT91SAM9G45_SMC_BASE 0xfffe800 #define AT91SAM9G45_SMC_SIZE 0x200 -#define AT91SAM9G45_PMC_BASE 0xffffc00 -#define AT91SAM9G45_PMC_SIZE 0x100 - #define AT91SAM9G45_HSMCI0_BASE 0xff80000 #define AT91SAM9G45_HSMCI0_SIZE 0x4000 diff --git a/sys/arm/at91/at91sam9x5reg.h b/sys/arm/at91/at91sam9x5reg.h index 17c43ffa7491..dd777f9a6b2d 100644 --- a/sys/arm/at91/at91sam9x5reg.h +++ b/sys/arm/at91/at91sam9x5reg.h @@ -151,9 +151,9 @@ * 6: USART 1 * 7: USART 2 * 8: USART 3 - * 9: Two-wirte interface - * 10: Two-wirte interface - * 11: Two-wirte interface + * 9: Two-wire interface + * 10: Two-wire interface + * 11: Two-wire interface * 12: HSMCI Interface * 13: SPI 0 * 14: SPI 1 diff --git a/sys/arm/at91/files.at91 b/sys/arm/at91/files.at91 index f8a98eb9ab4b..29ada7d26c1d 100644 --- a/sys/arm/at91/files.at91 +++ b/sys/arm/at91/files.at91 @@ -10,7 +10,7 @@ arm/at91/at91_smc.c standard arm/at91/at91_cfata.c optional at91_cfata arm/at91/at91_common.c optional fdt arm/at91/at91_mci.c optional at91_mci -arm/at91/at91_pinctrl.c optional fdt +arm/at91/at91_pinctrl.c optional fdt fdt_pinctrl arm/at91/at91_pit.c optional at91sam9 arm/at91/at91_reset.S optional at91sam9 arm/at91/at91_rst.c optional at91sam9 diff --git a/sys/arm/at91/if_ate.c b/sys/arm/at91/if_ate.c index 6b2eabc54ccc..4497611a5319 100644 --- a/sys/arm/at91/if_ate.c +++ b/sys/arm/at91/if_ate.c @@ -776,19 +776,19 @@ ate_tick(void *xsc) sc->mibdata.dot3StatsAlignmentErrors += RD4(sc, ETH_ALE); sc->mibdata.dot3StatsFCSErrors += RD4(sc, ETH_SEQE); c = RD4(sc, ETH_SCOL); - ifp->if_collisions += c; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, c); sc->mibdata.dot3StatsSingleCollisionFrames += c; c = RD4(sc, ETH_MCOL); sc->mibdata.dot3StatsMultipleCollisionFrames += c; - ifp->if_collisions += c; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, c); sc->mibdata.dot3StatsSQETestErrors += RD4(sc, ETH_SQEE); sc->mibdata.dot3StatsDeferredTransmissions += RD4(sc, ETH_DTE); c = RD4(sc, ETH_LCOL); sc->mibdata.dot3StatsLateCollisions += c; - ifp->if_collisions += c; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, c); c = RD4(sc, ETH_ECOL); sc->mibdata.dot3StatsExcessiveCollisions += c; - ifp->if_collisions += c; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, c); sc->mibdata.dot3StatsCarrierSenseErrors += RD4(sc, ETH_CSE); sc->mibdata.dot3StatsFrameTooLongs += RD4(sc, ETH_ELR); sc->mibdata.dot3StatsInternalMacReceiveErrors += RD4(sc, ETH_DRFC); @@ -797,9 +797,9 @@ ate_tick(void *xsc) * Not sure where to lump these, so count them against the errors * for the interface. */ - sc->ifp->if_oerrors += RD4(sc, ETH_TUE); - sc->ifp->if_ierrors += RD4(sc, ETH_CDE) + RD4(sc, ETH_RJB) + - RD4(sc, ETH_USF); + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, RD4(sc, ETH_TUE)); + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, + RD4(sc, ETH_CDE) + RD4(sc, ETH_RJB) + RD4(sc, ETH_USF)); /* Schedule another timeout one second from now. */ callout_reset(&sc->tick_ch, hz, ate_tick, sc); @@ -914,7 +914,7 @@ ate_intr(void *xsc) mb = m_get2(remain + ETHER_ALIGN, M_NOWAIT, MT_DATA, M_PKTHDR); if (mb == NULL) { - sc->ifp->if_iqdrops++; + if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, 1); rxdhead->status = 0; continue; } @@ -957,7 +957,7 @@ ate_intr(void *xsc) } while (!done); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, mb); } } @@ -990,7 +990,7 @@ ate_intr(void *xsc) m_freem(sc->sent_mbuf[sc->txtail]); sc->tx_descs[sc->txtail].addr = 0; sc->sent_mbuf[sc->txtail] = NULL; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->txtail = NEXT_TX_IDX(sc, sc->txtail); } @@ -1162,7 +1162,7 @@ atestart_locked(struct ifnet *ifp) BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->mtag, sc->tx_map[sc->txtail]); m_free(sc->sent_mbuf[sc->txhead]); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } sc->sent_mbuf[sc->txhead] = m; diff --git a/sys/arm/at91/if_macb.c b/sys/arm/at91/if_macb.c index a60cddfaf2b5..a7acc31d4399 100644 --- a/sys/arm/at91/if_macb.c +++ b/sys/arm/at91/if_macb.c @@ -522,12 +522,12 @@ macb_watchdog(struct macb_softc *sc) ifp = sc->ifp; if ((sc->flags & MACB_FLAG_LINK) == 0) { if_printf(ifp, "watchdog timeout (missed link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } if_printf(ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; macbinit_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -677,7 +677,7 @@ macb_tx_cleanup(struct macb_softc *sc) td->dmamap); m_freem(td->buff); td->buff = NULL; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } do { @@ -732,7 +732,7 @@ macb_rx(struct macb_softc *sc) bus_dmamap_sync(sc->dmatag_ring_rx, sc->rx_desc[sc->rx_cons].dmamap, BUS_DMASYNC_POSTREAD); if (macb_new_rxbuf(sc, sc->rx_cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); first = sc->rx_cons; do { @@ -781,7 +781,7 @@ macb_rx(struct macb_softc *sc) m->m_flags |= M_PKTHDR; m->m_pkthdr.len = rxbytes; m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); nsegs = 0; MACB_UNLOCK(sc); diff --git a/sys/arm/cavium/cns11xx/econa.c b/sys/arm/cavium/cns11xx/econa.c index f9492b6d8228..c331e20d9260 100644 --- a/sys/arm/cavium/cns11xx/econa.c +++ b/sys/arm/cavium/cns11xx/econa.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #define _ARM32_BUS_DMA_PRIVATE +#include #include #include #include @@ -508,7 +509,7 @@ econa_attach(device_t dev) bus_generic_probe(dev); bus_generic_attach(dev); - enable_interrupts(I32_bit | F32_bit); + enable_interrupts(PSR_I | PSR_F); return (0); } diff --git a/sys/arm/cavium/cns11xx/if_ece.c b/sys/arm/cavium/cns11xx/if_ece.c index 0ba2d774dc94..20bc07e7167f 100644 --- a/sys/arm/cavium/cns11xx/if_ece.c +++ b/sys/arm/cavium/cns11xx/if_ece.c @@ -1379,7 +1379,7 @@ ece_intr_rx_locked(struct ece_softc *sc, int count) if (desc->length < ETHER_MIN_LEN - ETHER_CRC_LEN || desc->length > ETHER_MAX_LEN - ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); desc->cown = 0; desc->length = MCLBYTES - 2; /* Invalid packet, skip and process next @@ -1389,7 +1389,7 @@ ece_intr_rx_locked(struct ece_softc *sc, int count) } if (ece_new_rxbuf(sc, rxdesc) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); desc->cown = 0; desc->length = MCLBYTES - 2; break; @@ -1478,7 +1478,7 @@ ece_intr_status(void *xsc) if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { if ((stat & ERROR_MASK) != 0) - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); } } diff --git a/sys/arm/conf/DIGI-CCWMX53 b/sys/arm/conf/DIGI-CCWMX53 index 286a83900828..77565588022f 100644 --- a/sys/arm/conf/DIGI-CCWMX53 +++ b/sys/arm/conf/DIGI-CCWMX53 @@ -17,51 +17,13 @@ # # $FreeBSD$ +#NO_UNIVERSE + +include "IMX53" ident DIGI-CCWMX53 -include "../freescale/imx/std.imx53" - makeoptions WITHOUT_MODULES="ahc" -makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -#options DEBUG - -options SCHED_4BSD # 4BSD scheduler -#options PREEMPTION # Enable kernel thread preemption -options INET # InterNETworking -options INET6 # IPv6 communications protocols -#options SCTP # Stream Control Transmission Protocol -options FFS # Berkeley Fast Filesystem -options SOFTUPDATES # Enable FFS soft updates support -options UFS_ACL # Support for access control lists -options UFS_DIRHASH # Improve performance on big directories -options UFS_GJOURNAL # Enable gjournal-based UFS journaling -#options MD_ROOT # MD is a potential root device -options NFSCL # New Network Filesystem Client -#options NFSD # New Network Filesystem Server -options NFSLOCKD # Network Lock Manager -options NFS_ROOT # NFS usable as /, requires NFSCL -options TMPFS # Efficient memory filesystem -options MSDOSFS # MSDOS Filesystem -options CD9660 # ISO 9660 Filesystem -#options PROCFS # Process filesystem (requires PSEUDOFS) -options PSEUDOFS # Pseudo-filesystem framework -options GEOM_PART_BSD # BSD partition scheme -options GEOM_PART_MBR # MBR partition scheme -options GEOM_PART_GPT # GUID Partition Tables. -options GEOM_LABEL # Provides labelization -#options COMPAT_FREEBSD5 # Compatible with FreeBSD5 -#options COMPAT_FREEBSD6 # Compatible with FreeBSD6 -#options COMPAT_FREEBSD7 # Compatible with FreeBSD7 -options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI -options KTRACE # ktrace(1) support -options SYSVSHM # SYSV-style shared memory -options SYSVMSG # SYSV-style message queues -options SYSVSEM # SYSV-style semaphores -options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions -options INCLUDE_CONFIG_FILE # Include this file in kernel -options VFP # vfp/neon - # required for netbooting #options BOOTP #options BOOTP_COMPAT @@ -71,117 +33,6 @@ options VFP # vfp/neon #options ROOTDEVNAME=\"ufs:ada0s2a\" - -# kernel/memory size reduction -#options MUTEX_NOINLINE -#options NO_FFS_SNAPSHOT -#options NO_SWAPPING -#options NO_SYSCTL_DESCR -#options RWLOCK_NOINLINE - -# Debugging support. Always need this: -options KDB # Enable kernel debugger support. -# For minimum debugger support (stable branch) use: -#options KDB_TRACE # Print a stack trace for a panic. -# For full debugger support use this instead: -options DDB # Support DDB. -#options GDB # Support remote GDB. -options DEADLKRES # Enable the deadlock resolver -options INVARIANTS # Enable calls of extra sanity checking -options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS -options WITNESS # Enable checks to detect deadlocks and cycles - -# The `bpf' device enables the Berkeley Packet Filter. -# Be aware of the administrative consequences of enabling this! -# Note that 'bpf' is required for DHCP. -device bpf # Berkeley packet filter - -# Pseudo devices. -device loop # Network loopback -device random # Entropy device -device ether # Ethernet support -#device vlan # 802.1Q VLAN support -#device tun # Packet tunnel. -#device md # Memory "disks" -#device gif # IPv6 and IPv4 tunneling -#device faith # IPv6-to-IPv4 relaying (translation) -#device firmware # firmware assist module - -# Ethernet -device ffec # Freescale Fast Ethernet Controller -device miibus # Standard mii bus - -# Serial (COM) ports -device uart # Multi-uart driver -options ALT_BREAK_TO_DEBUGGER - -device ata -device atapci # Only for helper functions -device imxata -options ATA_STATIC_ID # Static device numbering - -device gpio -device gpioled - -device fsliic -device iic -device iicbus - -# SCSI peripherals -device scbus # SCSI bus (required for ATA/SCSI) -device da # Direct Access (disks) -device cd # CD -device pass # Passthrough device (direct ATA/SCSI access) - -# USB support -options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. -options USB_DEBUG # enable debug msgs -device ehci # OHCI USB interface -device usb # USB Bus (required) -device umass # Disks/Mass storage - Requires scbus and da -device uhid # "Human Interface Devices" -#device ukbd # Allow keyboard like HIDs to control console -device ums - -# USB Ethernet, requires miibus -#device miibus -#device aue # ADMtek USB Ethernet -#device axe # ASIX Electronics USB Ethernet -#device cdce # Generic USB over Ethernet -#device cue # CATC USB Ethernet -#device kue # Kawasaki LSI USB Ethernet -#device rue # RealTek RTL8150 USB Ethernet -#device udav # Davicom DM9601E USB - -# USB Wireless -#device rum # Ralink Technology RT2501USB wireless NICs - -# Watchdog timer. -# WARNING: can't be disabled!!! -device imxwdt # Watchdog - -# Wireless NIC cards -device wlan # 802.11 support -device wlan_wep # 802.11 WEP support -device wlan_ccmp # 802.11 CCMP support -device wlan_tkip # 802.11 TKIP support -device wlan_amrr # AMRR transmit rate control algorithm - -# MMC -#device sdhci # SD controller -#device mmc # SD/MMC protocol -#device mmcsd # SDCard disk device - - # Flattened Device Tree -options FDT options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=digi-ccwmx53.dts - -# NOTE: serial console will be disabled if syscons enabled -# Uncomment following lines for framebuffer/syscons support -#device sc -#device vt -#device kbdmux -#options SC_DFLT_FONT # compile font in -#makeoptions SC_DFLT_FONT=cp437 diff --git a/sys/arm/conf/IMX53 b/sys/arm/conf/IMX53 new file mode 100644 index 000000000000..1396578e3e58 --- /dev/null +++ b/sys/arm/conf/IMX53 @@ -0,0 +1,173 @@ +# Kernel configuration for i.MX53 boards +# +# For more information on this file, please read the config(5) manual page, +# and/or the handbook section on Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD$ + +ident IMX53 + +include "../freescale/imx/std.imx53" + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +#options DEBUG + +options SCHED_4BSD # 4BSD scheduler +#options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +#options SCTP # Stream Control Transmission Protocol +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options UFS_GJOURNAL # Enable gjournal-based UFS journaling +#options MD_ROOT # MD is a potential root device +options NFSCL # New Network Filesystem Client +#options NFSD # New Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCL +options TMPFS # Efficient memory filesystem +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +#options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_PART_BSD # BSD partition scheme +options GEOM_PART_MBR # MBR partition scheme +options GEOM_PART_GPT # GUID Partition Tables. +options GEOM_LABEL # Provides labelization +#options COMPAT_FREEBSD5 # Compatible with FreeBSD5 +#options COMPAT_FREEBSD6 # Compatible with FreeBSD6 +#options COMPAT_FREEBSD7 # Compatible with FreeBSD7 +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options INCLUDE_CONFIG_FILE # Include this file in kernel +options VFP # vfp/neon + +# kernel/memory size reduction +#options MUTEX_NOINLINE +#options NO_FFS_SNAPSHOT +#options NO_SWAPPING +#options NO_SYSCTL_DESCR +#options RWLOCK_NOINLINE + +# Debugging support. Always need this: +options KDB # Enable kernel debugger support. +# For minimum debugger support (stable branch) use: +#options KDB_TRACE # Print a stack trace for a panic. +# For full debugger support use this instead: +options DDB # Support DDB. +#options GDB # Support remote GDB. +options DEADLKRES # Enable the deadlock resolver +options INVARIANTS # Enable calls of extra sanity checking +options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +options WITNESS # Enable checks to detect deadlocks and cycles + +# The `bpf' device enables the Berkeley Packet Filter. +# Be aware of the administrative consequences of enabling this! +# Note that 'bpf' is required for DHCP. +device bpf # Berkeley packet filter + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +#device vlan # 802.1Q VLAN support +#device tun # Packet tunnel. +device md # Memory "disks" +#device gif # IPv6 and IPv4 tunneling +#device faith # IPv6-to-IPv4 relaying (translation) +#device firmware # firmware assist module + +# Ethernet +device ffec # Freescale Fast Ethernet Controller +device miibus # Standard mii bus + +# Serial (COM) ports +device uart # Multi-uart driver +options ALT_BREAK_TO_DEBUGGER + +device ata +device atapci # Only for helper functions +device imxata +options ATA_STATIC_ID # Static device numbering + +device gpio +device gpioled + +device fsliic +device iic +device iicbus + +# SCSI peripherals +device scbus # SCSI bus (required for ATA/SCSI) +device da # Direct Access (disks) +device cd # CD +device pass # Passthrough device (direct ATA/SCSI access) + +# USB support +options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. +options USB_DEBUG # enable debug msgs +device ehci # OHCI USB interface +device usb # USB Bus (required) +device umass # Disks/Mass storage - Requires scbus and da +device uhid # "Human Interface Devices" +#device ukbd # Allow keyboard like HIDs to control console +device ums + +# USB Ethernet, requires miibus +#device miibus +#device aue # ADMtek USB Ethernet +#device axe # ASIX Electronics USB Ethernet +#device cdce # Generic USB over Ethernet +#device cue # CATC USB Ethernet +#device kue # Kawasaki LSI USB Ethernet +#device rue # RealTek RTL8150 USB Ethernet +#device udav # Davicom DM9601E USB + +# USB Wireless +#device rum # Ralink Technology RT2501USB wireless NICs + +# Watchdog timer. +# WARNING: can't be disabled!!! +device imxwdt # Watchdog + +# Wireless NIC cards +device wlan # 802.11 support +device wlan_wep # 802.11 WEP support +device wlan_ccmp # 802.11 CCMP support +device wlan_tkip # 802.11 TKIP support +device wlan_amrr # AMRR transmit rate control algorithm + +# MMC +#device sdhci # SD controller +#device mmc # SD/MMC protocol +#device mmcsd # SDCard disk device + + +# Flattened Device Tree +options FDT + +# NOTE: serial console will be disabled if syscons enabled +# Uncomment following lines for framebuffer/syscons support +#device sc +#device vt +#device kbdmux +#options SC_DFLT_FONT # compile font in +#makeoptions SC_DFLT_FONT=cp437 diff --git a/sys/arm/conf/IMX53-QSB b/sys/arm/conf/IMX53-QSB index e4c3ad6e51c1..fdaa4ec0f405 100644 --- a/sys/arm/conf/IMX53-QSB +++ b/sys/arm/conf/IMX53-QSB @@ -17,49 +17,12 @@ # # $FreeBSD$ +#NO_UNIVERSE + +include "IMX53" ident IMX53-QSB -include "../freescale/imx/std.imx53" - -makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -#options DEBUG - options HZ=250 # 4ms scheduling quantum -options SCHED_4BSD # 4BSD scheduler -#options PREEMPTION # Enable kernel thread preemption -options INET # InterNETworking -options INET6 # IPv6 communications protocols -#options SCTP # Stream Control Transmission Protocol -options FFS # Berkeley Fast Filesystem -options SOFTUPDATES # Enable FFS soft updates support -options UFS_ACL # Support for access control lists -options UFS_DIRHASH # Improve performance on big directories -options UFS_GJOURNAL # Enable gjournal-based UFS journaling -#options MD_ROOT # MD is a potential root device -options NFSCL # New Network Filesystem Client -#options NFSD # New Network Filesystem Server -options NFSLOCKD # Network Lock Manager -options NFS_ROOT # NFS usable as /, requires NFSCL -options TMPFS # Efficient memory filesystem -options MSDOSFS # MSDOS Filesystem -options CD9660 # ISO 9660 Filesystem -#options PROCFS # Process filesystem (requires PSEUDOFS) -options PSEUDOFS # Pseudo-filesystem framework -options GEOM_PART_BSD # BSD partition scheme -options GEOM_PART_MBR # MBR partition scheme -options GEOM_PART_GPT # GUID Partition Tables. -options GEOM_LABEL # Provides labelization -#options COMPAT_FREEBSD5 # Compatible with FreeBSD5 -#options COMPAT_FREEBSD6 # Compatible with FreeBSD6 -#options COMPAT_FREEBSD7 # Compatible with FreeBSD7 -options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI -options KTRACE # ktrace(1) support -options SYSVSHM # SYSV-style shared memory -options SYSVMSG # SYSV-style message queues -options SYSVSEM # SYSV-style semaphores -options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions -options INCLUDE_CONFIG_FILE # Include this file in kernel -options VFP # vfp/neon # required for netbooting #options BOOTP @@ -70,111 +33,6 @@ options VFP # vfp/neon #options ROOTDEVNAME=\"ufs:ada0s2a\" - -# kernel/memory size reduction -#options MUTEX_NOINLINE -#options NO_FFS_SNAPSHOT -#options NO_SWAPPING -#options NO_SYSCTL_DESCR -#options RWLOCK_NOINLINE - -# Debugging support. Always need this: -options KDB # Enable kernel debugger support. -# For minimum debugger support (stable branch) use: -#options KDB_TRACE # Print a stack trace for a panic. -# For full debugger support use this instead: -options DDB # Support DDB. -#options GDB # Support remote GDB. -#options DEADLKRES # Enable the deadlock resolver -#options INVARIANTS # Enable calls of extra sanity checking -#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS -#options WITNESS # Enable checks to detect deadlocks and cycles - -# The `bpf' device enables the Berkeley Packet Filter. -# Be aware of the administrative consequences of enabling this! -# Note that 'bpf' is required for DHCP. -device bpf # Berkeley packet filter - -# Pseudo devices. -device loop # Network loopback -device random # Entropy device -device ether # Ethernet support -#device vlan # 802.1Q VLAN support -#device tun # Packet tunnel. -device md # Memory "disks" -#device gif # IPv6 and IPv4 tunneling -#device faith # IPv6-to-IPv4 relaying (translation) -#device firmware # firmware assist module - -# Ethernet -device ffec # Freescale Fast Ethernet Controller -device miibus # Standard mii bus - -# Serial (COM) ports -device uart # Multi-uart driver -options ALT_BREAK_TO_DEBUGGER - -#device ata -#device atapci # Only for helper functions -#device imxata -#options ATA_STATIC_ID # Static device numbering - -device gpio -device gpioled - -device fsliic -device iic -device iicbus - -# SCSI peripherals -device scbus # SCSI bus (required for ATA/SCSI) -device da # Direct Access (disks) -device cd # CD -device pass # Passthrough device (direct ATA/SCSI access) - -# USB support -options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. -#options USB_DEBUG # enable debug msgs -device ehci # OHCI USB interface -device usb # USB Bus (required) -device umass # Disks/Mass storage - Requires scbus and da -#device uhid # "Human Interface Devices" -#device ukbd # Allow keyboard like HIDs to control console -#device ums - -# USB Ethernet, requires miibus -#device miibus -#device aue # ADMtek USB Ethernet -#device axe # ASIX Electronics USB Ethernet -#device cdce # Generic USB over Ethernet -#device cue # CATC USB Ethernet -#device kue # Kawasaki LSI USB Ethernet -#device rue # RealTek RTL8150 USB Ethernet -#device udav # Davicom DM9601E USB - -# USB Wireless -#device rum # Ralink Technology RT2501USB wireless NICs - -# Watchdog timer. -# WARNING: can't be disabled!!! -device imxwdt # Watchdog - -# Wireless NIC cards -device wlan # 802.11 support -device wlan_wep # 802.11 WEP support -device wlan_ccmp # 802.11 CCMP support -device wlan_tkip # 802.11 TKIP support -device wlan_amrr # AMRR transmit rate control algorithm - # Flattened Device Tree -options FDT options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=imx53-qsb.dts - -# NOTE: serial console will be disabled if syscons enabled -# Uncomment following lines for framebuffer/syscons support -#device sc -#device kbdmux -#options SC_DFLT_FONT # compile font in -#makeoptions SC_DFLT_FONT=cp437 - diff --git a/sys/arm/conf/LN2410SBC b/sys/arm/conf/LN2410SBC index 4c7480cac7f6..d4407eb509a4 100644 --- a/sys/arm/conf/LN2410SBC +++ b/sys/arm/conf/LN2410SBC @@ -19,7 +19,7 @@ ident LN2410SBC -include "../s3c2xx0/std.ln2410sbc" +include "../samsung/s3c2xx0/std.ln2410sbc" #To statically compile in device wiring instead of /boot/device.hints #hints "GENERIC.hints" # Default places to look for devices. makeoptions MODULES_OVERRIDE="" diff --git a/sys/arm/conf/NOTES b/sys/arm/conf/NOTES index 6a0218d6cee1..fa413bf861d7 100644 --- a/sys/arm/conf/NOTES +++ b/sys/arm/conf/NOTES @@ -19,7 +19,7 @@ files "../mv/discovery/files.db78xxx" files "../mv/kirkwood/files.kirkwood" files "../mv/orion/files.db88f5xxx" files "../mv/orion/files.ts7800" -files "../s3c2xx0/files.s3c2xx0" +files "../samsung/s3c2xx0/files.s3c2xx0" files "../xscale/i80321/files.ep80219" files "../xscale/i80321/files.i80219" files "../xscale/i80321/files.i80321" diff --git a/sys/arm/conf/SOCKIT b/sys/arm/conf/SOCKIT index e524f30ee1bf..d56a7f222e49 100644 --- a/sys/arm/conf/SOCKIT +++ b/sys/arm/conf/SOCKIT @@ -124,6 +124,7 @@ device ether device mii device smsc device smscphy +device dwc # USB ethernet support, requires miibus device miibus diff --git a/sys/arm/freescale/imx/files.imx51 b/sys/arm/freescale/imx/files.imx51 index f1c2c5d7ed25..951cb4d148b1 100644 --- a/sys/arm/freescale/imx/files.imx51 +++ b/sys/arm/freescale/imx/files.imx51 @@ -19,7 +19,7 @@ arm/arm/bus_space-v6.c standard arm/freescale/imx/tzic.c standard # IOMUX - external pins multiplexor -arm/freescale/imx/imx51_iomux.c standard +arm/freescale/imx/imx_iomux.c standard # GPIO arm/freescale/imx/imx_gpio.c optional gpio @@ -37,7 +37,7 @@ dev/ata/chipsets/ata-fsl.c optional imxata dev/uart/uart_dev_imx.c optional uart # USB OH3 controller (1 OTG, 3 EHCI) -arm/freescale/imx/imx_nop_usbphy.c optional echi +arm/freescale/imx/imx_nop_usbphy.c optional ehci dev/usb/controller/ehci_imx.c optional ehci # Watchdog diff --git a/sys/arm/freescale/imx/files.imx53 b/sys/arm/freescale/imx/files.imx53 index 01fb10edf1a4..3918400edab1 100644 --- a/sys/arm/freescale/imx/files.imx53 +++ b/sys/arm/freescale/imx/files.imx53 @@ -22,7 +22,7 @@ dev/uart/uart_dev_imx.c optional uart arm/freescale/imx/tzic.c standard # IOMUX - external pins multiplexor -arm/freescale/imx/imx51_iomux.c standard +arm/freescale/imx/imx_iomux.c standard # GPIO arm/freescale/imx/imx_gpio.c optional gpio diff --git a/sys/arm/freescale/imx/files.imx6 b/sys/arm/freescale/imx/files.imx6 index e66ef8b8f8d4..2fc6d3fb7dfc 100644 --- a/sys/arm/freescale/imx/files.imx6 +++ b/sys/arm/freescale/imx/files.imx6 @@ -20,11 +20,10 @@ arm/arm/mpcore_timer.c standard arm/freescale/fsl_ocotp.c standard arm/freescale/imx/imx6_anatop.c standard arm/freescale/imx/imx6_ccm.c standard -arm/freescale/imx/imx6_iomux.c standard arm/freescale/imx/imx6_machdep.c standard arm/freescale/imx/imx6_mp.c optional smp arm/freescale/imx/imx6_pl310.c standard -arm/freescale/imx/imx_common.c standard +arm/freescale/imx/imx_iomux.c standard arm/freescale/imx/imx_machdep.c standard arm/freescale/imx/imx_gpt.c standard arm/freescale/imx/imx_gpio.c optional gpio diff --git a/sys/arm/freescale/imx/imx51_iomux.c b/sys/arm/freescale/imx/imx51_iomux.c deleted file mode 100644 index 1953b7a95831..000000000000 --- a/sys/arm/freescale/imx/imx51_iomux.c +++ /dev/null @@ -1,249 +0,0 @@ -/* $NetBSD: imx51_iomux.c,v 1.3 2012/04/15 09:51:31 bsh Exp $ */ - -/* - * Copyright (c) 2009, 2010 Genetec Corporation. All rights reserved. - * Written by Hashimoto Kenichi for Genetec Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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 GENETEC CORPORATION ``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 GENETEC CORPORATION - * 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. - */ - -/*- - * Copyright (c) 2012, 2013 The FreeBSD Foundation - * All rights reserved. - * - * Portions of this software were developed by Oleksandr Rybalko - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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 "imx51_iomuxreg.h" - - -#define IOMUX_WRITE(_sc, _r, _v) \ - bus_write_4((_sc)->sc_res, (_r), (_v)) -#define IOMUX_READ(_sc, _r) \ - bus_read_4((_sc)->sc_res, (_r)) -#define IOMUX_SET(_sc, _r, _m) \ - IOMUX_WRITE((_sc), (_r), IOMUX_READ((_sc), (_r)) | (_m)) -#define IOMUX_CLEAR(_sc, _r, _m) \ - IOMUX_WRITE((_sc), (_r), IOMUX_READ((_sc), (_r)) & ~(_m)) - -struct iomux_softc { - struct resource *sc_res; - device_t sc_dev; -}; - -static int iomux_probe(device_t); -static int iomux_attach(device_t); - -static struct iomux_softc *iomuxsc = NULL; - -static struct resource_spec imx_iomux_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Global registers */ - { -1, 0 } -}; - -static int -iomux_probe(device_t dev) -{ - - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (!ofw_bus_is_compatible(dev, "fsl,imx51-iomux") && - !ofw_bus_is_compatible(dev, "fsl,imx53-iomux")) - return (ENXIO); - - device_set_desc(dev, "Freescale i.MX51 IO pins multiplexor"); - return (BUS_PROBE_DEFAULT); -} - -static int -iomux_attach(device_t dev) -{ - struct iomux_softc * sc; - - sc = device_get_softc(dev); - - if (bus_alloc_resources(dev, imx_iomux_spec, &sc->sc_res)) { - device_printf(dev, "could not allocate resources\n"); - return (ENXIO); - } - - iomuxsc = sc; - - /* - * XXX: place to fetch all info about pinmuxing from loader data - * (FDT blob) and apply. Loader (1st one) must care about - * device-to-device difference. - */ - - return (0); -} - -static void -iomux_set_function_sub(struct iomux_softc *sc, uint32_t pin, uint32_t fn) -{ - bus_size_t mux_ctl_reg = IOMUX_PIN_TO_MUX_ADDRESS(pin); - - if (mux_ctl_reg != IOMUX_MUX_NONE) - IOMUX_WRITE(sc, mux_ctl_reg, fn); -} - -void -iomux_set_function(unsigned int pin, unsigned int fn) -{ - - if (iomuxsc == NULL) - return; - iomux_set_function_sub(iomuxsc, pin, fn); -} - -static void -iomux_set_pad_sub(struct iomux_softc *sc, uint32_t pin, uint32_t config) -{ - bus_size_t pad_ctl_reg = IOMUX_PIN_TO_PAD_ADDRESS(pin); - - if (pad_ctl_reg != IOMUX_PAD_NONE) - IOMUX_WRITE(sc, pad_ctl_reg, config); -} - -void -iomux_set_pad(unsigned int pin, unsigned int config) -{ - - if (iomuxsc == NULL) - return; - iomux_set_pad_sub(iomuxsc, pin, config); -} - -static uint32_t -iomux_get_pad_config_sub(struct iomux_softc *sc, uint32_t pin) -{ - bus_size_t pad_reg = IOMUX_PIN_TO_PAD_ADDRESS(pin); - uint32_t result; - - result = IOMUX_READ(sc, pad_reg); - - return(result); -} - -unsigned int -iomux_get_pad_config(unsigned int pin) -{ - - return(iomux_get_pad_config_sub(iomuxsc, pin)); -} - -uint32_t -imx_iomux_gpr_get(u_int regnum) -{ - - KASSERT(iomuxsc != NULL, ("imx_iomux_gpr_get() called before attach")); - KASSERT(regnum >= 0 && regnum <= 1, - ("imx_iomux_gpr_get bad regnum %u", regnum)); - return (IOMUX_READ(iomuxsc, IOMUXC_GPR0 + regnum)); -} - -void -imx_iomux_gpr_set(u_int regnum, uint32_t val) -{ - - KASSERT(iomuxsc != NULL, ("imx_iomux_gpr_set() called before attach")); - KASSERT(regnum >= 0 && regnum <= 1, - ("imx_iomux_gpr_set bad regnum %u", regnum)); - IOMUX_WRITE(iomuxsc, IOMUXC_GPR0 + regnum, val); -} - -void -imx_iomux_gpr_set_masked(u_int regnum, uint32_t clrbits, uint32_t setbits) -{ - uint32_t val; - - KASSERT(iomuxsc != NULL, - ("imx_iomux_gpr_set_masked called before attach")); - KASSERT(regnum >= 0 && regnum <= 1, - ("imx_iomux_gpr_set_masked bad regnum %u", regnum)); - - val = IOMUX_READ(iomuxsc, IOMUXC_GPR0 + regnum); - val = (val & ~clrbits) | setbits; - IOMUX_WRITE(iomuxsc, IOMUXC_GPR0 + regnum, val); -} - -static device_method_t imx_iomux_methods[] = { - DEVMETHOD(device_probe, iomux_probe), - DEVMETHOD(device_attach, iomux_attach), - - DEVMETHOD_END -}; - -static driver_t imx_iomux_driver = { - "imx_iomux", - imx_iomux_methods, - sizeof(struct iomux_softc), -}; - -static devclass_t imx_iomux_devclass; - -EARLY_DRIVER_MODULE(imx_iomux, simplebus, imx_iomux_driver, - imx_iomux_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE); - diff --git a/sys/arm/freescale/imx/imx51_iomuxreg.h b/sys/arm/freescale/imx/imx51_iomuxreg.h deleted file mode 100644 index 1e90ffe58b06..000000000000 --- a/sys/arm/freescale/imx/imx51_iomuxreg.h +++ /dev/null @@ -1,761 +0,0 @@ -/* - * This file was generated automatically from PDF file by mkiomuxreg_imx51.rb - * - */ - -/*- - * Copyright (c) 2012, 2013 The FreeBSD Foundation - * All rights reserved. - * - * Portions of this software were developed by Oleksandr Rybalko - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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 _IMX51_IOMUXREG_H -#define _IMX51_IOMUXREG_H - -#define IOMUXC_MUX_CTL 0x001c /* multiplex control */ -#define IOMUX_CONFIG_SION (1 << 4) -#define IOMUX_CONFIG_ALT0 (0) -#define IOMUX_CONFIG_ALT1 (1) -#define IOMUX_CONFIG_ALT2 (2) -#define IOMUX_CONFIG_ALT3 (3) -#define IOMUX_CONFIG_ALT4 (4) -#define IOMUX_CONFIG_ALT5 (5) -#define IOMUX_CONFIG_ALT6 (6) -#define IOMUX_CONFIG_ALT7 (7) -#define IOMUXC_PAD_CTL 0x03f0 /* pad control */ -#define PAD_CTL_HVE (1 << 13) -#define PAD_CTL_DDR_INPUT (1 << 9) -#define PAD_CTL_HYS (1 << 8) -#define PAD_CTL_PKE (1 << 7) -#define PAD_CTL_PUE (1 << 6) -#define PAD_CTL_PULL (PAD_CTL_PKE|PAD_CTL_PUE) -#define PAD_CTL_KEEPER (PAD_CTL_PKE|0) -#define PAD_CTL_PUS_100K_PD (0x0 << 4) -#define PAD_CTL_PUS_47K_PU (0x1 << 4) -#define PAD_CTL_PUS_100K_PU (0x2 << 4) -#define PAD_CTL_PUS_22K_PU (0x3 << 4) -#define PAD_CTL_ODE (1 << 3) /* opendrain */ -#define PAD_CTL_DSE_LOW (0x0 << 1) -#define PAD_CTL_DSE_MID (0x1 << 1) -#define PAD_CTL_DSE_HIGH (0x2 << 1) -#define PAD_CTL_DSE_MAX (0x3 << 1) -#define PAD_CTL_SRE (1 << 0) -#define IOMUXC_INPUT_CTL 0x08c4 /* input control */ -#define INPUT_DAISY_0 0 -#define INPUT_DAISY_1 1 -#define INPUT_DAISY_2 2 -#define INPUT_DAISY_3 3 -#define INPUT_DAISY_4 4 -#define INPUT_DAISY_5 5 -#define INPUT_DAISY_6 6 -#define INPUT_DAISY_7 7 - -/* - * IOMUX index - */ -#define IOMUX_PIN_TO_MUX_ADDRESS(pin) (((pin) >> 16) & 0xffff) -#define IOMUX_PIN_TO_PAD_ADDRESS(pin) (((pin) >> 0) & 0xffff) - -#define IOMUX_PIN(mux_adr, pad_adr) \ - (((mux_adr) << 16) | (((pad_adr) << 0))) -#define IOMUX_MUX_NONE 0xffff -#define IOMUX_PAD_NONE 0xffff - -/* register offset address */ -#define IOMUXC_GPR0 0x0000 -#define IOMUXC_GPR1 0x0004 -#define IOMUXC_OBSERVE_MUX_0 0x0008 -#define IOMUXC_OBSERVE_MUX_1 0x000c -#define IOMUXC_OBSERVE_MUX_2 0x0010 -#define IOMUXC_OBSERVE_MUX_3 0x0014 -#define IOMUXC_OBSERVE_MUX_4 0x0018 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA0 0x001c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA1 0x0020 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA2 0x0024 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA3 0x0028 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA4 0x002c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA5 0x0030 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA6 0x0034 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA7 0x0038 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA8 0x003c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA9 0x0040 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA10 0x0044 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA11 0x0048 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA12 0x004c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA13 0x0050 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA14 0x0054 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DA15 0x0058 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D16 0x005c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D17 0x0060 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D18 0x0064 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D19 0x0068 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D20 0x006c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D21 0x0070 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D22 0x0074 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D23 0x0078 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D24 0x007c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D25 0x0080 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D26 0x0084 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D27 0x0088 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D28 0x008c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D29 0x0090 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D30 0x0094 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_D31 0x0098 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A16 0x009c -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A17 0x00a0 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A18 0x00a4 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A19 0x00a8 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A20 0x00ac -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A21 0x00b0 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A22 0x00b4 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A23 0x00b8 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A24 0x00bc -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A25 0x00c0 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A26 0x00c4 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_A27 0x00c8 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB0 0x00cc -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB1 0x00d0 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB2 0x00d4 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB3 0x00d8 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_OE 0x00dc -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS0 0x00e0 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS1 0x00e4 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS2 0x00e8 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS3 0x00ec -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS4 0x00f0 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS5 0x00f4 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DTACK 0x00f8 -#define IOMUXC_SW_MUX_CTL_PAD_EIM_LBA 0x00fc -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CRE 0x0100 -#define IOMUXC_SW_MUX_CTL_PAD_DRAM_CS1 0x0104 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_WE_B 0x0108 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_RE_B 0x010c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_ALE 0x0110 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CLE 0x0114 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_WP_B 0x0118 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_RB0 0x011c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_RB1 0x0120 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_RB2 0x0124 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_RB3 0x0128 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO_NAND 0x012c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS0 0x0130 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS1 0x0134 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS2 0x0138 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS3 0x013c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS4 0x0140 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS5 0x0144 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS6 0x0148 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_CS7 0x014c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_RDY_INT 0x0150 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D15 0x0154 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D14 0x0158 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D13 0x015c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D12 0x0160 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D11 0x0164 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D10 0x0168 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D9 0x016c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D8 0x0170 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D7 0x0174 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D6 0x0178 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D5 0x017c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D4 0x0180 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D3 0x0184 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D2 0x0188 -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D1 0x018c -#define IOMUXC_SW_MUX_CTL_PAD_NANDF_D0 0x0190 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D8 0x0194 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D9 0x0198 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D10 0x019c -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D11 0x01a0 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D12 0x01a4 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D13 0x01a8 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D14 0x01ac -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D15 0x01b0 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D16 0x01b4 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D17 0x01b8 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D18 0x01bc -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_D19 0x01c0 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_VSYNC 0x01c4 -#define IOMUXC_SW_MUX_CTL_PAD_CSI1_HSYNC 0x01c8 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D12 0x01cc -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D13 0x01d0 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D14 0x01d4 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D15 0x01d8 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D16 0x01dc -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D17 0x01e0 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D18 0x01e4 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_D19 0x01e8 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_VSYNC 0x01ec -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_HSYNC 0x01f0 -#define IOMUXC_SW_MUX_CTL_PAD_CSI2_PIXCLK 0x01f4 -#define IOMUXC_SW_MUX_CTL_PAD_I2C1_CLK 0x01f8 -#define IOMUXC_SW_MUX_CTL_PAD_I2C1_DAT 0x01fc -#define IOMUXC_SW_MUX_CTL_PAD_AUD3_BB_TXD 0x0200 -#define IOMUXC_SW_MUX_CTL_PAD_AUD3_BB_RXD 0x0204 -#define IOMUXC_SW_MUX_CTL_PAD_AUD3_BB_CK 0x0208 -#define IOMUXC_SW_MUX_CTL_PAD_AUD3_BB_FS 0x020c -#define IOMUXC_SW_MUX_CTL_PAD_CSPI1_MOSI 0x0210 -#define IOMUXC_SW_MUX_CTL_PAD_CSPI1_MISO 0x0214 -#define IOMUXC_SW_MUX_CTL_PAD_CSPI1_SS0 0x0218 -#define IOMUXC_SW_MUX_CTL_PAD_CSPI1_SS1 0x021c -#define IOMUXC_SW_MUX_CTL_PAD_CSPI1_RDY 0x0220 -#define IOMUXC_SW_MUX_CTL_PAD_CSPI1_SCLK 0x0224 -#define IOMUXC_SW_MUX_CTL_PAD_UART1_RXD 0x0228 -#define IOMUXC_SW_MUX_CTL_PAD_UART1_TXD 0x022c -#define IOMUXC_SW_MUX_CTL_PAD_UART1_RTS 0x0230 -#define IOMUXC_SW_MUX_CTL_PAD_UART1_CTS 0x0234 -#define IOMUXC_SW_MUX_CTL_PAD_UART2_RXD 0x0238 -#define IOMUXC_SW_MUX_CTL_PAD_UART2_TXD 0x023c -#define IOMUXC_SW_MUX_CTL_PAD_UART3_RXD 0x0240 -#define IOMUXC_SW_MUX_CTL_PAD_UART3_TXD 0x0244 -#define IOMUXC_SW_MUX_CTL_PAD_OWIRE_LINE 0x0248 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW0 0x024c -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW1 0x0250 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW2 0x0254 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW3 0x0258 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL0 0x025c -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL1 0x0260 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL2 0x0264 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL3 0x0268 -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL4 0x026c -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL5 0x0270 -#define IOMUXC_SW_MUX_CTL_PAD_JTAG_DE_B 0x0274 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_CLK 0x0278 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DIR 0x027c -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_STP 0x0280 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_NXT 0x0284 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA0 0x0288 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA1 0x028c -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA2 0x0290 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA3 0x0294 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA4 0x0298 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA5 0x029c -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA6 0x02a0 -#define IOMUXC_SW_MUX_CTL_PAD_USBH1_DATA7 0x02a4 -#define IOMUXC_SW_MUX_CTL_PAD_DI1_PIN11 0x02a8 -#define IOMUXC_SW_MUX_CTL_PAD_DI1_PIN12 0x02ac -#define IOMUXC_SW_MUX_CTL_PAD_DI1_PIN13 0x02b0 -#define IOMUXC_SW_MUX_CTL_PAD_DI1_D0_CS 0x02b4 -#define IOMUXC_SW_MUX_CTL_PAD_DI1_D1_CS 0x02b8 -#define IOMUXC_SW_MUX_CTL_PAD_DISPB2_SER_DIN 0x02bc -#define IOMUXC_SW_MUX_CTL_PAD_DISPB2_SER_DIO 0x02c0 -#define IOMUXC_SW_MUX_CTL_PAD_DISPB2_SER_CLK 0x02c4 -#define IOMUXC_SW_MUX_CTL_PAD_DISPB2_SER_RS 0x02c8 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT0 0x02cc -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT1 0x02d0 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT2 0x02d4 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT3 0x02d8 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT4 0x02dc -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT5 0x02e0 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT6 0x02e4 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT7 0x02e8 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT8 0x02ec -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT9 0x02f0 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT10 0x02f4 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT11 0x02f8 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT12 0x02fc -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT13 0x0300 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT14 0x0304 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT15 0x0308 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT16 0x030c -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT17 0x0310 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT18 0x0314 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT19 0x0318 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT20 0x031c -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT21 0x0320 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT22 0x0324 -#define IOMUXC_SW_MUX_CTL_PAD_DISP1_DAT23 0x0328 -#define IOMUXC_SW_MUX_CTL_PAD_DI1_PIN3 0x032c -#define IOMUXC_SW_MUX_CTL_PAD_DI1_PIN2 0x0330 -#define IOMUXC_SW_MUX_CTL_PAD_DI_GP1 0x0334 -#define IOMUXC_SW_MUX_CTL_PAD_DI_GP2 0x0338 -#define IOMUXC_SW_MUX_CTL_PAD_DI_GP3 0x033c -#define IOMUXC_SW_MUX_CTL_PAD_DI2_PIN4 0x0340 -#define IOMUXC_SW_MUX_CTL_PAD_DI2_PIN2 0x0344 -#define IOMUXC_SW_MUX_CTL_PAD_DI2_PIN3 0x0348 -#define IOMUXC_SW_MUX_CTL_PAD_DI2_DISP_CLK 0x034c -#define IOMUXC_SW_MUX_CTL_PAD_DI_GP4 0x0350 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT0 0x0354 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT1 0x0358 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT2 0x035c -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT3 0x0360 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT4 0x0364 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT5 0x0368 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT6 0x036c -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT7 0x0370 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT8 0x0374 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT9 0x0378 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT10 0x037c -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT11 0x0380 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT12 0x0384 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT13 0x0388 -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT14 0x038c -#define IOMUXC_SW_MUX_CTL_PAD_DISP2_DAT15 0x0390 -#define IOMUXC_SW_MUX_CTL_PAD_SD1_CMD 0x0394 -#define IOMUXC_SW_MUX_CTL_PAD_SD1_CLK 0x0398 -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA0 0x039c -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA1 0x03a0 -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA2 0x03a4 -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA3 0x03a8 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_0 0x03ac -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_1 0x03b0 -#define IOMUXC_SW_MUX_CTL_PAD_SD2_CMD 0x03b4 -#define IOMUXC_SW_MUX_CTL_PAD_SD2_CLK 0x03b8 -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA0 0x03bc -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA1 0x03c0 -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA2 0x03c4 -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA3 0x03c8 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_2 0x03cc -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_3 0x03d0 -#define IOMUXC_SW_MUX_CTL_PAD_PMIC_INT_REQ 0x03d4 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_4 0x03d8 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_5 0x03dc -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_6 0x03e0 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_7 0x03e4 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_8 0x03e8 -#define IOMUXC_SW_MUX_CTL_PAD_GPIO1_9 0x03ec -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D16 0x03f0 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D17 0x03f4 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D18 0x03f8 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D19 0x03fc -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D20 0x0400 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D21 0x0404 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D22 0x0408 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D23 0x040c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D24 0x0410 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D25 0x0414 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D26 0x0418 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D27 0x041c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D28 0x0420 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D29 0x0424 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D30 0x0428 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_D31 0x042c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A16 0x0430 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A17 0x0434 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A18 0x0438 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A19 0x043c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A20 0x0440 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A21 0x0444 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A22 0x0448 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A23 0x044c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A24 0x0450 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A25 0x0454 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A26 0x0458 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_A27 0x045c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB0 0x0460 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB1 0x0464 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB2 0x0468 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB3 0x046c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_OE 0x0470 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS0 0x0474 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS1 0x0478 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS2 0x047c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS3 0x0480 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS4 0x0484 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS5 0x0488 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DTACK 0x048c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT 0x0490 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_LBA 0x0494 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_BCLK 0x0498 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_RW 0x049c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CRE 0x04a0 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS 0x04a4 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS 0x04a8 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDWE 0x04ac -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCKE0 0x04b0 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCKE1 0x04b4 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK 0x04b8 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0 0x04bc -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1 0x04c0 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS2 0x04c4 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS3 0x04c8 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CS0 0x04cc -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CS1 0x04d0 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0 0x04d4 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1 0x04d8 -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM2 0x04dc -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM3 0x04e0 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_WE_B 0x04e4 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_RE_B 0x04e8 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_ALE 0x04ec -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CLE 0x04f0 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_WP_B 0x04f4 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_RB0 0x04f8 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_RB1 0x04fc -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_RB2 0x0500 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_RB3 0x0504 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_SDBA2 0x0508 -#define IOMUXC_SW_PAD_CTL_PAD_EIM_SDODT1 0x050c -#define IOMUXC_SW_PAD_CTL_PAD_EIM_SDODT0 0x0510 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO_NAND 0x0514 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS0 0x0518 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS1 0x051c -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS2 0x0520 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS3 0x0524 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS4 0x0528 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS5 0x052c -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS6 0x0530 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_CS7 0x0534 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_RDY_INT 0x0538 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D15 0x053c -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D14 0x0540 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D13 0x0544 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D12 0x0548 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D11 0x054c -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D10 0x0550 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D9 0x0554 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D8 0x0558 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D7 0x055c -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D6 0x0560 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D5 0x0564 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D4 0x0568 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D3 0x056c -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D2 0x0570 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D1 0x0574 -#define IOMUXC_SW_PAD_CTL_PAD_NANDF_D0 0x0578 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D8 0x057c -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D9 0x0580 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D10 0x0584 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D11 0x0588 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D12 0x058c -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D13 0x0590 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D14 0x0594 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D15 0x0598 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D16 0x059c -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D17 0x05a0 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D18 0x05a4 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_D19 0x05a8 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_VSYNC 0x05ac -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_HSYNC 0x05b0 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_PIXCLK 0x05b4 -#define IOMUXC_SW_PAD_CTL_PAD_CSI1_MCLK 0x05b8 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D12 0x05bc -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D13 0x05c0 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D14 0x05c4 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D15 0x05c8 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D16 0x05cc -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D17 0x05d0 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D18 0x05d4 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_D19 0x05d8 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_VSYNC 0x05dc -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_HSYNC 0x05e0 -#define IOMUXC_SW_PAD_CTL_PAD_CSI2_PIXCLK 0x05e4 -#define IOMUXC_SW_PAD_CTL_PAD_I2C1_CLK 0x05e8 -#define IOMUXC_SW_PAD_CTL_PAD_I2C1_DAT 0x05ec -#define IOMUXC_SW_PAD_CTL_PAD_AUD3_BB_TXD 0x05f0 -#define IOMUXC_SW_PAD_CTL_PAD_AUD3_BB_RXD 0x05f4 -#define IOMUXC_SW_PAD_CTL_PAD_AUD3_BB_CK 0x05f8 -#define IOMUXC_SW_PAD_CTL_PAD_AUD3_BB_FS 0x05fc -#define IOMUXC_SW_PAD_CTL_PAD_CSPI1_MOSI 0x0600 -#define IOMUXC_SW_PAD_CTL_PAD_CSPI1_MISO 0x0604 -#define IOMUXC_SW_PAD_CTL_PAD_CSPI1_SS0 0x0608 -#define IOMUXC_SW_PAD_CTL_PAD_CSPI1_SS1 0x060c -#define IOMUXC_SW_PAD_CTL_PAD_CSPI1_RDY 0x0610 -#define IOMUXC_SW_PAD_CTL_PAD_CSPI1_SCLK 0x0614 -#define IOMUXC_SW_PAD_CTL_PAD_UART1_RXD 0x0618 -#define IOMUXC_SW_PAD_CTL_PAD_UART1_TXD 0x061c -#define IOMUXC_SW_PAD_CTL_PAD_UART1_RTS 0x0620 -#define IOMUXC_SW_PAD_CTL_PAD_UART1_CTS 0x0624 -#define IOMUXC_SW_PAD_CTL_PAD_UART2_RXD 0x0628 -#define IOMUXC_SW_PAD_CTL_PAD_UART2_TXD 0x062c -#define IOMUXC_SW_PAD_CTL_PAD_UART3_RXD 0x0630 -#define IOMUXC_SW_PAD_CTL_PAD_UART3_TXD 0x0634 -#define IOMUXC_SW_PAD_CTL_PAD_OWIRE_LINE 0x0638 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW0 0x063c -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW1 0x0640 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW2 0x0644 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW3 0x0648 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL0 0x064c -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL1 0x0650 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL2 0x0654 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL3 0x0658 -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL4 0x065c -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL5 0x0660 -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TCK 0x0664 -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TMS 0x0668 -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TDI 0x066c -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TRSTB 0x0670 -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_MOD 0x0674 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_CLK 0x0678 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DIR 0x067c -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_STP 0x0680 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_NXT 0x0684 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA0 0x0688 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA1 0x068c -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA2 0x0690 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA3 0x0694 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA4 0x0698 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA5 0x069c -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA6 0x06a0 -#define IOMUXC_SW_PAD_CTL_PAD_USBH1_DATA7 0x06a4 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_PIN11 0x06a8 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_PIN12 0x06ac -#define IOMUXC_SW_PAD_CTL_PAD_DI1_PIN13 0x06b0 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_D0_CS 0x06b4 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_D1_CS 0x06b8 -#define IOMUXC_SW_PAD_CTL_PAD_DISPB2_SER_DIN 0x06bc -#define IOMUXC_SW_PAD_CTL_PAD_DISPB2_SER_DIO 0x06c0 -#define IOMUXC_SW_PAD_CTL_PAD_DISPB2_SER_CLK 0x06c4 -#define IOMUXC_SW_PAD_CTL_PAD_DISPB2_SER_RS 0x06c8 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT0 0x06cc -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT1 0x06d0 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT2 0x06d4 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT3 0x06d8 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT4 0x06dc -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT5 0x06e0 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT6 0x06e4 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT7 0x06e8 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT8 0x06ec -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT9 0x06f0 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT10 0x06f4 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT11 0x06f8 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT12 0x06fc -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT13 0x0700 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT14 0x0704 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT15 0x0708 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT16 0x070c -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT17 0x0710 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT18 0x0714 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT19 0x0718 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT20 0x071c -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT21 0x0720 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT22 0x0724 -#define IOMUXC_SW_PAD_CTL_PAD_DISP1_DAT23 0x0728 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_PIN3 0x072c -#define IOMUXC_SW_PAD_CTL_PAD_DI1_DISP_CLK 0x0730 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_PIN2 0x0734 -#define IOMUXC_SW_PAD_CTL_PAD_DI1_PIN15 0x0738 -#define IOMUXC_SW_PAD_CTL_PAD_DI_GP1 0x073c -#define IOMUXC_SW_PAD_CTL_PAD_DI_GP2 0x0740 -#define IOMUXC_SW_PAD_CTL_PAD_DI_GP3 0x0744 -#define IOMUXC_SW_PAD_CTL_PAD_DI2_PIN4 0x0748 -#define IOMUXC_SW_PAD_CTL_PAD_DI2_PIN2 0x074c -#define IOMUXC_SW_PAD_CTL_PAD_DI2_PIN3 0x0750 -#define IOMUXC_SW_PAD_CTL_PAD_DI2_DISP_CLK 0x0754 -#define IOMUXC_SW_PAD_CTL_PAD_DI_GP4 0x0758 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT0 0x075c -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT1 0x0760 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT2 0x0764 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT3 0x0768 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT4 0x076c -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT5 0x0770 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT6 0x0774 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT7 0x0778 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT8 0x077c -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT9 0x0780 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT10 0x0784 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT11 0x0788 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT12 0x078c -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT13 0x0790 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT14 0x0794 -#define IOMUXC_SW_PAD_CTL_PAD_DISP2_DAT15 0x0798 -#define IOMUXC_SW_PAD_CTL_PAD_SD1_CMD 0x079c -#define IOMUXC_SW_PAD_CTL_PAD_SD1_CLK 0x07a0 -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA0 0x07a4 -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA1 0x07a8 -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA2 0x07ac -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA3 0x07b0 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_0 0x07b4 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_1 0x07b8 -#define IOMUXC_SW_PAD_CTL_PAD_SD2_CMD 0x07bc -#define IOMUXC_SW_PAD_CTL_PAD_SD2_CLK 0x07c0 -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA0 0x07c4 -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA1 0x07c8 -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA2 0x07cc -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA3 0x07d0 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_2 0x07d4 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_3 0x07d8 -#define IOMUXC_SW_PAD_CTL_PAD_RESET_IN_B 0x07dc -#define IOMUXC_SW_PAD_CTL_PAD_POR_B 0x07e0 -#define IOMUXC_SW_PAD_CTL_PAD_BOOT_MODE1 0x07e4 -#define IOMUXC_SW_PAD_CTL_PAD_BOOT_MODE0 0x07e8 -#define IOMUXC_SW_PAD_CTL_PAD_PMIC_RDY 0x07ec -#define IOMUXC_SW_PAD_CTL_PAD_CKIL 0x07f0 -#define IOMUXC_SW_PAD_CTL_PAD_PMIC_STBY_REQ 0x07f4 -#define IOMUXC_SW_PAD_CTL_PAD_PMIC_ON_REQ 0x07f8 -#define IOMUXC_SW_PAD_CTL_PAD_PMIC_INT_REQ 0x07fc -#define IOMUXC_SW_PAD_CTL_PAD_CLK_SS 0x0800 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_4 0x0804 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_5 0x0808 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_6 0x080c -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_7 0x0810 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_8 0x0814 -#define IOMUXC_SW_PAD_CTL_PAD_GPIO1_9 0x0818 -#define IOMUXC_SW_PAD_CTL_GRP_CSI2_PKE0 0x081c -#define IOMUXC_SW_PAD_CTL_GRP_DDRPKS 0x0820 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_SR1 0x0824 -#define IOMUXC_SW_PAD_CTL_GRP_DISP2_PKE0 0x0828 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_B4 0x082c -#define IOMUXC_SW_PAD_CTL_GRP_INDDR 0x0830 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_SR2 0x0834 -#define IOMUXC_SW_PAD_CTL_GRP_PKEDDR 0x0838 -#define IOMUXC_SW_PAD_CTL_GRP_DDR_A0 0x083c -#define IOMUXC_SW_PAD_CTL_GRP_EMI_PKE0 0x0840 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_SR3 0x0844 -#define IOMUXC_SW_PAD_CTL_GRP_DDR_A1 0x0848 -#define IOMUXC_SW_PAD_CTL_GRP_DDRAPUS 0x084c -#define IOMUXC_SW_PAD_CTL_GRP_EIM_SR4 0x0850 -#define IOMUXC_SW_PAD_CTL_GRP_EMI_SR5 0x0854 -#define IOMUXC_SW_PAD_CTL_GRP_EMI_SR6 0x0858 -#define IOMUXC_SW_PAD_CTL_GRP_HYSDDR0 0x085c -#define IOMUXC_SW_PAD_CTL_GRP_CSI1_PKE0 0x0860 -#define IOMUXC_SW_PAD_CTL_GRP_HYSDDR1 0x0864 -#define IOMUXC_SW_PAD_CTL_GRP_DISP1_PKE0 0x0868 -#define IOMUXC_SW_PAD_CTL_GRP_HYSDDR2 0x086c -#define IOMUXC_SW_PAD_CTL_GRP_HVDDR 0x0870 -#define IOMUXC_SW_PAD_CTL_GRP_HYSDDR3 0x0874 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_SR_B0 0x0878 -#define IOMUXC_SW_PAD_CTL_GRP_DDRAPKS 0x087c -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_SR_B1 0x0880 -#define IOMUXC_SW_PAD_CTL_GRP_DDRPUS 0x0884 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_DS1 0x0888 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_SR_B2 0x088c -#define IOMUXC_SW_PAD_CTL_GRP_PKEADDR 0x0890 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_DS2 0x0894 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_DS3 0x0898 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_SR_B4 0x089c -#define IOMUXC_SW_PAD_CTL_GRP_INMODE1 0x08a0 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_B0 0x08a4 -#define IOMUXC_SW_PAD_CTL_GRP_EIM_DS4 0x08a8 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_B1 0x08ac -#define IOMUXC_SW_PAD_CTL_GRP_DDR_SR_A0 0x08b0 -#define IOMUXC_SW_PAD_CTL_GRP_EMI_DS5 0x08b4 -#define IOMUXC_SW_PAD_CTL_GRP_DRAM_B2 0x08b8 -#define IOMUXC_SW_PAD_CTL_GRP_DDR_SR_A1 0x08bc -#define IOMUXC_SW_PAD_CTL_GRP_EMI_DS6 0x08c0 -#define IOMUXC_AUDMUX_P4_INPUT_DA_AMX_SELECT_INPUT 0x08c4 -#define IOMUXC_AUDMUX_P4_INPUT_DB_AMX_SELECT_INPUT 0x08c8 -#define IOMUXC_AUDMUX_P4_INPUT_TXCLK_AMX_SELECT_INPUT 0x08cc -#define IOMUXC_AUDMUX_P4_INPUT_TXFS_AMX_SELECT_INPUT 0x08d0 -#define IOMUXC_AUDMUX_P5_INPUT_DA_AMX_SELECT_INPUT 0x08d4 -#define IOMUXC_AUDMUX_P5_INPUT_DB_AMX_SELECT_INPUT 0x08d8 -#define IOMUXC_AUDMUX_P5_INPUT_RXCLK_AMX_SELECT_INPUT 0x08dc -#define IOMUXC_AUDMUX_P5_INPUT_RXFS_AMX_SELECT_INPUT 0x08e0 -#define IOMUXC_AUDMUX_P5_INPUT_TXCLK_AMX_SELECT_INPUT 0x08e4 -#define IOMUXC_AUDMUX_P5_INPUT_TXFS_AMX_SELECT_INPUT 0x08e8 -#define IOMUXC_AUDMUX_P6_INPUT_DA_AMX_SELECT_INPUT 0x08ec -#define IOMUXC_AUDMUX_P6_INPUT_DB_AMX_SELECT_INPUT 0x08f0 -#define IOMUXC_AUDMUX_P6_INPUT_RXCLK_AMX_SELECT_INPUT 0x08f4 -#define IOMUXC_AUDMUX_P6_INPUT_RXFS_AMX_SELECT_INPUT 0x08f8 -#define IOMUXC_AUDMUX_P6_INPUT_TXCLK_AMX_SELECT_INPUT 0x08fc -#define IOMUXC_AUDMUX_P6_INPUT_TXFS_AMX_SELECT_INPUT 0x0900 -#define IOMUXC_CCM_IPP_DI0_CLK_SELECT_INPUT 0x0904 -#define IOMUXC_CCM_IPP_DI1_CLK_SELECT_INPUT 0x0908 -#define IOMUXC_CCM_PLL1_BYPASS_CLK_SELECT_INPUT 0x090c -#define IOMUXC_CCM_PLL2_BYPASS_CLK_SELECT_INPUT 0x0910 -#define IOMUXC_CSPI_IPP_CSPI_CLK_IN_SELECT_INPUT 0x0914 -#define IOMUXC_CSPI_IPP_IND_MISO_SELECT_INPUT 0x0918 -#define IOMUXC_CSPI_IPP_IND_MOSI_SELECT_INPUT 0x091c -#define IOMUXC_CSPI_IPP_IND_SS1_B_SELECT_INPUT 0x0920 -#define IOMUXC_CSPI_IPP_IND_SS2_B_SELECT_INPUT 0x0924 -#define IOMUXC_CSPI_IPP_IND_SS3_B_SELECT_INPUT 0x0928 -#define IOMUXC_DPLLIP1_L1T_TOG_EN_SELECT_INPUT 0x092c -#define IOMUXC_ECSPI2_IPP_IND_SS_B_1_SELECT_INPUT 0x0930 -#define IOMUXC_ECSPI2_IPP_IND_SS_B_3_SELECT_INPUT 0x0934 -#define IOMUXC_EMI_IPP_IND_RDY_INT_SELECT_INPUT 0x0938 -#define IOMUXC_ESDHC3_IPP_DAT0_IN_SELECT_INPUT 0x093c -#define IOMUXC_ESDHC3_IPP_DAT1_IN_SELECT_INPUT 0x0940 -#define IOMUXC_ESDHC3_IPP_DAT2_IN_SELECT_INPUT 0x0944 -#define IOMUXC_ESDHC3_IPP_DAT3_IN_SELECT_INPUT 0x0948 -#define IOMUXC_FEC_FEC_COL_SELECT_INPUT 0x094c -#define IOMUXC_FEC_FEC_CRS_SELECT_INPUT 0x0950 -#define IOMUXC_FEC_FEC_MDI_SELECT_INPUT 0x0954 -#define IOMUXC_FEC_FEC_RDATA_0_SELECT_INPUT 0x0958 -#define IOMUXC_FEC_FEC_RDATA_1_SELECT_INPUT 0x095c -#define IOMUXC_FEC_FEC_RDATA_2_SELECT_INPUT 0x0960 -#define IOMUXC_FEC_FEC_RDATA_3_SELECT_INPUT 0x0964 -#define IOMUXC_FEC_FEC_RX_CLK_SELECT_INPUT 0x0968 -#define IOMUXC_FEC_FEC_RX_DV_SELECT_INPUT 0x096c -#define IOMUXC_FEC_FEC_RX_ER_SELECT_INPUT 0x0970 -#define IOMUXC_FEC_FEC_TX_CLK_SELECT_INPUT 0x0974 -#define IOMUXC_GPIO3_IPP_IND_G_IN_1_SELECT_INPUT 0x0978 -#define IOMUXC_GPIO3_IPP_IND_G_IN_2_SELECT_INPUT 0x097c -#define IOMUXC_GPIO3_IPP_IND_G_IN_3_SELECT_INPUT 0x0980 -#define IOMUXC_GPIO3_IPP_IND_G_IN_4_SELECT_INPUT 0x0984 -#define IOMUXC_GPIO3_IPP_IND_G_IN_5_SELECT_INPUT 0x0988 -#define IOMUXC_GPIO3_IPP_IND_G_IN_6_SELECT_INPUT 0x098c -#define IOMUXC_GPIO3_IPP_IND_G_IN_7_SELECT_INPUT 0x0990 -#define IOMUXC_GPIO3_IPP_IND_G_IN_8_SELECT_INPUT 0x0994 -#define IOMUXC_GPIO3_IPP_IND_G_IN_12_SELECT_INPUT 0x0998 -#define IOMUXC_HSC_MIPI_MIX_PAR0_VSYNC_SELECT_INPUT 0x09a4 -#define IOMUXC_HSC_MIPI_MIX_PAR1_DI_WAIT_SELECT_INPUT 0x09a8 -#define IOMUXC_HSC_MIPI_MIX_PAR_SISG_TRIG_SELECT_INPUT 0x09ac -#define IOMUXC_I2C1_IPP_SCL_IN_SELECT_INPUT 0x09b0 -#define IOMUXC_I2C1_IPP_SDA_IN_SELECT_INPUT 0x09b4 -#define IOMUXC_I2C2_IPP_SCL_IN_SELECT_INPUT 0x09b8 -#define IOMUXC_I2C2_IPP_SDA_IN_SELECT_INPUT 0x09bc -#define IOMUXC_IPU_IPP_DI_0_IND_DISPB_SD_D_SELECT_INPUT 0x09c0 -#define IOMUXC_IPU_IPP_DI_1_IND_DISPB_SD_D_SELECT_INPUT 0x09c4 -#define IOMUXC_KPP_IPP_IND_COL_6_SELECT_INPUT 0x09c8 -#define IOMUXC_KPP_IPP_IND_COL_7_SELECT_INPUT 0x09cc -#define IOMUXC_KPP_IPP_IND_ROW_4_SELECT_INPUT 0x09d0 -#define IOMUXC_KPP_IPP_IND_ROW_5_SELECT_INPUT 0x09d4 -#define IOMUXC_KPP_IPP_IND_ROW_6_SELECT_INPUT 0x09d8 -#define IOMUXC_KPP_IPP_IND_ROW_7_SELECT_INPUT 0x09dc -#define IOMUXC_UART1_IPP_UART_RTS_B_SELECT_INPUT 0x09e0 -#define IOMUXC_UART1_IPP_UART_RXD_MUX_SELECT_INPUT 0x09e4 -#define IOMUXC_UART2_IPP_UART_RTS_B_SELECT_INPUT 0x09e8 -#define IOMUXC_UART2_IPP_UART_RXD_MUX_SELECT_INPUT 0x09ec -#define IOMUXC_UART3_IPP_UART_RTS_B_SELECT_INPUT 0x09f0 -#define IOMUXC_UART3_IPP_UART_RXD_MUX_SELECT_INPUT 0x09f4 -#define IOMUXC_USBOH3_IPP_IND_UH3_CLK_SELECT_INPUT 0x09f8 -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_0_SELECT_INPUT 0x09fc -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_1_SELECT_INPUT 0x0a00 -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_2_SELECT_INPUT 0x0a04 -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_3_SELECT_INPUT 0x0a08 -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_4_SELECT_INPUT 0x0a0c -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_5_SELECT_INPUT 0x0a10 -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_6_SELECT_INPUT 0x0a14 -#define IOMUXC_USBOH3_IPP_IND_UH3_DATA_7_SELECT_INPUT 0x0a18 -#define IOMUXC_USBOH3_IPP_IND_UH3_DIR_SELECT_INPUT 0x0a1c -#define IOMUXC_USBOH3_IPP_IND_UH3_NXT_SELECT_INPUT 0x0a20 -#define IOMUXC_USBOH3_IPP_IND_UH3_STP_SELECT_INPUT 0x0a24 - -/* MUX & PAD Control */ - -#define MUX_PIN(name) \ - IOMUX_PIN(IOMUXC_SW_MUX_CTL_PAD_##name, \ - IOMUXC_SW_PAD_CTL_PAD_##name) - -#define MUX_PIN_MUX(name) \ - IOMUX_PIN(IOMUXC_SW_MUX_CTL_PAD_##name, IOMUX_PAD_NONE) - -#define MUX_PIN_PAD(name) \ - IOMUX_PIN(IOMUX_MUX_NONE, IOMUXC_SW_PAD_CTL_PAD_##name) - -#define MUX_PIN_GRP(name) \ - IOMUX_PIN(IOMUX_MUX_NONE, IOMUXC_SW_PAD_CTL_GRP_##name) - -#define MUX_PIN_PATH(name) \ - IOMUX_PIN(IOMUXC_##name##_SELECT_INPUT, IOMUX_MUX_NONE) - -/* INPUT Control */ - -#define MUX_SELECT(name) (name##_SELECT_INPUT) - -#endif /* _IMX51_IOMUXREG_H */ diff --git a/sys/arm/freescale/imx/imx6_iomux.c b/sys/arm/freescale/imx/imx6_iomux.c deleted file mode 100644 index b15e503071d2..000000000000 --- a/sys/arm/freescale/imx/imx6_iomux.c +++ /dev/null @@ -1,225 +0,0 @@ -/*- - * Copyright (c) 2014 Boris Samorodov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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 "imx6_iomuxreg.h" - -#define IOMUX_WRITE(_sc, _r, _v) \ - bus_write_4((_sc)->sc_res, (_r), (_v)) -#define IOMUX_READ(_sc, _r) \ - bus_read_4((_sc)->sc_res, (_r)) -#define IOMUX_SET(_sc, _r, _m) \ - IOMUX_WRITE((_sc), (_r), IOMUX_READ((_sc), (_r)) | (_m)) -#define IOMUX_CLEAR(_sc, _r, _m) \ - IOMUX_WRITE((_sc), (_r), IOMUX_READ((_sc), (_r)) & ~(_m)) - -struct imx6_iomux_softc { - struct resource *sc_res; - device_t sc_dev; -}; - -static struct imx6_iomux_softc *iomuxsc = NULL; - -static struct resource_spec imx6_iomux_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE }, - { SYS_RES_IRQ, 0, RF_ACTIVE }, - { -1, 0 } -}; - -static int -imx6_iomux_probe(device_t dev) -{ - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (!ofw_bus_is_compatible(dev, "fsl,imx6-iomux")) - return (ENXIO); - - device_set_desc(dev, "Freescale i.MX6 IO pins multiplexor"); - return (BUS_PROBE_DEFAULT); - -} - -static int -imx6_iomux_attach(device_t dev) -{ - struct imx6_iomux_softc * sc; - - sc = device_get_softc(dev); - - if (bus_alloc_resources(dev, imx6_iomux_spec, &sc->sc_res)) { - device_printf(dev, "could not allocate resources\n"); - return (ENXIO); - } - - iomuxsc = sc; - - /* - * XXX: place to fetch all info about pinmuxing from loader data - * (FDT blob) and apply. Loader (1st one) must care about - * device-to-device difference. - */ - - return (0); -} - -static int -imx6_iomux_detach(device_t dev) -{ - - /* IOMUX registers are always accessible. */ - return (EBUSY); -} - -static void -iomux_set_pad_sub(struct imx6_iomux_softc *sc, uint32_t pin, uint32_t config) -{ - bus_size_t pad_ctl_reg = IOMUX_PIN_TO_PAD_ADDRESS(pin); - - if (pad_ctl_reg != IOMUX_PAD_NONE) - IOMUX_WRITE(sc, pad_ctl_reg, config); -} - -void -iomux_set_pad(unsigned int pin, unsigned int config) -{ - - if (iomuxsc == NULL) - return; - iomux_set_pad_sub(iomuxsc, pin, config); -} - -static void -iomux_set_function_sub(struct imx6_iomux_softc *sc, uint32_t pin, uint32_t fn) -{ - bus_size_t mux_ctl_reg = IOMUX_PIN_TO_MUX_ADDRESS(pin); - - if (mux_ctl_reg != IOMUX_MUX_NONE) - IOMUX_WRITE(sc, mux_ctl_reg, fn); -} - -void -iomux_set_function(unsigned int pin, unsigned int fn) -{ - - if (iomuxsc == NULL) - return; - iomux_set_function_sub(iomuxsc, pin, fn); -} - -static uint32_t -iomux_get_pad_config_sub(struct imx6_iomux_softc *sc, uint32_t pin) -{ - bus_size_t pad_reg = IOMUX_PIN_TO_PAD_ADDRESS(pin); - uint32_t result; - - result = IOMUX_READ(sc, pad_reg); - - return(result); -} - -unsigned int -iomux_get_pad_config(unsigned int pin) -{ - - return(iomux_get_pad_config_sub(iomuxsc, pin)); -} - - -uint32_t -imx_iomux_gpr_get(u_int regnum) -{ - - KASSERT(iomuxsc != NULL, ("imx_iomux_gpr_get() called before attach")); - KASSERT(regnum >= 0 && regnum <= 13, - ("imx_iomux_gpr_get bad regnum %u", regnum)); - return (IOMUX_READ(iomuxsc, IOMUXC_GPR0 + regnum)); -} - -void -imx_iomux_gpr_set(u_int regnum, uint32_t val) -{ - - KASSERT(iomuxsc != NULL, ("imx_iomux_gpr_set() called before attach")); - KASSERT(regnum >= 0 && regnum <= 13, - ("imx_iomux_gpr_set bad regnum %u", regnum)); - IOMUX_WRITE(iomuxsc, IOMUXC_GPR0 + regnum, val); -} - -void -imx_iomux_gpr_set_masked(u_int regnum, uint32_t clrbits, uint32_t setbits) -{ - uint32_t val; - - KASSERT(iomuxsc != NULL, - ("imx_iomux_gpr_set_masked called before attach")); - KASSERT(regnum >= 0 && regnum <= 13, - ("imx_iomux_gpr_set_masked bad regnum %u", regnum)); - - val = IOMUX_READ(iomuxsc, IOMUXC_GPR0 + regnum); - val = (val & ~clrbits) | setbits; - IOMUX_WRITE(iomuxsc, IOMUXC_GPR0 + regnum, val); -} - -static device_method_t imx6_iomux_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, imx6_iomux_probe), - DEVMETHOD(device_attach, imx6_iomux_attach), - DEVMETHOD(device_detach, imx6_iomux_detach), - - DEVMETHOD_END -}; - -static driver_t imx6_iomux_driver = { - "imx6_iomux", - imx6_iomux_methods, - sizeof(struct imx6_iomux_softc), -}; - -static devclass_t imx6_iomux_devclass; - -EARLY_DRIVER_MODULE(imx6_iomux, simplebus, imx6_iomux_driver, - imx6_iomux_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE); - - diff --git a/sys/arm/freescale/imx/imx6_iomuxreg.h b/sys/arm/freescale/imx/imx6_iomuxreg.h deleted file mode 100644 index 7b74cfc34cda..000000000000 --- a/sys/arm/freescale/imx/imx6_iomuxreg.h +++ /dev/null @@ -1,798 +0,0 @@ -/*- - * Copyright (c) 2014 Boris Samorodov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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$ - */ - -/* - * Pad : pin ("pin" is used at electric schemes, - * while at HW SOC it's named "pad"). - * Drive strength : the current that can be drawn with - * appropriate voltage (varies inversely with - * the supply impedance of the output pin). - * Drive strength enable (DSE) : The value of the current the pin uses. - * HiZ (HYZ) : high input impedance value. - * Daisy chain (DAISY) : the one after another interconnection of - * devices. - * On die termination (ODT) : the termination resistor for impedance - * matching. - * Software input on (SION) : the value to force the pin to be an input - * one (i.e. to force the pin state reading). - * Hysteresis (HYS) : Controls if the value of the input pin - * remains the same until a sufficient change - * is applied. - * Slow rate enable (SRE) : How slow the pin value changes (slow rate - * saves power). - * Open drain enable (ODE) : If the input pin drains on low input or - * goes down. - * Pull/keep enable (PKE) : Enables pull/keep functionality. - * PUll/keep select (PUE) : Selects if the pin is pullup/pulldown one - * or remains it's previous role. - * A note: I'm not sure why it's not PKS... - * Pullup (Pic.1)/pulldown (Pic.2): the pin's resistor connected to VCC (GND) - * to prevent random value drai. - * Pullup/pulldown select (PUS) : Selects the value of pullup/pulldown - * resistor. - * Open drain (Pic.3) : the output signal is applied to the base - * of a transistor whose collector is used - * as a pin. - * - * VCC o VCC o Open drain - * | | ----> pin - * +++ o| / - * | | R | Switch / - * +++ pullup o| .---. - * | | / |/ \ - * >---+------> Pin >---+------> Pin >---{--| ) - * | | \ |\ / - * o| +++ `--v' - * | Switch | | R \ - * o| +++ pulldown | - * | | | - * ----- ----- ----- - * --- --- --- - * - - - - * - * Pic.1 Pic.2 Pic.3 - */ - -#ifndef IMX6_IOMUXREG_H -#define IMX6_IOMUXREG_H - -/* - * Multiplex control - */ -#define IOMUXC_MUX_CTL 0x004c -#define IOMUX_CONFIG_SION (1<<4) -#define IOMUX_CONFIG_ALT0 0 -#define IOMUX_CONFIG_ALT1 1 -#define IOMUX_CONFIG_ALT2 2 -#define IOMUX_CONFIG_ALT3 3 -#define IOMUX_CONFIG_ALT4 4 -#define IOMUX_CONFIG_ALT5 5 -#define IOMUX_CONFIG_ALT6 6 -#define IOMUX_CONFIG_ALT7 7 - -/* - * Pad control - */ -#define IOMUXC_PAD_CTL 0x0360 - /* DDR Select Field */ -#define PAD_CTL_DDR_SEL_0 (0x0<<18) -#define PAD_CTL_DDR_SEL_1 (0x1<<18) -#define PAD_CTL_DDR_SEL_2 (0x2<<18) -#define PAD_CTL_DDR_SEL_3 (0x3<<18) -#define PAD_CTL_DDR_INPUT (0x1<<17) /* DDR/CMOS Input Mode Field */ -#define PAD_CTL_HYS (1<<16) /* Hysteresis Enable Field */ - /* PullUp/Down Config Field: */ -#define PAD_CTL_PUS_100K_PD (0x0<<14) /* 100K Ohm Pull Down */ -#define PAD_CTL_PUS_47K_PU (0x1<<14) /* 47K Ohn Pull Up */ -#define PAD_CTL_PUS_100K_PU (0x2<<14) /* 100K Ohm Pull Up */ -#define PAD_CTL_PUS_22K_PU (0x3<<14) /* 22K Ohm Pull Up */ -#define PAD_CTL_PUE (1<<13) /* Pull/Keep Select Field */ -#define PAD_CTL_PKE (1<<12) /* Pull/Keep Enable Field */ -#define PAD_CTL_ODE (1<<11) /* Open Drain Enable Field */ - /* On Die Termination Field: */ -#define PAD_CTL_ODT_DISABLED (0x0<<8) /* Disabled */ -#define PAD_CTL_ODT_1 (0x1<<8) -#define PAD_CTL_ODT_2 (0x2<<8) -#define PAD_CTL_ODT_3 (0x3<<8) -#define PAD_CTL_ODT_4 (0x4<<8) -#define PAD_CTL_ODT_5 (0x5<<8) -#define PAD_CTL_ODT_6 (0x6<<8) -#define PAD_CTL_ODT_7 (0x7<<8) - /* Speed Field: */ -#define PAD_CTL_SPEED_RESERVED0 (0x0<<6) /* RESERVED */ -#define PAD_CTL_SPEED_50_MHZ (0x1<<6) /* 50 MHz */ -#define PAD_CTL_SPEED_100_MHZ (0x2<<6) /* 100 MHz */ -#define PAD_CTL_SPEED_200_MHZ (0x3<<6) /* 200 MHz */ - /* Drive Strength Field */ -#define PAD_CTL_DSE_HIZ (0x0<<3) /* HI-Z */ -#define PAD_CTL_DSE_1 (0x1<<3) -#define PAD_CTL_DSE_2 (0x2<<3) -#define PAD_CTL_DSE_3 (0x3<<3) -#define PAD_CTL_DSE_4 (0x4<<3) -#define PAD_CTL_DSE_5 (0x5<<3) -#define PAD_CTL_DSE_6 (0x6<<3) -#define PAD_CTL_DSE_7 (0x7<<3) -#define PAD_CTL_SRE (0x1<<0) /* Slew rate Field */ - -/* - * Input control - */ -#define IOMUXC_INPUT_CTL 0x07b0 /* input control */ -#define INPUT_DAISY_0 0 -#define INPUT_DAISY_1 1 -#define INPUT_DAISY_2 2 -#define INPUT_DAISY_3 3 -#define INPUT_DAISY_4 4 -#define INPUT_DAISY_5 5 -#define INPUT_DAISY_6 6 -#define INPUT_DAISY_7 7 - -/* - * IOMUX index - */ -#define IOMUX_PIN_TO_MUX_ADDRESS(pin) (((pin) >> 16) & 0xffff) -#define IOMUX_PIN_TO_PAD_ADDRESS(pin) (((pin) >> 0) & 0xffff) -#define IOMUX_PIN(mux_adr, pad_adr) \ - (((mux_adr) << 16) | (((pad_adr) << 0))) -#define IOMUX_MUX_NONE 0xffff -#define IOMUX_PAD_NONE 0xffff - -/* - * MUX & PAD Control - */ -#define MUX_PIN(name) \ - IOMUX_PIN(IOMUXC_SW_MUX_CTL_PAD_##name, \ - IOMUXC_SW_PAD_CTL_PAD_##name) - -#define MUX_PIN_MUX(name) \ - IOMUX_PIN(IOMUXC_SW_MUX_CTL_PAD_##name, IOMUX_PAD_NONE) - -#define MUX_PIN_PAD(name) \ - IOMUX_PIN(IOMUX_MUX_NONE, IOMUXC_SW_PAD_CTL_PAD_##name) - -#define MUX_PIN_GRP(name) \ - IOMUX_PIN(IOMUX_MUX_NONE, IOMUXC_SW_PAD_CTL_GRP_##name) - -#define MUX_PIN_PATH(name) \ - IOMUX_PIN(IOMUXC_##name##_SELECT_INPUT, IOMUX_MUX_NONE) - -/* - * INPUT Control - */ -#define MUX_SELECT(name) (name##_SELECT_INPUT) - -/* - * Register names, offset addresses (and reset values for reference) - * from Chapter 36 IOMUX Controller (IOMUXC), IMX6DQRM, Rev.1, 04/2013 - * - * General Purpose Registers - */ -#define IOMUXC_GPR0 0x0000 /* 0x00000000 */ -#define IOMUXC_GPR1 0x0004 /* 0x48400005 */ -#define IOMUXC_GPR2 0x0008 /* 0x00000000 */ -#define IOMUXC_GPR3 0x000c /* 0x01e00000 */ -#define IOMUXC_GPR4 0x0010 /* 0x00000000 */ -#define IOMUXC_GPR5 0x0014 /* 0x00000000 */ -#define IOMUXC_GPR6 0x0018 /* 0x22222222 */ -#define IOMUXC_GPR7 0x001c /* 0x22222222 */ -#define IOMUXC_GPR8 0x0020 /* 0x00000000 */ -#define IOMUXC_GPR9 0x0024 /* 0x00000000 */ -#define IOMUXC_GPR10 0x0028 /* 0x00003800 */ -#define IOMUXC_GPR11 0x002c /* 0x00003800 */ -#define IOMUXC_GPR12 0x0030 /* 0x0f000000 */ -#define IOMUXC_GPR13 0x0034 /* 0x059124c4 */ -/* - * Pad Mux Registers - */ -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA1 0x004c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA2 0x0050 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA0 0x0054 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_TXC 0x0058 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_TD0 0x005c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_TD1 0x0060 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_TD2 0x0064 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_TD3 0x0068 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_RX_CTL 0x006c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_RD0 0x0070 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_TX_CTL 0x0074 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_RD1 0x0078 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_RD2 0x007c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_RD3 0x0080 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_RGMII_RXC 0x0084 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR25 0x0088 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB2_B 0x008c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA16 0x0090 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA17 0x0094 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA18 0x0098 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA19 0x009c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA20 0x00a0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA21 0x00a4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA22 0x00a8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA23 0x00ac /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB3_B 0x00b0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA24 0x00b4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA25 0x00b8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA26 0x00bc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA27 0x00c0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA28 0x00c4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA29 0x00c8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA30 0x00cc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_DATA31 0x00d0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR24 0x00d4 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR23 0x00d8 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR22 0x00dc /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR21 0x00e0 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR20 0x00e4 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR19 0x00e8 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR18 0x00ec /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR17 0x00f0 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_ADDR16 0x00f4 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS0_B 0x00f8 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_CS1_B 0x00fc /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_OE_B 0x0100 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_RW 0x0104 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_LBA_B 0x0108 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB0_B 0x010c /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_EB1_B 0x0110 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD00 0x0114 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD01 0x0118 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD02 0x011c /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD03 0x0120 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD04 0x0124 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD05 0x0128 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD06 0x012c /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD07 0x0130 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD08 0x0134 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD09 0x0138 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD10 0x013c /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD11 0x0140 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD12 0x0144 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD13 0x0148 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD14 0x014c /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_AD15 0x0150 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_WAIT_B 0x0154 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_EIM_BCLK 0x0158 /* 0x00000000 */ -#define IOMUXC_SW_MUX_CTL_PAD_DI0_DISP_CLK 0x015c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DI0_PIN15 0x0160 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DI0_PIN02 0x0164 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DI0_PIN03 0x0168 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DI0_PIN04 0x016c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA00 0x0170 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA01 0x0174 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA02 0x0178 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA03 0x017c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA04 0x0180 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA05 0x0184 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA06 0x0188 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA07 0x018c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA08 0x0190 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA09 0x0194 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA10 0x0198 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA11 0x019c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA12 0x01a0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA13 0x01a4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA14 0x01a8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA15 0x01ac /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA16 0x01b0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA17 0x01b4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA18 0x01b8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA19 0x01bc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA20 0x01c0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA21 0x01c4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA22 0x01c8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA23 0x01cc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_MDIO 0x01d0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_REF_CLK 0x01d4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_RX_ER 0x01d8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_CRS_DV 0x01dc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_RX_DATA1 0x01e0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_RX_DATA0 0x01e4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_TX_EN 0x01e8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_TX_DATA1 0x01ec /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_TX_DATA0 0x01f0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_ENET_MDC 0x01f4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL0 0x01f8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW0 0x01fc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL1 0x0200 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW1 0x0204 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL2 0x0208 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW2 0x020c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL3 0x0210 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW3 0x0214 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_COL4 0x0218 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_KEY_ROW4 0x021c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO00 0x0220 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO01 0x0224 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO09 0x0228 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO03 0x022c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO06 0x0230 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO02 0x0234 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO04 0x0238 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO05 0x023c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO07 0x0240 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO08 0x0244 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO16 0x0248 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO17 0x024c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO18 0x0250 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_GPIO19 0x0254 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_PIXCLK 0x0258 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_HSYNC 0x025c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA_EN 0x0260 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_VSYNC 0x0264 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA04 0x0268 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA05 0x026c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA06 0x0270 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA07 0x0274 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA08 0x0278 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA09 0x027c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA10 0x0280 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA11 0x0284 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA12 0x0288 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA13 0x028c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA14 0x0290 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA15 0x0294 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA16 0x0298 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA17 0x029c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA18 0x02a0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_CSI0_DATA19 0x02a4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA7 0x02a8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA6 0x02ac /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA5 0x02b0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA4 0x02b4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_CMD 0x02b8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_CLK 0x02bc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA0 0x02c0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA1 0x02c4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA2 0x02c8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_DATA3 0x02cc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD3_RESET 0x02d0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_CLE 0x02d4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_ALE 0x02d8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_WP_B 0x02dc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_READY_B 0x02e0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_CS0_B 0x02e4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_CS1_B 0x02e8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_CS2_B 0x02ec /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_CS3_B 0x02f0 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_CMD 0x02f4 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_CLK 0x02f8 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA00 0x02fc /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA01 0x0300 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA02 0x0304 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA03 0x0308 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA04 0x030c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA05 0x0310 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA06 0x0314 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_NAND_DATA07 0x0318 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA0 0x031c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA1 0x0320 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA2 0x0324 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA3 0x0328 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA4 0x032c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA5 0x0330 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA6 0x0334 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD4_DATA7 0x0338 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA1 0x033c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA0 0x0340 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA3 0x0344 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD1_CMD 0x0348 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD1_DATA2 0x034c /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD1_CLK 0x0350 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD2_CLK 0x0354 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD2_CMD 0x0358 /* 0x00000005 */ -#define IOMUXC_SW_MUX_CTL_PAD_SD2_DATA3 0x035c /* 0x00000005 */ -/* - * Pad Control registers - */ -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA1 0x0360 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA2 0x0364 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA0 0x0368 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_TXC 0x036c /* 0x00013030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_TD0 0x0370 /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_TD1 0x0374 /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_TD2 0x0378 /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_TD3 0x037c /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_RX_CTL 0x0380 /* 0x00013030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_RD0 0x0384 /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_TX_CTL 0x0388 /* 0x00013030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_RD1 0x038c /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_RD2 0x0390 /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_RD3 0x0394 /* 0x0001b030 */ -#define IOMUXC_SW_PAD_CTL_PAD_RGMII_RXC 0x0398 /* 0x00013030 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR25 0x039c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB2_B 0x03a0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA16 0x03a4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA17 0x03a8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA18 0x03ac /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA19 0x03b0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA20 0x03b4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA21 0x03b8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA22 0x03bc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA23 0x03c0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB3_B 0x03c4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA24 0x03c8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA25 0x03cc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA26 0x03d0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA27 0x03d4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA28 0x03d8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA29 0x03dc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA30 0x03e0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_DATA31 0x03e4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR24 0x03e8 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR23 0x03ec /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR22 0x03f0 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR21 0x03f4 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR20 0x03f8 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR19 0x03fc /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR18 0x0400 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR17 0x0404 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_ADDR16 0x0408 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS0_B 0x040c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_CS1_B 0x0410 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_OE_B 0x0414 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_RW 0x0418 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_LBA_B 0x041c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB0_B 0x0420 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_EB1_B 0x0424 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD00 0x0428 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD01 0x042c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD02 0x0430 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD03 0x0434 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD04 0x0438 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD05 0x043c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD06 0x0440 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD07 0x0444 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD08 0x0448 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD09 0x044c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD10 0x0450 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD11 0x0454 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD12 0x0458 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD13 0x045c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD14 0x0460 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_AD15 0x0464 /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_B 0x0468 /* 0x0000b060 */ -#define IOMUXC_SW_PAD_CTL_PAD_EIM_BCLK 0x046c /* 0x0000b0b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_DI0_DISP_CLK 0x0470 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DI0_PIN15 0x0474 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DI0_PIN02 0x0478 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DI0_PIN03 0x047c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DI0_PIN04 0x0480 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA00 0x0484 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA01 0x0488 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA02 0x048c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA03 0x0490 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA04 0x0494 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA05 0x0498 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA06 0x049c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA07 0x04a0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA08 0x04a4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA09 0x04a8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA10 0x04ac /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA11 0x04b0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA12 0x04b4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA13 0x04b8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA14 0x04bc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA15 0x04c0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA16 0x04c4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA17 0x04c8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA18 0x04cc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA19 0x04d0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA20 0x04d4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA21 0x04d8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA22 0x04dc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA23 0x04e0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_MDIO 0x04e4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_REF_CLK 0x04e8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_RX_ER 0x04ec /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_CRS_DV 0x04f0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_RX_DATA1 0x04f4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_RX_DATA0 0x04f8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_TX_EN 0x04fc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_TX_DATA1 0x0500 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_TX_DATA0 0x0504 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_ENET_MDC 0x0508 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS5_P 0x050c /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM5 0x0510 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM4 0x0514 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS4_P 0x0518 /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS3_P 0x051c /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM3 0x0520 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS2_P 0x0524 /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM2 0x0528 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR00 0x052c /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR01 0x0530 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR02 0x0534 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR03 0x0538 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR04 0x053c /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR05 0x0540 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR06 0x0544 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR07 0x0548 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR08 0x054c /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR09 0x0550 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR10 0x0554 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR11 0x0558 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR12 0x055c /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR13 0x0560 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR14 0x0564 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ADDR15 0x0568 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS_B 0x056c /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CS0_B 0x0570 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CS1_B 0x0574 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS_B 0x0578 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_RESET 0x057c /* 0x00083030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDBA0 0x0580 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDBA1 0x0584 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK0_P 0x0588 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDBA2 0x058c /* 0x0000b000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCKE0 0x0590 /* 0x00003000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK1_P 0x0594 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCKE1 0x0598 /* 0x00003000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ODT0 0x059c /* 0x00003030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_ODT1 0x05a0 /* 0x00003030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDWE_B 0x05a4 /* 0x00008000 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0_P 0x05a8 /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0 0x05ac /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1_P 0x05b0 /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1 0x05b4 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS6_P 0x05b8 /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM6 0x05bc /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS7_P 0x05c0 /* 0x00002030 */ -#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM7 0x05c4 /* 0x00008030 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL0 0x05c8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW0 0x05cc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL1 0x05d0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW1 0x05d4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL2 0x05d8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW2 0x05dc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL3 0x05e0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW3 0x05e4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_COL4 0x05e8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_KEY_ROW4 0x05ec /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO00 0x05f0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO01 0x05f4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO09 0x05f8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO03 0x05fc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO06 0x0600 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO02 0x0604 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO04 0x0608 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO05 0x060c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO07 0x0610 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO08 0x0614 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO16 0x0618 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO17 0x061c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO18 0x0620 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_GPIO19 0x0624 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_PIXCLK 0x0628 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_HSYNC 0x062c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA_EN 0x0630 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_VSYNC 0x0634 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA04 0x0638 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA05 0x063c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA06 0x0640 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA07 0x0644 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA08 0x0648 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA09 0x064c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA10 0x0650 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA11 0x0654 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA12 0x0658 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA13 0x065c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA14 0x0660 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA15 0x0664 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA16 0x0668 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA17 0x066c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA18 0x0670 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_CSI0_DATA19 0x0674 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TMS 0x0678 /* 0x00007060 */ -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_MOD 0x067c /* 0x0000b060 */ -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TRSTB 0x0680 /* 0x00007060 */ -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TDI 0x0684 /* 0x00007060 */ -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TCK 0x0688 /* 0x00007060 */ -#define IOMUXC_SW_PAD_CTL_PAD_JTAG_TDO 0x068c /* 0x000090b1 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7 0x0690 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6 0x0694 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA5 0x0698 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA4 0x069c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_CMD 0x06a0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_CLK 0x06a4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA0 0x06a8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA1 0x06ac /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA2 0x06b0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_DATA3 0x06b4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD3_RESET 0x06b8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_CLE 0x06bc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_ALE 0x06c0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B 0x06c4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_READY_B 0x06c8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B 0x06cc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_CS1_B 0x06d0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_CS2_B 0x06d4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_CS3_B 0x06d8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_CMD 0x06dc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_CLK 0x06e0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00 0x06e4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA01 0x06e8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA02 0x06ec /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA03 0x06f0 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA04 0x06f4 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA05 0x06f8 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA06 0x06fc /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_NAND_DATA07 0x0700 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA0 0x0704 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA1 0x0708 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA2 0x070c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA3 0x0710 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA4 0x0714 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA5 0x0718 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA6 0x071c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD4_DATA7 0x0720 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA1 0x0724 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA0 0x0728 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA3 0x072c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD1_CMD 0x0730 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD1_DATA2 0x0734 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD1_CLK 0x0738 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD2_CLK 0x073c /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD2_CMD 0x0740 /* 0x0001b0b0 */ -#define IOMUXC_SW_PAD_CTL_PAD_SD2_DATA3 0x0744 /* 0x0001b0b0 */ -/* - * Pad Group Control Registers - */ -#define IOMUXC_SW_PAD_CTL_GRP_B7DS 0x0748 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_ADDDS 0x074c /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDRMODE_CTL 0x0750 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL0 0x0754 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDRPKE 0x0758 /* 0x00001000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL1 0x075c /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL2 0x0760 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL3 0x0764 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDRPK 0x0768 /* 0x00002000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL4 0x076c /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDRHYS 0x0770 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDRMODE 0x0774 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL5 0x0778 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL6 0x077c /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_TERM_CTL7 0x0780 /* 0x00000000 */ -#define IOMUXC_SW_PAD_CTL_GRP_B0DS 0x0784 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_B1DS 0x0788 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_CTLDS 0x078c /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE_RGMII 0x0790 /* 0x00080000 */ -#define IOMUXC_SW_PAD_CTL_GRP_B2DS 0x0794 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE 0x0798 /* 0x00080000 */ -#define IOMUXC_SW_PAD_CTL_GRP_B3DS 0x079c /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_B4DS 0x07a0 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_B5DS 0x07a4 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_B6DS 0x07a8 /* 0x00000030 */ -#define IOMUXC_SW_PAD_CTL_GRP_RGMII_TERM 0x07ac /* 0x00000000 */ -/* - * Select Input Registers - */ -#define IOMUXC_ASRC_ASRCK_CLOCK_6_SELECT_INPUT 0x07b0 /* 0x00000000 */ -#define IOMUXC_AUD4_INPUT_DA_AMX_SELECT_INPUT 0x07b4 /* 0x00000000 */ -#define IOMUXC_AUD4_INPUT_DB_AMX_SELECT_INPUT 0x07b8 /* 0x00000000 */ -#define IOMUXC_AUD4_INPUT_RXCLK_AMX_SELECT_INPUT 0x07bc /* 0x00000000 */ -#define IOMUXC_AUD4_INPUT_RXFS_AMX_SELECT_INPUT 0x07c0 /* 0x00000000 */ -#define IOMUXC_AUD4_INPUT_TXCLK_AMX_SELECT_INPUT 0x07c4 /* 0x00000000 */ -#define IOMUXC_AUD4_INPUT_TXFS_AMX_SELECT_INPUT 0x07c8 /* 0x00000000 */ -#define IOMUXC_AUD5_INPUT_DA_AMX_SELECT_INPUT 0x07cc /* 0x00000000 */ -#define IOMUXC_AUD5_INPUT_DB_AMX_SELECT_INPUT 0x07d0 /* 0x00000000 */ -#define IOMUXC_AUD5_INPUT_RXCLK_AMX_SELECT_INPUT 0x07d4 /* 0x00000000 */ -#define IOMUXC_AUD5_INPUT_RXFS_AMX_SELECT_INPUT 0x07d8 /* 0x00000000 */ -#define IOMUXC_AUD5_INPUT_TXCLK_AMX_SELECT_INPUT 0x07dc /* 0x00000000 */ -#define IOMUXC_AUD5_INPUT_TXFS_AMX_SELECT_INPUT 0x07e0 /* 0x00000000 */ -#define IOMUXC_FLEXCAN1_RX_SELECT_INPUT 0x07e4 /* 0x00000000 */ -#define IOMUXC_FLEXCAN2_RX_SELECT_INPUT 0x07e8 /* 0x00000000 */ -#define IOMUXC_CCM_PMIC_READY_SELECT_INPUT 0x07f0 /* 0x00000000 */ -#define IOMUXC_ECSPI1_CSPI_CLK_IN_SELECT_INPUT 0x07f4 /* 0x00000000 */ -#define IOMUXC_ECSPI1_MISO_SELECT_INPUT 0x07f8 /* 0x00000000 */ -#define IOMUXC_ECSPI1_MOSI_SELECT_INPUT 0x07fc /* 0x00000000 */ -#define IOMUXC_ECSPI1_SS0_SELECT_INPUT 0x0800 /* 0x00000000 */ -#define IOMUXC_ECSPI1_SS1_SELECT_INPUT 0x0804 /* 0x00000000 */ -#define IOMUXC_ECSPI1_SS2_SELECT_INPUT 0x0808 /* 0x00000000 */ -#define IOMUXC_ECSPI1_SS3_SELECT_INPUT 0x080c /* 0x00000000 */ -#define IOMUXC_ECSPI2_CSPI_CLK_IN_SELECT_INPUT 0x0810 /* 0x00000000 */ -#define IOMUXC_ECSPI2_MISO_SELECT_INPUT 0x0814 /* 0x00000000 */ -#define IOMUXC_ECSPI2_MOSI_SELECT_INPUT 0x0818 /* 0x00000000 */ -#define IOMUXC_ECSPI2_SS0_SELECT_INPUT 0x081c /* 0x00000000 */ -#define IOMUXC_ECSPI2_SS1_SELECT_INPUT 0x0820 /* 0x00000000 */ -#define IOMUXC_ECSPI4_SS0_SELECT_INPUT 0x0824 /* 0x00000000 */ -#define IOMUXC_ECSPI5_CSPI_CLK_IN_SELECT_INPUT 0x0828 /* 0x00000000 */ -#define IOMUXC_ECSPI5_MISO_SELECT_INPUT 0x082c /* 0x00000000 */ -#define IOMUXC_ECSPI5_MOSI_SELECT_INPUT 0x0830 /* 0x00000000 */ -#define IOMUXC_ECSPI5_SS0_SELECT_INPUT 0x0834 /* 0x00000000 */ -#define IOMUXC_ECSPI5_SS1_SELECT_INPUT 0x0838 /* 0x00000000 */ -#define IOMUXC_ENET_REF_CLK_SELECT_INPUT 0x083c /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_MDIO_SELECT_INPUT 0x0840 /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_RX_CLK_SELECT_INPUT 0x0844 /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_RX_DATA0_SELECT_INPUT 0x0848 /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_RX_DATA1_SELECT_INPUT 0x084c /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_RX_DATA2_SELECT_INPUT 0x0850 /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_RX_DATA3_SELECT_INPUT 0x0854 /* 0x00000000 */ -#define IOMUXC_ENET_MAC0_RX_EN_SELECT_INPUT 0x0858 /* 0x00000000 */ -#define IOMUXC_ESAI_RX_FS_SELECT_INPUT 0x085c /* 0x00000000 */ -#define IOMUXC_ESAI_TX_FS_SELECT_INPUT 0x0860 /* 0x00000000 */ -#define IOMUXC_ESAI_RX_HF_CLK_SELECT_INPUT 0x0864 /* 0x00000000 */ -#define IOMUXC_ESAI_TX_HF_CLK_SELECT_INPUT 0x0868 /* 0x00000000 */ -#define IOMUXC_ESAI_RX_CLK_SELECT_INPUT 0x086c /* 0x00000000 */ -#define IOMUXC_ESAI_TX_CLK_SELECT_INPUT 0x0870 /* 0x00000000 */ -#define IOMUXC_ESAI_SDO0_SELECT_INPUT 0x0874 /* 0x00000000 */ -#define IOMUXC_ESAI_SDO1_SELECT_INPUT 0x0878 /* 0x00000000 */ -#define IOMUXC_ESAI_SDO2_SDI3_SELECT_INPUT 0x087c /* 0x00000000 */ -#define IOMUXC_ESAI_SDO3_SDI2_SELECT_INPUT 0x0880 /* 0x00000000 */ -#define IOMUXC_ESAI_SDO4_SDI1_SELECT_INPUT 0x0884 /* 0x00000000 */ -#define IOMUXC_ESAI_SDO5_SDI0_SELECT_INPUT 0x0888 /* 0x00000000 */ -#define IOMUXC_HDMI_ICECIN_SELECT_INPUT 0x088c /* 0x00000000 */ -#define IOMUXC_HDMI_II2C_CLKIN_SELECT_INPUT 0x0890 /* 0x00000000 */ -#define IOMUXC_HDMI_II2C_DATAIN_SELECT_INPUT 0x0894 /* 0x00000000 */ -#define IOMUXC_I2C1_SCL_IN_SELECT_INPUT 0x0898 /* 0x00000000 */ -#define IOMUXC_I2C1_SDA_IN_SELECT_INPUT 0x089c /* 0x00000000 */ -#define IOMUXC_I2C2_SCL_IN_SELECT_INPUT 0x08a0 /* 0x00000000 */ -#define IOMUXC_I2C2_SDA_IN_SELECT_INPUT 0x08a4 /* 0x00000000 */ -#define IOMUXC_I2C3_SCL_IN_SELECT_INPUT 0x08a8 /* 0x00000000 */ -#define IOMUXC_I2C3_SDA_IN_SELECT_INPUT 0x08ac /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA10_SELECT_INPUT 0x08b0 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA11_SELECT_INPUT 0x08b4 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA12_SELECT_INPUT 0x08b8 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA13_SELECT_INPUT 0x08bc /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA14_SELECT_INPUT 0x08c0 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA15_SELECT_INPUT 0x08c4 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA16_SELECT_INPUT 0x08c8 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA17_SELECT_INPUT 0x08cc /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA18_SELECT_INPUT 0x08d0 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA19_SELECT_INPUT 0x08d4 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_DATA_EN_SELECT_INPUT 0x08d8 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_HSYNC_SELECT_INPUT 0x08dc /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_PIX_CLK_SELECT_INPUT 0x08e0 /* 0x00000000 */ -#define IOMUXC_IPU2_SENS1_VSYNC_SELECT_INPUT 0x08e4 /* 0x00000000 */ -#define IOMUXC_KEY_COL5_SELECT_INPUT 0x08e8 /* 0x00000000 */ -#define IOMUXC_KEY_COL6_SELECT_INPUT 0x08ec /* 0x00000000 */ -#define IOMUXC_KEY_COL7_SELECT_INPUT 0x08f0 /* 0x00000000 */ -#define IOMUXC_KEY_ROW5_SELECT_INPUT 0x08f4 /* 0x00000000 */ -#define IOMUXC_KEY_ROW6_SELECT_INPUT 0x08f8 /* 0x00000000 */ -#define IOMUXC_KEY_ROW7_SELECT_INPUT 0x08fc /* 0x00000000 */ -#define IOMUXC_MLB_MLB_CLK_IN_SELECT_INPUT 0x0900 /* 0x00000000 */ -#define IOMUXC_MLB_MLB_DATA_IN_SELECT_INPUT 0x0904 /* 0x00000000 */ -#define IOMUXC_MLB_MLB_SIG_IN_SELECT_INPUT 0x0908 /* 0x00000000 */ -#define IOMUXC_SDMA_EVENTS14_SELECT_INPUT 0x090c /* 0x00000000 */ -#define IOMUXC_SDMA_EVENTS15_SELECT_INPUT 0x0910 /* 0x00000000 */ -#define IOMUXC_SPDIF_SPDIF_IN1_SELECT_INPUT 0x0914 /* 0x00000000 */ -#define IOMUXC_SPDIF_TX_CLK2_SELECT_INPUT 0x0918 /* 0x00000000 */ -#define IOMUXC_UART1_UART_RTS_B_SELECT_INPUT 0x091c /* 0x00000000 */ -#define IOMUXC_UART1_UART_RX_DATA_SELECT_INPUT 0x0920 /* 0x00000000 */ -#define IOMUXC_UART2_UART_RTS_B_SELECT_INPUT 0x0924 /* 0x00000000 */ -#define IOMUXC_UART2_UART_RX_DATA_SELECT_INPUT 0x0928 /* 0x00000000 */ -#define IOMUXC_UART3_UART_RTS_B_SELECT_INPUT 0x092c /* 0x00000000 */ -#define IOMUXC_UART3_UART_RX_DATA_SELECT_INPUT 0x0930 /* 0x00000000 */ -#define IOMUXC_UART4_UART_RTS_B_SELECT_INPUT 0x0934 /* 0x00000000 */ -#define IOMUXC_UART4_UART_RX_DATA_SELECT_INPUT 0x0938 /* 0x00000000 */ -#define IOMUXC_UART5_UART_RTS_B_SELECT_INPUT 0x093c /* 0x00000000 */ -#define IOMUXC_UART5_UART_RX_DATA_SELECT_INPUT 0x0940 /* 0x00000000 */ -#define IOMUXC_USB_OTG_OC_SELECT_INPUT 0x0944 /* 0x00000000 */ -#define IOMUXC_USB_H1_OC_SELECT_INPUT 0x0948 /* 0x00000000 */ -#define IOMUXC_USDHC1_WP_ON_SELECT_INPUT 0x094c /* 0x00000000 */ - -#endif /* IMX6_IOMUXREG_H */ diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c index 139e2cd2ecda..8841ec5b84b2 100644 --- a/sys/arm/freescale/imx/imx6_machdep.c +++ b/sys/arm/freescale/imx/imx6_machdep.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -46,6 +47,18 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + +struct fdt_fixup_entry fdt_fixup_table[] = { + { NULL, NULL } +}; + +fdt_pic_decode_t fdt_pic_table[] = { + &gic_decode_fdt, + NULL +}; + vm_offset_t platform_lastaddr(void) { diff --git a/sys/arm/freescale/imx/imx_iomux.c b/sys/arm/freescale/imx/imx_iomux.c new file mode 100644 index 000000000000..e5d5085bf0e0 --- /dev/null +++ b/sys/arm/freescale/imx/imx_iomux.c @@ -0,0 +1,282 @@ +/*- + * Copyright (c) 2014 Ian Lepore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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$ + */ + +/* + * Pin mux and pad control driver for imx5 and imx6. + * + * This driver implements the fdt_pinctrl interface for configuring the gpio and + * peripheral pins based on fdt configuration data. + * + * When the driver attaches, it walks the entire fdt tree and automatically + * configures the pins for each device which has a pinctrl-0 property and whose + * status is "okay". In addition it implements the fdt_pinctrl_configure() + * method which any other driver can call at any time to reconfigure its pins. + * + * The nature of the fsl,pins property in fdt data makes this driver's job very + * easy. Instead of representing each pin and pad configuration using symbolic + * properties such as pullup-enable="true" and so on, the data simply contains + * the addresses of the registers that control the pins, and the raw values to + * store in those registers. + * + * The imx5 and imx6 SoCs also have a small number of "general purpose + * registers" in the iomuxc device which are used to control an assortment + * of completely unrelated aspects of SoC behavior. This driver provides other + * drivers with direct access to those registers via simple accessor functions. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +struct iomux_softc { + device_t dev; + struct resource *mem_res; + u_int last_gpreg; +}; + +static struct iomux_softc *iomux_sc; + +static struct ofw_compat_data compat_data[] = { + {"fsl,imx6dl-iomuxc", true}, + {"fsl,imx6q-iomuxc", true}, + {"fsl,imx6sl-iomuxc", true}, + {"fsl,imx6sx-iomuxc", true}, + {"fsl,imx53-iomuxc", true}, + {"fsl,imx51-iomuxc", true}, + {NULL, false}, +}; + +/* + * Each tuple in an fsl,pins property contains these fields. + */ +struct pincfg { + uint32_t mux_reg; + uint32_t padconf_reg; + uint32_t input_reg; + uint32_t mux_val; + uint32_t input_val; + uint32_t padconf_val; +}; + +static inline uint32_t +RD4(struct iomux_softc *sc, bus_size_t off) +{ + + return (bus_read_4(sc->mem_res, off)); +} + +static inline void +WR4(struct iomux_softc *sc, bus_size_t off, uint32_t val) +{ + + bus_write_4(sc->mem_res, off, val); +} + +static int +iomux_configure_pins(device_t dev, phandle_t cfgxref) +{ + struct iomux_softc * sc; + struct pincfg *cfgtuples, *cfg; + phandle_t cfgnode; + int i, ntuples; + + sc = device_get_softc(dev); + cfgnode = OF_node_from_xref(cfgxref); + ntuples = OF_getencprop_alloc(cfgnode, "fsl,pins", sizeof(*cfgtuples), + (void **)&cfgtuples); + if (ntuples < 0) + return (ENOENT); + if (ntuples == 0) + return (0); /* Empty property is not an error. */ + for (i = 0, cfg = cfgtuples; i < ntuples; i++, cfg++) { + WR4(sc, cfg->mux_reg, cfg->mux_val); + WR4(sc, cfg->input_reg, cfg->input_val); + WR4(sc, cfg->padconf_reg, cfg->padconf_val); + } + free(cfgtuples, M_OFWPROP); + return (0); +} + +static int +iomux_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) + return (ENXIO); + + device_set_desc(dev, "Freescale i.MX pin configuration"); + return (BUS_PROBE_DEFAULT); +} + +static int +iomux_detach(device_t dev) +{ + + /* This device is always present. */ + return (EBUSY); +} + +static int +iomux_attach(device_t dev) +{ + struct iomux_softc * sc; + int rid; + + sc = device_get_softc(dev); + sc->dev = dev; + + switch (imx_soc_type()) { + case IMXSOC_51: + sc->last_gpreg = 1; + break; + case IMXSOC_53: + sc->last_gpreg = 2; + break; + case IMXSOC_6DL: + case IMXSOC_6S: + case IMXSOC_6SL: + case IMXSOC_6Q: + sc->last_gpreg = 13; + break; + default: + device_printf(dev, "Unknown SoC type\n"); + return (ENXIO); + } + + rid = 0; + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->mem_res == NULL) { + device_printf(dev, "Cannot allocate memory resources\n"); + return (ENXIO); + } + + iomux_sc = sc; + + /* + * Register as a pinctrl device, and call the convenience function that + * walks the entire device tree invoking FDT_PINCTRL_CONFIGURE() on any + * pinctrl-0 property cells whose xref phandle refers to a configuration + * that is a child node of our node in the tree. + * + * The pinctrl bindings documentation specifically mentions that the + * pinctrl device itself may have a pinctrl-0 property which contains + * static configuration to be applied at device init time. The tree + * walk will automatically handle this for us when it passes through our + * node in the tree. + */ + fdt_pinctrl_register(dev, "fsl,pins"); + fdt_pinctrl_configure_tree(dev); + + return (0); +} + +uint32_t +imx_iomux_gpr_get(u_int regnum) +{ + struct iomux_softc * sc; + + sc = iomux_sc; + KASSERT(sc != NULL, ("%s called before attach", __FUNCTION__)); + KASSERT(regnum >= 0 && regnum <= sc->last_gpreg, + ("%s bad regnum %u, max %u", __FUNCTION__, regnum, sc->last_gpreg)); + + return (RD4(iomux_sc, regnum * 4)); +} + +void +imx_iomux_gpr_set(u_int regnum, uint32_t val) +{ + struct iomux_softc * sc; + + sc = iomux_sc; + KASSERT(sc != NULL, ("%s called before attach", __FUNCTION__)); + KASSERT(regnum >= 0 && regnum <= sc->last_gpreg, + ("%s bad regnum %u, max %u", __FUNCTION__, regnum, sc->last_gpreg)); + + WR4(iomux_sc, regnum * 4, val); +} + +void +imx_iomux_gpr_set_masked(u_int regnum, uint32_t clrbits, uint32_t setbits) +{ + struct iomux_softc * sc; + uint32_t val; + + sc = iomux_sc; + KASSERT(sc != NULL, ("%s called before attach", __FUNCTION__)); + KASSERT(regnum >= 0 && regnum <= sc->last_gpreg, + ("%s bad regnum %u, max %u", __FUNCTION__, regnum, sc->last_gpreg)); + + val = RD4(iomux_sc, regnum * 4); + val = (val & ~clrbits) | setbits; + WR4(iomux_sc, regnum * 4, val); +} + +static device_method_t imx_iomux_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, iomux_probe), + DEVMETHOD(device_attach, iomux_attach), + DEVMETHOD(device_detach, iomux_detach), + + /* fdt_pinctrl interface */ + DEVMETHOD(fdt_pinctrl_configure,iomux_configure_pins), + + DEVMETHOD_END +}; + +static driver_t imx_iomux_driver = { + "imx_iomux", + imx_iomux_methods, + sizeof(struct iomux_softc), +}; + +static devclass_t imx_iomux_devclass; + +EARLY_DRIVER_MODULE(imx_iomux, simplebus, imx_iomux_driver, + imx_iomux_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE); + diff --git a/sys/arm/freescale/imx/std.imx51 b/sys/arm/freescale/imx/std.imx51 index a6b6ffadd9e7..ce9d7d26be7e 100644 --- a/sys/arm/freescale/imx/std.imx51 +++ b/sys/arm/freescale/imx/std.imx51 @@ -10,5 +10,7 @@ options KERNPHYSADDR=0x90100000 makeoptions KERNPHYSADDR=0x90100000 options PHYSADDR=0x90000000 +device fdt_pinctrl + files "../freescale/imx/files.imx51" diff --git a/sys/arm/freescale/imx/std.imx53 b/sys/arm/freescale/imx/std.imx53 index 40fbb300a9c7..09bdb2d0e92c 100644 --- a/sys/arm/freescale/imx/std.imx53 +++ b/sys/arm/freescale/imx/std.imx53 @@ -10,5 +10,7 @@ options KERNPHYSADDR=0x70100000 makeoptions KERNPHYSADDR=0x70100000 options PHYSADDR=0x70000000 +device fdt_pinctrl + files "../freescale/imx/files.imx53" diff --git a/sys/arm/freescale/imx/std.imx6 b/sys/arm/freescale/imx/std.imx6 index 51f82a8e2f90..a559f17ceb06 100644 --- a/sys/arm/freescale/imx/std.imx6 +++ b/sys/arm/freescale/imx/std.imx6 @@ -13,5 +13,7 @@ options PHYSADDR = 0x10000000 options IPI_IRQ_START=0 options IPI_IRQ_END=15 +device fdt_pinctrl + files "../freescale/imx/files.imx6" diff --git a/sys/arm/include/armreg.h b/sys/arm/include/armreg.h index 2f21f7c58d1f..f8536048e224 100644 --- a/sys/arm/include/armreg.h +++ b/sys/arm/include/armreg.h @@ -44,21 +44,29 @@ #define INSN_SIZE 4 #define INSN_COND_MASK 0xf0000000 /* Condition mask */ #define PSR_MODE 0x0000001f /* mode mask */ -#define PSR_USR26_MODE 0x00000000 -#define PSR_FIQ26_MODE 0x00000001 -#define PSR_IRQ26_MODE 0x00000002 -#define PSR_SVC26_MODE 0x00000003 #define PSR_USR32_MODE 0x00000010 #define PSR_FIQ32_MODE 0x00000011 #define PSR_IRQ32_MODE 0x00000012 #define PSR_SVC32_MODE 0x00000013 +#define PSR_MON32_MODE 0x00000016 #define PSR_ABT32_MODE 0x00000017 +#define PSR_HYP32_MODE 0x0000001a #define PSR_UND32_MODE 0x0000001b #define PSR_SYS32_MODE 0x0000001f #define PSR_32_MODE 0x00000010 -#define PSR_FLAGS 0xf0000000 /* flags */ - -#define PSR_C_bit (1 << 29) /* carry */ +#define PSR_T 0x00000020 /* Instruction set bit */ +#define PSR_F 0x00000040 /* FIQ disable bit */ +#define PSR_I 0x00000080 /* IRQ disable bit */ +#define PSR_A 0x00000100 /* Imprecise abort bit */ +#define PSR_E 0x00000200 /* Data endianess bit */ +#define PSR_GE 0x000f0000 /* Greater than or equal to bits */ +#define PSR_J 0x01000000 /* Java bit */ +#define PSR_Q 0x08000000 /* Sticky overflow bit */ +#define PSR_V 0x10000000 /* Overflow bit */ +#define PSR_C 0x20000000 /* Carry bit */ +#define PSR_Z 0x40000000 /* Zero bit */ +#define PSR_N 0x80000000 /* Negative bit */ +#define PSR_FLAGS 0xf0000000 /* Flags mask. */ /* The high-order byte is always the implementor */ #define CPU_ID_IMPLEMENTOR_MASK 0xff000000 @@ -236,16 +244,23 @@ #define CPU_CONTROL_SYST_ENABLE 0x00000100 /* S: System protection bit */ #define CPU_CONTROL_ROM_ENABLE 0x00000200 /* R: ROM protection bit */ #define CPU_CONTROL_CPCLK 0x00000400 /* F: Implementation defined */ +#define CPU_CONTROL_SW_ENABLE 0x00000400 /* SW: SWP instruction enable */ #define CPU_CONTROL_BPRD_ENABLE 0x00000800 /* Z: Branch prediction enable */ #define CPU_CONTROL_IC_ENABLE 0x00001000 /* I: IC enable */ #define CPU_CONTROL_VECRELOC 0x00002000 /* V: Vector relocation */ #define CPU_CONTROL_ROUNDROBIN 0x00004000 /* RR: Predictable replacement */ #define CPU_CONTROL_V4COMPAT 0x00008000 /* L4: ARMv4 compat LDR R15 etc */ +#define CPU_CONTROL_HAF_ENABLE 0x00020000 /* HA: Hardware Access Flag Enable */ #define CPU_CONTROL_FI_ENABLE 0x00200000 /* FI: Low interrupt latency */ #define CPU_CONTROL_UNAL_ENABLE 0x00400000 /* U: unaligned data access */ #define CPU_CONTROL_V6_EXTPAGE 0x00800000 /* XP: ARMv6 extended page tables */ +#define CPU_CONTROL_V_ENABLE 0x01000000 /* VE: Interrupt vectors enable */ +#define CPU_CONTROL_EX_BEND 0x02000000 /* EE: exception endianness */ #define CPU_CONTROL_L2_ENABLE 0x04000000 /* L2 Cache enabled */ -#define CPU_CONTROL_AF_ENABLE 0x20000000 /* Access Flag enable */ +#define CPU_CONTROL_NMFI 0x08000000 /* NMFI: Non maskable FIQ */ +#define CPU_CONTROL_TR_ENABLE 0x10000000 /* TRE: TEX Remap*/ +#define CPU_CONTROL_AF_ENABLE 0x20000000 /* AFE: Access Flag enable */ +#define CPU_CONTROL_TE_ENABLE 0x40000000 /* TE: Thumb Exception enable */ #define CPU_CONTROL_IDC_ENABLE CPU_CONTROL_DC_ENABLE @@ -362,6 +377,15 @@ #define FAULT_EXTERNAL 0x400 /* External abort (armv6+) */ #define FAULT_WNR 0x800 /* Write-not-Read access (armv6+) */ +/* Fault status register definitions - v6+ */ +#define FSR_STATUS_TO_IDX(fsr) (((fsr) & 0xF) | \ + (((fsr) & (1 << 10)>> (10 - 4)))) +#define FSR_LPAE (1 << 9) /* LPAE indicator */ +#define FSR_WNR (1 << 11) /* Write-not-Read access */ +#define FSR_EXT (1 << 12) /* DECERR/SLVERR for external*/ +#define FSR_CM (1 << 13) /* Cache maintenance fault */ + + /* * Address of the vector page, low and high versions. */ diff --git a/sys/arm/include/asm.h b/sys/arm/include/asm.h index 231d5598047b..9577001917b2 100644 --- a/sys/arm/include/asm.h +++ b/sys/arm/include/asm.h @@ -43,12 +43,6 @@ #define _C_LABEL(x) x #define _ASM_LABEL(x) x -#define I32_bit (1 << 7) /* IRQ disable */ -#define F32_bit (1 << 6) /* FIQ disable */ - -#define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */ -#define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */ - #ifndef _ALIGN_TEXT # define _ALIGN_TEXT .align 0 #endif diff --git a/sys/arm/include/atomic.h b/sys/arm/include/atomic.h index a62ca0037446..5857f5d96689 100644 --- a/sys/arm/include/atomic.h +++ b/sys/arm/include/atomic.h @@ -40,6 +40,7 @@ #define _MACHINE_ATOMIC_H_ #include +#include #ifndef _KERNEL #include @@ -67,12 +68,7 @@ #define wmb() dmb() #define rmb() dmb() -#ifndef I32_bit -#define I32_bit (1 << 7) /* IRQ disable */ -#endif -#ifndef F32_bit -#define F32_bit (1 << 6) /* FIQ disable */ -#endif + /* * It would be nice to use _HAVE_ARMv6_INSTRUCTIONS from machine/asm.h @@ -268,12 +264,12 @@ atomic_cmpset_64(volatile uint64_t *p, uint64_t cmpval, uint64_t newval) __asm __volatile( "1: \n" " ldrexd %[tmp], [%[ptr]]\n" - " teq %Q[tmp], %Q[cmp]\n" + " teq %Q[tmp], %Q[cmpval]\n" " itee eq \n" - " teqeq %R[tmp], %R[cmp]\n" + " teqeq %R[tmp], %R[cmpval]\n" " movne %[ret], #0\n" " bne 2f\n" - " strexd %[ret], %[new], [%[ptr]]\n" + " strexd %[ret], %[newval], [%[ptr]]\n" " teq %[ret], #0\n" " it ne \n" " bne 1b\n" @@ -282,8 +278,8 @@ atomic_cmpset_64(volatile uint64_t *p, uint64_t cmpval, uint64_t newval) : [ret] "=&r" (ret), [tmp] "=&r" (tmp) : [ptr] "r" (p), - [cmp] "r" (cmpval), - [new] "r" (newval) + [cmpval] "r" (cmpval), + [newval] "r" (newval) : "cc", "memory"); return (ret); } @@ -702,7 +698,7 @@ atomic_store_rel_long(volatile u_long *p, u_long v) "orr %1, %0, %2;" \ "msr cpsr_fsxc, %1;" \ : "=r" (cpsr_save), "=r" (tmp) \ - : "I" (I32_bit | F32_bit) \ + : "I" (PSR_I | PSR_F) \ : "cc" ); \ (expr); \ __asm __volatile( \ diff --git a/sys/arm/include/intr.h b/sys/arm/include/intr.h index c1d4e395e58d..35097725b71a 100644 --- a/sys/arm/include/intr.h +++ b/sys/arm/include/intr.h @@ -82,5 +82,7 @@ extern int (*arm_config_irq)(int irq, enum intr_trigger trig, void arm_irq_memory_barrier(uintptr_t); void gic_init_secondary(void); +int gic_decode_fdt(uint32_t iparentnode, uint32_t *intrcells, int *interrupt, + int *trig, int *pol); #endif /* _MACHINE_INTR_H */ diff --git a/sys/arm/include/pmap.h b/sys/arm/include/pmap.h index 70c337a9dfe7..3f0b9e984d77 100644 --- a/sys/arm/include/pmap.h +++ b/sys/arm/include/pmap.h @@ -256,7 +256,7 @@ int pmap_change_attr(vm_offset_t, vm_size_t, int); void pmap_kenter(vm_offset_t va, vm_paddr_t pa); void pmap_kenter_nocache(vm_offset_t va, vm_paddr_t pa); void pmap_kenter_device(vm_offset_t va, vm_paddr_t pa); -void *pmap_kenter_temp(vm_paddr_t pa, int i); +void *pmap_kenter_temporary(vm_paddr_t pa, int i); void pmap_kenter_user(vm_offset_t va, vm_paddr_t pa); vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kremove(vm_offset_t); diff --git a/sys/arm/include/sysreg.h b/sys/arm/include/sysreg.h new file mode 100644 index 000000000000..76b1f2bc59ee --- /dev/null +++ b/sys/arm/include/sysreg.h @@ -0,0 +1,232 @@ +/*- + * Copyright 2014 Svatopluk Kraus + * Copyright 2014 Michal Meloun + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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$ + */ + +/* + * Macros to make working with the System Control Registers simpler. + */ + +#ifndef MACHINE_SYSREG_H +#define MACHINE_SYSREG_H + +#include + +/* + * CP15 C0 registers + */ +#define CP15_MIDR(rr) p15, 0, rr, c0, c0, 0 /* Main ID Register */ +#define CP15_CTR(rr) p15, 0, rr, c0, c0, 1 /* Cache Type Register */ +#define CP15_TCMTR(rr) p15, 0, rr, c0, c0, 2 /* TCM Type Register */ +#define CP15_TLBTR(rr) p15, 0, rr, c0, c0, 3 /* TLB Type Register */ +#define CP15_MPIDR(rr) p15, 0, rr, c0, c0, 5 /* Multiprocessor Affinity Register */ +#define CP15_REVIDR(rr) p15, 0, rr, c0, c0, 6 /* Revision ID Register */ + +#define CP15_ID_PFR0(rr) p15, 0, rr, c0, c1, 0 /* Processor Feature Register 0 */ +#define CP15_ID_PFR1(rr) p15, 0, rr, c0, c1, 1 /* Processor Feature Register 1 */ +#define CP15_ID_DFR0(rr) p15, 0, rr, c0, c1, 2 /* Debug Feature Register 0 */ +#define CP15_ID_AFR0(rr) p15, 0, rr, c0, c1, 3 /* Auxiliary Feature Register 0 */ +#define CP15_ID_MMFR0(rr) p15, 0, rr, c0, c1, 4 /* Memory Model Feature Register 0 */ +#define CP15_ID_MMFR1(rr) p15, 0, rr, c0, c1, 5 /* Memory Model Feature Register 1 */ +#define CP15_ID_MMFR2(rr) p15, 0, rr, c0, c1, 6 /* Memory Model Feature Register 2 */ +#define CP15_ID_MMFR3(rr) p15, 0, rr, c0, c1, 7 /* Memory Model Feature Register 3 */ + +#define CP15_ID_ISAR0(rr) p15, 0, rr, c0, c2, 0 /* Instruction Set Attribute Register 0 */ +#define CP15_ID_ISAR1(rr) p15, 0, rr, c0, c2, 1 /* Instruction Set Attribute Register 1 */ +#define CP15_ID_ISAR2(rr) p15, 0, rr, c0, c2, 2 /* Instruction Set Attribute Register 2 */ +#define CP15_ID_ISAR3(rr) p15, 0, rr, c0, c2, 3 /* Instruction Set Attribute Register 3 */ +#define CP15_ID_ISAR4(rr) p15, 0, rr, c0, c2, 4 /* Instruction Set Attribute Register 4 */ +#define CP15_ID_ISAR5(rr) p15, 0, rr, c0, c2, 5 /* Instruction Set Attribute Register 5 */ + +#define CP15_CCSIDR(rr) p15, 1, rr, c0, c0, 0 /* Cache Size ID Registers */ +#define CP15_CLIDR(rr) p15, 1, rr, c0, c0, 1 /* Cache Level ID Register */ +#define CP15_AIDR(rr) p15, 1, rr, c0, c0, 7 /* Auxiliary ID Register */ + +#define CP15_CSSELR(rr) p15, 2, rr, c0, c0, 0 /* Cache Size Selection Register */ + +/* + * CP15 C1 registers + */ +#define CP15_SCTLR(rr) p15, 0, rr, c1, c0, 0 /* System Control Register */ +#define CP15_ACTLR(rr) p15, 0, rr, c1, c0, 1 /* IMPLEMENTATION DEFINED Auxiliary Control Register */ +#define CP15_CPACR(rr) p15, 0, rr, c1, c0, 2 /* Coprocessor Access Control Register */ + +#define CP15_SCR(rr) p15, 0, rr, c1, c1, 0 /* Secure Configuration Register */ +#define CP15_SDER(rr) p15, 0, rr, c1, c1, 1 /* Secure Debug Enable Register */ +#define CP15_NSACR(rr) p15, 0, rr, c1, c1, 2 /* Non-Secure Access Control Register */ + +/* + * CP15 C2 registers + */ +#define CP15_TTBR0(rr) p15, 0, rr, c2, c0, 0 /* Translation Table Base Register 0 */ +#define CP15_TTBR1(rr) p15, 0, rr, c2, c0, 1 /* Translation Table Base Register 1 */ +#define CP15_TTBCR(rr) p15, 0, rr, c2, c0, 2 /* Translation Table Base Control Register */ + +/* + * CP15 C3 registers + */ +#define CP15_DACR(rr) p15, 0, rr, c3, c0, 0 /* Domain Access Control Register */ + +/* + * CP15 C5 registers + */ +#define CP15_DFSR(rr) p15, 0, rr, c5, c0, 0 /* Data Fault Status Register */ + +#if __ARM_ARCH >= 6 +/* From ARMv6: */ +#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */ +/* From ARMv7: */ +#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */ +#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */ +#endif + + +/* + * CP15 C6 registers + */ +#define CP15_DFAR(rr) p15, 0, rr, c6, c0, 0 /* Data Fault Address Register */ + +#if __ARM_ARCH >= 6 +/* From ARMv6k: */ +#define CP15_IFAR(rr) p15, 0, rr, c6, c0, 2 /* Instruction Fault Address Register */ +#endif + +/* + * CP15 C7 registers + */ +#if __ARM_ARCH >= 6 +/* From ARMv7: */ +#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */ +#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */ +#endif + +#define CP15_PAR p15, 0, r0, c7, c4, 0 /* Physical Address Register */ + +#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */ +#define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */ +#if __ARM_ARCH >= 6 +/* Deprecated in ARMv7 */ +#define CP15_CP15ISB p15, 0, r0, c7, c5, 4 /* ISB */ +#endif +#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */ +#define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */ + +#if __ARM_ARCH >= 6 +/* Only ARMv6: */ +#define CP15_DCIALL p15, 0, r0, c7, c6, 0 /* Data cache invalidate all */ +#endif +#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */ +#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */ + +#define CP15_ATS1CPR(rr) p15, 0, rr, c7, c8, 0 /* Stage 1 Current state PL1 read */ +#define CP15_ATS1CPW(rr) p15, 0, rr, c7, c8, 1 /* Stage 1 Current state PL1 write */ +#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */ +#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */ + +#if __ARM_ARCH >= 6 +/* From ARMv7: */ +#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */ +#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */ +#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */ +#define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */ +#endif + +#if __ARM_ARCH >= 6 +/* Only ARMv6: */ +#define CP15_DCCALL p15, 0, r0, c7, c10, 0 /* Data cache clean all */ +#endif +#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */ +#define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */ +#if __ARM_ARCH >= 6 +/* Only ARMv6: */ +#define CP15_CP15DSB p15, 0, r0, c7, c10, 4 /* DSB */ +#define CP15_CP15DMB p15, 0, r0, c7, c10, 5 /* DMB */ +#endif + +#if __ARM_ARCH >= 6 +/* From ARMv7: */ +#define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */ +#endif + +#if __ARM_ARCH >= 6 +/* Only ARMv6: */ +#define CP15_DCCIALL p15, 0, r0, c7, c14, 0 /* Data cache clean and invalidate all */ +#endif +#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */ +#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */ + +/* + * CP15 C8 registers + */ +#if __ARM_ARCH >= 6 +/* From ARMv7: */ +#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */ +#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */ +#define CP15_TLBIASIDIS(rr) p15, 0, rr, c8, c3, 2 /* Invalidate unified TLB by ASID IS */ +#define CP15_TLBIMVAAIS(rr) p15, 0, rr, c8, c3, 3 /* Invalidate unified TLB by MVA, all ASID IS */ +#endif + +#define CP15_TLBIALL p15, 0, r0, c8, c7, 0 /* Invalidate entire unified TLB */ +#define CP15_TLBIMVA(rr) p15, 0, rr, c8, c7, 1 /* Invalidate unified TLB by MVA */ +#define CP15_TLBIASID(rr) p15, 0, rr, c8, c7, 2 /* Invalidate unified TLB by ASID */ + +#if __ARM_ARCH >= 6 +/* From ARMv6: */ +#define CP15_TLBIMVAA(rr) p15, 0, rr, c8, c7, 3 /* Invalidate unified TLB by MVA, all ASID */ +#endif + +/* + * CP15 C10 registers + */ +/* Without LPAE this is PRRR, with LPAE it's MAIR0 */ +#define CP15_PRRR(rr) p15, 0, rr, c10, c2, 0 /* Primary Region Remap Register */ +#define CP15_MAIR0(rr) p15, 0, rr, c10, c2, 0 /* Memory Attribute Indirection Register 0 */ +/* Without LPAE this is NMRR, with LPAE it's MAIR1 */ +#define CP15_NMRR(rr) p15, 0, rr, c10, c2, 1 /* Normal Memory Remap Register */ +#define CP15_MAIR1(rr) p15, 0, rr, c10, c2, 1 /* Memory Attribute Indirection Register 1 */ + +#define CP15_AMAIR0(rr) p15, 0, rr, c10, c3, 0 /* Auxiliary Memory Attribute Indirection Register 0 */ +#define CP15_AMAIR1(rr) p15, 0, rr, c10, c3, 1 /* Auxiliary Memory Attribute Indirection Register 1 */ + +/* + * CP15 C12 registers + */ +#define CP15_VBAR(rr) p15, 0, rr, c12, c0, 0 /* Vector Base Address Register */ +#define CP15_MVBAR(rr) p15, 0, rr, c12, c0, 1 /* Monitor Vector Base Address Register */ + +#define CP15_ISR(rr) p15, 0, rr, c12, c1, 0 /* Interrupt Status Register */ + +/* + * CP15 C13 registers + */ +#define CP15_FCSEIDR(rr) p15, 0, rr, c13, c0, 0 /* FCSE Process ID Register */ +#define CP15_CONTEXTIDR(rr) p15, 0, rr, c13, c0, 1 /* Context ID Register */ +#define CP15_TPIDRURW(rr) p15, 0, rr, c13, c0, 2 /* User Read/Write Thread ID Register */ +#define CP15_TPIDRURO(rr) p15, 0, rr, c13, c0, 3 /* User Read-Only Thread ID Register */ +#define CP15_TPIDRPRW(rr) p15, 0, rr, c13, c0, 4 /* PL1 only Thread ID Register */ + +#endif /* !MACHINE_SYSREG_H */ diff --git a/sys/arm/lpc/if_lpe.c b/sys/arm/lpc/if_lpe.c index 50f5f37f7b3f..0ddd2a5a33b2 100644 --- a/sys/arm/lpc/if_lpe.c +++ b/sys/arm/lpc/if_lpe.c @@ -754,7 +754,7 @@ lpe_rxintr(struct lpe_softc *sc) /* Check received frame for errors */ if (hws->lhs_info & LPE_HWDESC_RXERRS) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); lpe_discard_rxbuf(sc, cons); lpe_init_rxbuf(sc, cons); goto skip; @@ -764,7 +764,7 @@ lpe_rxintr(struct lpe_softc *sc) m->m_pkthdr.rcvif = ifp; m->m_data += 2; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); lpe_unlock(sc); (*ifp->if_input)(ifp, m); @@ -800,12 +800,12 @@ lpe_txintr(struct lpe_softc *sc) bus_dmamap_sync(sc->lpe_cdata.lpe_tx_buf_tag, txd->lpe_txdesc_dmamap, BUS_DMASYNC_POSTWRITE); - ifp->if_collisions += LPE_HWDESC_COLLISIONS(hws->lhs_info); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, LPE_HWDESC_COLLISIONS(hws->lhs_info)); if (hws->lhs_info & LPE_HWDESC_TXERRS) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (txd->lpe_txdesc_first) { bus_dmamap_unload(sc->lpe_cdata.lpe_tx_buf_tag, diff --git a/sys/arm/s3c2xx0/files.s3c2xx0 b/sys/arm/s3c2xx0/files.s3c2xx0 deleted file mode 100644 index 5ad289092fab..000000000000 --- a/sys/arm/s3c2xx0/files.s3c2xx0 +++ /dev/null @@ -1,15 +0,0 @@ -# $FreeBSD$ -arm/arm/bus_space_asm_generic.S standard -arm/arm/bus_space_generic.c standard -arm/arm/cpufunc_asm_arm9.S standard -arm/s3c2xx0/board_ln2410sbc.c optional board_ln2410sbc -arm/s3c2xx0/s3c24x0_rtc.c standard -arm/s3c2xx0/s3c24x0_machdep.c standard -arm/s3c2xx0/s3c24x0.c standard -arm/s3c2xx0/s3c2xx0_space.c standard -arm/s3c2xx0/s3c24x0_clk.c standard -arm/s3c2xx0/uart_bus_s3c2410.c optional uart -arm/s3c2xx0/uart_cpu_s3c2410.c optional uart -arm/s3c2xx0/uart_dev_s3c2410.c optional uart - -dev/usb/controller/ohci_s3c24x0.c optional ohci diff --git a/sys/arm/s3c2xx0/board_ln2410sbc.c b/sys/arm/samsung/s3c2xx0/board_ln2410sbc.c similarity index 94% rename from sys/arm/s3c2xx0/board_ln2410sbc.c rename to sys/arm/samsung/s3c2xx0/board_ln2410sbc.c index 5f5ac90652cd..d0f474ebb4d5 100644 --- a/sys/arm/s3c2xx0/board_ln2410sbc.c +++ b/sys/arm/samsung/s3c2xx0/board_ln2410sbc.c @@ -30,8 +30,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include extern vm_offset_t s3c2410_uart_vaddr; diff --git a/sys/arm/samsung/s3c2xx0/files.s3c2xx0 b/sys/arm/samsung/s3c2xx0/files.s3c2xx0 new file mode 100644 index 000000000000..eb02fc52de34 --- /dev/null +++ b/sys/arm/samsung/s3c2xx0/files.s3c2xx0 @@ -0,0 +1,15 @@ +# $FreeBSD$ +arm/arm/bus_space_asm_generic.S standard +arm/arm/bus_space_generic.c standard +arm/arm/cpufunc_asm_arm9.S standard +arm/samsung/s3c2xx0/board_ln2410sbc.c optional board_ln2410sbc +arm/samsung/s3c2xx0/s3c24x0_rtc.c standard +arm/samsung/s3c2xx0/s3c24x0_machdep.c standard +arm/samsung/s3c2xx0/s3c24x0.c standard +arm/samsung/s3c2xx0/s3c2xx0_space.c standard +arm/samsung/s3c2xx0/s3c24x0_clk.c standard +arm/samsung/s3c2xx0/uart_bus_s3c2410.c optional uart +arm/samsung/s3c2xx0/uart_cpu_s3c2410.c optional uart +arm/samsung/s3c2xx0/uart_dev_s3c2410.c optional uart + +dev/usb/controller/ohci_s3c24x0.c optional ohci diff --git a/sys/arm/s3c2xx0/s3c2410reg.h b/sys/arm/samsung/s3c2xx0/s3c2410reg.h similarity index 98% rename from sys/arm/s3c2xx0/s3c2410reg.h rename to sys/arm/samsung/s3c2xx0/s3c2410reg.h index 89298ea15ee1..e13ee3caf598 100644 --- a/sys/arm/s3c2xx0/s3c2410reg.h +++ b/sys/arm/samsung/s3c2xx0/s3c2410reg.h @@ -42,7 +42,7 @@ #define _ARM_S3C2XX0_S3C2410REG_H_ /* common definitions for S3C2410 and S3C2440 */ -#include +#include /* * Memory Map diff --git a/sys/arm/s3c2xx0/s3c2410var.h b/sys/arm/samsung/s3c2xx0/s3c2410var.h similarity index 97% rename from sys/arm/s3c2xx0/s3c2410var.h rename to sys/arm/samsung/s3c2xx0/s3c2410var.h index b17784de2881..1ce9b99afc1c 100644 --- a/sys/arm/s3c2xx0/s3c2410var.h +++ b/sys/arm/samsung/s3c2xx0/s3c2410var.h @@ -34,7 +34,7 @@ #ifndef _ARM_S3C2410VAR_H_ #define _ARM_S3C2410VAR_H_ -#include +#include int s3c2410_sscom_cnattach(bus_space_tag_t, int, int, int, tcflag_t); int s3c2410_sscom_kgdb_attach(bus_space_tag_t, int, int, int, tcflag_t); diff --git a/sys/arm/s3c2xx0/s3c2440reg.h b/sys/arm/samsung/s3c2xx0/s3c2440reg.h similarity index 98% rename from sys/arm/s3c2xx0/s3c2440reg.h rename to sys/arm/samsung/s3c2xx0/s3c2440reg.h index f3cda608d478..2304b69e0718 100644 --- a/sys/arm/s3c2xx0/s3c2440reg.h +++ b/sys/arm/samsung/s3c2xx0/s3c2440reg.h @@ -36,7 +36,7 @@ #define _ARM_S3C2XX0_S3C2440REG_H_ /* common definitions for S3C2410 and S3C2440 */ -#include +#include /* * Memory Map diff --git a/sys/arm/s3c2xx0/s3c24x0.c b/sys/arm/samsung/s3c2xx0/s3c24x0.c similarity index 99% rename from sys/arm/s3c2xx0/s3c24x0.c rename to sys/arm/samsung/s3c2xx0/s3c24x0.c index 14e6f82ad02c..49acdc65dbdd 100644 --- a/sys/arm/s3c2xx0/s3c24x0.c +++ b/sys/arm/samsung/s3c2xx0/s3c24x0.c @@ -43,14 +43,15 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #include -#include -#include -#include +#include +#include +#include #include #define S3C2XX0_XTAL_CLK 12000000 @@ -638,7 +639,7 @@ s3c24x0_clock_freq(struct s3c2xx0_softc *sc) void cpu_reset(void) { - (void) disable_interrupts(I32_bit|F32_bit); + (void) disable_interrupts(PSR_I|PSR_F); bus_space_write_4(&s3c2xx0_bs_tag, s3c2xx0_softc->sc_wdt_ioh, WDT_WTCON, WTCON_ENABLE | WTCON_CLKSEL_16 | WTCON_ENRST); diff --git a/sys/arm/s3c2xx0/s3c24x0_clk.c b/sys/arm/samsung/s3c2xx0/s3c24x0_clk.c similarity index 98% rename from sys/arm/s3c2xx0/s3c24x0_clk.c rename to sys/arm/samsung/s3c2xx0/s3c24x0_clk.c index 35ce349a8fd4..d4c4e984f7f9 100644 --- a/sys/arm/s3c2xx0/s3c24x0_clk.c +++ b/sys/arm/samsung/s3c2xx0/s3c24x0_clk.c @@ -48,8 +48,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include +#include +#include struct s3c24x0_timer_softc { device_t dev; diff --git a/sys/arm/s3c2xx0/s3c24x0_machdep.c b/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c similarity index 98% rename from sys/arm/s3c2xx0/s3c24x0_machdep.c rename to sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c index 5264e7a805d5..411447b416cc 100644 --- a/sys/arm/s3c2xx0/s3c24x0_machdep.c +++ b/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c @@ -89,9 +89,9 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include +#include +#include +#include /* Page table for mapping proc0 zero page */ #define KERNEL_PT_SYS 0 diff --git a/sys/arm/s3c2xx0/s3c24x0_rtc.c b/sys/arm/samsung/s3c2xx0/s3c24x0_rtc.c similarity index 98% rename from sys/arm/s3c2xx0/s3c24x0_rtc.c rename to sys/arm/samsung/s3c2xx0/s3c24x0_rtc.c index 8845c440d820..f0d35c9053b1 100644 --- a/sys/arm/s3c2xx0/s3c24x0_rtc.c +++ b/sys/arm/samsung/s3c2xx0/s3c24x0_rtc.c @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include "clock_if.h" diff --git a/sys/arm/s3c2xx0/s3c24x0reg.h b/sys/arm/samsung/s3c2xx0/s3c24x0reg.h similarity index 99% rename from sys/arm/s3c2xx0/s3c24x0reg.h rename to sys/arm/samsung/s3c2xx0/s3c24x0reg.h index e60ce8870f8b..2004e114701d 100644 --- a/sys/arm/s3c2xx0/s3c24x0reg.h +++ b/sys/arm/samsung/s3c2xx0/s3c24x0reg.h @@ -43,7 +43,7 @@ #define _ARM_S3C2XX0_S3C24X0REG_H_ /* common definitions for S3C2800, S3C2410 and S3C2440 */ -#include +#include /* * Map the device registers into kernel space. diff --git a/sys/arm/s3c2xx0/s3c24x0var.h b/sys/arm/samsung/s3c2xx0/s3c24x0var.h similarity index 97% rename from sys/arm/s3c2xx0/s3c24x0var.h rename to sys/arm/samsung/s3c2xx0/s3c24x0var.h index 5209da8eb68d..2ee042ea4318 100644 --- a/sys/arm/s3c2xx0/s3c24x0var.h +++ b/sys/arm/samsung/s3c2xx0/s3c24x0var.h @@ -34,7 +34,7 @@ #ifndef _ARM_S3C24X0VAR_H_ #define _ARM_S3C24X0VAR_H_ -#include +#include struct s3c24x0_softc { struct s3c2xx0_softc sc_sx; diff --git a/sys/arm/s3c2xx0/s3c2xx0_space.c b/sys/arm/samsung/s3c2xx0/s3c2xx0_space.c similarity index 100% rename from sys/arm/s3c2xx0/s3c2xx0_space.c rename to sys/arm/samsung/s3c2xx0/s3c2xx0_space.c diff --git a/sys/arm/s3c2xx0/s3c2xx0board.h b/sys/arm/samsung/s3c2xx0/s3c2xx0board.h similarity index 100% rename from sys/arm/s3c2xx0/s3c2xx0board.h rename to sys/arm/samsung/s3c2xx0/s3c2xx0board.h diff --git a/sys/arm/s3c2xx0/s3c2xx0reg.h b/sys/arm/samsung/s3c2xx0/s3c2xx0reg.h similarity index 100% rename from sys/arm/s3c2xx0/s3c2xx0reg.h rename to sys/arm/samsung/s3c2xx0/s3c2xx0reg.h diff --git a/sys/arm/s3c2xx0/s3c2xx0var.h b/sys/arm/samsung/s3c2xx0/s3c2xx0var.h similarity index 100% rename from sys/arm/s3c2xx0/s3c2xx0var.h rename to sys/arm/samsung/s3c2xx0/s3c2xx0var.h diff --git a/sys/arm/s3c2xx0/std.ln2410sbc b/sys/arm/samsung/s3c2xx0/std.ln2410sbc similarity index 83% rename from sys/arm/s3c2xx0/std.ln2410sbc rename to sys/arm/samsung/s3c2xx0/std.ln2410sbc index a76a849c97dd..1f1143e6cfbf 100644 --- a/sys/arm/s3c2xx0/std.ln2410sbc +++ b/sys/arm/samsung/s3c2xx0/std.ln2410sbc @@ -1,5 +1,5 @@ #$FreeBSD$ -include "../s3c2xx0/std.s3c2410" +include "../samsung/s3c2xx0/std.s3c2410" makeoptions KERNPHYSADDR=0x30000000 makeoptions KERNVIRTADDR=0xc0000000 diff --git a/sys/arm/s3c2xx0/std.s3c2410 b/sys/arm/samsung/s3c2xx0/std.s3c2410 similarity index 71% rename from sys/arm/s3c2xx0/std.s3c2410 rename to sys/arm/samsung/s3c2xx0/std.s3c2410 index 266d9e77f7ec..4f55b9335e72 100644 --- a/sys/arm/s3c2xx0/std.s3c2410 +++ b/sys/arm/samsung/s3c2xx0/std.s3c2410 @@ -1,6 +1,6 @@ # $FreeBSD$ -files "../s3c2xx0/files.s3c2xx0" +files "../samsung/s3c2xx0/files.s3c2xx0" cpu CPU_ARM9 machine arm diff --git a/sys/arm/s3c2xx0/uart_bus_s3c2410.c b/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c similarity index 96% rename from sys/arm/s3c2xx0/uart_bus_s3c2410.c rename to sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c index 41c750afb5cd..2102d8b013c4 100644 --- a/sys/arm/s3c2xx0/uart_bus_s3c2410.c +++ b/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c @@ -15,7 +15,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "uart_if.h" diff --git a/sys/arm/s3c2xx0/uart_cpu_s3c2410.c b/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c similarity index 98% rename from sys/arm/s3c2xx0/uart_cpu_s3c2410.c rename to sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c index 2ed036b48ad7..37b668e85da3 100644 --- a/sys/arm/s3c2xx0/uart_cpu_s3c2410.c +++ b/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; diff --git a/sys/arm/s3c2xx0/uart_dev_s3c2410.c b/sys/arm/samsung/s3c2xx0/uart_dev_s3c2410.c similarity index 98% rename from sys/arm/s3c2xx0/uart_dev_s3c2410.c rename to sys/arm/samsung/s3c2xx0/uart_dev_s3c2410.c index aadd835dcbec..2ee121700dec 100644 --- a/sys/arm/s3c2xx0/uart_dev_s3c2410.c +++ b/sys/arm/samsung/s3c2xx0/uart_dev_s3c2410.c @@ -41,10 +41,10 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "uart_if.h" /* Finds the subirq from the parent */ diff --git a/sys/arm/s3c2xx0/uart_dev_s3c2410.h b/sys/arm/samsung/s3c2xx0/uart_dev_s3c2410.h similarity index 100% rename from sys/arm/s3c2xx0/uart_dev_s3c2410.h rename to sys/arm/samsung/s3c2xx0/uart_dev_s3c2410.h diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c index ab0824e40950..5abad150a887 100644 --- a/sys/arm/ti/cpsw/if_cpsw.c +++ b/sys/arm/ti/cpsw/if_cpsw.c @@ -1837,7 +1837,7 @@ cpsw_tx_watchdog(struct cpsw_softc *sc) ++sc->watchdog.timer; if (sc->watchdog.timer > 2) { sc->watchdog.timer = 0; - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ++sc->watchdog.resets; cpsw_tx_watchdog_full_reset(sc); } diff --git a/sys/arm/versatile/files.versatile b/sys/arm/versatile/files.versatile index 254ebe1ea337..199fecbb566a 100644 --- a/sys/arm/versatile/files.versatile +++ b/sys/arm/versatile/files.versatile @@ -17,6 +17,5 @@ arm/versatile/versatile_pci.c optional pci arm/versatile/versatile_pci_bus_space.c optional pci arm/versatile/versatile_sic.c standard arm/versatile/versatile_timer.c standard -arm/versatile/if_smc_fdt.c optional smc kern/kern_clocksource.c standard diff --git a/sys/arm/xscale/i80321/i80321_intr.h b/sys/arm/xscale/i80321/i80321_intr.h index bde0bac97246..29003a05ce56 100644 --- a/sys/arm/xscale/i80321/i80321_intr.h +++ b/sys/arm/xscale/i80321/i80321_intr.h @@ -106,7 +106,7 @@ i80321_splx(int new) hwpend = (i80321_ipending & ICU_INT_HWMASK) & ~new; if (hwpend != 0) { - oldirqstate = disable_interrupts(I32_bit); + oldirqstate = disable_interrupts(PSR_I); intr_enabled |= hwpend; i80321_set_intrmask(); restore_interrupts(oldirqstate); diff --git a/sys/arm/xscale/i80321/i80321_timer.c b/sys/arm/xscale/i80321/i80321_timer.c index 98c1805df6ee..3b4e5a11b552 100644 --- a/sys/arm/xscale/i80321/i80321_timer.c +++ b/sys/arm/xscale/i80321/i80321_timer.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -381,7 +382,7 @@ cpu_initclocks(void) /* Report the clock frequency. */ - oldirqstate = disable_interrupts(I32_bit); + oldirqstate = disable_interrupts(PSR_I); irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, #ifdef CPU_XSCALE_81342 diff --git a/sys/arm/xscale/i80321/iq80321.c b/sys/arm/xscale/i80321/iq80321.c index 72300f13c0ee..fb344556ccb0 100644 --- a/sys/arm/xscale/i80321/iq80321.c +++ b/sys/arm/xscale/i80321/iq80321.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -325,7 +326,7 @@ arm_unmask_irq(uintptr_t nb) void cpu_reset() { - (void) disable_interrupts(I32_bit|F32_bit); + (void) disable_interrupts(PSR_I|PSR_F); *(__volatile uint32_t *)(IQ80321_80321_VBASE + VERDE_ATU_BASE + ATU_PCSR) = PCSR_RIB | PCSR_RPB; printf("Reset failed!\n"); diff --git a/sys/arm/xscale/i8134x/i81342.c b/sys/arm/xscale/i8134x/i81342.c index bb3795c5aeb2..49d658ae2d53 100644 --- a/sys/arm/xscale/i8134x/i81342.c +++ b/sys/arm/xscale/i8134x/i81342.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #define _ARM32_BUS_DMA_PRIVATE +#include #include #include @@ -248,7 +249,7 @@ void cpu_reset(void) { - disable_interrupts(I32_bit); + disable_interrupts(PSR_I); /* XXX: Use the watchdog to reset for now */ __asm __volatile("mcr p6, 0, %0, c8, c9, 0\n" "mcr p6, 0, %1, c7, c9, 0\n" diff --git a/sys/arm/xscale/ixp425/if_npe.c b/sys/arm/xscale/ixp425/if_npe.c index d031de674230..d6db7e6134fd 100644 --- a/sys/arm/xscale/ixp425/if_npe.c +++ b/sys/arm/xscale/ixp425/if_npe.c @@ -906,20 +906,18 @@ npe_addstats(struct npe_softc *sc) be32toh(ns->RxOverrunDiscards) + be32toh(ns->RxUnderflowEntryDiscards); - ifp->if_oerrors += - be32toh(ns->dot3StatsInternalMacTransmitErrors) - + be32toh(ns->dot3StatsCarrierSenseErrors) - + be32toh(ns->TxVLANIdFilterDiscards) - ; - ifp->if_ierrors += be32toh(ns->dot3StatsFCSErrors) - + be32toh(ns->dot3StatsInternalMacReceiveErrors) - + be32toh(ns->RxOverrunDiscards) - + be32toh(ns->RxUnderflowEntryDiscards) - ; - ifp->if_collisions += - be32toh(ns->dot3StatsSingleCollisionFrames) - + be32toh(ns->dot3StatsMultipleCollisionFrames) - ; + if_inc_counter(ifp, IFCOUNTER_OERRORS, + be32toh(ns->dot3StatsInternalMacTransmitErrors) + + be32toh(ns->dot3StatsCarrierSenseErrors) + + be32toh(ns->TxVLANIdFilterDiscards)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, + be32toh(ns->dot3StatsFCSErrors) + + be32toh(ns->dot3StatsInternalMacReceiveErrors) + + be32toh(ns->RxOverrunDiscards) + + be32toh(ns->RxUnderflowEntryDiscards)); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + be32toh(ns->dot3StatsSingleCollisionFrames) + + be32toh(ns->dot3StatsMultipleCollisionFrames)); #undef NPEADD #undef MIBADD } @@ -999,7 +997,7 @@ npe_txdone_finish(struct npe_softc *sc, const struct txdone *td) * We're no longer busy, so clear the busy flag and call the * start routine to xmit more packets. */ - ifp->if_opackets += td->count; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, td->count); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->npe_watchdog_timer = 0; npestart_locked(ifp); @@ -1138,7 +1136,7 @@ npe_rxdone(int qid, void *arg) mrx->m_pkthdr.len = mrx->m_len; mrx->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); ifp->if_input(ifp, mrx); rx_npkts++; } else { @@ -1467,7 +1465,7 @@ npewatchdog(struct npe_softc *sc) return; device_printf(sc->sc_dev, "watchdog timeout\n"); - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); npeinit_locked(sc); } diff --git a/sys/arm/xscale/ixp425/ixp425.c b/sys/arm/xscale/ixp425/ixp425.c index efe9aa3edeaa..07c491aa573f 100644 --- a/sys/arm/xscale/ixp425/ixp425.c +++ b/sys/arm/xscale/ixp425/ixp425.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -202,7 +203,7 @@ arm_mask_irq(uintptr_t nb) { int i; - i = disable_interrupts(I32_bit); + i = disable_interrupts(PSR_I); if (nb < 32) { intr_enabled &= ~(1 << nb); ixp425_set_intrmask(); @@ -220,7 +221,7 @@ arm_unmask_irq(uintptr_t nb) { int i; - i = disable_interrupts(I32_bit); + i = disable_interrupts(PSR_I); if (nb < 32) { intr_enabled |= (1 << nb); ixp425_set_intrmask(); diff --git a/sys/arm/xscale/ixp425/ixp425_pci.c b/sys/arm/xscale/ixp425/ixp425_pci.c index 9495ede5eea9..5a1321864621 100644 --- a/sys/arm/xscale/ixp425/ixp425_pci.c +++ b/sys/arm/xscale/ixp425/ixp425_pci.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -70,7 +71,7 @@ extern struct ixp425_softc *ixp425_softc; #define PCI_CSR_READ_4(sc, reg) \ bus_read_4(sc->sc_csr, reg) -#define PCI_CONF_LOCK(s) (s) = disable_interrupts(I32_bit) +#define PCI_CONF_LOCK(s) (s) = disable_interrupts(PSR_I) #define PCI_CONF_UNLOCK(s) restore_interrupts((s)) static device_probe_t ixppcib_probe; @@ -319,9 +320,12 @@ static int ixppcib_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { - struct ixppcib_softc *sc = device_get_softc(bus); + int error; + error = rman_activate_resource(r); + if (error) + return (error); switch (type) { case SYS_RES_IOPORT: rman_set_bustag(r, &sc->sc_pci_iot); @@ -334,7 +338,7 @@ ixppcib_activate_resource(device_t bus, device_t child, int type, int rid, break; } - return (rman_activate_resource(r)); + return (0); } static int diff --git a/sys/arm/xscale/ixp425/ixp425_timer.c b/sys/arm/xscale/ixp425/ixp425_timer.c index e0b70e94e3ac..6357c1385664 100644 --- a/sys/arm/xscale/ixp425/ixp425_timer.c +++ b/sys/arm/xscale/ixp425/ixp425_timer.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -175,7 +176,7 @@ cpu_initclocks(void) /* Report the clock frequency. */ - oldirqstate = disable_interrupts(I32_bit); + oldirqstate = disable_interrupts(PSR_I); irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, IXP425_INT_TMR0, IXP425_INT_TMR0, 1, RF_ACTIVE); diff --git a/sys/arm/xscale/pxa/pxa_icu.c b/sys/arm/xscale/pxa/pxa_icu.c index 0d7a51945d14..4194da3c036b 100644 --- a/sys/arm/xscale/pxa/pxa_icu.c +++ b/sys/arm/xscale/pxa/pxa_icu.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -105,7 +106,7 @@ pxa_icu_attach(device_t dev) pxa_icu_set_iclr(0); /* XXX: This should move to configure_final or something. */ - enable_interrupts(I32_bit|F32_bit); + enable_interrupts(PSR_I|PSR_F); return (0); } diff --git a/sys/arm/xscale/pxa/pxa_timer.c b/sys/arm/xscale/pxa/pxa_timer.c index 77e68a2eb095..d62c1e1edbc4 100644 --- a/sys/arm/xscale/pxa/pxa_timer.c +++ b/sys/arm/xscale/pxa/pxa_timer.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -190,7 +191,7 @@ cpu_reset(void) { uint32_t val; - (void)disable_interrupts(I32_bit|F32_bit); + (void)disable_interrupts(PSR_I|PSR_F); val = pxa_timer_get_oscr(); val += PXA_TIMER_FREQUENCY; diff --git a/sys/boot/Makefile.pc98 b/sys/boot/Makefile.pc98 index aa989e1784bd..84683991a645 100644 --- a/sys/boot/Makefile.pc98 +++ b/sys/boot/Makefile.pc98 @@ -1,4 +1,3 @@ # $FreeBSD$ -# Blank, to override Makefile.i386 since Makefile.$MACHINE is included before -# Makefile.$MACHINE_ARCH +SUBDIR+= libstand32 diff --git a/sys/boot/amd64/boot1.efi/boot1.c b/sys/boot/amd64/boot1.efi/boot1.c index 8661f0586877..eb27846383ab 100644 --- a/sys/boot/amd64/boot1.efi/boot1.c +++ b/sys/boot/amd64/boot1.efi/boot1.c @@ -26,6 +26,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #define _PATH_LOADER "/boot/loader.efi" #define _PATH_KERNEL "/boot/kernel/kernel" @@ -97,6 +98,7 @@ strcmp(const char *s1, const char *s2) static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; +static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID; static EFI_BLOCK_IO *bootdev; static EFI_DEVICE_PATH *bootdevpath; @@ -109,11 +111,20 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab) UINTN i, nparts = sizeof(handles); EFI_STATUS status; EFI_DEVICE_PATH *devpath; + EFI_BOOT_SERVICES *BS; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; char *path = _PATH_LOADER; systab = Xsystab; image = Ximage; + BS = systab->BootServices; + status = BS->LocateProtocol(&ConsoleControlGUID, NULL, + (VOID **)&ConsoleControl); + if (status == EFI_SUCCESS) + (void)ConsoleControl->SetMode(ConsoleControl, + EfiConsoleControlScreenText); + printf(" \n>> FreeBSD EFI boot block\n"); printf(" Loader path: %s\n", path); diff --git a/sys/boot/amd64/efi/bootinfo.c b/sys/boot/amd64/efi/bootinfo.c index db82b241df56..90798e888323 100644 --- a/sys/boot/amd64/efi/bootinfo.c +++ b/sys/boot/amd64/efi/bootinfo.c @@ -60,6 +60,7 @@ bi_getboothowto(char *kargs) { const char *sw; char *opts; + char *console; int howto, i; howto = 0; @@ -70,6 +71,14 @@ bi_getboothowto(char *kargs) howto |= howto_names[i].mask; } + console = getenv("console"); + if (console != NULL) { + if (strcmp(console, "comconsole") == 0) + howto |= RB_SERIAL; + if (strcmp(console, "nullconsole") == 0) + howto |= RB_MUTE; + } + /* Parse kargs */ if (kargs == NULL) return (howto); @@ -227,10 +236,14 @@ bi_load_efi_data(struct preloaded_file *kfp) if (efi_find_framebuffer(&efifb) == 0) { printf("EFI framebuffer information:\n"); - printf("addr, size 0x%lx, 0x%lx\n", efifb.fb_addr, efifb.fb_size); - printf("dimensions %d x %d\n", efifb.fb_width, efifb.fb_height); + printf("addr, size 0x%lx, 0x%lx\n", efifb.fb_addr, + efifb.fb_size); + printf("dimensions %d x %d\n", efifb.fb_width, + efifb.fb_height); printf("stride %d\n", efifb.fb_stride); - printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue, efifb.fb_mask_reserved); + printf("masks 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", + efifb.fb_mask_red, efifb.fb_mask_green, efifb.fb_mask_blue, + efifb.fb_mask_reserved); file_addmetadata(kfp, MODINFOMD_EFI_FB, sizeof(efifb), &efifb); } diff --git a/sys/boot/amd64/efi/conf.c b/sys/boot/amd64/efi/conf.c index 0e67b6b0fd09..f9984a325210 100644 --- a/sys/boot/amd64/efi/conf.c +++ b/sys/boot/amd64/efi/conf.c @@ -62,8 +62,12 @@ struct file_format *file_formats[] = { }; extern struct console efi_console; +extern struct console comconsole; +extern struct console nullconsole; struct console *consoles[] = { &efi_console, + &comconsole, + &nullconsole, NULL }; diff --git a/sys/boot/arm/ixp425/boot2/Makefile b/sys/boot/arm/ixp425/boot2/Makefile index 6fe515e0cfcb..fe1068faefaa 100644 --- a/sys/boot/arm/ixp425/boot2/Makefile +++ b/sys/boot/arm/ixp425/boot2/Makefile @@ -17,9 +17,7 @@ FILES=${P} SRCS=arm_init.S boot2.c ${BOOT_FLAVOR:tl}_board.c SRCS+=memchr.c memcmp.c memcpy.c memmem.c memset.c printf.c strcmp.c strcpy.c SRCS+=strlen.c ashldi3.c divsi3.S muldi3.c -.if ${MK_ARM_EABI} != "no" SRCS+=aeabi_unwind.c -.endif MAN= KERNPHYSADDR=0x180000 diff --git a/sys/boot/arm/uboot/help.uboot b/sys/boot/arm/uboot/help.uboot index 5873eb0512d2..c1574af92715 100644 --- a/sys/boot/arm/uboot/help.uboot +++ b/sys/boot/arm/uboot/help.uboot @@ -1 +1,27 @@ $FreeBSD$ + +############################################################################### +# Tubenv DShow or import U-Boot environment variables + + ubenv [varname ...] + + Display U-Boot environment variables, or import them into the + loader environment (which makes them available in the kernel). + +############################################################################### +# Tubenv Simport DImport U-Boot env vars + + ubenv import [varname ...] + + If no variable names are specified, all U-Boot environment + variables are imported. Each variable is prefixed with "uboot." + to avoid any possible conflicts with loader or kernel variables. + +############################################################################### +# Tubenv Sshow DShow U-Boot env vars + + ubenv show [varname ...] + + If no variable names are specified, all U-Boot environment + variables are shown. + diff --git a/sys/boot/common/Makefile.inc b/sys/boot/common/Makefile.inc index a44dcc1f8183..dde687940650 100644 --- a/sys/boot/common/Makefile.inc +++ b/sys/boot/common/Makefile.inc @@ -78,3 +78,6 @@ CFLAGS+=-I${.CURDIR}/../../../../lib/libstand .endif MAN+= loader.8 +.if ${MK_ZFS} != "no" +MAN+= zfsloader.8 +.endif diff --git a/sys/boot/common/part.c b/sys/boot/common/part.c index 086809f67aac..445761969563 100644 --- a/sys/boot/common/part.c +++ b/sys/boot/common/part.c @@ -53,6 +53,7 @@ static const uuid_t gpt_uuid_unused = GPT_ENT_TYPE_UNUSED; static const uuid_t gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; static const uuid_t gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS; static const uuid_t gpt_uuid_efi = GPT_ENT_TYPE_EFI; +static const uuid_t gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD; static const uuid_t gpt_uuid_freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT; static const uuid_t gpt_uuid_freebsd_nandfs = GPT_ENT_TYPE_FREEBSD_NANDFS; static const uuid_t gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP; @@ -139,6 +140,8 @@ gpt_parttype(uuid_t type) return (PART_FREEBSD_VINUM); else if (uuid_equal(&type, &gpt_uuid_freebsd_nandfs, NULL)) return (PART_FREEBSD_NANDFS); + else if (uuid_equal(&type, &gpt_uuid_freebsd, NULL)) + return (PART_FREEBSD); return (PART_UNKNOWN); } diff --git a/sys/boot/common/zfsloader.8 b/sys/boot/common/zfsloader.8 new file mode 100644 index 000000000000..9bb74a475171 --- /dev/null +++ b/sys/boot/common/zfsloader.8 @@ -0,0 +1,109 @@ +.\" Copyright (c) 2014 Andriy Gapon +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that 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 September 15, 2014 +.Dt ZFSLOADER 8 +.Os +.Sh NAME +.Nm zfsloader +.Nd kernel bootstrapping final stage +.Sh DESCRIPTION +.Nm +is an extended variant of +.Xr loader 8 +with added support for booting from ZFS. +This document describes only differences from +.Xr loader 8 . +.Sh ZFS FEATURES +.Nm +supports the following format for specifying ZFS filesystems which +can be used wherever +.Xr loader 8 +refers to a device specification: +.Pp +.Ar zfs:pool/filesystem: +.Pp +where +.Pa pool/filesystem +is a ZFS filesystem name as described in +.Xr zfs 8 . +.Pp +If +.Pa /etc/fstab +does not have an entry for the root filesystem and +.Va vfs.root.mountfrom +is not set, but +.Va currdev +refers to a ZFS filesystem, then +.Nm +will instruct kernel to use that filesystem as the root filesystem. +.Sh ZFS COMMAND EXTENSIONS +.Bl -tag -width Ds -compact +.Pp +.It Ic lsdev Op Fl v +Lists ZFS pools in addition to disks and partitions. +Adding +.Fl v +shows more ZFS pool details in a format that resembles +.Nm zpool Cm status +output. +.Pp +.It Ic lszfs Ar filesystem +A ZFS extended command that can be used to explore the ZFS filesystem +hierarchy in a pool. +Lists the immediate children of the +.Ar filesystem . +The filesystem hierarchy is rooted at a filesystem with the same name +as the pool. +.El +.Sh FILES +.Bl -tag -width /boot/zfsloader -compact +.It Pa /boot/zfsloader +.Nm +itself. +.El +.Sh EXAMPLES +Set the default device used for loading a kernel from a ZFS filesystem: +.Pp +.Bd -literal -offset indent +set currdev=zfs:tank/ROOT/knowngood: +.Ed +.Pp +.Sh SEE ALSO +.Xr gptzfsboot 8 , +.Xr loader 8 , +.Xr zfs 8 , +.Xr zfsboot 8 , +.Xr zfsloader 8 , +.Xr zpool 8 +.Sh HISTORY +The +.Nm +first appeared in +.Fx 7.3 . +.Sh AUTHORS +This manual page was written by +.An Andriy Gapon Aq avg@FreeBSD.org . diff --git a/sys/boot/efi/include/eficonsctl.h b/sys/boot/efi/include/eficonsctl.h new file mode 100644 index 000000000000..36dd2c1aceec --- /dev/null +++ b/sys/boot/efi/include/eficonsctl.h @@ -0,0 +1,134 @@ +/*- + * Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +/* + * Original Module Name: ConsoleControl.h + * Abstract: Abstraction of a Text mode or GOP/UGA screen + */ + +/* $FreeBSD$ */ + +#ifndef _EFI_CONS_CTL_H +#define _EFI_CONS_CTL_H + +#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \ + { 0xf42f7782, 0x12e, 0x4c12, {0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21} } + +typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL; + + +typedef enum { + EfiConsoleControlScreenText, + EfiConsoleControlScreenGraphics, + EfiConsoleControlScreenMaxValue +} EFI_CONSOLE_CONTROL_SCREEN_MODE; + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) ( + IN EFI_CONSOLE_CONTROL_PROTOCOL *This, + OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode, + OUT BOOLEAN *GopUgaExists, OPTIONAL + OUT BOOLEAN *StdInLocked OPTIONAL + ) +/*++ + + Routine Description: + Return the current video mode information. Also returns info about existence + of Graphics Output devices or UGA Draw devices in system, and if the Std In + device is locked. All the arguments are optional and only returned if a non + NULL pointer is passed in. + + Arguments: + This - Protocol instance pointer. + Mode - Are we in text of grahics mode. + GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device + StdInLocked - TRUE if StdIn device is keyboard locked + + Returns: + EFI_SUCCESS - Mode information returned. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) ( + IN EFI_CONSOLE_CONTROL_PROTOCOL *This, + IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode + ) +/*++ + + Routine Description: + Set the current mode to either text or graphics. Graphics is + for Quiet Boot. + + Arguments: + This - Protocol instance pointer. + Mode - Mode to set the + + Returns: + EFI_SUCCESS - Mode information returned. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) ( + IN EFI_CONSOLE_CONTROL_PROTOCOL *This, + IN CHAR16 *Password + ) +/*++ + + Routine Description: + Lock Std In devices until Password is typed. + + Arguments: + This - Protocol instance pointer. + Password - Password needed to unlock screen. NULL means unlock keyboard + + Returns: + EFI_SUCCESS - Mode information returned. + EFI_DEVICE_ERROR - Std In not locked + +--*/ +; + + + +struct _EFI_CONSOLE_CONTROL_PROTOCOL { + EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode; + EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode; + EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn; +}; + +extern EFI_GUID gEfiConsoleControlProtocolGuid; + +#endif diff --git a/sys/boot/efi/libefi/Makefile b/sys/boot/efi/libefi/Makefile index 60cb43f02744..3edeb22ea5a7 100644 --- a/sys/boot/efi/libefi/Makefile +++ b/sys/boot/efi/libefi/Makefile @@ -5,6 +5,8 @@ INTERNALLIB= SRCS= delay.c efi_console.c efinet.c efipart.c errno.c handles.c \ libefi.c time.c +.PATH: ${.CURDIR}/../../i386/libi386 +SRCS+= nullconsole.c comconsole.c .if ${MACHINE_ARCH} == "amd64" CFLAGS+= -fPIC @@ -16,6 +18,8 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand # Pick up the bootstrap header for some interface items CFLAGS+= -I${.CURDIR}/../../common +CFLAGS+= -DNO_PCI + # Suppress warning from clang for FreeBSD %b and %D formats CFLAGS+= -fformat-extensions diff --git a/sys/boot/efi/libefi/libefi.c b/sys/boot/efi/libefi/libefi.c index 45a48dc0c627..c6c01d39dc6d 100644 --- a/sys/boot/efi/libefi/libefi.c +++ b/sys/boot/efi/libefi/libefi.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -82,6 +83,9 @@ void efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) { static EFI_GUID image_protocol = LOADED_IMAGE_PROTOCOL; + static EFI_GUID console_control_protocol = + EFI_CONSOLE_CONTROL_PROTOCOL_GUID; + EFI_CONSOLE_CONTROL_PROTOCOL *console_control = NULL; EFI_LOADED_IMAGE *img; CHAR16 *argp, *args, **argv; EFI_STATUS status; @@ -92,6 +96,12 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) BS = ST->BootServices; RS = ST->RuntimeServices; + status = BS->LocateProtocol(&console_control_protocol, NULL, + (VOID **)&console_control); + if (status == EFI_SUCCESS) + (void)console_control->SetMode(console_control, + EfiConsoleControlScreenText); + heapsize = 2 * 1024 * 1024; status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, EFI_SIZE_TO_PAGES(heapsize), &heap); diff --git a/sys/boot/fdt/dts/arm/socfpga-sockit.dts b/sys/boot/fdt/dts/arm/socfpga-sockit.dts index 1cd90eaa87a6..d76b6cf2b3bd 100644 --- a/sys/boot/fdt/dts/arm/socfpga-sockit.dts +++ b/sys/boot/fdt/dts/arm/socfpga-sockit.dts @@ -51,6 +51,10 @@ usb1: usb@ffb40000 { status = "okay"; }; + + gmac1: ethernet@ff702000 { + status = "okay"; + }; }; chosen { diff --git a/sys/boot/fdt/dts/arm/socfpga.dtsi b/sys/boot/fdt/dts/arm/socfpga.dtsi index 8bdcda22412a..2480484692e1 100644 --- a/sys/boot/fdt/dts/arm/socfpga.dtsi +++ b/sys/boot/fdt/dts/arm/socfpga.dtsi @@ -39,6 +39,8 @@ aliases { soc = &SOC; + rstmgr = &rstmgr; + l3regs = &l3regs; serial0 = &serial0; serial1 = &serial1; }; @@ -69,6 +71,29 @@ interrupt-parent = < &GIC >; }; + sysmgr: sysmgr@ffd08000 { + compatible = "altr,sys-mgr"; + reg = <0xffd08000 0x1000>; + }; + + rstmgr: rstmgr@ffd05000 { + compatible = "altr,rst-mgr"; + reg = <0xffd05000 0x1000>; + }; + + l3regs: l3regs@ff800000 { + compatible = "altr,l3regs"; + reg = <0xff800000 0x1000>; + }; + + fpgamgr: fpgamgr@ff706000 { + compatible = "altr,fpga-mgr"; + reg = <0xff706000 0x1000>, /* FPGAMGRREGS */ + <0xffb90000 0x1000>; /* FPGAMGRDATA */ + interrupts = < 207 >; + interrupt-parent = <&GIC>; + }; + serial0: serial@ffc02000 { compatible = "ns16550"; reg = <0xffc02000 0x1000>; @@ -107,5 +132,25 @@ dr_mode = "host"; status = "disabled"; }; + + gmac0: ethernet@ff700000 { + compatible = "altr,socfpga-stmmac", + "snps,dwmac-3.70a", "snps,dwmac"; + reg = <0xff700000 0x2000>; + interrupts = <147>; + interrupt-parent = <&GIC>; + phy-mode = "rgmii"; + status = "disabled"; + }; + + gmac1: ethernet@ff702000 { + compatible = "altr,socfpga-stmmac", + "snps,dwmac-3.70a", "snps,dwmac"; + reg = <0xff702000 0x2000>; + interrupts = <152>; + interrupt-parent = <&GIC>; + phy-mode = "rgmii"; + status = "disabled"; + }; }; }; diff --git a/sys/boot/ficl/loader.c b/sys/boot/ficl/loader.c index 349a7c66d1ca..6641438c234e 100644 --- a/sys/boot/ficl/loader.c +++ b/sys/boot/ficl/loader.c @@ -727,6 +727,142 @@ static void fkey(FICL_VM *pVM) return; } + +#ifdef __i386__ +/* + * pcibios-device-count (devid -- count) + * + * Returns the PCI BIOS' count of how many devices matching devid are in the system. + * devid is the 32-bit vendor + device. + */ +static void +ficlPciBiosCountDevices(FICL_VM *pVM) +{ + uint32_t devid; + int i; + + devid = stackPopINT(pVM->pStack); + + i = biospci_count_device_type(devid); + + stackPushINT(pVM->pStack, i); +} + +/* + * pcibios-write-config (locator offset width value -- ) + * + * Writes the specified config register. + * Locator is bus << 8 | device << 3 | fuction + * offset is the pci config register + * width is 0 for byte, 1 for word, 2 for dword + * value is the value to write + */ +static void +ficlPciBiosWriteConfig(FICL_VM *pVM) +{ + uint32_t value, width, offset, locator; + + value = stackPopINT(pVM->pStack); + width = stackPopINT(pVM->pStack); + offset = stackPopINT(pVM->pStack); + locator = stackPopINT(pVM->pStack); + + biospci_write_config(locator, offset, width, value); +} + +/* + * pcibios-read-config (locator offset width -- value) + * + * Reads the specified config register. + * Locator is bus << 8 | device << 3 | fuction + * offset is the pci config register + * width is 0 for byte, 1 for word, 2 for dword + * value is the value to read from the register + */ +static void +ficlPciBiosReadConfig(FICL_VM *pVM) +{ + uint32_t value, width, offset, locator; + + width = stackPopINT(pVM->pStack); + offset = stackPopINT(pVM->pStack); + locator = stackPopINT(pVM->pStack); + + biospci_read_config(locator, offset, width, &value); + + stackPushINT(pVM->pStack, value); +} + +/* + * pcibios-find-devclass (class index -- locator) + * + * Finds the index'th instance of class in the pci tree. + * must be an exact match. + * class is the class to search for. + * index 0..N (set to 0, increment until error) + * + * Locator is bus << 8 | device << 3 | fuction (or -1 on error) + */ +static void +ficlPciBiosFindDevclass(FICL_VM *pVM) +{ + uint32_t index, class, locator; + + index = stackPopINT(pVM->pStack); + class = stackPopINT(pVM->pStack); + + if (biospci_find_devclass(class, index, &locator)) + locator = 0xffffffff; + + stackPushINT(pVM->pStack, locator); +} + +/* + * pcibios-find-device(devid index -- locator) + * + * Finds the index'th instance of devid in the pci tree. + * must be an exact match. + * class is the class to search for. + * index 0..N (set to 0, increment until error) + * + * Locator is bus << 8 | device << 3 | fuction (or -1 on error) + */ +static void +ficlPciBiosFindDevice(FICL_VM *pVM) +{ + uint32_t index, devid, locator; + + index = stackPopINT(pVM->pStack); + devid = stackPopINT(pVM->pStack); + + if (biospci_find_device(devid, index, &locator)) + locator = 0xffffffff; + + stackPushINT(pVM->pStack, locator); +} + +/* + * pcibios-find-device(bus device function -- locator) + * + * converts bus, device, function to locator. + * + * Locator is bus << 8 | device << 3 | fuction + */ +static void +ficlPciBiosLocator(FICL_VM *pVM) +{ + uint32_t bus, device, function, locator; + + function = stackPopINT(pVM->pStack); + device = stackPopINT(pVM->pStack); + bus = stackPopINT(pVM->pStack); + + locator = biospci_locator(bus, device, function); + + stackPushINT(pVM->pStack, locator); +} +#endif + /* ** Retrieves free space remaining on the dictionary */ @@ -749,7 +885,6 @@ static void ficlDictIncrease(FICL_VM *pVM) stackPushPtr(pVM->pStack, &dictIncrease); } - /************************************************************************** f i c l C o m p i l e P l a t f o r m ** Build FreeBSD platform extensions into the system dictionary @@ -795,6 +930,14 @@ void ficlCompilePlatform(FICL_SYSTEM *pSys) dictAppendWord(dp, "pnphandlers",ficlPnphandlers, FW_DEFAULT); #endif #endif +#ifdef __i386__ + dictAppendWord(dp, "pcibios-device-count", ficlPciBiosCountDevices, FW_DEFAULT); + dictAppendWord(dp, "pcibios-read-config", ficlPciBiosReadConfig, FW_DEFAULT); + dictAppendWord(dp, "pcibios-write-config", ficlPciBiosWriteConfig, FW_DEFAULT); + dictAppendWord(dp, "pcibios-find-devclass", ficlPciBiosFindDevclass, FW_DEFAULT); + dictAppendWord(dp, "pcibios-find-device", ficlPciBiosFindDevice, FW_DEFAULT); + dictAppendWord(dp, "pcibios-locator", ficlPciBiosLocator, FW_DEFAULT); +#endif #if defined(PC98) ficlSetEnv(pSys, "arch-pc98", FICL_TRUE); @@ -808,4 +951,3 @@ void ficlCompilePlatform(FICL_SYSTEM *pSys) return; } - diff --git a/sys/boot/forth/pcibios.4th b/sys/boot/forth/pcibios.4th new file mode 100644 index 000000000000..392d236e5471 --- /dev/null +++ b/sys/boot/forth/pcibios.4th @@ -0,0 +1,47 @@ +\ Copyright (c) 2014 M. Warner Losh +\ All rights reserved. +\ +\ Redistribution and use in source and binary forms, with or without +\ modification, are permitted provided that 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$ + +only forth also support-functions also builtins definitions + +\ pci-device-count pci-id +\ +\ Counts the number of instances of pci-id in the system and reports +\ it to the user. +: pci-device-count + 0= if ( interpreted ) get_arguments then + + 0= if ." Need an argument" cr abort then + \ First argument is 0 when we're interprated. See support.4th + \ for get_arguments reading the rest of the line and parsing it + \ stack: argN lenN ... arg1 len1 N + hex ?number decimal + 0= if ." Bad pci-id given (must be legal hex value)" cr abort then + dup pcibios-device-count ." Found " . ." instances of " hex . decimal cr +; + +also forth definitions also builtins + +builtin: pci-device-count diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index fa8c29d33a88..40413e9477d4 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -37,7 +37,7 @@ CFLAGS= -Os \ -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ - -Winline \ + -Winline CFLAGS.gcc+= -fno-guess-branch-probability \ -fno-unit-at-a-time \ diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile index a9d6ac891f10..6fdf014a2184 100644 --- a/sys/boot/i386/gptzfsboot/Makefile +++ b/sys/boot/i386/gptzfsboot/Makefile @@ -5,6 +5,7 @@ ${.CURDIR}/../../common FILES= gptzfsboot +MAN= gptzfsboot.8 NM?= nm diff --git a/sys/boot/i386/gptzfsboot/gptzfsboot.8 b/sys/boot/i386/gptzfsboot/gptzfsboot.8 new file mode 100644 index 000000000000..400c8c6128fe --- /dev/null +++ b/sys/boot/i386/gptzfsboot/gptzfsboot.8 @@ -0,0 +1,193 @@ +.\" Copyright (c) 2014 Andriy Gapon +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that 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 AUTHORS 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 AUTHORS 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 September 15, 2014 +.Dt GPTZFSBOOT 8 +.Os +.Sh NAME +.Nm gptzfsboot +.Nd GPT bootcode for ZFS on BIOS-based computers +.Sh DESCRIPTION +.Nm +is used on BIOS-based computers to boot from a filesystem in +a ZFS pool. +.Nm +is installed in a +.Cm freebsd-boot +partition of a GPT-partitioned disk with +.Xr gpart 8 . +.Sh IMPLEMENTATION NOTES +The GPT standard allows a variable number of partitions, but +.Nm +only boots from tables with 128 partitions or less. +.Sh BOOTING +.Nm +tries to find all ZFS pools that are composed of BIOS-visible +hard disks or partitions on them. +.Nm +looks for ZFS device labels on all visible disks and in discovered +supported partitions for all supported partition scheme types. +The search starts with the disk from which +.Nm +itself was loaded. +Other disks are probed in BIOS defined order. +After a disk is probed and +.Nm +determines that the whole disk is not a ZFS pool member, then +individual partitions are probed in their partition table order. +Currently GPT and MBR partition schemes are supported. +With the GPT scheme, only partitions of type +.Cm freebsd-zfs +are probed. +The first pool seen during probing is used as a default boot pool. +.Pp +The filesystem specified by the +.Cm bootfs +property of the pool is used as a default boot filesystem. +If the +.Cm bootfs +property is not set, then the root filesystem of the pool is used as +the default. +.Xr zfsloader 8 +is loaded from the boot filesystem. +If +.Pa /boot.config +or +.Pa /boot/config +is present in the boot filesystem, boot options are read from it +in the same way as +.Xr boot 8 . +.Pp +The ZFS GUIDs of the first successfully probed device and the first +detected pool are made available to +.Xr zfsloader 8 +in the +.Cm vfs.zfs.boot.primary_vdev +and +.Cm vfs.zfs.boot.primary_pool +variables. +.Sh USAGE +Normally +.Nm +will boot in fully automatic mode. +However, like +.Xr boot 8 , +it is possible to interrupt the automatic boot process and interact with +.Nm +through a prompt. +.Nm +accepts all the options that +.Xr boot 8 +supports. +.Pp +Filesystem specification and the path to +.Xr zfsloader 8 +is different from +.Xr boot 8 . +The format is +.Pp +.Sm off +.Oo zfs:pool/filesystem: Oc Oo /path/to/loader Oc +.Sm on +.Pp +Both the filesystem and the path can be specified. +If only a path is specified, then the default filesystem is used. +If only a pool and filesystem are specified, then +.Pa /boot/zfsloader +is used as a path. +.Pp +Additionally, the +.Ic status +command can be used to query information about discovered pools. +The output format is similar to that of +.Cm zpool status +.Pq see Xr zpool 8 . +.Pp +The configured or automatically determined ZFS boot filesystem is +stored in the +.Xr zfsloader 8 +.Cm loaddev +variable, and also set as the initial value of the +.Cm currdev +variable. +.Sh FILES +.Bl -tag -width /boot/gptzfsboot -compact +.It Pa /boot/gptzfsboot +boot code binary +.It Pa /boot.config +parameters for the boot block +.Pq optional +.It Pa /boot/config +alternative parameters for the boot block +.Pq optional +.El +.Sh EXAMPLES +.Nm +is typically installed in combination with a +.Dq protective MBR +.Po +see +.Xr gpart 8 +.Pc . +To install +.Nm +on the +.Pa ada0 +drive: +.Bd -literal -offset indent +gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0 +.Ed +.Pp +.Nm +can also be installed without the PMBR: +.Bd -literal -offset indent +gpart bootcode -p /boot/gptzfsboot -i 1 ada0 +.Ed +.Sh SEE ALSO +.Xr boot.config 5 , +.Xr boot 8 , +.Xr gpart 8 , +.Xr loader 8 , +.Xr zfsloader 8 , +.Xr zpool 8 +.Sh HISTORY +.Nm +appeared in FreeBSD 7.3. +.Sh BUGS +.Nm +looks for ZFS meta-data only in MBR partitions +.Pq known on FreeBSD as slices . +It does not look into BSD +.Xr disklabel 8 +partitions that are traditionally called partitions. +If a disklabel partition happens to be placed so that ZFS meta-data can be +found at the fixed offsets relative to a slice, then +.Nm +will recognize the partition as a part of a ZFS pool, +but this is not guaranteed to happen. +.Sh AUTHORS +This manual page was written by +.An Andriy Gapon Aq avg@FreeBSD.org . diff --git a/sys/boot/i386/libfirewire/fwohcireg.h b/sys/boot/i386/libfirewire/fwohcireg.h index d24f65858315..d57870cd626e 100644 --- a/sys/boot/i386/libfirewire/fwohcireg.h +++ b/sys/boot/i386/libfirewire/fwohcireg.h @@ -235,7 +235,7 @@ struct ohci_registers { fwohcireg_t config_rom; /* config ROM map 0x34 */ fwohcireg_t post_wr_lo; /* post write addr lo 0x38 */ fwohcireg_t post_wr_hi; /* post write addr hi 0x3c */ - fwohcireg_t vender; /* vender ID 0x40 */ + fwohcireg_t vendor; /* vendor ID 0x40 */ fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */ fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */ fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */ diff --git a/sys/boot/i386/libi386/biospci.c b/sys/boot/i386/libi386/biospci.c index ff4e86202c49..196590e1bf97 100644 --- a/sys/boot/i386/libi386/biospci.c +++ b/sys/boot/i386/libi386/biospci.c @@ -192,15 +192,69 @@ static struct pci_class static void biospci_enumerate(void); static void biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi); -static int biospci_version; -static int biospci_hwcap; - struct pnphandler biospcihandler = { "PCI BIOS", biospci_enumerate }; +#define PCI_BIOS_PRESENT 0xb101 +#define FIND_PCI_DEVICE 0xb102 +#define FIND_PCI_CLASS_CODE 0xb103 +#define GENERATE_SPECIAL_CYCLE 0xb106 +#define READ_CONFIG_BYTE 0xb108 +#define READ_CONFIG_WORD 0xb109 +#define READ_CONFIG_DWORD 0xb10a +#define WRITE_CONFIG_BYTE 0xb10b +#define WRITE_CONFIG_WORD 0xb10c +#define WRITE_CONFIG_DWORD 0xb10d +#define GET_IRQ_ROUTING_OPTIONS 0xb10e +#define SET_PCI_IRQ 0xb10f + +#define PCI_INT 0x1a + +#define PCI_SIGNATURE 0x20494350 /* AKA "PCI " */ + +void +biospci_detect(void) +{ + uint16_t version, hwcap, maxbus; + char buf[24]; + + /* Find the PCI BIOS */ + v86.ctl = V86_FLAGS; + v86.addr = PCI_INT; + v86.eax = PCI_BIOS_PRESENT; + v86.edi = 0x0; + v86int(); + + /* Check for OK response */ + if (V86_CY(v86.efl) || ((v86.eax & 0xff00) != 0) || + (v86.edx != PCI_SIGNATURE)) + return; + + version = v86.ebx & 0xffff; + hwcap = v86.eax & 0xff; + maxbus = v86.ecx & 0xff; +#if 0 + printf("PCI BIOS %d.%d%s%s maxbus %d\n", + bcd2bin((version >> 8) & 0xf), bcd2bin(version & 0xf), + (hwcap & 1) ? " config1" : "", (hwcap & 2) ? " config2" : "", + maxbus); +#endif + sprintf(buf, "%d", bcd2bin((version >> 8) & 0xf)); + setenv("pcibios.major", buf, 1); + sprintf(buf, "%d", bcd2bin(version & 0xf)); + setenv("pcibios.minor", buf, 1); + sprintf(buf, "%d", !!(hwcap & 1)); + setenv("pcibios.config1", buf, 1); + sprintf(buf, "%d", !!(hwcap & 2)); + setenv("pcibios.config2", buf, 1); + sprintf(buf, "%d", maxbus); + setenv("pcibios.maxbus", buf, 1); + +} + static void biospci_enumerate(void) { @@ -210,25 +264,6 @@ biospci_enumerate(void) struct pci_subclass *psc; struct pci_progif *ppi; - /* Find the PCI BIOS */ - v86.ctl = V86_FLAGS; - v86.addr = 0x1a; - v86.eax = 0xb101; - v86.edi = 0x0; - v86int(); - - /* Check for OK response */ - if (V86_CY(v86.efl) || ((v86.eax & 0xff00) != 0) || - (v86.edx != 0x20494350)) - return; - - biospci_version = v86.ebx & 0xffff; - biospci_hwcap = v86.eax & 0xff; -#if 0 - printf("PCI BIOS %d.%d%s%s\n", - bcd2bin((biospci_version >> 8) & 0xf), bcd2bin(biospci_version & 0xf), - (biospci_hwcap & 1) ? " config1" : "", (biospci_hwcap & 2) ? " config2" : ""); -#endif /* Iterate over known classes */ for (pc = pci_classes; pc->pc_class >= 0; pc++) { /* Iterate over subclasses */ @@ -289,8 +324,8 @@ int biospci_find_devclass(uint32_t class, int index, uint32_t *locator) { v86.ctl = V86_FLAGS; - v86.addr = 0x1a; - v86.eax = 0xb103; + v86.addr = PCI_INT; + v86.eax = FIND_PCI_CLASS_CODE; v86.ecx = class; v86.esi = index; v86int(); @@ -302,6 +337,25 @@ biospci_find_devclass(uint32_t class, int index, uint32_t *locator) *locator = v86.ebx; return (0); } + +int +biospci_find_device(uint32_t devid, int index, uint32_t *locator) +{ + v86.ctl = V86_FLAGS; + v86.addr = PCI_INT; + v86.eax = FIND_PCI_DEVICE; + v86.edx = devid & 0xffff; /* EDX - Vendor ID */ + v86.ecx = (devid >> 16) & 0xffff; /* ECX - Device ID */ + v86.esi = index; + v86int(); + + /* error */ + if (V86_CY(v86.efl) || (v86.eax & 0xff00)) + return (-1); + + *locator = v86.ebx; + return (0); +} /* * Configuration space access methods. * width = 0(byte), 1(word) or 2(dword). @@ -310,8 +364,8 @@ int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val) { v86.ctl = V86_FLAGS; - v86.addr = 0x1a; - v86.eax = 0xb10b + width; + v86.addr = PCI_INT; + v86.eax = WRITE_CONFIG_BYTE + width; v86.ebx = locator; v86.edi = offset; v86.ecx = val; @@ -328,8 +382,8 @@ int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val) { v86.ctl = V86_FLAGS; - v86.addr = 0x1a; - v86.eax = 0xb108 + width; + v86.addr = PCI_INT; + v86.eax = READ_CONFIG_BYTE + width; v86.ebx = locator; v86.edi = offset; v86int(); @@ -348,3 +402,27 @@ biospci_locator(int8_t bus, uint8_t device, uint8_t function) return ((bus << 8) | ((device & 0x1f) << 3) | (function & 0x7)); } + +/* + * Counts the number of instances of devid we have in the system, as least as + * far as the PCI BIOS is able to tell. + */ +int +biospci_count_device_type(uint32_t devid) +{ + int i; + + for (i = 0; 1; i++) { + v86.ctl = V86_FLAGS; + v86.addr = PCI_INT; + v86.eax = FIND_PCI_DEVICE; + v86.edx = devid & 0xffff; /* EDX - Vendor ID */ + v86.ecx = (devid >> 16) & 0xffff; /* ECX - Device ID */ + v86.esi = i; + v86int(); + if (V86_CY(v86.efl) || (v86.eax & 0xff00)) + break; + + } + return i; +} diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c index 76a62401a9d2..bd2a2e864fa2 100644 --- a/sys/boot/i386/libi386/comconsole.c +++ b/sys/boot/i386/libi386/comconsole.c @@ -214,6 +214,9 @@ comc_port_set(struct env_var *ev, int flags, const void *value) static uint32_t comc_parse_pcidev(const char *string) { +#ifdef NO_PCI + return (0); +#else char *p, *p1; uint8_t bus, dev, func, bar; uint32_t locator; @@ -247,11 +250,15 @@ comc_parse_pcidev(const char *string) locator = (bar << 16) | biospci_locator(bus, dev, func); return (locator); +#endif } static int comc_pcidev_handle(uint32_t locator) { +#ifdef NO_PCI + return (CMD_ERROR); +#else char intbuf[64]; uint32_t port; @@ -275,6 +282,7 @@ comc_pcidev_handle(uint32_t locator) comc_locator = locator; return (CMD_OK); +#endif } static int diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h index 24d6f56b8d7f..3f6704fac020 100644 --- a/sys/boot/i386/libi386/libi386.h +++ b/sys/boot/i386/libi386/libi386.h @@ -103,7 +103,10 @@ extern vm_offset_t memtop_copyin; /* memtop less heap size for the cases */ extern uint32_t high_heap_size; /* extended memory region available */ extern vm_offset_t high_heap_base; /* for use as the heap */ +void biospci_detect(void); +int biospci_count_device_type(uint32_t devid); int biospci_find_devclass(uint32_t class, int index, uint32_t *locator); +int biospci_find_device(uint32_t devid, int index, uint32_t *locator); int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index 6d372dd3b961..b10399e79d5a 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -110,6 +110,7 @@ FILES+= loader.help loader.4th support.4th loader.conf FILES+= screen.4th frames.4th beastie.4th FILES+= brand.4th check-password.4th color.4th delay.4th FILES+= menu.4th menu-commands.4th menusets.4th shortcuts.4th version.4th +FILES+= pcibios.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index 13f93350127f..347916964564 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -183,6 +183,9 @@ main(void) /* detect SMBIOS for future reference */ smbios_detect(); + /* detect PCI BIOS for future reference */ + biospci_detect(); + printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile index f4da642fdad2..0c24c40fed86 100644 --- a/sys/boot/i386/zfsboot/Makefile +++ b/sys/boot/i386/zfsboot/Makefile @@ -3,6 +3,7 @@ .PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common FILES= zfsboot +MAN= zfsboot.8 NM?= nm diff --git a/sys/boot/i386/zfsboot/zfsboot.8 b/sys/boot/i386/zfsboot/zfsboot.8 new file mode 100644 index 000000000000..6450939de955 --- /dev/null +++ b/sys/boot/i386/zfsboot/zfsboot.8 @@ -0,0 +1,133 @@ +.\" Copyright (c) 2014 Andriy Gapon +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that 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 AUTHORS 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 AUTHORS 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 September 15, 2014 +.Dt ZFSBOOT 8 +.Os +.Sh NAME +.Nm zfsboot +.Nd bootcode for ZFS on BIOS-based computers +.Sh DESCRIPTION +.Nm +is used on BIOS-based computers to boot from a filesystem in +a ZFS pool. +.Nm +is installed in two parts on a disk or a partition used by a ZFS pool. +The first part, a single-sector starter boot block, is installed +at the beginning of the disk or partition. +The second part, a main boot block, is installed at a special offset +within the disk or partition. +Both areas are reserved by the ZFS on-disk specification for boot use. +If +.Nm +is installed in a partition, then that partition should be made +bootable using appropriate configuration and boot blocks described in +.Xr boot 8 . +.Sh BOOTING +The +.Nm +boot process is very similar to that of +.Xr gptzfsboot 8 . +One significant difference is that +.Nm +does not currently support the GPT partitioning scheme. +Thus only whole disks and MBR partitions, traditionally referred to as +slices, are probed for ZFS disk labels. +See the BUGS section in +.Xr gptzfsboot 8 +for some limitations of the MBR scheme support. +.Sh USAGE +.Nm +supports all the same prompt and configuration file arguments as +.Xr gptzfsboot 8 . +.Sh FILES +.Bl -tag -width /boot/zfsboot -compact +.It Pa /boot/zfsboot +boot code binary +.It Pa /boot.config +parameters for the boot block +.Pq optional +.It Pa /boot/config +alternative parameters for the boot block +.Pq optional +.El +.Sh EXAMPLES +.Nm +is typically installed using +.Xr dd 1 . +To install +.Nm +on the +.Pa ada0 +drive: +.Bd -literal -offset indent +dd if=/boot/zfsboot of=/dev/ada0 count=1 +dd if=/boot/zfsboot of=/dev/ada0 iseek=1 oseek=1024 +.Ed +.Pp +If the drive is currently in use, the GEOM safety will prevent writes +and must be disabled before running the above commands: +.Bd -literal -offset indent +sysctl kern.geom.debugflags=0x10 +.Ed +.Pp +.Nm +can also be installed in an MBR slice: +.Bd -literal -offset indent +gpart create -s mbr ada0 +gpart add -t freebsd ada0 +gpart create -s BSD ada0s1 +gpart bootcode -b /boot/boot0 ada0 +gpart set -a active -i 1 ada0 +dd if=/boot/zfsboot of=/dev/ada0s1 count=1 +dd if=/boot/zfsboot of=/dev/ada0s1 iseek=1 oseek=1024 +.Ed +.Pp +Note that commands to create and populate a pool are not shown +in the example above. +.Sh SEE ALSO +.Xr dd 1 , +.Xr boot.config 5 , +.Xr boot 8 , +.Xr gptzfsboot 8 , +.Xr loader 8 , +.Xr zfsloader 8 , +.Xr zpool 8 +.Sh HISTORY +.Nm +appeared in FreeBSD 7.3. +.Sh AUTHORS +This manual page was written by +.An Andriy Gapon Aq avg@FreeBSD.org . +.Sh BUGS +Installing +.Nm +with +.Xr dd 1 +is a hack. +ZFS needs a command to properly install +.Nm +onto a ZFS-controlled disk or partition. diff --git a/sys/boot/libstand32/Makefile b/sys/boot/libstand32/Makefile index 39c8e4003d58..437fa3bbe4d2 100644 --- a/sys/boot/libstand32/Makefile +++ b/sys/boot/libstand32/Makefile @@ -67,9 +67,6 @@ SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ .if ${MACHINE_CPUARCH} == "arm" .PATH: ${LIBC}/arm/gen -.if ${MK_ARM_EABI} == "no" -SRCS+= divsi3.S -.else # Compiler support functions .PATH: ${.CURDIR}/../../../contrib/compiler-rt/lib/ # __clzsi2 and ctzsi2 for various builtin functions @@ -81,7 +78,6 @@ SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c .PATH: ${.CURDIR}/../../../contrib/compiler-rt/lib/arm/ SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S -.endif .endif .if ${MACHINE_CPUARCH} == "powerpc" diff --git a/sys/boot/pc98/boot2/Makefile b/sys/boot/pc98/boot2/Makefile index f462717fee99..0b744aa83a30 100644 --- a/sys/boot/pc98/boot2/Makefile +++ b/sys/boot/pc98/boot2/Makefile @@ -2,10 +2,6 @@ .include -# XXX: clang can compile the boot code just fine, but boot2 gets too big -#CC:= gcc -#COMPILER_TYPE:= gcc - FILES= boot boot1 boot2 NM?= nm @@ -114,4 +110,5 @@ boot2.h: boot1.out .include # XXX: clang integrated-as doesn't grok .codeNN directives yet -CFLAGS+= ${CLANG_NO_IAS} +CFLAGS.boot1.S= ${CLANG_NO_IAS} +CFLAGS+= ${CFLAGS.${.IMPSRC:T}} diff --git a/sys/boot/pc98/cdboot/cdboot.S b/sys/boot/pc98/cdboot/cdboot.S index ae333d1d7ef3..c97c02bea31b 100644 --- a/sys/boot/pc98/cdboot/cdboot.S +++ b/sys/boot/pc98/cdboot/cdboot.S @@ -11,9 +11,6 @@ # 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. Neither the name of the author nor the names of any co-contributors -# may 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 diff --git a/sys/boot/pc98/libpc98/Makefile b/sys/boot/pc98/libpc98/Makefile index b4433a474d76..e612205de46c 100644 --- a/sys/boot/pc98/libpc98/Makefile +++ b/sys/boot/pc98/libpc98/Makefile @@ -44,4 +44,7 @@ CFLAGS+= -I${.CURDIR}/../../common \ # the location of libstand CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ +# Suppress warning from clang for FreeBSD %b and %D formats +CFLAGS+= -fformat-extensions + .include diff --git a/sys/boot/pc98/loader/Makefile b/sys/boot/pc98/loader/Makefile index 7ab13a189dd3..4d865e7703ec 100644 --- a/sys/boot/pc98/loader/Makefile +++ b/sys/boot/pc98/loader/Makefile @@ -56,6 +56,8 @@ LDFLAGS= -static -Ttext 0x0 LIBPC98= ${.OBJDIR}/../libpc98/libpc98.a CFLAGS+= -I${.CURDIR}/.. +LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a + # BTX components CFLAGS+= -I${.CURDIR}/../btx/lib diff --git a/sys/boot/uboot/common/main.c b/sys/boot/uboot/common/main.c index 288a02d14ce8..ae77766d1a8b 100644 --- a/sys/boot/uboot/common/main.c +++ b/sys/boot/uboot/common/main.c @@ -556,6 +556,75 @@ command_sysinfo(int argc, char *argv[]) return (CMD_OK); } +enum ubenv_action { + UBENV_UNKNOWN, + UBENV_SHOW, + UBENV_IMPORT +}; + +static void +handle_uboot_env_var(enum ubenv_action action, const char * var) +{ + const char * val; + char ubv[128]; + + /* + * If the user prepended "uboot." (which is how they usually see these + * names) strip it off as a convenience. + */ + if (strncmp(var, "uboot.", 6) == 0) { + snprintf(ubv, sizeof(ubv), "%s", &var[6]); + var = ubv; + } + val = ub_env_get(var); + if (action == UBENV_SHOW) { + if (val == NULL) + printf("uboot.%s is not set\n", var); + else + printf("uboot.%s=%s\n", var, val); + } else if (action == UBENV_IMPORT) { + if (val != NULL) { + snprintf(ubv, sizeof(ubv), "uboot.%s", var); + setenv(ubv, val, 1); + } + } +} + +static int +command_ubenv(int argc, char *argv[]) +{ + enum ubenv_action action; + const char *var; + int i; + + action = UBENV_UNKNOWN; + if (argc > 1) { + if (strcasecmp(argv[1], "import") == 0) + action = UBENV_IMPORT; + else if (strcasecmp(argv[1], "show") == 0) + action = UBENV_SHOW; + } + if (action == UBENV_UNKNOWN) { + command_errmsg = "usage: 'ubenv [var ...]"; + return (CMD_ERROR); + } + + if (argc > 2) { + for (i = 2; i < argc; i++) + handle_uboot_env_var(action, argv[i]); + } else { + var = NULL; + for (;;) { + if ((var = ub_env_enum(var)) == NULL) + break; + handle_uboot_env_var(action, var); + } + } + + return (CMD_OK); +} +COMMAND_SET(ubenv, "ubenv", "show or import U-Boot env vars", command_ubenv); + #ifdef LOADER_FDT_SUPPORT /* * Since proper fdt command handling function is defined in fdt_loader_cmd.c, diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h index 87553c629380..7ee7d79bd352 100644 --- a/sys/cam/cam_ccb.h +++ b/sys/cam/cam_ccb.h @@ -347,8 +347,8 @@ struct ccb_getdevstats { struct ccb_hdr ccb_h; int dev_openings; /* Space left for more work on device*/ int dev_active; /* Transactions running on the device */ - int devq_openings; /* Space left for more queued work */ - int devq_queued; /* Transactions queued to be sent */ + int allocated; /* CCBs allocated for the device */ + int queued; /* CCBs queued to be sent to the device */ int held; /* * CCBs held by peripheral drivers * for this device diff --git a/sys/cam/cam_queue.c b/sys/cam/cam_queue.c index f6624f30f068..b67f687c0c22 100644 --- a/sys/cam/cam_queue.c +++ b/sys/cam/cam_queue.c @@ -290,7 +290,6 @@ cam_ccbq_resize(struct cam_ccbq *ccbq, int new_size) delta = new_size - (ccbq->dev_active + ccbq->dev_openings); ccbq->total_openings += delta; - ccbq->devq_openings += delta; ccbq->dev_openings += delta; new_size = imax(64, 1 << fls(new_size + new_size / 2)); @@ -308,7 +307,6 @@ cam_ccbq_init(struct cam_ccbq *ccbq, int openings) imax(64, 1 << fls(openings + openings / 2))) != 0) return (1); ccbq->total_openings = openings; - ccbq->devq_openings = openings; ccbq->dev_openings = openings; return (0); } diff --git a/sys/cam/cam_queue.h b/sys/cam/cam_queue.h index 0f74e8241a40..33f6b1d979fc 100644 --- a/sys/cam/cam_queue.h +++ b/sys/cam/cam_queue.h @@ -62,10 +62,9 @@ struct cam_ccbq { struct ccb_hdr_tailq queue_extra_head; int queue_extra_entries; int total_openings; - int devq_openings; + int allocated; int dev_openings; int dev_active; - int held; }; struct cam_ed; @@ -188,8 +187,8 @@ cam_ccbq_pending_ccb_count(struct cam_ccbq *ccbq) static __inline void cam_ccbq_take_opening(struct cam_ccbq *ccbq) { - ccbq->devq_openings--; - ccbq->held++; + + ccbq->allocated++; } static __inline void @@ -198,8 +197,6 @@ cam_ccbq_insert_ccb(struct cam_ccbq *ccbq, union ccb *new_ccb) struct ccb_hdr *old_ccb; struct camq *queue = &ccbq->queue; - ccbq->held--; - /* * If queue is already full, try to resize. * If resize fail, push CCB with lowest priority out to the TAILQ. @@ -264,7 +261,7 @@ cam_ccbq_send_ccb(struct cam_ccbq *ccbq, union ccb *send_ccb) send_ccb->ccb_h.pinfo.index = CAM_ACTIVE_INDEX; ccbq->dev_active++; - ccbq->dev_openings--; + ccbq->dev_openings--; } static __inline void @@ -272,15 +269,14 @@ cam_ccbq_ccb_done(struct cam_ccbq *ccbq, union ccb *done_ccb) { ccbq->dev_active--; - ccbq->dev_openings++; - ccbq->held++; + ccbq->dev_openings++; } static __inline void cam_ccbq_release_opening(struct cam_ccbq *ccbq) { - ccbq->held--; - ccbq->devq_openings++; + + ccbq->allocated--; } #endif /* _KERNEL */ diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 4a8f14b0f732..3cba1b0e676e 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -2648,20 +2648,25 @@ xpt_action_default(union ccb *start_ccb) struct ccb_getdevstats *cgds; struct cam_eb *bus; struct cam_et *tar; + struct cam_devq *devq; cgds = &start_ccb->cgds; bus = path->bus; tar = path->target; + devq = bus->sim->devq; + mtx_lock(&devq->send_mtx); cgds->dev_openings = dev->ccbq.dev_openings; cgds->dev_active = dev->ccbq.dev_active; - cgds->devq_openings = dev->ccbq.devq_openings; - cgds->devq_queued = cam_ccbq_pending_ccb_count(&dev->ccbq); - cgds->held = dev->ccbq.held; + cgds->allocated = dev->ccbq.allocated; + cgds->queued = cam_ccbq_pending_ccb_count(&dev->ccbq); + cgds->held = cgds->allocated - cgds->dev_active - + cgds->queued; 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; + mtx_unlock(&devq->send_mtx); cgds->ccb_h.status = CAM_REQ_CMP; } break; @@ -3004,7 +3009,6 @@ xpt_polled_action(union ccb *start_ccb) * can get it before us while we simulate interrupts. */ mtx_lock(&devq->send_mtx); - dev->ccbq.devq_openings--; dev->ccbq.dev_openings--; while((devq->send_openings <= 0 || dev->ccbq.dev_openings < 0) && (--timeout > 0)) { @@ -3016,7 +3020,6 @@ xpt_polled_action(union ccb *start_ccb) camisr_runqueue(); mtx_lock(&devq->send_mtx); } - dev->ccbq.devq_openings++; dev->ccbq.dev_openings++; mtx_unlock(&devq->send_mtx); @@ -3049,7 +3052,7 @@ xpt_polled_action(union ccb *start_ccb) } /* - * Schedule a peripheral driver to receive a ccb when it's + * Schedule a peripheral driver to receive a ccb when its * target device has space for more transactions. */ void diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 147441ca076f..3627a503c433 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -263,7 +263,7 @@ static struct scsi_caching_page caching_page_default = { static struct scsi_caching_page caching_page_changeable = { /*page_code*/SMS_CACHING_PAGE, /*page_length*/sizeof(struct scsi_caching_page) - 2, - /*flags1*/ 0, + /*flags1*/ SCP_WCE | SCP_RCD, /*ret_priority*/ 0, /*disable_pf_transfer_len*/ {0, 0}, /*min_prefetch*/ {0, 0}, @@ -280,7 +280,7 @@ static struct scsi_control_page control_page_default = { /*page_code*/SMS_CONTROL_MODE_PAGE, /*page_length*/sizeof(struct scsi_control_page) - 2, /*rlec*/0, - /*queue_flags*/0, + /*queue_flags*/SCP_QUEUE_ALG_RESTRICTED, /*eca_and_aen*/0, /*flags4*/SCP_TAS, /*aen_holdoff_period*/{0, 0}, @@ -292,7 +292,7 @@ static struct scsi_control_page control_page_changeable = { /*page_code*/SMS_CONTROL_MODE_PAGE, /*page_length*/sizeof(struct scsi_control_page) - 2, /*rlec*/SCP_DSENSE, - /*queue_flags*/0, + /*queue_flags*/SCP_QUEUE_ALG_MASK, /*eca_and_aen*/0, /*flags4*/0, /*aen_holdoff_period*/{0, 0}, @@ -320,10 +320,11 @@ SYSCTL_INT(_kern_cam_ctl, OID_AUTO, verbose, CTLFLAG_RWTUN, /* * Supported pages (0x00), Serial number (0x80), Device ID (0x83), + * Extended INQUIRY Data (0x86), Mode Page Policy (0x87), * SCSI Ports (0x88), Third-party Copy (0x8F), Block limits (0xB0), * Block Device Characteristics (0xB1) and Logical Block Provisioning (0xB2) */ -#define SCSI_EVPD_NUM_SUPPORTED_PAGES 8 +#define SCSI_EVPD_NUM_SUPPORTED_PAGES 10 static void ctl_isc_event_handler(ctl_ha_channel chanel, ctl_ha_event event, int param); @@ -379,6 +380,8 @@ static void ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg); static int ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len); +static int ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len); +static int ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, @@ -387,10 +390,10 @@ static int ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len); static int ctl_inquiry_evpd(struct ctl_scsiio *ctsio); static int ctl_inquiry_std(struct ctl_scsiio *ctsio); -static int ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint32_t *len); +static int ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint64_t *len); static ctl_action ctl_extent_check(union ctl_io *io1, union ctl_io *io2); -static ctl_action ctl_check_for_blockage(union ctl_io *pending_io, - union ctl_io *ooa_io); +static ctl_action ctl_check_for_blockage(struct ctl_lun *lun, + union ctl_io *pending_io, union ctl_io *ooa_io); static ctl_action ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io, union ctl_io *starting_io); static int ctl_check_blocked(struct ctl_lun *lun); @@ -437,7 +440,7 @@ static void ctl_enqueue_rtr(union ctl_io *io); static void ctl_enqueue_done(union ctl_io *io); static void ctl_enqueue_isc(union ctl_io *io); static const struct ctl_cmd_entry * - ctl_get_cmd_entry(struct ctl_scsiio *ctsio); + ctl_get_cmd_entry(struct ctl_scsiio *ctsio, int *sa); static const struct ctl_cmd_entry * ctl_validate_command(struct ctl_scsiio *ctsio); static int ctl_cmd_applicable(uint8_t lun_type, @@ -641,7 +644,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_event event, int param) if (ctl_softc->ha_mode == CTL_HA_MODE_XFER) { const struct ctl_cmd_entry *entry; - entry = ctl_get_cmd_entry(&io->scsiio); + entry = ctl_get_cmd_entry(&io->scsiio, NULL); io->io_hdr.flags &= ~CTL_FLAG_DATA_MASK; io->io_hdr.flags |= entry->flags & CTL_FLAG_DATA_MASK; @@ -2541,7 +2544,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, mtx_lock(&softc->ctl_lock); if (((ooa_hdr->flags & CTL_OOA_FLAG_ALL_LUNS) == 0) - && ((ooa_hdr->lun_num > CTL_MAX_LUNS) + && ((ooa_hdr->lun_num >= CTL_MAX_LUNS) || (softc->ctl_luns[ooa_hdr->lun_num] == NULL))) { mtx_unlock(&softc->ctl_lock); free(entries, M_CTL); @@ -2736,7 +2739,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, #ifdef CTL_IO_DELAY mtx_lock(&softc->ctl_lock); - if ((delay_info->lun_id > CTL_MAX_LUNS) + if ((delay_info->lun_id >= CTL_MAX_LUNS) || (softc->ctl_luns[delay_info->lun_id] == NULL)) { delay_info->status = CTL_DELAY_STATUS_INVALID_LUN; } else { @@ -2897,6 +2900,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, lun = softc->ctl_luns[err_desc->lun_id]; if (lun == NULL) { mtx_unlock(&softc->ctl_lock); + free(new_err_desc, M_CTL); printf("%s: CTL_ERROR_INJECT: invalid LUN %ju\n", __func__, (uintmax_t)err_desc->lun_id); retval = EINVAL; @@ -4091,6 +4095,7 @@ ctl_init_page_index(struct ctl_lun *lun) int i; struct ctl_page_index *page_index; struct ctl_softc *softc; + const char *value; memcpy(&lun->mode_pages.index, page_index_template, sizeof(page_index_template)); @@ -4240,52 +4245,61 @@ ctl_init_page_index(struct ctl_lun *lun) break; } case SMS_CACHING_PAGE: { + struct scsi_caching_page *caching_page; if (page_index->subpage != SMS_SUBPAGE_PAGE_0) panic("invalid subpage value %d", page_index->subpage); - /* - * Defaults should be okay here, no calculations - * needed. - */ - memcpy(&lun->mode_pages.caching_page[CTL_PAGE_CURRENT], + memcpy(&lun->mode_pages.caching_page[CTL_PAGE_DEFAULT], &caching_page_default, sizeof(caching_page_default)); memcpy(&lun->mode_pages.caching_page[ CTL_PAGE_CHANGEABLE], &caching_page_changeable, sizeof(caching_page_changeable)); - memcpy(&lun->mode_pages.caching_page[CTL_PAGE_DEFAULT], - &caching_page_default, - sizeof(caching_page_default)); memcpy(&lun->mode_pages.caching_page[CTL_PAGE_SAVED], &caching_page_default, sizeof(caching_page_default)); + caching_page = &lun->mode_pages.caching_page[ + CTL_PAGE_SAVED]; + value = ctl_get_opt(&lun->be_lun->options, "writecache"); + if (value != NULL && strcmp(value, "off") == 0) + caching_page->flags1 &= ~SCP_WCE; + value = ctl_get_opt(&lun->be_lun->options, "readcache"); + if (value != NULL && strcmp(value, "off") == 0) + caching_page->flags1 |= SCP_RCD; + memcpy(&lun->mode_pages.caching_page[CTL_PAGE_CURRENT], + &lun->mode_pages.caching_page[CTL_PAGE_SAVED], + sizeof(caching_page_default)); page_index->page_data = (uint8_t *)lun->mode_pages.caching_page; break; } case SMS_CONTROL_MODE_PAGE: { + struct scsi_control_page *control_page; if (page_index->subpage != SMS_SUBPAGE_PAGE_0) panic("invalid subpage value %d", page_index->subpage); - /* - * Defaults should be okay here, no calculations - * needed. - */ - memcpy(&lun->mode_pages.control_page[CTL_PAGE_CURRENT], + memcpy(&lun->mode_pages.control_page[CTL_PAGE_DEFAULT], &control_page_default, sizeof(control_page_default)); memcpy(&lun->mode_pages.control_page[ CTL_PAGE_CHANGEABLE], &control_page_changeable, sizeof(control_page_changeable)); - memcpy(&lun->mode_pages.control_page[CTL_PAGE_DEFAULT], - &control_page_default, - sizeof(control_page_default)); memcpy(&lun->mode_pages.control_page[CTL_PAGE_SAVED], &control_page_default, sizeof(control_page_default)); + control_page = &lun->mode_pages.control_page[ + CTL_PAGE_SAVED]; + value = ctl_get_opt(&lun->be_lun->options, "reordering"); + if (value != NULL && strcmp(value, "unrestricted") == 0) { + control_page->queue_flags &= ~SCP_QUEUE_ALG_MASK; + control_page->queue_flags |= SCP_QUEUE_ALG_UNRESTRICTED; + } + memcpy(&lun->mode_pages.control_page[CTL_PAGE_CURRENT], + &lun->mode_pages.control_page[CTL_PAGE_SAVED], + sizeof(control_page_default)); page_index->page_data = (uint8_t *)lun->mode_pages.control_page; break; @@ -5255,6 +5269,8 @@ ctl_data_submit_done(union ctl_io *io) void ctl_config_write_done(union ctl_io *io) { + uint8_t *buf; + /* * If the IO_CONT flag is set, we need to call the supplied * function to continue processing the I/O, instead of completing @@ -5263,9 +5279,10 @@ ctl_config_write_done(union ctl_io *io) * If there is an error, though, we don't want to keep processing. * Instead, just send status back to the initiator. */ - if ((io->io_hdr.flags & CTL_FLAG_IO_CONT) - && (((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE) - || ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS))) { + if ((io->io_hdr.flags & CTL_FLAG_IO_CONT) && + (io->io_hdr.flags & CTL_FLAG_ABORT) == 0 && + ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE || + (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) { io->scsiio.io_cont(io); return; } @@ -5274,9 +5291,13 @@ ctl_config_write_done(union ctl_io *io) * have data allocated, like write buffer, and commands that have * no data, like start/stop unit, we need to check here. */ - if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_OUT) - free(io->scsiio.kern_data_ptr, M_CTL); + if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) + buf = io->scsiio.kern_data_ptr; + else + buf = NULL; ctl_done(io); + if (buf) + free(buf, M_CTL); } /* @@ -5288,12 +5309,14 @@ ctl_scsi_release(struct ctl_scsiio *ctsio) int length, longid, thirdparty_id, resv_id; struct ctl_softc *ctl_softc; struct ctl_lun *lun; + uint32_t residx; length = 0; resv_id = 0; CTL_DEBUG_PRINT(("ctl_scsi_release\n")); + residx = ctl_get_resindex(&ctsio->io_hdr.nexus); lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; ctl_softc = control_softc; @@ -5351,14 +5374,8 @@ ctl_scsi_release(struct ctl_scsiio *ctsio) * released, though, by the initiator who made it or by one of * several reset type events. */ - if (lun->flags & CTL_LUN_RESERVED) { - if ((ctsio->io_hdr.nexus.initid.id == lun->rsv_nexus.initid.id) - && (ctsio->io_hdr.nexus.targ_port == lun->rsv_nexus.targ_port) - && (ctsio->io_hdr.nexus.targ_target.id == - lun->rsv_nexus.targ_target.id)) { + if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == residx)) lun->flags &= ~CTL_LUN_RESERVED; - } - } mtx_unlock(&lun->lun_lock); @@ -5382,6 +5399,7 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsio) uint64_t thirdparty_id; struct ctl_softc *ctl_softc; struct ctl_lun *lun; + uint32_t residx; extent = 0; thirdparty = 0; @@ -5392,6 +5410,7 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsio) CTL_DEBUG_PRINT(("ctl_reserve\n")); + residx = ctl_get_resindex(&ctsio->io_hdr.nexus); lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; ctl_softc = control_softc; @@ -5440,19 +5459,14 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsio) thirdparty_id = scsi_8btou64(ctsio->kern_data_ptr); mtx_lock(&lun->lun_lock); - if (lun->flags & CTL_LUN_RESERVED) { - if ((ctsio->io_hdr.nexus.initid.id != lun->rsv_nexus.initid.id) - || (ctsio->io_hdr.nexus.targ_port != lun->rsv_nexus.targ_port) - || (ctsio->io_hdr.nexus.targ_target.id != - lun->rsv_nexus.targ_target.id)) { - ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT; - ctsio->io_hdr.status = CTL_SCSI_ERROR; - goto bailout; - } + if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx != residx)) { + ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT; + ctsio->io_hdr.status = CTL_SCSI_ERROR; + goto bailout; } lun->flags |= CTL_LUN_RESERVED; - lun->rsv_nexus = ctsio->io_hdr.nexus; + lun->res_idx = residx; ctsio->scsi_status = SCSI_STATUS_OK; ctsio->io_hdr.status = CTL_SUCCESS; @@ -5973,6 +5987,15 @@ ctl_write_same(struct ctl_scsiio *ctsio) break; /* NOTREACHED */ } + /* NDOB and ANCHOR flags can be used only together with UNMAP */ + if ((byte2 & SWS_UNMAP) == 0 && + (byte2 & (SWS_NDOB | SWS_ANCHOR)) != 0) { + ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, + /*command*/ 1, /*field*/ 1, /*bit_valid*/ 1, /*bit*/ 0); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } + /* * The first check is to make sure we're in bounds, the second * check is to catch wrap-around problems. If the lba + num blocks @@ -6007,7 +6030,8 @@ ctl_write_same(struct ctl_scsiio *ctsio) * If we've got a kernel request that hasn't been malloced yet, * malloc it and tell the caller the data buffer is here. */ - if ((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) { + if ((byte2 & SWS_NDOB) == 0 && + (ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) { ctsio->kern_data_ptr = malloc(len, M_CTL, M_WAITOK);; ctsio->kern_data_len = len; ctsio->kern_total_len = len; @@ -6037,7 +6061,7 @@ ctl_unmap(struct ctl_scsiio *ctsio) struct scsi_unmap *cdb; struct ctl_ptr_len_flags *ptrlen; struct scsi_unmap_header *hdr; - struct scsi_unmap_desc *buf, *end; + struct scsi_unmap_desc *buf, *end, *endnz, *range; uint64_t lba; uint32_t num_blocks; int len, retval; @@ -6090,24 +6114,41 @@ ctl_unmap(struct ctl_scsiio *ctsio) buf = (struct scsi_unmap_desc *)(hdr + 1); end = buf + len / sizeof(*buf); - ptrlen = (struct ctl_ptr_len_flags *)&ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; - ptrlen->ptr = (void *)buf; - ptrlen->len = len; - ptrlen->flags = byte2; - - for (; buf < end; buf++) { - lba = scsi_8btou64(buf->lba); - num_blocks = scsi_4btoul(buf->length); + endnz = buf; + for (range = buf; range < end; range++) { + lba = scsi_8btou64(range->lba); + num_blocks = scsi_4btoul(range->length); if (((lba + num_blocks) > (lun->be_lun->maxlba + 1)) || ((lba + num_blocks) < lba)) { ctl_set_lba_out_of_range(ctsio); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } + if (num_blocks != 0) + endnz = range + 1; } - retval = lun->backend->config_write((union ctl_io *)ctsio); + /* + * Block backend can not handle zero last range. + * Filter it out and return if there is nothing left. + */ + len = (uint8_t *)endnz - (uint8_t *)buf; + if (len == 0) { + ctl_set_success(ctsio); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } + mtx_lock(&lun->lun_lock); + ptrlen = (struct ctl_ptr_len_flags *) + &ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; + ptrlen->ptr = (void *)buf; + ptrlen->len = len; + ptrlen->flags = byte2; + ctl_check_blocked(lun); + mtx_unlock(&lun->lun_lock); + + retval = lun->backend->config_write((union ctl_io *)ctsio); return (retval); } @@ -6170,65 +6211,61 @@ ctl_control_page_handler(struct ctl_scsiio *ctsio, lun->flags &= ~CTL_LUN_SENSE_DESC; set_ua = 1; } - if (current_cp->queue_flags & SCP_QUEUE_DQUE) { - if (user_cp->queue_flags & SCP_QUEUE_DQUE) { -#ifdef NEEDTOPORT - csevent_log(CSC_CTL | CSC_SHELF_SW | - CTL_UNTAG_TO_UNTAG, - csevent_LogType_Trace, - csevent_Severity_Information, - csevent_AlertLevel_Green, - csevent_FRU_Firmware, - csevent_FRU_Unknown, - "Received untagged to untagged transition"); -#endif /* NEEDTOPORT */ - } else { -#ifdef NEEDTOPORT - csevent_log(CSC_CTL | CSC_SHELF_SW | - CTL_UNTAG_TO_TAG, - csevent_LogType_ConfigChange, - csevent_Severity_Information, - csevent_AlertLevel_Green, - csevent_FRU_Firmware, - csevent_FRU_Unknown, - "Received untagged to tagged " - "queueing transition"); -#endif /* NEEDTOPORT */ + if ((current_cp->queue_flags & SCP_QUEUE_ALG_MASK) != + (user_cp->queue_flags & SCP_QUEUE_ALG_MASK)) { + current_cp->queue_flags &= ~SCP_QUEUE_ALG_MASK; + current_cp->queue_flags |= user_cp->queue_flags & SCP_QUEUE_ALG_MASK; + saved_cp->queue_flags &= ~SCP_QUEUE_ALG_MASK; + saved_cp->queue_flags |= user_cp->queue_flags & SCP_QUEUE_ALG_MASK; + set_ua = 1; + } + if (set_ua != 0) { + int i; + /* + * Let other initiators know that the mode + * parameters for this LUN have changed. + */ + for (i = 0; i < CTL_MAX_INITIATORS; i++) { + if (i == initidx) + continue; - current_cp->queue_flags &= ~SCP_QUEUE_DQUE; - saved_cp->queue_flags &= ~SCP_QUEUE_DQUE; - set_ua = 1; + lun->pending_ua[i] |= CTL_UA_MODE_CHANGE; } - } else { - if (user_cp->queue_flags & SCP_QUEUE_DQUE) { -#ifdef NEEDTOPORT - csevent_log(CSC_CTL | CSC_SHELF_SW | - CTL_TAG_TO_UNTAG, - csevent_LogType_ConfigChange, - csevent_Severity_Warning, - csevent_AlertLevel_Yellow, - csevent_FRU_Firmware, - csevent_FRU_Unknown, - "Received tagged queueing to untagged " - "transition"); -#endif /* NEEDTOPORT */ + } + mtx_unlock(&lun->lun_lock); - current_cp->queue_flags |= SCP_QUEUE_DQUE; - saved_cp->queue_flags |= SCP_QUEUE_DQUE; - set_ua = 1; - } else { -#ifdef NEEDTOPORT - csevent_log(CSC_CTL | CSC_SHELF_SW | - CTL_TAG_TO_TAG, - csevent_LogType_Trace, - csevent_Severity_Information, - csevent_AlertLevel_Green, - csevent_FRU_Firmware, - csevent_FRU_Unknown, - "Received tagged queueing to tagged " - "queueing transition"); -#endif /* NEEDTOPORT */ - } + return (0); +} + +int +ctl_caching_sp_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, uint8_t *page_ptr) +{ + struct scsi_caching_page *current_cp, *saved_cp, *user_cp; + struct ctl_lun *lun; + int set_ua; + uint32_t initidx; + + lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); + set_ua = 0; + + user_cp = (struct scsi_caching_page *)page_ptr; + current_cp = (struct scsi_caching_page *) + (page_index->page_data + (page_index->page_len * + CTL_PAGE_CURRENT)); + saved_cp = (struct scsi_caching_page *) + (page_index->page_data + (page_index->page_len * + CTL_PAGE_SAVED)); + + mtx_lock(&lun->lun_lock); + if ((current_cp->flags1 & (SCP_WCE | SCP_RCD)) != + (user_cp->flags1 & (SCP_WCE | SCP_RCD))) { + current_cp->flags1 &= ~(SCP_WCE | SCP_RCD); + current_cp->flags1 |= user_cp->flags1 & (SCP_WCE | SCP_RCD); + saved_cp->flags1 &= ~(SCP_WCE | SCP_RCD); + saved_cp->flags1 |= user_cp->flags1 & (SCP_WCE | SCP_RCD); + set_ua = 1; } if (set_ua != 0) { int i; @@ -7008,7 +7045,8 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) header = (struct scsi_mode_hdr_6 *)ctsio->kern_data_ptr; header->datalen = ctl_min(total_len - 1, 254); - + if (control_dev == 0) + header->dev_specific = 0x10; /* DPOFUA */ if (dbd) header->block_descr_len = 0; else @@ -7025,6 +7063,8 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) datalen = ctl_min(total_len - 2, 65533); scsi_ulto2b(datalen, header->datalen); + if (control_dev == 0) + header->dev_specific = 0x10; /* DPOFUA */ if (dbd) scsi_ulto2b(0, header->block_descr_len); else @@ -7043,7 +7083,7 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) * descriptor. Otherwise, just set it to 0. */ if (dbd == 0) { - if (control_dev != 0) + if (control_dev == 0) scsi_ulto3b(lun->be_lun->blocksize, block_desc->block_len); else @@ -7857,7 +7897,7 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) res_cap = (struct scsi_per_res_cap *)ctsio->kern_data_ptr; scsi_ulto2b(sizeof(*res_cap), res_cap->length); - res_cap->flags2 |= SPRI_TMV | SPRI_ALLOW_3; + res_cap->flags2 |= SPRI_TMV | SPRI_ALLOW_5; type_mask = SPRI_TM_WR_EX_AR | SPRI_TM_EX_AC_RO | SPRI_TM_WR_EX_RO | @@ -7910,7 +7950,8 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) scsi_ulto2b(i / CTL_MAX_INIT_PER_PORT, res_desc->rel_trgt_port_id); len = 0; - port = softc->ctl_ports[i / CTL_MAX_INIT_PER_PORT]; + port = softc->ctl_ports[ + ctl_port_idx(i / CTL_MAX_INIT_PER_PORT)]; if (port != NULL) len = ctl_create_iid(port, i % CTL_MAX_INIT_PER_PORT, @@ -8976,17 +9017,14 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct ctl_lba_len_flags *lbalen; uint64_t lba; uint32_t num_blocks; - int fua, dpo; - int retval; + int flags, retval; int isread; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; CTL_DEBUG_PRINT(("ctl_read_write: command: %#x\n", ctsio->cdb[0])); - fua = 0; - dpo = 0; - + flags = 0; retval = CTL_RETVAL_COMPLETE; isread = ctsio->cdb[0] == READ_6 || ctsio->cdb[0] == READ_10 @@ -9032,12 +9070,10 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct scsi_rw_10 *cdb; cdb = (struct scsi_rw_10 *)ctsio->cdb; - if (cdb->byte2 & SRW10_FUA) - fua = 1; + flags |= CTL_LLF_FUA; if (cdb->byte2 & SRW10_DPO) - dpo = 1; - + flags |= CTL_LLF_DPO; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_2btoul(cdb->length); break; @@ -9046,17 +9082,9 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct scsi_write_verify_10 *cdb; cdb = (struct scsi_write_verify_10 *)ctsio->cdb; - - /* - * XXX KDM we should do actual write verify support at some - * point. This is obviously fake, we're just translating - * things to a write. So we don't even bother checking the - * BYTCHK field, since we don't do any verification. If - * the user asks for it, we'll just pretend we did it. - */ + flags |= CTL_LLF_FUA; if (cdb->byte2 & SWV_DPO) - dpo = 1; - + flags |= CTL_LLF_DPO; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_2btoul(cdb->length); break; @@ -9066,11 +9094,10 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct scsi_rw_12 *cdb; cdb = (struct scsi_rw_12 *)ctsio->cdb; - if (cdb->byte2 & SRW12_FUA) - fua = 1; + flags |= CTL_LLF_FUA; if (cdb->byte2 & SRW12_DPO) - dpo = 1; + flags |= CTL_LLF_DPO; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_4btoul(cdb->length); break; @@ -9079,13 +9106,11 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct scsi_write_verify_12 *cdb; cdb = (struct scsi_write_verify_12 *)ctsio->cdb; - + flags |= CTL_LLF_FUA; if (cdb->byte2 & SWV_DPO) - dpo = 1; - + flags |= CTL_LLF_DPO; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_4btoul(cdb->length); - break; } case READ_16: @@ -9093,12 +9118,10 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct scsi_rw_16 *cdb; cdb = (struct scsi_rw_16 *)ctsio->cdb; - if (cdb->byte2 & SRW12_FUA) - fua = 1; + flags |= CTL_LLF_FUA; if (cdb->byte2 & SRW12_DPO) - dpo = 1; - + flags |= CTL_LLF_DPO; lba = scsi_8btou64(cdb->addr); num_blocks = scsi_4btoul(cdb->length); break; @@ -9107,10 +9130,9 @@ ctl_read_write(struct ctl_scsiio *ctsio) struct scsi_write_verify_16 *cdb; cdb = (struct scsi_write_verify_16 *)ctsio->cdb; - + flags |= CTL_LLF_FUA; if (cdb->byte2 & SWV_DPO) - dpo = 1; - + flags |= CTL_LLF_DPO; lba = scsi_8btou64(cdb->addr); num_blocks = scsi_4btoul(cdb->length); break; @@ -9127,13 +9149,6 @@ ctl_read_write(struct ctl_scsiio *ctsio) break; /* NOTREACHED */ } - /* - * XXX KDM what do we do with the DPO and FUA bits? FUA might be - * interesting for us, but if RAIDCore is in write-back mode, - * getting it to do write-through for a particular transaction may - * not be possible. - */ - /* * The first check is to make sure we're in bounds, the second * check is to catch wrap-around problems. If the lba + num blocks @@ -9158,11 +9173,22 @@ ctl_read_write(struct ctl_scsiio *ctsio) return (CTL_RETVAL_COMPLETE); } + /* Set FUA and/or DPO if caches are disabled. */ + if (isread) { + if ((lun->mode_pages.caching_page[CTL_PAGE_CURRENT].flags1 & + SCP_RCD) != 0) + flags |= CTL_LLF_FUA | CTL_LLF_DPO; + } else { + if ((lun->mode_pages.caching_page[CTL_PAGE_CURRENT].flags1 & + SCP_WCE) == 0) + flags |= CTL_LLF_FUA; + } + lbalen = (struct ctl_lba_len_flags *) &ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; lbalen->lba = lba; lbalen->len = num_blocks; - lbalen->flags = isread ? CTL_LLF_READ : CTL_LLF_WRITE; + lbalen->flags = (isread ? CTL_LLF_READ : CTL_LLF_WRITE) | flags; ctsio->kern_total_len = num_blocks * lun->be_lun->blocksize; ctsio->kern_rel_offset = 0; @@ -9188,7 +9214,8 @@ ctl_cnw_cont(union ctl_io *io) lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; lbalen = (struct ctl_lba_len_flags *) &ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; - lbalen->flags = CTL_LLF_WRITE; + lbalen->flags &= ~CTL_LLF_COMPARE; + lbalen->flags |= CTL_LLF_WRITE; CTL_DEBUG_PRINT(("ctl_cnw_cont: calling data_submit()\n")); retval = lun->backend->data_submit((union ctl_io *)ctsio); @@ -9202,16 +9229,13 @@ ctl_cnw(struct ctl_scsiio *ctsio) struct ctl_lba_len_flags *lbalen; uint64_t lba; uint32_t num_blocks; - int fua, dpo; - int retval; + int flags, retval; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; CTL_DEBUG_PRINT(("ctl_cnw: command: %#x\n", ctsio->cdb[0])); - fua = 0; - dpo = 0; - + flags = 0; retval = CTL_RETVAL_COMPLETE; switch (ctsio->cdb[0]) { @@ -9219,11 +9243,10 @@ ctl_cnw(struct ctl_scsiio *ctsio) struct scsi_compare_and_write *cdb; cdb = (struct scsi_compare_and_write *)ctsio->cdb; - if (cdb->byte2 & SRW10_FUA) - fua = 1; + flags |= CTL_LLF_FUA; if (cdb->byte2 & SRW10_DPO) - dpo = 1; + flags |= CTL_LLF_DPO; lba = scsi_8btou64(cdb->addr); num_blocks = cdb->length; break; @@ -9240,13 +9263,6 @@ ctl_cnw(struct ctl_scsiio *ctsio) break; /* NOTREACHED */ } - /* - * XXX KDM what do we do with the DPO and FUA bits? FUA might be - * interesting for us, but if RAIDCore is in write-back mode, - * getting it to do write-through for a particular transaction may - * not be possible. - */ - /* * The first check is to make sure we're in bounds, the second * check is to catch wrap-around problems. If the lba + num blocks @@ -9269,6 +9285,11 @@ ctl_cnw(struct ctl_scsiio *ctsio) return (CTL_RETVAL_COMPLETE); } + /* Set FUA if write cache is disabled. */ + if ((lun->mode_pages.caching_page[CTL_PAGE_CURRENT].flags1 & + SCP_WCE) == 0) + flags |= CTL_LLF_FUA; + ctsio->kern_total_len = 2 * num_blocks * lun->be_lun->blocksize; ctsio->kern_rel_offset = 0; @@ -9284,7 +9305,7 @@ ctl_cnw(struct ctl_scsiio *ctsio) &ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; lbalen->lba = lba; lbalen->len = num_blocks; - lbalen->flags = CTL_LLF_COMPARE; + lbalen->flags = CTL_LLF_COMPARE | flags; CTL_DEBUG_PRINT(("ctl_cnw: calling data_submit()\n")); retval = lun->backend->data_submit((union ctl_io *)ctsio); @@ -9298,7 +9319,7 @@ ctl_verify(struct ctl_scsiio *ctsio) struct ctl_lba_len_flags *lbalen; uint64_t lba; uint32_t num_blocks; - int bytchk, dpo; + int bytchk, flags; int retval; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; @@ -9306,7 +9327,7 @@ ctl_verify(struct ctl_scsiio *ctsio) CTL_DEBUG_PRINT(("ctl_verify: command: %#x\n", ctsio->cdb[0])); bytchk = 0; - dpo = 0; + flags = CTL_LLF_FUA; retval = CTL_RETVAL_COMPLETE; switch (ctsio->cdb[0]) { @@ -9317,7 +9338,7 @@ ctl_verify(struct ctl_scsiio *ctsio) if (cdb->byte2 & SVFY_BYTCHK) bytchk = 1; if (cdb->byte2 & SVFY_DPO) - dpo = 1; + flags |= CTL_LLF_DPO; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_2btoul(cdb->length); break; @@ -9329,7 +9350,7 @@ ctl_verify(struct ctl_scsiio *ctsio) if (cdb->byte2 & SVFY_BYTCHK) bytchk = 1; if (cdb->byte2 & SVFY_DPO) - dpo = 1; + flags |= CTL_LLF_DPO; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_4btoul(cdb->length); break; @@ -9341,7 +9362,7 @@ ctl_verify(struct ctl_scsiio *ctsio) if (cdb->byte2 & SVFY_BYTCHK) bytchk = 1; if (cdb->byte2 & SVFY_DPO) - dpo = 1; + flags |= CTL_LLF_DPO; lba = scsi_8btou64(cdb->addr); num_blocks = scsi_4btoul(cdb->length); break; @@ -9383,10 +9404,10 @@ ctl_verify(struct ctl_scsiio *ctsio) lbalen->lba = lba; lbalen->len = num_blocks; if (bytchk) { - lbalen->flags = CTL_LLF_COMPARE; + lbalen->flags = CTL_LLF_COMPARE | flags; ctsio->kern_total_len = num_blocks * lun->be_lun->blocksize; } else { - lbalen->flags = CTL_LLF_VERIFY; + lbalen->flags = CTL_LLF_VERIFY | flags; ctsio->kern_total_len = 0; } ctsio->kern_rel_offset = 0; @@ -9668,13 +9689,10 @@ ctl_request_sense(struct ctl_scsiio *ctsio) if (lun->pending_ua[initidx] != CTL_UA_NONE) { ctl_ua_type ua_type; - ua_type = ctl_build_ua(lun->pending_ua[initidx], + ua_type = ctl_build_ua(&lun->pending_ua[initidx], sense_ptr, sense_format); - if (ua_type != CTL_UA_NONE) { + if (ua_type != CTL_UA_NONE) have_error = 1; - /* We're reporting this UA, so clear it */ - lun->pending_ua[initidx] &= ~ua_type; - } } mtx_unlock(&lun->lun_lock); @@ -9804,16 +9822,20 @@ ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len) pages->page_list[1] = SVPD_UNIT_SERIAL_NUMBER; /* Device Identification */ pages->page_list[2] = SVPD_DEVICE_ID; + /* Extended INQUIRY Data */ + pages->page_list[3] = SVPD_EXTENDED_INQUIRY_DATA; + /* Mode Page Policy */ + pages->page_list[4] = SVPD_MODE_PAGE_POLICY; /* SCSI Ports */ - pages->page_list[3] = SVPD_SCSI_PORTS; + pages->page_list[5] = SVPD_SCSI_PORTS; /* Third-party Copy */ - pages->page_list[4] = SVPD_SCSI_TPC; + pages->page_list[6] = SVPD_SCSI_TPC; /* Block limits */ - pages->page_list[5] = SVPD_BLOCK_LIMITS; + pages->page_list[7] = SVPD_BLOCK_LIMITS; /* Block Device Characteristics */ - pages->page_list[6] = SVPD_BDC; + pages->page_list[8] = SVPD_BDC; /* Logical Block Provisioning */ - pages->page_list[7] = SVPD_LBP; + pages->page_list[9] = SVPD_LBP; ctsio->scsi_status = SCSI_STATUS_OK; @@ -9881,6 +9903,109 @@ ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) } +static int +ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) +{ + struct scsi_vpd_extended_inquiry_data *eid_ptr; + struct ctl_lun *lun; + int data_len; + + lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + + data_len = sizeof(struct scsi_vpd_mode_page_policy) + + sizeof(struct scsi_vpd_mode_page_policy_descr); + + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); + eid_ptr = (struct scsi_vpd_extended_inquiry_data *)ctsio->kern_data_ptr; + ctsio->kern_sg_entries = 0; + + if (data_len < alloc_len) { + ctsio->residual = alloc_len - data_len; + ctsio->kern_data_len = data_len; + ctsio->kern_total_len = data_len; + } else { + ctsio->residual = 0; + ctsio->kern_data_len = alloc_len; + ctsio->kern_total_len = alloc_len; + } + ctsio->kern_data_resid = 0; + ctsio->kern_rel_offset = 0; + ctsio->kern_sg_entries = 0; + + /* + * The control device is always connected. The disk device, on the + * other hand, may not be online all the time. + */ + if (lun != NULL) + eid_ptr->device = (SID_QUAL_LU_CONNECTED << 5) | + lun->be_lun->lun_type; + else + eid_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; + eid_ptr->page_code = SVPD_EXTENDED_INQUIRY_DATA; + eid_ptr->page_length = data_len - 4; + eid_ptr->flags2 = SVPD_EID_HEADSUP | SVPD_EID_ORDSUP | SVPD_EID_SIMPSUP; + eid_ptr->flags3 = SVPD_EID_V_SUP; + + ctsio->scsi_status = SCSI_STATUS_OK; + ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; + ctsio->be_move_done = ctl_config_move_done; + ctl_datamove((union ctl_io *)ctsio); + + return (CTL_RETVAL_COMPLETE); +} + +static int +ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) +{ + struct scsi_vpd_mode_page_policy *mpp_ptr; + struct ctl_lun *lun; + int data_len; + + lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + + data_len = sizeof(struct scsi_vpd_mode_page_policy) + + sizeof(struct scsi_vpd_mode_page_policy_descr); + + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); + mpp_ptr = (struct scsi_vpd_mode_page_policy *)ctsio->kern_data_ptr; + ctsio->kern_sg_entries = 0; + + if (data_len < alloc_len) { + ctsio->residual = alloc_len - data_len; + ctsio->kern_data_len = data_len; + ctsio->kern_total_len = data_len; + } else { + ctsio->residual = 0; + ctsio->kern_data_len = alloc_len; + ctsio->kern_total_len = alloc_len; + } + ctsio->kern_data_resid = 0; + ctsio->kern_rel_offset = 0; + ctsio->kern_sg_entries = 0; + + /* + * The control device is always connected. The disk device, on the + * other hand, may not be online all the time. + */ + if (lun != NULL) + mpp_ptr->device = (SID_QUAL_LU_CONNECTED << 5) | + lun->be_lun->lun_type; + else + mpp_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; + mpp_ptr->page_code = SVPD_MODE_PAGE_POLICY; + scsi_ulto2b(data_len - 4, mpp_ptr->page_length); + mpp_ptr->descr[0].page_code = 0x3f; + mpp_ptr->descr[0].subpage_code = 0xff; + mpp_ptr->descr[0].policy = SVPD_MPP_SHARED; + + ctsio->scsi_status = SCSI_STATUS_OK; + ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; + ctsio->be_move_done = ctl_config_move_done; + ctl_datamove((union ctl_io *)ctsio); + + return (CTL_RETVAL_COMPLETE); +} + static int ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) { @@ -10160,7 +10285,7 @@ ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) bl_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; bl_ptr->page_code = SVPD_BLOCK_LIMITS; - scsi_ulto2b(sizeof(*bl_ptr), bl_ptr->page_length); + scsi_ulto2b(sizeof(*bl_ptr) - 4, bl_ptr->page_length); bl_ptr->max_cmp_write_len = 0xff; scsi_ulto4b(0xffffffff, bl_ptr->max_txfer_len); if (lun != NULL) { @@ -10311,6 +10436,12 @@ ctl_inquiry_evpd(struct ctl_scsiio *ctsio) case SVPD_DEVICE_ID: retval = ctl_inquiry_evpd_devid(ctsio, alloc_len); break; + case SVPD_EXTENDED_INQUIRY_DATA: + retval = ctl_inquiry_evpd_eid(ctsio, alloc_len); + break; + case SVPD_MODE_PAGE_POLICY: + retval = ctl_inquiry_evpd_mpp(ctsio, alloc_len); + break; case SVPD_SCSI_PORTS: retval = ctl_inquiry_evpd_scsi_ports(ctsio, alloc_len); break; @@ -10349,7 +10480,7 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio) struct ctl_softc *ctl_softc; struct ctl_lun *lun; char *val; - uint32_t alloc_len; + uint32_t alloc_len, data_len; ctl_port_type port_type; ctl_softc = control_softc; @@ -10373,16 +10504,17 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio) * in. If the user only asks for less, we'll give him * that much. */ - ctsio->kern_data_ptr = malloc(sizeof(*inq_ptr), M_CTL, M_WAITOK | M_ZERO); + data_len = offsetof(struct scsi_inquiry_data, vendor_specific1); + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); inq_ptr = (struct scsi_inquiry_data *)ctsio->kern_data_ptr; ctsio->kern_sg_entries = 0; ctsio->kern_data_resid = 0; ctsio->kern_rel_offset = 0; - if (sizeof(*inq_ptr) < alloc_len) { - ctsio->residual = alloc_len - sizeof(*inq_ptr); - ctsio->kern_data_len = sizeof(*inq_ptr); - ctsio->kern_total_len = sizeof(*inq_ptr); + if (data_len < alloc_len) { + ctsio->residual = alloc_len - data_len; + ctsio->kern_data_len = data_len; + ctsio->kern_total_len = data_len; } else { ctsio->residual = 0; ctsio->kern_data_len = alloc_len; @@ -10462,15 +10594,12 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio) */ inq_ptr->response_format = SID_HiSup | 2; - inq_ptr->additional_length = - offsetof(struct scsi_inquiry_data, vendor_specific1) - + inq_ptr->additional_length = data_len - (offsetof(struct scsi_inquiry_data, additional_length) + 1); CTL_DEBUG_PRINT(("additional_length = %d\n", inq_ptr->additional_length)); - inq_ptr->spc3_flags = SPC3_SID_3PC; - if (!ctl_is_single) - inq_ptr->spc3_flags |= SPC3_SID_TPGS_IMPLICIT; + inq_ptr->spc3_flags = SPC3_SID_3PC | SPC3_SID_TPGS_IMPLICIT; /* 16 bit addressing */ if (port_type == CTL_PORT_SCSI) inq_ptr->spc2_flags = SPC2_SID_ADDR16; @@ -10495,24 +10624,28 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio) */ if (lun == NULL || (val = ctl_get_opt(&lun->be_lun->options, "vendor")) == NULL) { - strcpy(inq_ptr->vendor, CTL_VENDOR); + strncpy(inq_ptr->vendor, CTL_VENDOR, sizeof(inq_ptr->vendor)); } else { memset(inq_ptr->vendor, ' ', sizeof(inq_ptr->vendor)); strncpy(inq_ptr->vendor, val, min(sizeof(inq_ptr->vendor), strlen(val))); } if (lun == NULL) { - strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT); + strncpy(inq_ptr->product, CTL_DIRECT_PRODUCT, + sizeof(inq_ptr->product)); } else if ((val = ctl_get_opt(&lun->be_lun->options, "product")) == NULL) { switch (lun->be_lun->lun_type) { case T_DIRECT: - strcpy(inq_ptr->product, CTL_DIRECT_PRODUCT); + strncpy(inq_ptr->product, CTL_DIRECT_PRODUCT, + sizeof(inq_ptr->product)); break; case T_PROCESSOR: - strcpy(inq_ptr->product, CTL_PROCESSOR_PRODUCT); + strncpy(inq_ptr->product, CTL_PROCESSOR_PRODUCT, + sizeof(inq_ptr->product)); break; default: - strcpy(inq_ptr->product, CTL_UNKNOWN_PRODUCT); + strncpy(inq_ptr->product, CTL_UNKNOWN_PRODUCT, + sizeof(inq_ptr->product)); break; } } else { @@ -10596,45 +10729,23 @@ ctl_inquiry(struct ctl_scsiio *ctsio) struct scsi_inquiry *cdb; int retval; - cdb = (struct scsi_inquiry *)ctsio->cdb; - - retval = 0; - CTL_DEBUG_PRINT(("ctl_inquiry\n")); - /* - * Right now, we don't support the CmdDt inquiry information. - * This would be nice to support in the future. When we do - * support it, we should change this test so that it checks to make - * sure SI_EVPD and SI_CMDDT aren't both set at the same time. - */ -#ifdef notyet - if (((cdb->byte2 & SI_EVPD) - && (cdb->byte2 & SI_CMDDT))) -#endif - if (cdb->byte2 & SI_CMDDT) { - /* - * Point to the SI_CMDDT bit. We might change this - * when we support SI_CMDDT, but since both bits would be - * "wrong", this should probably just stay as-is then. - */ + cdb = (struct scsi_inquiry *)ctsio->cdb; + if (cdb->byte2 & SI_EVPD) + retval = ctl_inquiry_evpd(ctsio); + else if (cdb->page_code == 0) + retval = ctl_inquiry_std(ctsio); + else { ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, - /*field*/ 1, - /*bit_valid*/ 1, - /*bit*/ 1); + /*field*/ 2, + /*bit_valid*/ 0, + /*bit*/ 0); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } - if (cdb->byte2 & SI_EVPD) - retval = ctl_inquiry_evpd(ctsio); -#ifdef notyet - else if (cdb->byte2 & SI_CMDDT) - retval = ctl_inquiry_cmddt(ctsio); -#endif - else - retval = ctl_inquiry_std(ctsio); return (retval); } @@ -10643,7 +10754,7 @@ ctl_inquiry(struct ctl_scsiio *ctsio) * For known CDB types, parse the LBA and length. */ static int -ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint32_t *len) +ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint64_t *len) { if (io->io_hdr.io_type != CTL_IO_SCSI) return (1); @@ -10773,6 +10884,11 @@ ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint32_t *len) *len = scsi_4btoul(cdb->length); break; } + case UNMAP: { + *lba = 0; + *len = UINT64_MAX; + break; + } default: return (1); break; /* NOTREACHED */ @@ -10782,7 +10898,7 @@ ctl_get_lba_len(union ctl_io *io, uint64_t *lba, uint32_t *len) } static ctl_action -ctl_extent_check_lba(uint64_t lba1, uint32_t len1, uint64_t lba2, uint32_t len2) +ctl_extent_check_lba(uint64_t lba1, uint64_t len1, uint64_t lba2, uint64_t len2) { uint64_t endlba1, endlba2; @@ -10796,26 +10912,61 @@ ctl_extent_check_lba(uint64_t lba1, uint32_t len1, uint64_t lba2, uint32_t len2) return (CTL_ACTION_BLOCK); } +static int +ctl_extent_check_unmap(union ctl_io *io, uint64_t lba2, uint64_t len2) +{ + struct ctl_ptr_len_flags *ptrlen; + struct scsi_unmap_desc *buf, *end, *range; + uint64_t lba; + uint32_t len; + + /* If not UNMAP -- go other way. */ + if (io->io_hdr.io_type != CTL_IO_SCSI || + io->scsiio.cdb[0] != UNMAP) + return (CTL_ACTION_ERROR); + + /* If UNMAP without data -- block and wait for data. */ + ptrlen = (struct ctl_ptr_len_flags *) + &io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; + if ((io->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0 || + ptrlen->ptr == NULL) + return (CTL_ACTION_BLOCK); + + /* UNMAP with data -- check for collision. */ + buf = (struct scsi_unmap_desc *)ptrlen->ptr; + end = buf + ptrlen->len / sizeof(*buf); + for (range = buf; range < end; range++) { + lba = scsi_8btou64(range->lba); + len = scsi_4btoul(range->length); + if ((lba < lba2 + len2) && (lba + len > lba2)) + return (CTL_ACTION_BLOCK); + } + return (CTL_ACTION_PASS); +} + static ctl_action ctl_extent_check(union ctl_io *io1, union ctl_io *io2) { uint64_t lba1, lba2; - uint32_t len1, len2; + uint64_t len1, len2; int retval; - retval = ctl_get_lba_len(io1, &lba1, &len1); - if (retval != 0) + if (ctl_get_lba_len(io1, &lba1, &len1) != 0) return (CTL_ACTION_ERROR); - retval = ctl_get_lba_len(io2, &lba2, &len2); - if (retval != 0) + retval = ctl_extent_check_unmap(io2, lba1, len1); + if (retval != CTL_ACTION_ERROR) + return (retval); + + if (ctl_get_lba_len(io2, &lba2, &len2) != 0) return (CTL_ACTION_ERROR); return (ctl_extent_check_lba(lba1, len1, lba2, len2)); } static ctl_action -ctl_check_for_blockage(union ctl_io *pending_io, union ctl_io *ooa_io) +ctl_check_for_blockage(struct ctl_lun *lun, union ctl_io *pending_io, + union ctl_io *ooa_io) { const struct ctl_cmd_entry *pending_entry, *ooa_entry; ctl_serialize_action *serialize_row; @@ -10890,28 +11041,33 @@ ctl_check_for_blockage(union ctl_io *pending_io, union ctl_io *ooa_io) || (ooa_io->scsiio.tag_type == CTL_TAG_ORDERED))) return (CTL_ACTION_BLOCK); - pending_entry = ctl_get_cmd_entry(&pending_io->scsiio); - ooa_entry = ctl_get_cmd_entry(&ooa_io->scsiio); + pending_entry = ctl_get_cmd_entry(&pending_io->scsiio, NULL); + ooa_entry = ctl_get_cmd_entry(&ooa_io->scsiio, NULL); serialize_row = ctl_serialize_table[ooa_entry->seridx]; switch (serialize_row[pending_entry->seridx]) { case CTL_SER_BLOCK: return (CTL_ACTION_BLOCK); - break; /* NOTREACHED */ case CTL_SER_EXTENT: return (ctl_extent_check(pending_io, ooa_io)); - break; /* NOTREACHED */ + case CTL_SER_EXTENTOPT: + if ((lun->mode_pages.control_page[CTL_PAGE_CURRENT].queue_flags + & SCP_QUEUE_ALG_MASK) != SCP_QUEUE_ALG_UNRESTRICTED) + return (ctl_extent_check(pending_io, ooa_io)); + /* FALLTHROUGH */ case CTL_SER_PASS: return (CTL_ACTION_PASS); - break; /* NOTREACHED */ + case CTL_SER_BLOCKOPT: + if ((lun->mode_pages.control_page[CTL_PAGE_CURRENT].queue_flags + & SCP_QUEUE_ALG_MASK) != SCP_QUEUE_ALG_UNRESTRICTED) + return (CTL_ACTION_BLOCK); + return (CTL_ACTION_PASS); case CTL_SER_SKIP: return (CTL_ACTION_SKIP); - break; default: panic("invalid serialization value %d", serialize_row[pending_entry->seridx]); - break; /* NOTREACHED */ } return (CTL_ACTION_ERROR); @@ -10948,7 +11104,7 @@ ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io, * of it in the queue. It doesn't queue/dequeue * cur_blocked. */ - action = ctl_check_for_blockage(pending_io, ooa_io); + action = ctl_check_for_blockage(lun, pending_io, ooa_io); switch (action) { case CTL_ACTION_BLOCK: case CTL_ACTION_OVERLAP: @@ -11059,7 +11215,7 @@ ctl_check_blocked(struct ctl_lun *lun) } break; } - entry = ctl_get_cmd_entry(&cur_blocked->scsiio); + entry = ctl_get_cmd_entry(&cur_blocked->scsiio, NULL); softc = control_softc; initidx = ctl_get_initindex(&cur_blocked->io_hdr.nexus); @@ -11110,6 +11266,7 @@ ctl_scsiio_lun_check(struct ctl_softc *ctl_softc, struct ctl_lun *lun, const struct ctl_cmd_entry *entry, struct ctl_scsiio *ctsio) { int retval; + uint32_t residx; retval = 0; @@ -11134,12 +11291,10 @@ ctl_scsiio_lun_check(struct ctl_softc *ctl_softc, struct ctl_lun *lun, * even on reserved LUNs, and if this initiator isn't the one who * reserved us, reject the command with a reservation conflict. */ + residx = ctl_get_resindex(&ctsio->io_hdr.nexus); if ((lun->flags & CTL_LUN_RESERVED) && ((entry->flags & CTL_CMD_FLAG_ALLOW_ON_RESV) == 0)) { - if ((ctsio->io_hdr.nexus.initid.id != lun->rsv_nexus.initid.id) - || (ctsio->io_hdr.nexus.targ_port != lun->rsv_nexus.targ_port) - || (ctsio->io_hdr.nexus.targ_target.id != - lun->rsv_nexus.targ_target.id)) { + if (lun->res_idx != residx) { ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT; ctsio->io_hdr.status = CTL_SCSI_ERROR; retval = 1; @@ -11147,11 +11302,8 @@ ctl_scsiio_lun_check(struct ctl_softc *ctl_softc, struct ctl_lun *lun, } } - if ( (lun->flags & CTL_LUN_PR_RESERVED) + if ((lun->flags & CTL_LUN_PR_RESERVED) && ((entry->flags & CTL_CMD_FLAG_ALLOW_ON_PR_RESV) == 0)) { - uint32_t residx; - - residx = ctl_get_resindex(&ctsio->io_hdr.nexus); /* * if we aren't registered or it's a res holder type * reservation and this isn't the res holder then set a @@ -11588,8 +11740,7 @@ ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio) if ((entry->flags & CTL_CMD_FLAG_NO_SENSE) == 0) { ctl_ua_type ua_type; - ua_type = lun->pending_ua[initidx]; - if (ua_type != CTL_UA_NONE) { + if (lun->pending_ua[initidx] != CTL_UA_NONE) { scsi_sense_data_type sense_format; if (lun != NULL) @@ -11599,14 +11750,13 @@ ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio) else sense_format = SSD_TYPE_FIXED; - ua_type = ctl_build_ua(ua_type, &ctsio->sense_data, - sense_format); + ua_type = ctl_build_ua(&lun->pending_ua[initidx], + &ctsio->sense_data, sense_format); if (ua_type != CTL_UA_NONE) { ctsio->scsi_status = SCSI_STATUS_CHECK_COND; ctsio->io_hdr.status = CTL_SCSI_ERROR | CTL_AUTOSENSE; ctsio->sense_len = SSD_FULL_SIZE; - lun->pending_ua[initidx] &= ~ua_type; mtx_unlock(&lun->lun_lock); ctl_done((union ctl_io *)ctsio); return (retval); @@ -11710,12 +11860,14 @@ ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio) } const struct ctl_cmd_entry * -ctl_get_cmd_entry(struct ctl_scsiio *ctsio) +ctl_get_cmd_entry(struct ctl_scsiio *ctsio, int *sa) { const struct ctl_cmd_entry *entry; int service_action; entry = &ctl_cmd_table[ctsio->cdb[0]]; + if (sa) + *sa = ((entry->flags & CTL_CMD_FLAG_SA5) != 0); if (entry->flags & CTL_CMD_FLAG_SA5) { service_action = ctsio->cdb[1] & SERVICE_ACTION_MASK; entry = &((const struct ctl_cmd_entry *) @@ -11728,12 +11880,20 @@ const struct ctl_cmd_entry * ctl_validate_command(struct ctl_scsiio *ctsio) { const struct ctl_cmd_entry *entry; - int i; + int i, sa; uint8_t diff; - entry = ctl_get_cmd_entry(ctsio); + entry = ctl_get_cmd_entry(ctsio, &sa); if (entry->execute == NULL) { - ctl_set_invalid_opcode(ctsio); + if (sa) + ctl_set_invalid_field(ctsio, + /*sks_valid*/ 1, + /*command*/ 1, + /*field*/ 1, + /*bit_valid*/ 1, + /*bit*/ 4); + else + ctl_set_invalid_opcode(ctsio); ctl_done((union ctl_io *)ctsio); return (NULL); } @@ -11787,7 +11947,7 @@ ctl_scsiio(struct ctl_scsiio *ctsio) CTL_DEBUG_PRINT(("ctl_scsiio cdb[0]=%02X\n", ctsio->cdb[0])); - entry = ctl_get_cmd_entry(ctsio); + entry = ctl_get_cmd_entry(ctsio, NULL); /* * If this I/O has been aborted, just send it straight to @@ -11926,12 +12086,11 @@ ctl_lun_reset(struct ctl_lun *lun, union ctl_io *io, ctl_ua_type ua_type) return (0); } -static int +static void ctl_abort_tasks_lun(struct ctl_lun *lun, uint32_t targ_port, uint32_t init_id, int other_sc) { union ctl_io *xio; - int found; mtx_assert(&lun->lun_lock, MA_OWNED); @@ -11953,7 +12112,6 @@ ctl_abort_tasks_lun(struct ctl_lun *lun, uint32_t targ_port, uint32_t init_id, init_id != xio->io_hdr.nexus.initid.id) xio->io_hdr.flags |= CTL_FLAG_ABORT_STATUS; xio->io_hdr.flags |= CTL_FLAG_ABORT; - found = 1; if (!other_sc && !(lun->flags & CTL_LUN_PRIMARY_SC)) { union ctl_ha_msg msg_info; @@ -11969,7 +12127,6 @@ ctl_abort_tasks_lun(struct ctl_lun *lun, uint32_t targ_port, uint32_t init_id, } } } - return (found); } static int @@ -12010,9 +12167,10 @@ ctl_i_t_nexus_reset(union ctl_io *io) { struct ctl_softc *softc = control_softc; struct ctl_lun *lun; - uint32_t initindex; + uint32_t initindex, residx; initindex = ctl_get_initindex(&io->io_hdr.nexus); + residx = ctl_get_resindex(&io->io_hdr.nexus); mtx_lock(&softc->ctl_lock); STAILQ_FOREACH(lun, &softc->lun_list, links) { mtx_lock(&lun->lun_lock); @@ -12022,6 +12180,8 @@ ctl_i_t_nexus_reset(union ctl_io *io) #ifdef CTL_WITH_CA ctl_clear_mask(lun->have_ca, initindex); #endif + if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == residx)) + lun->flags &= ~CTL_LUN_RESERVED; lun->pending_ua[initindex] |= CTL_UA_I_T_NEXUS_LOSS; mtx_unlock(&lun->lun_lock); } @@ -12320,7 +12480,7 @@ ctl_handle_isc(union ctl_io *io) * This is only used in SER_ONLY mode. */ free_io = 0; - entry = ctl_get_cmd_entry(&io->scsiio); + entry = ctl_get_cmd_entry(&io->scsiio, NULL); mtx_lock(&lun->lun_lock); if (ctl_scsiio_lun_check(ctl_softc, lun, entry, (struct ctl_scsiio *)io) != 0) { @@ -12400,7 +12560,7 @@ ctl_cmd_pattern_match(struct ctl_scsiio *ctsio, struct ctl_error_desc *desc) if ((pattern & CTL_LUN_PAT_MASK) == CTL_LUN_PAT_ANY) return (CTL_LUN_PAT_ANY); - entry = ctl_get_cmd_entry(ctsio); + entry = ctl_get_cmd_entry(ctsio, NULL); filtered_pattern = entry->pattern & pattern; @@ -12422,7 +12582,7 @@ ctl_cmd_pattern_match(struct ctl_scsiio *ctsio, struct ctl_error_desc *desc) */ if (filtered_pattern & CTL_LUN_PAT_RANGE) { uint64_t lba1; - uint32_t len1; + uint64_t len1; ctl_action action; int retval; diff --git a/sys/cam/ctl/ctl.h b/sys/cam/ctl/ctl.h index 0525a51d24a2..fa09c0e772e0 100644 --- a/sys/cam/ctl/ctl.h +++ b/sys/cam/ctl/ctl.h @@ -119,7 +119,7 @@ typedef enum { CTL_UA_I_T_NEXUS_LOSS = 0x0008, CTL_UA_LUN_RESET = 0x0010, CTL_UA_LUN_CHANGE = 0x0020, - CTL_UA_MODE_CHANGE = 0x0030, + CTL_UA_MODE_CHANGE = 0x0040, CTL_UA_LOG_CHANGE = 0x0080, CTL_UA_LVD = 0x0100, CTL_UA_SE = 0x0200, @@ -162,6 +162,8 @@ int ctl_ffz(uint32_t *mask, uint32_t size); int ctl_set_mask(uint32_t *mask, uint32_t bit); int ctl_clear_mask(uint32_t *mask, uint32_t bit); int ctl_is_set(uint32_t *mask, uint32_t bit); +int ctl_caching_sp_handler(struct ctl_scsiio *ctsio, + struct ctl_page_index *page_index, uint8_t *page_ptr); int ctl_control_page_handler(struct ctl_scsiio *ctsio, struct ctl_page_index *page_index, uint8_t *page_ptr); diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index 1fe4874a0f76..0ae8ecb1eb10 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -203,7 +203,6 @@ struct ctl_be_block_io { struct ctl_sg_entry sg_segs[CTLBLK_MAX_SEGS]; struct iovec xiovecs[CTLBLK_MAX_SEGS]; int bio_cmd; - int bio_flags; int num_segs; int num_bios_sent; int num_bios_done; @@ -599,7 +598,11 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, file_data = &be_lun->backend.file; io = beio->io; - flags = beio->bio_flags; + flags = 0; + if (ARGS(io)->flags & CTL_LLF_DPO) + flags |= IO_DIRECT; + if (beio->bio_cmd == BIO_WRITE && ARGS(io)->flags & CTL_LLF_FUA) + flags |= IO_SYNC; bzero(&xuio, sizeof(xuio)); if (beio->bio_cmd == BIO_READ) { @@ -649,8 +652,7 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, * So, to attempt to provide some barrier semantics in the * BIO_ORDERED case, set both IO_DIRECT and IO_SYNC. */ - error = VOP_READ(be_lun->vn, &xuio, (flags & BIO_ORDERED) ? - (IO_DIRECT|IO_SYNC) : 0, file_data->cred); + error = VOP_READ(be_lun->vn, &xuio, flags, file_data->cred); VOP_UNLOCK(be_lun->vn, 0); SDT_PROBE(cbb, kernel, read, file_done, 0, 0, 0, 0, 0); @@ -687,8 +689,7 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, * So if we've got the BIO_ORDERED flag set, we want * IO_SYNC in either the UFS or ZFS case. */ - error = VOP_WRITE(be_lun->vn, &xuio, (flags & BIO_ORDERED) ? - IO_SYNC : 0, file_data->cred); + error = VOP_WRITE(be_lun->vn, &xuio, flags, file_data->cred); VOP_UNLOCK(be_lun->vn, 0); vn_finished_write(mountpoint); @@ -752,7 +753,11 @@ ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun, dev_data = &be_lun->backend.dev; io = beio->io; - flags = beio->bio_flags; + flags = 0; + if (ARGS(io)->flags & CTL_LLF_DPO) + flags |= IO_DIRECT; + if (beio->bio_cmd == BIO_WRITE && ARGS(io)->flags & CTL_LLF_FUA) + flags |= IO_SYNC; bzero(&xuio, sizeof(xuio)); if (beio->bio_cmd == BIO_READ) { @@ -780,10 +785,10 @@ ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun, mtx_unlock(&be_lun->io_lock); if (beio->bio_cmd == BIO_READ) { - error = (*dev_data->csw->d_read)(dev_data->cdev, &xuio, 0); + error = (*dev_data->csw->d_read)(dev_data->cdev, &xuio, flags); SDT_PROBE(cbb, kernel, read, file_done, 0, 0, 0, 0, 0); } else { - error = (*dev_data->csw->d_write)(dev_data->cdev, &xuio, 0); + error = (*dev_data->csw->d_write)(dev_data->cdev, &xuio, flags); SDT_PROBE(cbb, kernel, write, file_done, 0, 0, 0, 0, 0); } @@ -874,7 +879,6 @@ ctl_be_block_unmap_dev_range(struct ctl_be_block_lun *be_lun, while (len > 0) { bio = g_alloc_bio(); bio->bio_cmd = BIO_DELETE; - bio->bio_flags |= beio->bio_flags; bio->bio_dev = dev_data->cdev; bio->bio_offset = off; bio->bio_length = MIN(len, maxlen); @@ -973,7 +977,6 @@ ctl_be_block_dispatch_dev(struct ctl_be_block_lun *be_lun, KASSERT(bio != NULL, ("g_alloc_bio() failed!\n")); bio->bio_cmd = beio->bio_cmd; - bio->bio_flags |= beio->bio_flags; bio->bio_dev = dev_data->cdev; bio->bio_caller1 = beio; bio->bio_length = min(cur_size, max_iosize); @@ -1039,7 +1042,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_be_block_lun *be_lun, softc = be_lun->softc; lbalen = ARGS(beio->io); - if (lbalen->flags & ~(SWS_LBDATA | SWS_UNMAP | SWS_ANCHOR) || + if (lbalen->flags & ~(SWS_LBDATA | SWS_UNMAP | SWS_ANCHOR | SWS_NDOB) || (lbalen->flags & (SWS_UNMAP | SWS_ANCHOR) && be_lun->unmap == NULL)) { ctl_free_beio(beio); ctl_set_invalid_field(&io->scsiio, @@ -1052,15 +1055,6 @@ ctl_be_block_cw_dispatch_ws(struct ctl_be_block_lun *be_lun, return; } - /* - * If the I/O came down with an ordered or head of queue tag, set - * the BIO_ORDERED attribute. For head of queue tags, that's - * pretty much the best we can do. - */ - if ((io->scsiio.tag_type == CTL_TAG_ORDERED) - || (io->scsiio.tag_type == CTL_TAG_HEAD_OF_QUEUE)) - beio->bio_flags = BIO_ORDERED; - switch (io->scsiio.tag_type) { case CTL_TAG_ORDERED: beio->ds_tag_type = DEVSTAT_TAG_ORDERED; @@ -1158,15 +1152,6 @@ ctl_be_block_cw_dispatch_unmap(struct ctl_be_block_lun *be_lun, return; } - /* - * If the I/O came down with an ordered or head of queue tag, set - * the BIO_ORDERED attribute. For head of queue tags, that's - * pretty much the best we can do. - */ - if ((io->scsiio.tag_type == CTL_TAG_ORDERED) - || (io->scsiio.tag_type == CTL_TAG_HEAD_OF_QUEUE)) - beio->bio_flags = BIO_ORDERED; - switch (io->scsiio.tag_type) { case CTL_TAG_ORDERED: beio->ds_tag_type = DEVSTAT_TAG_ORDERED; @@ -1305,20 +1290,6 @@ ctl_be_block_dispatch(struct ctl_be_block_lun *be_lun, bptrlen = PRIV(io); bptrlen->ptr = (void *)beio; - /* - * If the I/O came down with an ordered or head of queue tag, set - * the BIO_ORDERED attribute. For head of queue tags, that's - * pretty much the best we can do. - * - * XXX KDM we don't have a great way to easily know about the FUA - * bit right now (it is decoded in ctl_read_write(), but we don't - * pass that knowledge to the backend), and in any case we would - * need to determine how to handle it. - */ - if ((io->scsiio.tag_type == CTL_TAG_ORDERED) - || (io->scsiio.tag_type == CTL_TAG_HEAD_OF_QUEUE)) - beio->bio_flags = BIO_ORDERED; - switch (io->scsiio.tag_type) { case CTL_TAG_ORDERED: beio->ds_tag_type = DEVSTAT_TAG_ORDERED; @@ -2307,7 +2278,9 @@ ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun, if (params->lun_size_bytes != 0) { be_lun->size_bytes = params->lun_size_bytes; } else { + vn_lock(be_lun->vn, LK_SHARED | LK_RETRY); error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred); + VOP_UNLOCK(be_lun->vn, 0); if (error != 0) { snprintf(req->error_str, sizeof(req->error_str), "error calling VOP_GETATTR() for file %s", @@ -2325,24 +2298,22 @@ static int ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) { - struct cdev *dev; - struct cdevsw *devsw; + struct ctl_be_block_devdata *dev_data; int error; struct ctl_lun_modify_params *params; uint64_t size_bytes; params = &req->reqdata.modify; - dev = be_lun->vn->v_rdev; - devsw = dev->si_devsw; - if (!devsw->d_ioctl) { + dev_data = &be_lun->backend.dev; + if (!dev_data->csw->d_ioctl) { snprintf(req->error_str, sizeof(req->error_str), "%s: no d_ioctl for device %s!", __func__, be_lun->dev_path); return (ENODEV); } - error = devsw->d_ioctl(dev, DIOCGMEDIASIZE, + error = dev_data->csw->d_ioctl(dev_data->cdev, DIOCGMEDIASIZE, (caddr_t)&size_bytes, FREAD, curthread); if (error) { @@ -2375,6 +2346,7 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) { struct ctl_lun_modify_params *params; struct ctl_be_block_lun *be_lun; + uint64_t oldsize; int error; params = &req->reqdata.modify; @@ -2405,28 +2377,27 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) } } - vn_lock(be_lun->vn, LK_SHARED | LK_RETRY); - + oldsize = be_lun->size_bytes; if (be_lun->vn->v_type == VREG) error = ctl_be_block_modify_file(be_lun, req); else error = ctl_be_block_modify_dev(be_lun, req); - - VOP_UNLOCK(be_lun->vn, 0); - if (error != 0) goto bailout_error; - be_lun->size_blocks = be_lun->size_bytes >> be_lun->blocksize_shift; + if (be_lun->size_bytes != oldsize) { + be_lun->size_blocks = be_lun->size_bytes >> + be_lun->blocksize_shift; - /* - * The maximum LBA is the size - 1. - * - * XXX: Note that this field is being updated without locking, - * which might cause problems on 32-bit architectures. - */ - be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; - ctl_lun_capacity_changed(&be_lun->ctl_be_lun); + /* + * The maximum LBA is the size - 1. + * + * XXX: Note that this field is being updated without locking, + * which might cause problems on 32-bit architectures. + */ + be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; + ctl_lun_capacity_changed(&be_lun->ctl_be_lun); + } /* Tell the user the exact size we ended up using */ params->lun_size_bytes = be_lun->size_bytes; diff --git a/sys/cam/ctl/ctl_cmd_table.c b/sys/cam/ctl/ctl_cmd_table.c index 6ad90dd36883..eb1b0ee41e2f 100644 --- a/sys/cam/ctl/ctl_cmd_table.c +++ b/sys/cam/ctl/ctl_cmd_table.c @@ -304,7 +304,8 @@ const struct ctl_cmd_entry ctl_cmd_table_84[32] = /* 00 RECEIVE COPY STATUS (LID1) */ {ctl_receive_copy_status_lid1, CTL_SERIDX_RD_CAP, CTL_CMD_FLAG_OK_ON_BOTH | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, 16, {0x00, 0xff, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, @@ -320,14 +321,16 @@ const struct ctl_cmd_entry ctl_cmd_table_84[32] = CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_SECONDARY | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, 16, {0x03, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* 04 RECEIVE COPY FAILURE DETAILS (LID1) */ {ctl_receive_copy_failure_details, CTL_SERIDX_RD_CAP, CTL_CMD_FLAG_OK_ON_BOTH | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, 16, {0x04, 0xff, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, @@ -470,7 +473,8 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] = CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_SECONDARY | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, 12, {0x0c, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, @@ -479,7 +483,8 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] = CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_SECONDARY | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE, 12, {0x0d, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, @@ -631,7 +636,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, - CTL_LUN_PAT_NONE, 6, {0x08, 0xff, 0, 0xff, 0x07}}, + CTL_LUN_PAT_NONE, 6, {0x08, 0xff, 0xff, 0xff, 0x07}}, /* 1B START STOP UNIT */ {ctl_start_stop, CTL_SERIDX_START, CTL_CMD_FLAG_OK_ON_SLUN | @@ -689,7 +694,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_READ | CTL_LUN_PAT_RANGE, - 10, {0x18, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}}, + 10, {0x1a, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}}, /* 29 READ GENERATION */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -697,7 +702,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = /* 2A WRITE(10) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 10, {0x18, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}}, + 10, {0x1a, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}}, /* 2B SEEK(10) */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -711,7 +716,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = /* 2E WRITE AND VERIFY(10) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 10, {0x10, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}}, + 10, {0x12, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0x07}}, /* 2F VERIFY(10) */ {ctl_verify, CTL_SERIDX_READ, CTL_CMD_FLAG_OK_ON_SLUN | @@ -885,7 +890,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, - CTL_LUN_PAT_NONE, 10, {0x18, 0xff, 0, 0, 0, 0, 0xff, 0xff, 0x07} }, + CTL_LUN_PAT_NONE, 10, {0x18, 0xff, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} }, /* 5B CLOSE TRACK/SESSION */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -1030,7 +1035,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_read_write, CTL_SERIDX_READ, CTL_CMD_FLAG_OK_ON_SLUN | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_READ | CTL_LUN_PAT_RANGE, - 16, {0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 16, {0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* 89 COMPARE AND WRITE */ @@ -1042,7 +1047,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = /* 8A WRITE(16) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 16, {0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 16, {0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* 8B */ @@ -1057,7 +1062,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = /* 8E WRITE AND VERIFY(16) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 16, {0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 16, {0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* 8F VERIFY(16) */ @@ -1085,7 +1090,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_write_same, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN | CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 16, {0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 16, {0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* 94 */ @@ -1164,7 +1169,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_read_write, CTL_SERIDX_READ, CTL_CMD_FLAG_OK_ON_SLUN | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_READ | CTL_LUN_PAT_RANGE, - 12, {0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + 12, {0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* A9 PLAY TRACK RELATIVE(12) */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -1172,7 +1177,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = /* AA WRITE(12) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 12, {0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + 12, {0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* AB SERVICE ACTION IN(12) */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -1186,7 +1191,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = /* AE WRITE AND VERIFY(12) */ {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT, CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE, - 12, {0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, + 12, {0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* AF VERIFY(12) */ {ctl_verify, CTL_SERIDX_READ, CTL_CMD_FLAG_OK_ON_SLUN | diff --git a/sys/cam/ctl/ctl_error.c b/sys/cam/ctl/ctl_error.c index 6ecb54bee75a..d2edb2a95712 100644 --- a/sys/cam/ctl/ctl_error.c +++ b/sys/cam/ctl/ctl_error.c @@ -367,44 +367,42 @@ ctl_set_ua(struct ctl_scsiio *ctsio, int asc, int ascq) } ctl_ua_type -ctl_build_ua(ctl_ua_type ua_type, struct scsi_sense_data *sense, +ctl_build_ua(ctl_ua_type *ua_type, struct scsi_sense_data *sense, scsi_sense_data_type sense_format) { - ctl_ua_type ua_to_build; - int i, asc, ascq; + ctl_ua_type ua_to_build, ua_to_clear; + int asc, ascq; - if (ua_type == CTL_UA_NONE) - return (ua_type); + if (*ua_type == CTL_UA_NONE) + return (CTL_UA_NONE); - ua_to_build = CTL_UA_NONE; - - for (i = 0; i < (sizeof(ua_type) * 8); i++) { - if (ua_type & (1 << i)) { - ua_to_build = 1 << i; - break; - } - } + ua_to_build = (1 << (ffs(*ua_type) - 1)); + ua_to_clear = ua_to_build; switch (ua_to_build) { case CTL_UA_POWERON: /* 29h/01h POWER ON OCCURRED */ asc = 0x29; ascq = 0x01; + ua_to_clear = ~0; break; case CTL_UA_BUS_RESET: /* 29h/02h SCSI BUS RESET OCCURRED */ asc = 0x29; ascq = 0x02; + ua_to_clear = ~0; break; case CTL_UA_TARG_RESET: /* 29h/03h BUS DEVICE RESET FUNCTION OCCURRED*/ asc = 0x29; ascq = 0x03; + ua_to_clear = ~0; break; case CTL_UA_I_T_NEXUS_LOSS: /* 29h/07h I_T NEXUS LOSS OCCURRED */ asc = 0x29; ascq = 0x07; + ua_to_clear = ~0; break; case CTL_UA_LUN_RESET: /* 29h/00h POWER ON, RESET, OR BUS DEVICE RESET OCCURRED */ @@ -466,9 +464,7 @@ ctl_build_ua(ctl_ua_type ua_type, struct scsi_sense_data *sense, ascq = 0x09; break; default: - ua_to_build = CTL_UA_NONE; - return (ua_to_build); - break; /* NOTREACHED */ + panic("ctl_build_ua: Unknown UA %x", ua_to_build); } ctl_set_sense_data(sense, @@ -480,6 +476,9 @@ ctl_build_ua(ctl_ua_type ua_type, struct scsi_sense_data *sense, ascq, SSD_ELEM_NONE); + /* We're reporting this UA, so clear it */ + *ua_type &= ~ua_to_clear; + return (ua_to_build); } @@ -694,7 +693,7 @@ ctl_set_lun_not_ready(struct ctl_scsiio *ctsio) /*current_error*/ 1, /*sense_key*/ SSD_KEY_NOT_READY, /*asc*/ 0x04, - /*ascq*/ 0x05, + /*ascq*/ 0x03, SSD_ELEM_NONE); } diff --git a/sys/cam/ctl/ctl_error.h b/sys/cam/ctl/ctl_error.h index 62596d0a1a40..034d14bff990 100644 --- a/sys/cam/ctl/ctl_error.h +++ b/sys/cam/ctl/ctl_error.h @@ -55,7 +55,7 @@ void ctl_sense_to_desc(struct scsi_sense_data_fixed *sense_src, void ctl_sense_to_fixed(struct scsi_sense_data_desc *sense_src, struct scsi_sense_data_fixed *sense_dest); void ctl_set_ua(struct ctl_scsiio *ctsio, int asc, int ascq); -ctl_ua_type ctl_build_ua(ctl_ua_type ua_type, struct scsi_sense_data *sense, +ctl_ua_type ctl_build_ua(ctl_ua_type *ua_type, struct scsi_sense_data *sense, scsi_sense_data_type sense_format); void ctl_set_overlapped_cmd(struct ctl_scsiio *ctsio); void ctl_set_overlapped_tag(struct ctl_scsiio *ctsio, uint8_t tag); diff --git a/sys/cam/ctl/ctl_frontend.c b/sys/cam/ctl/ctl_frontend.c index 34b4a9ef5875..8a992cc0ba74 100644 --- a/sys/cam/ctl/ctl_frontend.c +++ b/sys/cam/ctl/ctl_frontend.c @@ -147,9 +147,9 @@ ctl_port_register(struct ctl_port *port, int master_shelf) KASSERT(control_softc != NULL, ("CTL is not initialized")); mtx_lock(&control_softc->ctl_lock); - port_num = ctl_ffz(&control_softc->ctl_port_mask, CTL_MAX_PORTS); + port_num = ctl_ffz(control_softc->ctl_port_mask, CTL_MAX_PORTS); if ((port_num == -1) - || (ctl_set_mask(&control_softc->ctl_port_mask, port_num) == -1)) { + || (ctl_set_mask(control_softc->ctl_port_mask, port_num) == -1)) { port->targ_port = -1; mtx_unlock(&control_softc->ctl_lock); return (1); @@ -183,7 +183,7 @@ ctl_port_register(struct ctl_port *port, int master_shelf) error: port->targ_port = -1; mtx_lock(&control_softc->ctl_lock); - ctl_clear_mask(&control_softc->ctl_port_mask, port_num); + ctl_clear_mask(control_softc->ctl_port_mask, port_num); mtx_unlock(&control_softc->ctl_lock); return (retval); } @@ -223,7 +223,7 @@ ctl_port_deregister(struct ctl_port *port) control_softc->num_ports--; port_num = (port->targ_port < CTL_MAX_PORTS) ? port->targ_port : port->targ_port - CTL_MAX_PORTS; - ctl_clear_mask(&control_softc->ctl_port_mask, port_num); + ctl_clear_mask(control_softc->ctl_port_mask, port_num); control_softc->ctl_ports[port_num] = NULL; mtx_unlock(&control_softc->ctl_lock); diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index d251789eb3ea..85a0667968ba 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -993,7 +993,7 @@ cfiscsi_callout(void *context) #ifdef ICL_KERNEL_PROXY if (cs->cs_waiting_for_ctld || cs->cs_login_phase) { - if (cs->cs_timeout > login_timeout) { + if (login_timeout > 0 && cs->cs_timeout > login_timeout) { CFISCSI_SESSION_WARN(cs, "login timed out after " "%d seconds; dropping connection", cs->cs_timeout); cfiscsi_session_terminate(cs); @@ -1002,6 +1002,19 @@ cfiscsi_callout(void *context) } #endif + if (ping_timeout <= 0) { + /* + * Pings are disabled. Don't send NOP-In in this case; + * user might have disabled pings to work around problems + * with certain initiators that can't properly handle + * NOP-In, such as iPXE. Reset the timeout, to avoid + * triggering reconnection, should the user decide to + * reenable them. + */ + cs->cs_timeout = 0; + return; + } + if (cs->cs_timeout >= ping_timeout) { CFISCSI_SESSION_WARN(cs, "no ping reply (NOP-Out) after %d seconds; " "dropping connection", ping_timeout); @@ -2492,10 +2505,10 @@ cfiscsi_datamove_in(union ctl_io *io) sg_addr += len; sg_len -= len; - KASSERT(buffer_offset + request->ip_data_len <= expected_len, + KASSERT(buffer_offset + response->ip_data_len <= expected_len, ("buffer_offset %zd + ip_data_len %zd > expected_len %zd", - buffer_offset, request->ip_data_len, expected_len)); - if (buffer_offset + request->ip_data_len == expected_len) { + buffer_offset, response->ip_data_len, expected_len)); + if (buffer_offset + response->ip_data_len == expected_len) { /* * Already have the amount of data the initiator wanted. */ diff --git a/sys/cam/ctl/ctl_io.h b/sys/cam/ctl/ctl_io.h index 8f4ab92c330b..c81081734c26 100644 --- a/sys/cam/ctl/ctl_io.h +++ b/sys/cam/ctl/ctl_io.h @@ -139,6 +139,8 @@ struct ctl_lba_len_flags { uint64_t lba; uint32_t len; uint32_t flags; +#define CTL_LLF_FUA 0x04000000 +#define CTL_LLF_DPO 0x08000000 #define CTL_LLF_READ 0x10000000 #define CTL_LLF_WRITE 0x20000000 #define CTL_LLF_VERIFY 0x40000000 diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h index 46527ba015b4..43ee3947434b 100644 --- a/sys/cam/ctl/ctl_private.h +++ b/sys/cam/ctl/ctl_private.h @@ -115,7 +115,9 @@ struct ctl_ioctl_info { typedef enum { CTL_SER_BLOCK, + CTL_SER_BLOCKOPT, CTL_SER_EXTENT, + CTL_SER_EXTENTOPT, CTL_SER_PASS, CTL_SER_SKIP } ctl_serialize_action; @@ -304,7 +306,7 @@ static const struct ctl_page_index page_index_template[] = { {SMS_RIGID_DISK_PAGE, 0, sizeof(struct scsi_rigid_disk_page), NULL, CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, {SMS_CACHING_PAGE, 0, sizeof(struct scsi_caching_page), NULL, - CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, + CTL_PAGE_FLAG_DISK_ONLY, NULL, ctl_caching_sp_handler}, {SMS_CONTROL_MODE_PAGE, 0, sizeof(struct scsi_control_page), NULL, CTL_PAGE_FLAG_NONE, NULL, ctl_control_page_handler}, {SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, PWR_SUBPAGE_CODE, @@ -387,7 +389,6 @@ struct ctl_lun { TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue; STAILQ_ENTRY(ctl_lun) links; STAILQ_ENTRY(ctl_lun) run_links; - struct ctl_nexus rsv_nexus; #ifdef CTL_WITH_CA uint32_t have_ca[CTL_MAX_INITIATORS >> 5]; struct scsi_sense_data pending_sense[CTL_MAX_INITIATORS]; @@ -395,6 +396,7 @@ struct ctl_lun { ctl_ua_type pending_ua[CTL_MAX_INITIATORS]; struct ctl_mode_pages mode_pages; struct ctl_lun_io_stats stats; + uint32_t res_idx; struct ctl_per_res_info per_res[2*CTL_MAX_INITIATORS]; unsigned int PRGeneration; int pr_key_count; @@ -441,9 +443,9 @@ struct ctl_softc { struct ctl_io_pool *othersc_pool; struct proc *ctl_proc; int targ_online; - uint32_t ctl_lun_mask[CTL_MAX_LUNS >> 5]; + uint32_t ctl_lun_mask[(CTL_MAX_LUNS + 31) / 32]; struct ctl_lun *ctl_luns[CTL_MAX_LUNS]; - uint32_t ctl_port_mask; + uint32_t ctl_port_mask[(CTL_MAX_PORTS + 31) / 32]; uint64_t aps_locked_lun; STAILQ_HEAD(, ctl_lun) lun_list; STAILQ_HEAD(, ctl_be_lun) pending_lun_queue; diff --git a/sys/cam/ctl/ctl_ser_table.c b/sys/cam/ctl/ctl_ser_table.c index 2bf39e6955f9..d3693ce9c194 100644 --- a/sys/cam/ctl/ctl_ser_table.c +++ b/sys/cam/ctl/ctl_ser_table.c @@ -54,17 +54,19 @@ /****************************************************************************/ #define sK CTL_SER_SKIP /* Skip */ -#define pS CTL_SER_PASS /* pS */ +#define pS CTL_SER_PASS /* Pass */ #define bK CTL_SER_BLOCK /* Blocked */ +#define bO CTL_SER_BLOCKOPT /* Optional block */ #define xT CTL_SER_EXTENT /* Extent check */ +#define xO CTL_SER_EXTENTOPT /* Optional extent check */ static ctl_serialize_action ctl_serialize_table[CTL_SERIDX_COUNT][CTL_SERIDX_COUNT] = { /**>IDX_ :: 2nd:TUR RD WRT UNM MDSN MDSL RQSN INQ RDCP RES LSNS FMT STR*/ /*TUR */{ pS, pS, pS, pS, bK, bK, bK, pS, pS, bK, pS, bK, bK}, -/*READ */{ pS, pS, xT, bK, bK, bK, bK, pS, pS, bK, pS, bK, bK}, -/*WRITE */{ pS, xT, xT, bK, bK, bK, bK, pS, pS, bK, pS, bK, bK}, -/*UNMAP */{ pS, bK, bK, pS, bK, bK, bK, pS, pS, bK, pS, bK, bK}, +/*READ */{ pS, pS, xT, bO, bK, bK, bK, pS, pS, bK, pS, bK, bK}, +/*WRITE */{ pS, xT, xT, bO, bK, bK, bK, pS, pS, bK, pS, bK, bK}, +/*UNMAP */{ pS, xO, xO, pS, bK, bK, bK, pS, pS, bK, pS, bK, bK}, /*MD_SNS */{ bK, bK, bK, bK, pS, bK, bK, pS, pS, bK, pS, bK, bK}, /*MD_SEL */{ bK, bK, bK, bK, bK, bK, bK, pS, pS, bK, pS, bK, bK}, /*RQ_SNS */{ pS, pS, pS, pS, pS, pS, bK, pS, pS, bK, pS, bK, bK}, diff --git a/sys/cam/ctl/ctl_tpc.c b/sys/cam/ctl/ctl_tpc.c index 4d41005d2e61..60ae8a01347c 100644 --- a/sys/cam/ctl/ctl_tpc.c +++ b/sys/cam/ctl/ctl_tpc.c @@ -1811,6 +1811,8 @@ tpc_create_token(struct ctl_lun *lun, struct ctl_port *port, off_t len, { static int id = 0; struct scsi_vpd_id_descriptor *idd = NULL; + struct scsi_ec_cscd_id *cscd; + struct scsi_read_capacity_data_long *dtsd; int targid_len; scsi_ulto4b(ROD_TYPE_AUR, token->type); @@ -1824,10 +1826,24 @@ tpc_create_token(struct ctl_lun *lun, struct ctl_port *port, off_t len, idd = scsi_get_devid_desc((struct scsi_vpd_id_descriptor *) lun->lun_devid->data, lun->lun_devid->len, scsi_devid_is_lun_eui64); - if (idd != NULL) - memcpy(&token->body[8], idd, 4 + idd->length); - scsi_u64to8b(0, &token->body[40]); + if (idd != NULL) { + cscd = (struct scsi_ec_cscd_id *)&token->body[8]; + cscd->type_code = EC_CSCD_ID; + cscd->luidt_pdt = T_DIRECT; + memcpy(&cscd->codeset, idd, 4 + idd->length); + scsi_ulto3b(lun->be_lun->blocksize, cscd->dtsp.block_length); + } + scsi_u64to8b(0, &token->body[40]); /* XXX: Should be 128bit value. */ scsi_u64to8b(len, &token->body[48]); + + /* ROD token device type specific data (RC16 without first field) */ + dtsd = (struct scsi_read_capacity_data_long *)&token->body[88 - 8]; + scsi_ulto4b(lun->be_lun->blocksize, dtsd->length); + dtsd->prot_lbppbe = lun->be_lun->pblockexp & SRC16_LBPPBE; + scsi_ulto2b(lun->be_lun->pblockoff & SRC16_LALBA_A, dtsd->lalba_lbp); + if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) + dtsd->lalba_lbp[0] |= SRC16_LBPME | SRC16_LBPRZ; + if (port->target_devid) { targid_len = port->target_devid->len; memcpy(&token->body[120], port->target_devid->data, targid_len); @@ -1933,6 +1949,8 @@ ctl_populate_token(struct ctl_scsiio *ctsio) token->range = &data->desc[0]; token->nrange = scsi_2btoul(data->range_descriptor_length) / sizeof(struct scsi_range_desc); + list->cursectors = tpc_ranges_length(token->range, token->nrange); + list->curbytes = (off_t)list->cursectors * lun->be_lun->blocksize; tpc_create_token(lun, port, list->curbytes, (struct scsi_token *)token->token); token->active = 0; @@ -1949,8 +1967,6 @@ ctl_populate_token(struct ctl_scsiio *ctsio) } memcpy(list->res_token, token->token, sizeof(list->res_token)); list->res_token_valid = 1; - list->cursectors = tpc_ranges_length(token->range, token->nrange); - list->curbytes = (off_t)list->cursectors * lun->be_lun->blocksize; list->curseg = 0; list->completed = 1; list->last_active = time_uptime; diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h index 010a4abcd2c0..8eb58fee60bd 100644 --- a/sys/cam/scsi/scsi_all.h +++ b/sys/cam/scsi/scsi_all.h @@ -317,6 +317,7 @@ struct scsi_per_res_cap #define SPRI_ALLOW_2 0x20 #define SPRI_ALLOW_3 0x30 #define SPRI_ALLOW_4 0x40 +#define SPRI_ALLOW_5 0x50 #define SPRI_PTPL_A 0x01 uint8_t type_mask[2]; #define SPRI_TM_WR_EX_AR 0x8000 @@ -1030,6 +1031,7 @@ struct scsi_write_same_16 { uint8_t opcode; uint8_t byte2; +#define SWS_NDOB 0x01 uint8_t addr[8]; uint8_t length[4]; uint8_t group; @@ -1608,11 +1610,11 @@ struct scsi_token { uint8_t type[4]; #define ROD_TYPE_INTERNAL 0x00000000 -#define ROD_TYPE_AUR 0x00001000 -#define ROD_TYPE_PIT_DEF 0x00080000 -#define ROD_TYPE_PIT_VULN 0x00080001 -#define ROD_TYPE_PIT_PERS 0x00080002 -#define ROD_TYPE_PIT_ANY 0x0008FFFF +#define ROD_TYPE_AUR 0x00010000 +#define ROD_TYPE_PIT_DEF 0x00800000 +#define ROD_TYPE_PIT_VULN 0x00800001 +#define ROD_TYPE_PIT_PERS 0x00800002 +#define ROD_TYPE_PIT_ANY 0x0080FFFF #define ROD_TYPE_BLOCK_ZERO 0xFFFF0001 uint8_t reserved[2]; uint8_t length[2]; @@ -2110,6 +2112,76 @@ struct scsi_service_action_in uint8_t control; }; +struct scsi_vpd_extended_inquiry_data +{ + uint8_t device; + uint8_t page_code; +#define SVPD_EXTENDED_INQUIRY_DATA 0x86 + uint8_t reserved; + uint8_t page_length; + uint8_t flags1; +#define SVPD_EID_AM 0xC0 +#define SVPD_EID_SPT 0x38 +#define SVPD_EID_SPT_1 0x00 +#define SVPD_EID_SPT_12 0x08 +#define SVPD_EID_SPT_2 0x10 +#define SVPD_EID_SPT_13 0x18 +#define SVPD_EID_SPT_3 0x20 +#define SVPD_EID_SPT_23 0x28 +#define SVPD_EID_SPT_123 0x38 +#define SVPD_EID_GRD_CHK 0x04 +#define SVPD_EID_APP_CHK 0x02 +#define SVPD_EID_REF_CHK 0x01 + uint8_t flags2; +#define SVPD_EID_UASK_SUP 0x20 +#define SVPD_EID_GROUP_SUP 0x10 +#define SVPD_EID_PRIOR_SUP 0x08 +#define SVPD_EID_HEADSUP 0x04 +#define SVPD_EID_ORDSUP 0x02 +#define SVPD_EID_SIMPSUP 0x01 + uint8_t flags3; +#define SVPD_EID_WU_SUP 0x08 +#define SVPD_EID_CRD_SUP 0x04 +#define SVPD_EID_NV_SUP 0x02 +#define SVPD_EID_V_SUP 0x01 + uint8_t flags4; +#define SVPD_EID_P_I_I_SUP 0x10 +#define SVPD_EID_LUICLT 0x01 + uint8_t flags5; +#define SVPD_EID_R_SUP 0x10 +#define SVPD_EID_CBCS 0x01 + uint8_t flags6; +#define SVPD_EID_MULTI_I_T_FW 0x0F + uint8_t est[2]; + uint8_t flags7; +#define SVPD_EID_POA_SUP 0x80 +#define SVPD_EID_HRA_SUP 0x80 +#define SVPD_EID_VSA_SUP 0x80 + uint8_t max_sense_length; + uint8_t reserved2[50]; +}; + +struct scsi_vpd_mode_page_policy_descr +{ + uint8_t page_code; + uint8_t subpage_code; + uint8_t policy; +#define SVPD_MPP_SHARED 0x00 +#define SVPD_MPP_PORT 0x01 +#define SVPD_MPP_I_T 0x03 +#define SVPD_MPP_MLUS 0x80 + uint8_t reserved; +}; + +struct scsi_vpd_mode_page_policy +{ + uint8_t device; + uint8_t page_code; +#define SVPD_MODE_PAGE_POLICY 0x87 + uint8_t page_length[2]; + struct scsi_vpd_mode_page_policy_descr descr[0]; +}; + struct scsi_diag_page { uint8_t page_code; uint8_t page_specific_flags; diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index a7a79020e086..3793f315e7fc 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -354,9 +354,9 @@ static struct da_quirk_entry da_quirk_table[] = }, { /* - * The STEC 842 sometimes hang on UNMAP. + * The STEC SSDs sometimes hang on UNMAP. */ - {T_DIRECT, SIP_MEDIA_FIXED, "STEC", "S842E800M2", "*"}, + {T_DIRECT, SIP_MEDIA_FIXED, "STEC", "*", "*"}, /*quirks*/ DA_Q_NO_UNMAP }, /* USB mass storage devices supported by umass(4) */ @@ -545,6 +545,13 @@ static struct da_quirk_entry da_quirk_table[] = {T_DIRECT, SIP_MEDIA_REMOVABLE, "TOSHIBA", "TransMemory", "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE }, + { + /* + * PNY USB 3.0 Flash Drives + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "PNY", "USB 3.0 FD*", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE | DA_Q_NO_RC16 + }, { /* * PNY USB Flash keys diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 42b8774fd88a..5677cdde125f 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -1135,6 +1135,7 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) u_int8_t periph_qual; path->device->flags |= CAM_DEV_INQUIRY_DATA_VALID; + scsi_find_quirk(path->device); inq_buf = &path->device->inq_data; periph_qual = SID_QUAL(inq_buf); @@ -1163,8 +1164,6 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) goto out; } - scsi_find_quirk(path->device); - scsi_devise_transport(path); if (path->device->lun_id == 0 && @@ -1192,15 +1191,9 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) xpt_schedule(periph, priority); goto out; } else if (path->device->lun_id == 0 && - SID_ANSI_REV(inq_buf) > SCSI_REV_SPC2 && + SID_ANSI_REV(inq_buf) >= SCSI_REV_SPC2 && (SCSI_QUIRK(path->device)->quirks & CAM_QUIRK_NORPTLUNS) == 0) { - if (path->device->flags & - CAM_DEV_UNCONFIGURED) { - path->device->flags &= - ~CAM_DEV_UNCONFIGURED; - xpt_acquire_device(path->device); - } PROBE_SET_ACTION(softc, PROBE_REPORT_LUNS); periph->path->target->rpl_size = 16; xpt_release_ccb(done_ccb); @@ -1213,10 +1206,13 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) : SF_RETRY_UA, &softc->saved_ccb) == ERESTART) { goto outr; - } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { - /* Don't wedge the queue */ - xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, - /*run_queue*/TRUE); + } else { + if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { + /* Don't wedge the queue */ + xpt_release_devq(done_ccb->ccb_h.path, + /*count*/1, /*run_queue*/TRUE); + } + path->device->flags &= ~CAM_DEV_INQUIRY_DATA_VALID; } /* * If we get to this point, we got an error status back @@ -1308,14 +1304,6 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) tlun, 8); CAM_DEBUG(path, CAM_DEBUG_PROBE, ("lun 0 in position %u\n", idx)); - } else { - /* - * There is no lun 0 in our list. Destroy - * the validity of the inquiry data so we - * bail here and now. - */ - path->device->flags &= - ~CAM_DEV_INQUIRY_DATA_VALID; } } /* @@ -1328,7 +1316,8 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) probe_purge_old(path, lp, softc->flags); lp = NULL; } - if (path->device->flags & CAM_DEV_INQUIRY_DATA_VALID) { + if (path->device->flags & CAM_DEV_INQUIRY_DATA_VALID && + SID_QUAL(&path->device->inq_data) == SID_QUAL_LU_CONNECTED) { struct scsi_inquiry_data *inq_buf; inq_buf = &path->device->inq_data; if (INQ_DATA_TQ_ENABLED(inq_buf)) @@ -1343,6 +1332,8 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) if (lp) { free(lp, M_CAMXPT); } + PROBE_SET_ACTION(softc, PROBE_INVALID); + xpt_release_ccb(done_ccb); break; } case PROBE_MODE_SENSE: @@ -1975,7 +1966,7 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb) struct cam_path *path, *oldpath; scsi_scan_bus_info *scan_info; struct cam_et *target; - struct cam_ed *device; + struct cam_ed *device, *nextdev; int next_target; path_id_t path_id; target_id_t target_id; @@ -1984,18 +1975,10 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb) oldpath = request_ccb->ccb_h.path; status = cam_ccb_status(request_ccb); - /* Reuse the same CCB to query if a device was really found */ scan_info = (scsi_scan_bus_info *)request_ccb->ccb_h.ppriv_ptr0; - xpt_setup_ccb(&request_ccb->ccb_h, request_ccb->ccb_h.path, - request_ccb->ccb_h.pinfo.priority); - request_ccb->ccb_h.func_code = XPT_GDEV_TYPE; - - path_id = request_ccb->ccb_h.path_id; target_id = request_ccb->ccb_h.target_id; lun_id = request_ccb->ccb_h.target_lun; - xpt_action(request_ccb); - target = request_ccb->ccb_h.path->target; next_target = 1; @@ -2068,56 +2051,39 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *request_ccb) } } } else { - mtx_unlock(&target->luns_mtx); - if (request_ccb->ccb_h.status != CAM_REQ_CMP) { - int phl; - - /* - * If we already probed lun 0 successfully, or - * we have additional configured luns on this - * target that might have "gone away", go onto - * the next lun. - */ - /* - * We may touch devices that we don't - * hold references too, so ensure they - * don't disappear out from under us. - * The target above is referenced by the - * path in the request ccb. - */ - phl = 0; - device = TAILQ_FIRST(&target->ed_entries); - if (device != NULL) { - phl = CAN_SRCH_HI_SPARSE(device); - if (device->lun_id == 0) - device = TAILQ_NEXT(device, links); - } - if ((lun_id != 0) || (device != NULL)) { - if (lun_id < (CAM_SCSI2_MAXLUN-1) || phl) { - lun_id++; - next_target = 0; - } - } - if (lun_id == request_ccb->ccb_h.target_lun - || lun_id > scan_info->cpi->max_lun) - next_target = 1; - } else { - + mtx_unlock(&target->luns_mtx); device = request_ccb->ccb_h.path->device; - - if ((SCSI_QUIRK(device)->quirks & - CAM_QUIRK_NOLUNS) == 0) { - /* Try the next lun */ - if (lun_id < (CAM_SCSI2_MAXLUN-1) - || CAN_SRCH_HI_DENSE(device)) { - lun_id++; - next_target = 0; - } - } - if (lun_id == request_ccb->ccb_h.target_lun - || lun_id > scan_info->cpi->max_lun) + /* Continue sequential LUN scan if: */ + /* -- we have more LUNs that need recheck */ + mtx_lock(&target->bus->eb_mtx); + nextdev = device; + while ((nextdev = TAILQ_NEXT(nextdev, links)) != NULL) + if ((nextdev->flags & CAM_DEV_UNCONFIGURED) == 0) + break; + mtx_unlock(&target->bus->eb_mtx); + if (nextdev != NULL) { + next_target = 0; + /* -- stop if CAM_QUIRK_NOLUNS is set. */ + } else if (SCSI_QUIRK(device)->quirks & CAM_QUIRK_NOLUNS) { next_target = 1; - } + /* -- this LUN is connected and its SCSI version + * allows more LUNs. */ + } else if ((device->flags & CAM_DEV_UNCONFIGURED) == 0) { + if (lun_id < (CAM_SCSI2_MAXLUN-1) || + CAN_SRCH_HI_DENSE(device)) + next_target = 0; + /* -- this LUN is disconnected, its SCSI version + * allows more LUNs and we guess they may be. */ + } else if ((device->flags & CAM_DEV_INQUIRY_DATA_VALID) != 0) { + if (lun_id < (CAM_SCSI2_MAXLUN-1) || + CAN_SRCH_HI_SPARSE(device)) + next_target = 0; + } + if (next_target == 0) { + lun_id++; + if (lun_id > scan_info->cpi->max_lun) + next_target = 1; + } } /* diff --git a/sys/cddl/boot/zfs/lz4.c b/sys/cddl/boot/zfs/lz4.c index 78af95942eee..055bd627fd10 100644 --- a/sys/cddl/boot/zfs/lz4.c +++ b/sys/cddl/boot/zfs/lz4.c @@ -82,6 +82,17 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dum */ #endif +/* + * Unaligned memory access is automatically enabled for "common" CPU, + * such as x86. For others CPU, the compiler will be more cautious, and + * insert extra code to ensure aligned access is respected. If you know + * your target CPU supports unaligned memory access, you may want to + * force this option manually to improve performance + */ +#if defined(__ARM_FEATURE_UNALIGNED) +#define LZ4_FORCE_UNALIGNED_ACCESS 1 +#endif + /* * Compiler Options */ @@ -113,6 +124,10 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dum #define S32 int32_t #define U64 uint64_t +#ifndef LZ4_FORCE_UNALIGNED_ACCESS +#pragma pack(1) +#endif + typedef struct _U16_S { U16 v; } U16_S; @@ -123,6 +138,10 @@ typedef struct _U64_S { U64 v; } U64_S; +#ifndef LZ4_FORCE_UNALIGNED_ACCESS +#pragma pack() +#endif + #define A64(x) (((U64_S *)(x))->v) #define A32(x) (((U32_S *)(x))->v) #define A16(x) (((U16_S *)(x))->v) diff --git a/sys/cddl/boot/zfs/zfsimpl.h b/sys/cddl/boot/zfs/zfsimpl.h index 98f54791ae26..5f2e255e7707 100644 --- a/sys/cddl/boot/zfs/zfsimpl.h +++ b/sys/cddl/boot/zfs/zfsimpl.h @@ -840,7 +840,7 @@ struct uberblock { * Fixed constants. */ #define DNODE_SHIFT 9 /* 512 bytes */ -#define DN_MIN_INDBLKSHIFT 10 /* 1k */ +#define DN_MIN_INDBLKSHIFT 12 /* 4k */ #define DN_MAX_INDBLKSHIFT 14 /* 16k */ #define DNODE_BLOCK_SHIFT 14 /* 16k */ #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ diff --git a/lib/libproc/test/t2-name2map/t2-name2map.c b/sys/cddl/compat/opensolaris/kern/opensolaris_dtrace.c similarity index 61% rename from lib/libproc/test/t2-name2map/t2-name2map.c rename to sys/cddl/compat/opensolaris/kern/opensolaris_dtrace.c index 825963d3f504..4d54b53fd4fe 100644 --- a/lib/libproc/test/t2-name2map/t2-name2map.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_dtrace.c @@ -1,46 +1,36 @@ -/* - * Copyright (c) 2010 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Rui Paulo under sponsorship from the - * FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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. +/*- + * Copyright 2014 The FreeBSD Project. + * All rights reserved. * - * $FreeBSD$ + * This software was developed by Steven Hartland. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 -#include -#include -#include +#include +__FBSDID("$FreeBSD$"); -int -main(int argc, char *argv[]) -{ - prmap_t *map = NULL; - struct proc_handle *phdl; +#include +#include +#include - proc_create("./t2-name2map", argv, NULL, NULL, &phdl); - map = proc_name2map(phdl, "ld-elf.so.1"); - assert(map); -} +SDT_PROBE_DEFINE1(sdt, , , set__error, "int"); diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c b/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c index fd8798d2e16a..aa2661801cd0 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c @@ -126,42 +126,6 @@ kmem_size_init(void *unused __unused) } SYSINIT(kmem_size_init, SI_SUB_KMEM, SI_ORDER_ANY, kmem_size_init, NULL); -/* - * The return values from kmem_free_* are only valid once the pagedaemon - * has been initialised, before then they return 0. - * - * To ensure the returns are valid the caller can use a SYSINIT with - * subsystem set to SI_SUB_KTHREAD_PAGE and an order of at least - * SI_ORDER_SECOND. - */ -u_int -kmem_free_target(void) -{ - - return (vm_cnt.v_free_target); -} - -u_int -kmem_free_min(void) -{ - - return (vm_cnt.v_free_min); -} - -u_int -kmem_free_count(void) -{ - - return (vm_cnt.v_free_count + vm_cnt.v_cache_count); -} - -u_int -kmem_page_count(void) -{ - - return (vm_cnt.v_page_count); -} - uint64_t kmem_size(void) { @@ -169,13 +133,6 @@ kmem_size(void) return (kmem_size_val); } -uint64_t -kmem_used(void) -{ - - return (vmem_size(kmem_arena, VMEM_ALLOC)); -} - static int kmem_std_constructor(void *mem, int size __unused, void *private, int flags) { diff --git a/sys/cddl/compat/opensolaris/sys/kmem.h b/sys/cddl/compat/opensolaris/sys/kmem.h index 1879ba44a4b3..5616067c1217 100644 --- a/sys/cddl/compat/opensolaris/sys/kmem.h +++ b/sys/cddl/compat/opensolaris/sys/kmem.h @@ -66,17 +66,6 @@ typedef struct kmem_cache { void *zfs_kmem_alloc(size_t size, int kmflags); void zfs_kmem_free(void *buf, size_t size); uint64_t kmem_size(void); -uint64_t kmem_used(void); -u_int kmem_page_count(void); - -/* - * The return values from kmem_free_* are only valid once the pagedaemon - * has been initialised, before then they return 0. - */ -u_int kmem_free_count(void); -u_int kmem_free_target(void); -u_int kmem_free_min(void); - kmem_cache_t *kmem_cache_create(char *name, size_t bufsize, size_t align, int (*constructor)(void *, void *, int), void (*destructor)(void *, void *), void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int cflags); @@ -88,6 +77,9 @@ void kmem_reap(void); int kmem_debugging(void); void *calloc(size_t n, size_t s); +#define freemem (vm_cnt.v_free_count + vm_cnt.v_cache_count) +#define minfree vm_cnt.v_free_min +#define heap_arena kmem_arena #define kmem_alloc(size, kmflags) zfs_kmem_alloc((size), (kmflags)) #define kmem_zalloc(size, kmflags) zfs_kmem_alloc((size), (kmflags) | M_ZERO) #define kmem_free(buf, size) zfs_kmem_free((buf), (size)) diff --git a/sys/cddl/compat/opensolaris/sys/sdt.h b/sys/cddl/compat/opensolaris/sys/sdt.h index 6d05ba9d6199..04e4abba88a9 100644 --- a/sys/cddl/compat/opensolaris/sys/sdt.h +++ b/sys/cddl/compat/opensolaris/sys/sdt.h @@ -31,6 +31,15 @@ #include_next -#define SET_ERROR(err) (err) +#ifdef KDTRACE_HOOKS +SDT_PROBE_DECLARE(sdt, , , set__error); + +#define SET_ERROR(err) \ + ((sdt_sdt___set__error->id ? \ + (*sdt_probe_func)(sdt_sdt___set__error->id, \ + (uintptr_t)err, 0, 0, 0, 0) : 0), err) +#else +#define SET_ERROR(err) (err) +#endif #endif /* _OPENSOLARIS_SYS_SDT_H_ */ diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index 4ae881198372..3eced1aea686 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -138,6 +138,7 @@ #include #include +#include #ifdef illumos #ifndef _KERNEL @@ -201,7 +202,7 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; int zfs_disable_dup_eviction = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ -u_int zfs_arc_free_target = (1 << 19); /* default before pagedaemon init only */ +u_int zfs_arc_free_target = 0; static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS); @@ -210,11 +211,10 @@ static void arc_free_target_init(void *unused __unused) { - zfs_arc_free_target = kmem_free_target(); + zfs_arc_free_target = vm_pageout_wakeup_thresh; } SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY, arc_free_target_init, NULL); -#endif TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit); SYSCTL_DECL(_vfs_zfs); @@ -245,15 +245,16 @@ sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS) if (err != 0 || req->newptr == NULL) return (err); - if (val < kmem_free_min()) + if (val < minfree) return (EINVAL); - if (val > kmem_page_count()) + if (val > vm_cnt.v_page_count) return (EINVAL); zfs_arc_free_target = val; return (0); } +#endif /* * Note that buffers can be in one of 6 states: @@ -1503,23 +1504,6 @@ arc_space_return(uint64_t space, arc_space_type_t type) atomic_add_64(&arc_size, -space); } -void * -arc_data_buf_alloc(uint64_t size) -{ - if (arc_evict_needed(ARC_BUFC_DATA)) - cv_signal(&arc_reclaim_thr_cv); - atomic_add_64(&arc_size, size); - return (zio_data_buf_alloc(size)); -} - -void -arc_data_buf_free(void *buf, uint64_t size) -{ - zio_data_buf_free(buf, size); - ASSERT(arc_size >= size); - atomic_add_64(&arc_size, -size); -} - arc_buf_t * arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type) { @@ -2462,8 +2446,8 @@ arc_shrink(void) if (arc_c > arc_c_min) { uint64_t to_free; - DTRACE_PROBE2(arc__shrink, uint64_t, arc_c, uint64_t, - arc_c_min); + DTRACE_PROBE4(arc__shrink, uint64_t, arc_c, uint64_t, + arc_c_min, uint64_t, arc_p, uint64_t, to_free); #ifdef _KERNEL to_free = arc_c >> arc_shrink_shift; #else @@ -2479,6 +2463,10 @@ arc_shrink(void) arc_c = MAX(arc_size, arc_c_min); if (arc_p > arc_c) arc_p = (arc_c >> 1); + + DTRACE_PROBE2(arc__shrunk, uint64_t, arc_c, uint64_t, + arc_p); + ASSERT(arc_c >= arc_c_min); ASSERT((int64_t)arc_p >= 0); } @@ -2503,18 +2491,13 @@ arc_reclaim_needed(void) return (1); } - if (kmem_free_count() < zfs_arc_free_target) { - DTRACE_PROBE2(arc__reclaim_freetarget, uint64_t, - kmem_free_count(), uint64_t, zfs_arc_free_target); - return (1); - } - /* * Cooperate with pagedaemon when it's time for it to scan * and reclaim some pages. */ - if (vm_paging_needed()) { - DTRACE_PROBE(arc__reclaim_paging); + if (freemem < zfs_arc_free_target) { + DTRACE_PROBE2(arc__reclaim_freemem, uint64_t, + freemem, uint64_t, zfs_arc_free_target); return (1); } @@ -2544,7 +2527,18 @@ arc_reclaim_needed(void) if (availrmem < swapfs_minfree + swapfs_reserve + extra) return (1); -#if defined(__i386) + /* + * Check that we have enough availrmem that memory locking (e.g., via + * mlock(3C) or memcntl(2)) can still succeed. (pages_pp_maximum + * stores the number of pages that cannot be locked; when availrmem + * drops below pages_pp_maximum, page locking mechanisms such as + * page_pp_lock() will fail.) + */ + if (availrmem <= pages_pp_maximum) + return (1); + +#endif /* sun */ +#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC) /* * If we're on an i386 platform, it's possible that we'll exhaust the * kernel heap space before we ever run out of available physical @@ -2556,25 +2550,33 @@ arc_reclaim_needed(void) * heap is allocated. (Or, in the calculation, if less than 1/4th is * free) */ - if (btop(vmem_size(heap_arena, VMEM_FREE)) < - (btop(vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC)) >> 2)) - return (1); -#endif -#else /* sun */ -#ifdef __i386__ - /* i386 has KVA limits that the raw page counts above don't consider */ - if (kmem_used() > (kmem_size() * 3) / 4) { + if (vmem_size(heap_arena, VMEM_FREE) < + (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC) >> 2)) { DTRACE_PROBE2(arc__reclaim_used, uint64_t, - kmem_used(), uint64_t, (kmem_size() * 3) / 4); + vmem_size(heap_arena, VMEM_FREE), uint64_t, + (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC)) >> 2); return (1); } #endif +#ifdef sun + /* + * If zio data pages are being allocated out of a separate heap segment, + * then enforce that the size of available vmem for this arena remains + * above about 1/16th free. + * + * Note: The 1/16th arena free requirement was put in place + * to aggressively evict memory from the arc in order to avoid + * memory fragmentation issues. + */ + if (zio_arena != NULL && + vmem_size(zio_arena, VMEM_FREE) < + (vmem_size(zio_arena, VMEM_ALLOC) >> 4)) + return (1); #endif /* sun */ - -#else +#else /* _KERNEL */ if (spa_get_random(100) == 0) return (1); -#endif +#endif /* _KERNEL */ DTRACE_PROBE(arc__reclaim_no); return (0); @@ -2583,13 +2585,15 @@ arc_reclaim_needed(void) extern kmem_cache_t *zio_buf_cache[]; extern kmem_cache_t *zio_data_buf_cache[]; -static void +static void __noinline arc_kmem_reap_now(arc_reclaim_strategy_t strat) { size_t i; kmem_cache_t *prev_cache = NULL; kmem_cache_t *prev_data_cache = NULL; + extern kmem_cache_t *range_seg_cache; + DTRACE_PROBE(arc__kmem_reap_start); #ifdef _KERNEL if (arc_meta_used >= arc_meta_limit) { /* @@ -2625,6 +2629,17 @@ arc_kmem_reap_now(arc_reclaim_strategy_t strat) } kmem_cache_reap_now(buf_cache); kmem_cache_reap_now(hdr_cache); + kmem_cache_reap_now(range_seg_cache); + +#ifdef sun + /* + * Ask the vmem arena to reclaim unused memory from its + * quantum caches. + */ + if (zio_arena != NULL && strat == ARC_RECLAIM_AGGR) + vmem_qcache_reap(zio_arena); +#endif + DTRACE_PROBE(arc__kmem_reap_end); } static void @@ -2642,6 +2657,7 @@ arc_reclaim_thread(void *dummy __unused) if (arc_no_grow) { if (last_reclaim == ARC_RECLAIM_CONS) { + DTRACE_PROBE(arc__reclaim_aggr_no_grow); last_reclaim = ARC_RECLAIM_AGGR; } else { last_reclaim = ARC_RECLAIM_CONS; @@ -2649,6 +2665,7 @@ arc_reclaim_thread(void *dummy __unused) } else { arc_no_grow = TRUE; last_reclaim = ARC_RECLAIM_AGGR; + DTRACE_PROBE(arc__reclaim_aggr); membar_producer(); } @@ -2753,6 +2770,7 @@ arc_adapt(int bytes, arc_state_t *state) * cache size, increment the target cache size */ if (arc_size > arc_c - (2ULL << SPA_MAXBLOCKSHIFT)) { + DTRACE_PROBE1(arc__inc_adapt, int, bytes); atomic_add_64(&arc_c, (int64_t)bytes); if (arc_c > arc_c_max) arc_c = arc_c_max; @@ -2774,20 +2792,6 @@ arc_evict_needed(arc_buf_contents_t type) if (type == ARC_BUFC_METADATA && arc_meta_used >= arc_meta_limit) return (1); -#ifdef sun -#ifdef _KERNEL - /* - * If zio data pages are being allocated out of a separate heap segment, - * then enforce that the size of available vmem for this area remains - * above about 1/32nd free. - */ - if (type == ARC_BUFC_DATA && zio_arena != NULL && - vmem_size(zio_arena, VMEM_FREE) < - (vmem_size(zio_arena, VMEM_ALLOC) >> 5)) - return (1); -#endif -#endif /* sun */ - if (arc_reclaim_needed()) return (1); @@ -3946,20 +3950,16 @@ static int arc_memory_throttle(uint64_t reserve, uint64_t txg) { #ifdef _KERNEL - uint64_t available_memory = - ptoa((uintmax_t)vm_cnt.v_free_count + vm_cnt.v_cache_count); + uint64_t available_memory = ptob(freemem); static uint64_t page_load = 0; static uint64_t last_txg = 0; -#ifdef sun -#if defined(__i386) +#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC) available_memory = - MIN(available_memory, vmem_size(heap_arena, VMEM_FREE)); + MIN(available_memory, ptob(vmem_size(heap_arena, VMEM_FREE))); #endif -#endif /* sun */ - if (vm_cnt.v_free_count + vm_cnt.v_cache_count > - (uint64_t)physmem * arc_lotsfree_percent / 100) + if (freemem > (uint64_t)physmem * arc_lotsfree_percent / 100) return (0); if (txg > last_txg) { @@ -3972,7 +3972,7 @@ arc_memory_throttle(uint64_t reserve, uint64_t txg) * continue to let page writes occur as quickly as possible. */ if (curproc == pageproc) { - if (page_load > available_memory / 4) + if (page_load > MAX(ptob(minfree), available_memory) / 4) return (SET_ERROR(ERESTART)); /* Note: reserve is inflated, so we deflate */ page_load += reserve / 8; @@ -4000,8 +4000,10 @@ arc_tempreserve_space(uint64_t reserve, uint64_t txg) int error; uint64_t anon_size; - if (reserve > arc_c/4 && !arc_no_grow) + if (reserve > arc_c/4 && !arc_no_grow) { arc_c = MIN(arc_c_max, reserve * 4); + DTRACE_PROBE1(arc__set_reserve, uint64_t, arc_c); + } if (reserve > arc_c) return (SET_ERROR(ENOMEM)); @@ -4055,6 +4057,7 @@ arc_lowmem(void *arg __unused, int howto __unused) mutex_enter(&arc_lowmem_lock); mutex_enter(&arc_reclaim_thr_lock); needfree = 1; + DTRACE_PROBE(arc__needfree); cv_signal(&arc_reclaim_thr_cv); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c index e75ae72f9e9c..b19df1af3967 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c @@ -301,8 +301,10 @@ bpobj_iterate_impl(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx, if (free) { err = bpobj_space(&sublist, &used_before, &comp_before, &uncomp_before); - if (err) + if (err != 0) { + bpobj_close(&sublist); break; + } } err = bpobj_iterate_impl(&sublist, func, arg, tx, free); if (free) { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c index 9102322cb2d2..c9ea6c02a13e 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c @@ -671,6 +671,8 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags) db->db_state == DB_FILL) { ASSERT(db->db_state == DB_READ || (flags & DB_RF_HAVESTRUCT) == 0); + DTRACE_PROBE2(blocked__read, dmu_buf_impl_t *, + db, zio_t *, zio); cv_wait(&db->db_changed, &db->db_mtx); } if (db->db_state == DB_UNCACHED) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c index 55bf895aa883..0b19e76343f0 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c @@ -1948,6 +1948,15 @@ dnode_next_offset(dnode_t *dn, int flags, uint64_t *offset, flags, offset, lvl, blkfill, txg); } + /* + * There's always a "virtual hole" at the end of the object, even + * if all BP's which physically exist are non-holes. + */ + if ((flags & DNODE_FIND_HOLE) && error == ESRCH && txg == 0 && + minlvl == 1 && blkfill == 1 && !(flags & DNODE_FIND_BACKWARDS)) { + error = 0; + } + if (error == 0 && (flags & DNODE_FIND_BACKWARDS ? initial_offset < *offset : initial_offset > *offset)) error = SET_ERROR(ESRCH); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c index ff666b212d5e..2a57aee904fd 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c @@ -684,6 +684,11 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx) return; } + if (dn->dn_next_nlevels[txgoff]) { + dnode_increase_indirection(dn, tx); + dn->dn_next_nlevels[txgoff] = 0; + } + if (dn->dn_next_nblkptr[txgoff]) { /* this should only happen on a realloc */ ASSERT(dn->dn_allocated_txg == tx->tx_txg); @@ -708,11 +713,6 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx) mutex_exit(&dn->dn_mtx); } - if (dn->dn_next_nlevels[txgoff]) { - dnode_increase_indirection(dn, tx); - dn->dn_next_nlevels[txgoff] = 0; - } - dbuf_sync_list(list, tx); if (!DMU_OBJECT_IS_SPECIAL(dn->dn_object)) { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c index a97a10a48621..d013206f11ab 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c @@ -2257,6 +2257,9 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx) dsl_dir_t *odd = NULL; uint64_t oldnext_obj; int64_t delta; +#if defined(__FreeBSD__) && defined(_KERNEL) + char *oldname, *newname; +#endif VERIFY0(promote_hold(ddpa, dp, FTAG)); hds = ddpa->ddpa_clone; @@ -2322,6 +2325,14 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx) dd->dd_phys->dd_clones, origin_head->ds_object, tx)); } +#if defined(__FreeBSD__) && defined(_KERNEL) + /* Take the spa_namespace_lock early so zvol renames don't deadlock. */ + mutex_enter(&spa_namespace_lock); + + oldname = kmem_alloc(MAXPATHLEN, KM_SLEEP); + newname = kmem_alloc(MAXPATHLEN, KM_SLEEP); +#endif + /* move snapshots to this dir */ for (snap = list_head(&ddpa->shared_snaps); snap; snap = list_next(&ddpa->shared_snaps, snap)) { @@ -2356,6 +2367,12 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx) VERIFY0(dsl_dir_hold_obj(dp, dd->dd_object, NULL, ds, &ds->ds_dir)); +#if defined(__FreeBSD__) && defined(_KERNEL) + dsl_dataset_name(ds, newname); + zfsvfs_update_fromname(oldname, newname); + zvol_rename_minors(oldname, newname); +#endif + /* move any clone references */ if (ds->ds_phys->ds_next_clones_obj && spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { @@ -2393,6 +2410,12 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx) ASSERT(!dsl_prop_hascb(ds)); } +#if defined(__FreeBSD__) && defined(_KERNEL) + mutex_exit(&spa_namespace_lock); + + kmem_free(newname, MAXPATHLEN); + kmem_free(oldname, MAXPATHLEN); +#endif /* * Change space accounting. * Note, pa->*usedsnap and dd_used_breakdown[SNAP] will either diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c index ae2420b23963..53371e642294 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c @@ -116,8 +116,8 @@ int zfs_delay_min_dirty_percent = 60; /* * This controls how quickly the delay approaches infinity. - * Larger values cause it to delay less for a given amount of dirty data. - * Therefore larger values will cause there to be more dirty data for a + * Larger values cause it to delay more for a given amount of dirty data. + * Therefore larger values will cause there to be less dirty data for a * given throughput. * * For the smoothest delay, this value should be about 1 billion divided @@ -130,11 +130,6 @@ int zfs_delay_min_dirty_percent = 60; uint64_t zfs_delay_scale = 1000 * 1000 * 1000 / 2000; -/* - * XXX someday maybe turn these into #defines, and you have to tune it on a - * per-pool basis using zfs.conf. - */ - #ifdef __FreeBSD__ extern int zfs_vdev_async_write_active_max_dirty_percent; @@ -150,8 +145,10 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max_max, CTLFLAG_RDTUN, &zfs_dirty_data_max_max, 0, "The absolute cap on dirty_data_max when auto calculating"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, dirty_data_max_percent, CTLFLAG_RDTUN, - &zfs_dirty_data_max_percent, 0, +static int sysctl_zfs_dirty_data_max_percent(SYSCTL_HANDLER_ARGS); +SYSCTL_PROC(_vfs_zfs, OID_AUTO, dirty_data_max_percent, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(int), + sysctl_zfs_dirty_data_max_percent, "I", "The percent of physical memory used to auto calculate dirty_data_max"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_sync, CTLFLAG_RWTUN, @@ -172,6 +169,24 @@ SYSCTL_PROC(_vfs_zfs, OID_AUTO, delay_scale, sysctl_zfs_delay_scale, "QU", "Controls how quickly the delay approaches infinity"); +static int +sysctl_zfs_dirty_data_max_percent(SYSCTL_HANDLER_ARGS) +{ + int val, err; + + val = zfs_dirty_data_max_percent; + err = sysctl_handle_int(oidp, &val, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + + if (val < 0 || val > 100) + return (EINVAL); + + zfs_dirty_data_max_percent = val; + + return (0); +} + static int sysctl_zfs_delay_min_dirty_percent(SYSCTL_HANDLER_ARGS) { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c index daf87eee8ca4..03dc7028864f 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c @@ -90,6 +90,11 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RWTUN, &zfs_no_scrub_prefetch, 0, "Disable scrub prefetching"); enum ddt_class zfs_scrub_ddt_class_max = DDT_CLASS_DUPLICATE; +/* max number of blocks to free in a single TXG */ +uint64_t zfs_free_max_blocks = UINT64_MAX; +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, free_max_blocks, CTLFLAG_RWTUN, + &zfs_free_max_blocks, 0, "Maximum number of blocks to free in one TXG"); + #define DSL_SCAN_IS_SCRUB_RESILVER(scn) \ ((scn)->scn_phys.scn_func == POOL_SCAN_SCRUB || \ @@ -1341,6 +1346,9 @@ dsl_scan_free_should_pause(dsl_scan_t *scn) if (zfs_recover) return (B_FALSE); + if (scn->scn_visited_this_txg >= zfs_free_max_blocks) + return (B_TRUE); + elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time; return (elapsed_nanosecs / NANOSEC > zfs_txg_timeout || (NSEC2MSEC(elapsed_nanosecs) > zfs_free_min_time_ms && diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c index 370556fcfb75..c2bcbfd0ccc7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c @@ -75,7 +75,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, /* * Condensing a metaslab is not guaranteed to actually reduce the amount of * space used on disk. In particular, a space map uses data in increments of - * MAX(1 << ashift, SPACE_MAP_INITIAL_BLOCKSIZE), so a metaslab might use the + * MAX(1 << ashift, space_map_blksize), so a metaslab might use the * same number of blocks after condensing. Since the goal of condensing is to * reduce the number of IOPs required to read the space map, we only want to * condense when we can be sure we will reduce the number of blocks used by the @@ -1470,10 +1470,12 @@ metaslab_fragmentation(metaslab_t *msp) uint64_t txg = spa_syncing_txg(spa); vdev_t *vd = msp->ms_group->mg_vd; - msp->ms_condense_wanted = B_TRUE; - vdev_dirty(vd, VDD_METASLAB, msp, txg + 1); - spa_dbgmsg(spa, "txg %llu, requesting force condense: " - "msp %p, vd %p", txg, msp, vd); + if (spa_writeable(spa)) { + msp->ms_condense_wanted = B_TRUE; + vdev_dirty(vd, VDD_METASLAB, msp, txg + 1); + spa_dbgmsg(spa, "txg %llu, requesting force condense: " + "msp %p, vd %p", txg, msp, vd); + } return (ZFS_FRAG_INVALID); } @@ -1917,6 +1919,15 @@ metaslab_sync(metaslab_t *msp, uint64_t txg) mutex_enter(&msp->ms_lock); + /* + * Note: metaslab_condense() clears the space_map's histogram. + * Therefore we must verify and remove this histogram before + * condensing. + */ + metaslab_group_histogram_verify(mg); + metaslab_class_histogram_verify(mg->mg_class); + metaslab_group_histogram_remove(mg, msp); + if (msp->ms_loaded && spa_sync_pass(spa) == 1 && metaslab_should_condense(msp)) { metaslab_condense(msp, txg, tx); @@ -1925,9 +1936,6 @@ metaslab_sync(metaslab_t *msp, uint64_t txg) space_map_write(msp->ms_sm, *freetree, SM_FREE, tx); } - metaslab_group_histogram_verify(mg); - metaslab_class_histogram_verify(mg->mg_class); - metaslab_group_histogram_remove(mg, msp); if (msp->ms_loaded) { /* * When the space map is loaded, we have an accruate diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c index 22175e06ab30..6422fd1c1fa6 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c @@ -33,7 +33,7 @@ #include #include -static kmem_cache_t *range_seg_cache; +kmem_cache_t *range_seg_cache; void range_tree_init(void) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c index 7d218964270a..0100206645f9 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c @@ -83,16 +83,20 @@ /* Check hostid on import? */ static int check_hostid = 1; -SYSCTL_DECL(_vfs_zfs); -SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RWTUN, &check_hostid, 0, - "Check hostid on import?"); - /* * The interval, in seconds, at which failed configuration cache file writes * should be retried. */ static int zfs_ccw_retry_interval = 300; +SYSCTL_DECL(_vfs_zfs); +SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RWTUN, &check_hostid, 0, + "Check hostid on import?"); +TUNABLE_INT("vfs.zfs.ccw_retry_interval", &zfs_ccw_retry_interval); +SYSCTL_INT(_vfs_zfs, OID_AUTO, ccw_retry_interval, CTLFLAG_RW, + &zfs_ccw_retry_interval, 0, + "Configuration cache file write, retry after failure, interval (seconds)"); + typedef enum zti_modes { ZTI_MODE_FIXED, /* value is # of threads (min 1) */ ZTI_MODE_BATCH, /* cpu-intensive; value is ignored */ diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c index 2ab28473be41..c3a42d026b60 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c @@ -243,9 +243,6 @@ int zfs_flags = ~(ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SPA); #else int zfs_flags = 0; #endif -SYSCTL_DECL(_debug); -SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, - "ZFS debug flags."); /* * zfs_recover can be set to nonzero to attempt to recover from @@ -259,6 +256,32 @@ SYSCTL_DECL(_vfs_zfs); SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, "Try to recover from otherwise-fatal errors."); +static int +sysctl_vfs_zfs_debug_flags(SYSCTL_HANDLER_ARGS) +{ + int err, val; + + val = zfs_flags; + err = sysctl_handle_int(oidp, &val, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + + /* + * ZFS_DEBUG_MODIFY must be enabled prior to boot so all + * arc buffers in the system have the necessary additional + * checksum data. However, it is safe to disable at any + * time. + */ + if (!(zfs_flags & ZFS_DEBUG_MODIFY)) + val &= ~ZFS_DEBUG_MODIFY; + zfs_flags = val; + + return (0); +} +SYSCTL_PROC(_vfs_zfs, OID_AUTO, debug_flags, + CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(int), + sysctl_vfs_zfs_debug_flags, "IU", "Debug flags for ZFS testing."); + /* * If destroy encounters an EIO while reading metadata (e.g. indirect * blocks), space referenced by the missing metadata can not be freed. diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c index d158b246d8c2..94790b9eaee5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c @@ -38,15 +38,12 @@ #include /* - * This value controls how the space map's block size is allowed to grow. - * If the value is set to the same size as SPACE_MAP_INITIAL_BLOCKSIZE then - * the space map block size will remain fixed. Setting this value to something - * greater than SPACE_MAP_INITIAL_BLOCKSIZE will allow the space map to - * increase its block size as needed. To maintain backwards compatibilty the - * space map's block size must be a power of 2 and SPACE_MAP_INITIAL_BLOCKSIZE - * or larger. + * The data for a given space map can be kept on blocks of any size. + * Larger blocks entail fewer i/o operations, but they also cause the + * DMU to keep more data in-core, and also to waste more i/o bandwidth + * when only a few blocks have changed since the last transaction group. */ -int space_map_max_blksz = (1 << 12); +int space_map_blksz = (1 << 12); /* * Load the space map disk into the specified range tree. Segments of maptype @@ -233,58 +230,6 @@ space_map_entries(space_map_t *sm, range_tree_t *rt) return (entries); } -void -space_map_set_blocksize(space_map_t *sm, uint64_t size, dmu_tx_t *tx) -{ - uint32_t blksz; - u_longlong_t blocks; - - ASSERT3U(sm->sm_blksz, !=, 0); - ASSERT3U(space_map_object(sm), !=, 0); - ASSERT(sm->sm_dbuf != NULL); - VERIFY(ISP2(space_map_max_blksz)); - - if (sm->sm_blksz >= space_map_max_blksz) - return; - - /* - * The object contains more than one block so we can't adjust - * its size. - */ - if (sm->sm_phys->smp_objsize > sm->sm_blksz) - return; - - if (size > sm->sm_blksz) { - uint64_t newsz; - - /* - * Older software versions treat space map blocks as fixed - * entities. The DMU is capable of handling different block - * sizes making it possible for us to increase the - * block size and maintain backwards compatibility. The - * caveat is that the new block sizes must be a - * power of 2 so that old software can append to the file, - * adding more blocks. The block size can grow until it - * reaches space_map_max_blksz. - */ - newsz = ISP2(size) ? size : 1ULL << highbit64(size); - if (newsz > space_map_max_blksz) - newsz = space_map_max_blksz; - - VERIFY0(dmu_object_set_blocksize(sm->sm_os, - space_map_object(sm), newsz, 0, tx)); - dmu_object_size_from_db(sm->sm_dbuf, &blksz, &blocks); - - zfs_dbgmsg("txg %llu, spa %s, increasing blksz from %d to %d", - dmu_tx_get_txg(tx), spa_name(dmu_objset_spa(sm->sm_os)), - sm->sm_blksz, blksz); - - VERIFY3U(newsz, ==, blksz); - VERIFY3U(sm->sm_blksz, <, blksz); - sm->sm_blksz = blksz; - } -} - /* * Note: space_map_write() will drop sm_lock across dmu_write() calls. */ @@ -298,7 +243,7 @@ space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype, range_seg_t *rs; uint64_t size, total, rt_space, nodes; uint64_t *entry, *entry_map, *entry_map_end; - uint64_t newsz, expected_entries, actual_entries = 1; + uint64_t expected_entries, actual_entries = 1; ASSERT(MUTEX_HELD(rt->rt_lock)); ASSERT(dsl_pool_sync_context(dmu_objset_pool(os))); @@ -324,13 +269,6 @@ space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype, expected_entries = space_map_entries(sm, rt); - /* - * Calculate the new size for the space map on-disk and see if - * we can grow the block size to accommodate the new size. - */ - newsz = sm->sm_phys->smp_objsize + expected_entries * sizeof (uint64_t); - space_map_set_blocksize(sm, newsz, tx); - entry_map = zio_buf_alloc(sm->sm_blksz); entry_map_end = entry_map + (sm->sm_blksz / sizeof (uint64_t)); entry = entry_map; @@ -457,46 +395,48 @@ space_map_close(space_map_t *sm) kmem_free(sm, sizeof (*sm)); } -static void -space_map_reallocate(space_map_t *sm, dmu_tx_t *tx) -{ - ASSERT(dmu_tx_is_syncing(tx)); - - space_map_free(sm, tx); - dmu_buf_rele(sm->sm_dbuf, sm); - - sm->sm_object = space_map_alloc(sm->sm_os, tx); - VERIFY0(space_map_open_impl(sm)); -} - void space_map_truncate(space_map_t *sm, dmu_tx_t *tx) { objset_t *os = sm->sm_os; spa_t *spa = dmu_objset_spa(os); dmu_object_info_t doi; - int bonuslen; ASSERT(dsl_pool_sync_context(dmu_objset_pool(os))); ASSERT(dmu_tx_is_syncing(tx)); - VERIFY0(dmu_free_range(os, space_map_object(sm), 0, -1ULL, tx)); dmu_object_info_from_db(sm->sm_dbuf, &doi); - if (spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM)) { - bonuslen = sizeof (space_map_phys_t); - ASSERT3U(bonuslen, <=, dmu_bonus_max()); - } else { - bonuslen = SPACE_MAP_SIZE_V0; - } - - if (bonuslen != doi.doi_bonus_size || - doi.doi_data_block_size != SPACE_MAP_INITIAL_BLOCKSIZE) { + /* + * If the space map has the wrong bonus size (because + * SPA_FEATURE_SPACEMAP_HISTOGRAM has recently been enabled), or + * the wrong block size (because space_map_blksz has changed), + * free and re-allocate its object with the updated sizes. + * + * Otherwise, just truncate the current object. + */ + if ((spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM) && + doi.doi_bonus_size != sizeof (space_map_phys_t)) || + doi.doi_data_block_size != space_map_blksz) { zfs_dbgmsg("txg %llu, spa %s, reallocating: " "old bonus %u, old blocksz %u", dmu_tx_get_txg(tx), spa_name(spa), doi.doi_bonus_size, doi.doi_data_block_size); - space_map_reallocate(sm, tx); - VERIFY3U(sm->sm_blksz, ==, SPACE_MAP_INITIAL_BLOCKSIZE); + + space_map_free(sm, tx); + dmu_buf_rele(sm->sm_dbuf, sm); + + sm->sm_object = space_map_alloc(sm->sm_os, tx); + VERIFY0(space_map_open_impl(sm)); + } else { + VERIFY0(dmu_free_range(os, space_map_object(sm), 0, -1ULL, tx)); + + /* + * If the spacemap is reallocated, its histogram + * will be reset. Do the same in the common case so that + * bugs related to the uncommon case do not go unnoticed. + */ + bzero(sm->sm_phys->smp_histogram, + sizeof (sm->sm_phys->smp_histogram)); } dmu_buf_will_dirty(sm->sm_dbuf, tx); @@ -535,7 +475,7 @@ space_map_alloc(objset_t *os, dmu_tx_t *tx) } object = dmu_object_alloc(os, - DMU_OT_SPACE_MAP, SPACE_MAP_INITIAL_BLOCKSIZE, + DMU_OT_SPACE_MAP, space_map_blksz, DMU_OT_SPACE_MAP_HEADER, bonuslen, tx); return (object); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h index 8bf07c3ec8c2..9065a22afd4e 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h @@ -83,8 +83,6 @@ typedef enum arc_space_type { void arc_space_consume(uint64_t space, arc_space_type_t type); void arc_space_return(uint64_t space, arc_space_type_t type); -void *arc_data_buf_alloc(uint64_t space); -void arc_data_buf_free(void *buf, uint64_t space); arc_buf_t *arc_buf_alloc(spa_t *spa, int size, void *tag, arc_buf_contents_t type); arc_buf_t *arc_loan_buf(spa_t *spa, int size); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h index 8a4f3f6185e3..5668af1fef08 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h @@ -56,7 +56,7 @@ extern "C" { * Fixed constants. */ #define DNODE_SHIFT 9 /* 512 bytes */ -#define DN_MIN_INDBLKSHIFT 10 /* 1k */ +#define DN_MIN_INDBLKSHIFT 12 /* 4k */ #define DN_MAX_INDBLKSHIFT 14 /* 16k */ #define DNODE_BLOCK_SHIFT 14 /* 16k */ #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h index 67fa2767b1f8..a59e6d37d43a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h @@ -133,17 +133,6 @@ typedef enum { SM_FREE } maptype_t; -/* - * The data for a given space map can be kept on blocks of any size. - * Larger blocks entail fewer i/o operations, but they also cause the - * DMU to keep more data in-core, and also to waste more i/o bandwidth - * when only a few blocks have changed since the last transaction group. - * Rather than having a fixed block size for all space maps the block size - * can adjust as needed (see space_map_max_blksz). Set the initial block - * size for the space map to 4k. - */ -#define SPACE_MAP_INITIAL_BLOCKSIZE (1ULL << 12) - int space_map_load(space_map_t *sm, range_tree_t *rt, maptype_t maptype); void space_map_histogram_clear(space_map_t *sm); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c index 0c599b172d60..dea1a8fa7bf1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c @@ -155,6 +155,15 @@ static vdev_ops_t *vdev_ops_table[] = { }; +/* + * When a vdev is added, it will be divided into approximately (but no + * more than) this number of metaslabs. + */ +int metaslabs_per_vdev = 200; +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, metaslabs_per_vdev, CTLFLAG_RDTUN, + &metaslabs_per_vdev, 0, + "When a vdev is added, how many metaslabs the vdev should be divided into"); + /* * Given a vdev type, return the appropriate ops vector. */ @@ -1663,9 +1672,9 @@ void vdev_metaslab_set_size(vdev_t *vd) { /* - * Aim for roughly 200 metaslabs per vdev. + * Aim for roughly metaslabs_per_vdev (default 200) metaslabs per vdev. */ - vd->vdev_ms_shift = highbit64(vd->vdev_asize / 200); + vd->vdev_ms_shift = highbit64(vd->vdev_asize / metaslabs_per_vdev); vd->vdev_ms_shift = MAX(vd->vdev_ms_shift, SPA_MAXBLOCKSHIFT); } @@ -1951,12 +1960,15 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done) /* * If the vdev was resilvering and no longer has any - * DTLs then reset its resilvering flag. + * DTLs then reset its resilvering flag and dirty + * the top level so that we persist the change. */ if (vd->vdev_resilver_txg != 0 && range_tree_space(vd->vdev_dtl[DTL_MISSING]) == 0 && - range_tree_space(vd->vdev_dtl[DTL_OUTAGE]) == 0) + range_tree_space(vd->vdev_dtl[DTL_OUTAGE]) == 0) { vd->vdev_resilver_txg = 0; + vdev_config_dirty(vd->vdev_top); + } mutex_exit(&vd->vdev_dtl_lock); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c index 3071d5aa6d2f..395ea29ff187 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c @@ -176,6 +176,21 @@ int zfs_vdev_write_gap_limit = 4 << 10; #ifdef __FreeBSD__ SYSCTL_DECL(_vfs_zfs_vdev); + +static int sysctl_zfs_async_write_active_min_dirty_percent(SYSCTL_HANDLER_ARGS); +SYSCTL_PROC(_vfs_zfs_vdev, OID_AUTO, async_write_active_min_dirty_percent, + CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(int), + sysctl_zfs_async_write_active_min_dirty_percent, "I", + "Percentage of async write dirty data below which " + "async_write_min_active is used."); + +static int sysctl_zfs_async_write_active_max_dirty_percent(SYSCTL_HANDLER_ARGS); +SYSCTL_PROC(_vfs_zfs_vdev, OID_AUTO, async_write_active_max_dirty_percent, + CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(int), + sysctl_zfs_async_write_active_max_dirty_percent, "I", + "Percentage of async write dirty data above which " + "async_write_max_active is used."); + SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RWTUN, &zfs_vdev_max_active, 0, "The maximum number of I/Os of all types active for each device."); @@ -216,6 +231,44 @@ SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RWTUN, SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RWTUN, &zfs_vdev_write_gap_limit, 0, "Acceptable gap between two writes being aggregated"); + +static int +sysctl_zfs_async_write_active_min_dirty_percent(SYSCTL_HANDLER_ARGS) +{ + int val, err; + + val = zfs_vdev_async_write_active_min_dirty_percent; + err = sysctl_handle_int(oidp, &val, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + + if (val < 0 || val > 100 || + val >= zfs_vdev_async_write_active_max_dirty_percent) + return (EINVAL); + + zfs_vdev_async_write_active_min_dirty_percent = val; + + return (0); +} + +static int +sysctl_zfs_async_write_active_max_dirty_percent(SYSCTL_HANDLER_ARGS) +{ + int val, err; + + val = zfs_vdev_async_write_active_max_dirty_percent; + err = sysctl_handle_int(oidp, &val, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + + if (val < 0 || val > 100 || + val <= zfs_vdev_async_write_active_min_dirty_percent) + return (EINVAL); + + zfs_vdev_async_write_active_max_dirty_percent = val; + + return (0); +} #endif int diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index a6246ccc9a85..5f42c79223f5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -3540,6 +3540,7 @@ zfs_destroy_unmount_origin(const char *fsname) static int zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl) { + int error, poollen; nvlist_t *snaps; nvpair_t *pair; boolean_t defer; @@ -3548,9 +3549,25 @@ zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl) return (SET_ERROR(EINVAL)); defer = nvlist_exists(innvl, "defer"); + poollen = strlen(poolname); for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL; pair = nvlist_next_nvpair(snaps, pair)) { - (void) zfs_unmount_snap(nvpair_name(pair)); + const char *name = nvpair_name(pair); + + /* + * The snap must be in the specified pool to prevent the + * invalid removal of zvol minors below. + */ + if (strncmp(name, poolname, poollen) != 0 || + (name[poollen] != '/' && name[poollen] != '@')) + return (SET_ERROR(EXDEV)); + + error = zfs_unmount_snap(name); + if (error != 0) + return (error); +#if defined(__FreeBSD__) + zvol_remove_minors(name); +#endif } return (dsl_destroy_snapshots_nvl(snaps, defer, outnvl)); @@ -3644,7 +3661,6 @@ zfs_ioc_destroy_bookmarks(const char *poolname, nvlist_t *innvl, if (strncmp(name, poolname, poollen) != 0 || (name[poollen] != '/' && name[poollen] != '#')) return (SET_ERROR(EXDEV)); - (void) zvol_remove_minor(name); } error = dsl_bookmark_destroy(innvl, outnvl); @@ -3675,7 +3691,11 @@ zfs_ioc_destroy(zfs_cmd_t *zc) else err = dsl_destroy_head(zc->zc_name); if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0) +#ifdef __FreeBSD__ + zvol_remove_minors(zc->zc_name); +#else (void) zvol_remove_minor(zc->zc_name); +#endif return (err); } diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index d7d5fde35b86..ea17daf81f93 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -870,6 +870,17 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp) int i, error; uint64_t sa_obj; + /* + * XXX: Fix struct statfs so this isn't necessary! + * + * The 'osname' is used as the filesystem's special node, which means + * it must fit in statfs.f_mntfromname, or else it can't be + * enumerated, so libzfs_mnttab_find() returns NULL, which causes + * 'zfs unmount' to think it's not mounted when it is. + */ + if (strlen(osname) >= MNAMELEN) + return (SET_ERROR(ENAMETOOLONG)); + zfsvfs = kmem_zalloc(sizeof (zfsvfs_t), KM_SLEEP); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index 1553a818136d..109a3393d53d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2014 by Delphix. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ @@ -266,16 +266,19 @@ zfs_holey(vnode_t *vp, u_long cmd, offset_t *off) error = dmu_offset_next(zp->z_zfsvfs->z_os, zp->z_id, hole, &noff); - /* end of file? */ - if ((error == ESRCH) || (noff > file_sz)) { - /* - * Handle the virtual hole at the end of file. - */ - if (hole) { - *off = file_sz; - return (0); - } + if (error == ESRCH) return (SET_ERROR(ENXIO)); + + /* + * We could find a hole that begins after the logical end-of-file, + * because dmu_offset_next() only works on whole blocks. If the + * EOF falls mid-block, then indicate that the "virtual hole" + * at the end of the file begins at the logical EOF, rather than + * at the end of the last block. + */ + if (noff > file_sz) { + ASSERT(hole); + noff = file_sz; } if (noff < *off) @@ -2834,6 +2837,7 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr, #endif vap->va_seq = zp->z_seq; vap->va_flags = 0; /* FreeBSD: Reset chflags(2) flags. */ + vap->va_filerev = zp->z_seq; /* * Add in any requested optional attributes and the create time. @@ -5829,7 +5833,6 @@ zfs_freebsd_getpages(ap) vm_page_t *a_m; int a_count; int a_reqpage; - vm_ooffset_t a_offset; } */ *ap; { @@ -5990,7 +5993,6 @@ zfs_freebsd_putpages(ap) int a_count; int a_sync; int *a_rtvals; - vm_ooffset_t a_offset; } */ *ap; { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c index 228e4591d50d..c26e53cea635 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c @@ -644,7 +644,14 @@ zil_claim(const char *osname, void *txarg) error = dmu_objset_own(osname, DMU_OST_ANY, B_FALSE, FTAG, &os); if (error != 0) { - cmn_err(CE_WARN, "can't open objset for %s", osname); + /* + * EBUSY indicates that the objset is inconsistent, in which + * case it can not have a ZIL. + */ + if (error != EBUSY) { + cmn_err(CE_WARN, "can't open objset for %s, error %u", + osname, error); + } return (0); } diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c index 056efd8a82ec..f56efe8118a7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c @@ -167,6 +167,14 @@ static LIST_HEAD(, zvol_state) all_zvols; */ int zvol_maxphys = DMU_MAX_ACCESS/2; +/* + * Toggle unmap functionality. + */ +boolean_t zvol_unmap_enabled = B_TRUE; +SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, unmap_enabled, CTLFLAG_RWTUN, + &zvol_unmap_enabled, 0, + "Enable UNMAP functionality"); + static d_open_t zvol_d_open; static d_close_t zvol_d_close; static d_read_t zvol_read; @@ -882,7 +890,8 @@ zvol_remove_minors(const char *name) LIST_FOREACH_SAFE(zv, &all_zvols, zv_links, tzv) { if (strcmp(zv->zv_name, name) == 0 || (strncmp(zv->zv_name, name, namelen) == 0 && - zv->zv_name[namelen] == '/')) { + strlen(zv->zv_name) > namelen && (zv->zv_name[namelen] == '/' || + zv->zv_name[namelen] == '@'))) { (void) zvol_remove_zv(zv); } } @@ -1633,7 +1642,7 @@ zvol_write(struct cdev *dev, struct uio *uio, int ioflag) #ifdef sun sync = !(zv->zv_flags & ZVOL_WCE) || #else - sync = + sync = (ioflag & IO_SYNC) || #endif (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS); @@ -1970,6 +1979,9 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) dkioc_free_t df; dmu_tx_t *tx; + if (!zvol_unmap_enabled) + break; + if (ddi_copyin((void *)arg, &df, sizeof (df), flag)) { error = SET_ERROR(EFAULT); break; @@ -1982,8 +1994,8 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) */ if (df.df_start >= zv->zv_volsize) break; /* No need to do anything... */ - if (df.df_start + df.df_length > zv->zv_volsize) - df.df_length = DMU_OBJECT_END; + + mutex_exit(&spa_namespace_lock); rl = zfs_range_lock(&zv->zv_znode, df.df_start, df.df_length, RL_WRITER); @@ -2022,7 +2034,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) dmu_objset_pool(zv->zv_objset), 0); } } - break; + return (error); } default: @@ -2570,9 +2582,10 @@ zvol_create_minors(const char *name) if (dmu_objset_type(os) == DMU_OST_ZVOL) { dsl_dataset_long_hold(os->os_dsl_dataset, FTAG); dsl_pool_rele(dmu_objset_pool(os), FTAG); - if ((error = zvol_create_minor(name)) == 0) + error = zvol_create_minor(name); + if (error == 0 || error == EEXIST) { error = zvol_create_snapshots(os, name); - else { + } else { printf("ZFS WARNING: Unable to create ZVOL %s (error=%d).\n", name, error); } @@ -2673,12 +2686,17 @@ zvol_rename_minors(const char *oldname, const char *newname) size_t oldnamelen, newnamelen; zvol_state_t *zv; char *namebuf; + boolean_t locked = B_FALSE; oldnamelen = strlen(oldname); newnamelen = strlen(newname); DROP_GIANT(); - mutex_enter(&spa_namespace_lock); + /* See comment in zvol_open(). */ + if (!MUTEX_HELD(&spa_namespace_lock)) { + mutex_enter(&spa_namespace_lock); + locked = B_TRUE; + } LIST_FOREACH(zv, &all_zvols, zv_links) { if (strcmp(zv->zv_name, oldname) == 0) { @@ -2693,7 +2711,8 @@ zvol_rename_minors(const char *oldname, const char *newname) } } - mutex_exit(&spa_namespace_lock); + if (locked) + mutex_exit(&spa_namespace_lock); PICKUP_GIANT(); } @@ -2807,6 +2826,9 @@ zvol_d_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct threa zil_commit(zv->zv_zilog, ZVOL_OBJ); break; case DIOCGDELETE: + if (!zvol_unmap_enabled) + break; + offset = ((off_t *)data)[0]; length = ((off_t *)data)[1]; if ((offset % DEV_BSIZE) != 0 || (length % DEV_BSIZE) != 0 || diff --git a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c index b7edca5acf32..d35bf773eb23 100644 --- a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c @@ -52,9 +52,103 @@ /* Offset to LR Save word (ppc64). CR Save area sits between back chain and LR */ #define RETURN_OFFSET64 16 +#ifdef __powerpc64__ +#define OFFSET 4 /* Account for the TOC reload slot */ +#else +#define OFFSET 0 +#endif + #define INKERNEL(x) ((x) <= VM_MAX_KERNEL_ADDRESS && \ (x) >= VM_MIN_KERNEL_ADDRESS) +static __inline int +dtrace_sp_inkernel(uintptr_t sp, int aframes) +{ + vm_offset_t callpc; + +#ifdef __powerpc64__ + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64); +#else + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET); +#endif + if ((callpc & 3) || (callpc < 0x100)) + return (0); + + /* + * trapexit() and asttrapexit() are sentinels + * for kernel stack tracing. + * + * Special-case this for 'aframes == 0', because fbt sets aframes to the + * trap callchain depth, so we want to break out of it. + */ + if ((callpc + OFFSET == (vm_offset_t) &trapexit || + callpc + OFFSET == (vm_offset_t) &asttrapexit) && + aframes != 0) + return (0); + + return (1); +} + +static __inline uintptr_t +dtrace_next_sp(uintptr_t sp) +{ + vm_offset_t callpc; + +#ifdef __powerpc64__ + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64); +#else + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET); +#endif + + /* + * trapexit() and asttrapexit() are sentinels + * for kernel stack tracing. + * + * Special-case this for 'aframes == 0', because fbt sets aframes to the + * trap callchain depth, so we want to break out of it. + */ + if ((callpc + OFFSET == (vm_offset_t) &trapexit || + callpc + OFFSET == (vm_offset_t) &asttrapexit)) + /* Access the trap frame */ +#ifdef __powerpc64__ + return (*(uintptr_t *)sp + 48 + sizeof(register_t)); +#else + return (*(uintptr_t *)sp + 8 + sizeof(register_t)); +#endif + + return (*(uintptr_t*)sp); +} + +static __inline uintptr_t +dtrace_get_pc(uintptr_t sp) +{ + vm_offset_t callpc; + +#ifdef __powerpc64__ + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64); +#else + callpc = *(vm_offset_t *)(sp + RETURN_OFFSET); +#endif + + /* + * trapexit() and asttrapexit() are sentinels + * for kernel stack tracing. + * + * Special-case this for 'aframes == 0', because fbt sets aframes to the + * trap callchain depth, so we want to break out of it. + */ + if ((callpc + OFFSET == (vm_offset_t) &trapexit || + callpc + OFFSET == (vm_offset_t) &asttrapexit)) + /* Access the trap frame */ +#ifdef __powerpc64__ + return (*(uintptr_t *)sp + 48 + offsetof(struct trapframe, lr)); +#else + return (*(uintptr_t *)sp + 8 + offsetof(struct trapframe, lr)); +#endif + + return (callpc); +} + greg_t dtrace_getfp(void) { @@ -66,10 +160,11 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, uint32_t *intrpc) { int depth = 0; - register_t sp; + uintptr_t osp, sp; vm_offset_t callpc; pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; + osp = PAGE_SIZE; if (intrpc != 0) pcstack[depth++] = (pc_t) intrpc; @@ -78,17 +173,12 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, sp = dtrace_getfp(); while (depth < pcstack_limit) { - if (!INKERNEL((long) sp)) + if (sp <= osp) break; -#ifdef __powerpc64__ - callpc = *(uintptr_t *)(sp + RETURN_OFFSET64); -#else - callpc = *(uintptr_t *)(sp + RETURN_OFFSET); -#endif - - if (!INKERNEL(callpc)) + if (!dtrace_sp_inkernel(sp, aframes)) break; + callpc = dtrace_get_pc(sp); if (aframes > 0) { aframes--; @@ -100,7 +190,8 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, pcstack[depth++] = callpc; } - sp = *(uintptr_t*)sp; + osp = sp; + sp = dtrace_next_sp(sp); } for (; depth < pcstack_limit; depth++) { @@ -368,8 +459,11 @@ dtrace_getarg(int arg, int aframes) * On ppc32 AIM, and booke, trapexit() is the immediately following * label. On ppc64 AIM trapexit() follows a nop. */ - if (((long)(fp[1]) == (long)trapexit) || - (((long)(fp[1]) + 4 == (long)trapexit))) { +#ifdef __powerpc64__ + if ((long)(fp[2]) + 4 == (long)trapexit) { +#else + if ((long)(fp[1]) == (long)trapexit) { +#endif /* * In the case of powerpc, we will use the pointer to the regs * structure that was pushed when we took the trap. To get this @@ -433,23 +527,31 @@ int dtrace_getstackdepth(int aframes) { int depth = 0; - register_t sp; + uintptr_t osp, sp; + vm_offset_t callpc; + osp = PAGE_SIZE; aframes++; sp = dtrace_getfp(); depth++; for(;;) { - if (!INKERNEL((long) sp)) + if (sp <= osp) break; - if (!INKERNEL((long) *(void **)sp)) + + if (!dtrace_sp_inkernel(sp, aframes)) break; - depth++; + + if (aframes == 0) + depth++; + else + aframes--; + osp = sp; sp = *(uintptr_t *)sp; } if (depth < aframes) - return 0; - else - return depth - aframes; + return (0); + + return (depth); } ulong_t diff --git a/sys/cddl/dev/fbt/powerpc/fbt_isa.c b/sys/cddl/dev/fbt/powerpc/fbt_isa.c index b862f8a773fe..f10ff7bb6f2f 100644 --- a/sys/cddl/dev/fbt/powerpc/fbt_isa.c +++ b/sys/cddl/dev/fbt/powerpc/fbt_isa.c @@ -147,7 +147,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx, fbt = malloc(sizeof (fbt_probe_t), M_FBT, M_WAITOK | M_ZERO); fbt->fbtp_name = name; fbt->fbtp_id = dtrace_probe_create(fbt_id, modname, - name, FBT_ENTRY, 3, fbt); + name, FBT_ENTRY, 7, fbt); fbt->fbtp_patchpoint = instr; fbt->fbtp_ctl = lf; fbt->fbtp_loadcnt = lf->loadcnt; @@ -210,7 +210,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx, if (retfbt == NULL) { fbt->fbtp_id = dtrace_probe_create(fbt_id, modname, - name, FBT_RETURN, 5, fbt); + name, FBT_RETURN, 7, fbt); } else { retfbt->fbtp_next = fbt; fbt->fbtp_id = retfbt->fbtp_id; diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index fb8736cacf2d..d909a71ff270 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2984,7 +2984,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_procctl_args *uap) int freebsd32_fcntl(struct thread *td, struct freebsd32_fcntl_args *uap) { - intptr_t tmp; + long tmp; switch (uap->cmd) { /* @@ -3003,5 +3003,5 @@ freebsd32_fcntl(struct thread *td, struct freebsd32_fcntl_args *uap) tmp = uap->arg; break; } - return (kern_fcntl(td, uap->fd, uap->cmd, tmp)); + return (kern_fcntl_freebsd(td, uap->fd, uap->cmd, tmp)); } diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 7293a28d5846..92ecb2f308a0 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1139,26 +1139,26 @@ linprocfs_donetdev(PFS_FILL_ARGS) linux_ifname(ifp, ifname, sizeof ifname); sbuf_printf(sb, "%6.6s: ", ifname); sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ", - (uintmax_t )ifp->if_ibytes, /* rx_bytes */ - (uintmax_t )ifp->if_ipackets, /* rx_packets */ - (uintmax_t )ifp->if_ierrors, /* rx_errors */ - (uintmax_t )ifp->if_iqdrops, /* rx_dropped + - * rx_missed_errors */ + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IBYTES), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IERRORS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IQDROPS), + /* rx_missed_errors */ 0UL, /* rx_fifo_errors */ 0UL, /* rx_length_errors + * rx_over_errors + * rx_crc_errors + * rx_frame_errors */ 0UL, /* rx_compressed */ - (uintmax_t )ifp->if_imcasts); /* multicast, - * XXX-BZ rx only? */ - sbuf_printf(sb, "%8ju %7ju %4ju %4lu %4lu %5ju %7lu %10lu\n", - (uintmax_t )ifp->if_obytes, /* tx_bytes */ - (uintmax_t )ifp->if_opackets, /* tx_packets */ - (uintmax_t )ifp->if_oerrors, /* tx_errors */ - 0UL, /* tx_dropped */ + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IMCASTS)); + /* XXX-BZ rx only? */ + sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n", + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OBYTES), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OERRORS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OQDROPS), 0UL, /* tx_fifo_errors */ - (uintmax_t )ifp->if_collisions, /* collisions */ + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_COLLISIONS), 0UL, /* tx_carrier_errors + * tx_aborted_errors + * tx_window_errors + diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 77feed0870ee..0148fec97be5 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -1699,13 +1699,6 @@ linux_ioctl_vfat(struct thread *td, struct linux_ioctl_args *args) * Sound related ioctls */ -struct linux_mixer_info { - char id[16]; - char name[32]; - int modify_counter; - int fillers[10]; -}; - struct linux_old_mixer_info { char id[16]; char name[32]; @@ -1793,12 +1786,8 @@ linux_ioctl_sound(struct thread *td, struct linux_ioctl_args *args) /* Key on encoded length */ switch ((args->cmd >> 16) & 0x1fff) { case 0x005c: { /* SOUND_MIXER_INFO */ - struct linux_mixer_info info; - bzero(&info, sizeof(info)); - strncpy(info.id, "OSS", sizeof(info.id) - 1); - strncpy(info.name, "FreeBSD OSS Mixer", sizeof(info.name) - 1); - copyout(&info, (void *)args->arg, sizeof(info)); - return (0); + args->cmd = SOUND_MIXER_INFO; + return (sys_ioctl(td, (struct ioctl_args *)args)); } case 0x0030: { /* SOUND_OLD_MIXER_INFO */ struct linux_old_mixer_info info; diff --git a/sys/compat/linux/linux_mib.c b/sys/compat/linux/linux_mib.c index 3b75307337db..8f8cb81b48b6 100644 --- a/sys/compat/linux/linux_mib.c +++ b/sys/compat/linux/linux_mib.c @@ -129,9 +129,9 @@ struct linux_prison { static struct linux_prison lprison0 = { .pr_osname = "Linux", - .pr_osrelease = "2.6.16", + .pr_osrelease = "2.6.18", .pr_oss_version = 0x030600, - .pr_osrel = 2006016 + .pr_osrel = 2006018 }; static unsigned linux_osd_jail_slot; diff --git a/sys/compat/linux/linux_timer.c b/sys/compat/linux/linux_timer.c new file mode 100644 index 000000000000..92dae4c67280 --- /dev/null +++ b/sys/compat/linux/linux_timer.c @@ -0,0 +1,182 @@ +/*- + * Copyright (c) 2014 Bjoern A. Zeeb + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249 + * ("MRC2"), as part of the DARPA MRC research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 "opt_compat.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef COMPAT_LINUX32 +#include +#include +#else +#include +#include +#endif +#include + +static int +linux_convert_l_clockid(clockid_t *clock_id) +{ + + switch (*clock_id) { + case LINUX_CLOCK_REALTIME: + *clock_id = CLOCK_REALTIME; + break; + case LINUX_CLOCK_MONOTONIC: + *clock_id = CLOCK_MONOTONIC; + break; + default: + return (EINVAL); + } + + return (0); +} + +static int +linux_convert_l_sigevent(struct l_sigevent *l_sig, struct sigevent *sig) +{ + + CP(*l_sig, *sig, sigev_notify); + switch (l_sig->sigev_notify) { + case L_SIGEV_SIGNAL: + sig->sigev_notify = SIGEV_SIGNAL; + CP(*l_sig, *sig, sigev_signo); + PTRIN_CP(*l_sig, *sig, sigev_value.sival_ptr); + break; + case L_SIGEV_NONE: + sig->sigev_notify = SIGEV_NONE; + break; + case L_SIGEV_THREAD: +#if 0 + /* Seems to not be used anywhere (anymore)? */ + sig->sigev_notify = SIGEV_THREAD; + return (ENOSYS); +#else + return (EINVAL); +#endif + case L_SIGEV_THREAD_ID: + sig->sigev_notify = SIGEV_THREAD_ID; + CP2(*l_sig, *sig, _l_sigev_un._tid, sigev_notify_thread_id); + CP(*l_sig, *sig, sigev_signo); + PTRIN_CP(*l_sig, *sig, sigev_value.sival_ptr); + break; + default: + return (EINVAL); + } + return (0); +} + +int +linux_timer_create(struct thread *td, struct linux_timer_create_args *uap) +{ + struct l_sigevent l_ev; + struct sigevent ev, *evp; + int error, id; + + if (uap->evp == NULL) { + evp = NULL; + } else { + error = copyin(uap->evp, &l_ev, sizeof(l_ev)); + if (error != 0) + return (error); + error = linux_convert_l_sigevent(&l_ev, &ev); + if (error != 0) + return (error); + evp = &ev; + } + error = linux_convert_l_clockid(&uap->clock_id); + if (error != 0) + return (error); + error = kern_ktimer_create(td, uap->clock_id, evp, &id, -1); + if (error == 0) { + error = copyout(&id, uap->timerid, sizeof(int)); + if (error != 0) + kern_ktimer_delete(td, id); + } + return (error); +} + +int +linux_timer_settime(struct thread *td, struct linux_timer_settime_args *uap) +{ + struct l_itimerspec l_val, l_oval; + struct itimerspec val, oval, *ovalp; + int error; + + error = copyin(uap->new, &l_val, sizeof(l_val)); + if (error != 0) + return (error); + ITS_CP(l_val, val); + ovalp = uap->old != NULL ? &oval : NULL; + error = kern_ktimer_settime(td, uap->timerid, uap->flags, &val, ovalp); + if (error == 0 && uap->old != NULL) { + ITS_CP(oval, l_oval); + error = copyout(&l_oval, uap->old, sizeof(l_oval)); + } + return (error); +} + +int +linux_timer_gettime(struct thread *td, struct linux_timer_gettime_args *uap) +{ + struct l_itimerspec l_val; + struct itimerspec val; + int error; + + error = kern_ktimer_gettime(td, uap->timerid, &val); + if (error == 0) { + ITS_CP(val, l_val); + error = copyout(&l_val, uap->setting, sizeof(l_val)); + } + return (error); +} + +int +linux_timer_getoverrun(struct thread *td, struct linux_timer_getoverrun_args *uap) +{ + + return (kern_ktimer_getoverrun(td, uap->timerid)); +} + +int +linux_timer_delete(struct thread *td, struct linux_timer_delete_args *uap) +{ + + return (kern_ktimer_delete(td, uap->timerid)); +} + diff --git a/sys/compat/linux/linux_timer.h b/sys/compat/linux/linux_timer.h new file mode 100644 index 000000000000..4f64ee5fe9cb --- /dev/null +++ b/sys/compat/linux/linux_timer.h @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2014 Bjoern A. Zeeb + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249 + * ("MRC2"), as part of the DARPA MRC research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 _LINUX_TIMER_H +#define _LINUX_TIMER_H + +#ifndef __LINUX_ARCH_SIGEV_PREAMBLE_SIZE +#define __LINUX_ARCH_SIGEV_PREAMBLE_SIZE \ + (sizeof(l_int) * 2 + sizeof(l_sigval_t)) +#endif + +#define LINUX_SIGEV_MAX_SIZE 64 +#define LINUX_SIGEV_PAD_SIZE \ + ((LINUX_SIGEV_MAX_SIZE - __LINUX_ARCH_SIGEV_PREAMBLE_SIZE) / \ + sizeof(l_int)) + +#define LINUX_CLOCK_REALTIME 0 +#define LINUX_CLOCK_MONOTONIC 1 +#define LINUX_CLOCK_PROCESS_CPUTIME_ID 2 +#define LINUX_CLOCK_THREAD_CPUTIME_ID 3 +#define LINUX_CLOCK_MONOTONIC_RAW 4 +#define LINUX_CLOCK_REALTIME_COARSE 5 +#define LINUX_CLOCK_MONOTONIC_COARSE 6 +#define LINUX_CLOCK_BOOTTIME 7 +#define LINUX_CLOCK_REALTIME_ALARM 8 +#define LINUX_CLOCK_BOOTTIME_ALARM 9 +#define LINUX_CLOCK_SGI_CYCLE 10 +#define LINUX_CLOCK_TAI 11 + +#define L_SIGEV_SIGNAL 0 +#define L_SIGEV_NONE 1 +#define L_SIGEV_THREAD 2 +#define L_SIGEV_THREAD_ID 4 + +#define TS_CP(src,dst,fld) do { \ + CP((src).fld,(dst).fld,tv_sec); \ + CP((src).fld,(dst).fld,tv_nsec); \ +} while (0) + +#define ITS_CP(src, dst) do { \ + TS_CP((src), (dst), it_interval); \ + TS_CP((src), (dst), it_value); \ +} while (0) + +struct l_sigevent { + l_sigval_t sigev_value; + l_int sigev_signo; + l_int sigev_notify; + union { + l_int _pad[LINUX_SIGEV_PAD_SIZE]; + l_int _tid; + struct { + l_uintptr_t _function; + l_uintptr_t _attribute; + } _l_sigev_thread; + } _l_sigev_un; +} +#if defined(__amd64__) && defined(COMPAT_LINUX32) +__packed +#endif +; + +struct l_itimerspec { + struct l_timespec it_interval; + struct l_timespec it_value; +}; + +#endif /* _LINUX_TIMER_H */ diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm index 67db55dd6fa6..08e70f30a502 100644 --- a/sys/conf/Makefile.arm +++ b/sys/conf/Makefile.arm @@ -42,11 +42,7 @@ STRIP_FLAGS = -S # We don't support gcc's thump interwork stuff, so disable it CFLAGS.gcc += -mno-thumb-interwork -.if empty(DDB_ENABLED) -.if ${MK_ARM_EABI} == "no" -CFLAGS.gcc += -mno-apcs-frame -.endif -.elif ${MK_ARM_EABI} != "no" +.if !empty(DDB_ENABLED) CFLAGS += -funwind-tables # clang requires us to tell it to emit assembly with unwind information CFLAGS.clang += -mllvm -arm-enable-ehabi diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 62bca5717093..5baa306c99db 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2095,8 +2095,6 @@ device em # Intel Pro/1000 Gigabit Ethernet device igb # Intel Pro/1000 PCIE Gigabit Ethernet device ixgb # Intel Pro/10Gbe PCI-X Ethernet device ixgbe # Intel Pro/10Gbe PCIE Ethernet -device ixl # Intel XL710 40Gbe PCIE Ethernet -device ixlv # Intel XL710 40Gbe VF PCIE Ethernet device le # AMD Am7900 LANCE and Am79C9xx PCnet device mxge # Myricom Myri-10G 10GbE NIC device nxge # Neterion Xframe 10GbE Server/Storage Adapter @@ -2627,9 +2625,8 @@ options NSFBUFS=1024 # Enable extra debugging code for locks. This stores the filename and # line of whatever acquired the lock in the lock itself, and changes a # number of function calls to pass around the relevant data. This is -# not at all useful unless you are debugging lock code. Also note -# that it is likely to break e.g. fstat(1) unless you recompile your -# userland with -DDEBUG_LOCKS as well. +# not at all useful unless you are debugging lock code. Note that +# modules should be recompiled as this option modifies KBI. # options DEBUG_LOCKS diff --git a/sys/conf/files b/sys/conf/files index 4038569cf2d0..c885ecac7266 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -111,6 +111,7 @@ cddl/compat/opensolaris/kern/opensolaris_misc.c optional zfs compile-with "${ 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_dtrace.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}" @@ -254,6 +255,8 @@ 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/common/ahids.c optional acpi acpi_debug +contrib/dev/acpica/common/ahuuids.c optional acpi acpi_debug 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 @@ -264,6 +267,7 @@ 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/dbtest.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 @@ -386,6 +390,7 @@ 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/tbdata.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 @@ -406,6 +411,7 @@ contrib/dev/acpica/components/utilities/uterror.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/uthex.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 @@ -419,6 +425,7 @@ 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/utuuid.c optional acpi acpi_debug 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 @@ -645,6 +652,7 @@ dev/aic7xxx/aic7xxx_pci.c optional ahc pci dev/aic7xxx/aic7xxx_reg_print.c optional ahc ahc_reg_pretty_print dev/alc/if_alc.c optional alc pci dev/ale/if_ale.c optional ale pci +dev/alpm/alpm.c optional alpm 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 @@ -653,6 +661,8 @@ 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/amdpm/amdpm.c optional amdpm pci | nfpm pci +dev/amdsmb/amdsmb.c optional amdsmb pci dev/amr/amr.c optional amr dev/amr/amr_cam.c optional amrp amr dev/amr/amr_disk.c optional amr @@ -1377,9 +1387,11 @@ dev/fatm/if_fatm.c optional fatm pci dev/fb/fbd.c optional fbd | vt dev/fb/fb_if.m standard dev/fb/splash.c optional sc splash -dev/fdt/fdt_clock.c optional fdt -dev/fdt/fdt_clock_if.m optional fdt +dev/fdt/fdt_clock.c optional fdt fdt_clock +dev/fdt/fdt_clock_if.m optional fdt fdt_clock dev/fdt/fdt_common.c optional fdt +dev/fdt/fdt_pinctrl.c optional fdt fdt_pinctrl +dev/fdt/fdt_pinctrl_if.m optional fdt fdt_pinctrl 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/${MACHINE}/${FDT_DTS_FILE}" @@ -1427,26 +1439,6 @@ 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/ixl/if_ixl.c optional ixl inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/if_ixlv.c optional ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/ixlvc.c optional ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/ixl_txrx.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_osdep.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_lan_hmc.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_hmc.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_common.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_nvm.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" -dev/ixl/i40e_adminq.c optional ixl ixlv inet \ - compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ichsmb/ichsmb.c optional ichsmb dev/ichsmb/ichsmb_pci.c optional ichsmb pci dev/ida/ida.c optional ida @@ -1480,6 +1472,7 @@ 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 +dev/intpm/intpm.c optional intpm pci # XXX Work around clang warning, until maintainer approves fix. dev/ips/ips.c optional ips \ compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}" @@ -1777,7 +1770,7 @@ 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" + compile-with "${NORMAL_C} -I$S/dev/ixgbe -DSMP" dev/ixgbe/ixv.c optional ixgbe inet \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" dev/ixgbe/ixgbe_phy.c optional ixgbe inet \ @@ -1962,6 +1955,7 @@ 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/ncr/ncr.c optional ncr pci dev/ncv/ncr53c500.c optional ncv dev/ncv/ncr53c500_pccard.c optional ncv pccard dev/netmap/netmap.c optional netmap @@ -1974,6 +1968,7 @@ dev/netmap/netmap_offloadings.c optional netmap dev/netmap/netmap_pipe.c optional netmap dev/netmap/netmap_vale.c optional netmap # compile-with "${NORMAL_C} -Wconversion -Wextra" +dev/nfsmb/nfsmb.c optional nfsmb pci dev/nge/if_nge.c optional nge dev/nxge/if_nxge.c optional nxge \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" @@ -2149,6 +2144,7 @@ dev/random/hash.c optional random dev/random/rwfile.c optional random dev/rc/rc.c optional rc dev/re/if_re.c optional re +dev/rl/if_rl.c optional rl pci dev/rndtest/rndtest.c optional rndtest dev/rp/rp.c optional rp dev/rp/rp_isa.c optional rp isa @@ -2188,6 +2184,7 @@ 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/smc/if_smc_fdt.c optional smc fdt 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 @@ -2575,7 +2572,7 @@ 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/viapm/viapm.c optional viapm pci dev/vkbd/vkbd.c optional vkbd dev/vr/if_vr.c optional vr pci dev/vt/colors/vt_termcolors.c optional vt @@ -2647,6 +2644,9 @@ dev/xen/netfront/netfront.c optional xen | xenhvm dev/xen/xenpci/xenpci.c optional xenpci dev/xen/timer/timer.c optional xen | xenhvm dev/xen/pvcpu/pvcpu.c optional xen | xenhvm +dev/xen/xenstore/xenstore.c optional xen | xenhvm +dev/xen/xenstore/xenstore_dev.c optional xen | xenhvm +dev/xen/xenstore/xenstored_dev.c optional xen | xenhvm dev/xl/if_xl.c optional xl pci dev/xl/xlphy.c optional xl pci fs/autofs/autofs.c optional autofs @@ -3176,8 +3176,9 @@ libkern/inet_pton.c standard libkern/jenkins_hash.c standard libkern/mcount.c optional profiling-routine libkern/memcchr.c standard -libkern/memchr.c optional fdt +libkern/memchr.c optional fdt | gdb libkern/memcmp.c standard +libkern/memmem.c optional gdb libkern/qsort.c standard libkern/qsort_r.c standard libkern/random.c standard @@ -3791,7 +3792,7 @@ ofed/drivers/net/mlx4/sys_tune.c optional mlx4ib | mlxen \ 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 \ +ofed/drivers/net/mlx4/utils.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 \ @@ -3861,15 +3862,6 @@ opencrypto/cryptodeflate.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 \ - compile-with "${NORMAL_C} -Wno-unused" -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 @@ -3996,8 +3988,6 @@ 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 diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index a42e2522e16c..9e5a2ed86bf2 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -192,6 +192,26 @@ dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux32 +dev/ixl/if_ixl.c optional ixl pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/if_ixlv.c optional ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/ixlvc.c optional ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/ixl_txrx.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_osdep.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_lan_hmc.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_hmc.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_common.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_nvm.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" +dev/ixl/i40e_adminq.c optional ixl pci | ixlv pci \ + compile-with "${NORMAL_C} -I$S/dev/ixl" dev/fdc/fdc.c optional fdc dev/fdc/fdc_acpi.c optional fdc dev/fdc/fdc_isa.c optional fdc isa @@ -223,6 +243,7 @@ dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv +dev/hyperv/utilities/hv_kvp.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv @@ -476,6 +497,7 @@ compat/linux/linux_socket.c optional compat_linux32 compat/linux/linux_stats.c optional compat_linux32 compat/linux/linux_sysctl.c optional compat_linux32 compat/linux/linux_time.c optional compat_linux32 +compat/linux/linux_timer.c optional compat_linux32 compat/linux/linux_uid16.c optional compat_linux32 compat/linux/linux_util.c optional compat_linux32 dev/amr/amr_linux.c optional compat_linux32 amr @@ -560,3 +582,5 @@ x86/xen/pvcpu_enum.c optional xenhvm x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xenhvm x86/xen/xen_nexus.c optional xenhvm +x86/xen/xen_msi.c optional xenhvm +x86/xen/xen_pci.c optional xenhvm diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 1f7c71d443d5..f8c5fc4aaab3 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -49,6 +49,7 @@ arm/arm/stdatomic.c standard \ arm/arm/support.S standard arm/arm/swtch.S standard arm/arm/sys_machdep.c standard +arm/arm/syscall.c standard arm/arm/trap.c standard arm/arm/uio_machdep.c standard arm/arm/undefined.c standard diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index a2f3bff45b08..0e4519dc769f 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -83,6 +83,7 @@ compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux compat/linux/linux_time.c optional compat_linux +compat/linux/linux_timer.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux compat/ndis/kern_ndis.c optional ndisapi pci @@ -215,6 +216,7 @@ dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv +dev/hyperv/utilities/hv_kvp.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv @@ -597,3 +599,4 @@ x86/xen/xen_intr.c optional xen | xenhvm x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xen | xenhvm x86/xen/xen_nexus.c optional xen | xenhvm +x86/xen/xen_msi.c optional xen | xenhvm diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98 index ef7af3fa11ce..be67ce42a261 100644 --- a/sys/conf/files.pc98 +++ b/sys/conf/files.pc98 @@ -55,6 +55,7 @@ compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux compat/linux/linux_time.c optional compat_linux +compat/linux/linux_timer.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux compat/svr4/imgact_svr4.c optional compat_svr4 @@ -88,7 +89,8 @@ dev/agp/agp_via.c optional agp dev/aic/aic_cbus.c optional aic isa dev/ce/ceddk.c optional ce dev/ce/if_ce.c optional ce -dev/ce/tau32-ddk.c optional ce +dev/ce/tau32-ddk.c optional ce \ + compile-with "${NORMAL_C} ${NO_WCONSTANT_CONVERSION}" dev/cp/cpddk.c optional cp dev/cp/if_cp.c optional cp dev/ct/bshw_machdep.c optional ct @@ -97,6 +99,8 @@ dev/ct/ct_isa.c optional ct isa dev/ed/if_ed_cbus.c optional ed isa dev/ed/if_ed_wd80x3.c optional ed isa dev/fb/fb.c optional fb | gdc +dev/fdc/fdc.c optional fdc +dev/fdc/fdc_cbus.c optional fdc isa dev/fe/if_fe_cbus.c optional fe isa dev/hwpmc/hwpmc_amd.c optional hwpmc dev/hwpmc/hwpmc_intel.c optional hwpmc @@ -145,6 +149,7 @@ i386/i386/initcpu.c standard i386/i386/io.c optional io i386/i386/k6_mem.c optional mem i386/i386/locore.s standard no-obj +i386/i386/machdep.c standard i386/i386/mem.c optional mem i386/i386/minidump_machdep.c standard i386/i386/mp_clock.c optional smp @@ -216,8 +221,6 @@ libkern/udivdi3.c standard libkern/umoddi3.c standard pc98/apm/apm_bioscall.S optional apm pc98/cbus/cbus_dma.c optional isa -pc98/cbus/fdc.c optional fdc -pc98/cbus/fdc_cbus.c optional fdc isa pc98/cbus/gdc.c optional gdc pc98/cbus/nmi.c standard pc98/cbus/olpt.c optional olpt @@ -235,12 +238,11 @@ pc98/pc98/busiosubr.c standard pc98/pc98/canbepm.c optional canbepm pc98/pc98/canbus.c optional canbus pc98/pc98/canbus_if.m optional canbus -pc98/pc98/machdep.c standard pc98/pc98/pc98_machdep.c standard # # x86 shared code between IA32, AMD64 and PC98 architectures # -x86/isa/atpic.c optional atpic +x86/isa/atpic.c optional atpic x86/isa/clock.c standard x86/isa/isa.c optional isa x86/pci/pci_bus.c optional pci @@ -258,5 +260,4 @@ x86/x86/mptable_pci.c optional apic pci x86/x86/msi.c optional apic pci x86/x86/nexus.c standard x86/x86/tsc.c standard -x86/x86/tsc.c standard x86/x86/delay.c standard diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index 31555cce53c4..8c7a0baac5d4 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -23,7 +23,6 @@ # src tree. __DEFAULT_YES_OPTIONS = \ - ARM_EABI \ BLUETOOTH \ CDDL \ CRYPT \ diff --git a/sys/conf/options b/sys/conf/options index eff8a120d729..42113c35bd3e 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -363,7 +363,7 @@ SYM_SETUP_PCI_PARITY opt_sym.h #-PCI parity checking SYM_SETUP_MAX_LUN opt_sym.h #-Number of LUNs supported # default:8, range:[1..64] -# Options used only in pci/ncr.c +# Options used only in dev/ncr/* SCSI_NCR_DEBUG opt_ncr.h SCSI_NCR_MAX_SYNC opt_ncr.h SCSI_NCR_MAX_WIDE opt_ncr.h diff --git a/sys/conf/options.pc98 b/sys/conf/options.pc98 index a10737be7672..a19ebd11271b 100644 --- a/sys/conf/options.pc98 +++ b/sys/conf/options.pc98 @@ -31,12 +31,6 @@ KVA_PAGES opt_global.h TIMER_FREQ opt_clock.h -# options for serial support -COM_ESP opt_sio.h -COM_MULTIPORT opt_sio.h -CONSPEED opt_sio.h -GDBSPEED opt_sio.h - CPU_BLUELIGHTNING_3X opt_cpu.h CPU_BLUELIGHTNING_FPU_OP_CACHE opt_cpu.h CPU_BTB_EN opt_cpu.h @@ -67,8 +61,17 @@ I486_CPU opt_global.h I586_CPU opt_global.h I686_CPU opt_global.h +# options for serial support +COM_ESP opt_sio.h +COM_MULTIPORT opt_sio.h +CONSPEED opt_sio.h +GDBSPEED opt_sio.h + GDC +# AGP debugging support +AGP_DEBUG opt_agp.h + # Video spigot SPIGOT_UNSECURE opt_spigot.h @@ -96,7 +99,6 @@ DEV_NPX opt_npx.h # Debugging NPX_DEBUG opt_npx.h -AGP_DEBUG opt_agp.h # BPF just-in-time compiler BPF_JITTER opt_bpf.h diff --git a/sys/contrib/altq/altq/if_altq.h b/sys/contrib/altq/altq/if_altq.h index 9524c45177b3..7c4d1c2795cd 100644 --- a/sys/contrib/altq/altq/if_altq.h +++ b/sys/contrib/altq/altq/if_altq.h @@ -50,7 +50,6 @@ struct ifaltq { struct mbuf *ifq_tail; int ifq_len; int ifq_maxlen; - int ifq_drops; #ifdef __FreeBSD__ struct mtx ifq_mtx; #endif diff --git a/sys/contrib/dev/acpica/acpica_prep.sh b/sys/contrib/dev/acpica/acpica_prep.sh index a6802ef325c7..00c5fa43f290 100755 --- a/sys/contrib/dev/acpica/acpica_prep.sh +++ b/sys/contrib/dev/acpica/acpica_prep.sh @@ -19,9 +19,10 @@ fulldirs="common compiler components include os_specific" # files to remove stripdirs="generate libraries tests tools" stripfiles="Makefile README accygwin.h acefi.h achaiku.h acintel.h \ - aclinux.h acmacosx.h acmsvc.h acnetbsd.h acos2.h acwin.h \ - acwin64.h new_table.txt osfreebsdtbl.c oslinuxtbl.c osunixdir.c \ - osunixmap.c oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c" + aclinux.h aclinuxex.h acmacosx.h acmsvc.h acnetbsd.h acos2.h \ + acwin.h acwin64.h new_table.txt osefitbl.c osefixf.c \ + osfreebsdtbl.c oslinuxtbl.c osunixdir.c osunixmap.c oswindir.c \ + oswintbl.c oswinxf.c readme.txt utclib.c" # include files to canonify src_headers="acapps.h acbuffer.h accommon.h acconfig.h acdebug.h \ @@ -30,8 +31,8 @@ src_headers="acapps.h acbuffer.h accommon.h acconfig.h acdebug.h \ acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h \ acpredef.h acresrc.h acrestyp.h acstruct.h actables.h actbl.h \ actbl1.h actbl2.h actbl3.h actypes.h acutils.h amlcode.h \ - amlresrc.h platform/acenv.h platform/acfreebsd.h \ - platform/acgcc.h" + amlresrc.h platform/acenv.h platform/acenvex.h \ + platform/acfreebsd.h platform/acgcc.h" comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h \ aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h" platform_headers="acfreebsd.h acgcc.h" diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt index ab43358d46f5..1c2b1edbae9c 100644 --- a/sys/contrib/dev/acpica/changes.txt +++ b/sys/contrib/dev/acpica/changes.txt @@ -1,3 +1,920 @@ +---------------------------------------- +26 September 2014. Summary of changes for version 20140926: + +1) ACPICA kernel-resident subsystem: + +Updated the GPIO operation region handler interface (GeneralPurposeIo). +In order to support GPIO Connection objects with multiple pins, along +with the related Field objects, the following changes to the interface +have been made: The Address is now defined to be the offset in bits of +the field unit from the previous invocation of a Connection. It can be +viewed as a "Pin Number Index" into the connection resource descriptor. +The BitWidth is the exact bit width of the field. It is usually one bit, +but not always. See the ACPICA reference guide (section 8.8.6.2.1) for +additional information and examples. + +GPE support: During ACPICA/GPE initialization, ensure that all GPEs with +corresponding _Lxx/_Exx methods are disabled (they may have been enabled +by the firmware), so that they cannot fire until they are enabled via +AcpiUpdateAllGpes. Rafael J. Wysocki. + +Added a new return flag for the Event/GPE status interfaces -- +AcpiGetEventStatus and AcpiGetGpeStatus. The new +ACPI_EVENT_FLAGS_HAS_HANDLER flag is used to indicate that the event or +GPE currently has a handler associated with it, and can thus actually +affect the system. 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. + + Current Release: + Non-Debug Version: 99.1K Code, 27.3K Data, 126.4K Total + Debug Version: 192.8K Code, 79.9K Data, 272.7K Total + Previous Release: + Non-Debug Version: 98.8K Code, 27.3K Data, 126.1K Total + Debug Version: 192.1K Code, 79.8K Data, 271.9K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed a memory allocation/free regression introduced in 20140828 +that could cause the compiler to crash. This was introduced inadvertently +during the effort to eliminate compiler memory leaks. ACPICA BZ 1111, +1113. + +iASL: Removed two error messages that have been found to create false +positives, until they can be fixed and fully validated (ACPICA BZ 1112): +1) Illegal forward reference within a method +2) Illegal reference across two methods + +iASL: Implemented a new option (-lm) to create a hardware mapping file +that summarizes all GPIO, I2C, SPI, and UART connections. This option +works for both the compiler and disassembler. See the iASL compiler user +guide for additional information and examples (section 6.4.6). + +AcpiDump: Added support for the version 1 (ACPI 1.0) RSDP in addition to +version 2. This corrects the AE_BAD_HEADER exception seen on systems with +a version 1 RSDP. Lv Zheng ACPICA BZ 1097. + +AcpiExec: For Unix versions, don't attempt to put STDIN into raw mode +unless STDIN is actually a terminal. Assists with batch-mode processing. +ACPICA BZ 1114. + +Disassembler/AcpiHelp: Added another large group of recognized _HID +values. + + +---------------------------------------- +28 August 2014. Summary of changes for version 20140828: + +1) ACPICA kernel-resident subsystem: + +Fixed a problem related to the internal use of the Timer() operator where +a 64-bit divide could cause an attempted link to a double-precision math +library. This divide is not actually necessary, so the code was +restructured to eliminate it. Lv Zheng. + +ACPI 5.1: Added support for the runtime validation of the _DSD package +(similar to the iASL support). + +ACPI 5.1/Headers: Added support for the GICC affinity subtable to the +SRAT table. Hanjun Guo . + +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: 98.8K Code, 27.3K Data, 126.1K Total + Debug Version: 192.1K Code, 79.8K Data, 271.9K Total + Previous Release: + Non-Debug Version: 98.7K Code, 27.3K Data, 126.0K Total1 + Debug Version: 192.0K Code, 79.7K Data, 271.7K Total + +2) iASL Compiler/Disassembler and Tools: + +AcpiExec: Fixed a problem on unix systems where the original terminal +state was not always properly restored upon exit. Seen when using the -v +option. ACPICA BZ 1104. + +iASL: Fixed a problem with the validation of the ranges/length within the +Memory24 resource descriptor. There was a boundary condition when the +range was equal to the (length -1) caused by the fact that these values +are defined in 256-byte blocks, not bytes. ACPICA BZ 1098 + +Disassembler: Fixed a problem with the GpioInt descriptor interrupt +polarity +flags. The flags are actually 2 bits, not 1, and the "ActiveBoth" keyword +is +now supported properly. + +ACPI 5.1: Added the GICC affinity subtable to the SRAT table. Supported +in the disassembler, data table compiler, and table template generator. + +iASL: Added a requirement for Device() objects that one of either a _HID +or _ADR must exist within the scope of a Device, as per the ACPI +specification. Remove a similar requirement that was incorrectly in place +for the _DSD object. + +iASL: Added error detection for illegal named references within control +methods that would cause runtime failures. Now trapped as errors are: 1) +References to objects within a non-parent control method. 2) Forward +references (within a method) -- for control methods, AML interpreters use +a one-pass parse of control methods. ACPICA BZ 1008. + +iASL: Added error checking for dependencies related to the _PSx power +methods. ACPICA BZ 1029. +1) For _PS0, one of these must exist within the same scope: _PS1, _PS2, +_PS3. +2) For _PS1, _PS2, and PS3: A _PS0 object must exist within the same +scope. + +iASL and table compiler: Cleanup miscellaneous memory leaks by fully +deploying the existing object and string caches and adding new caches for +the table compiler. + +iASL: Split the huge parser source file into multiple subfiles to improve +manageability. Generation now requires the M4 macro preprocessor, which +is part of the Bison distribution on both unix and windows platforms. + +AcpiSrc: Fixed and removed all extraneous warnings generated during +entire ACPICA source code scan and/or conversion. + + +---------------------------------------- + +24 July 2014. Summary of changes for version 20140724: + +The ACPI 5.1 specification has been released and is available at: +http://uefi.org/specs/access + + +0) ACPI 5.1 support in ACPICA: + +ACPI 5.1 is fully supported in ACPICA as of this release. + +New predefined names. Support includes iASL and runtime ACPICA +validation. + _CCA (Cache Coherency Attribute). + _DSD (Device-Specific Data). David Box. + +Modifications to existing ACPI tables. Support includes headers, iASL +Data Table compiler, disassembler, and the template generator. + FADT - New fields and flags. Graeme Gregory. + GTDT - One new subtable and new fields. Tomasz Nowicki. + MADT - Two new subtables. Tomasz Nowicki. + PCCT - One new subtable. + +Miscellaneous. + New notification type for System Resource Affinity change events. + + +1) ACPICA kernel-resident subsystem: + +Fixed a regression introduced in 20140627 where a fault can happen during +the deletion of Alias AML namespace objects. The problem affected both +the core ACPICA and the ACPICA tools including iASL and AcpiExec. + +Implemented a new GPE public interface, AcpiMarkGpeForWake. Provides a +simple mechanism to enable wake GPEs that have no associated handler or +control method. Rafael Wysocki. + +Updated the AcpiEnableGpe interface to disallow the enable if there is no +handler or control method associated with the particular GPE. This will +help avoid meaningless GPEs and even GPE floods. Rafael Wysocki. + +Updated GPE handling and dispatch by disabling the GPE before clearing +the status bit for edge-triggered GPEs. Lv Zheng. + +Added Timer() support to the AML Debug object. The current timer value is +now displayed with each invocation of (Store to) the debug object to +enable simple generation of execution times for AML code (method +execution for example.) ACPICA BZ 1093. + +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: 98.7K Code, 27.3K Data, 126.0K Total + Debug Version: 192.0K Code, 79.7K Data, 271.7K Total + Previous Release: + Non-Debug Version: 98.7K Code, 27.2K Data, 125.9K Total + Debug Version: 191.7K Code, 79.6K Data, 271.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed an issue with the recently added local printf implementation, +concerning width/precision specifiers that could cause incorrect output. +Lv Zheng. ACPICA BZ 1094. + +Disassembler: Added support to detect buffers that contain UUIDs and +disassemble them to an invocation of the ToUUID operator. Also emit +commented descriptions of known ACPI-related UUIDs. + +AcpiHelp: Added support to display known ACPI-related UUIDs. New option, +-u. Adds three new files. + +iASL: Update table compiler and disassembler for DMAR table changes that +were introduced in September 2013. With assistance by David Woodhouse. + +---------------------------------------- +27 June 2014. Summary of changes for version 20140627: + +1) ACPICA kernel-resident subsystem: + +Formatted Output: Implemented local versions of standard formatted output +utilities such as printf, etc. Over time, it has been discovered that +there are in fact many portability issues with printf, and the addition +of this feature will fix/prevent these issues once and for all. Some +known issues are summarized below: + +1) Output of 64-bit values is not portable. For example, UINT64 is %ull +for the Linux kernel and is %uI64 for some MSVC versions. +2) Invoking printf consistently in a manner that is portable across both +32-bit and 64-bit platforms is difficult at best in many situations. +3) The output format for pointers varies from system to system (leading +zeros especially), and leads to inconsistent output from ACPICA across +platforms. +4) Certain platform-specific printf formats may conflict with ACPICA use. +5) If there is no local C library available, ACPICA now has local support +for printf. + +-- To address these printf issues in a complete manner, ACPICA now +directly implements a small subset of printf format specifiers, only +those that it requires. Adds a new file, utilities/utprint.c. Lv Zheng. + +Implemented support for ACPICA generation within the EFI environment. +Initially, the AcpiDump utility is supported in the UEFI shell +environment. Lv Zheng. + +Added a new external interface, AcpiLogError, to improve ACPICA +portability. This allows the host to redirect error messages from the +ACPICA utilities. Lv Zheng. + +Added and deployed new OSL file I/O interfaces to improve ACPICA +portability: + AcpiOsOpenFile + AcpiOsCloseFile + AcpiOsReadFile + AcpiOsWriteFile + AcpiOsGetFileOffset + AcpiOsSetFileOffset +There are C library implementations of these functions in the new file +service_layers/oslibcfs.c -- however, the functions can be implemented by +the local host in any way necessary. Lv Zheng. + +Implemented a mechanism to disable/enable ACPI table checksum validation +at runtime. This can be useful when loading tables very early during OS +initialization when it may not be possible to map the entire table in +order to compute the checksum. Lv Zheng. + +Fixed a buffer allocation issue for the Generic Serial Bus support. +Originally, a fixed buffer length was used. This change allows for +variable-length buffers based upon the protocol indicated by the field +access attributes. Reported by Lan Tianyu. Lv Zheng. + +Fixed a problem where an object detached from a namespace node was not +properly terminated/cleared and could cause a circular list problem if +reattached. ACPICA BZ 1063. David Box. + +Fixed a possible recursive lock acquisition in hwregs.c. Rakib Mullick. + +Fixed a possible memory leak in an error return path within the function +AcpiUtCopyIobjectToIobject. ACPICA BZ 1087. Colin Ian King. + +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: 98.7K Code, 27.2K Data, 125.9K Total + Debug Version: 191.7K Code, 79.6K Data, 271.3K Total + Previous Release: + Non-Debug Version: 96.8K Code, 27.2K Data, 124.0K Total + Debug Version: 189.5K Code, 79.7K Data, 269.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Add dump of ASCII equivalent text within a comment at the +end of each line of the output for the Buffer() ASL operator. + +AcpiDump: Miscellaneous changes: + Fixed repetitive table dump in -n mode. + For older EFI platforms, use the ACPI 1.0 GUID during RSDP search if +the ACPI 2.0 GUID fails. + +iASL: Fixed a problem where the compiler could fault if incorrectly given +an acpidump output file as input. ACPICA BZ 1088. David Box. + +AcpiExec/AcpiNames: Fixed a problem where these utilities could fault if +they are invoked without any arguments. + +Debugger: Fixed a possible memory leak in an error return path. ACPICA BZ +1086. Colin Ian King. + +Disassembler: Cleaned up a block of code that extracts a parent Op +object. Added a comment that explains that the parent is guaranteed to be +valid in this case. ACPICA BZ 1069. + +---------------------------------------- +24 April 2014. Summary of changes for version 20140424: + +1) ACPICA kernel-resident subsystem: + +Implemented support to skip/ignore NULL address entries in the RSDT/XSDT. +Some of these tables are known to contain a trailing NULL entry. Lv +Zheng. + +Removed an extraneous error message for the case where there are a large +number of system GPEs (> 124). This was the "32-bit FADT register is too +long to convert to GAS struct" message, which is irrelevant for GPEs +since the GPEx_BLK_LEN fields of the FADT are always used instead of the +(limited capacity) GAS bit length. Also, several changes to ensure proper +support for GPE numbers > 255, where some "GPE number" fields were 8-bits +internally. + +Implemented and deployed additional configuration support for the public +ACPICA external interfaces. Entire classes of interfaces can now be +easily modified or configured out, replaced by stubbed inline functions +by default. Lv Zheng. + +Moved all public ACPICA runtime configuration globals to the public +ACPICA external interface file for convenience. Also, removed some +obsolete/unused globals. See the file acpixf.h. Lv Zheng. + +Documentation: Added a new section to the ACPICA reference describing the +maximum number of GPEs that can be supported by the FADT-defined GPEs in +block zero and one. About 1200 total. See section 4.4.1 of the ACPICA +reference. + +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: 96.8K Code, 27.2K Data, 124.0K Total + Debug Version: 189.5K Code, 79.7K Data, 269.2K Total + Previous Release: + Non-Debug Version: 97.0K Code, 27.2K Data, 124.2K Total + Debug Version: 189.7K Code, 79.5K Data, 269.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL and disassembler: Add full support for the LPIT table (Low Power +Idle Table). Includes support in the disassembler, data table compiler, +and template generator. + +AcpiDump utility: +1) Add option to force the use of the RSDT (over the XSDT). +2) Improve validation of the RSDP signature (use 8 chars instead of 4). + +iASL: Add check for predefined packages that are too large. For +predefined names that contain subpackages, check if each subpackage is +too large. (Check for too small already exists.) + +Debugger: Updated the GPE command (which simulates a GPE by executing the +GPE code paths in ACPICA). The GPE device is now optional, and defaults +to the GPE 0/1 FADT-defined blocks. + +Unix application OSL: Update line-editing support. Add additional error +checking and take care not to reset terminal attributes on exit if they +were never set. This should help guarantee that the terminal is always +left in the previous state on program exit. + +---------------------------------------- +25 March 2014. Summary of changes for version 20140325: + +1) ACPICA kernel-resident subsystem: + +Updated the auto-serialize feature for control methods. This feature +automatically serializes all methods that create named objects in order +to prevent runtime errors. The update adds support to ignore the +currently executing AML SyncLevel when invoking such a method, in order +to prevent disruption of any existing SyncLevel priorities that may exist +in the AML code. Although the use of SyncLevels is relatively rare, this +change fixes a regression where an AE_AML_MUTEX_ORDER exception can +appear on some machines starting with the 20140214 release. + +Added a new external interface to allow the host to install ACPI tables +very early, before the namespace is even created. AcpiInstallTable gives +the host additional flexibility for ACPI table management. Tables can be +installed directly by the host as if they had originally appeared in the +XSDT/RSDT. Installed tables can be SSDTs or other ACPI data tables +(anything except the DSDT and FACS). Adds a new file, tbdata.c, along +with additional internal restructuring and cleanup. See the ACPICA +Reference for interface details. Lv Zheng. + +Added validation of the checksum for all incoming dynamically loaded +tables (via external interfaces or via AML Load/LoadTable operators). Lv +Zheng. + +Updated the use of the AcpiOsWaitEventsComplete interface during Notify +and GPE handler removal. Restructured calls to eliminate possible race +conditions. Lv Zheng. + +Added a warning for the use/execution of the ASL/AML Unload (table) +operator. This will help detect and identify machines that use this +operator if and when it is ever used. This operator has never been seen +in the field and the usage model and possible side-effects of the drastic +runtime action of a full table removal are unknown. + +Reverted the use of #pragma push/pop which was introduced in the 20140214 +release. It appears that push and pop are not implemented by enough +compilers to make the use of this feature feasible for ACPICA at this +time. However, these operators may be deployed in a future ACPICA +release. + +Added the missing EXPORT_SYMBOL macros for the install and remove SCI +handler interfaces. + +Source code generation: +1) Disabled the use of the "strchr" macro for the gcc-specific +generation. For some versions of gcc, this macro can periodically expose +a compiler bug which in turn causes compile-time error(s). +2) Added support for PPC64 compilation. Colin Ian King. + +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: 97.0K Code, 27.2K Data, 124.2K Total + Debug Version: 189.7K Code, 79.5K Data, 269.2K Total + Previous Release: + Non-Debug Version: 96.5K Code, 27.2K Data, 123.7K Total + Debug Version: 188.6K Code, 79.0K Data, 267.6K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Added several new features to improve the readability of +the resulting ASL code. Extra information is emitted within comment +fields in the ASL code: +1) Known _HID/_CID values are decoded to descriptive text. +2) Standard values for the Notify() operator are decoded to descriptive +text. +3) Target operands are expanded to full pathnames (in a comment) when +possible. + +Disassembler: Miscellaneous updates for extern() handling: +1) Abort compiler if file specified by -fe option does not exist. +2) Silence unnecessary warnings about argument count mismatches. +3) Update warning messages concerning unresolved method externals. +4) Emit "UnknownObj" keyword for externals whose type cannot be +determined. + +AcpiHelp utility: +1) Added the -a option to display both the ASL syntax and the AML +encoding for an input ASL operator. This effectively displays all known +information about an ASL operator with one AcpiHelp invocation. +2) Added substring match support (similar to a wildcard) for the -i +(_HID/PNP IDs) option. + +iASL/Disassembler: Since this tool does not yet support execution on big- +endian machines, added detection of endianness and an error message if +execution is attempted on big-endian. Support for big-endian within iASL +is a feature that is on the ACPICA to-be-done list. + +AcpiBin utility: +1) Remove option to extract binary files from an acpidump; this function +is made obsolete by the AcpiXtract utility. +2) General cleanup of open files and allocated buffers. + +---------------------------------------- +14 February 2014. Summary of changes for version 20140214: + +1) ACPICA kernel-resident subsystem: + +Implemented a new mechanism to proactively prevent problems with ill- +behaved reentrant control methods that create named ACPI objects. This +behavior is illegal as per the ACPI specification, but is nonetheless +frequently seen in the field. Previously, this could lead to an +AE_ALREADY_EXISTS exception if the method was actually entered by more +than one thread. This new mechanism detects such methods at table load +time and marks them "serialized" to prevent reentrancy. A new global +option, AcpiGbl_AutoSerializeMethods, has been added to disable this +feature if desired. This mechanism and global option obsoletes and +supersedes the previous AcpiGbl_SerializeAllMethods option. + +Added the "Windows 2013" string to the _OSI support. ACPICA will now +respond TRUE to _OSI queries with this string. It is the stated policy of +ACPICA to add new strings to the _OSI support as soon as possible after +they are defined. See the full ACPICA _OSI policy which has been added to +the utilities/utosi.c file. + +Hardened/updated the _PRT return value auto-repair code: +1) Do not abort the repair on a single subpackage failure, continue to +check all subpackages. +2) Add check for the minimum subpackage length (4). +3) Properly handle extraneous NULL package elements. + +Added support to avoid the possibility of infinite loops when traversing +object linked lists. Never allow an infinite loop, even in the face of +corrupted object lists. + +ACPICA headers: Deployed the use of #pragma pack(push) and #pragma +pack(pop) directives to ensure that the ACPICA headers are independent of +compiler settings or other host headers. + +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: 96.5K Code, 27.2K Data, 123.7K Total + Debug Version: 188.6K Code, 79.0K Data, 267.6K Total + Previous Release: + Non-Debug Version: 96.2K Code, 27.0K Data, 123.2K Total + Debug Version: 187.5K Code, 78.3K Data, 265.8K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL/Table-compiler: Fixed a problem with support for the SPMI table. The +first reserved field was incorrectly forced to have a value of zero. This +change correctly forces the field to have a value of one. ACPICA BZ 1081. + +Debugger: Added missing support for the "Extra" and "Data" subobjects +when displaying object data. + +Debugger: Added support to display entire object linked lists when +displaying object data. + +iASL: Removed the obsolete -g option to obtain ACPI tables from the +Windows registry. This feature has been superseded by the acpidump +utility. + +---------------------------------------- +14 January 2014. Summary of changes for version 20140114: + +1) ACPICA kernel-resident subsystem: + +Updated all ACPICA copyrights and signons to 2014. Added the 2014 +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. + +Improved parameter validation for AcpiInstallGpeBlock. Added the +following checks: +1) The incoming device handle refers to type ACPI_TYPE_DEVICE. +2) There is not already a GPE block attached to the device. +Likewise, with AcpiRemoveGpeBlock, ensure that the incoming object is a +device. + +Correctly support "references" in the ACPI_OBJECT. This change fixes the +support to allow references (namespace nodes) to be passed as arguments +to control methods via the evaluate object interface. This is probably +most useful for testing purposes, however. + +Improved support for 32/64 bit physical addresses in printf()-like +output. This change improves the support for physical addresses in printf +debug statements and other output on both 32-bit and 64-bit hosts. It +consistently outputs the appropriate number of bytes for each host. The +%p specifier is unsatisfactory since it does not emit uniform output on +all hosts/clib implementations (on some, leading zeros are not supported, +leading to difficult-to-read output). + +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: 96.2K Code, 27.0K Data, 123.2K Total + Debug Version: 187.5K Code, 78.3K Data, 265.8K Total + Previous Release: + Non-Debug Version: 96.1K Code, 27.0K Data, 123.1K Total + Debug Version: 185.6K Code, 77.3K Data, 262.9K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fix a possible fault when using the Connection() operator. Fixes a +problem if the parent Field definition for the Connection operator refers +to an operation region that does not exist. ACPICA BZ 1064. + +AcpiExec: Load of local test tables is now optional. The utility has the +capability to load some various tables to test features of ACPICA. +However, there are enough of them that the output of the utility became +confusing. With this change, only the required local tables are displayed +(RSDP, XSDT, etc.) along with the actual tables loaded via the command +line specification. This makes the default output simler and easier to +understand. The -el command line option restores the original behavior +for testing purposes. + +AcpiExec: Added support for overlapping operation regions. This change +expands the simulation of operation regions by supporting regions that +overlap within the given address space. Supports SystemMemory and +SystemIO. ASLTS test suite updated also. David Box. ACPICA BZ 1031. + +AcpiExec: Added region handler support for PCI_Config and EC spaces. This +allows AcpiExec to simulate these address spaces, similar to the current +support for SystemMemory and SystemIO. + +Debugger: Added new command to read/write/compare all namespace objects. +The command "test objects" will exercise the entire namespace by writing +new values to each data object, and ensuring that the write was +successful. The original value is then restored and verified. + +Debugger: Added the "test predefined" command. This change makes this +test public and puts it under the new "test" command. The test executes +each and every predefined name within the current namespace. + +---------------------------------------- +18 December 2013. Summary of changes for version 20131218: + +Global note: The ACPI 5.0A specification was released this month. There +are no changes needed for ACPICA since this release of ACPI is an +errata/clarification release. The specification is available at +acpi.info. + + +1) ACPICA kernel-resident subsystem: + +Added validation of the XSDT root table if it is present. Some older +platforms contain an XSDT that is ill-formed or otherwise invalid (such +as containing some or all entries that are NULL pointers). This change +adds a new function to validate the XSDT before actually using it. If the +XSDT is found to be invalid, ACPICA will now automatically fall back to +using the RSDT instead. Original implementation by Zhao Yakui. Ported to +ACPICA and enhanced by Lv Zheng and Bob Moore. + +Added a runtime option to ignore the XSDT and force the use of the RSDT. +This change adds a runtime option that will force ACPICA to use the RSDT +instead of the XSDT (AcpiGbl_DoNotUseXsdt). Although the ACPI spec +requires that an XSDT be used instead of the RSDT, the XSDT has been +found to be corrupt or ill-formed on some machines. Lv Zheng. + +Added a runtime option to favor 32-bit FADT register addresses over the +64-bit addresses. This change adds an option to favor 32-bit FADT +addresses when there is a conflict between the 32-bit and 64-bit versions +of the same register. The default behavior is to use the 64-bit version +in accordance with the ACPI specification. This can now be overridden via +the AcpiGbl_Use32BitFadtAddresses flag. ACPICA BZ 885. Lv Zheng. + +During the change above, the internal "Convert FADT" and "Verify FADT" +functions have been merged to simplify the code, making it easier to +understand and maintain. ACPICA BZ 933. + +Improve exception reporting and handling for GPE block installation. +Return an actual status from AcpiEvGetGpeXruptBlock and don't clobber the +status when exiting AcpiEvInstallGpeBlock. ACPICA BZ 1019. + +Added helper macros to extract bus/segment numbers from the HEST table. +This change adds two macros to extract the encoded bus and segment +numbers from the HEST Bus field - ACPI_HEST_BUS and ACPI_HEST_SEGMENT. +Betty Dall + +Removed the unused ACPI_FREE_BUFFER macro. This macro is no longer used +by ACPICA. It is not a public macro, so it should have no effect on +existing OSV code. 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. + + Current Release: + Non-Debug Version: 96.1K Code, 27.0K Data, 123.1K Total + Debug Version: 185.6K Code, 77.3K Data, 262.9K Total + Previous Release: + Non-Debug Version: 95.9K Code, 27.0K Data, 122.9K Total + Debug Version: 185.1K Code, 77.2K Data, 262.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Improved pathname support for emitted External() +statements. This change adds full pathname support for external names +that have been resolved internally by the inclusion of additional ACPI +tables (via the iASL -e option). Without this change, the disassembler +can emit multiple externals for the same object, or it become confused +when the Scope() operator is used on an external object. Overall, greatly +improves the ability to actually recompile the emitted ASL code when +objects a referenced across multiple ACPI tables. Reported by Michael +Tsirkin (mst@redhat.com). + +Tests/ASLTS: Updated functional control suite to execute with no errors. +David Box. Fixed several errors related to the testing of the interpreter +slack mode. Lv Zheng. + +iASL: Added support to detect names that are declared within a control +method, but are unused (these are temporary names that are only valid +during the time the method is executing). A remark is issued for these +cases. ACPICA BZ 1022. + +iASL: Added full support for the DBG2 table. Adds full disassembler, +table compiler, and template generator support for the DBG2 table (Debug +Port 2 table). + +iASL: Added full support for the PCCT table, update the table definition. +Updates the PCCT table definition in the actbl3.h header and adds table +compiler and template generator support. + +iASL: Added an option to emit only error messages (no warnings/remarks). +The -ve option will enable only error messages, warnings and remarks are +suppressed. This can simplify debugging when only the errors are +important, such as when an ACPI table is disassembled and there are many +warnings and remarks -- but only the actual errors are of real interest. + +Example ACPICA code (source/tools/examples): Updated the example code so +that it builds to an actual working program, not just example code. Added +ACPI tables and execution of an example control method in the DSDT. Added +makefile support for Unix generation. + +---------------------------------------- +15 November 2013. Summary of changes for version 20131115: + +This release is available at https://acpica.org/downloads + + +1) ACPICA kernel-resident subsystem: + +Resource Manager: Fixed loop termination for the "get AML length" +function. The loop previously had an error termination on a NULL resource +pointer, which can never happen since the loop simply increments a valid +resource pointer. This fix changes the loop to terminate with an error on +an invalid end-of-buffer condition. The problem can be seen as an +infinite loop by callers to AcpiSetCurrentResources with an invalid or +corrupted resource descriptor, or a resource descriptor that is missing +an END_TAG descriptor. Reported by Dan Carpenter +. Lv Zheng, Bob Moore. + +Table unload and ACPICA termination: Delete all attached data objects +during namespace node deletion. This fix updates namespace node deletion +to delete the entire list of attached objects (attached via +AcpiAttachObject) instead of just one of the attached items. ACPICA BZ +1024. Tomasz Nowicki (tomasz.nowicki@linaro.org). + +ACPICA termination: Added support to delete all objects attached to the +root namespace node. This fix deletes any and all objects that have been +attached to the root node via AcpiAttachData. Previously, none of these +objects were deleted. Reported by Tomasz Nowicki. ACPICA BZ 1026. + +Debug output: Do not emit the function nesting level for the in-kernel +build. The nesting level is really only useful during a single-thread +execution. Therefore, only enable this output for the AcpiExec utility. +Also, only emit the thread ID when executing under AcpiExec (Context +switches are still always detected and a message is emitted). ACPICA BZ +972. + +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.9K Code, 27.0K Data, 122.9K Total + Debug Version: 185.1K Code, 77.2K Data, 262.3K Total + Previous Release: + Non-Debug Version: 95.8K Code, 27.0K Data, 122.8K Total + Debug Version: 185.2K Code, 77.2K Data, 262.4K Total + + +2) iASL Compiler/Disassembler and Tools: + +AcpiExec/Unix-OSL: Use instead of . This is the +correct portable POSIX header for terminal control functions. + +Disassembler: Fixed control method invocation issues related to the use +of the CondRefOf() operator. The problem is seen in the disassembly where +control method invocations may not be disassembled properly if the +control method name has been used previously as an argument to CondRefOf. +The solution is to not attempt to emit an external declaration for the +CondRefOf target (it is not necessary in the first place). This prevents +disassembler object type confusion. ACPICA BZ 988. + +Unix Makefiles: Added an option to disable compiler optimizations and the +_FORTIFY_SOURCE flag. Some older compilers have problems compiling ACPICA +with optimizations (reportedly, gcc 4.4 for example). This change adds a +command line option for make (NOOPT) that disables all compiler +optimizations and the _FORTIFY_SOURCE compiler flag. The default +optimization is -O2 with the _FORTIFY_SOURCE flag specified. ACPICA BZ +1034. Lv Zheng, Bob Moore. + +Tests/ASLTS: Added options to specify individual test cases and modes. +This allows testers running aslts.sh to optionally specify individual +test modes and test cases. Also added an option to disable the forced +generation of the ACPICA tools from source if desired. Lv Zheng. + +---------------------------------------- +27 September 2013. Summary of changes for version 20130927: + +This release is available at https://acpica.org/downloads + + +1) ACPICA kernel-resident subsystem: + +Fixed a problem with store operations to reference objects. This change +fixes a problem where a Store operation to an ArgX object that contained +a +reference to a field object did not complete the automatic dereference +and +then write to the actual field object. Instead, the object type of the +field object was inadvertently changed to match the type of the source +operand. The new behavior will actually write to the field object (buffer +field or field unit), thus matching the correct ACPI-defined behavior. + +Implemented support to allow the host to redefine individual OSL +prototypes. This change enables the host to redefine OSL prototypes found +in the acpiosxf.h file. This allows the host to implement OSL interfaces +with a macro or inlined function. Further, it allows the host to add any +additional required modifiers such as __iomem, __init, __exit, etc., as +necessary on a per-interface basis. Enables maximum flexibility for the +OSL interfaces. Lv Zheng. + +Hardcoded the access width for the FADT-defined reset register. The ACPI +specification requires the reset register width to be 8 bits. ACPICA now +hardcodes the width to 8 and ignores the FADT width value. This provides +compatibility with other ACPI implementations that have allowed BIOS code +with bad register width values to go unnoticed. Matthew Garett, Bob +Moore, +Lv Zheng. + +Changed the position/use of the ACPI_PRINTF_LIKE macro. This macro is +used +in the OSL header (acpiosxf). The change modifies the position of this +macro in each instance where it is used (AcpiDebugPrint, etc.) to avoid +build issues if the OSL defines the implementation of the interface to be +an inline stub function. Lv Zheng. + +Deployed a new macro ACPI_EXPORT_SYMBOL_INIT for the main ACPICA +initialization interfaces. This change adds a new macro for the main init +and terminate external interfaces in order to support hosts that require +additional or different processing for these functions. Changed from +ACPI_EXPORT_SYMBOL to ACPI_EXPORT_SYMBOL_INIT for these functions. Lv +Zheng, Bob Moore. + +Cleaned up the memory allocation macros for configurability. In the +common +case, the ACPI_ALLOCATE and related macros now resolve directly to their +respective AcpiOs* OSL interfaces. Two options: +1) The ACPI_ALLOCATE_ZEROED macro uses a simple local implementation by +default, unless overridden by the USE_NATIVE_ALLOCATE_ZEROED define. +2) For AcpiExec (and for debugging), the macros can optionally be +resolved +to the local ACPICA interfaces that track each allocation (local tracking +is used to immediately detect memory leaks). +Lv Zheng. + +Simplified the configuration for ACPI_REDUCED_HARDWARE. Allows the kernel +to predefine this macro to either TRUE or FALSE during the system build. + +Replaced __FUNCTION_ with __func__ in the gcc-specific header. + +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.8K Code, 27.0K Data, 122.8K Total + Debug Version: 185.2K Code, 77.2K Data, 262.4K Total + Previous Release: + Non-Debug Version: 96.7K Code, 27.1K Data, 123.9K Total + Debug Version: 184.4K Code, 76.8K Data, 261.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented wildcard support for the -e option. This simplifies use +when there are many SSDTs that must be included to resolve external +method +declarations. ACPICA BZ 1041. Example: + iasl -e ssdt*.dat -d dsdt.dat + +AcpiExec: Add history/line-editing for Unix/Linux systems. This change +adds a portable module that implements full history and limited line +editing for Unix and Linux systems. It does not use readline() due to +portability issues. Instead it uses the POSIX termio interface to put the +terminal in raw input mode so that the various special keys can be +trapped +(such as up/down-arrow for history support and left/right-arrow for line +editing). Uses the existing debugger history mechanism. ACPICA BZ 1036. + +AcpiXtract: Add support to handle (ignore) "empty" lines containing only +one or more spaces. This provides compatible with early or different +versions of the AcpiDump utility. ACPICA BZ 1044. + +AcpiDump: Do not ignore tables that contain only an ACPI table header. +Apparently, some BIOSs create SSDTs that contain an ACPI table header but +no other data. This change adds support to dump these tables. Any tables +shorter than the length of an ACPI table header remain in error (an error +message is emitted). Reported by Yi Li. + +Debugger: Echo actual command along with the "unknown command" message. + ---------------------------------------- 23 August 2013. Summary of changes for version 20130823: diff --git a/sys/contrib/dev/acpica/common/acgetline.c b/sys/contrib/dev/acpica/common/acgetline.c new file mode 100644 index 000000000000..f0948df7d4cf --- /dev/null +++ b/sys/contrib/dev/acpica/common/acgetline.c @@ -0,0 +1,440 @@ +/****************************************************************************** + * + * Module Name: acgetline - local line editing + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +/* + * This is an os-independent implementation of line-editing services needed + * by the AcpiExec utility. It uses getchar() and putchar() and the existing + * history support provided by the AML debugger. It assumes that the terminal + * is in the correct line-editing mode such as raw and noecho. The OSL + * interface AcpiOsInitialize should do this. AcpiOsTerminate should put the + * terminal back into the original mode. + */ +#define _COMPONENT ACPI_OS_SERVICES + ACPI_MODULE_NAME ("acgetline") + + +/* Local prototypes */ + +static void +AcpiAcClearLine ( + UINT32 EndOfLine, + UINT32 CursorPosition); + +/* Various ASCII constants */ + +#define _ASCII_NUL 0 +#define _ASCII_BACKSPACE 0x08 +#define _ASCII_TAB 0x09 +#define _ASCII_ESCAPE 0x1B +#define _ASCII_SPACE 0x20 +#define _ASCII_LEFT_BRACKET 0x5B +#define _ASCII_DEL 0x7F +#define _ASCII_UP_ARROW 'A' +#define _ASCII_DOWN_ARROW 'B' +#define _ASCII_RIGHT_ARROW 'C' +#define _ASCII_LEFT_ARROW 'D' +#define _ASCII_NEWLINE '\n' + +extern UINT32 AcpiGbl_NextCmdNum; + +/* Erase a single character on the input command line */ + +#define ACPI_CLEAR_CHAR() \ + putchar (_ASCII_BACKSPACE); \ + putchar (_ASCII_SPACE); \ + putchar (_ASCII_BACKSPACE); + +/* Backup cursor by Count positions */ + +#define ACPI_BACKUP_CURSOR(i, Count) \ + for (i = 0; i < (Count); i++) \ + {putchar (_ASCII_BACKSPACE);} + + +/****************************************************************************** + * + * FUNCTION: AcpiAcClearLine + * + * PARAMETERS: EndOfLine - Current end-of-line index + * CursorPosition - Current cursor position within line + * + * RETURN: None + * + * DESCRIPTION: Clear the entire command line the hard way, but probably the + * most portable. + * + *****************************************************************************/ + +static void +AcpiAcClearLine ( + UINT32 EndOfLine, + UINT32 CursorPosition) +{ + UINT32 i; + + + if (CursorPosition < EndOfLine) + { + /* Clear line from current position to end of line */ + + for (i = 0; i < (EndOfLine - CursorPosition); i++) + { + putchar (' '); + } + } + + /* Clear the entire line */ + + for (; EndOfLine > 0; EndOfLine--) + { + ACPI_CLEAR_CHAR (); + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsGetLine + * + * PARAMETERS: Buffer - Where to return the command line + * BufferLength - Maximum length of Buffer + * BytesRead - Where the actual byte count is returned + * + * RETURN: Status and actual bytes read + * + * DESCRIPTION: Get the next input line from the terminal. NOTE: terminal + * is expected to be in a mode that supports line-editing (raw, + * noecho). This function is intended to be very portable. Also, + * it uses the history support implemented in the AML debugger. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsGetLine ( + char *Buffer, + UINT32 BufferLength, + UINT32 *BytesRead) +{ + char *NextCommand; + UINT32 MaxCommandIndex = AcpiGbl_NextCmdNum - 1; + UINT32 CurrentCommandIndex = MaxCommandIndex; + UINT32 PreviousCommandIndex = MaxCommandIndex; + int InputChar; + UINT32 CursorPosition = 0; + UINT32 EndOfLine = 0; + UINT32 i; + + + /* Always clear the line buffer before we read a new line */ + + memset (Buffer, 0, BufferLength); + + /* + * This loop gets one character at a time (except for esc sequences) + * until a newline or error is detected. + * + * Note: Don't attempt to write terminal control ESC sequences, even + * though it makes certain things more difficult. + */ + while (1) + { + if (EndOfLine >= (BufferLength - 1)) + { + return (AE_BUFFER_OVERFLOW); + } + + InputChar = getchar (); + switch (InputChar) + { + default: /* This is the normal character case */ + + /* Echo the character (at EOL) and copy it to the line buffer */ + + if (EndOfLine == CursorPosition) + { + putchar (InputChar); + Buffer[EndOfLine] = (char) InputChar; + + EndOfLine++; + CursorPosition++; + Buffer[EndOfLine] = 0; + continue; + } + + /* Insert character into the middle of the buffer */ + + memmove (&Buffer[CursorPosition + 1], &Buffer[CursorPosition], + (EndOfLine - CursorPosition + 1)); + + Buffer [CursorPosition] = (char) InputChar; + Buffer [EndOfLine + 1] = 0; + + /* Display the new part of line starting at the new character */ + + fprintf (stdout, "%s", &Buffer[CursorPosition]); + + /* Restore cursor */ + + ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition); + CursorPosition++; + EndOfLine++; + continue; + + case _ASCII_DEL: /* Backspace key */ + + if (!EndOfLine) /* Any characters on the command line? */ + { + continue; + } + + if (EndOfLine == CursorPosition) /* Erase the final character */ + { + ACPI_CLEAR_CHAR (); + EndOfLine--; + CursorPosition--; + continue; + } + + if (!CursorPosition) /* Do not backup beyond start of line */ + { + continue; + } + + /* Remove the character from the line */ + + memmove (&Buffer[CursorPosition - 1], &Buffer[CursorPosition], + (EndOfLine - CursorPosition + 1)); + + /* Display the new part of line starting at the new character */ + + putchar (_ASCII_BACKSPACE); + fprintf (stdout, "%s ", &Buffer[CursorPosition - 1]); + + /* Restore cursor */ + + ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition + 1); + EndOfLine--; + if (CursorPosition > 0) + { + CursorPosition--; + } + continue; + + case _ASCII_NEWLINE: /* Normal exit case at end of command line */ + case _ASCII_NUL: + + /* Return the number of bytes in the command line string */ + + if (BytesRead) + { + *BytesRead = EndOfLine; + } + + /* Echo, terminate string buffer, and exit */ + + putchar (InputChar); + Buffer[EndOfLine] = 0; + return (AE_OK); + + case _ASCII_TAB: + + /* Ignore */ + + continue; + + case EOF: + + return (AE_ERROR); + + case _ASCII_ESCAPE: + + /* Check for escape sequences of the form "ESC[x" */ + + InputChar = getchar (); + if (InputChar != _ASCII_LEFT_BRACKET) + { + continue; /* Ignore this ESC, does not have the '[' */ + } + + /* Get the code following the ESC [ */ + + InputChar = getchar (); /* Backup one character */ + switch (InputChar) + { + case _ASCII_LEFT_ARROW: + + if (CursorPosition > 0) + { + putchar (_ASCII_BACKSPACE); + CursorPosition--; + } + continue; + + case _ASCII_RIGHT_ARROW: + /* + * Move one character forward. Do this without sending + * ESC sequence to the terminal for max portability. + */ + if (CursorPosition < EndOfLine) + { + /* Backup to start of line and print the entire line */ + + ACPI_BACKUP_CURSOR (i, CursorPosition); + fprintf (stdout, "%s", Buffer); + + /* Backup to where the cursor should be */ + + CursorPosition++; + ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition); + } + continue; + + case _ASCII_UP_ARROW: + + /* If no commands available or at start of history list, ignore */ + + if (!CurrentCommandIndex) + { + continue; + } + + /* Manage our up/down progress */ + + if (CurrentCommandIndex > PreviousCommandIndex) + { + CurrentCommandIndex = PreviousCommandIndex; + } + + /* Get the historical command from the debugger */ + + NextCommand = AcpiDbGetHistoryByIndex (CurrentCommandIndex); + if (!NextCommand) + { + return (AE_ERROR); + } + + /* Make this the active command and echo it */ + + AcpiAcClearLine (EndOfLine, CursorPosition); + strcpy (Buffer, NextCommand); + fprintf (stdout, "%s", Buffer); + EndOfLine = CursorPosition = strlen (Buffer); + + PreviousCommandIndex = CurrentCommandIndex; + CurrentCommandIndex--; + continue; + + case _ASCII_DOWN_ARROW: + + if (!MaxCommandIndex) /* Any commands available? */ + { + continue; + } + + /* Manage our up/down progress */ + + if (CurrentCommandIndex < PreviousCommandIndex) + { + CurrentCommandIndex = PreviousCommandIndex; + } + + /* If we are the end of the history list, output a clear new line */ + + if ((CurrentCommandIndex + 1) > MaxCommandIndex) + { + AcpiAcClearLine (EndOfLine, CursorPosition); + EndOfLine = CursorPosition = 0; + PreviousCommandIndex = CurrentCommandIndex; + continue; + } + + PreviousCommandIndex = CurrentCommandIndex; + CurrentCommandIndex++; + + /* Get the historical command from the debugger */ + + NextCommand = AcpiDbGetHistoryByIndex (CurrentCommandIndex); + if (!NextCommand) + { + return (AE_ERROR); + } + + /* Make this the active command and echo it */ + + AcpiAcClearLine (EndOfLine, CursorPosition); + strcpy (Buffer, NextCommand); + fprintf (stdout, "%s", Buffer); + EndOfLine = CursorPosition = strlen (Buffer); + continue; + + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + /* + * Ignore the various keys like insert/delete/home/end, etc. + * But we must eat the final character of the ESC sequence. + */ + InputChar = getchar (); + continue; + + default: + + /* Ignore random escape sequences that we don't care about */ + + continue; + } + continue; + } + } +} diff --git a/sys/contrib/dev/acpica/common/adfile.c b/sys/contrib/dev/acpica/common/adfile.c index 5cde806b3331..ed5dc99bad3c 100644 --- a/sys/contrib/dev/acpica/common/adfile.c +++ b/sys/contrib/dev/acpica/common/adfile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ - +#include #include #include #include @@ -199,20 +199,28 @@ FlGenerateFilename ( { char *Position; char *NewFilename; + char *DirectoryPosition; /* - * Copy the original filename to a new buffer. Leave room for the worst case - * where we append the suffix, an added dot and the null terminator. + * Copy the original filename to a new buffer. Leave room for the worst + * case where we append the suffix, an added dot and the null terminator. */ - NewFilename = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) + NewFilename = UtStringCacheCalloc ((ACPI_SIZE) strlen (InputFilename) + strlen (Suffix) + 2); + if (!NewFilename) + { + return (NULL); + } + strcpy (NewFilename, InputFilename); /* Try to find the last dot in the filename */ + DirectoryPosition = strrchr (NewFilename, '/'); Position = strrchr (NewFilename, '.'); - if (Position) + + if (Position && (Position > DirectoryPosition)) { /* Tack on the new suffix */ @@ -247,7 +255,7 @@ FlStrdup ( char *NewString; - NewString = ACPI_ALLOCATE ((ACPI_SIZE) strlen (String) + 1); + NewString = UtStringCacheCalloc ((ACPI_SIZE) strlen (String) + 1); if (!NewString) { return (NULL); @@ -288,7 +296,6 @@ FlSplitInputPathname ( *OutDirectoryPath = NULL; - *OutFilename = NULL; if (!InputPath) { @@ -334,6 +341,12 @@ FlSplitInputPathname ( } *OutDirectoryPath = DirectoryPath; - *OutFilename = Filename; + + if (OutFilename) + { + *OutFilename = Filename; + return (AE_OK); + } + return (AE_OK); } diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index c361a6a65897..dd1a93dc8034 100644 --- a/sys/contrib/dev/acpica/common/adisasm.c +++ b/sys/contrib/dev/acpica/common/adisasm.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,12 +41,9 @@ * POSSIBILITY OF SUCH DAMAGES. */ - -#include -#include +#include #include #include -#include #include #include #include @@ -60,29 +57,8 @@ #define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("adisasm") -/* - * Older versions of Bison won't emit this external in the generated header. - * Newer versions do emit the external, so we don't need to do it. - */ -#ifndef ASLCOMPILER_ASLCOMPILERPARSE_H -extern int AslCompilerdebug; -#endif - -ACPI_STATUS -NsDisplayNamespace ( - void); - -void -NsSetupNamespaceListing ( - void *Handle); - - /* Local prototypes */ -static UINT32 -AdGetFileSize ( - FILE *File); - static void AdCreateTableHeader ( char *Filename, @@ -152,39 +128,7 @@ AcpiDsMethodDataInitArgs ( static ACPI_TABLE_DESC LocalTables[1]; -static ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; - - -/******************************************************************************* - * - * FUNCTION: AdGetFileSize - * - * PARAMETERS: File - Open file handle - * - * RETURN: File Size - * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. - * - ******************************************************************************/ - -static UINT32 -AdGetFileSize ( - FILE *File) -{ - UINT32 FileSize; - long Offset; - - - Offset = ftell (File); - - fseek (File, 0, SEEK_END); - FileSize = (UINT32) ftell (File); - - /* Restore file pointer */ - - fseek (File, Offset, SEEK_SET); - return (FileSize); -} +ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; /******************************************************************************* @@ -206,7 +150,7 @@ AdInitialize ( ACPI_STATUS Status; - /* ACPI CA subsystem initialization */ + /* ACPICA subsystem initialization */ Status = AcpiOsInitialize (); if (ACPI_FAILURE (Status)) @@ -250,7 +194,6 @@ AdInitialize ( * OutToFile - TRUE if output should go to a file * Prefix - Path prefix for output * OutFilename - where the filename is returned - * GetAllTables - TRUE if all tables are desired * * RETURN: Status * @@ -263,8 +206,7 @@ AdAmlDisassemble ( BOOLEAN OutToFile, char *Filename, char *Prefix, - char **OutFilename, - BOOLEAN GetAllTables) + char **OutFilename) { ACPI_STATUS Status; char *DisasmFilename = NULL; @@ -348,7 +290,7 @@ AdAmlDisassemble ( } else { - Status = AdGetLocalTables (Filename, GetAllTables); + Status = AdGetLocalTables (); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get ACPI tables, %s\n", @@ -383,7 +325,7 @@ AdAmlDisassemble ( /* Create/Open a disassembly output file */ DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY); - if (!OutFilename) + if (!DisasmFilename) { fprintf (stderr, "Could not generate output filename\n"); Status = AE_ERROR; @@ -395,6 +337,7 @@ AdAmlDisassemble ( { fprintf (stderr, "Could not open output file %s\n", DisasmFilename); Status = AE_ERROR; + ACPI_FREE (DisasmFilename); goto Cleanup; } @@ -415,7 +358,7 @@ AdAmlDisassemble ( fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n", Table->Signature); fprintf (stderr, "Formatted output: %s - %u bytes\n", - DisasmFilename, AdGetFileSize (File)); + DisasmFilename, CmGetFileSize (File)); } else { @@ -471,9 +414,10 @@ AdAmlDisassemble ( "reparsing with new information\n", AcpiDmGetExternalMethodCount ()); - /* Reparse, rebuild namespace. no need to xref namespace */ + /* Reparse, rebuild namespace */ AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); + AcpiGbl_ParseOpRoot = NULL; AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); AcpiGbl_RootNode = NULL; @@ -487,6 +431,9 @@ AdAmlDisassemble ( AcpiGbl_RootNodeStruct.Flags = 0; Status = AcpiNsRootInitialize (); + + /* New namespace, add the external definitions first */ + AcpiDmAddExternalsToNamespace (); /* Parse the table again. No need to reload it, however */ @@ -499,6 +446,14 @@ AdAmlDisassemble ( goto Cleanup; } + /* Cross reference the namespace again */ + + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + + AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + if (AslCompilerdebug) { AcpiOsPrintf ("/**** After second load and resource conversion\n"); @@ -533,7 +488,15 @@ AdAmlDisassemble ( fprintf (stderr, "Disassembly completed\n"); fprintf (stderr, "ASL Output: %s - %u bytes\n", - DisasmFilename, AdGetFileSize (File)); + DisasmFilename, CmGetFileSize (File)); + + if (Gbl_MapfileFlag) + { + fprintf (stderr, "%14s %s - %u bytes\n", + Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription, + Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename, + FlGetFileSize (ASL_FILE_MAP_OUTPUT)); + } } } @@ -570,7 +533,7 @@ AdAmlDisassemble ( * * RETURN: None * - * DESCRIPTION: Create the disassembler header, including ACPI CA signon with + * DESCRIPTION: Create the disassembler header, including ACPICA signon with * current time and date. * *****************************************************************************/ @@ -602,7 +565,7 @@ AdDisassemblerHeader ( * * RETURN: None * - * DESCRIPTION: Create the ASL table header, including ACPI CA signon with + * DESCRIPTION: Create the ASL table header, including ACPICA signon with * current time and date. * *****************************************************************************/ @@ -679,9 +642,18 @@ AdCreateTableHeader ( } else { - NewFilename = ACPI_ALLOCATE_ZEROED (9); - strncat (NewFilename, Table->Signature, 4); - strcat (NewFilename, ".aml"); + NewFilename = UtStringCacheCalloc (9); + if (NewFilename) + { + strncat (NewFilename, Table->Signature, 4); + strcat (NewFilename, ".aml"); + } + } + + if (!NewFilename) + { + AcpiOsPrintf (" **** Could not generate AML output filename\n"); + return; } /* Open the ASL definition block */ @@ -690,8 +662,6 @@ AdCreateTableHeader ( "DefinitionBlock (\"%s\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", NewFilename, Table->Signature, Table->Revision, Table->OemId, Table->OemTableId, Table->OemRevision); - - ACPI_FREE (NewFilename); } @@ -726,6 +696,7 @@ AdDisplayTables ( } AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX); + MpEmitMappingInfo (); if (AcpiGbl_DbOpt_verbose) { @@ -746,8 +717,7 @@ AdDisplayTables ( * * FUNCTION: AdGetLocalTables * - * PARAMETERS: Filename - Not used - * GetAllTables - TRUE if all tables are desired + * PARAMETERS: None * * RETURN: Status * @@ -757,105 +727,36 @@ AdDisplayTables ( ACPI_STATUS AdGetLocalTables ( - char *Filename, - BOOLEAN GetAllTables) + void) { ACPI_STATUS Status; ACPI_TABLE_HEADER TableHeader; ACPI_TABLE_HEADER *NewTable; - UINT32 NumTables; - UINT32 PointerSize; UINT32 TableIndex; - if (GetAllTables) - { - ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_RSDT); - AcpiOsTableOverride (&TableHeader, &NewTable); - if (!NewTable) - { - fprintf (stderr, "Could not obtain RSDT\n"); - return (AE_NO_ACPI_TABLES); - } - else - { - AdWriteTable (NewTable, NewTable->Length, - ACPI_SIG_RSDT, NewTable->OemTableId); - } - - if (ACPI_COMPARE_NAME (NewTable->Signature, ACPI_SIG_RSDT)) - { - PointerSize = sizeof (UINT32); - } - else - { - PointerSize = sizeof (UINT64); - } - - /* - * Determine the number of tables pointed to by the RSDT/XSDT. - * This is defined by the ACPI Specification to be the number of - * pointers contained within the RSDT/XSDT. The size of the pointers - * is architecture-dependent. - */ - NumTables = (NewTable->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize; - AcpiOsPrintf ("There are %u tables defined in the %4.4s\n\n", - NumTables, NewTable->Signature); - - /* Get the FADT */ - - ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_FADT); - AcpiOsTableOverride (&TableHeader, &NewTable); - if (NewTable) - { - AdWriteTable (NewTable, NewTable->Length, - ACPI_SIG_FADT, NewTable->OemTableId); - } - AcpiOsPrintf ("\n"); - - /* Don't bother with FACS, it is usually all zeros */ - } - - /* Always get the DSDT */ + /* Get the DSDT via table override */ ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT); AcpiOsTableOverride (&TableHeader, &NewTable); - if (NewTable) - { - AdWriteTable (NewTable, NewTable->Length, - ACPI_SIG_DSDT, NewTable->OemTableId); - - /* Store DSDT in the Table Manager */ - - Status = AcpiTbStoreTable (0, NewTable, NewTable->Length, - 0, &TableIndex); - if (ACPI_FAILURE (Status)) - { - fprintf (stderr, "Could not store DSDT\n"); - return (AE_NO_ACPI_TABLES); - } - } - else + if (!NewTable) { fprintf (stderr, "Could not obtain DSDT\n"); return (AE_NO_ACPI_TABLES); } -#if 0 - /* TBD: Future implementation */ + AdWriteTable (NewTable, NewTable->Length, + ACPI_SIG_DSDT, NewTable->OemTableId); - AcpiOsPrintf ("\n"); + /* Store DSDT in the Table Manager */ - /* Get all SSDTs */ - - ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_SSDT); - do + Status = AcpiTbStoreTable (0, NewTable, NewTable->Length, + 0, &TableIndex); + if (ACPI_FAILURE (Status)) { - NewTable = NULL; - Status = AcpiOsTableOverride (&TableHeader, &NewTable); - - } while (NewTable); -#endif + fprintf (stderr, "Could not store DSDT\n"); + return (AE_NO_ACPI_TABLES); + } return (AE_OK); } @@ -944,7 +845,8 @@ AdParseTable ( if (LoadTable) { Status = AcpiTbStoreTable ((ACPI_PHYSICAL_ADDRESS) Table, Table, - Table->Length, ACPI_TABLE_ORIGIN_ALLOCATED, &TableIndex); + Table->Length, ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, + &TableIndex); if (ACPI_FAILURE (Status)) { return (Status); @@ -979,9 +881,12 @@ AdParseTable ( return (AE_OK); } - /* Pass 3: Parse control methods and link their parse trees into the main parse tree */ - - fprintf (stderr, "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); + /* + * Pass 3: Parse control methods and link their parse trees + * into the main parse tree + */ + fprintf (stderr, + "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); Status = AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot); fprintf (stderr, "\n"); diff --git a/sys/contrib/dev/acpica/common/adwalk.c b/sys/contrib/dev/acpica/common/adwalk.c index 80f6d83d504f..df0222dfc32d 100644 --- a/sys/contrib/dev/acpica/common/adwalk.c +++ b/sys/contrib/dev/acpica/common/adwalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -469,8 +468,9 @@ AcpiDmFindOrphanDescending ( !ChildOp->Common.Node) { AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String, - NULL, &Path); - AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", Op->Common.AmlOpName, Path); + NULL, &Path); + AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", + Op->Common.AmlOpName, Path); ACPI_FREE (Path); NextOp = Op->Common.Next; @@ -478,22 +478,26 @@ AcpiDmFindOrphanDescending ( { /* This NamePath has no args, assume it is an integer */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp); - AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", ArgCount, AcpiDmCountChildren (Op)); + AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", + ArgCount, AcpiDmCountChildren (Op)); if (ArgCount < 1) { /* One Arg means this is just a Store(Name,Target) */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; #endif @@ -509,7 +513,8 @@ AcpiDmFindOrphanDescending ( { /* This NamePath has no args, assume it is an integer */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } @@ -518,11 +523,13 @@ AcpiDmFindOrphanDescending ( { /* One Arg means this is just a Store(Name,Target) */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; @@ -554,7 +561,8 @@ AcpiDmFindOrphanDescending ( /* And namepath is the first argument */ (ParentOp->Common.Value.Arg == Op)) { - AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (Op, + Op->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); break; } } @@ -564,8 +572,8 @@ AcpiDmFindOrphanDescending ( * operator) - it *must* be a method invocation, nothing else is * grammatically possible. */ - AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); - + AcpiDmAddOpToExternalList (Op, + Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; @@ -741,6 +749,7 @@ AcpiDmXrefDescendingOp ( ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; UINT32 ParamCount = 0; + char *Pathname; WalkState = Info->WalkState; @@ -750,11 +759,13 @@ AcpiDmXrefDescendingOp ( if ((!(OpInfo->Flags & AML_NAMED)) && (!(OpInfo->Flags & AML_CREATE)) && - (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) + (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP) && + (Op->Common.AmlOpcode != AML_NOTIFY_OP)) { goto Exit; } + /* Get the NamePath from the appropriate place */ if (OpInfo->Flags & AML_NAMED) @@ -791,6 +802,10 @@ AcpiDmXrefDescendingOp ( Path = NextOp->Common.Value.String; } } + else if (Op->Common.AmlOpcode == AML_NOTIFY_OP) + { + Path = Op->Common.Value.Arg->Asl.Value.String; + } else { Path = Op->Common.Value.String; @@ -808,11 +823,14 @@ AcpiDmXrefDescendingOp ( * The namespace is also used as a lookup table for references to resource * descriptors and the fields within them. */ + Node = NULL; Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Node); if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL)) { + /* Node was created by an External() statement */ + Status = AE_NOT_FOUND; } @@ -820,25 +838,38 @@ AcpiDmXrefDescendingOp ( { if (Status == AE_NOT_FOUND) { - AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType, 0); - /* - * We could install this into the namespace, but we catch duplicate - * externals when they are added to the list. + * Add this symbol as an external declaration, except if the + * parent is a CondRefOf operator. For this operator, we do not + * need an external, nor do we want one, since this can cause + * disassembly problems if the symbol is actually a control + * method. */ -#if 0 - Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_DONT_OPEN_SCOPE, - WalkState, &Node); -#endif + if (!(Op->Asl.Parent && + (Op->Asl.Parent->Asl.AmlOpcode == AML_COND_REF_OF_OP))) + { + if (Node) + { + AcpiDmAddNodeToExternalList (Node, + (UINT8) ObjectType, 0, 0); + } + else + { + AcpiDmAddOpToExternalList (Op, Path, + (UINT8) ObjectType, 0, 0); + } + } } } /* - * Found the node in external table, add it to external list - * Node->OwnerId == 0 indicates built-in ACPI Names, _OS_ etc + * Found the node, but check if it came from an external table. + * Add it to external list. Note: Node->OwnerId == 0 indicates + * one of the built-in ACPI Names (_OS_ etc.) which can safely + * be ignored. */ - else if (Node->OwnerId && WalkState->OwnerId != Node->OwnerId) + else if (Node->OwnerId && + (WalkState->OwnerId != Node->OwnerId)) { ObjectType2 = ObjectType; @@ -852,7 +883,16 @@ AcpiDmXrefDescendingOp ( } } - AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType2, ParamCount | 0x80); + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_NO_MEMORY); + } + + AcpiDmAddNodeToExternalList (Node, (UINT8) ObjectType2, + ParamCount, ACPI_EXT_RESOLVED_REFERENCE); + + ACPI_FREE (Pathname); Op->Common.Node = Node; } else diff --git a/sys/contrib/dev/acpica/common/ahids.c b/sys/contrib/dev/acpica/common/ahids.c new file mode 100644 index 000000000000..d272fdae8043 --- /dev/null +++ b/sys/contrib/dev/acpica/common/ahids.c @@ -0,0 +1,240 @@ +/****************************************************************************** + * + * Module Name: ahids - Table of ACPI/PNP _HID/_CID values + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahids") + + +/* + * ACPI/PNP Device IDs with description strings + */ +const AH_DEVICE_ID AslDeviceIds[] = +{ + {"10EC5640", "Realtek I2S Audio Codec"}, + {"80860F09", "Intel PWM Controller"}, + {"80860F0A", "Intel Atom UART Controller"}, + {"80860F0E", "Intel SPI Controller"}, + {"80860F14", "Intel Baytrail SDIO/MMC Host Controller"}, + {"80860F28", "Intel SST Audio DSP"}, + {"80860F41", "Intel Baytrail I2C Host Controller"}, + {"ACPI0001", "SMBus 1.0 Host Controller"}, + {"ACPI0002", "Smart Battery Subsystem"}, + {"ACPI0003", "Power Source Device"}, + {"ACPI0004", "Module Device"}, + {"ACPI0005", "SMBus 2.0 Host Controller"}, + {"ACPI0006", "GPE Block Device"}, + {"ACPI0007", "Processor Device"}, + {"ACPI0008", "Ambient Light Sensor Device"}, + {"ACPI0009", "I/O xAPIC Device"}, + {"ACPI000A", "I/O APIC Device"}, + {"ACPI000B", "I/O SAPIC Device"}, + {"ACPI000C", "Processor Aggregator Device"}, + {"ACPI000D", "Power Meter Device"}, + {"ACPI000E", "Time and Alarm Device"}, + {"ACPI000F", "User Presence Detection Device"}, + {"ADMA0F28", "Intel Audio DMA"}, + {"AMCR0F28", "Intel Audio Machine Driver"}, + {"ATK4001", "Asus Radio Control Button"}, + {"ATML1000", "Atmel Touchscreen Controller"}, + {"AUTH2750", "AuthenTec AES2750"}, + {"BCM2E39", "Broadcom BT Serial Bus Driver over UART Bus Enumerator"}, + {"BCM4752E", "Broadcom GPS Controller"}, + {"BMG0160", "Bosch Gyro Sensor"}, + {"CPLM3218", "Capella Micro CM3218x Ambient Light Sensor"}, + {"DELLABCE", "Dell Airplane Mode Switch Driver"}, + {"DLAC3002", "Qualcomm Atheros Bluetooth UART Transport"}, + {"FTTH5506", "FocalTech 5506 Touch Controller"}, + {"HAD0F28", "Intel HDMI Audio Driver"}, + {"INBC0000", "GPIO Expander"}, + {"INT0002", "Virtual GPIO Controller"}, + {"INT0800", "Intel 82802 Firmware Hub Device"}, + {"INT3394", "ACPI System Fan"}, + {"INT3396", "Standard Power Management Controller"}, + {"INT33A0", "Intel Smart Connect Technology Device"}, + {"INT33A1", "Intel Power Engine"}, + {"INT33BB", "Intel Baytrail SD Host Controller"}, + {"INT33BD", "Intel Baytrail Mailbox Device"}, + {"INT33BE", "Camera Sensor OV5693"}, + {"INT33C0", "Intel Serial I/O SPI Host Controller"}, + {"INT33C1", "Intel Serial I/O SPI Host Controller"}, + {"INT33C2", "Intel Serial I/O I2C Host Controller"}, + {"INT33C3", "Intel Serial I/O I2C Host Controller"}, + {"INT33C4", "Intel Serial I/O UART Host Controller"}, + {"INT33C5", "Intel Serial I/O UART Host Controller"}, + {"INT33C6", "Intel SD Host Controller"}, + {"INT33C7", "Intel Serial I/O GPIO Host Controller"}, + {"INT33C8", "Intel Smart Sound Technology Host Controller"}, + {"INT33C9", "Wolfson Microelectronics Audio WM5102"}, + {"INT33CA", "Intel SPB Peripheral"}, + {"INT33CB", "Intel Smart Sound Technology Audio Codec"}, + {"INT33D1", "Intel GPIO Buttons"}, + {"INT33D2", "Intel GPIO Buttons"}, + {"INT33D3", "Intel GPIO Buttons"}, + {"INT33D4", "Intel GPIO Buttons"}, + {"INT33D6", "Intel Virtual Buttons Device"}, + {"INT33F0", "Camera Sensor MT9M114"}, + {"INT33F4", "XPOWER PMIC Controller"}, + {"INT33F5", "TI PMIC Controller"}, + {"INT33FB", "MIPI-CSI Camera Sensor OV2722"}, + {"INT33FC", "Intel Baytrail GPIO Controller"}, + {"INT33FD", "Intel Baytrail Power Management IC"}, + {"INT33FE", "XPOWER Battery Device"}, + {"INT3400", "Intel Dynamic Power Performance Management"}, + {"INT3401", "Intel Extended Thermal Model CPU"}, + {"INT3403", "DPTF Temperature Sensor"}, + {"INT3406", "Intel Dynamic Platform & Thermal Framework Display Participant"}, + {"INT3407", "DPTF Platform Power Meter"}, + {"INT340E", "Motherboard Resources"}, + {"INT3420", "Intel Bluetooth RF Kill"}, + {"INT3F0D", "ACPI Motherboard Resources"}, + {"INTCF1A", "Sony IMX175 Camera Sensor"}, + {"INTCFD9", "Intel Baytrail SOC GPIO Controller"}, + {"INTL9C60", "Intel Baytrail SOC DMA Controller"}, + {"INVN6500", "InvenSense MPU-6500 Six Axis Gyroscope and Accelerometer"}, + {"LNXCPU", "Linux Logical CPU"}, + {"LNXPOWER", "ACPI Power Resource (power gating)"}, + {"LNXPWRBN", "System Power Button"}, + {"LNXSYBUS", "System Bus"}, + {"LNXSYSTM", "ACPI Root Node"}, + {"LNXTHERM", "ACPI Thermal Zone"}, + {"LNXVIDEO", "ACPI Video Controller"}, + {"MAX17047", "Fuel Gauge Controller"}, + {"MSFT0101", "TPM 2.0 Security Device"}, + {"NXP5442", "NXP 5442 Near Field Communications Controller"}, + {"NXP5472", "NXP NFC"}, + {"PNP0000", "8259-compatible Programmable Interrupt Controller"}, + {"PNP0001", "EISA Interrupt Controller"}, + {"PNP0002", "MCA Interrupt Controller"}, + {"PNP0003", "IO-APIC Interrupt Controller"}, + {"PNP0100", "PC-class System Timer"}, + {"PNP0103", "HPET System Timer"}, + {"PNP0200", "PC-class DMA Controller"}, + {"PNP0300", "IBM PC/XT Keyboard Controller (83 key)"}, + {"PNP0301", "IBM PC/XT Keyboard Controller (86 key)"}, + {"PNP0302", "IBM PC/XT Keyboard Controller (84 key)"}, + {"PNP0303", "IBM Enhanced Keyboard (101/102-key, PS/2 Mouse)"}, + {"PNP0400", "Standard LPT Parallel Port"}, + {"PNP0401", "ECP Parallel Port"}, + {"PNP0500", "Standard PC COM Serial Port"}, + {"PNP0501", "16550A-compatible COM Serial Port"}, + {"PNP0510", "Generic IRDA-compatible Device"}, + {"PNP0800", "Microsoft Sound System Compatible Device"}, + {"PNP0A03", "PCI Bus"}, + {"PNP0A05", "Generic Container Device"}, + {"PNP0A06", "Generic Container Device"}, + {"PNP0A08", "PCI Express Bus"}, + {"PNP0B00", "AT Real-Time Clock"}, + {"PNP0B01", "Intel PIIX4-compatible RTC/CMOS Device"}, + {"PNP0B02", "Dallas Semiconductor-compatible RTC/CMOS Device"}, + {"PNP0C01", "System Board"}, + {"PNP0C02", "PNP Motherboard Resources"}, + {"PNP0C04", "x87-compatible Floating Point Processing Unit"}, + {"PNP0C08", "ACPI Core Hardware"}, + {"PNP0C09", "Embedded Controller Device"}, + {"PNP0C0A", "Control Method Battery"}, + {"PNP0C0B", "Fan (Thermal Solution)"}, + {"PNP0C0C", "Power Button Device"}, + {"PNP0C0D", "Lid Device"}, + {"PNP0C0E", "Sleep Button Device"}, + {"PNP0C0F", "PCI Interrupt Link Device"}, + {"PNP0C10", "System Indicator Device"}, + {"PNP0C11", "Thermal Zone"}, + {"PNP0C12", "Device Bay Controller"}, + {"PNP0C14", "Windows Management Instrumentation Device"}, + {"PNP0C15", "Docking Station"}, + {"PNP0C40", "Standard Button Controller"}, + {"PNP0C50", "HID Protocol Device (I2C bus)"}, + {"PNP0C60", "Display Sensor Device"}, + {"PNP0C70", "Dock Sensor Device"}, + {"PNP0C80", "Memory Device"}, + {"PNP0D10", "XHCI USB Controller with debug"}, + {"PNP0D15", "XHCI USB Controller without debug"}, + {"PNP0D20", "EHCI USB Controller without debug"}, + {"PNP0D25", "EHCI USB Controller with debug"}, + {"PNP0D40", "SDA Standard Compliant SD Host Controller"}, + {"PNP0D80", "Windows-compatible System Power Management Controller"}, + {"PNP0F03", "Microsoft PS/2-style Mouse"}, + {"PNP0F13", "PS/2 Mouse"}, + {"RTL8723", "Realtek Wireless Controller"}, + {"SMB0349", "Charger"}, + {"SMO91D0", "Sensor Hub"}, + {"SMSC3750", "SMSC 3750 USB MUX"}, + {"SSPX0000", "Intel SSP Device"}, + {"TBQ24296", "Charger"}, + + {NULL, NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchHardwareId + * + * PARAMETERS: HardwareId - String representation of an _HID or _CID + * + * RETURN: ID info struct. NULL if HardwareId is not found + * + * DESCRIPTION: Lookup an _HID/_CID in the device ID table + * + ******************************************************************************/ + +const AH_DEVICE_ID * +AcpiAhMatchHardwareId ( + char *HardwareId) +{ + const AH_DEVICE_ID *Info; + + + for (Info = AslDeviceIds; Info->Name; Info++) + { + if (!ACPI_STRCMP (HardwareId, Info->Name)) + { + return (Info); + } + } + + return (NULL); +} diff --git a/sys/contrib/dev/acpica/common/ahpredef.c b/sys/contrib/dev/acpica/common/ahpredef.c index de28b40aa5c0..4522ca698afa 100644 --- a/sys/contrib/dev/acpica/common/ahpredef.c +++ b/sys/contrib/dev/acpica/common/ahpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,9 @@ #include #include +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahpredef") + /* * iASL only needs a partial table (short descriptions only). * AcpiHelp needs the full table. @@ -94,6 +97,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_BTM", "Battery Time", "Returns the battery runtime"), AH_PREDEF ("_BTP", "Battery Trip Point", "Sets a Control Method Battery trip point"), AH_PREDEF ("_CBA", "Configuration Base Address", "Sets the base address for a PCI Express host bridge"), + AH_PREDEF ("_CCA", "Cache Coherency Attribute", "Returns a device's support level for cache coherency"), AH_PREDEF ("_CDM", "Clock Domain", "Returns a logical processor's clock domain identifier"), AH_PREDEF ("_CID", "Compatible ID", "Returns a device's Plug and Play Compatible ID list"), AH_PREDEF ("_CLS", "Class Code", "Returns PCI class code and subclass"), @@ -118,6 +122,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_DOS", "Disable Output Switching", "Sets the display output switching mode"), AH_PREDEF ("_DPL", "Device Selection Polarity", "Polarity of Device Selection signal, Resource Descriptor field"), AH_PREDEF ("_DRS", "Drive Strength", "Drive Strength setting for GPIO connection, Resource Descriptor field"), + AH_PREDEF ("_DSD", "Device-Specific Data", "Returns a list of device property information"), AH_PREDEF ("_DSM", "Device-Specific Method", "Executes device-specific functions"), AH_PREDEF ("_DSS", "Device Set State", "Sets the display device state"), AH_PREDEF ("_DSW", "Device Sleep Wake", "Sets the sleep and wake transition states for a device"), @@ -169,6 +174,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_LID", "Lid Status", "Returns the open/closed status of the lid on a mobile system"), AH_PREDEF ("_LIN", "Lines In Use", "Handshake lines, Resource Descriptor field"), AH_PREDEF ("_LL_", "Low Level", "Interrupt polarity, Resource Descriptor field"), + AH_PREDEF ("_LPD", "Low Power Dependencies", "Returns a list of dependencies for low power idle entry"), AH_PREDEF ("_MAF", "Maximum Address Fixed", "Resource Descriptor field"), AH_PREDEF ("_MAT", "Multiple APIC Table Entry", "Returns a list of MADT APIC structure entries"), AH_PREDEF ("_MAX", "Maximum Base Address", "Resource Descriptor field"), @@ -321,3 +327,34 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_Wxx", "Wake Event", "Method executed as a result of a wake event"), AH_PREDEF (NULL, NULL, NULL) }; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchPredefinedName + * + * PARAMETERS: Nameseg - Predefined name string + * + * RETURN: ID info struct. NULL if Nameseg not found + * + * DESCRIPTION: Lookup a predefined name. + * + ******************************************************************************/ + +const AH_PREDEFINED_NAME * +AcpiAhMatchPredefinedName ( + char *Nameseg) +{ + const AH_PREDEFINED_NAME *Info; + + + for (Info = AslPredefinedInfo; Info->Name; Info++) + { + if (ACPI_COMPARE_NAME (Nameseg, Info->Name)) + { + return (Info); + } + } + + return (NULL); +} diff --git a/sys/contrib/dev/acpica/common/ahuuids.c b/sys/contrib/dev/acpica/common/ahuuids.c new file mode 100644 index 000000000000..ef53008d44da --- /dev/null +++ b/sys/contrib/dev/acpica/common/ahuuids.c @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * Module Name: ahuuids - Table of known ACPI-related UUIDs + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahuuids") + +/* + * Table of "known" (ACPI-related) UUIDs + */ +const AH_UUID AcpiUuids[] = +{ + {"PCI Host Bridge Device", + "33db4d5b-1ff7-401c-9657-7441c03dd766"}, + + {"Platform-wide Capabilities", + "0811b06e-4a27-44f9-8d60-3cbbc22e7b48"}, + + {"Dynamic Enumeration", + "d8c1a3a6-be9b-4c9b-91bf-c3cb81fc5daf"}, + + {"GPIO Controller", + "4f248f40-d5e2-499f-834c-27758ea1cd3f"}, + + {"Battery Thermal Limit", + "4c2067e3-887d-475c-9720-4af1d3ed602e"}, + + {"Thermal Extensions", + "14d399cd-7a27-4b18-8fb4-7cb7b9f4e500"}, + + {"USB Controller", + "ce2ee385-00e6-48cb-9f05-2edb927c4899"}, + + {"HID I2C Device", + "3cdff6f7-4267-4555-ad05-b30a3d8938de"}, + + {"Power Button Device", + "dfbcf3c5-e7a5-44e6-9c1f-29c76f6e059c"}, + + {"Device Labeling Interface", + "e5c937d0-3553-4d7a-9117-ea4d19c3434d"}, + + {"SATA Controller", + "e4db149b-fcfe-425b-a6d8-92357d78fc7f"}, + + {"Physical Presence Interface", + "3dddfaa6-361b-4eb4-a424-8d10089d1653"}, + + {"Device Properties for _DSD", + "daffd814-6eba-4d8c-8a91-bc9bbf4aa301"}, + + {NULL, NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchUuid + * + * PARAMETERS: Data - Data buffer containing a UUID + * + * RETURN: ASCII description string for the UUID if it is found. + * + * DESCRIPTION: Returns a description string for "known" UUIDs, which are + * are UUIDs that are related to ACPI in some way. + * + ******************************************************************************/ + +const char * +AcpiAhMatchUuid ( + UINT8 *Data) +{ + const AH_UUID *Info; + UINT8 UuidBuffer[UUID_BUFFER_LENGTH]; + + + /* Walk the table of known ACPI-related UUIDs */ + + for (Info = AcpiUuids; Info->Description; Info++) + { + AcpiUtConvertStringToUuid (Info->String, UuidBuffer); + + if (!ACPI_MEMCMP (Data, UuidBuffer, UUID_BUFFER_LENGTH)) + { + return (Info->Description); + } + } + + return (NULL); +} diff --git a/sys/contrib/dev/acpica/common/cmfsize.c b/sys/contrib/dev/acpica/common/cmfsize.c new file mode 100644 index 000000000000..0f9b7385cf52 --- /dev/null +++ b/sys/contrib/dev/acpica/common/cmfsize.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * Module Name: cfsize - Common get file size function + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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_TOOLS + ACPI_MODULE_NAME ("cmfsize") + + +/******************************************************************************* + * + * FUNCTION: CmGetFileSize + * + * PARAMETERS: File - Open file descriptor + * + * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX) + * + * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open. + * Does not disturb the current file pointer. + * + ******************************************************************************/ + +UINT32 +CmGetFileSize ( + ACPI_FILE File) +{ + long FileSize; + long CurrentOffset; + ACPI_STATUS Status; + + + /* Save the current file pointer, seek to EOF to obtain file size */ + + CurrentOffset = AcpiOsGetFileOffset (File); + if (CurrentOffset < 0) + { + goto OffsetError; + } + + Status = AcpiOsSetFileOffset (File, 0, ACPI_FILE_END); + if (ACPI_FAILURE (Status)) + { + goto SeekError; + } + + FileSize = AcpiOsGetFileOffset (File); + if (FileSize < 0) + { + goto OffsetError; + } + + /* Restore original file pointer */ + + Status = AcpiOsSetFileOffset (File, CurrentOffset, ACPI_FILE_BEGIN); + if (ACPI_FAILURE (Status)) + { + goto SeekError; + } + + return ((UINT32) FileSize); + + +OffsetError: + AcpiLogError ("Could not get file offset"); + return (ACPI_UINT32_MAX); + +SeekError: + AcpiLogError ("Could not set file offset"); + return (ACPI_UINT32_MAX); +} diff --git a/sys/contrib/dev/acpica/common/dmextern.c b/sys/contrib/dev/acpica/common/dmextern.c index 56e278100b17..f8362e14d4e1 100644 --- a/sys/contrib/dev/acpica/common/dmextern.c +++ b/sys/contrib/dev/acpica/common/dmextern.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,7 +67,7 @@ */ static const char *AcpiGbl_DmTypeNames[] = { - /* 00 */ "", /* Type ANY */ + /* 00 */ ", UnknownObj", /* Type ANY */ /* 01 */ ", IntObj", /* 02 */ ", StrObj", /* 03 */ ", BuffObj", @@ -104,10 +104,19 @@ AcpiDmNormalizeParentPrefix ( char *Path); static void -AcpiDmAddToExternalListFromFile ( +AcpiDmAddPathToExternalList ( char *Path, UINT8 Type, - UINT32 Value); + UINT32 Value, + UINT16 Flags); + +static ACPI_STATUS +AcpiDmCreateNewExternal ( + char *ExternalPath, + char *InternalPath, + UINT8 Type, + UINT32 Value, + UINT16 Flags); /******************************************************************************* @@ -279,48 +288,41 @@ AcpiDmNormalizeParentPrefix ( ACPI_STATUS AcpiDmAddToExternalFileList ( - char *PathList) + char *Pathname) { ACPI_EXTERNAL_FILE *ExternalFile; - char *Path; - char *TmpPath; + char *LocalPathname; - if (!PathList) + if (!Pathname) { return (AE_OK); } - Path = strtok (PathList, ","); - - while (Path) + LocalPathname = ACPI_ALLOCATE (strlen (Pathname) + 1); + if (!LocalPathname) { - TmpPath = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (Path) + 1); - if (!TmpPath) - { - return (AE_NO_MEMORY); - } - - ACPI_STRCPY (TmpPath, Path); - - ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE)); - if (!ExternalFile) - { - ACPI_FREE (TmpPath); - return (AE_NO_MEMORY); - } - - ExternalFile->Path = TmpPath; - - if (AcpiGbl_ExternalFileList) - { - ExternalFile->Next = AcpiGbl_ExternalFileList; - } - - AcpiGbl_ExternalFileList = ExternalFile; - Path = strtok (NULL, ","); + return (AE_NO_MEMORY); } + ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE)); + if (!ExternalFile) + { + ACPI_FREE (LocalPathname); + return (AE_NO_MEMORY); + } + + /* Take a copy of the file pathname */ + + strcpy (LocalPathname, Pathname); + ExternalFile->Path = LocalPathname; + + if (AcpiGbl_ExternalFileList) + { + ExternalFile->Next = AcpiGbl_ExternalFileList; + } + + AcpiGbl_ExternalFileList = ExternalFile; return (AE_OK); } @@ -354,196 +356,6 @@ AcpiDmClearExternalFileList ( } -/******************************************************************************* - * - * FUNCTION: AcpiDmAddToExternalList - * - * PARAMETERS: Op - Current parser Op - * Path - Internal (AML) path to the object - * Type - ACPI object type to be added - * Value - Arg count if adding a Method object - * - * RETURN: None - * - * DESCRIPTION: Insert a new name into the global list of Externals which - * will in turn be later emitted as an External() declaration - * in the disassembled output. - * - ******************************************************************************/ - -void -AcpiDmAddToExternalList ( - ACPI_PARSE_OBJECT *Op, - char *Path, - UINT8 Type, - UINT32 Value) -{ - char *ExternalPath; - char *Fullpath = NULL; - ACPI_EXTERNAL_LIST *NewExternal; - ACPI_EXTERNAL_LIST *NextExternal; - ACPI_EXTERNAL_LIST *PrevExternal = NULL; - ACPI_STATUS Status; - BOOLEAN Resolved = FALSE; - - - if (!Path) - { - return; - } - - if (Type == ACPI_TYPE_METHOD) - { - if (Value & 0x80) - { - Resolved = TRUE; - } - Value &= 0x07; - } - - /* - * We don't want External() statements to contain a leading '\'. - * This prevents duplicate external statements of the form: - * - * External (\ABCD) - * External (ABCD) - * - * This would cause a compile time error when the disassembled - * output file is recompiled. - */ - if ((*Path == AML_ROOT_PREFIX) && (Path[1])) - { - Path++; - } - - /* Externalize the ACPI pathname */ - - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, - NULL, &ExternalPath); - if (ACPI_FAILURE (Status)) - { - return; - } - - /* - * Get the full pathname from the root if "Path" has one or more - * parent prefixes (^). Note: path will not contain a leading '\'. - */ - if (*Path == (UINT8) AML_PARENT_PREFIX) - { - Fullpath = AcpiDmNormalizeParentPrefix (Op, ExternalPath); - if (Fullpath) - { - /* Set new external path */ - - ACPI_FREE (ExternalPath); - ExternalPath = Fullpath; - } - } - - /* Check all existing externals to ensure no duplicates */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) - { - /* Duplicate method, check that the Value (ArgCount) is the same */ - - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Value != Value)) - { - ACPI_ERROR ((AE_INFO, - "External method arg count mismatch %s: Current %u, attempted %u", - NextExternal->Path, NextExternal->Value, Value)); - } - - /* Allow upgrade of type from ANY */ - - else if (NextExternal->Type == ACPI_TYPE_ANY) - { - NextExternal->Type = Type; - NextExternal->Value = Value; - } - - ACPI_FREE (ExternalPath); - return; - } - - NextExternal = NextExternal->Next; - } - - /* Allocate and init a new External() descriptor */ - - NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); - if (!NewExternal) - { - ACPI_FREE (ExternalPath); - return; - } - - NewExternal->Path = ExternalPath; - NewExternal->Type = Type; - NewExternal->Value = Value; - NewExternal->Resolved = Resolved; - NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); - - /* Was the external path with parent prefix normalized to a fullpath? */ - - if (Fullpath == ExternalPath) - { - /* Get new internal path */ - - Status = AcpiNsInternalizeName (ExternalPath, &Path); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (ExternalPath); - ACPI_FREE (NewExternal); - return; - } - - /* Set flag to indicate External->InternalPath need to be freed */ - - NewExternal->Flags |= ACPI_IPATH_ALLOCATED; - } - - NewExternal->InternalPath = Path; - - /* Link the new descriptor into the global list, alphabetically ordered */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (AcpiUtStricmp (NewExternal->Path, NextExternal->Path) < 0) - { - if (PrevExternal) - { - PrevExternal->Next = NewExternal; - } - else - { - AcpiGbl_ExternalList = NewExternal; - } - - NewExternal->Next = NextExternal; - return; - } - - PrevExternal = NextExternal; - NextExternal = NextExternal->Next; - } - - if (PrevExternal) - { - PrevExternal->Next = NewExternal; - } - else - { - AcpiGbl_ExternalList = NewExternal; - } -} - - /******************************************************************************* * * FUNCTION: AcpiDmGetExternalsFromFile @@ -585,6 +397,7 @@ AcpiDmGetExternalsFromFile ( { fprintf (stderr, "Could not open external reference file \"%s\"\n", Gbl_ExternalRefFilename); + AslAbort (); return; } @@ -593,18 +406,37 @@ AcpiDmGetExternalsFromFile ( while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ExternalRefFile)) { Token = strtok (StringBuffer, METHOD_SEPARATORS); /* "External" */ - if (!Token) continue; - if (strcmp (Token, "External")) continue; + if (!Token) + { + continue; + } + if (strcmp (Token, "External")) + { + continue; + } MethodName = strtok (NULL, METHOD_SEPARATORS); /* Method namepath */ - if (!MethodName) continue; + if (!MethodName) + { + continue; + } Token = strtok (NULL, METHOD_SEPARATORS); /* "MethodObj" */ - if (!Token) continue; - if (strcmp (Token, "MethodObj")) continue; + if (!Token) + { + continue; + } + + if (strcmp (Token, "MethodObj")) + { + continue; + } Token = strtok (NULL, METHOD_SEPARATORS); /* Arg count */ - if (!Token) continue; + if (!Token) + { + continue; + } /* Convert arg count string to an integer */ @@ -626,7 +458,8 @@ AcpiDmGetExternalsFromFile ( AcpiOsPrintf ("%s: Importing method external (%u arguments) %s\n", Gbl_ExternalRefFilename, ArgCount, MethodName); - AcpiDmAddToExternalListFromFile (MethodName, ACPI_TYPE_METHOD, ArgCount | 0x80); + AcpiDmAddPathToExternalList (MethodName, ACPI_TYPE_METHOD, + ArgCount, (ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_FILE)); ImportCount++; } @@ -651,11 +484,13 @@ AcpiDmGetExternalsFromFile ( /******************************************************************************* * - * FUNCTION: AcpiDmAddToExternalListFromFile + * FUNCTION: AcpiDmAddOpToExternalList * - * PARAMETERS: Path - Internal (AML) path to the object + * PARAMETERS: Op - Current parser Op + * Path - Internal (AML) path to the object * Type - ACPI object type to be added * Value - Arg count if adding a Method object + * Flags - To be passed to the external object * * RETURN: None * @@ -663,73 +498,325 @@ AcpiDmGetExternalsFromFile ( * will in turn be later emitted as an External() declaration * in the disassembled output. * + * This function handles the most common case where the referenced + * name is simply not found in the constructed namespace. + * ******************************************************************************/ -static void -AcpiDmAddToExternalListFromFile ( +void +AcpiDmAddOpToExternalList ( + ACPI_PARSE_OBJECT *Op, char *Path, UINT8 Type, - UINT32 Value) + UINT32 Value, + UINT16 Flags) { - char *InternalPath; char *ExternalPath; - ACPI_EXTERNAL_LIST *NewExternal; - ACPI_EXTERNAL_LIST *NextExternal; - ACPI_EXTERNAL_LIST *PrevExternal = NULL; + char *InternalPath = Path; + char *Temp; ACPI_STATUS Status; - BOOLEAN Resolved = FALSE; + + + ACPI_FUNCTION_TRACE (DmAddOpToExternalList); if (!Path) { - return; + return_VOID; } - /* TBD: Add a flags parameter */ + /* Remove a root backslash if present */ - if (Type == ACPI_TYPE_METHOD) - { - if (Value & 0x80) - { - Resolved = TRUE; - } - Value &= 0x07; - } - - /* - * We don't want External() statements to contain a leading '\'. - * This prevents duplicate external statements of the form: - * - * External (\ABCD) - * External (ABCD) - * - * This would cause a compile time error when the disassembled - * output file is recompiled. - */ if ((*Path == AML_ROOT_PREFIX) && (Path[1])) { Path++; } + /* Externalize the pathname */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, + NULL, &ExternalPath); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* + * Get the full pathname from the root if "Path" has one or more + * parent prefixes (^). Note: path will not contain a leading '\'. + */ + if (*Path == (UINT8) AML_PARENT_PREFIX) + { + Temp = AcpiDmNormalizeParentPrefix (Op, ExternalPath); + + /* Set new external path */ + + ACPI_FREE (ExternalPath); + ExternalPath = Temp; + if (!Temp) + { + return_VOID; + } + + /* Create the new internal pathname */ + + Flags |= ACPI_EXT_INTERNAL_PATH_ALLOCATED; + Status = AcpiNsInternalizeName (ExternalPath, &InternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + return_VOID; + } + } + + /* Create the new External() declaration node */ + + Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, + Type, Value, Flags); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + if (Flags & ACPI_EXT_INTERNAL_PATH_ALLOCATED) + { + ACPI_FREE (InternalPath); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddNodeToExternalList + * + * PARAMETERS: Node - Namespace node for object to be added + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * Flags - To be passed to the external object + * + * RETURN: None + * + * DESCRIPTION: Insert a new name into the global list of Externals which + * will in turn be later emitted as an External() declaration + * in the disassembled output. + * + * This function handles the case where the referenced name has + * been found in the namespace, but the name originated in a + * table other than the one that is being disassembled (such + * as a table that is added via the iASL -e option). + * + ******************************************************************************/ + +void +AcpiDmAddNodeToExternalList ( + ACPI_NAMESPACE_NODE *Node, + UINT8 Type, + UINT32 Value, + UINT16 Flags) +{ + char *ExternalPath; + char *InternalPath; + char *Temp; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DmAddNodeToExternalList); + + + if (!Node) + { + return_VOID; + } + + /* Get the full external and internal pathnames to the node */ + + ExternalPath = AcpiNsGetExternalPathname (Node); + if (!ExternalPath) + { + return_VOID; + } + + Status = AcpiNsInternalizeName (ExternalPath, &InternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + return_VOID; + } + + /* Remove the root backslash */ + + if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1])) + { + Temp = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (ExternalPath) + 1); + if (!Temp) + { + return_VOID; + } + + ACPI_STRCPY (Temp, &ExternalPath[1]); + ACPI_FREE (ExternalPath); + ExternalPath = Temp; + } + + /* Create the new External() declaration node */ + + Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, Type, + Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + ACPI_FREE (InternalPath); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddPathToExternalList + * + * PARAMETERS: Path - External name of the object to be added + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * Flags - To be passed to the external object + * + * RETURN: None + * + * DESCRIPTION: Insert a new name into the global list of Externals which + * will in turn be later emitted as an External() declaration + * in the disassembled output. + * + * This function currently is used to add externals via a + * reference file (via the -fe iASL option). + * + ******************************************************************************/ + +static void +AcpiDmAddPathToExternalList ( + char *Path, + UINT8 Type, + UINT32 Value, + UINT16 Flags) +{ + char *InternalPath; + char *ExternalPath; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DmAddPathToExternalList); + + + if (!Path) + { + return_VOID; + } + + /* Remove a root backslash if present */ + + if ((*Path == AML_ROOT_PREFIX) && (Path[1])) + { + Path++; + } + + /* Create the internal and external pathnames */ + + Status = AcpiNsInternalizeName (Path, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath, + NULL, &ExternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (InternalPath); + return_VOID; + } + + /* Create the new External() declaration node */ + + Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, + Type, Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + ACPI_FREE (InternalPath); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmCreateNewExternal + * + * PARAMETERS: ExternalPath - External path to the object + * InternalPath - Internal (AML) path to the object + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * Flags - To be passed to the external object + * + * RETURN: Status + * + * DESCRIPTION: Common low-level function to insert a new name into the global + * list of Externals which will in turn be later emitted as + * External() declarations in the disassembled output. + * + * Note: The external name should not include a root prefix + * (backslash). We do not want External() statements to contain + * a leading '\', as this prevents duplicate external statements + * of the form: + * + * External (\ABCD) + * External (ABCD) + * + * This would cause a compile time error when the disassembled + * output file is recompiled. + * + * There are two cases that are handled here. For both, we emit + * an External() statement: + * 1) The name was simply not found in the namespace. + * 2) The name was found, but it originated in a table other than + * the table that is being disassembled. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDmCreateNewExternal ( + char *ExternalPath, + char *InternalPath, + UINT8 Type, + UINT32 Value, + UINT16 Flags) +{ + ACPI_EXTERNAL_LIST *NewExternal; + ACPI_EXTERNAL_LIST *NextExternal; + ACPI_EXTERNAL_LIST *PrevExternal = NULL; + + + ACPI_FUNCTION_TRACE (DmCreateNewExternal); + + /* Check all existing externals to ensure no duplicates */ NextExternal = AcpiGbl_ExternalList; while (NextExternal) { - if (!ACPI_STRCMP (Path, NextExternal->Path)) + if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) { /* Duplicate method, check that the Value (ArgCount) is the same */ if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Value != Value)) + (NextExternal->Value != Value) && + (Value > 0)) { ACPI_ERROR ((AE_INFO, - "(File) External method arg count mismatch %s: Current %u, override to %u", + "External method arg count mismatch %s: Current %u, attempted %u", NextExternal->Path, NextExternal->Value, Value)); - - /* Override, since new value came from external reference file */ - - NextExternal->Value = Value; } /* Allow upgrade of type from ANY */ @@ -740,44 +827,31 @@ AcpiDmAddToExternalListFromFile ( NextExternal->Value = Value; } - return; + return_ACPI_STATUS (AE_ALREADY_EXISTS); } NextExternal = NextExternal->Next; } - /* Get the internal pathname (AML format) */ - - Status = AcpiNsInternalizeName (Path, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return; - } - /* Allocate and init a new External() descriptor */ NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); if (!NewExternal) { - ACPI_FREE (InternalPath); - return; + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Must copy and normalize the input path */ - - AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath, NULL, &ExternalPath); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Adding external reference node (%s) type [%s]\n", + ExternalPath, AcpiUtGetTypeName (Type))); + NewExternal->Flags = Flags; + NewExternal->Value = Value; NewExternal->Path = ExternalPath; NewExternal->Type = Type; - NewExternal->Value = Value; - NewExternal->Resolved = Resolved; - NewExternal->Length = (UINT16) ACPI_STRLEN (Path); + NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); NewExternal->InternalPath = InternalPath; - /* Set flag to indicate External->InternalPath needs to be freed */ - - NewExternal->Flags |= ACPI_IPATH_ALLOCATED | ACPI_FROM_REFERENCE_FILE; - /* Link the new descriptor into the global list, alphabetically ordered */ NextExternal = AcpiGbl_ExternalList; @@ -795,7 +869,7 @@ AcpiDmAddToExternalListFromFile ( } NewExternal->Next = NextExternal; - return; + return_ACPI_STATUS (AE_OK); } PrevExternal = NextExternal; @@ -810,6 +884,8 @@ AcpiDmAddToExternalListFromFile ( { AcpiGbl_ExternalList = NewExternal; } + + return_ACPI_STATUS (AE_OK); } @@ -985,7 +1061,7 @@ AcpiDmEmitExternals ( if (NextExternal->Type == ACPI_TYPE_METHOD) { AcpiGbl_NumExternalMethods++; - if (NextExternal->Resolved) + if (NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE) { AcpiGbl_ResolvedExternalMethods++; } @@ -1004,18 +1080,17 @@ AcpiDmEmitExternals ( while (NextExternal) { if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (!NextExternal->Resolved)) + (!(NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE))) { AcpiOsPrintf (" External (%s%s", NextExternal->Path, AcpiDmGetObjectTypeName (NextExternal->Type)); - AcpiOsPrintf ( - ") // Warning: Unresolved Method, " - "guessing %u arguments (may be incorrect, see warning above)\n", + AcpiOsPrintf (") // Warning: Unresolved method, " + "guessing %u arguments\n", NextExternal->Value); - NextExternal->Emitted = TRUE; + NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; } NextExternal = NextExternal->Next; @@ -1036,7 +1111,8 @@ AcpiDmEmitExternals ( NextExternal = AcpiGbl_ExternalList; while (NextExternal) { - if (!NextExternal->Emitted && (NextExternal->Flags & ACPI_FROM_REFERENCE_FILE)) + if (!(NextExternal->Flags & ACPI_EXT_EXTERNAL_EMITTED) && + (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_FILE)) { AcpiOsPrintf (" External (%s%s", NextExternal->Path, @@ -1051,7 +1127,7 @@ AcpiDmEmitExternals ( { AcpiOsPrintf (")\n"); } - NextExternal->Emitted = TRUE; + NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; } NextExternal = NextExternal->Next; @@ -1065,7 +1141,7 @@ AcpiDmEmitExternals ( */ while (AcpiGbl_ExternalList) { - if (!AcpiGbl_ExternalList->Emitted) + if (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_EXTERNAL_EMITTED)) { AcpiOsPrintf (" External (%s%s", AcpiGbl_ExternalList->Path, @@ -1087,7 +1163,7 @@ AcpiDmEmitExternals ( /* Free this external info block and move on to next external */ NextExternal = AcpiGbl_ExternalList->Next; - if (AcpiGbl_ExternalList->Flags & ACPI_IPATH_ALLOCATED) + if (AcpiGbl_ExternalList->Flags & ACPI_EXT_INTERNAL_PATH_ALLOCATED) { ACPI_FREE (AcpiGbl_ExternalList->InternalPath); } @@ -1209,12 +1285,24 @@ AcpiDmUnresolvedWarning ( " * were not specified. This resulting disassembler output file may not\n" " * compile because the disassembler did not know how many arguments\n" " * to assign to these methods. To specify the tables needed to resolve\n" - " * external control method references, use the one of the following\n" - " * example iASL invocations:\n" - " * iasl -e -d \n" - " * iasl -e -d \n" + " * external control method references, the -e option can be used to\n" + " * specify the filenames. Example iASL invocations:\n" + " * iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n" + " * iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n" + " * iasl -e ssdt*.aml -d dsdt.aml\n" + " *\n" + " * In addition, the -fe option can be used to specify a file containing\n" + " * control method external declarations with the associated method\n" + " * argument counts. Each line of the file must be of the form:\n" + " * External (, MethodObj, )\n" + " * Invocation:\n" + " * iasl -fe refs.txt -d dsdt.aml\n" + " *\n" + " * The following methods were unresolved and many not compile properly\n" + " * because the disassembler had to guess at the number of arguments\n" + " * required for each:\n" " */\n", - AcpiGbl_NumExternalMethods); + AcpiGbl_NumExternalMethods); } else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) { @@ -1223,10 +1311,21 @@ AcpiDmUnresolvedWarning ( AcpiOsPrintf (" /*\n" " * iASL Warning: There were %u external control methods found during\n" " * disassembly, but only %u %s resolved (%u unresolved). Additional\n" - " * ACPI tables are required to properly disassemble the code. This\n" + " * ACPI tables may be required to properly disassemble the code. This\n" " * resulting disassembler output file may not compile because the\n" " * disassembler did not know how many arguments to assign to the\n" " * unresolved methods.\n" + " *\n" + " * If necessary, the -fe option can be used to specify a file containing\n" + " * control method external declarations with the associated method\n" + " * argument counts. Each line of the file must be of the form:\n" + " * External (, MethodObj, )\n" + " * Invocation:\n" + " * iasl -fe refs.txt -d dsdt.aml\n" + " *\n" + " * The following methods were unresolved and many not compile properly\n" + " * because the disassembler had to guess at the number of arguments\n" + " * required for each:\n" " */\n", AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), @@ -1245,10 +1344,18 @@ AcpiDmUnresolvedWarning ( "were not specified. The resulting disassembler output file may not\n" "compile because the disassembler did not know how many arguments\n" "to assign to these methods. To specify the tables needed to resolve\n" - "external control method references, use the one of the following\n" - "example iASL invocations:\n" - " iasl -e -d \n" - " iasl -e -d \n", + "external control method references, the -e option can be used to\n" + "specify the filenames. Example iASL invocations:\n" + " iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n" + " iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n" + " iasl -e ssdt*.aml -d dsdt.aml\n" + "\n" + "In addition, the -fe option can be used to specify a file containing\n" + "control method external declarations with the associated method\n" + "argument counts. Each line of the file must be of the form:\n" + " External (, MethodObj, )\n" + "Invocation:\n" + " iasl -fe refs.txt -d dsdt.aml\n", AcpiGbl_NumExternalMethods); } else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) @@ -1258,10 +1365,17 @@ AcpiDmUnresolvedWarning ( fprintf (stderr, "\n" "iASL Warning: There were %u external control methods found during\n" "disassembly, but only %u %s resolved (%u unresolved). Additional\n" - "ACPI tables are required to properly disassemble the code. The\n" + "ACPI tables may be required to properly disassemble the code. The\n" "resulting disassembler output file may not compile because the\n" "disassembler did not know how many arguments to assign to the\n" - "unresolved methods.\n", + "unresolved methods.\n" + "\n" + "If necessary, the -fe option can be used to specify a file containing\n" + "control method external declarations with the associated method\n" + "argument counts. Each line of the file must be of the form:\n" + " External (, MethodObj, )\n" + "Invocation:\n" + " iasl -fe refs.txt -d dsdt.aml\n", AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods)); diff --git a/sys/contrib/dev/acpica/common/dmrestag.c b/sys/contrib/dev/acpica/common/dmrestag.c index 9b8549877e5e..e1b435b725b8 100644 --- a/sys/contrib/dev/acpica/common/dmrestag.c +++ b/sys/contrib/dev/acpica/common/dmrestag.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/common/dmtable.c b/sys/contrib/dev/acpica/common/dmtable.c index e7ce520b4ce8..0b756537cb3f 100644 --- a/sys/contrib/dev/acpica/common/dmtable.c +++ b/sys/contrib/dev/acpica/common/dmtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,9 +87,21 @@ static const char *AcpiDmDmarSubnames[] = "Reserved Memory Region", "Root Port ATS Capability", "Remapping Hardware Static Affinity", + "ACPI Namespace Device Declaration", "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmDmarScope[] = +{ + "Reserved value", + "PCI Endpoint Device", + "PCI Bridge Device", + "IOAPIC Device", + "Message-capable HPET Device", + "Namespace Device", + "Unknown Scope Type" /* Reserved */ +}; + static const char *AcpiDmEinjActions[] = { "Begin Operation", @@ -160,6 +172,13 @@ static const char *AcpiDmErstInstructions[] = "Unknown Instruction" }; +static const char *AcpiDmGtdtSubnames[] = +{ + "Generic Timer Block", + "Generic Watchdog Timer", + "Unknown SubTable Type" /* Reserved */ +}; + static const char *AcpiDmHestSubnames[] = { "IA-32 Machine Check Exception", @@ -189,20 +208,29 @@ static const char *AcpiDmHestNotifySubnames[] = static const char *AcpiDmMadtSubnames[] = { - "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ - "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ - "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ - "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ - "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ - "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ - "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ - "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ - "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ - "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ - "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ - "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ - "Generic Interrupt Distributor",/* ACPI_MADT_GENERIC_DISTRIBUTOR */ - "Unknown SubTable Type" /* Reserved */ + "Processor Local APIC", /* ACPI_MADT_TYPE_LOCAL_APIC */ + "I/O APIC", /* ACPI_MADT_TYPE_IO_APIC */ + "Interrupt Source Override", /* ACPI_MADT_TYPE_INTERRUPT_OVERRIDE */ + "NMI Source", /* ACPI_MADT_TYPE_NMI_SOURCE */ + "Local APIC NMI", /* ACPI_MADT_TYPE_LOCAL_APIC_NMI */ + "Local APIC Address Override", /* ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE */ + "I/O SAPIC", /* ACPI_MADT_TYPE_IO_SAPIC */ + "Local SAPIC", /* ACPI_MADT_TYPE_LOCAL_SAPIC */ + "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ + "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ + "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ + "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ + "Generic Interrupt Distributor", /* ACPI_MADT_GENERIC_DISTRIBUTOR */ + "Generic MSI Frame", /* ACPI_MADT_GENERIC_MSI_FRAME */ + "Generic Interrupt Redistributor", /* ACPI_MADT_GENERIC_REDISTRIBUTOR */ + "Unknown SubTable Type" /* Reserved */ +}; + +static const char *AcpiDmPcctSubnames[] = +{ + "Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */ + "HW-Reduced Communications Subspace", + "Unknown SubTable Type" /* Reserved */ }; static const char *AcpiDmPmttSubnames[] = @@ -225,6 +253,7 @@ static const char *AcpiDmSratSubnames[] = "Processor Local APIC/SAPIC Affinity", "Memory Affinity", "Processor Local x2APIC Affinity", + "GICC Affinity", "Unknown SubTable Type" /* Reserved */ }; @@ -235,6 +264,12 @@ static const char *AcpiDmIvrsSubnames[] = "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmLpitSubnames[] = +{ + "Native C-state Idle Structure", + "Simple I/O Idle Structure", + "Unknown SubTable Type" /* Reserved */ +}; #define ACPI_FADT_PM_RESERVED 9 @@ -286,7 +321,7 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot, "Simple Boot Flag Table"}, {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep, "Corrected Platform Error Polling table"}, {ACPI_SIG_CSRT, NULL, AcpiDmDumpCsrt, DtCompileCsrt, TemplateCsrt, "Core System Resource Table"}, - {ACPI_SIG_DBG2, NULL, AcpiDmDumpDbg2, NULL, NULL, "Debug Port table type 2"}, + {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2, AcpiDmDumpDbg2, DtCompileDbg2, TemplateDbg2, "Debug Port table type 2"}, {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp, "Debug Port table"}, {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar, "DMA Remapping table"}, {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt, "Embedded Controller Boot Resources Table"}, @@ -294,17 +329,18 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst, "Error Record Serialization Table"}, {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt, "Fixed ACPI Description Table (FADT)"}, {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt, "Firmware Performance Data Table"}, - {ACPI_SIG_GTDT, AcpiDmTableInfoGtdt, NULL, NULL, TemplateGtdt, "Generic Timer Description Table"}, + {ACPI_SIG_GTDT, NULL, AcpiDmDumpGtdt, DtCompileGtdt, TemplateGtdt, "Generic Timer Description Table"}, {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest, "Hardware Error Source Table"}, {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet, "High Precision Event Timer table"}, {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs, "I/O Virtualization Reporting Structure"}, + {ACPI_SIG_LPIT, NULL, AcpiDmDumpLpit, DtCompileLpit, TemplateLpit, "Low Power Idle Table"}, {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, DtCompileMadt, TemplateMadt, "Multiple APIC Description Table (MADT)"}, {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, DtCompileMcfg, TemplateMcfg, "Memory Mapped Configuration table"}, {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, NULL, TemplateMchi, "Management Controller Host Interface table"}, {ACPI_SIG_MPST, AcpiDmTableInfoMpst, AcpiDmDumpMpst, DtCompileMpst, TemplateMpst, "Memory Power State Table"}, {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct, "Maximum System Characteristics Table"}, {ACPI_SIG_MTMR, NULL, AcpiDmDumpMtmr, DtCompileMtmr, TemplateMtmr, "MID Timer Table"}, - {ACPI_SIG_PCCT, NULL, AcpiDmDumpPcct, NULL, NULL, "Platform Communications Channel Table"}, + {ACPI_SIG_PCCT, AcpiDmTableInfoPcct, AcpiDmDumpPcct, DtCompilePcct, TemplatePcct, "Platform Communications Channel Table"}, {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt, "Platform Memory Topology Table"}, {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt, "Root System Description Table"}, {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt, "S3 Performance Table"}, @@ -650,6 +686,7 @@ AcpiDmDumpTable ( UINT32 ByteLength; UINT8 Temp8; UINT16 Temp16; + UINT64 Value; ACPI_DMTABLE_DATA *TableData; const char *Name; BOOLEAN LastOutputBlankLine = FALSE; @@ -691,7 +728,9 @@ AcpiDmDumpTable ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: + case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: @@ -701,6 +740,7 @@ AcpiDmDumpTable ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -721,6 +761,7 @@ AcpiDmDumpTable ( case ACPI_DMT_NAME4: case ACPI_DMT_SIG: case ACPI_DMT_SLIC: + case ACPI_DMT_LPIT: ByteLength = 4; break; @@ -863,10 +904,19 @@ AcpiDmDumpTable ( * Dump bytes - high byte first, low byte last. * Note: All ACPI tables are little-endian. */ + Value = 0; for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--) { AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]); + Value |= Target[Temp8 - 1]; + Value <<= 8; } + + if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL)) + { + AcpiOsPrintf (" [Optional field not present]"); + } + AcpiOsPrintf ("\n"); break; @@ -1022,6 +1072,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target), AcpiDmDmarSubnames[Temp16]); break; + case ACPI_DMT_DMAR_SCOPE: + + /* DMAR device scope types */ + + Temp8 = *Target; + if (Temp8 > ACPI_DMAR_SCOPE_TYPE_RESERVED) + { + Temp8 = ACPI_DMAR_SCOPE_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmDmarScope[Temp8]); + break; + case ACPI_DMT_EINJACT: /* EINJ Action types */ @@ -1074,6 +1137,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmErstInstructions[Temp8]); break; + case ACPI_DMT_GTDT: + + /* GTDT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_GTDT_TYPE_RESERVED) + { + Temp8 = ACPI_GTDT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmGtdtSubnames[Temp8]); + break; + case ACPI_DMT_HEST: /* HEST subtable types */ @@ -1122,6 +1198,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmMadtSubnames[Temp8]); break; + case ACPI_DMT_PCCT: + + /* PCCT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_PCCT_TYPE_RESERVED) + { + Temp8 = ACPI_PCCT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmPcctSubnames[Temp8]); + break; + case ACPI_DMT_PMTT: /* PMTT subtable types */ @@ -1202,6 +1291,32 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, Name); break; + case ACPI_DMT_LPIT: + + /* LPIT subtable types */ + + Temp8 = *Target; + switch (Temp8) + { + case ACPI_LPIT_TYPE_NATIVE_CSTATE: + + Name = AcpiDmLpitSubnames[0]; + break; + + case ACPI_LPIT_TYPE_SIMPLE_IO: + + Name = AcpiDmLpitSubnames[1]; + break; + + default: + + Name = AcpiDmLpitSubnames[2]; + break; + } + + AcpiOsPrintf (UINT32_FORMAT, *Target, Name); + break; + case ACPI_DMT_EXIT: return (AE_OK); diff --git a/sys/contrib/dev/acpica/common/dmtbdump.c b/sys/contrib/dev/acpica/common/dmtbdump.c index 89d38e706780..2f88a54e2311 100644 --- a/sys/contrib/dev/acpica/common/dmtbdump.c +++ b/sys/contrib/dev/acpica/common/dmtbdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -419,12 +419,12 @@ AcpiDmDumpAsf ( UINT8 Type; - /* No main table, only sub-tables */ + /* No main table, only subtables */ SubTable = ACPI_ADD_PTR (ACPI_ASF_INFO, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, SubTable->Header.Length, AcpiDmTableInfoAsfHdr); @@ -479,7 +479,7 @@ AcpiDmDumpAsf ( default: - AcpiOsPrintf ("\n**** Unknown ASF sub-table type 0x%X\n", SubTable->Header.Type); + AcpiOsPrintf ("\n**** Unknown ASF subtable type 0x%X\n", SubTable->Header.Type); return; } @@ -541,7 +541,7 @@ AcpiDmDumpAsf ( AcpiOsPrintf ("\n"); - /* Point to next sub-table */ + /* Point to next subtable */ if (!SubTable->Header.Length) { @@ -586,7 +586,7 @@ AcpiDmDumpCpep ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Table, Offset); while (Offset < Table->Length) @@ -599,7 +599,7 @@ AcpiDmDumpCpep ( return; } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Header.Length; SubTable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, SubTable, @@ -638,7 +638,7 @@ AcpiDmDumpCsrt ( /* The main table only contains the ACPI header, thus already handled */ - /* Sub-tables (Resource Groups) */ + /* Subtables (Resource Groups) */ SubTable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset); while (Offset < Table->Length) @@ -702,7 +702,7 @@ AcpiDmDumpCsrt ( SubSubTable->Length); } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, SubTable, @@ -746,7 +746,7 @@ AcpiDmDumpDbg2 ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset); while (Offset < Table->Length) @@ -809,10 +809,13 @@ AcpiDmDumpDbg2 ( /* Dump the OemData (optional) */ - AcpiDmDumpBuffer (SubTable, SubTable->OemDataOffset, SubTable->OemDataLength, - Offset + SubTable->OemDataOffset, "OEM Data"); + if (SubTable->OemDataOffset) + { + AcpiDmDumpBuffer (SubTable, SubTable->OemDataOffset, SubTable->OemDataLength, + Offset + SubTable->OemDataOffset, "OEM Data"); + } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, SubTable, @@ -858,12 +861,12 @@ AcpiDmDumpDmar ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, @@ -888,21 +891,27 @@ AcpiDmDumpDmar ( ScopeOffset = sizeof (ACPI_DMAR_RESERVED_MEMORY); break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; ScopeOffset = sizeof (ACPI_DMAR_ATSR); break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; ScopeOffset = sizeof (ACPI_DMAR_RHSA); break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + ScopeOffset = sizeof (ACPI_DMAR_ANDD); + break; + default: - AcpiOsPrintf ("\n**** Unknown DMAR sub-table type 0x%X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", SubTable->Type); return; } @@ -913,7 +922,16 @@ AcpiDmDumpDmar ( return; } - /* Dump the device scope entries (if any) */ + /* + * Dump the optional device scope entries + */ + if ((SubTable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (SubTable->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + goto NextSubtable; + } ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, SubTable, ScopeOffset); while (ScopeOffset < SubTable->Length) @@ -953,7 +971,8 @@ AcpiDmDumpDmar ( ScopeTable, ScopeTable->Length); } - /* Point to next sub-table */ +NextSubtable: + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, SubTable, SubTable->Length); @@ -992,7 +1011,7 @@ AcpiDmDumpEinj ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset); while (Offset < Table->Length) @@ -1005,7 +1024,7 @@ AcpiDmDumpEinj ( return; } - /* Point to next sub-table (each subtable is of fixed length) */ + /* Point to next subtable (each subtable is of fixed length) */ Offset += sizeof (ACPI_WHEA_HEADER); SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, SubTable, @@ -1045,7 +1064,7 @@ AcpiDmDumpErst ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset); while (Offset < Table->Length) @@ -1058,7 +1077,7 @@ AcpiDmDumpErst ( return; } - /* Point to next sub-table (each subtable is of fixed length) */ + /* Point to next subtable (each subtable is of fixed length) */ Offset += sizeof (ACPI_WHEA_HEADER); SubTable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, SubTable, @@ -1093,12 +1112,12 @@ AcpiDmDumpFpdt ( /* There is no main table (other than the standard ACPI header) */ - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, @@ -1122,7 +1141,7 @@ AcpiDmDumpFpdt ( default: - AcpiOsPrintf ("\n**** Unknown FPDT sub-table type 0x%X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n", SubTable->Type); /* Attempt to continue */ @@ -1142,7 +1161,7 @@ AcpiDmDumpFpdt ( } NextSubTable: - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, SubTable, SubTable->Length); @@ -1150,6 +1169,123 @@ AcpiDmDumpFpdt ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpGtdt + * + * PARAMETERS: Table - A GTDT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a GTDT. This table type consists + * of an open-ended number of subtables. + * + ******************************************************************************/ + +void +AcpiDmDumpGtdt ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_GTDT_HEADER *SubTable; + UINT32 Length = Table->Length; + UINT32 Offset = sizeof (ACPI_TABLE_GTDT); + ACPI_DMTABLE_INFO *InfoTable; + UINT32 SubTableLength; + UINT32 GtCount; + ACPI_GTDT_TIMER_ENTRY *GtxTable; + + + /* Main table */ + + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoGtdt); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Subtables */ + + SubTable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common subtable header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoGtdtHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + GtCount = 0; + switch (SubTable->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + SubTableLength = sizeof (ACPI_GTDT_TIMER_BLOCK); + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + SubTable))->TimerCount; + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + SubTableLength = sizeof (ACPI_GTDT_WATCHDOG); + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + /* Cannot continue on unknown type - no length */ + + AcpiOsPrintf ("\n**** Unknown GTDT subtable type 0x%X\n", SubTable->Type); + return; + } + + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to end of current subtable (each subtable above is of fixed length) */ + + Offset += SubTableLength; + + /* If there are any Gt Timer Blocks from above, dump them now */ + + if (GtCount) + { + GtxTable = ACPI_ADD_PTR (ACPI_GTDT_TIMER_ENTRY, SubTable, SubTableLength); + SubTableLength += GtCount * sizeof (ACPI_GTDT_TIMER_ENTRY); + + while (GtCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, GtxTable, + sizeof (ACPI_GTDT_TIMER_ENTRY), AcpiDmTableInfoGtdt0a); + if (ACPI_FAILURE (Status)) + { + return; + } + Offset += sizeof (ACPI_GTDT_TIMER_ENTRY); + GtxTable++; + GtCount--; + } + } + + /* Point to next subtable */ + + SubTable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, SubTable, SubTableLength); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpHest @@ -1185,7 +1321,7 @@ AcpiDmDumpHest ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset); while (Offset < Table->Length) @@ -1243,7 +1379,7 @@ AcpiDmDumpHest ( /* Cannot continue on unknown type - no length */ - AcpiOsPrintf ("\n**** Unknown HEST sub-table type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown HEST subtable type 0x%X\n", SubTable->Type); return; } @@ -1281,7 +1417,7 @@ AcpiDmDumpHest ( } } - /* Point to next sub-table */ + /* Point to next subtable */ SubTable = ACPI_ADD_PTR (ACPI_HEST_HEADER, SubTable, SubTableLength); } @@ -1324,12 +1460,12 @@ AcpiDmDumpIvrs ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -1355,7 +1491,7 @@ AcpiDmDumpIvrs ( default: - AcpiOsPrintf ("\n**** Unknown IVRS sub-table type 0x%X\n", + AcpiOsPrintf ("\n**** Unknown IVRS subtable type 0x%X\n", SubTable->Type); /* Attempt to continue */ @@ -1458,7 +1594,7 @@ AcpiDmDumpIvrs ( } NextSubTable: - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, SubTable, SubTable->Length); @@ -1466,6 +1602,85 @@ AcpiDmDumpIvrs ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpLpit + * + * PARAMETERS: Table - A LPIT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a LPIT. This table type consists + * of an open-ended number of subtables. Note: There are no + * entries in the main table. An LPIT consists of the table + * header and then subtables only. + * + ******************************************************************************/ + +void +AcpiDmDumpLpit ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_LPIT_HEADER *SubTable; + UINT32 Length = Table->Length; + UINT32 Offset = sizeof (ACPI_TABLE_LPIT); + ACPI_DMTABLE_INFO *InfoTable; + UINT32 SubTableLength; + + + /* Subtables */ + + SubTable = ACPI_ADD_PTR (ACPI_LPIT_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common subtable header */ + + Status = AcpiDmDumpTable (Length, Offset, SubTable, + sizeof (ACPI_LPIT_HEADER), AcpiDmTableInfoLpitHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + switch (SubTable->Type) + { + case ACPI_LPIT_TYPE_NATIVE_CSTATE: + + InfoTable = AcpiDmTableInfoLpit0; + SubTableLength = sizeof (ACPI_LPIT_NATIVE); + break; + + case ACPI_LPIT_TYPE_SIMPLE_IO: + + InfoTable = AcpiDmTableInfoLpit1; + SubTableLength = sizeof (ACPI_LPIT_IO); + break; + + default: + + /* Cannot continue on unknown type - no length */ + + AcpiOsPrintf ("\n**** Unknown LPIT subtable type 0x%X\n", SubTable->Type); + return; + } + + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTableLength, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + AcpiOsPrintf ("\n"); + + /* Point to next subtable */ + + Offset += SubTableLength; + SubTable = ACPI_ADD_PTR (ACPI_LPIT_HEADER, SubTable, SubTableLength); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpMadt @@ -1498,12 +1713,12 @@ AcpiDmDumpMadt ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, @@ -1580,9 +1795,19 @@ AcpiDmDumpMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: - AcpiOsPrintf ("\n**** Unknown MADT sub-table type 0x%X\n\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown MADT subtable type 0x%X\n\n", SubTable->Type); /* Attempt to continue */ @@ -1602,7 +1827,7 @@ AcpiDmDumpMadt ( } NextSubTable: - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, SubTable, SubTable->Length); @@ -1639,7 +1864,7 @@ AcpiDmDumpMcfg ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_MCFG_ALLOCATION, Table, Offset); while (Offset < Table->Length) @@ -1659,7 +1884,7 @@ AcpiDmDumpMcfg ( return; } - /* Point to next sub-table (each subtable is of fixed length) */ + /* Point to next subtable (each subtable is of fixed length) */ Offset += sizeof (ACPI_MCFG_ALLOCATION); SubTable = ACPI_ADD_PTR (ACPI_MCFG_ALLOCATION, SubTable, @@ -1841,12 +2066,12 @@ AcpiDmDumpMsct ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -1856,7 +2081,7 @@ AcpiDmDumpMsct ( return; } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += sizeof (ACPI_MSCT_PROXIMITY); SubTable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, SubTable, sizeof (ACPI_MSCT_PROXIMITY)); @@ -1893,12 +2118,12 @@ AcpiDmDumpMtmr ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_MTMR_ENTRY, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -1908,7 +2133,7 @@ AcpiDmDumpMtmr ( return; } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += sizeof (ACPI_MTMR_ENTRY); SubTable = ACPI_ADD_PTR (ACPI_MTMR_ENTRY, SubTable, sizeof (ACPI_MTMR_ENTRY)); @@ -1935,6 +2160,7 @@ AcpiDmDumpPcct ( { ACPI_STATUS Status; ACPI_PCCT_SUBSPACE *SubTable; + ACPI_DMTABLE_INFO *InfoTable; UINT32 Length = Table->Length; UINT32 Offset = sizeof (ACPI_TABLE_PCCT); @@ -1947,20 +2173,50 @@ AcpiDmDumpPcct ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_PCCT_SUBSPACE, Table, Offset); while (Offset < Table->Length) { + /* Common subtable header */ + AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, - SubTable->Header.Length, AcpiDmTableInfoPcct0); + SubTable->Header.Length, AcpiDmTableInfoPcctHdr); if (ACPI_FAILURE (Status)) { return; } - /* Point to next sub-table */ + switch (SubTable->Header.Type) + { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + + default: + + AcpiOsPrintf ( + "\n**** Unexpected or unknown PCCT subtable type 0x%X\n\n", + SubTable->Header.Type); + return; + } + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Header.Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Point to next subtable */ Offset += SubTable->Header.Length; SubTable = ACPI_ADD_PTR (ACPI_PCCT_SUBSPACE, SubTable, @@ -2108,8 +2364,7 @@ AcpiDmDumpPmtt ( if (DomainCount) { AcpiOsPrintf ( - "\n**** DomainCount exceeds subtable length\n\n", - MemSubTable->Type); + "\n**** DomainCount exceeds subtable length\n\n"); } /* Walk the physical component (DIMM) subtables */ @@ -2209,7 +2464,7 @@ AcpiDmDumpS3pt ( SubTable = ACPI_ADD_PTR (ACPI_S3PT_HEADER, S3ptTable, Offset); while (Offset < S3ptTable->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (S3ptTable->Length, Offset, SubTable, @@ -2233,7 +2488,7 @@ AcpiDmDumpS3pt ( default: - AcpiOsPrintf ("\n**** Unknown S3PT sub-table type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown S3PT subtable type 0x%X\n", SubTable->Type); /* Attempt to continue */ @@ -2254,7 +2509,7 @@ AcpiDmDumpS3pt ( } NextSubTable: - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_S3PT_HEADER, SubTable, SubTable->Length); @@ -2291,7 +2546,7 @@ AcpiDmDumpSlic ( SubTable = ACPI_ADD_PTR (ACPI_SLIC_HEADER, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -2315,7 +2570,7 @@ AcpiDmDumpSlic ( default: - AcpiOsPrintf ("\n**** Unknown SLIC sub-table type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown SLIC subtable type 0x%X\n", SubTable->Type); /* Attempt to continue */ @@ -2336,7 +2591,7 @@ AcpiDmDumpSlic ( } NextSubTable: - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_SLIC_HEADER, SubTable, SubTable->Length); @@ -2452,12 +2707,12 @@ AcpiDmDumpSrat ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -2484,8 +2739,13 @@ AcpiDmDumpSrat ( InfoTable = AcpiDmTableInfoSrat2; break; + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + default: - AcpiOsPrintf ("\n**** Unknown SRAT sub-table type 0x%X\n", SubTable->Type); + AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n", SubTable->Type); /* Attempt to continue */ @@ -2506,7 +2766,7 @@ AcpiDmDumpSrat ( } NextSubTable: - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Length; SubTable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, SubTable, SubTable->Length); @@ -2543,12 +2803,12 @@ AcpiDmDumpVrtc ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -2558,7 +2818,7 @@ AcpiDmDumpVrtc ( return; } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += sizeof (ACPI_VRTC_ENTRY); SubTable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, SubTable, sizeof (ACPI_VRTC_ENTRY)); @@ -2595,12 +2855,12 @@ AcpiDmDumpWdat ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset); while (Offset < Table->Length) { - /* Common sub-table header */ + /* Common subtable header */ AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Table->Length, Offset, SubTable, @@ -2610,7 +2870,7 @@ AcpiDmDumpWdat ( return; } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += sizeof (ACPI_WDAT_ENTRY); SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, SubTable, sizeof (ACPI_WDAT_ENTRY)); diff --git a/sys/contrib/dev/acpica/common/dmtbinfo.c b/sys/contrib/dev/acpica/common/dmtbinfo.c index 4272a33f3614..cadb4c4e2c36 100644 --- a/sys/contrib/dev/acpica/common/dmtbinfo.c +++ b/sys/contrib/dev/acpica/common/dmtbinfo.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,11 +137,16 @@ #define ACPI_DMAR1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RESERVED_MEMORY,f) #define ACPI_DMAR2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ATSR,f) #define ACPI_DMAR3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RHSA,f) +#define ACPI_DMAR4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ANDD,f) #define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_ERST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_FPDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) #define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT,f) #define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_PTR,f) +#define ACPI_GTDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_BLOCK,f) +#define ACPI_GTDT0a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_ENTRY,f) +#define ACPI_GTDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_WATCHDOG,f) +#define ACPI_GTDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_HEADER,f) #define ACPI_HEST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_MACHINE_CHECK,f) #define ACPI_HEST1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_CORRECTED,f) #define ACPI_HEST2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_NMI,f) @@ -158,6 +163,9 @@ #define ACPI_IVRS8A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_DEVICE8A,f) #define ACPI_IVRS8B_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_DEVICE8B,f) #define ACPI_IVRS8C_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_DEVICE8C,f) +#define ACPI_LPITH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_LPIT_HEADER,f) +#define ACPI_LPIT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_LPIT_NATIVE,f) +#define ACPI_LPIT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_LPIT_IO,f) #define ACPI_MADT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_LOCAL_APIC,f) #define ACPI_MADT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_IO_APIC,f) #define ACPI_MADT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_INTERRUPT_OVERRIDE,f) @@ -171,6 +179,8 @@ #define ACPI_MADT10_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f) #define ACPI_MADT11_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_INTERRUPT,f) #define ACPI_MADT12_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_DISTRIBUTOR,f) +#define ACPI_MADT13_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f) +#define ACPI_MADT14_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_REDISTRIBUTOR,f) #define ACPI_MADTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f) #define ACPI_MCFG0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MCFG_ALLOCATION,f) #define ACPI_MPST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MPST_POWER_NODE,f) @@ -181,6 +191,7 @@ #define ACPI_MSCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MSCT_PROXIMITY,f) #define ACPI_MTMR0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MTMR_ENTRY,f) #define ACPI_PCCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f) +#define ACPI_PCCT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED,f) #define ACPI_PMTT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_SOCKET,f) #define ACPI_PMTT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_CONTROLLER,f) #define ACPI_PMTT1A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_DOMAIN,f) @@ -196,6 +207,7 @@ #define ACPI_SRAT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_CPU_AFFINITY,f) #define ACPI_SRAT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_MEM_AFFINITY,f) #define ACPI_SRAT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f) +#define ACPI_SRAT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SRAT_GICC_AFFINITY,f) #define ACPI_VRTC0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_VRTC_ENTRY,f) #define ACPI_WDAT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WDAT_ENTRY,f) @@ -212,7 +224,11 @@ #define ACPI_SRAT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_CPU_AFFINITY,f,o) #define ACPI_SRAT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_MEM_AFFINITY,f,o) #define ACPI_SRAT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_X2APIC_CPU_AFFINITY,f,o) +#define ACPI_SRAT3_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_SRAT_GICC_AFFINITY,f,o) #define ACPI_GTDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_GTDT,f,o) +#define ACPI_GTDT0a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o) +#define ACPI_GTDT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o) +#define ACPI_LPITH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_LPIT_HEADER,f,o) #define ACPI_MADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_MADT,f,o) #define ACPI_MADT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_APIC,f,o) #define ACPI_MADT2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_INTERRUPT_OVERRIDE,f,o) @@ -223,9 +239,11 @@ #define ACPI_MADT9_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC,f,o) #define ACPI_MADT10_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_X2APIC_NMI,f,o) #define ACPI_MADT11_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_INTERRUPT,f,o) +#define ACPI_MADT13_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f,o) #define ACPI_MPST0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_NODE,f,o) #define ACPI_MPST2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_DATA,f,o) #define ACPI_PCCT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_PCCT,f,o) +#define ACPI_PCCT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED,f,o) #define ACPI_PMTTH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PMTT_HEADER,f,o) #define ACPI_WDDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_WDDT,f,o) #define ACPI_EINJ0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_WHEA_HEADER,f,o) @@ -436,17 +454,22 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = { {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "Reserved", 0}, ACPI_DMT_TERMINATOR }; -/* ACPI 2.0+ Extensions (FADT version 3 and 4) */ +/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = { {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, - {ACPI_DMT_UINT24, ACPI_FADT_OFFSET (Reserved4[0]), "Reserved", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "ARM Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "PSCI Compliant", 0}, + {ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "Must use HVC for PSCI", 0}, + ACPI_DMT_NEW_LINE, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "FADT Minor Revision", 0}, {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XFacs), "FACS Address", 0}, {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XDsdt), "DSDT Address", 0}, {ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aEventBlock), "PM1A Event Block", 0}, @@ -720,12 +743,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Device[] = { {ACPI_DMT_UINT8, ACPI_DBG20_OFFSET (Revision), "Revision", 0}, - {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (Length), "Length", 0}, + {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (Length), "Length", DT_LENGTH}, {ACPI_DMT_UINT8, ACPI_DBG20_OFFSET (RegisterCount), "Register Count", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (NamepathLength), "Namepath Length", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (NamepathOffset), "Namepath Offset", 0}, - {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataLength), "OEM Data Length", 0}, - {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataOffset), "OEM Data Offset", 0}, + {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataLength), "OEM Data Length", DT_DESCRIBES_OPTIONAL}, + {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataOffset), "OEM Data Offset", DT_DESCRIBES_OPTIONAL}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (PortType), "Port Type", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (PortSubtype), "Port Subtype", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (Reserved), "Reserved", 0}, @@ -754,6 +777,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Name[] = ACPI_DMT_TERMINATOR }; +ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2OemData[] = +{ + {ACPI_DMT_BUFFER, 0, "OEM Data", DT_OPTIONAL}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -797,7 +826,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[] = { - {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EntryType), "Device Scope Entry Type", 0}, + {ACPI_DMT_DMAR_SCOPE, ACPI_DMARS_OFFSET (EntryType), "Device Scope Type", 0}, {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (Length), "Entry Length", DT_LENGTH}, {ACPI_DMT_UINT16, ACPI_DMARS_OFFSET (Reserved), "Reserved", 0}, {ACPI_DMT_UINT8, ACPI_DMARS_OFFSET (EnumerationId), "Enumeration ID", 0}, @@ -849,6 +878,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[] = ACPI_DMT_TERMINATOR }; +/* 4: ACPI Namespace Device Declaration Structure */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[] = +{ + {ACPI_DMT_UINT24, ACPI_DMAR4_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_DMAR4_OFFSET (DeviceNumber), "Device Number", 0}, + {ACPI_DMT_STRING, ACPI_DMAR4_OFFSET (DeviceName[0]), "Device Name", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -988,29 +1027,89 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[] = ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt[] = { - {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (Address), "Timer Address", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (Flags,0), "Memory Present", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (CounterBlockAddresss), "Counter Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (Reserved), "Reserved", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecurePl1Interrupt), "Secure PL1 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecurePl1Flags), "SPL1 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (SecurePl1Flags,0), "Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (SecurePl1Flags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecureEl1Interrupt), "Secure EL1 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (SecureEl1Flags), "EL1 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (SecureEl1Flags,0), "Always On", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl1Interrupt), "Non-Secure PL1 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl1Flags), "NSPL1 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecurePl1Flags,0),"Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecurePl1Flags,0),"Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl1Interrupt), "Non-Secure EL1 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl1Flags), "NEL1 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (NonSecureEl1Flags,0),"Always On", 0}, ACPI_DMT_NEW_LINE, {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (VirtualTimerInterrupt), "Virtual Timer Interrupt", 0}, {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (VirtualTimerFlags), "VT Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Trigger Mode", 0}, {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (VirtualTimerFlags,0),"Always On", 0}, ACPI_DMT_NEW_LINE, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl2Interrupt), "Non-Secure PL2 Interrupt", 0}, - {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecurePl2Flags), "NSPL2 Flags (decoded below)", DT_FLAG}, - {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecurePl2Flags,0),"Trigger Mode", 0}, - {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecurePl2Flags,0),"Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl2Interrupt), "Non-Secure EL2 Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (NonSecureEl2Flags), "NEL2 Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT_FLAG_OFFSET (NonSecureEl2Flags,0),"Always On", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT_OFFSET (CounterReadBlockAddress), "Counter Read Block Address", 0}, + ACPI_DMT_NEW_LINE, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (PlatformTimerCount), "Platform Timer Count", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT_OFFSET (PlatformTimerOffset), "Platform Timer Offset", 0}, + ACPI_DMT_TERMINATOR +}; + +/* GTDT Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdtHdr[] = +{ + {ACPI_DMT_GTDT, ACPI_GTDTH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT16, ACPI_GTDTH_OFFSET (Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR +}; + +/* GTDT Subtables */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0[] = +{ + {ACPI_DMT_UINT8, ACPI_GTDT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0_OFFSET (BlockAddress), "Block Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0_OFFSET (TimerCount), "Timer Count", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0_OFFSET (TimerOffset), "Timer Offset", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0a[] = +{ + {ACPI_DMT_UINT8 , ACPI_GTDT0a_OFFSET (FrameNumber), "Frame Number", 0}, + {ACPI_DMT_UINT24, ACPI_GTDT0a_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0a_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT0a_OFFSET (El0BaseAddress), "EL0 Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (TimerInterrupt), "Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (TimerFlags), "Timer Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (TimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (TimerFlags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (VirtualTimerInterrupt), "Virtual Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (VirtualTimerFlags), "Virtual Timer Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (VirtualTimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (VirtualTimerFlags,0), "Polarity", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT0a_OFFSET (CommonFlags), "Common Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_GTDT0a_FLAG_OFFSET (CommonFlags,0), "Secure", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT0a_FLAG_OFFSET (CommonFlags,0), "Always On", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt1[] = +{ + {ACPI_DMT_UINT8, ACPI_GTDT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT1_OFFSET (RefreshFrameAddress), "Refresh Frame Address", 0}, + {ACPI_DMT_UINT64, ACPI_GTDT1_OFFSET (ControlFrameAddress), "Control Frame Address", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT1_OFFSET (TimerInterrupt), "Timer Interrupt", 0}, + {ACPI_DMT_UINT32, ACPI_GTDT1_OFFSET (TimerFlags), "Timer Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Trigger Mode", 0}, + {ACPI_DMT_FLAG1, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Polarity", 0}, + {ACPI_DMT_FLAG2, ACPI_GTDT1_FLAG_OFFSET (TimerFlags,0), "Security", 0}, ACPI_DMT_TERMINATOR }; @@ -1299,6 +1398,59 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs8c[] = }; +/******************************************************************************* + * + * LPIT - Low Power Idle Table + * + ******************************************************************************/ + +/* Main table consists only of the standard ACPI table header */ + +/* Common Subtable header (one per Subtable) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoLpitHdr[] = +{ + {ACPI_DMT_LPIT, ACPI_LPITH_OFFSET (Type), "Subtable Type", 0}, + {ACPI_DMT_UINT32, ACPI_LPITH_OFFSET (Length), "Length", DT_LENGTH}, + {ACPI_DMT_UINT16, ACPI_LPITH_OFFSET (UniqueId), "Unique ID", 0}, + {ACPI_DMT_UINT16, ACPI_LPITH_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_LPITH_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_LPITH_FLAG_OFFSET (Flags, 0), "State Disabled", 0}, + {ACPI_DMT_FLAG1, ACPI_LPITH_FLAG_OFFSET (Flags, 0), "No Counter", 0}, + ACPI_DMT_TERMINATOR +}; + +/* LPIT Subtables */ + +/* 0: Native C-state */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoLpit0[] = +{ + {ACPI_DMT_GAS, ACPI_LPIT0_OFFSET (EntryTrigger), "Entry Trigger", 0}, + {ACPI_DMT_UINT32, ACPI_LPIT0_OFFSET (Residency), "Residency", 0}, + {ACPI_DMT_UINT32, ACPI_LPIT0_OFFSET (Latency), "Latency", 0}, + {ACPI_DMT_GAS, ACPI_LPIT0_OFFSET (ResidencyCounter), "Residency Counter", 0}, + {ACPI_DMT_UINT64, ACPI_LPIT0_OFFSET (CounterFrequency), "Counter Frequency", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 1: Simple I/O */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoLpit1[] = +{ + {ACPI_DMT_GAS, ACPI_LPIT1_OFFSET (EntryTrigger), "Entry Trigger", 0}, + {ACPI_DMT_UINT32, ACPI_LPIT1_OFFSET (TriggerAction), "Trigger Action", 0}, + {ACPI_DMT_UINT64, ACPI_LPIT1_OFFSET (TriggerValue), "Trigger Value", 0}, + {ACPI_DMT_UINT64, ACPI_LPIT1_OFFSET (TriggerMask), "Trigger Mask", 0}, + {ACPI_DMT_GAS, ACPI_LPIT1_OFFSET (MinimumIdleState), "Minimum Idle State", 0}, + {ACPI_DMT_UINT32, ACPI_LPIT1_OFFSET (Residency), "Residency", 0}, + {ACPI_DMT_UINT32, ACPI_LPIT1_OFFSET (Latency), "Latency", 0}, + {ACPI_DMT_GAS, ACPI_LPIT1_OFFSET (ResidencyCounter), "Residency Counter", 0}, + {ACPI_DMT_UINT64, ACPI_LPIT1_OFFSET (CounterFrequency), "Counter Frequency", 0}, + ACPI_DMT_TERMINATOR +}; + + /******************************************************************************* * * MADT - Multiple APIC Description Table and subtables @@ -1464,14 +1616,21 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[] = ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[] = { {ACPI_DMT_UINT16, ACPI_MADT11_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (GicId), "Local GIC Hardware ID", 0}, + {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (CpuInterfaceNumber), "CPU Interface Number", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (Uid), "Processor UID", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Processor Enabled", 0}, + {ACPI_DMT_FLAG1, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Performance Interrupt Trigger Mode", 0}, + {ACPI_DMT_FLAG2, ACPI_MADT11_FLAG_OFFSET (Flags,0), "Virtual GIC Interrupt Trigger Mode", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (ParkingVersion), "Parking Protocol Version", 0}, {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (PerformanceInterrupt), "Performance Interrupt", 0}, {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ParkedAddress), "Parked Address", 0}, {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicvBaseAddress), "Virtual GIC Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GichBaseAddress), "Hypervisor GIC Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (VgicInterrupt), "Virtual GIC Interrupt", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicrBaseAddress), "Redistributor Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ArmMpidr), "ARM MPIDR", 0}, ACPI_DMT_TERMINATOR }; @@ -1487,6 +1646,30 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[] = ACPI_DMT_TERMINATOR }; +/* 13: Generic MSI Frame (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_MADT13_OFFSET (MsiFrameId), "MSI Frame ID", 0}, + {ACPI_DMT_UINT64, ACPI_MADT13_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT13_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_MADT13_FLAG_OFFSET (Flags,0), "Select SPI", 0}, + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (SpiCount), "SPI Count", 0}, + {ACPI_DMT_UINT16, ACPI_MADT13_OFFSET (SpiBase), "SPI Base", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 14: Generic Redistributor (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[] = +{ + {ACPI_DMT_UINT16, ACPI_MADT14_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_MADT14_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_MADT14_OFFSET (Length), "Length", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -1677,25 +1860,52 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[] = { {ACPI_DMT_UINT32, ACPI_PCCT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_PCCT_FLAG_OFFSET (Flags,0), "Doorbell", 0}, - {ACPI_DMT_UINT32, ACPI_PCCT_OFFSET (Latency), "Command Latency", 0}, - {ACPI_DMT_UINT32, ACPI_PCCT_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT_OFFSET (Reserved), "Reserved", 0}, ACPI_DMT_TERMINATOR }; /* PCCT subtables */ +ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[] = +{ + {ACPI_DMT_PCCT, ACPI_PCCT0_OFFSET (Header.Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT0_OFFSET (Header.Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR +}; + /* 0: Generic Communications Subspace */ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[] = { - {ACPI_DMT_UINT8, ACPI_PCCT0_OFFSET (Header.Type), "Subtable Type", 0}, - {ACPI_DMT_UINT8, ACPI_PCCT0_OFFSET (Header.Length), "Length", DT_LENGTH}, {ACPI_DMT_UINT48, ACPI_PCCT0_OFFSET (Reserved[0]), "Reserved", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (BaseAddress), "Base Address", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (Length), "Address Length", 0}, {ACPI_DMT_GAS, ACPI_PCCT0_OFFSET (DoorbellRegister), "Doorbell Register", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (PreserveMask), "Preserve Mask", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (WriteMask), "Write Mask", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT0_OFFSET (Latency), "Command Latency", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT0_OFFSET (MaxAccessRate), "Maximum Access Rate", 0}, + {ACPI_DMT_UINT16, ACPI_PCCT0_OFFSET (MinTurnaroundTime), "Minimum Turnaround Time", 0}, + ACPI_DMT_TERMINATOR +}; + +/* 1: HW-reduced Communications Subspace (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[] = +{ + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (DoorbellInterrupt), "Doorbell Interrupt", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT1_OFFSET (Flags), "Flags (Decoded Below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_PCCT1_FLAG_OFFSET (Flags,0), "Polarity", 0}, + {ACPI_DMT_FLAG1, ACPI_PCCT1_FLAG_OFFSET (Flags,0), "Mode", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT1_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (Length), "Address Length", 0}, + {ACPI_DMT_GAS, ACPI_PCCT1_OFFSET (DoorbellRegister), "Doorbell Register", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (PreserveMask), "Preserve Mask", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT1_OFFSET (WriteMask), "Write Mask", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (Latency), "Command Latency", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT1_OFFSET (MaxAccessRate), "Maximum Access Rate", 0}, + {ACPI_DMT_UINT16, ACPI_PCCT1_OFFSET (MinTurnaroundTime), "Minimum Turnaround Time", 0}, ACPI_DMT_TERMINATOR }; @@ -1927,7 +2137,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[] = { {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterfaceType), "Interface Type", 0}, - {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved", DT_NON_ZERO}, /* Value must be 1 */ {ACPI_DMT_UINT16, ACPI_SPMI_OFFSET (SpecRevision), "IPMI Spec Version", 0}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterruptType), "Interrupt Type", 0}, {ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (GpeNumber), "GPE Number", 0}, @@ -1978,7 +2188,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[] = {ACPI_DMT_FLAG0, ACPI_SRAT0_FLAG_OFFSET (Flags,0), "Enabled", 0}, {ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (LocalSapicEid), "Local Sapic EID", 0}, {ACPI_DMT_UINT24, ACPI_SRAT0_OFFSET (ProximityDomainHi[0]), "Proximity Domain High(24)", 0}, - {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (ClockDomain), "Clock Domain", 0}, ACPI_DMT_TERMINATOR }; @@ -2013,6 +2223,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[] = ACPI_DMT_TERMINATOR }; +/* : GICC Affinity (ACPI 5.1) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[] = +{ + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (ProximityDomain), "Proximity Domain", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (AcpiProcessorUid), "Acpi Processor UID", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, + {ACPI_DMT_FLAG0, ACPI_SRAT3_FLAG_OFFSET (Flags,0), "Enabled", 0}, + {ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (ClockDomain), "Clock Domain", 0}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * diff --git a/sys/contrib/dev/acpica/common/getopt.c b/sys/contrib/dev/acpica/common/getopt.c index 69f2ed518fdc..cf3eb593c0b7 100644 --- a/sys/contrib/dev/acpica/common/getopt.c +++ b/sys/contrib/dev/acpica/common/getopt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,14 +51,12 @@ * "f|" - Option has required single-char sub-options */ -#include -#include #include #include #include #define ACPI_OPTION_ERROR(msg, badchar) \ - if (AcpiGbl_Opterr) {fprintf (stderr, "%s%c\n", msg, badchar);} + if (AcpiGbl_Opterr) {AcpiLogError ("%s%c\n", msg, badchar);} int AcpiGbl_Opterr = 1; @@ -123,7 +121,7 @@ AcpiGetoptArgument ( * PARAMETERS: argc, argv - from main * opts - options info list * - * RETURN: Option character or EOF + * RETURN: Option character or ACPI_OPT_END * * DESCRIPTION: Get the next option * @@ -145,12 +143,12 @@ AcpiGetopt( argv[AcpiGbl_Optind][0] != '-' || argv[AcpiGbl_Optind][1] == '\0') { - return (EOF); + return (ACPI_OPT_END); } - else if (strcmp (argv[AcpiGbl_Optind], "--") == 0) + else if (ACPI_STRCMP (argv[AcpiGbl_Optind], "--") == 0) { AcpiGbl_Optind++; - return (EOF); + return (ACPI_OPT_END); } } @@ -161,7 +159,7 @@ AcpiGetopt( /* Make sure that the option is legal */ if (CurrentChar == ':' || - (OptsPtr = strchr (opts, CurrentChar)) == NULL) + (OptsPtr = ACPI_STRCHR (opts, CurrentChar)) == NULL) { ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar); diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index f5338bc656f9..acd41bedbc9a 100644 --- a/sys/contrib/dev/acpica/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -569,3 +568,51 @@ ApCheckRegMethod ( AslError (ASL_WARNING, ASL_MSG_NO_REGION, Op, NULL); } + + +/******************************************************************************* + * + * FUNCTION: ApFindNameInScope + * + * PARAMETERS: Name - Name to search for + * Op - Current parse op + * + * RETURN: TRUE if name found in the same scope as Op. + * + * DESCRIPTION: Determine if a name appears in the same scope as Op, as either + * a Method() or a Name(). + * + ******************************************************************************/ + +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Parent; + + + /* Get the start of the current scope */ + + Parent = Op->Asl.Parent; + Next = Parent->Asl.Child; + + /* Search entire scope for a match to the name */ + + while (Next) + { + if ((Next->Asl.ParseOpcode == PARSEOP_METHOD) || + (Next->Asl.ParseOpcode == PARSEOP_NAME)) + { + if (ACPI_COMPARE_NAME (Name, Next->Asl.NameSeg)) + { + return (TRUE); + } + } + + Next = Next->Asl.Next; + } + + return (FALSE); +} diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c new file mode 100644 index 000000000000..f8a3980a09bd --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslascii.c @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Module Name: aslascii - ASCII detection and support routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslascii") + + +/* Local prototypes */ + +static void +FlConsumeAnsiComment ( + FILE *Handle, + ASL_FILE_STATUS *Status); + +static void +FlConsumeNewComment ( + FILE *Handle, + ASL_FILE_STATUS *Status); + + +/******************************************************************************* + * + * FUNCTION: FlCheckForAcpiTable + * + * PARAMETERS: Handle - Open input file + * + * RETURN: Status + * + * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the + * following checks on what would be the table header: + * 0) File must be at least as long as an ACPI_TABLE_HEADER + * 1) The header length field must match the file size + * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAcpiTable ( + FILE *Handle) +{ + ACPI_TABLE_HEADER Table; + UINT32 FileSize; + size_t Actual; + UINT32 i; + + + /* Read a potential table header */ + + Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); + fseek (Handle, 0, SEEK_SET); + + if (Actual < sizeof (ACPI_TABLE_HEADER)) + { + return (AE_ERROR); + } + + /* Header length field must match the file size */ + + FileSize = CmGetFileSize (Handle); + if (Table.Length != FileSize) + { + return (AE_ERROR); + } + + /* + * These fields must be ASCII: + * Signature, OemId, OemTableId, AslCompilerId. + * We allow a NULL terminator in OemId and OemTableId. + */ + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) + { + return (AE_ERROR); + } + + if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) + { + return (AE_ERROR); + } + } + + printf ("Binary file appears to be a valid ACPI table, disassembling\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlCheckForAscii + * + * PARAMETERS: Handle - Open input file + * Filename - Input filename + * DisplayErrors - TRUE if error messages desired + * + * RETURN: Status + * + * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters + * within comments. Note: does not handle nested comments and does + * not handle comment delimiters within string literals. However, + * on the rare chance this happens and an invalid character is + * missed, the parser will catch the error by failing in some + * spectactular manner. + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAscii ( + FILE *Handle, + char *Filename, + BOOLEAN DisplayErrors) +{ + UINT8 Byte; + ACPI_SIZE BadBytes = 0; + BOOLEAN OpeningComment = FALSE; + ASL_FILE_STATUS Status; + + + Status.Line = 1; + Status.Offset = 0; + + /* Read the entire file */ + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Ignore comment fields (allow non-ascii within) */ + + if (OpeningComment) + { + /* Check for second comment open delimiter */ + + if (Byte == '*') + { + FlConsumeAnsiComment (Handle, &Status); + } + + if (Byte == '/') + { + FlConsumeNewComment (Handle, &Status); + } + + /* Reset */ + + OpeningComment = FALSE; + } + else if (Byte == '/') + { + OpeningComment = TRUE; + } + + /* Check for an ASCII character */ + + if (!ACPI_IS_ASCII (Byte)) + { + if ((BadBytes < 10) && (DisplayErrors)) + { + AcpiOsPrintf ( + "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", + Byte, Status.Line, Status.Offset); + } + + BadBytes++; + } + + /* Update line counter */ + + else if (Byte == 0x0A) + { + Status.Line++; + } + + Status.Offset++; + } + + /* Seek back to the beginning of the source file */ + + fseek (Handle, 0, SEEK_SET); + + /* Were there any non-ASCII characters in the file? */ + + if (BadBytes) + { + if (DisplayErrors) + { + AcpiOsPrintf ( + "%u non-ASCII characters found in input source text, could be a binary file\n", + BadBytes); + AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); + } + + return (AE_BAD_CHARACTER); + } + + /* File is OK (100% ASCII) */ + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: FlConsumeAnsiComment + * + * PARAMETERS: Handle - Open input file + * Status - File current status struct + * + * RETURN: Number of lines consumed + * + * DESCRIPTION: Step over a normal slash-star type comment + * + ******************************************************************************/ + +static void +FlConsumeAnsiComment ( + FILE *Handle, + ASL_FILE_STATUS *Status) +{ + UINT8 Byte; + BOOLEAN ClosingComment = FALSE; + + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Scan until comment close is found */ + + if (ClosingComment) + { + if (Byte == '/') + { + return; + } + + if (Byte != '*') + { + /* Reset */ + + ClosingComment = FALSE; + } + } + else if (Byte == '*') + { + ClosingComment = TRUE; + } + + /* Maintain line count */ + + if (Byte == 0x0A) + { + Status->Line++; + } + + Status->Offset++; + } +} + + +/******************************************************************************* + * + * FUNCTION: FlConsumeNewComment + * + * PARAMETERS: Handle - Open input file + * Status - File current status struct + * + * RETURN: Number of lines consumed + * + * DESCRIPTION: Step over a slash-slash type of comment + * + ******************************************************************************/ + +static void +FlConsumeNewComment ( + FILE *Handle, + ASL_FILE_STATUS *Status) +{ + UINT8 Byte; + + + while (fread (&Byte, 1, 1, Handle) == 1) + { + Status->Offset++; + + /* Comment ends at newline */ + + if (Byte == 0x0A) + { + Status->Line++; + return; + } + } +} diff --git a/sys/contrib/dev/acpica/compiler/aslbtypes.c b/sys/contrib/dev/acpica/compiler/aslbtypes.c index 16f3a0bc529a..0ff8664f6f73 100644 --- a/sys/contrib/dev/acpica/compiler/aslbtypes.c +++ b/sys/contrib/dev/acpica/compiler/aslbtypes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -243,7 +242,7 @@ AnMapEtypeToBtype ( return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); - case ACPI_BTYPE_DEBUG_OBJECT: + case ACPI_TYPE_DEBUG_OBJECT: /* Cannot be used as a source operand */ diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index b7d510db3a5b..b462d7beb920 100644 --- a/sys/contrib/dev/acpica/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 48ccfa3eefd1..b26c9e890466 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -66,21 +67,263 @@ static void CmFlushSourceCode ( void); -static void -FlConsumeAnsiComment ( - FILE *Handle, - ASL_FILE_STATUS *Status); - -static void -FlConsumeNewComment ( - FILE *Handle, - ASL_FILE_STATUS *Status); - static void CmDumpAllEvents ( void); +/******************************************************************************* + * + * FUNCTION: CmDoCompile + * + * PARAMETERS: None + * + * RETURN: Status (0 = OK) + * + * DESCRIPTION: This procedure performs the entire compile + * + ******************************************************************************/ + +int +CmDoCompile ( + void) +{ + ACPI_STATUS Status; + UINT8 FullCompile; + UINT8 Event; + + + FullCompile = UtBeginEvent ("*** Total Compile time ***"); + Event = UtBeginEvent ("Open input and output files"); + UtEndEvent (Event); + + Event = UtBeginEvent ("Preprocess input file"); + if (Gbl_PreprocessFlag) + { + /* Preprocessor */ + + PrDoPreprocess (); + if (Gbl_PreprocessOnly) + { + UtEndEvent (Event); + CmCleanupAndExit (); + return (0); + } + } + UtEndEvent (Event); + + /* Build the parse tree */ + + Event = UtBeginEvent ("Parse source code and build parse tree"); + AslCompilerparse(); + UtEndEvent (Event); + + /* Check for parse errors */ + + Status = AslCheckForErrorExit (); + if (ACPI_FAILURE (Status)) + { + fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n"); + LsDumpParseTree (); + goto ErrorExit; + } + + /* Did the parse tree get successfully constructed? */ + + if (!RootNode) + { + /* + * If there are no errors, then we have some sort of + * internal problem. + */ + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, + NULL, "- Could not resolve parse tree root node"); + + goto ErrorExit; + } + + /* Flush out any remaining source after parse tree is complete */ + + Event = UtBeginEvent ("Flush source input"); + CmFlushSourceCode (); + + /* Optional parse tree dump, compiler debug output only */ + + LsDumpParseTree (); + + OpcGetIntegerWidth (RootNode); + UtEndEvent (Event); + + /* Pre-process parse tree for any operator transforms */ + + Event = UtBeginEvent ("Parse tree transforms"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrAmlTransformWalk, NULL, NULL); + UtEndEvent (Event); + + /* Generate AML opcodes corresponding to the parse tokens */ + + Event = UtBeginEvent ("Generate AML opcodes"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + OpcAmlOpcodeWalk, NULL); + UtEndEvent (Event); + + /* + * Now that the input is parsed, we can open the AML output file. + * Note: by default, the name of this file comes from the table descriptor + * within the input file. + */ + Event = UtBeginEvent ("Open AML output file"); + Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); + UtEndEvent (Event); + if (ACPI_FAILURE (Status)) + { + AePrintErrorLog (ASL_FILE_STDERR); + return (-1); + } + + /* Interpret and generate all compile-time constants */ + + Event = UtBeginEvent ("Constant folding via AML interpreter"); + DbgPrint (ASL_DEBUG_OUTPUT, + "\nInterpreting compile-time constant expressions\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + OpcAmlConstantWalk, NULL, NULL); + UtEndEvent (Event); + + /* Update AML opcodes if necessary, after constant folding */ + + Event = UtBeginEvent ("Updating AML opcodes after constant folding"); + DbgPrint (ASL_DEBUG_OUTPUT, + "\nUpdating AML opcodes after constant folding\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + NULL, OpcAmlOpcodeUpdateWalk, NULL); + UtEndEvent (Event); + + /* Calculate all AML package lengths */ + + Event = UtBeginEvent ("Generate AML package lengths"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + LnPackageLengthWalk, NULL); + UtEndEvent (Event); + + if (Gbl_ParseOnlyFlag) + { + AePrintErrorLog (ASL_FILE_STDERR); + UtDisplaySummary (ASL_FILE_STDERR); + if (Gbl_DebugFlag) + { + /* Print error summary to the stdout also */ + + AePrintErrorLog (ASL_FILE_STDOUT); + UtDisplaySummary (ASL_FILE_STDOUT); + } + UtEndEvent (FullCompile); + return (0); + } + + /* + * Create an internal namespace and use it as a symbol table + */ + + /* Namespace loading */ + + Event = UtBeginEvent ("Create ACPI Namespace"); + Status = LdLoadNamespace (RootNode); + UtEndEvent (Event); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Namespace cross-reference */ + + AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); + Status = XfCrossReferenceNamespace (); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Namespace - Check for non-referenced objects */ + + LkFindUnreferencedObjects (); + UtEndEvent (AslGbl_NamespaceEvent); + + /* + * Semantic analysis. This can happen only after the + * namespace has been loaded and cross-referenced. + * + * part one - check control methods + */ + Event = UtBeginEvent ("Analyze control method return types"); + AnalysisWalkInfo.MethodStack = NULL; + + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + MtMethodAnalysisWalkBegin, + MtMethodAnalysisWalkEnd, &AnalysisWalkInfo); + UtEndEvent (Event); + + /* Semantic error checking part two - typing of method returns */ + + Event = UtBeginEvent ("Determine object types returned by methods"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + NULL, AnMethodTypingWalkEnd, NULL); + UtEndEvent (Event); + + /* Semantic error checking part three - operand type checking */ + + Event = UtBeginEvent ("Analyze AML operand types"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + UtEndEvent (Event); + + /* Semantic error checking part four - other miscellaneous checks */ + + Event = UtBeginEvent ("Miscellaneous analysis"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + AnOtherSemanticAnalysisWalkBegin, + NULL, &AnalysisWalkInfo); + UtEndEvent (Event); + + /* Calculate all AML package lengths */ + + Event = UtBeginEvent ("Finish AML package length generation"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + LnInitLengthsWalk, NULL); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + LnPackageLengthWalk, NULL); + UtEndEvent (Event); + + /* Code generation - emit the AML */ + + Event = UtBeginEvent ("Generate AML code and write output files"); + CgGenerateAmlOutput (); + UtEndEvent (Event); + + Event = UtBeginEvent ("Write optional output files"); + CmDoOutputFiles (); + UtEndEvent (Event); + + UtEndEvent (FullCompile); + CmCleanupAndExit (); + return (0); + +ErrorExit: + UtEndEvent (FullCompile); + CmCleanupAndExit (); + return (-1); +} + + /******************************************************************************* * * FUNCTION: AslCompilerSignon @@ -272,534 +515,6 @@ CmFlushSourceCode ( } -/******************************************************************************* - * - * FUNCTION: FlConsume* - * - * PARAMETERS: Handle - Open input file - * Status - File current status struct - * - * RETURN: Number of lines consumed - * - * DESCRIPTION: Step over both types of comment during check for ascii chars - * - ******************************************************************************/ - -static void -FlConsumeAnsiComment ( - FILE *Handle, - ASL_FILE_STATUS *Status) -{ - UINT8 Byte; - BOOLEAN ClosingComment = FALSE; - - - while (fread (&Byte, 1, 1, Handle) == 1) - { - /* Scan until comment close is found */ - - if (ClosingComment) - { - if (Byte == '/') - { - return; - } - - if (Byte != '*') - { - /* Reset */ - - ClosingComment = FALSE; - } - } - else if (Byte == '*') - { - ClosingComment = TRUE; - } - - /* Maintain line count */ - - if (Byte == 0x0A) - { - Status->Line++; - } - - Status->Offset++; - } -} - - -static void -FlConsumeNewComment ( - FILE *Handle, - ASL_FILE_STATUS *Status) -{ - UINT8 Byte; - - - while (fread (&Byte, 1, 1, Handle) == 1) - { - Status->Offset++; - - /* Comment ends at newline */ - - if (Byte == 0x0A) - { - Status->Line++; - return; - } - } -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAcpiTable - * - * PARAMETERS: Handle - Open input file - * - * RETURN: Status - * - * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the - * following checks on what would be the table header: - * 0) File must be at least as long as an ACPI_TABLE_HEADER - * 1) The header length field must match the file size - * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle) -{ - ACPI_TABLE_HEADER Table; - UINT32 FileSize; - size_t Actual; - UINT32 i; - - - /* Read a potential table header */ - - Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); - fseek (Handle, 0, SEEK_SET); - - if (Actual < sizeof (ACPI_TABLE_HEADER)) - { - return (AE_ERROR); - } - - /* Header length field must match the file size */ - - FileSize = DtGetFileSize (Handle); - if (Table.Length != FileSize) - { - return (AE_ERROR); - } - - /* - * These fields must be ASCII: - * Signature, OemId, OemTableId, AslCompilerId. - * We allow a NULL terminator in OemId and OemTableId. - */ - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) - { - return (AE_ERROR); - } - - if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) - { - return (AE_ERROR); - } - } - - printf ("Binary file appears to be a valid ACPI table, disassembling\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAscii - * - * PARAMETERS: Handle - Open input file - * Filename - Input filename - * DisplayErrors - TRUE if error messages desired - * - * RETURN: Status - * - * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters - * within comments. Note: does not handle nested comments and does - * not handle comment delimiters within string literals. However, - * on the rare chance this happens and an invalid character is - * missed, the parser will catch the error by failing in some - * spectactular manner. - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAscii ( - FILE *Handle, - char *Filename, - BOOLEAN DisplayErrors) -{ - UINT8 Byte; - ACPI_SIZE BadBytes = 0; - BOOLEAN OpeningComment = FALSE; - ASL_FILE_STATUS Status; - - - Status.Line = 1; - Status.Offset = 0; - - /* Read the entire file */ - - while (fread (&Byte, 1, 1, Handle) == 1) - { - /* Ignore comment fields (allow non-ascii within) */ - - if (OpeningComment) - { - /* Check for second comment open delimiter */ - - if (Byte == '*') - { - FlConsumeAnsiComment (Handle, &Status); - } - - if (Byte == '/') - { - FlConsumeNewComment (Handle, &Status); - } - - /* Reset */ - - OpeningComment = FALSE; - } - else if (Byte == '/') - { - OpeningComment = TRUE; - } - - /* Check for an ASCII character */ - - if (!ACPI_IS_ASCII (Byte)) - { - if ((BadBytes < 10) && (DisplayErrors)) - { - AcpiOsPrintf ( - "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", - Byte, Status.Line, Status.Offset); - } - - BadBytes++; - } - - /* Update line counter */ - - else if (Byte == 0x0A) - { - Status.Line++; - } - - Status.Offset++; - } - - /* Seek back to the beginning of the source file */ - - fseek (Handle, 0, SEEK_SET); - - /* Were there any non-ASCII characters in the file? */ - - if (BadBytes) - { - if (DisplayErrors) - { - AcpiOsPrintf ( - "%u non-ASCII characters found in input source text, could be a binary file\n", - BadBytes); - AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); - } - - return (AE_BAD_CHARACTER); - } - - /* File is OK (100% ASCII) */ - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: CmDoCompile - * - * PARAMETERS: None - * - * RETURN: Status (0 = OK) - * - * DESCRIPTION: This procedure performs the entire compile - * - ******************************************************************************/ - -int -CmDoCompile ( - void) -{ - ACPI_STATUS Status; - UINT8 FullCompile; - UINT8 Event; - - - FullCompile = UtBeginEvent ("*** Total Compile time ***"); - Event = UtBeginEvent ("Open input and output files"); - UtEndEvent (Event); - - Event = UtBeginEvent ("Preprocess input file"); - if (Gbl_PreprocessFlag) - { - /* Preprocessor */ - - PrDoPreprocess (); - if (Gbl_PreprocessOnly) - { - UtEndEvent (Event); - CmCleanupAndExit (); - return (0); - } - } - UtEndEvent (Event); - - /* Build the parse tree */ - - Event = UtBeginEvent ("Parse source code and build parse tree"); - AslCompilerparse(); - UtEndEvent (Event); - - /* Check for parse errors */ - - Status = AslCheckForErrorExit (); - if (ACPI_FAILURE (Status)) - { - fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n"); - LsDumpParseTree (); - goto ErrorExit; - } - - /* Did the parse tree get successfully constructed? */ - - if (!RootNode) - { - /* - * If there are no errors, then we have some sort of - * internal problem. - */ - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, - NULL, "- Could not resolve parse tree root node"); - - goto ErrorExit; - } - - - /* Flush out any remaining source after parse tree is complete */ - - Event = UtBeginEvent ("Flush source input"); - CmFlushSourceCode (); - - /* Optional parse tree dump, compiler debug output only */ - - LsDumpParseTree (); - - OpcGetIntegerWidth (RootNode); - UtEndEvent (Event); - - /* Pre-process parse tree for any operator transforms */ - - Event = UtBeginEvent ("Parse tree transforms"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - TrAmlTransformWalk, NULL, NULL); - UtEndEvent (Event); - - /* Generate AML opcodes corresponding to the parse tokens */ - - Event = UtBeginEvent ("Generate AML opcodes"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, - OpcAmlOpcodeWalk, NULL); - UtEndEvent (Event); - - /* - * Now that the input is parsed, we can open the AML output file. - * Note: by default, the name of this file comes from the table descriptor - * within the input file. - */ - Event = UtBeginEvent ("Open AML output file"); - Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); - UtEndEvent (Event); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return (-1); - } - - /* Interpret and generate all compile-time constants */ - - Event = UtBeginEvent ("Constant folding via AML interpreter"); - DbgPrint (ASL_DEBUG_OUTPUT, - "\nInterpreting compile-time constant expressions\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - OpcAmlConstantWalk, NULL, NULL); - UtEndEvent (Event); - - /* Update AML opcodes if necessary, after constant folding */ - - Event = UtBeginEvent ("Updating AML opcodes after constant folding"); - DbgPrint (ASL_DEBUG_OUTPUT, - "\nUpdating AML opcodes after constant folding\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, - NULL, OpcAmlOpcodeUpdateWalk, NULL); - UtEndEvent (Event); - - /* Calculate all AML package lengths */ - - Event = UtBeginEvent ("Generate AML package lengths"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, - LnPackageLengthWalk, NULL); - UtEndEvent (Event); - - if (Gbl_ParseOnlyFlag) - { - AePrintErrorLog (ASL_FILE_STDERR); - UtDisplaySummary (ASL_FILE_STDERR); - if (Gbl_DebugFlag) - { - /* Print error summary to the stdout also */ - - AePrintErrorLog (ASL_FILE_STDOUT); - UtDisplaySummary (ASL_FILE_STDOUT); - } - UtEndEvent (FullCompile); - return (0); - } - - /* - * Create an internal namespace and use it as a symbol table - */ - - /* Namespace loading */ - - Event = UtBeginEvent ("Create ACPI Namespace"); - Status = LdLoadNamespace (RootNode); - UtEndEvent (Event); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - /* Namespace cross-reference */ - - AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); - Status = XfCrossReferenceNamespace (); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - /* Namespace - Check for non-referenced objects */ - - LkFindUnreferencedObjects (); - UtEndEvent (AslGbl_NamespaceEvent); - - /* - * Semantic analysis. This can happen only after the - * namespace has been loaded and cross-referenced. - * - * part one - check control methods - */ - Event = UtBeginEvent ("Analyze control method return types"); - AnalysisWalkInfo.MethodStack = NULL; - - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, - MtMethodAnalysisWalkBegin, - MtMethodAnalysisWalkEnd, &AnalysisWalkInfo); - UtEndEvent (Event); - - /* Semantic error checking part two - typing of method returns */ - - Event = UtBeginEvent ("Determine object types returned by methods"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, - NULL, AnMethodTypingWalkEnd, NULL); - UtEndEvent (Event); - - /* Semantic error checking part three - operand type checking */ - - Event = UtBeginEvent ("Analyze AML operand types"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, - NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); - UtEndEvent (Event); - - /* Semantic error checking part four - other miscellaneous checks */ - - Event = UtBeginEvent ("Miscellaneous analysis"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - AnOtherSemanticAnalysisWalkBegin, - NULL, &AnalysisWalkInfo); - UtEndEvent (Event); - - /* Calculate all AML package lengths */ - - Event = UtBeginEvent ("Finish AML package length generation"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, - LnInitLengthsWalk, NULL); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, - LnPackageLengthWalk, NULL); - UtEndEvent (Event); - - /* Code generation - emit the AML */ - - Event = UtBeginEvent ("Generate AML code and write output files"); - CgGenerateAmlOutput (); - UtEndEvent (Event); - - Event = UtBeginEvent ("Write optional output files"); - CmDoOutputFiles (); - UtEndEvent (Event); - - UtEndEvent (FullCompile); - CmCleanupAndExit (); - return (0); - -ErrorExit: - UtEndEvent (FullCompile); - CmCleanupAndExit (); - return (-1); -} - - /******************************************************************************* * * FUNCTION: CmDoOutputFiles @@ -825,6 +540,10 @@ CmDoOutputFiles ( /* Dump the namespace to the .nsp file if requested */ (void) NsDisplayNamespace (); + + /* Dump the device mapping file */ + + MpEmitMappingInfo (); } @@ -965,7 +684,8 @@ CmCleanupAndExit ( * We will delete the AML file if there are errors and the * force AML output option has not been used. */ - if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) && + if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && + (!Gbl_IgnoreErrors) && Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) { DeleteAmlFile = TRUE; @@ -1025,4 +745,71 @@ CmCleanupAndExit ( { FlDeleteFile (ASL_FILE_SOURCE_OUTPUT); } + + /* Final cleanup after compiling one file */ + + CmDeleteCaches (); +} + + +/******************************************************************************* + * + * FUNCTION: CmDeleteCaches + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all local cache buffer blocks + * + ******************************************************************************/ + +void +CmDeleteCaches ( + void) +{ + UINT32 BufferCount; + ASL_CACHE_INFO *Next; + + + /* Parse Op cache */ + + BufferCount = 0; + while (Gbl_ParseOpCacheList) + { + Next = Gbl_ParseOpCacheList->Next; + ACPI_FREE (Gbl_ParseOpCacheList); + Gbl_ParseOpCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n", + Gbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE, + (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount); + + Gbl_ParseOpCount = 0; + Gbl_ParseOpCacheNext = NULL; + Gbl_ParseOpCacheLast = NULL; + RootNode = NULL; + + /* Generic string cache */ + + BufferCount = 0; + while (Gbl_StringCacheList) + { + Next = Gbl_StringCacheList->Next; + ACPI_FREE (Gbl_StringCacheList); + Gbl_StringCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n", + Gbl_StringCount, Gbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount); + + Gbl_StringSize = 0; + Gbl_StringCount = 0; + Gbl_StringCacheNext = NULL; + Gbl_StringCacheLast = NULL; } diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index 132ae7d5039b..1667d8fedf7c 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLCOMPILER_H #define __ASLCOMPILER_H @@ -111,6 +110,11 @@ AslPushInputFileStack ( FILE *InputFile, char *Filename); +void +AslParserCleanup ( + void); + + /* * aslstartup - entered from main() */ @@ -122,11 +126,6 @@ typedef ACPI_STATUS (*ASL_PATHNAME_CALLBACK) ( char *); -ACPI_STATUS -AslDoOnePathname ( - char *Pathname, - ASL_PATHNAME_CALLBACK Callback); - ACPI_STATUS AslDoOneFile ( char *Filename); @@ -159,6 +158,14 @@ void CmCleanupAndExit ( void); +void +CmDeleteCaches ( + void); + + +/* + * aslascii - ascii support + */ ACPI_STATUS FlCheckForAcpiTable ( FILE *Handle); @@ -280,14 +287,23 @@ void ApCheckRegMethod ( ACPI_PARSE_OBJECT *Op); +BOOLEAN +ApFindNameInScope ( + char *Name, + ACPI_PARSE_OBJECT *Op); + /* * aslerror - error handling/reporting */ void +AslAbort ( + void); + +void AslError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, ACPI_PARSE_OBJECT *Op, char *ExtraMessage); @@ -298,7 +314,7 @@ AslDisableException ( BOOLEAN AslIsExceptionDisabled ( UINT8 Level, - UINT8 MessageId); + UINT16 MessageId); void AslCoreSubsystemError ( @@ -314,7 +330,7 @@ AslCompilererror( void AslCommonError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 CurrentLineNumber, UINT32 LogicalLineNumber, UINT32 LogicalByteOffset, @@ -325,7 +341,7 @@ AslCommonError ( void AslCommonError2 ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 LineNumber, UINT32 Column, char *SourceLine, @@ -346,10 +362,6 @@ void AeClearErrorLog ( void); -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - /* * asllisting - generate all "listing" type files @@ -439,6 +451,22 @@ OpcAmlConstantWalk ( void *Context); +/* + * aslmessages - exception strings + */ +const char * +AeDecodeMessageId ( + UINT16 MessageId); + +const char * +AeDecodeExceptionLevel ( + UINT8 Level); + +UINT16 +AeBuildFullExceptionCode ( + UINT8 Level, + UINT16 MessageId); + /* * asloffset - generate C offset file for BIOS support */ @@ -708,10 +736,6 @@ TrLinkPeerNodes ( * aslfiles - File I/O support */ void -AslAbort ( - void); - -void FlAddIncludeDirectory ( char *Dir); @@ -784,6 +808,13 @@ ACPI_STATUS FlOpenMiscOutputFiles ( char *InputFilename); +/* + * aslhwmap - hardware map summary + */ +void +MpEmitMappingInfo ( + void); + /* * asload - load namespace in prep for cross reference @@ -883,10 +914,6 @@ void UtDisplaySummary ( UINT32 FileId); -UINT8 -UtHexCharToValue ( - int HexChar); - void UtConvertByteToHex ( UINT8 RawByte, @@ -906,13 +933,17 @@ UtSetParseOpName ( ACPI_PARSE_OBJECT *Op); char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length); void UtExpandLineBuffers ( void); +void +UtFreeLineBuffers ( + void); + ACPI_STATUS UtInternalizeName ( char *ExternalName, @@ -947,11 +978,6 @@ ACPI_STATUS AuValidateUuid ( char *InString); -ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuIdBuffer); - ACPI_STATUS AuConvertUuidToString ( char *UuIdBuffer, @@ -1026,8 +1052,7 @@ RsCheckListForDuplicates ( ASL_RESOURCE_NODE * RsDoOneResourceDescriptor ( - ACPI_PARSE_OBJECT *DescriptorTypeOp, - UINT32 CurrentByteOffset, + ASL_RESOURCE_INFO *Info, UINT8 *State); /* Values for State above */ @@ -1051,43 +1076,35 @@ RsDoResourceTemplate ( */ ASL_RESOURCE_NODE * RsDoEndTagDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoEndDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoMemory24Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoMemory32Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoMemory32FixedDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoStartDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoStartDependentNoPriDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoVendorSmallDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1095,33 +1112,27 @@ RsDoVendorSmallDescriptor ( */ ASL_RESOURCE_NODE * RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoFixedDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1129,61 +1140,50 @@ RsDoIrqNoFlagsDescriptor ( */ ASL_RESOURCE_NODE * RsDoInterruptDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoVendorLargeDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoGpioIntDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoGpioIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoI2cSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoSpiSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoUartSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* * aslrestype2d - DWord address descriptors */ ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoDwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoDwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1191,18 +1191,15 @@ RsDoDwordSpaceDescriptor ( */ ASL_RESOURCE_NODE * RsDoExtendedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoExtendedMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoExtendedSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1210,18 +1207,15 @@ RsDoExtendedSpaceDescriptor ( */ ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoQwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoQwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); /* @@ -1229,18 +1223,16 @@ RsDoQwordSpaceDescriptor ( */ ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoWordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); ASL_RESOURCE_NODE * RsDoWordBusNumberDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); + ASL_RESOURCE_INFO *Info); + /* * Entry to data table compiler subsystem diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index 5b2d9ce3e7f6..bbf41cd693ae 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,10 +110,11 @@ NamePathTail [.]{NameSeg} [ \t] { count (0); } -"/*" { if (!AslDoComment ()) yyterminate (); } -"//" { if (!AslDoCommentType2 ()) yyterminate (); } +"/*" { if (!AslDoComment ()) {yyterminate ();} } +"//" { if (!AslDoCommentType2 ()) {yyterminate ();} } -"\"" { if (AslDoStringLiteral ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); } +"\"" { if (AslDoStringLiteral ()) {return (PARSEOP_STRING_LITERAL);} + else {yyterminate ();} } ";" { count (0); return(';'); } @@ -607,7 +608,7 @@ NamePathTail [.]{NameSeg} {NameSeg} { char *s; count (0); - s=malloc (ACPI_NAME_SIZE + 1); + s=UtStringCacheCalloc (ACPI_NAME_SIZE + 1); if (strcmp (AslCompilertext, "\\")) { strcpy (s, "____"); @@ -620,10 +621,9 @@ NamePathTail [.]{NameSeg} {NameString} { char *s; count (0); - s=malloc (strlen (AslCompilertext)+1); + s=UtStringCacheCalloc (strlen (AslCompilertext)+1); AcpiUtStrupr (AslCompilertext); strcpy (s, AslCompilertext); - s[strlen (AslCompilertext)] = 0; AslCompilerlval.s = s; DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s); return (PARSEOP_NAMESTRING); } @@ -639,9 +639,9 @@ NamePathTail [.]{NameSeg} AslCompilererror (MsgBuffer);} <> { if (AslPopInputFileStack ()) - yyterminate(); + {yyterminate();} else - return (PARSEOP_INCLUDE_END);}; + {return (PARSEOP_INCLUDE_END);} }; %% diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h index 76e2e12e7cd7..94002816ebcc 100644 --- a/sys/contrib/dev/acpica/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLDEFINE_H #define __ASLDEFINE_H @@ -55,14 +54,14 @@ #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.1" /* Configuration constants */ #define ASL_MAX_ERROR_COUNT 200 -#define ASL_NODE_CACHE_SIZE 1024 -#define ASL_STRING_CACHE_SIZE 32768 +#define ASL_PARSEOP_CACHE_SIZE (1024 * 16) +#define ASL_STRING_CACHE_SIZE (1024 * 64) #define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS #define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */ @@ -109,6 +108,7 @@ #define FILE_SUFFIX_PREPROCESSOR "i" #define FILE_SUFFIX_AML_CODE "aml" +#define FILE_SUFFIX_MAP "map" #define FILE_SUFFIX_LISTING "lst" #define FILE_SUFFIX_HEX_DUMP "hex" #define FILE_SUFFIX_DEBUG "txt" diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c index ff6ec3687139..7f25f9724942 100644 --- a/sys/contrib/dev/acpica/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/compiler/aslerror.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#define ASL_EXCEPTIONS #include #define _COMPONENT ACPI_COMPILER @@ -54,6 +53,36 @@ AeAddToErrorLog ( ASL_ERROR_MSG *Enode); +/******************************************************************************* + * + * FUNCTION: AslAbort + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump the error log and abort the compiler. Used for serious + * I/O errors. + * + ******************************************************************************/ + +void +AslAbort ( + void) +{ + + AePrintErrorLog (ASL_FILE_STDERR); + if (Gbl_DebugFlag) + { + /* Print error summary to stdout also */ + + AePrintErrorLog (ASL_FILE_STDOUT); + } + + exit (1); +} + + /******************************************************************************* * * FUNCTION: AeClearErrorLog @@ -174,7 +203,7 @@ AePrintException ( int Actual; size_t RActual; UINT32 MsgLength; - char *MainMessage; + const char *MainMessage; char *ExtraMessage; UINT32 SourceColumn; UINT32 ErrorColumn; @@ -200,6 +229,16 @@ AePrintException ( switch (Enode->Level) { + case ASL_WARNING: + case ASL_WARNING2: + case ASL_WARNING3: + + if (!Gbl_DisplayWarnings) + { + return; + } + break; + case ASL_REMARK: if (!Gbl_DisplayRemarks) @@ -222,11 +261,10 @@ AePrintException ( } } - /* Get the file handles */ + /* Get the various required file handles */ OutputFile = Gbl_Files[FileId].Handle; - if (!Enode->SourceLine) { /* Use the merged header/source file if present, otherwise use input file */ @@ -360,110 +398,94 @@ AePrintException ( } } - /* NULL message ID, just print the raw message */ + /* If a NULL message ID, just print the raw message */ if (Enode->MessageId == 0) { fprintf (OutputFile, "%s\n", Enode->Message); + return; } - else + + /* Decode the message ID */ + + fprintf (OutputFile, "%s %4.4d -", + AeDecodeExceptionLevel (Enode->Level), + AeBuildFullExceptionCode (Enode->Level, Enode->MessageId)); + + MainMessage = AeDecodeMessageId (Enode->MessageId); + ExtraMessage = Enode->Message; + + /* If a NULL line number, just print the decoded message */ + + if (!Enode->LineNumber) { - /* Decode the message ID */ + fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); + return; + } - if (Gbl_VerboseErrors) + MsgLength = strlen (MainMessage); + if (MsgLength == 0) + { + /* Use the secondary/extra message as main message */ + + MainMessage = Enode->Message; + if (!MainMessage) { - fprintf (OutputFile, "%s %4.4d -", - AslErrorLevel[Enode->Level], - Enode->MessageId + ((Enode->Level+1) * 1000)); - } - else /* IDE case */ - { - fprintf (OutputFile, "%s %4.4d:", - AslErrorLevelIde[Enode->Level], - Enode->MessageId + ((Enode->Level+1) * 1000)); + MainMessage = ""; } - MainMessage = AslMessages[Enode->MessageId]; - ExtraMessage = Enode->Message; + MsgLength = strlen (MainMessage); + ExtraMessage = NULL; + } - if (Enode->LineNumber) + if (Gbl_VerboseErrors && !PrematureEOF) + { + if (Total >= 256) { - /* Main message: try to use string from AslMessages first */ - - if (!MainMessage) - { - MainMessage = ""; - } - - MsgLength = strlen (MainMessage); - if (MsgLength == 0) - { - /* Use the secondary/extra message as main message */ - - MainMessage = Enode->Message; - if (!MainMessage) - { - MainMessage = ""; - } - - MsgLength = strlen (MainMessage); - ExtraMessage = NULL; - } - - if (Gbl_VerboseErrors && !PrematureEOF) - { - if (Total >= 256) - { - fprintf (OutputFile, " %s", - MainMessage); - } - else - { - SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; - ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; - - if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) - { - fprintf (OutputFile, "%*s%s", - (int) ((SourceColumn - 1) - ErrorColumn), - MainMessage, " ^ "); - } - else - { - fprintf (OutputFile, "%*s %s", - (int) ((SourceColumn - ErrorColumn) + 1), "^", - MainMessage); - } - } - } - else - { - fprintf (OutputFile, " %s", MainMessage); - } - - /* Print the extra info message if present */ - - if (ExtraMessage) - { - fprintf (OutputFile, " (%s)", ExtraMessage); - } - - if (PrematureEOF) - { - fprintf (OutputFile, " and premature End-Of-File"); - } - - fprintf (OutputFile, "\n"); - if (Gbl_VerboseErrors) - { - fprintf (OutputFile, "\n"); - } + fprintf (OutputFile, " %s", + MainMessage); } else { - fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); + SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; + ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; + + if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) + { + fprintf (OutputFile, "%*s%s", + (int) ((SourceColumn - 1) - ErrorColumn), + MainMessage, " ^ "); + } + else + { + fprintf (OutputFile, "%*s %s", + (int) ((SourceColumn - ErrorColumn) + 1), "^", + MainMessage); + } } } + else + { + fprintf (OutputFile, " %s", MainMessage); + } + + /* Print the extra info message if present */ + + if (ExtraMessage) + { + fprintf (OutputFile, " (%s)", ExtraMessage); + } + + if (PrematureEOF) + { + fprintf (OutputFile, " and premature End-Of-File"); + } + + fprintf (OutputFile, "\n"); + if (Gbl_VerboseErrors) + { + fprintf (OutputFile, "\n"); + } } @@ -517,7 +539,7 @@ AePrintErrorLog ( void AslCommonError2 ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 LineNumber, UINT32 Column, char *SourceLine, @@ -535,7 +557,7 @@ AslCommonError2 ( { /* Allocate a buffer for the message and a new error node */ - MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -549,7 +571,7 @@ AslCommonError2 ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { @@ -603,7 +625,7 @@ AslCommonError2 ( void AslCommonError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 CurrentLineNumber, UINT32 LogicalLineNumber, UINT32 LogicalByteOffset, @@ -611,7 +633,6 @@ AslCommonError ( char *Filename, char *ExtraMessage) { - UINT32 MessageSize; char *MessageBuffer = NULL; ASL_ERROR_MSG *Enode; @@ -622,8 +643,7 @@ AslCommonError ( { /* Allocate a buffer for the message and a new error node */ - MessageSize = strlen (ExtraMessage) + 1; - MessageBuffer = UtLocalCalloc (MessageSize); + MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1); /* Keep a copy of the extra message */ @@ -634,7 +654,7 @@ AslCommonError ( if (Filename) { - Enode->Filename = Filename; + Enode->Filename = Filename; Enode->FilenameLength = strlen (Filename); if (Enode->FilenameLength < 6) { @@ -739,7 +759,7 @@ AslDisableException ( BOOLEAN AslIsExceptionDisabled ( UINT8 Level, - UINT8 MessageId) + UINT16 MessageId) { UINT32 EncodedMessageId; UINT32 i; @@ -764,7 +784,7 @@ AslIsExceptionDisabled ( * Ignore this warning/remark if it has been disabled by * the user (-vw option) */ - EncodedMessageId = MessageId + ((Level + 1) * 1000); + EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId); for (i = 0; i < Gbl_DisabledMessagesIndex; i++) { /* Simple implementation via fixed array */ @@ -803,14 +823,15 @@ AslIsExceptionDisabled ( void AslError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, ACPI_PARSE_OBJECT *Op, char *ExtraMessage) { /* Check if user wants to ignore this exception */ - if (AslIsExceptionDisabled (Level, MessageId)) + if (Gbl_AllExceptionsDisabled || + AslIsExceptionDisabled (Level, MessageId)) { return; } @@ -836,14 +857,14 @@ AslError ( * FUNCTION: AslCoreSubsystemError * * PARAMETERS: Op - Parse node where error happened - * Status - The ACPI CA Exception + * Status - The ACPICA Exception * ExtraMessage - additional error message * Abort - TRUE -> Abort compilation * * RETURN: None * - * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI - * CA core subsystem. + * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA + * core subsystem. * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c index 660b82f6d30b..a4085757f181 100644 --- a/sys/contrib/dev/acpica/compiler/aslfileio.c +++ b/sys/contrib/dev/acpica/compiler/aslfileio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,41 +42,12 @@ */ #include +#include #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfileio") -/******************************************************************************* - * - * FUNCTION: AslAbort - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Dump the error log and abort the compiler. Used for serious - * I/O errors. - * - ******************************************************************************/ - -void -AslAbort ( - void) -{ - - AePrintErrorLog (ASL_FILE_STDERR); - if (Gbl_DebugFlag) - { - /* Print error summary to stdout also */ - - AePrintErrorLog (ASL_FILE_STDOUT); - } - - exit (1); -} - - /******************************************************************************* * * FUNCTION: FlFileError @@ -147,7 +118,8 @@ FlOpenFile ( * * RETURN: File Size * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. + * DESCRIPTION: Get current file size. Uses common seek-to-EOF function. + * File must be open. Aborts compiler on error. * ******************************************************************************/ @@ -155,20 +127,15 @@ UINT32 FlGetFileSize ( UINT32 FileId) { - FILE *fp; UINT32 FileSize; - long Offset; - fp = Gbl_Files[FileId].Handle; - Offset = ftell (fp); + FileSize = CmGetFileSize (Gbl_Files[FileId].Handle); + if (FileSize == ACPI_UINT32_MAX) + { + AslAbort(); + } - fseek (fp, 0, SEEK_END); - FileSize = (UINT32) ftell (fp); - - /* Restore file pointer */ - - fseek (fp, Offset, SEEK_SET); return (FileSize); } @@ -352,6 +319,8 @@ FlCloseFile ( AslAbort (); } + /* Do not clear/free the filename string */ + Gbl_Files[FileId].Handle = NULL; return; } diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index 2ed94131fcda..2c84c9e99d9d 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -107,6 +107,8 @@ FlSetFilename ( DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n", Filename, Gbl_Files[ASL_FILE_INPUT].Filename); + /* No need to free any existing filename */ + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; } @@ -216,14 +218,14 @@ FlMergePathnames ( (*FilePathname == '/') || (FilePathname[1] == ':')) { - Pathname = ACPI_ALLOCATE (strlen (FilePathname) + 1); + Pathname = UtStringCacheCalloc (strlen (FilePathname) + 1); strcpy (Pathname, FilePathname); goto ConvertBackslashes; } /* Need a local copy of the prefix directory path */ - CommonPath = ACPI_ALLOCATE (strlen (PrefixDir) + 1); + CommonPath = UtStringCacheCalloc (strlen (PrefixDir) + 1); strcpy (CommonPath, PrefixDir); /* @@ -259,14 +261,13 @@ FlMergePathnames ( /* Build the final merged pathname */ ConcatenatePaths: - Pathname = ACPI_ALLOCATE_ZEROED (strlen (CommonPath) + strlen (FilePathname) + 2); + Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2); if (LastElement && *CommonPath) { strcpy (Pathname, CommonPath); strcat (Pathname, "/"); } strcat (Pathname, FilePathname); - ACPI_FREE (CommonPath); /* Convert all backslashes to normal slashes */ @@ -824,6 +825,7 @@ FlParseInputPathname ( *(Substring+1) = 0; } + UtConvertBackslashes (Gbl_OutputFilenamePrefix); return (AE_OK); } #endif diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c index 00595af2dce1..88042337cf5e 100644 --- a/sys/contrib/dev/acpica/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/compiler/aslfold.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index 3f2c401bd8e8..8106824fd8ef 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLGLOBAL_H #define __ASLGLOBAL_H @@ -63,11 +62,6 @@ #ifdef _DECLARE_GLOBALS UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; -char AslHexLookup[] = -{ - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' -}; - /* Table below must match ASL_FILE_TYPES in asltypes.h */ @@ -87,12 +81,12 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = {NULL, NULL, "C Source: ", "C Code Output"}, {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, {NULL, NULL, "C Include: ", "C Header Output"}, - {NULL, NULL, "Offset Table: ", "C Offset Table Output"} + {NULL, NULL, "Offset Table: ", "C Offset Table Output"}, + {NULL, NULL, "Device Map: ", "Device Map Output"} }; #else extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -extern char AslHexLookup[]; extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; #endif @@ -102,12 +96,20 @@ extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; */ extern int yydebug; extern FILE *AslCompilerin; -extern int AslCompilerdebug; extern int DtParserdebug; extern int PrParserdebug; extern const ASL_MAPPING_ENTRY AslKeywordMapping[]; extern char *AslCompilertext; +/* + * Older versions of Bison won't emit this external in the generated header. + * Newer versions do emit the external, so we don't need to do it. + */ +#ifndef ASLCOMPILER_ASLCOMPILERPARSE_H +extern int AslCompilerdebug; +#endif + + #define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */ #define ASL_MSG_BUFFER_SIZE 4096 #define ASL_MAX_DISABLED_MESSAGES 32 @@ -140,6 +142,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisassembleAll, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); @@ -159,16 +162,17 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_WarningsAsErrors, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoResourceChecking, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE); -ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayWarnings, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNING); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseOriginalCompilerId, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseTemplates, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileGeneric, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AllExceptionsDisabled, FALSE); #define HEX_OUTPUT_NONE 0 @@ -206,6 +210,25 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalAllocated, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0); +/* Local caches */ + +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ParseOpCount, 0); +ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*Gbl_ParseOpCacheList, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseOpCacheNext, NULL); +ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_ParseOpCacheLast, NULL); + +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_StringCount, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_StringSize, 0); +ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*Gbl_StringCacheList, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); + +/* Map file */ + +ASL_EXTERN ACPI_GPIO_INFO ASL_INIT_GLOBAL (*Gbl_GpioList, NULL); +ASL_EXTERN ACPI_SERIAL_INFO ASL_INIT_GLOBAL (*Gbl_SerialList, NULL); + + /* Misc */ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); @@ -214,10 +237,6 @@ ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0); ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheNext, NULL); -ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); @@ -232,7 +251,6 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0) ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG"); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID"); -ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswinxf only */ /* Static structures */ diff --git a/sys/contrib/dev/acpica/compiler/aslhex.c b/sys/contrib/dev/acpica/compiler/aslhex.c index 8d69b92726cc..7eb678a9a2de 100644 --- a/sys/contrib/dev/acpica/compiler/aslhex.c +++ b/sys/contrib/dev/acpica/compiler/aslhex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_COMPILER diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c index 53e860cd126a..5b3f8a29c41a 100644 --- a/sys/contrib/dev/acpica/compiler/asllength.c +++ b/sys/contrib/dev/acpica/compiler/asllength.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index 2b02541a5655..865d646dda05 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/asllistsup.c b/sys/contrib/dev/acpica/compiler/asllistsup.c index 795672e180d5..7d121a375da0 100644 --- a/sys/contrib/dev/acpica/compiler/asllistsup.c +++ b/sys/contrib/dev/acpica/compiler/asllistsup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c index bc4d59336a3a..9d5117aa90b3 100644 --- a/sys/contrib/dev/acpica/compiler/aslload.c +++ b/sys/contrib/dev/acpica/compiler/aslload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -129,6 +129,7 @@ LdLoadNamespace ( /* Dump the namespace if debug is enabled */ AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); + ACPI_FREE (WalkState); return (AE_OK); } @@ -359,7 +360,6 @@ LdNamespace1Begin ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", Op, Op->Asl.ParseOpName)); - /* * We are only interested in opcodes that have an associated name * (or multiple names) @@ -373,6 +373,34 @@ LdNamespace1Begin ( Status = LdLoadFieldElements (Op, WalkState); return (Status); + case AML_INT_CONNECTION_OP: + + + if (Op->Asl.Child->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) + { + break; + } + Arg = Op->Asl.Child; + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Asl.ExternalName, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + break; + } + + if (Node->Type == ACPI_TYPE_BUFFER) + { + Arg->Asl.Node = Node; + + Arg = Node->Op->Asl.Child; /* Get namepath */ + Arg = Arg->Asl.Next; /* Get actual buffer */ + Arg = Arg->Asl.Child; /* Buffer length */ + Arg = Arg->Asl.Next; /* RAW_DATA buffer */ + } + break; + default: /* All other opcodes go below */ @@ -466,7 +494,6 @@ LdNamespace1Begin ( ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); break; - case PARSEOP_SCOPE: /* * The name referenced by Scope(Name) must already exist at this point. diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c index 66c09508c85d..6f3f0c275304 100644 --- a/sys/contrib/dev/acpica/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/compiler/asllookup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -105,7 +104,9 @@ LkFindUnreferencedObjects ( * DESCRIPTION: Check for an unreferenced namespace object and emit a warning. * We have to be careful, because some types and names are * typically or always unreferenced, we don't want to issue - * excessive warnings. + * excessive warnings. Note: Names that are declared within a + * control method are temporary, so we always issue a remark + * if they are not referenced. * ******************************************************************************/ @@ -117,6 +118,7 @@ LkIsObjectUsed ( void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ACPI_NAMESPACE_NODE *Next; /* Referenced flag is set during the namespace xref */ @@ -126,23 +128,19 @@ LkIsObjectUsed ( return (AE_OK); } - /* - * Ignore names that start with an underscore, - * these are the reserved ACPI names and are typically not referenced, - * they are called by the host OS. - */ - if (Node->Name.Ascii[0] == '_') + if (!Node->Op) { return (AE_OK); } - /* There are some types that are typically not referenced, ignore them */ + /* These types are typically never directly referenced, ignore them */ switch (Node->Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: case ACPI_TYPE_LOCAL_RESOURCE: return (AE_OK); @@ -152,12 +150,47 @@ LkIsObjectUsed ( break; } - /* All others are valid unreferenced namespace objects */ + /* Determine if the name is within a control method */ - if (Node->Op) + Next = Node->Parent; + while (Next) { - AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL); + if (Next->Type == ACPI_TYPE_METHOD) + { + /* + * Name is within a method, therefore it is temporary. + * Issue a remark even if it is a reserved name (starts + * with an underscore). + */ + sprintf (MsgBuffer, "Name is within method [%4.4s]", + Next->Name.Ascii); + AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED, + LkGetNameOp (Node->Op), MsgBuffer); + return (AE_OK); + } + + Next = Next->Parent; } + + /* The name is not within a control method */ + + /* + * Ignore names that start with an underscore. These are the reserved + * ACPI names and are typically not referenced since they are meant + * to be called by the host OS. + */ + if (Node->Name.Ascii[0] == '_') + { + return (AE_OK); + } + + /* + * What remains is an unresolved user name that is not within a method. + * However, the object could be referenced via another table, so issue + * the warning at level 2. + */ + AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, + LkGetNameOp (Node->Op), NULL); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index 67e561acf0aa..8c3d2d296e2d 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,17 @@ #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslmain") +/* + * Main routine for the iASL compiler. + * + * Portability note: The compiler depends upon the host for command-line + * wildcard support - it is not implemented locally. For example: + * + * Linux/Unix systems: Shell expands wildcards automatically. + * + * Windows: The setargv.obj module must be linked in to automatically + * expand wildcards. + */ /* Local prototypes */ @@ -62,6 +73,36 @@ static void AslInitialize ( void); +UINT8 +AcpiIsBigEndianMachine ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiIsBigEndianMachine + * + * PARAMETERS: None + * + * RETURN: TRUE if machine is big endian + * FALSE if machine is little endian + * + * DESCRIPTION: Detect whether machine is little endian or big endian. + * + ******************************************************************************/ + +UINT8 +AcpiIsBigEndianMachine ( + void) +{ + union { + UINT32 Integer; + UINT8 Bytes[4]; + } Overlay = {0xFF000000}; + + return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */ +} + /******************************************************************************* * @@ -83,11 +124,21 @@ Usage ( printf ("%s\n\n", ASL_COMPLIANCE); ACPI_USAGE_HEADER ("iasl [Options] [Files]"); - printf ("\nGlobal:\n"); + printf ("\nGeneral:\n"); ACPI_OPTION ("-@ ", "Specify command file"); ACPI_OPTION ("-I

", "Specify additional include directory"); ACPI_OPTION ("-T |ALL|*", "Create table template file for ACPI "); + ACPI_OPTION ("-p ", "Specify path/filename prefix for all output files"); ACPI_OPTION ("-v", "Display compiler version"); + ACPI_OPTION ("-vo", "Enable optimization comments"); + ACPI_OPTION ("-vs", "Disable signon"); + + printf ("\nHelp:\n"); + ACPI_OPTION ("-h", "This message"); + ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); + ACPI_OPTION ("-hf", "Display help for output filename generation"); + ACPI_OPTION ("-hr", "Display ACPI reserved method names"); + ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); printf ("\nPreprocessor:\n"); ACPI_OPTION ("-D ", "Define symbol for preprocessor use"); @@ -95,13 +146,11 @@ Usage ( ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)"); ACPI_OPTION ("-Pn", "Disable preprocessor"); - printf ("\nGeneral Processing:\n"); - ACPI_OPTION ("-p ", "Specify path/filename prefix for all output files"); - ACPI_OPTION ("-va", "Disable all errors and warnings (summary only)"); + printf ("\nErrors, Warnings, and Remarks:\n"); + ACPI_OPTION ("-va", "Disable all errors/warnings/remarks"); + ACPI_OPTION ("-ve", "Report only errors (ignore warnings and remarks)"); ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs"); - ACPI_OPTION ("-vo", "Enable optimization comments"); ACPI_OPTION ("-vr", "Disable remarks"); - ACPI_OPTION ("-vs", "Disable signon"); ACPI_OPTION ("-vw ", "Disable specific warning or remark"); ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); ACPI_OPTION ("-we", "Report warnings as errors"); @@ -123,6 +172,7 @@ Usage ( printf ("\nOptional Listing Files:\n"); ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)"); + ACPI_OPTION ("-lm", "Create hardware summary map file (*.map)"); ACPI_OPTION ("-ln", "Create namespace file (*.nsp)"); ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)"); @@ -131,25 +181,17 @@ Usage ( ACPI_OPTION ("-vt", "Create verbose template files (full disassembly)"); printf ("\nAML Disassembler:\n"); - ACPI_OPTION ("-d ", "Disassemble or decode binary ACPI tables to file (*.dsl)"); + ACPI_OPTION ("-d ", "Disassemble or decode binary ACPI tables to file (*.dsl)"); ACPI_OPTION ("", " (Optional, file type is automatically detected)"); - ACPI_OPTION ("-da ", "Disassemble multiple tables from single namespace"); + ACPI_OPTION ("-da ", "Disassemble multiple tables from single namespace"); ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates"); - ACPI_OPTION ("-dc ", "Disassemble AML and immediately compile it"); + ACPI_OPTION ("-dc ", "Disassemble AML and immediately compile it"); ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)"); - ACPI_OPTION ("-e ", "Include ACPI table(s) for external symbol resolution"); + ACPI_OPTION ("-e ", "Include ACPI table(s) for external symbol resolution"); ACPI_OPTION ("-fe ", "Specify external symbol declaration file"); - ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); ACPI_OPTION ("-in", "Ignore NoOp opcodes"); ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); - printf ("\nHelp:\n"); - ACPI_OPTION ("-h", "This message"); - ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); - ACPI_OPTION ("-hf", "Display help for output filename generation"); - ACPI_OPTION ("-hr", "Display ACPI reserved method names"); - ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); - printf ("\nDebug Options:\n"); ACPI_OPTION ("-bf -bt", "Create debug file (full or parse tree only) (*.txt)"); ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); @@ -286,8 +328,22 @@ main ( ACPI_STATUS Status; int Index1; int Index2; + int ReturnStatus = 0; + /* + * Big-endian machines are not currently supported. ACPI tables must + * be little-endian, and support for big-endian machines needs to + * be implemented. + */ + if (AcpiIsBigEndianMachine ()) + { + fprintf (stderr, + "iASL is not currently supported on big-endian machines.\n"); + return (-1); + } + + AcpiOsInitialize (); ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Initialize preprocessor and compiler before command line processing */ @@ -307,21 +363,11 @@ main ( /* Perform global actions first/only */ - if (Gbl_GetAllTables) - { - Status = AslDoOneFile (NULL); - if (ACPI_FAILURE (Status)) - { - return (-1); - } - return (0); - } - if (Gbl_DisassembleAll) { while (argv[Index1]) { - Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); + Status = AcpiDmAddToExternalFileList (argv[Index1]); if (ACPI_FAILURE (Status)) { return (-1); @@ -335,19 +381,36 @@ main ( while (argv[Index2]) { - Status = AslDoOnePathname (argv[Index2], AslDoOneFile); + /* + * If -p not specified, we will use the input filename as the + * output filename prefix + */ + if (Gbl_UseDefaultAmlFilename) + { + Gbl_OutputFilenamePrefix = argv[Index2]; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); + } + + Status = AslDoOneFile (argv[Index2]); if (ACPI_FAILURE (Status)) { - return (-1); + ReturnStatus = -1; + goto CleanupAndExit; } Index2++; } + +CleanupAndExit: + + UtFreeLineBuffers (); + AslParserCleanup (); + if (AcpiGbl_ExternalFileList) { AcpiDmClearExternalFileList(); } - return (0); + return (ReturnStatus); } diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index 0d2e636cd186..a4b4e670d2df 100644 --- a/sys/contrib/dev/acpica/compiler/aslmap.c +++ b/sys/contrib/dev/acpica/compiler/aslmap.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c new file mode 100644 index 000000000000..5dced39c8244 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c @@ -0,0 +1,346 @@ +/****************************************************************************** + * + * Module Name: aslmapenter - Build resource descriptor/device maps + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmapenter") + +/* Local prototypes */ + +static ACPI_GPIO_INFO * +MpCreateGpioInfo ( + UINT16 PinNumber, + char *DeviceName); + +static ACPI_SERIAL_INFO * +MpCreateSerialInfo ( + char *DeviceName, + UINT16 Address); + + +/******************************************************************************* + * + * FUNCTION: MpSaveGpioInfo + * + * PARAMETERS: Resource - GPIO resource descriptor + * PinCount - From GPIO descriptor + * PinList - From GPIO descriptor + * DeviceName - The "ResourceSource" name + * + * RETURN: None + * + * DESCRIPTION: External Interface. + * Save GPIO resource descriptor information. + * Creates new GPIO info blocks, one for each pin defined by the + * GPIO descriptor. + * + ******************************************************************************/ + +void +MpSaveGpioInfo ( + ACPI_PARSE_OBJECT *Op, + AML_RESOURCE *Resource, + UINT32 PinCount, + UINT16 *PinList, + char *DeviceName) +{ + ACPI_GPIO_INFO *Info; + UINT32 i; + + + /* Mapfile option enabled? */ + + if (!Gbl_MapfileFlag) + { + return; + } + + /* Create an info block for each pin defined in the descriptor */ + + for (i = 0; i < PinCount; i++) + { + Info = MpCreateGpioInfo (PinList[i], DeviceName); + + Info->Op = Op; + Info->DeviceName = DeviceName; + Info->PinCount = PinCount; + Info->PinIndex = i; + Info->PinNumber = PinList[i]; + Info->Type = Resource->Gpio.ConnectionType; + Info->Direction = (UINT8) (Resource->Gpio.IntFlags & 0x0003); /* _IOR, for IO descriptor */ + Info->Polarity = (UINT8) ((Resource->Gpio.IntFlags >> 1) & 0x0003); /* _POL, for INT descriptor */ + } +} + + +/******************************************************************************* + * + * FUNCTION: MpSaveSerialInfo + * + * PARAMETERS: Resource - A Serial resource descriptor + * DeviceName - The "ResourceSource" name. + * + * RETURN: None + * + * DESCRIPTION: External Interface. + * Save serial resource descriptor information. + * Creates a new serial info block. + * + ******************************************************************************/ + +void +MpSaveSerialInfo ( + ACPI_PARSE_OBJECT *Op, + AML_RESOURCE *Resource, + char *DeviceName) +{ + ACPI_SERIAL_INFO *Info; + UINT16 Address; + UINT32 Speed; + + + /* Mapfile option enabled? */ + + if (!Gbl_MapfileFlag) + { + return; + } + + if (Resource->DescriptorType != ACPI_RESOURCE_NAME_SERIAL_BUS) + { + return; + } + + /* Extract address and speed from the resource descriptor */ + + switch (Resource->CommonSerialBus.Type) + { + case AML_RESOURCE_I2C_SERIALBUSTYPE: + + Address = Resource->I2cSerialBus.SlaveAddress; + Speed = Resource->I2cSerialBus.ConnectionSpeed; + break; + + case AML_RESOURCE_SPI_SERIALBUSTYPE: + + Address = Resource->SpiSerialBus.DeviceSelection; + Speed = Resource->SpiSerialBus.ConnectionSpeed; + break; + + case AML_RESOURCE_UART_SERIALBUSTYPE: + + Address = 0; + Speed = Resource->UartSerialBus.DefaultBaudRate; + break; + + default: /* Invalid bus subtype */ + return; + } + + Info = MpCreateSerialInfo (DeviceName, Address); + + Info->Op = Op; + Info->DeviceName = DeviceName; + Info->Resource = Resource; + Info->Address = Address; + Info->Speed = Speed; +} + + +/******************************************************************************* + * + * FUNCTION: MpCreateGpioInfo + * + * PARAMETERS: PinNumber - GPIO pin number + * DeviceName - The "ResourceSource" name + * + * RETURN: New GPIO info block. + * + * DESCRIPTION: Create a new GPIO info block and place it on the global list. + * The list is sorted by GPIO device names first, and pin numbers + * secondarily. + * + ******************************************************************************/ + +static ACPI_GPIO_INFO * +MpCreateGpioInfo ( + UINT16 PinNumber, + char *DeviceName) +{ + ACPI_GPIO_INFO *Info; + ACPI_GPIO_INFO *NextGpio; + ACPI_GPIO_INFO *PrevGpio; + + + /* + * Allocate a new info block and insert it into the global GPIO list + * sorted by both source device name and then the pin number. There is + * one block per pin. + */ + Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, + UtStringCacheCalloc (sizeof (ACPI_GPIO_INFO))); + + NextGpio = Gbl_GpioList; + PrevGpio = NULL; + if (!Gbl_GpioList) + { + Gbl_GpioList = Info; + Info->Next = NULL; + return (Info); + } + + /* Sort on source DeviceName first */ + + while (NextGpio && + (ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0)) + { + PrevGpio = NextGpio; + NextGpio = NextGpio->Next; + } + + /* Now sort on the PinNumber */ + + while (NextGpio && + (NextGpio->PinNumber < PinNumber) && + !ACPI_STRCMP (DeviceName, NextGpio->DeviceName)) + { + PrevGpio = NextGpio; + NextGpio = NextGpio->Next; + } + + /* Finish the list insertion */ + + if (PrevGpio) + { + PrevGpio->Next = Info; + } + else + { + Gbl_GpioList = Info; + } + + Info->Next = NextGpio; + return (Info); +} + + +/******************************************************************************* + * + * FUNCTION: MpCreateSerialInfo + * + * PARAMETERS: DeviceName - The "ResourceSource" name. + * Address - Physical address for the device + * + * RETURN: New Serial info block. + * + * DESCRIPTION: Create a new Serial info block and place it on the global list. + * The list is sorted by Serial device names first, and addresses + * secondarily. + * + ******************************************************************************/ + +static ACPI_SERIAL_INFO * +MpCreateSerialInfo ( + char *DeviceName, + UINT16 Address) +{ + ACPI_SERIAL_INFO *Info; + ACPI_SERIAL_INFO *NextSerial; + ACPI_SERIAL_INFO *PrevSerial; + + + /* + * Allocate a new info block and insert it into the global Serial list + * sorted by both source device name and then the address. + */ + Info = ACPI_CAST_PTR (ACPI_SERIAL_INFO, + UtStringCacheCalloc (sizeof (ACPI_SERIAL_INFO))); + + NextSerial = Gbl_SerialList; + PrevSerial = NULL; + if (!Gbl_SerialList) + { + Gbl_SerialList = Info; + Info->Next = NULL; + return (Info); + } + + /* Sort on source DeviceName */ + + while (NextSerial && + (ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0)) + { + PrevSerial = NextSerial; + NextSerial = NextSerial->Next; + } + + /* Now sort on the Address */ + + while (NextSerial && + (NextSerial->Address < Address) && + !ACPI_STRCMP (DeviceName, NextSerial->DeviceName)) + { + PrevSerial = NextSerial; + NextSerial = NextSerial->Next; + } + + /* Finish the list insertion */ + + if (PrevSerial) + { + PrevSerial->Next = Info; + } + else + { + Gbl_SerialList = Info; + } + + Info->Next = NextSerial; + return (Info); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c new file mode 100644 index 000000000000..26d4fedfe0c7 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c @@ -0,0 +1,661 @@ +/****************************************************************************** + * + * Module Name: aslmapoutput - Output/emit the resource descriptor/device maps + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 "aslcompiler.y.h" +#include +#include +#include +#include + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmapoutput") + +/* Local prototypes */ + +static void +MpEmitGpioInfo ( + void); + +static void +MpEmitSerialInfo ( + void); + +static void +MpEmitDeviceTree ( + void); + +static ACPI_STATUS +MpEmitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static void +MpXrefDevices ( + ACPI_GPIO_INFO *Info); + +static ACPI_STATUS +MpNamespaceXrefBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + + +/* Strings used to decode flag bits */ + +const char *DirectionDecode[] = +{ + "Both I/O ", + "InputOnly ", + "OutputOnly ", + "Preserve " +}; + +const char *PolarityDecode[] = +{ + "ActiveHigh", + "ActiveLow ", + "ActiveBoth", + "Reserved " +}; + + +/******************************************************************************* + * + * FUNCTION: MpEmitMappingInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: External interface. + * Create and open the mapfile and emit all of the collected + * hardware mapping information. Includes: GPIO information, + * Serial information, and a dump of the entire ACPI device tree. + * + ******************************************************************************/ + +void +MpEmitMappingInfo ( + void) +{ + char *NewFilename; + + + /* Mapfile option enabled? */ + + if (!Gbl_MapfileFlag) + { + return; + } + + /* Create/Open a map file */ + + NewFilename = FlGenerateFilename (Gbl_OutputFilenamePrefix, + FILE_SUFFIX_MAP); + if (!NewFilename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + } + + /* Open the hex file, text mode (closed at compiler exit) */ + + FlOpenFile (ASL_FILE_MAP_OUTPUT, NewFilename, "w+t"); + AslCompilerSignon (ASL_FILE_MAP_OUTPUT); + AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT); + + if (!Gbl_GpioList) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\nNo GPIO devices found\n"); + } + + if (!Gbl_SerialList) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\nNo Serial devices found (I2C/SPI/UART)\n"); + } + + if (!Gbl_GpioList && !Gbl_SerialList) + { + return; + } + + /* Headers */ + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\nResource Descriptor Connectivity Map\n"); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "------------------------------------\n"); + + /* Emit GPIO and Serial descriptors, then entire ACPI device tree */ + + MpEmitGpioInfo (); + MpEmitSerialInfo (); + MpEmitDeviceTree (); + + /* Clear the lists - no need to free memory here */ + + Gbl_SerialList = NULL; + Gbl_GpioList = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitGpioInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit the info about all GPIO devices found during the + * compile or disassembly. + * + ******************************************************************************/ + +static void +MpEmitGpioInfo ( + void) +{ + ACPI_GPIO_INFO *Info; + char *Type; + char *PrevDeviceName = NULL; + const char *Direction; + const char *Polarity; + char *ParentPathname; + const char *Description; + char *HidString; + const AH_DEVICE_ID *HidInfo; + + + /* Walk the GPIO descriptor list */ + + Info = Gbl_GpioList; + while (Info) + { + HidString = MpGetHidViaNamestring (Info->DeviceName); + + /* Print header info for the controller itself */ + + if (!PrevDeviceName || + ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\n\nGPIO Controller: %-8s %-28s", + HidString, Info->DeviceName); + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "\n\nPin Type Direction Polarity" + " Dest _HID Destination\n"); + } + + PrevDeviceName = Info->DeviceName; + + /* Setup various strings based upon the type (GpioInt or GpioIo) */ + + switch (Info->Type) + { + case AML_RESOURCE_GPIO_TYPE_INT: + + Type = "GpioInt"; + Direction = "-Interrupt-"; + Polarity = PolarityDecode[Info->Polarity]; + break; + + case AML_RESOURCE_GPIO_TYPE_IO: + + Type = "GpioIo "; + Direction = DirectionDecode[Info->Direction]; + Polarity = " "; + break; + + default: + continue; + } + + /* Emit the GPIO info */ + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%4.4X %s %s %s ", + Info->PinNumber, Type, Direction, Polarity); + + ParentPathname = NULL; + HidString = MpGetConnectionInfo (Info->Op, Info->PinIndex, + &Info->TargetNode, &ParentPathname); + if (HidString) + { + /* + * This is a Connection() field + * Attempt to find all references to the field. + */ + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + + MpXrefDevices (Info); + } + else + { + /* + * For Devices, attempt to get the _HID description string. + * Failing that (many _HIDs are not recognized), attempt to + * get the _DDN description string. + */ + HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode, + &ParentPathname); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + + /* Get the _HID description or _DDN string */ + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + else if ((Description = MpGetDdnValue (ParentPathname))) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", + Description); + } + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n"); + ACPI_FREE (ParentPathname); + Info = Info->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitSerialInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit the info about all Serial devices found during the + * compile or disassembly. + * + ******************************************************************************/ + +static void +MpEmitSerialInfo ( + void) +{ + ACPI_SERIAL_INFO *Info; + char *Type; + char *ParentPathname; + char *PrevDeviceName = NULL; + char *HidString; + const AH_DEVICE_ID *HidInfo; + const char *Description; + AML_RESOURCE *Resource; + + + /* Walk the constructed serial descriptor list */ + + Info = Gbl_SerialList; + while (Info) + { + Resource = Info->Resource; + switch (Resource->CommonSerialBus.Type) + { + case AML_RESOURCE_I2C_SERIALBUSTYPE: + Type = "I2C "; + break; + + case AML_RESOURCE_SPI_SERIALBUSTYPE: + Type = "SPI "; + break; + + case AML_RESOURCE_UART_SERIALBUSTYPE: + Type = "UART"; + break; + + default: + Type = "UNKN"; + break; + } + + HidString = MpGetHidViaNamestring (Info->DeviceName); + + /* Print header info for the controller itself */ + + if (!PrevDeviceName || + ACPI_STRCMP (PrevDeviceName, Info->DeviceName)) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ", + Type); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-8s %-28s", + HidString, Info->DeviceName); + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n"); + FlPrintFile (ASL_FILE_MAP_OUTPUT, + "Type Address Speed Dest _HID Destination\n"); + } + + PrevDeviceName = Info->DeviceName; + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%s %4.4X %8.8X ", + Type, Info->Address, Info->Speed); + + ParentPathname = NULL; + HidString = MpGetConnectionInfo (Info->Op, 0, &Info->TargetNode, + &ParentPathname); + if (HidString) + { + /* + * This is a Connection() field + * Attempt to find all references to the field. + */ + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + } + else + { + /* Normal resource template */ + + HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode, + &ParentPathname); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s", + HidString, ParentPathname); + + /* Get the _HID description or _DDN string */ + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + else if ((Description = MpGetDdnValue (ParentPathname))) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", + Description); + } + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n"); + ACPI_FREE (ParentPathname); + Info = Info->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitDeviceTree + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit information about all devices within the ACPI namespace. + * + ******************************************************************************/ + +static void +MpEmitDeviceTree ( + void) +{ + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nACPI Device Tree\n"); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "----------------\n\n"); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "Device Pathname " + "_HID Description\n\n"); + + /* Walk the namespace from the root */ + + (void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: MpEmitOneDevice + * + * PARAMETERS: ACPI_NAMESPACE_WALK callback + * + * RETURN: Status + * + * DESCRIPTION: Emit information about one ACPI device in the namespace. Used + * during dump of all device objects within the namespace. + * + ******************************************************************************/ + +static ACPI_STATUS +MpEmitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + char *DevicePathname; + char *DdnString; + char *HidString; + const AH_DEVICE_ID *HidInfo; + + + /* Device pathname */ + + DevicePathname = AcpiNsGetExternalPathname ( + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle)); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-32s", DevicePathname); + + /* _HID or _DDN */ + + HidString = MpGetHidValue ( + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle)); + FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s", HidString); + + HidInfo = AcpiAhMatchHardwareId (HidString); + if (HidInfo) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s", + HidInfo->Description); + } + else if ((DdnString = MpGetDdnValue (DevicePathname))) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", DdnString); + } + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n"); + ACPI_FREE (DevicePathname); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: MpXrefDevices + * + * PARAMETERS: Info - A GPIO Info block + * + * RETURN: None + * + * DESCRIPTION: Cross-reference the parse tree and find all references to the + * specified GPIO device. + * + ******************************************************************************/ + +static void +MpXrefDevices ( + ACPI_GPIO_INFO *Info) +{ + + /* Walk the entire parse tree */ + + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + MpNamespaceXrefBegin, NULL, Info); + + if (!Info->References) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // **** No references in table"); + } +} + + +/******************************************************************************* + * + * FUNCTION: MpNamespaceXrefBegin + * + * PARAMETERS: WALK_PARSE_TREE callback + * + * RETURN: Status + * + * DESCRIPTION: Walk parse tree callback used to cross-reference GPIO pins. + * + ******************************************************************************/ + +static ACPI_STATUS +MpNamespaceXrefBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_GPIO_INFO *Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Context); + const ACPI_OPCODE_INFO *OpInfo; + char *DevicePathname; + ACPI_PARSE_OBJECT *ParentOp; + char *HidString; + + + ACPI_FUNCTION_TRACE_PTR (MpNamespaceXrefBegin, Op); + + /* + * If this node is the actual declaration of a name + * [such as the XXXX name in "Method (XXXX)"], + * we are not interested in it here. We only care about names that + * are references to other objects within the namespace and the + * parent objects of name declarations + */ + if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) + { + return (AE_OK); + } + + /* We are only interested in opcodes that have an associated name */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + + if ((OpInfo->Flags & AML_NAMED) || + (OpInfo->Flags & AML_CREATE)) + { + return (AE_OK); + } + + if ((Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && + (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && + (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) + { + return (AE_OK); + } + + if (!Op->Asl.Node) + { + return (AE_OK); + } + + ParentOp = Op->Asl.Parent; + if (ParentOp->Asl.ParseOpcode == PARSEOP_FIELD) + { + return (AE_OK); + } + + if (Op->Asl.Node == Info->TargetNode) + { + DevicePathname = AcpiNsGetExternalPathname ( + Info->TargetNode); + + while (ParentOp && (!ParentOp->Asl.Node)) + { + ParentOp = ParentOp->Asl.Parent; + } + + if (ParentOp) + { + DevicePathname = AcpiNsGetExternalPathname ( + ParentOp->Asl.Node); + + if (!Info->References) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " // References:"); + } + + HidString = MpGetHidViaNamestring (DevicePathname); + + FlPrintFile (ASL_FILE_MAP_OUTPUT, " %s [%s]", + DevicePathname, HidString); + + Info->References++; + } + } + + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmaputils.c b/sys/contrib/dev/acpica/compiler/aslmaputils.c new file mode 100644 index 000000000000..f50c9ea68b5f --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmaputils.c @@ -0,0 +1,402 @@ +/****************************************************************************** + * + * Module Name: aslmaputils - Utilities for the resource descriptor/device maps + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 "aslcompiler.y.h" +#include +#include +#include + +/* This module used for application-level code only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmaputils") + + +/******************************************************************************* + * + * FUNCTION: MpGetHidFromParseTree + * + * PARAMETERS: HidNode - Node for a _HID object + * + * RETURN: An _HID string value. Automatically converts _HID integers + * to strings. Never NULL. + * + * DESCRIPTION: Extract a _HID value from the parse tree, not the namespace. + * Used when a fully initialized namespace is not available. + * + ******************************************************************************/ + +char * +MpGetHidFromParseTree ( + ACPI_NAMESPACE_NODE *HidNode) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Arg; + char *HidString; + + + Op = HidNode->Op; + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_NAME: + + Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ + Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ + + switch (Arg->Asl.ParseOpcode) + { + case PARSEOP_STRING_LITERAL: + + return (Arg->Asl.Value.String); + + case PARSEOP_INTEGER: + + /* Convert EISAID to a string */ + + HidString = UtStringCacheCalloc (ACPI_EISAID_STRING_SIZE); + AcpiExEisaIdToString (HidString, Arg->Asl.Value.Integer); + return (HidString); + + default: + + return ("UNKNOWN"); + } + + default: + return ("-No HID-"); + } +} + + +/******************************************************************************* + * + * FUNCTION: MpGetHidValue + * + * PARAMETERS: DeviceNode - Node for parent device + * + * RETURN: An _HID string value. Automatically converts _HID integers + * to strings. Never NULL. + * + * DESCRIPTION: Extract _HID value from within a device scope. Does not + * actually execute a method, just gets the string or integer + * value for the _HID. + * + ******************************************************************************/ + +char * +MpGetHidValue ( + ACPI_NAMESPACE_NODE *DeviceNode) +{ + ACPI_NAMESPACE_NODE *HidNode; + char *HidString; + ACPI_STATUS Status; + + + Status = AcpiNsGetNode (DeviceNode, METHOD_NAME__HID, + ACPI_NS_NO_UPSEARCH, &HidNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* If only partial namespace, get the _HID from the parse tree */ + + if (!HidNode->Object) + { + return (MpGetHidFromParseTree (HidNode)); + } + + /* Handle the different _HID flavors */ + + switch (HidNode->Type) + { + case ACPI_TYPE_STRING: + + return (HidNode->Object->String.Pointer); + + case ACPI_TYPE_INTEGER: + + /* Convert EISAID to a string */ + + HidString = UtStringCacheCalloc (ACPI_EISAID_STRING_SIZE); + AcpiExEisaIdToString (HidString, HidNode->Object->Integer.Value); + return (HidString); + + case ACPI_TYPE_METHOD: + + return ("-Method-"); + + default: + + FlPrintFile (ASL_FILE_MAP_OUTPUT, "BAD HID TYPE: %u", HidNode->Type); + break; + } + + +ErrorExit: + return ("-No HID-"); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetHidViaNamestring + * + * PARAMETERS: DeviceName - Namepath for parent device + * + * RETURN: _HID string. Never NULL. + * + * DESCRIPTION: Get a _HID value via a device pathname (instead of just simply + * a device node.) + * + ******************************************************************************/ + +char * +MpGetHidViaNamestring ( + char *DeviceName) +{ + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_STATUS Status; + + + Status = AcpiNsGetNode (NULL, DeviceName, ACPI_NS_NO_UPSEARCH, + &DeviceNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + return (MpGetHidValue (DeviceNode)); + + +ErrorExit: + return ("-No HID-"); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetParentDeviceHid + * + * PARAMETERS: Op - Parse Op to be examined + * TargetNode - Where the field node is returned + * ParentDeviceName - Where the node path is returned + * + * RETURN: _HID string. Never NULL. + * + * DESCRIPTION: Find the parent Device or Scope Op, get the full pathname to + * the parent, and get the _HID associated with the parent. + * + ******************************************************************************/ + +char * +MpGetParentDeviceHid ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE **TargetNode, + char **ParentDeviceName) +{ + ACPI_NAMESPACE_NODE *DeviceNode; + + + /* Find parent Device() or Scope() Op */ + + while (Op && + (Op->Asl.AmlOpcode != AML_DEVICE_OP) && + (Op->Asl.AmlOpcode != AML_SCOPE_OP)) + { + Op = Op->Asl.Parent; + } + + if (!Op) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " No_Parent_Device "); + goto ErrorExit; + } + + /* Get the full pathname to the device and the _HID */ + + DeviceNode = Op->Asl.Node; + if (!DeviceNode) + { + FlPrintFile (ASL_FILE_MAP_OUTPUT, " No_Device_Node "); + goto ErrorExit; + } + + *ParentDeviceName = AcpiNsGetExternalPathname (DeviceNode); + return (MpGetHidValue (DeviceNode)); + + +ErrorExit: + return ("-No HID-"); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetDdnValue + * + * PARAMETERS: DeviceName - Namepath for parent device + * + * RETURN: _DDN description string. NULL on failure. + * + * DESCRIPTION: Execute the _DDN method for the device. + * + ******************************************************************************/ + +char * +MpGetDdnValue ( + char *DeviceName) +{ + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_NAMESPACE_NODE *DdnNode; + ACPI_STATUS Status; + + + Status = AcpiNsGetNode (NULL, DeviceName, ACPI_NS_NO_UPSEARCH, + &DeviceNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + Status = AcpiNsGetNode (DeviceNode, METHOD_NAME__DDN, ACPI_NS_NO_UPSEARCH, + &DdnNode); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + if ((DdnNode->Type != ACPI_TYPE_STRING) || + !DdnNode->Object) + { + goto ErrorExit; + } + + return (DdnNode->Object->String.Pointer); + + +ErrorExit: + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: MpGetConnectionInfo + * + * PARAMETERS: Op - Parse Op to be examined + * PinIndex - Index into GPIO PinList + * TargetNode - Where the field node is returned + * TargetName - Where the node path is returned + * + * RETURN: A substitute _HID string, indicating that the name is actually + * a field. NULL if the Op does not refer to a Connection. + * + * DESCRIPTION: Get the Field Unit that corresponds to the PinIndex after + * a Connection() invocation. + * + ******************************************************************************/ + +char * +MpGetConnectionInfo ( + ACPI_PARSE_OBJECT *Op, + UINT32 PinIndex, + ACPI_NAMESPACE_NODE **TargetNode, + char **TargetName) +{ + ACPI_PARSE_OBJECT *NextOp; + UINT32 i; + + + /* + * Handle Connection() here. Find the next named FieldUnit. + * Note: we look at the ParseOpcode for the compiler, look + * at the AmlOpcode for the disassembler. + */ + if ((Op->Asl.AmlOpcode == AML_INT_CONNECTION_OP) || + (Op->Asl.ParseOpcode == PARSEOP_CONNECTION)) + { + /* Find the correct field unit definition */ + + NextOp = Op; + for (i = 0; i <= PinIndex;) + { + NextOp = NextOp->Asl.Next; + while (NextOp && + (NextOp->Asl.ParseOpcode != PARSEOP_NAMESEG) && + (NextOp->Asl.AmlOpcode != AML_INT_NAMEDFIELD_OP)) + { + NextOp = NextOp->Asl.Next; + } + + if (!NextOp) + { + return ("UNKNOWN"); + } + + /* Add length of this field to the current pin index */ + + if (NextOp->Asl.ParseOpcode == PARSEOP_NAMESEG) + { + i += (UINT32) NextOp->Asl.Child->Asl.Value.Integer; + } + else /* AML_INT_NAMEDFIELD_OP */ + { + i += (UINT32) NextOp->Asl.Value.Integer; + } + } + + /* Return the node and pathname for the field unit */ + + *TargetNode = NextOp->Asl.Node; + *TargetName = AcpiNsGetExternalPathname (*TargetNode); + return ("-Field-"); + } + + return (NULL); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.c b/sys/contrib/dev/acpica/compiler/aslmessages.c new file mode 100644 index 000000000000..da4c7365cbd0 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslmessages.c @@ -0,0 +1,409 @@ +/****************************************************************************** + * + * Module Name: aslmessages.c - Compiler error/warning message strings + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslmessages") + + +/* + * Strings for message reporting levels, must match error + * type string tables in aslmessages.c + */ +const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { + "Optimize", + "Remark ", + "Warning ", + "Warning ", + "Warning ", + "Error " +}; + +/* All lowercase versions for IDEs */ + +const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = { + "optimize", + "remark ", + "warning ", + "warning ", + "warning ", + "error " +}; + + +/* + * Actual message strings for each compiler message ID. There are currently + * three distinct blocks of error messages (so that they can be expanded + * individually): + * Main ASL compiler + * Data Table compiler + * Preprocessor + * + * NOTE1: These tables must match the enum list of message IDs in the file + * aslmessages.h exactly. + * + * NOTE2: With the introduction of the -vw option to disable specific messages, + * new messages should only be added to the end of this list, so that values + * for existing messages are not disturbed. + */ + +/* ASL compiler */ + +const char *AslCompilerMsgs [] = +{ +/* The zeroth message is reserved */ "", +/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", +/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", +/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", +/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", +/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments", +/* ASL_MSG_ARG_INIT */ "Method argument is not initialized", +/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset", +/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero", +/* ASL_MSG_CLOSE */ "Could not close file", +/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error", +/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", +/* ASL_MSG_CONNECTION_MISSING */ "A Connection operator is required for this field SpaceId", +/* ASL_MSG_CONNECTION_INVALID */ "Invalid OpRegion SpaceId for use of Connection operator", +/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", +/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", +/* ASL_MSG_CORE_EXCEPTION */ "From ACPICA Subsystem", +/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", +/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", +/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested", +/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)", +/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)", +/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", +/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list", +/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", +/* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode", +/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", +/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)", +/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", +/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", +/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", +/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit", +/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method", +/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters", +/* ASL_MSG_HID_PREFIX */ "_HID prefix must be all uppercase or decimal digits", +/* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits", +/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", +/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", +/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT version < 2)", +/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", +/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", +/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", +/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)", +/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags", +/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)", +/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", +/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence", +/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max", +/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one", +/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window", +/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window", +/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max", +/* ASL_MSG_INVALID_OPERAND */ "Invalid operand", +/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value", +/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value", +/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", +/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression", +/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", +/* ASL_MSG_INVALID_TYPE */ "Invalid type", +/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", +/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)", +/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk", +/* ASL_MSG_LIST_LENGTH_LONG */ "Initializer list longer than declared package length", +/* ASL_MSG_LIST_LENGTH_SHORT */ "Initializer list shorter than declared package length", +/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", +/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", +/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", +/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method", +/* ASL_MSG_LONG_LINE */ "Splitting long input line", +/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure", +/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list", +/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list", +/* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct", +/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types", +/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope", +/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized", +/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", +/* ASL_MSG_NESTED_COMMENT */ "Nested comment found", +/* ASL_MSG_NO_CASES */ "No Case statements under Switch", +/* ASL_MSG_NO_REGION */ "_REG has no corresponding Operation Region", +/* ASL_MSG_NO_RETVAL */ "Called method returns no value", +/* ASL_MSG_NO_WHILE */ "No enclosing While statement", +/* ASL_MSG_NON_ASCII */ "Invalid characters found in file", +/* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", +/* ASL_MSG_NOT_EXIST */ "Object does not exist", +/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from scope", +/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", +/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", +/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope", +/* ASL_MSG_NOT_REFERENCED */ "Object is not referenced", +/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag", +/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string", +/* ASL_MSG_OPEN */ "Could not open file", +/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file", +/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename", +/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero", +/* ASL_MSG_PREPROCESSOR_FILENAME */ "Could not create preprocessor filename", +/* ASL_MSG_READ */ "Could not read file", +/* ASL_MSG_RECURSION */ "Recursive method call", +/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access", +/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access", +/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", +/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", +/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", +/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value", +/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid object type for reserved name", +/* ASL_MSG_RESERVED_PACKAGE_LENGTH */ "Invalid package length for reserved name", +/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", +/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", +/* ASL_MSG_RESERVED_WORD */ "Use of reserved name", +/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", +/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", +/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", +/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)", +/* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect", +/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value", +/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope operator not allowed", +/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", +/* ASL_MSG_SEEK */ "Could not seek file", +/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", +/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized", +/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", +/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", +/* ASL_MSG_STRING_LENGTH */ "String literal too long", +/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer", +/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15", +/* ASL_MSG_SYNTAX */ "", +/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature", +/* ASL_MSG_TAG_LARGER */ "ResourceTag larger than Field", +/* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field", +/* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", +/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", +/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT version < 2)", +/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", +/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", +/* ASL_MSG_UNSUPPORTED */ "Unsupported feature", +/* ASL_MSG_UPPER_CASE */ "Non-hex letters must be upper case", +/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", +/* ASL_MSG_WRITE */ "Could not write file", +/* ASL_MSG_RANGE */ "Constant out of range", +/* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", +/* ASL_MSG_MISSING_DEPENDENCY */ "Missing dependency", +/* ASL_MSG_ILLEGAL_FORWARD_REF */ "Illegal forward reference within a method", +/* ASL_MSG_ILLEGAL_METHOD_REF */ "Illegal reference across two methods" +}; + +/* Table compiler */ + +const char *AslTableCompilerMsgs [] = +{ +/* ASL_MSG_BUFFER_ELEMENT */ "Invalid element in buffer initializer list", +/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero", +/* ASL_MSG_FLAG_VALUE */ "Flag value is too large", +/* ASL_MSG_INTEGER_SIZE */ "Integer too large for target", +/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression", +/* ASL_MSG_INVALID_FIELD_NAME */ "Invalid Field Name", +/* ASL_MSG_INVALID_HEX_INTEGER */ "Invalid hex integer constant", +/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents", +/* ASL_MSG_RESERVED_VALUE */ "Reserved field", +/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined", +/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type", +/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature", +/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero" +}; + +/* Preprocessor */ + +const char *AslPreprocessorMsgs [] = +{ +/* ASL_MSG_DIRECTIVE_SYNTAX */ "Invalid directive syntax", +/* ASL_MSG_ENDIF_MISMATCH */ "Mismatched #endif", +/* ASL_MSG_ERROR_DIRECTIVE */ "#error", +/* ASL_MSG_EXISTING_NAME */ "Name is already defined", +/* ASL_MSG_INVALID_INVOCATION */ "Invalid macro invocation", +/* ASL_MSG_MACRO_SYNTAX */ "Invalid macro syntax", +/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments", +/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive", +/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma", +/* ASL_MSG_WARNING_DIRECTIVE */ "#warning" +}; + + +/******************************************************************************* + * + * FUNCTION: AeDecodeMessageId + * + * PARAMETERS: MessageId - ASL message ID (exception code) to be + * formatted. Possibly fully encoded. + * + * RETURN: A string containing the exception message text. + * + * DESCRIPTION: This function validates and translates an ASL message ID into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AeDecodeMessageId ( + UINT16 MessageId) +{ + UINT32 Index; + const char **MessageTable; + + + /* Main ASL Compiler messages */ + + if (MessageId <= ASL_MSG_MAIN_COMPILER_END) + { + MessageTable = AslCompilerMsgs; + Index = MessageId; + + if (Index >= ACPI_ARRAY_LENGTH (AslCompilerMsgs)) + { + return ("[Unknown ASL Compiler exception ID]"); + } + } + + /* Data Table Compiler messages */ + + else if (MessageId <= ASL_MSG_TABLE_COMPILER_END) + { + MessageTable = AslTableCompilerMsgs; + Index = MessageId - ASL_MSG_TABLE_COMPILER; + + if (Index >= ACPI_ARRAY_LENGTH (AslTableCompilerMsgs)) + { + return ("[Unknown Table Compiler exception ID]"); + } + } + + /* Preprocessor messages */ + + else if (MessageId <= ASL_MSG_PREPROCESSOR_END) + { + MessageTable = AslPreprocessorMsgs; + Index = MessageId - ASL_MSG_PREPROCESSOR; + + if (Index >= ACPI_ARRAY_LENGTH (AslPreprocessorMsgs)) + { + return ("[Unknown Preprocesor exception ID]"); + } + } + + /* Everything else is unknown */ + + else + { + return ("[Unknown exception/component ID]"); + } + + return (MessageTable[Index]); +} + + +/******************************************************************************* + * + * FUNCTION: AeDecodeExceptionLevel + * + * PARAMETERS: Level - The ASL error level to be decoded + * + * RETURN: A string containing the error level text + * + * DESCRIPTION: This function validates and translates an ASL error level into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AeDecodeExceptionLevel ( + UINT8 Level) +{ + /* Range check on Level */ + + if (Level >= ACPI_ARRAY_LENGTH (AslErrorLevel)) + { + return ("Unknown exception level"); + } + + /* Differentiate the string type to be used (IDE is all lower case) */ + + if (Gbl_VerboseErrors) + { + return (AslErrorLevel[Level]); + } + + return (AslErrorLevelIde[Level]); +} + + +/******************************************************************************* + * + * FUNCTION: AeBuildFullExceptionCode + * + * PARAMETERS: Level - ASL error level + * MessageId - ASL exception code to be formatted + * + * RETURN: Fully encoded exception code + * + * DESCRIPTION: Build the full exception code from the error level and the + * actual message ID. + * + ******************************************************************************/ + +UINT16 +AeBuildFullExceptionCode ( + UINT8 Level, + UINT16 MessageId) +{ + + /* + * Error level is in the thousands slot (error/warning/remark, etc.) + * Error codes are 0 - 999 + */ + return (((Level + 1) * 1000) + MessageId); +} diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.h b/sys/contrib/dev/acpica/compiler/aslmessages.h index 9fb7229c44e9..ba0c22b1d297 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.h +++ b/sys/contrib/dev/acpica/compiler/aslmessages.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,11 +41,12 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLMESSAGES_H #define __ASLMESSAGES_H +/* These values must match error type string tables in aslmessages.c */ + typedef enum { ASL_OPTIMIZATION = 0, @@ -58,43 +59,41 @@ typedef enum } ASL_MESSAGE_TYPES; -#ifdef ASL_EXCEPTIONS -/* Strings for message reporting levels, must match values above */ - -const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { - "Optimize", - "Remark ", - "Warning ", - "Warning ", - "Warning ", - "Error " -}; - -/* All lowercase versions for IDEs */ - -const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = { - "optimize", - "remark ", - "warning ", - "warning ", - "warning ", - "error " -}; - -#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */ -#endif +#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings for types above */ /* - * Values for all compiler messages. + * Exception code blocks, 0 - 999 + * Available for new exception blocks: 600 - 999 + */ +#define ASL_MSG_MAIN_COMPILER 0 /* 0 - 299 */ +#define ASL_MSG_MAIN_COMPILER_END 299 + +#define ASL_MSG_TABLE_COMPILER 300 /* 300 - 499 */ +#define ASL_MSG_TABLE_COMPILER_END 499 + +#define ASL_MSG_PREPROCESSOR 500 /* 500 - 599 */ +#define ASL_MSG_PREPROCESSOR_END 599 + + +/* + * Values (message IDs) for all compiler messages. There are currently + * three distinct blocks of error messages (so that they can be expanded + * individually): + * Main ASL compiler + * Data Table compiler + * Preprocessor * - * NOTE: With the introduction of the -vw option to disable specific messages, - * new messages should only be added to the end of this list, so that values - * for existing messages are not disturbed. + * NOTE1: This list must match the tables of message strings in the file + * aslmessages.c exactly. + * + * NOTE2: With the introduction of the -vw option to disable specific + * messages, new messages should only be added to the end of these + * lists, so that values for existing messages are not disturbed. */ typedef enum { - ASL_MSG_RESERVED = 0, + ASL_MSG_RESERVED = ASL_MSG_MAIN_COMPILER, ASL_MSG_ALIGNMENT, ASL_MSG_ALPHANUMERIC_STRING, @@ -236,23 +235,13 @@ typedef enum ASL_MSG_WRITE, ASL_MSG_RANGE, ASL_MSG_BUFFER_ALLOCATION, + ASL_MSG_MISSING_DEPENDENCY, + ASL_MSG_ILLEGAL_FORWARD_REF, + ASL_MSG_ILLEGAL_METHOD_REF, - /* These messages are used by the Preprocessor only */ + /* These messages are used by the Data Table compiler only */ - ASL_MSG_DIRECTIVE_SYNTAX, - ASL_MSG_ENDIF_MISMATCH, - ASL_MSG_ERROR_DIRECTIVE, - ASL_MSG_EXISTING_NAME, - ASL_MSG_INVALID_INVOCATION, - ASL_MSG_MACRO_SYNTAX, - ASL_MSG_TOO_MANY_ARGUMENTS, - ASL_MSG_UNKNOWN_DIRECTIVE, - ASL_MSG_UNKNOWN_PRAGMA, - ASL_MSG_WARNING_DIRECTIVE, - - /* These messages are used by the data table compiler only */ - - ASL_MSG_BUFFER_ELEMENT, + ASL_MSG_BUFFER_ELEMENT = ASL_MSG_TABLE_COMPILER, ASL_MSG_DIVIDE_BY_ZERO, ASL_MSG_FLAG_VALUE, ASL_MSG_INTEGER_SIZE, @@ -264,194 +253,22 @@ typedef enum ASL_MSG_UNKNOWN_LABEL, ASL_MSG_UNKNOWN_SUBTABLE, ASL_MSG_UNKNOWN_TABLE, - ASL_MSG_ZERO_VALUE + ASL_MSG_ZERO_VALUE, + + /* These messages are used by the Preprocessor only */ + + ASL_MSG_DIRECTIVE_SYNTAX = ASL_MSG_PREPROCESSOR, + ASL_MSG_ENDIF_MISMATCH, + ASL_MSG_ERROR_DIRECTIVE, + ASL_MSG_EXISTING_NAME, + ASL_MSG_INVALID_INVOCATION, + ASL_MSG_MACRO_SYNTAX, + ASL_MSG_TOO_MANY_ARGUMENTS, + ASL_MSG_UNKNOWN_DIRECTIVE, + ASL_MSG_UNKNOWN_PRAGMA, + ASL_MSG_WARNING_DIRECTIVE, } ASL_MESSAGE_IDS; -#ifdef ASL_EXCEPTIONS - -/* - * Actual message strings for each compiler message. - * - * NOTE: With the introduction of the -vw option to disable specific messages, - * new messages should only be added to the end of this list, so that values - * for existing messages are not disturbed. - */ -char *AslMessages [] = -{ -/* The zeroth message is reserved */ "", -/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", -/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", -/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", -/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", -/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments", -/* ASL_MSG_ARG_INIT */ "Method argument is not initialized", -/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset", -/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero", -/* ASL_MSG_CLOSE */ "Could not close file", -/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error", -/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", -/* ASL_MSG_CONNECTION_MISSING */ "A Connection operator is required for this field SpaceId", -/* ASL_MSG_CONNECTION_INVALID */ "Invalid OpRegion SpaceId for use of Connection operator", -/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", -/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", -/* ASL_MSG_CORE_EXCEPTION */ "From ACPI CA Subsystem", -/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", -/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", -/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested",\ -/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)", -/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)", -/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", -/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list", -/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", -/* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode", -/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", -/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)", -/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", -/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", -/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", -/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit", -/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method", -/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters", -/* ASL_MSG_HID_PREFIX */ "_HID prefix must be all uppercase or decimal digits", -/* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits", -/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", -/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", -/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT version < 2)", -/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", -/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", -/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", -/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)", -/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags", -/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)", -/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", -/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence", -/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max", -/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one", -/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window", -/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window", -/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max", -/* ASL_MSG_INVALID_OPERAND */ "Invalid operand", -/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value", -/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value", -/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", -/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression", -/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", -/* ASL_MSG_INVALID_TYPE */ "Invalid type", -/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", -/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)", -/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk", -/* ASL_MSG_LIST_LENGTH_LONG */ "Initializer list longer than declared package length", -/* ASL_MSG_LIST_LENGTH_SHORT */ "Initializer list shorter than declared package length", -/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", -/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", -/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", -/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method", -/* ASL_MSG_LONG_LINE */ "Splitting long input line", -/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure", -/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list", -/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list", -/* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct", -/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types", -/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope", -/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized", -/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", -/* ASL_MSG_NESTED_COMMENT */ "Nested comment found", -/* ASL_MSG_NO_CASES */ "No Case statements under Switch", -/* ASL_MSG_NO_REGION */ "_REG has no corresponding Operation Region", -/* ASL_MSG_NO_RETVAL */ "Called method returns no value", -/* ASL_MSG_NO_WHILE */ "No enclosing While statement", -/* ASL_MSG_NON_ASCII */ "Invalid characters found in file", -/* ASL_MSG_NON_ZERO */ "Operand evaluates to zero", -/* ASL_MSG_NOT_EXIST */ "Object does not exist", -/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from scope", -/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", -/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", -/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope", -/* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced", -/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag", -/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string", -/* ASL_MSG_OPEN */ "Could not open file", -/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file", -/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename", -/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero", -/* ASL_MSG_PREPROCESSOR_FILENAME */ "Could not create preprocessor filename", -/* ASL_MSG_READ */ "Could not read file", -/* ASL_MSG_RECURSION */ "Recursive method call", -/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access", -/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access", -/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", -/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", -/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", -/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value", -/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid object type for reserved name", -/* ASL_MSG_RESERVED_PACKAGE_LENGTH */ "Invalid package length for reserved name", -/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", -/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", -/* ASL_MSG_RESERVED_WORD */ "Use of reserved name", -/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", -/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", -/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", -/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)", -/* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect", -/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value", -/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope operator not allowed", -/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", -/* ASL_MSG_SEEK */ "Could not seek file", -/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", -/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized", -/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", -/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", -/* ASL_MSG_STRING_LENGTH */ "String literal too long", -/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer", -/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15", -/* ASL_MSG_SYNTAX */ "", -/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature", -/* ASL_MSG_TAG_LARGER */ "ResourceTag larger than Field", -/* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field", -/* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", -/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", -/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT version < 2)", -/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", -/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", -/* ASL_MSG_UNSUPPORTED */ "Unsupported feature", -/* ASL_MSG_UPPER_CASE */ "Non-hex letters must be upper case", -/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", -/* ASL_MSG_WRITE */ "Could not write file", -/* ASL_MSG_RANGE */ "Constant out of range", -/* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", - -/* Preprocessor */ - -/* ASL_MSG_DIRECTIVE_SYNTAX */ "Invalid directive syntax", -/* ASL_MSG_ENDIF_MISMATCH */ "Mismatched #endif", -/* ASL_MSG_ERROR_DIRECTIVE */ "#error", -/* ASL_MSG_EXISTING_NAME */ "Name is already defined", -/* ASL_MSG_INVALID_INVOCATION */ "Invalid macro invocation", -/* ASL_MSG_MACRO_SYNTAX */ "Invalid macro syntax", -/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments", -/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive", -/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma", -/* ASL_MSG_WARNING_DIRECTIVE */ "#warning", - -/* Table compiler */ - -/* ASL_MSG_BUFFER_ELEMENT */ "Invalid element in buffer initializer list", -/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero", -/* ASL_MSG_FLAG_VALUE */ "Flag value is too large", -/* ASL_MSG_INTEGER_SIZE */ "Integer too large for target", -/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression", -/* ASL_MSG_INVALID_FIELD_NAME */ "Invalid Field Name", -/* ASL_MSG_INVALID_HEX_INTEGER */ "Invalid hex integer constant", -/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents", -/* ASL_MSG_RESERVED_VALUE */ "Reserved field must be zero", -/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined", -/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type", -/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature", -/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero" -}; - -#endif /* ASL_EXCEPTIONS */ - #endif /* __ASLMESSAGES_H */ diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c index 72f76477fc64..4e8535110d95 100644 --- a/sys/contrib/dev/acpica/compiler/aslmethod.c +++ b/sys/contrib/dev/acpica/compiler/aslmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -108,7 +107,42 @@ MtMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; - /* Get the name node, ignored here */ + /* + * Special handling for _PSx methods. Dependency rules (same scope): + * + * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3 + * 2) _PS1/_PS2/_PS3: A _PS0 must exist + */ + if (ACPI_COMPARE_NAME (METHOD_NAME__PS0, Op->Asl.NameSeg)) + { + /* For _PS0, one of _PS1/_PS2/_PS3 must exist */ + + if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) && + (!ApFindNameInScope (METHOD_NAME__PS2, Op)) && + (!ApFindNameInScope (METHOD_NAME__PS3, Op))) + { + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + "_PS0 requires one of _PS1/_PS2/_PS3 in same scope"); + } + } + else if ( + ACPI_COMPARE_NAME (METHOD_NAME__PS1, Op->Asl.NameSeg) || + ACPI_COMPARE_NAME (METHOD_NAME__PS2, Op->Asl.NameSeg) || + ACPI_COMPARE_NAME (METHOD_NAME__PS3, Op->Asl.NameSeg)) + { + /* For _PS1/_PS2/_PS3, a _PS0 must exist */ + + if (!ApFindNameInScope (METHOD_NAME__PS0, Op)) + { + sprintf (MsgBuffer, + "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg); + + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + MsgBuffer); + } + } + + /* Get the name node */ Next = Op->Asl.Child; @@ -359,6 +393,17 @@ MtMethodAnalysisWalkBegin ( break; case PARSEOP_DEVICE: + + Next = Op->Asl.Child; + + if (!ApFindNameInScope (METHOD_NAME__HID, Next) && + !ApFindNameInScope (METHOD_NAME__ADR, Next)) + { + AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, + "Device object requires a _HID or _ADR in same scope"); + } + break; + case PARSEOP_EVENT: case PARSEOP_MUTEX: case PARSEOP_OPERATIONREGION: @@ -412,6 +457,7 @@ MtMethodAnalysisWalkBegin ( AnCheckId (Next, ASL_TYPE_CID); } } + break; default: diff --git a/sys/contrib/dev/acpica/compiler/aslnamesp.c b/sys/contrib/dev/acpica/compiler/aslnamesp.c index e7ad672c60cb..550c730bf5d0 100644 --- a/sys/contrib/dev/acpica/compiler/aslnamesp.c +++ b/sys/contrib/dev/acpica/compiler/aslnamesp.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include diff --git a/sys/contrib/dev/acpica/compiler/asloffset.c b/sys/contrib/dev/acpica/compiler/asloffset.c index 390a118d4661..cbe69b21f306 100644 --- a/sys/contrib/dev/acpica/compiler/asloffset.c +++ b/sys/contrib/dev/acpica/compiler/asloffset.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index 6d39da927f89..76e2b058eeaa 100644 --- a/sys/contrib/dev/acpica/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -403,6 +402,7 @@ OpcDoConnection ( ACPI_PARSE_OBJECT *BufferOp; ACPI_PARSE_OBJECT *BufferLengthOp; ACPI_PARSE_OBJECT *BufferDataOp; + ASL_RESOURCE_INFO Info; UINT8 State; @@ -417,8 +417,10 @@ OpcDoConnection ( BufferLengthOp = BufferOp->Asl.Child; BufferDataOp = BufferLengthOp->Asl.Next; + Info.DescriptorTypeOp = BufferDataOp->Asl.Next; + Info.CurrentByteOffset = 0; State = ACPI_RSTATE_NORMAL; - Rnode = RsDoOneResourceDescriptor (BufferDataOp->Asl.Next, 0, &State); + Rnode = RsDoOneResourceDescriptor (&Info, &State); if (!Rnode) { return; /* error */ @@ -623,10 +625,10 @@ OpcDoEisaId ( (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 | (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 | - (UtHexCharToValue (InString[3])) << 12 | - (UtHexCharToValue (InString[4])) << 8 | - (UtHexCharToValue (InString[5])) << 4 | - UtHexCharToValue (InString[6]); + (AcpiUtAsciiCharToHex (InString[3])) << 12 | + (AcpiUtAsciiCharToHex (InString[4])) << 8 | + (AcpiUtAsciiCharToHex (InString[5])) << 4 | + AcpiUtAsciiCharToHex (InString[6]); /* Swap to little-endian to get final ID (see function header) */ @@ -666,7 +668,7 @@ OpcDoUuId ( ACPI_PARSE_OBJECT *Op) { char *InString; - char *Buffer; + UINT8 *Buffer; ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *NewOp; @@ -681,7 +683,7 @@ OpcDoUuId ( } else { - (void) AuConvertStringToUuid (InString, Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } /* Change Op to a Buffer */ diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c index 07bf88fa335f..8c6bfbd6f492 100644 --- a/sys/contrib/dev/acpica/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/compiler/asloperands.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -913,8 +912,8 @@ OpnDoDefinitionBlock ( * We will use the AML filename that is embedded in the source file * for the output filename. */ - Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) + - strlen ((char *) Child->Asl.Value.Buffer) + 1); + Filename = UtStringCacheCalloc (strlen (Gbl_DirectoryPath) + + strlen ((char *) Child->Asl.Value.Buffer) + 1); /* Prepend the current directory path */ @@ -922,6 +921,7 @@ OpnDoDefinitionBlock ( strcat (Filename, (char *) Child->Asl.Value.Buffer); Gbl_OutputFilenamePrefix = Filename; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); } Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; @@ -968,7 +968,7 @@ OpnDoDefinitionBlock ( if (Child->Asl.Value.String) { Length = ACPI_STRLEN (Child->Asl.Value.String); - Gbl_TableId = AcpiOsAllocate (Length + 1); + Gbl_TableId = UtStringCacheCalloc (Length + 1); ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); /* diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index 3471006748e5..8e632925b230 100644 --- a/sys/contrib/dev/acpica/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/compiler/aslopt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -168,7 +167,7 @@ OptSearchToRoot ( /* We must allocate a new string for the name (TargetPath gets deleted) */ - *NewPath = ACPI_ALLOCATE_ZEROED (ACPI_NAME_SIZE + 1); + *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1); ACPI_STRCPY (*NewPath, Path); if (ACPI_STRNCMP (*NewPath, "_T_", 3)) @@ -576,7 +575,8 @@ OptOptimizeNamePath ( return_VOID; } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "%5d [%12.12s] [%12.12s] ", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + "PATH OPTIMIZE: Line %5d ParentOp [%12.12s] ThisOp [%12.12s] ", Op->Asl.LogicalLineNumber, AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); @@ -620,7 +620,7 @@ OptOptimizeNamePath ( { /* This is the declaration of a new name */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n")); /* * The node of interest is the parent of this node (the containing @@ -646,7 +646,7 @@ OptOptimizeNamePath ( { /* This is a reference to an existing named object */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REF ")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n")); } /* @@ -688,9 +688,10 @@ OptOptimizeNamePath ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, - "%37s (%2u) ==> %-32s(%2u) %-32s", - (char *) CurrentPath.Pointer, (UINT32) CurrentPath.Length, - (char *) TargetPath.Pointer, (UINT32) TargetPath.Length, ExternalNameString)); + "CURRENT SCOPE: (%2u) %-37s FULL PATH TO NAME: (%2u) %-32s ACTUAL AML:%-32s\n", + (UINT32) CurrentPath.Length, (char *) CurrentPath.Pointer, + (UINT32) TargetPath.Length, (char *) TargetPath.Pointer, + ExternalNameString)); ACPI_FREE (ExternalNameString); @@ -747,7 +748,8 @@ OptOptimizeNamePath ( HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath)); OptTotal += HowMuchShorter; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED %2u (%u)", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + " REDUCED BY %2u (TOTAL SAVED %2u)", (UINT32) HowMuchShorter, OptTotal)); if (Flags & AML_NAMED) diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c index 66a92493397b..9c38371281e9 100644 --- a/sys/contrib/dev/acpica/compiler/asloptions.c +++ b/sys/contrib/dev/acpica/compiler/asloptions.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -118,8 +118,7 @@ AslCommandLine ( /* Next parameter must be the input filename */ if (!argv[AcpiGbl_Optind] && - !Gbl_DisasmFlag && - !Gbl_GetAllTables) + !Gbl_DisasmFlag) { printf ("Missing input filename\n"); BadCommandLine = TRUE; @@ -169,7 +168,7 @@ AslDoOptions ( /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) { case '@': /* Begin a response file */ @@ -267,11 +266,22 @@ AslDoOptions ( case 'e': /* External files for disassembler */ - Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); - if (ACPI_FAILURE (Status)) + /* Get entire list of external files */ + + AcpiGbl_Optind--; + argv[AcpiGbl_Optind] = AcpiGbl_Optarg; + + while (argv[AcpiGbl_Optind] && + (argv[AcpiGbl_Optind][0] != '-')) { - printf ("Could not add %s to external list\n", AcpiGbl_Optarg); - return (-1); + Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); + if (ACPI_FAILURE (Status)) + { + printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]); + return (-1); + } + + AcpiGbl_Optind++; } break; @@ -308,9 +318,8 @@ AslDoOptions ( case 'g': /* Get all ACPI tables */ - Gbl_GetAllTables = TRUE; - Gbl_DoCompile = FALSE; - break; + printf ("-g option is deprecated, use acpidump utility instead\n"); + exit (1); case 'h': @@ -404,6 +413,13 @@ AslDoOptions ( Gbl_PreprocessorOutputFlag = TRUE; break; + case 'm': + + /* Produce hardware map summary file */ + + Gbl_MapfileFlag = TRUE; + break; + case 'n': /* Produce namespace file */ @@ -513,6 +529,8 @@ AslDoOptions ( case 'p': /* Override default AML output filename */ Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); + Gbl_UseDefaultAmlFilename = FALSE; break; @@ -596,11 +614,19 @@ AslDoOptions ( case 'a': - /* Disable All error/warning messages */ + /* Disable all error/warning/remark messages */ Gbl_NoErrors = TRUE; break; + case 'e': + + /* Disable all warning/remark messages (errors only) */ + + Gbl_DisplayRemarks = FALSE; + Gbl_DisplayWarnings = FALSE; + break; + case 'i': /* * Support for integrated development environment(s). diff --git a/sys/contrib/dev/acpica/compiler/aslparser.y b/sys/contrib/dev/acpica/compiler/aslparser.y new file mode 100644 index 000000000000..b473041ac43b --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslparser.y @@ -0,0 +1,131 @@ +%{ +/****************************************************************************** + * + * Module Name: aslparser.y - Master Bison/Yacc input file for iASL + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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_COMPILER + ACPI_MODULE_NAME ("aslparse") + +/* + * Global Notes: + * + * October 2005: The following list terms have been optimized (from the + * original ASL grammar in the ACPI specification) to force the immediate + * reduction of each list item so that the parse stack use doesn't increase on + * each list element and possibly overflow on very large lists (>4000 items). + * This dramatically reduces use of the parse stack overall. + * + * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, + * ResourceMacroList, and FieldUnitList + */ + +void * +AslLocalAllocate ( + unsigned int Size); + +/* Bison/yacc configuration */ + +#define static +#undef malloc +#define malloc AslLocalAllocate +#undef alloca +#define alloca AslLocalAllocate +#define yytname AslCompilername + +#define YYINITDEPTH 600 /* State stack depth */ +#define YYDEBUG 1 /* Enable debug output */ +#define YYERROR_VERBOSE 1 /* Verbose error messages */ +#define YYFLAG -32768 + +/* Define YYMALLOC/YYFREE to prevent redefinition errors */ + +#define YYMALLOC AslLocalAllocate +#define YYFREE ACPI_FREE +%} + +/* + * Declare the type of values in the grammar + */ +%union { + UINT64 i; + char *s; + ACPI_PARSE_OBJECT *n; +} + +/* + * These shift/reduce conflicts are expected. There should be zero + * reduce/reduce conflicts. + */ +%expect 86 + +/*! [Begin] no source code translation */ + +/* + * The M4 macro processor is used to bring in the parser items, + * in order to keep this master file smaller, and to break up + * the various parser items. + */ +m4_define(NoEcho) + +/* Token types */ + +m4_include(asltokens.y) + +/* Production types/names */ + +m4_include(asltypes.y) +%% + +/* Production rules */ + +m4_include(aslrules.y) +%% + +/*! [End] no source code translation !*/ + +/* Local support functions in C */ + +m4_include(aslsupport.y) diff --git a/sys/contrib/dev/acpica/compiler/aslpredef.c b/sys/contrib/dev/acpica/compiler/aslpredef.c index 7f411fbd7155..e436f8765c88 100644 --- a/sys/contrib/dev/acpica/compiler/aslpredef.c +++ b/sys/contrib/dev/acpica/compiler/aslpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -251,10 +251,16 @@ ApCheckPredefinedReturnValue ( const ACPI_PREDEFINED_INFO *ThisName; - /* Check parent method for a match against the predefined name list */ - + /* + * Check parent method for a match against the predefined name list. + * + * Note: Disable compiler errors/warnings because any errors will be + * caught when analyzing the parent method. Eliminates duplicate errors. + */ + Gbl_AllExceptionsDisabled = TRUE; Index = ApCheckForPredefinedName (MethodInfo->Op, MethodInfo->Op->Asl.NameSeg); + Gbl_AllExceptionsDisabled = FALSE; switch (Index) { diff --git a/sys/contrib/dev/acpica/compiler/aslprepkg.c b/sys/contrib/dev/acpica/compiler/aslprepkg.c index 9cc67f421b10..174bb823500a 100644 --- a/sys/contrib/dev/acpica/compiler/aslprepkg.c +++ b/sys/contrib/dev/acpica/compiler/aslprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -169,7 +169,7 @@ ApCheckPackage ( { case ACPI_PTYPE1_FIXED: /* - * The package count is fixed and there are no sub-packages + * The package count is fixed and there are no subpackages * * If package is too small, exit. * If package is larger than expected, issue warning but continue @@ -194,7 +194,7 @@ ApCheckPackage ( case ACPI_PTYPE1_VAR: /* - * The package count is variable, there are no sub-packages, + * The package count is variable, there are no subpackages, * and all elements must be of the same type */ for (i = 0; i < Count; i++) @@ -207,7 +207,7 @@ ApCheckPackage ( case ACPI_PTYPE1_OPTION: /* - * The package count is variable, there are no sub-packages. + * The package count is variable, there are no subpackages. * There are a fixed number of required elements, and a variable * number of optional elements. * @@ -251,7 +251,7 @@ ApCheckPackage ( Op = Op->Asl.Next; Count--; - /* Examine the sub-packages */ + /* Examine the subpackages */ ApCheckPackageList (Predefined->Info.Name, Op, Package, 1, Count); @@ -259,7 +259,7 @@ ApCheckPackage ( case ACPI_PTYPE2_PKG_COUNT: - /* First element is the (Integer) count of sub-packages to follow */ + /* First element is the (Integer) count of subpackages to follow */ Status = ApCheckObjectType (Predefined->Info.Name, Op, ACPI_RTYPE_INTEGER, 0); @@ -283,12 +283,47 @@ ApCheckPackage ( Op = Op->Asl.Next; - /* Examine the sub-packages */ + /* Examine the subpackages */ ApCheckPackageList (Predefined->Info.Name, Op, Package, 1, Count); break; + case ACPI_PTYPE2_UUID_PAIR: + + /* The package contains a variable list of UUID Buffer/Package pairs */ + + /* The length of the package must be even */ + + if (Count & 1) + { + sprintf (MsgBuffer, "%4.4s: Package length, %d, must be even.", + Predefined->Info.Name, Count); + + AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, + ParentOp->Asl.Child, MsgBuffer); + } + + /* Validate the alternating types */ + + for (i = 0; i < Count; ++i) + { + if (i & 1) + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType2, i); + } + else + { + ApCheckObjectType (Predefined->Info.Name, Op, + Package->RetInfo.ObjectType1, i); + } + + Op = Op->Asl.Next; + } + + break; + case ACPI_PTYPE2: case ACPI_PTYPE2_FIXED: case ACPI_PTYPE2_MIN: @@ -296,10 +331,10 @@ ApCheckPackage ( case ACPI_PTYPE2_FIX_VAR: /* * These types all return a single Package that consists of a - * variable number of sub-Packages. + * variable number of subpackages. */ - /* Examine the sub-packages */ + /* Examine the subpackages */ ApCheckPackageList (Predefined->Info.Name, Op, Package, 0, Count); @@ -467,6 +502,12 @@ ApCheckPackageList ( Count, ExpectedCount); break; } + if (Count > ExpectedCount) + { + ApPackageTooLarge (PredefinedName, SubPackageOp, + Count, ExpectedCount); + break; + } ApCheckPackageElements (PredefinedName, Op, Package->RetInfo.ObjectType1, Package->RetInfo.Count1, @@ -494,7 +535,7 @@ ApCheckPackageList ( case ACPI_PTYPE2_FIXED: - /* Each sub-package has a fixed length */ + /* Each subpackage has a fixed length */ ExpectedCount = Package->RetInfo2.Count; if (Count < ExpectedCount) @@ -503,6 +544,12 @@ ApCheckPackageList ( Count, ExpectedCount); break; } + if (Count > ExpectedCount) + { + ApPackageTooLarge (PredefinedName, SubPackageOp, + Count, ExpectedCount); + break; + } /* Check each object/type combination */ @@ -517,7 +564,7 @@ ApCheckPackageList ( case ACPI_PTYPE2_MIN: - /* Each sub-package has a variable but minimum length */ + /* Each subpackage has a variable but minimum length */ ExpectedCount = Package->RetInfo.Count1; if (Count < ExpectedCount) @@ -527,7 +574,7 @@ ApCheckPackageList ( break; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ ApCheckPackageElements (PredefinedName, Op, Package->RetInfo.ObjectType1, Count, 0, 0); @@ -576,7 +623,7 @@ ApCheckPackageList ( Count = ExpectedCount; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ Op = Op->Asl.Next; ApCheckPackageElements (PredefinedName, Op, diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 0a95a9011c47..3cedeedf061f 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -123,22 +122,10 @@ RsSmallAddressCheck ( return; } - /* Special case for Memory24, values are compressed */ - - if (Type == ACPI_RESOURCE_NAME_MEMORY24) - { - if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */ - { - Alignment = ACPI_UINT16_MAX + 1; - } - - Minimum <<= 8; - Maximum <<= 8; - Length *= 256; - } - - /* IO descriptor has different definition of min/max, don't check */ - + /* + * Range checks for Memory24 and Memory32. + * IO descriptor has different definition of min/max, don't check. + */ if (Type != ACPI_RESOURCE_NAME_IO) { /* Basic checks on Min/Max/Length */ @@ -151,6 +138,19 @@ RsSmallAddressCheck ( { AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); } + + /* Special case for Memory24, min/max values are compressed */ + + if (Type == ACPI_RESOURCE_NAME_MEMORY24) + { + if (!Alignment) /* Alignment==0 means 64K alignment */ + { + Alignment = ACPI_UINT16_MAX + 1; + } + + Minimum <<= 8; + Maximum <<= 8; + } } /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */ @@ -645,8 +645,7 @@ RsCheckListForDuplicates ( ASL_RESOURCE_NODE * RsDoOneResourceDescriptor ( - ACPI_PARSE_OBJECT *DescriptorTypeOp, - UINT32 CurrentByteOffset, + ASL_RESOURCE_INFO *Info, UINT8 *State) { ASL_RESOURCE_NODE *Rnode = NULL; @@ -654,36 +653,31 @@ RsDoOneResourceDescriptor ( /* Construct the resource */ - switch (DescriptorTypeOp->Asl.ParseOpcode) + switch (Info->DescriptorTypeOp->Asl.ParseOpcode) { case PARSEOP_DMA: - Rnode = RsDoDmaDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDmaDescriptor (Info); break; case PARSEOP_FIXEDDMA: - Rnode = RsDoFixedDmaDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoFixedDmaDescriptor (Info); break; case PARSEOP_DWORDIO: - Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDwordIoDescriptor (Info); break; case PARSEOP_DWORDMEMORY: - Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDwordMemoryDescriptor (Info); break; case PARSEOP_DWORDSPACE: - Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoDwordSpaceDescriptor (Info); break; case PARSEOP_ENDDEPENDENTFN: @@ -693,13 +687,13 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_NORMAL: AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_START_DEPENDENT: AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_DEPENDENT_LIST: @@ -709,104 +703,87 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_NORMAL; - Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoEndDependentDescriptor (Info); break; case PARSEOP_ENDTAG: - Rnode = RsDoEndTagDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoEndTagDescriptor (Info); break; case PARSEOP_EXTENDEDIO: - Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoExtendedIoDescriptor (Info); break; case PARSEOP_EXTENDEDMEMORY: - Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoExtendedMemoryDescriptor (Info); break; case PARSEOP_EXTENDEDSPACE: - Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoExtendedSpaceDescriptor (Info); break; case PARSEOP_FIXEDIO: - Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoFixedIoDescriptor (Info); break; case PARSEOP_INTERRUPT: - Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoInterruptDescriptor (Info); break; case PARSEOP_IO: - Rnode = RsDoIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoIoDescriptor (Info); break; case PARSEOP_IRQ: - Rnode = RsDoIrqDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoIrqDescriptor (Info); break; case PARSEOP_IRQNOFLAGS: - Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoIrqNoFlagsDescriptor (Info); break; case PARSEOP_MEMORY24: - Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoMemory24Descriptor (Info); break; case PARSEOP_MEMORY32: - Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoMemory32Descriptor (Info); break; case PARSEOP_MEMORY32FIXED: - Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoMemory32FixedDescriptor (Info); break; case PARSEOP_QWORDIO: - Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoQwordIoDescriptor (Info); break; case PARSEOP_QWORDMEMORY: - Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoQwordMemoryDescriptor (Info); break; case PARSEOP_QWORDSPACE: - Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoQwordSpaceDescriptor (Info); break; case PARSEOP_REGISTER: - Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoGeneralRegisterDescriptor (Info); break; case PARSEOP_STARTDEPENDENTFN: @@ -816,7 +793,7 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_START_DEPENDENT: AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_NORMAL: @@ -827,8 +804,7 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_START_DEPENDENT; - Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoStartDependentDescriptor (Info); *State = ACPI_RSTATE_DEPENDENT_LIST; break; @@ -839,7 +815,7 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_START_DEPENDENT: AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, - DescriptorTypeOp, NULL); + Info->DescriptorTypeOp, NULL); break; case ACPI_RSTATE_NORMAL: @@ -850,69 +826,58 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_START_DEPENDENT; - Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoStartDependentNoPriDescriptor (Info); *State = ACPI_RSTATE_DEPENDENT_LIST; break; case PARSEOP_VENDORLONG: - Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoVendorLargeDescriptor (Info); break; case PARSEOP_VENDORSHORT: - Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoVendorSmallDescriptor (Info); break; case PARSEOP_WORDBUSNUMBER: - Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoWordBusNumberDescriptor (Info); break; case PARSEOP_WORDIO: - Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoWordIoDescriptor (Info); break; case PARSEOP_WORDSPACE: - Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoWordSpaceDescriptor (Info); break; case PARSEOP_GPIO_INT: - Rnode = RsDoGpioIntDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoGpioIntDescriptor (Info); break; case PARSEOP_GPIO_IO: - Rnode = RsDoGpioIoDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoGpioIoDescriptor (Info); break; case PARSEOP_I2C_SERIALBUS: - Rnode = RsDoI2cSerialBusDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoI2cSerialBusDescriptor (Info); break; case PARSEOP_SPI_SERIALBUS: - Rnode = RsDoSpiSerialBusDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoSpiSerialBusDescriptor (Info); break; case PARSEOP_UART_SERIALBUS: - Rnode = RsDoUartSerialBusDescriptor (DescriptorTypeOp, - CurrentByteOffset); + Rnode = RsDoUartSerialBusDescriptor (Info); break; case PARSEOP_DEFAULT_ARG: @@ -923,7 +888,7 @@ RsDoOneResourceDescriptor ( default: printf ("Unknown resource descriptor type [%s]\n", - DescriptorTypeOp->Asl.ParseOpName); + Info->DescriptorTypeOp->Asl.ParseOpName); break; } @@ -932,14 +897,14 @@ RsDoOneResourceDescriptor ( * This allows the resource to be installed in the namespace so that * references to the descriptor can be resolved. */ - DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; - DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC; - DescriptorTypeOp->Asl.Value.Integer = CurrentByteOffset; + Info->DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + Info->DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC; + Info->DescriptorTypeOp->Asl.Value.Integer = Info->CurrentByteOffset; if (Rnode) { - DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; - DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; + Info->DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength; + Info->DescriptorTypeOp->Asl.Extra = ((AML_RESOURCE *) Rnode->Buffer)->DescriptorType; } return (Rnode); @@ -1023,6 +988,7 @@ RsDoResourceTemplate ( ASL_RESOURCE_NODE HeadRnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *Rnode; + ASL_RESOURCE_INFO Info; UINT8 State; @@ -1055,9 +1021,22 @@ RsDoResourceTemplate ( PreviousRnode = &HeadRnode; while (DescriptorTypeOp) { + /* Save information for optional mapfile */ + + if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION) + { + Info.MappingOp = Op->Asl.Parent; + } + else + { + Info.MappingOp = DescriptorTypeOp; + } + + Info.DescriptorTypeOp = DescriptorTypeOp; + Info.CurrentByteOffset = CurrentByteOffset; + DescriptorTypeOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC; - Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, - &State); + Rnode = RsDoOneResourceDescriptor (&Info, &State); /* * Update current byte offset to indicate the number of bytes from the diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 21a87050c430..46bb1fa30fb1 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -65,9 +64,7 @@ * * FUNCTION: RsDoEndTagDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -77,8 +74,7 @@ ASL_RESOURCE_NODE * RsDoEndTagDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ASL_RESOURCE_NODE *Rnode; @@ -99,9 +95,7 @@ RsDoEndTagDescriptor ( * * FUNCTION: RsDoEndDependentDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -111,8 +105,7 @@ RsDoEndTagDescriptor ( ASL_RESOURCE_NODE * RsDoEndDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ASL_RESOURCE_NODE *Rnode; @@ -131,9 +124,7 @@ RsDoEndDependentDescriptor ( * * FUNCTION: RsDoMemory24Descriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -143,8 +134,7 @@ RsDoEndDependentDescriptor ( ASL_RESOURCE_NODE * RsDoMemory24Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -152,10 +142,12 @@ RsDoMemory24Descriptor ( ACPI_PARSE_OBJECT *MaxOp = NULL; ACPI_PARSE_OBJECT *LengthOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); Descriptor = Rnode->Buffer; @@ -208,7 +200,7 @@ RsDoMemory24Descriptor ( case 5: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -227,7 +219,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Maximum, Descriptor->Memory24.AddressLength, Descriptor->Memory24.Alignment, - MinOp, MaxOp, LengthOp, NULL, Op); + MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp); return (Rnode); } @@ -237,9 +229,7 @@ RsDoMemory24Descriptor ( * * FUNCTION: RsDoMemory32Descriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -249,8 +239,7 @@ RsDoMemory24Descriptor ( ASL_RESOURCE_NODE * RsDoMemory32Descriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -259,10 +248,12 @@ RsDoMemory32Descriptor ( ACPI_PARSE_OBJECT *LengthOp = NULL; ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); Descriptor = Rnode->Buffer; @@ -316,7 +307,7 @@ RsDoMemory32Descriptor ( case 5: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -335,7 +326,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Maximum, Descriptor->Memory32.AddressLength, Descriptor->Memory32.Alignment, - MinOp, MaxOp, LengthOp, AlignOp, Op); + MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp); return (Rnode); } @@ -345,9 +336,7 @@ RsDoMemory32Descriptor ( * * FUNCTION: RsDoMemory32FixedDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -357,16 +346,17 @@ RsDoMemory32Descriptor ( ASL_RESOURCE_NODE * RsDoMemory32FixedDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); Descriptor = Rnode->Buffer; @@ -402,7 +392,7 @@ RsDoMemory32FixedDescriptor ( case 3: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -422,9 +412,7 @@ RsDoMemory32FixedDescriptor ( * * FUNCTION: RsDoStartDependentDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -434,19 +422,21 @@ RsDoMemory32FixedDescriptor ( ASL_RESOURCE_NODE * RsDoStartDependentDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *NextRnode; + ASL_RESOURCE_INFO NextInfo; + UINT32 CurrentByteOffset; UINT32 i; UINT8 State; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT)); PreviousRnode = Rnode; @@ -492,8 +482,10 @@ RsDoStartDependentDescriptor ( default: - NextRnode = RsDoOneResourceDescriptor (InitializerOp, - CurrentByteOffset, &State); + NextInfo.CurrentByteOffset = CurrentByteOffset; + NextInfo.DescriptorTypeOp = InitializerOp; + + NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State); /* * Update current byte offset to indicate the number of bytes from the @@ -517,9 +509,7 @@ RsDoStartDependentDescriptor ( * * FUNCTION: RsDoStartDependentNoPriDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -529,18 +519,20 @@ RsDoStartDependentDescriptor ( ASL_RESOURCE_NODE * RsDoStartDependentNoPriDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; ASL_RESOURCE_NODE *PreviousRnode; ASL_RESOURCE_NODE *NextRnode; + ASL_RESOURCE_INFO NextInfo; + UINT32 CurrentByteOffset; UINT8 State; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); Descriptor = Rnode->Buffer; @@ -557,8 +549,10 @@ RsDoStartDependentNoPriDescriptor ( State = ACPI_RSTATE_START_DEPENDENT; while (InitializerOp) { - NextRnode = RsDoOneResourceDescriptor (InitializerOp, - CurrentByteOffset, &State); + NextInfo.CurrentByteOffset = CurrentByteOffset; + NextInfo.DescriptorTypeOp = InitializerOp; + + NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State); /* * Update current byte offset to indicate the number of bytes from the @@ -579,9 +573,7 @@ RsDoStartDependentNoPriDescriptor ( * * FUNCTION: RsDoVendorSmallDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -591,8 +583,7 @@ RsDoStartDependentNoPriDescriptor ( ASL_RESOURCE_NODE * RsDoVendorSmallDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -601,7 +592,7 @@ RsDoVendorSmallDescriptor ( UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; /* Allocate worst case - 7 vendor bytes */ diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/compiler/aslrestype1i.c index 4e78c2c1d8cc..6de7b93b3a78 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1i.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1i.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -63,9 +62,7 @@ * * FUNCTION: RsDoDmaDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -75,18 +72,19 @@ ASL_RESOURCE_NODE * RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; UINT8 DmaChannelMask = 0; UINT8 DmaChannels = 0; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); Descriptor = Rnode->Buffer; @@ -122,7 +120,7 @@ RsDoDmaDescriptor ( case 3: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -184,9 +182,7 @@ RsDoDmaDescriptor ( * * FUNCTION: RsDoFixedDmaDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -196,16 +192,17 @@ RsDoDmaDescriptor ( ASL_RESOURCE_NODE * RsDoFixedDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_DMA)); Descriptor = Rnode->Buffer; @@ -241,7 +238,7 @@ RsDoFixedDmaDescriptor ( case 3: /* Descriptor Name (optional) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: /* Ignore any extra nodes */ @@ -260,9 +257,7 @@ RsDoFixedDmaDescriptor ( * * FUNCTION: RsDoFixedIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -272,17 +267,18 @@ RsDoFixedDmaDescriptor ( ASL_RESOURCE_NODE * RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ACPI_PARSE_OBJECT *AddressOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); Descriptor = Rnode->Buffer; @@ -314,7 +310,7 @@ RsDoFixedIoDescriptor ( case 2: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -341,9 +337,7 @@ RsDoFixedIoDescriptor ( * * FUNCTION: RsDoIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -353,8 +347,7 @@ RsDoFixedIoDescriptor ( ASL_RESOURCE_NODE * RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -363,10 +356,12 @@ RsDoIoDescriptor ( ACPI_PARSE_OBJECT *LengthOp = NULL; ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); Descriptor = Rnode->Buffer; @@ -424,7 +419,7 @@ RsDoIoDescriptor ( case 5: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -443,7 +438,7 @@ RsDoIoDescriptor ( Descriptor->Io.Maximum, Descriptor->Io.AddressLength, Descriptor->Io.Alignment, - MinOp, MaxOp, LengthOp, AlignOp, Op); + MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp); return (Rnode); } @@ -453,9 +448,7 @@ RsDoIoDescriptor ( * * FUNCTION: RsDoIrqDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -465,18 +458,19 @@ RsDoIoDescriptor ( ASL_RESOURCE_NODE * RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 Interrupts = 0; UINT16 IrqMask = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); /* Length = 3 (with flag byte) */ @@ -514,7 +508,7 @@ RsDoIrqDescriptor ( case 3: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -576,9 +570,7 @@ RsDoIrqDescriptor ( * * FUNCTION: RsDoIrqNoFlagsDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -588,18 +580,19 @@ RsDoIrqDescriptor ( ASL_RESOURCE_NODE * RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT16 IrqMask = 0; UINT32 Interrupts = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); Descriptor = Rnode->Buffer; @@ -614,7 +607,7 @@ RsDoIrqNoFlagsDescriptor ( { case 0: /* Name */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index 942d45eb56f6..ec6067b2fb49 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -61,9 +60,7 @@ * * FUNCTION: RsDoGeneralRegisterDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -73,16 +70,17 @@ ASL_RESOURCE_NODE * RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); Descriptor = Rnode->Buffer; @@ -138,7 +136,7 @@ RsDoGeneralRegisterDescriptor ( case 5: /* ResourceTag (ACPI 3.0b) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -157,9 +155,7 @@ RsDoGeneralRegisterDescriptor ( * * FUNCTION: RsDoInterruptDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -169,8 +165,7 @@ RsDoGeneralRegisterDescriptor ( ASL_RESOURCE_NODE * RsDoInterruptDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; AML_RESOURCE *Rover = NULL; @@ -178,13 +173,15 @@ RsDoInterruptDescriptor ( ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN HasResSourceIndex = FALSE; UINT8 ResSourceIndex = 0; UINT8 *ResSourceString = NULL; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; StringLength = RsGetStringDataLength (InitializerOp); /* Count the interrupt numbers */ @@ -211,9 +208,9 @@ RsDoInterruptDescriptor ( OptionIndex += 4; } - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_EXTENDED_IRQ) + - 1 + OptionIndex + StringLength); + 1 + OptionIndex + StringLength); Descriptor = Rnode->Buffer; Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; @@ -303,7 +300,7 @@ RsDoInterruptDescriptor ( case 6: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -396,9 +393,7 @@ RsDoInterruptDescriptor ( * * FUNCTION: RsDoVendorLargeDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -408,8 +403,7 @@ RsDoInterruptDescriptor ( ASL_RESOURCE_NODE * RsDoVendorLargeDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -420,7 +414,7 @@ RsDoVendorLargeDescriptor ( /* Count the number of data bytes */ - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); for (i = 0; InitializerOp; i++) @@ -432,7 +426,7 @@ RsDoVendorLargeDescriptor ( InitializerOp = InitializerOp->Asl.Next; } - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/compiler/aslrestype2d.c index 035b6ecde2b6..39b1f6b764a4 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2d.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2d.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -60,9 +59,7 @@ * * FUNCTION: RsDoDwordIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -72,8 +69,7 @@ ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -85,12 +81,14 @@ RsDoDwordIoDescriptor ( UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT8 *OptionalFields; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); @@ -245,7 +243,7 @@ RsDoDwordIoDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Type */ @@ -279,10 +277,10 @@ RsDoDwordIoDescriptor ( (UINT64) Descriptor->Address32.AddressLength, (UINT64) Descriptor->Address32.Granularity, Descriptor->Address32.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -291,9 +289,7 @@ RsDoDwordIoDescriptor ( * * FUNCTION: RsDoDwordMemoryDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -303,8 +299,7 @@ RsDoDwordIoDescriptor ( ASL_RESOURCE_NODE * RsDoDwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -316,12 +311,14 @@ RsDoDwordMemoryDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); @@ -480,7 +477,7 @@ RsDoDwordMemoryDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; @@ -515,10 +512,10 @@ RsDoDwordMemoryDescriptor ( (UINT64) Descriptor->Address32.AddressLength, (UINT64) Descriptor->Address32.Granularity, Descriptor->Address32.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -527,9 +524,7 @@ RsDoDwordMemoryDescriptor ( * * FUNCTION: RsDoDwordSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -539,8 +534,7 @@ RsDoDwordMemoryDescriptor ( ASL_RESOURCE_NODE * RsDoDwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -552,12 +546,14 @@ RsDoDwordSpaceDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); @@ -712,7 +708,7 @@ RsDoDwordSpaceDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -733,9 +729,9 @@ RsDoDwordSpaceDescriptor ( (UINT64) Descriptor->Address32.AddressLength, (UINT64) Descriptor->Address32.Granularity, Descriptor->Address32.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/compiler/aslrestype2e.c index 5621762a3d3e..b39556342438 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2e.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2e.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_COMPILER @@ -59,9 +58,7 @@ * * FUNCTION: RsDoExtendedIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -71,8 +68,7 @@ ASL_RESOURCE_NODE * RsDoExtendedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -82,11 +78,13 @@ RsDoExtendedIoDescriptor ( ACPI_PARSE_OBJECT *GranOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); @@ -187,7 +185,7 @@ RsDoExtendedIoDescriptor ( case 11: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 12: /* Type */ @@ -221,9 +219,10 @@ RsDoExtendedIoDescriptor ( Descriptor->ExtAddress64.AddressLength, Descriptor->ExtAddress64.Granularity, Descriptor->ExtAddress64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + + StringLength; return (Rnode); } @@ -232,9 +231,7 @@ RsDoExtendedIoDescriptor ( * * FUNCTION: RsDoExtendedMemoryDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -244,8 +241,7 @@ RsDoExtendedIoDescriptor ( ASL_RESOURCE_NODE * RsDoExtendedMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -255,11 +251,13 @@ RsDoExtendedMemoryDescriptor ( ACPI_PARSE_OBJECT *GranOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); @@ -367,7 +365,7 @@ RsDoExtendedMemoryDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; @@ -402,9 +400,10 @@ RsDoExtendedMemoryDescriptor ( Descriptor->ExtAddress64.AddressLength, Descriptor->ExtAddress64.Granularity, Descriptor->ExtAddress64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + + StringLength; return (Rnode); } @@ -413,9 +412,7 @@ RsDoExtendedMemoryDescriptor ( * * FUNCTION: RsDoExtendedSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -425,8 +422,7 @@ RsDoExtendedMemoryDescriptor ( ASL_RESOURCE_NODE * RsDoExtendedSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -436,11 +432,13 @@ RsDoExtendedSpaceDescriptor ( ACPI_PARSE_OBJECT *GranOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT16 StringLength = 0; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); @@ -545,7 +543,7 @@ RsDoExtendedSpaceDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -565,8 +563,9 @@ RsDoExtendedSpaceDescriptor ( Descriptor->ExtAddress64.AddressLength, Descriptor->ExtAddress64.Granularity, Descriptor->ExtAddress64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/compiler/aslrestype2q.c index 3a002a453b9b..f79680f4a488 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2q.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2q.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -60,9 +59,7 @@ * * FUNCTION: RsDoQwordIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -72,8 +69,7 @@ ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -85,12 +81,14 @@ RsDoQwordIoDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); @@ -236,7 +234,7 @@ RsDoQwordIoDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Type */ @@ -270,10 +268,10 @@ RsDoQwordIoDescriptor ( Descriptor->Address64.AddressLength, Descriptor->Address64.Granularity, Descriptor->Address64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -282,9 +280,7 @@ RsDoQwordIoDescriptor ( * * FUNCTION: RsDoQwordMemoryDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -294,8 +290,7 @@ RsDoQwordIoDescriptor ( ASL_RESOURCE_NODE * RsDoQwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -307,12 +302,14 @@ RsDoQwordMemoryDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); @@ -465,7 +462,7 @@ RsDoQwordMemoryDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; @@ -500,10 +497,10 @@ RsDoQwordMemoryDescriptor ( Descriptor->Address64.AddressLength, Descriptor->Address64.Granularity, Descriptor->Address64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -512,9 +509,7 @@ RsDoQwordMemoryDescriptor ( * * FUNCTION: RsDoQwordSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -524,8 +519,7 @@ RsDoQwordMemoryDescriptor ( ASL_RESOURCE_NODE * RsDoQwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -537,12 +531,14 @@ RsDoQwordSpaceDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); @@ -692,7 +688,7 @@ RsDoQwordSpaceDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -712,9 +708,9 @@ RsDoQwordSpaceDescriptor ( Descriptor->Address64.AddressLength, Descriptor->Address64.Granularity, Descriptor->Address64.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2s.c b/sys/contrib/dev/acpica/compiler/aslrestype2s.c index 96be2ad1842e..2be295b6e4e1 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2s.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2s.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -268,9 +267,7 @@ RsGetVendorData ( * * FUNCTION: RsDoGpioIntDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -280,8 +277,7 @@ RsGetVendorData ( ASL_RESOURCE_NODE * RsDoGpioIntDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -289,14 +285,18 @@ RsDoGpioIntDescriptor ( char *ResourceSource = NULL; UINT8 *VendorData = NULL; UINT16 *InterruptList = NULL; + UINT16 *PinList = NULL; UINT16 ResSourceLength; UINT16 VendorLength; UINT16 InterruptLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; + UINT32 PinCount = 0; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -324,6 +324,7 @@ RsDoGpioIntDescriptor ( /* Build pointers to optional areas */ InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + PinList = InterruptList; ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); @@ -407,7 +408,7 @@ RsDoGpioIntDescriptor ( case 8: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -438,6 +439,7 @@ RsDoGpioIntDescriptor ( */ *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; InterruptList++; + PinCount++; /* Case 10: First interrupt number in list */ @@ -466,6 +468,7 @@ RsDoGpioIntDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); return (Rnode); } @@ -474,9 +477,7 @@ RsDoGpioIntDescriptor ( * * FUNCTION: RsDoGpioIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -486,8 +487,7 @@ RsDoGpioIntDescriptor ( ASL_RESOURCE_NODE * RsDoGpioIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -495,14 +495,18 @@ RsDoGpioIoDescriptor ( char *ResourceSource = NULL; UINT8 *VendorData = NULL; UINT16 *InterruptList = NULL; + UINT16 *PinList = NULL; UINT16 ResSourceLength; UINT16 VendorLength; UINT16 InterruptLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; + UINT32 PinCount = 0; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -513,6 +517,7 @@ RsDoGpioIoDescriptor ( ResSourceLength = RsGetStringDataLength (InitializerOp); VendorLength = RsGetBufferDataLength (InitializerOp); InterruptLength = RsGetInterruptDataLength (InitializerOp); + PinList = InterruptList; DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) + ResSourceLength + VendorLength + InterruptLength; @@ -530,6 +535,7 @@ RsDoGpioIoDescriptor ( /* Build pointers to optional areas */ InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + PinList = InterruptList; ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); @@ -613,7 +619,7 @@ RsDoGpioIoDescriptor ( case 8: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -643,6 +649,7 @@ RsDoGpioIoDescriptor ( */ *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; InterruptList++; + PinCount++; /* Case 10: First interrupt number in list */ @@ -671,6 +678,7 @@ RsDoGpioIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveGpioInfo (Info->MappingOp, Descriptor, PinCount, PinList, ResourceSource); return (Rnode); } @@ -679,9 +687,7 @@ RsDoGpioIoDescriptor ( * * FUNCTION: RsDoI2cSerialBusDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -691,8 +697,7 @@ RsDoGpioIoDescriptor ( ASL_RESOURCE_NODE * RsDoI2cSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -702,10 +707,12 @@ RsDoI2cSerialBusDescriptor ( UINT16 ResSourceLength; UINT16 VendorLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -801,7 +808,7 @@ RsDoI2cSerialBusDescriptor ( case 7: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -818,6 +825,7 @@ RsDoI2cSerialBusDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource); return (Rnode); } @@ -826,9 +834,7 @@ RsDoI2cSerialBusDescriptor ( * * FUNCTION: RsDoSpiSerialBusDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -838,8 +844,7 @@ RsDoI2cSerialBusDescriptor ( ASL_RESOURCE_NODE * RsDoSpiSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -849,10 +854,12 @@ RsDoSpiSerialBusDescriptor ( UINT16 ResSourceLength; UINT16 VendorLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -976,7 +983,7 @@ RsDoSpiSerialBusDescriptor ( case 11: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -993,6 +1000,7 @@ RsDoSpiSerialBusDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource); return (Rnode); } @@ -1001,9 +1009,7 @@ RsDoSpiSerialBusDescriptor ( * * FUNCTION: RsDoUartSerialBusDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -1013,8 +1019,7 @@ RsDoSpiSerialBusDescriptor ( ASL_RESOURCE_NODE * RsDoUartSerialBusDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -1024,10 +1029,12 @@ RsDoUartSerialBusDescriptor ( UINT16 ResSourceLength; UINT16 VendorLength; UINT16 DescriptorSize; + UINT32 CurrentByteOffset; UINT32 i; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; /* * Calculate lengths for fields that have variable length: @@ -1168,7 +1175,7 @@ RsDoUartSerialBusDescriptor ( case 12: /* Resource Tag (Descriptor Name) */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ @@ -1185,5 +1192,6 @@ RsDoUartSerialBusDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource); return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/compiler/aslrestype2w.c index be388b753bc6..34c3e1e4515a 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2w.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2w.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -60,9 +59,7 @@ * * FUNCTION: RsDoWordIoDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -72,8 +69,7 @@ ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -85,12 +81,14 @@ RsDoWordIoDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); @@ -236,7 +234,7 @@ RsDoWordIoDescriptor ( case 12: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; case 13: /* Type */ @@ -270,10 +268,10 @@ RsDoWordIoDescriptor ( (UINT64) Descriptor->Address16.AddressLength, (UINT64) Descriptor->Address16.Granularity, Descriptor->Address16.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -282,9 +280,7 @@ RsDoWordIoDescriptor ( * * FUNCTION: RsDoWordBusNumberDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -294,8 +290,7 @@ RsDoWordIoDescriptor ( ASL_RESOURCE_NODE * RsDoWordBusNumberDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -307,12 +302,14 @@ RsDoWordBusNumberDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); @@ -456,7 +453,7 @@ RsDoWordBusNumberDescriptor ( case 11: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -476,10 +473,10 @@ RsDoWordBusNumberDescriptor ( (UINT64) Descriptor->Address16.AddressLength, (UINT64) Descriptor->Address16.Granularity, Descriptor->Address16.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } @@ -488,9 +485,7 @@ RsDoWordBusNumberDescriptor ( * * FUNCTION: RsDoWordSpaceDescriptor * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) + * PARAMETERS: Info - Parse Op and resource template offset * * RETURN: Completed resource node * @@ -500,8 +495,7 @@ RsDoWordBusNumberDescriptor ( ASL_RESOURCE_NODE * RsDoWordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) + ASL_RESOURCE_INFO *Info) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; @@ -513,12 +507,14 @@ RsDoWordSpaceDescriptor ( UINT8 *OptionalFields; UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT32 CurrentByteOffset; UINT32 i; BOOLEAN ResSourceIndex = FALSE; - InitializerOp = Op->Asl.Child; + InitializerOp = Info->DescriptorTypeOp->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); + CurrentByteOffset = Info->CurrentByteOffset; Rnode = RsAllocateResourceNode ( sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); @@ -673,7 +669,7 @@ RsDoWordSpaceDescriptor ( case 13: /* ResourceTag */ - UtAttachNamepathToOwner (Op, InitializerOp); + UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp); break; default: @@ -693,9 +689,9 @@ RsDoWordSpaceDescriptor ( (UINT64) Descriptor->Address16.AddressLength, (UINT64) Descriptor->Address16.Granularity, Descriptor->Address16.Flags, - MinOp, MaxOp, LengthOp, GranOp, Op); + MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp); Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; + OptionIndex + StringLength; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.y b/sys/contrib/dev/acpica/compiler/aslrules.y similarity index 82% rename from sys/contrib/dev/acpica/compiler/aslcompiler.y rename to sys/contrib/dev/acpica/compiler/aslrules.y index 42ff850ff409..2bc48db11f6a 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.y +++ b/sys/contrib/dev/acpica/compiler/aslrules.y @@ -1,12 +1,12 @@ -%{ +NoEcho(' /****************************************************************************** * - * Module Name: aslcompiler.y - Bison/Yacc input file (ASL grammar and actions) + * Module Name: aslrules.y - Bison/Yacc production rules * *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,755 +42,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include -#include -#include -#include -#include -#include +') -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslparse") - -/* - * Global Notes: - * - * October 2005: The following list terms have been optimized (from the - * original ASL grammar in the ACPI specification) to force the immediate - * reduction of each list item so that the parse stack use doesn't increase on - * each list element and possibly overflow on very large lists (>4000 items). - * This dramatically reduces use of the parse stack overall. - * - * ArgList, TermList, Objectlist, ByteList, DWordList, PackageList, - * ResourceMacroList, and FieldUnitList - */ - -void * AslLocalAllocate (unsigned int Size); - -/* Bison/yacc configuration */ - -#define static -#undef alloca -#define alloca AslLocalAllocate -#define yytname AslCompilername - -#define YYINITDEPTH 600 /* State stack depth */ -#define YYDEBUG 1 /* Enable debug output */ -#define YYERROR_VERBOSE 1 /* Verbose error messages */ - -/* Define YYMALLOC/YYFREE to prevent redefinition errors */ - -#define YYMALLOC malloc -#define YYFREE free - -/* - * The windows version of bison defines this incorrectly as "32768" (Not negative). - * We use a custom (edited binary) version of bison that defines YYFLAG as YYFBAD - * instead (#define YYFBAD 32768), so we can define it correctly here. - * - * The problem is that if YYFLAG is positive, the extended syntax error messages - * are disabled. - */ -#define YYFLAG -32768 - -%} - -/* - * Declare the type of values in the grammar - */ -%union { - UINT64 i; - char *s; - ACPI_PARSE_OBJECT *n; -} - -/*! [Begin] no source code translation */ - -/* - * These shift/reduce conflicts are expected. There should be zero - * reduce/reduce conflicts. - */ -%expect 86 - -/****************************************************************************** - * - * Token types: These are returned by the lexer - * - * NOTE: This list MUST match the AslKeywordMapping table found - * in aslmap.c EXACTLY! Double check any changes! - * - *****************************************************************************/ - -%token PARSEOP_ACCESSAS -%token PARSEOP_ACCESSATTRIB_BLOCK -%token PARSEOP_ACCESSATTRIB_BLOCK_CALL -%token PARSEOP_ACCESSATTRIB_BYTE -%token PARSEOP_ACCESSATTRIB_MULTIBYTE -%token PARSEOP_ACCESSATTRIB_QUICK -%token PARSEOP_ACCESSATTRIB_RAW_BYTES -%token PARSEOP_ACCESSATTRIB_RAW_PROCESS -%token PARSEOP_ACCESSATTRIB_SND_RCV -%token PARSEOP_ACCESSATTRIB_WORD -%token PARSEOP_ACCESSATTRIB_WORD_CALL -%token PARSEOP_ACCESSTYPE_ANY -%token PARSEOP_ACCESSTYPE_BUF -%token PARSEOP_ACCESSTYPE_BYTE -%token PARSEOP_ACCESSTYPE_DWORD -%token PARSEOP_ACCESSTYPE_QWORD -%token PARSEOP_ACCESSTYPE_WORD -%token PARSEOP_ACQUIRE -%token PARSEOP_ADD -%token PARSEOP_ADDRESSINGMODE_7BIT -%token PARSEOP_ADDRESSINGMODE_10BIT -%token PARSEOP_ADDRESSTYPE_ACPI -%token PARSEOP_ADDRESSTYPE_MEMORY -%token PARSEOP_ADDRESSTYPE_NVS -%token PARSEOP_ADDRESSTYPE_RESERVED -%token PARSEOP_ALIAS -%token PARSEOP_AND -%token PARSEOP_ARG0 -%token PARSEOP_ARG1 -%token PARSEOP_ARG2 -%token PARSEOP_ARG3 -%token PARSEOP_ARG4 -%token PARSEOP_ARG5 -%token PARSEOP_ARG6 -%token PARSEOP_BANKFIELD -%token PARSEOP_BITSPERBYTE_EIGHT -%token PARSEOP_BITSPERBYTE_FIVE -%token PARSEOP_BITSPERBYTE_NINE -%token PARSEOP_BITSPERBYTE_SEVEN -%token PARSEOP_BITSPERBYTE_SIX -%token PARSEOP_BREAK -%token PARSEOP_BREAKPOINT -%token PARSEOP_BUFFER -%token PARSEOP_BUSMASTERTYPE_MASTER -%token PARSEOP_BUSMASTERTYPE_NOTMASTER -%token PARSEOP_BYTECONST -%token PARSEOP_CASE -%token PARSEOP_CLOCKPHASE_FIRST -%token PARSEOP_CLOCKPHASE_SECOND -%token PARSEOP_CLOCKPOLARITY_HIGH -%token PARSEOP_CLOCKPOLARITY_LOW -%token PARSEOP_CONCATENATE -%token PARSEOP_CONCATENATERESTEMPLATE -%token PARSEOP_CONDREFOF -%token PARSEOP_CONNECTION -%token PARSEOP_CONTINUE -%token PARSEOP_COPYOBJECT -%token PARSEOP_CREATEBITFIELD -%token PARSEOP_CREATEBYTEFIELD -%token PARSEOP_CREATEDWORDFIELD -%token PARSEOP_CREATEFIELD -%token PARSEOP_CREATEQWORDFIELD -%token PARSEOP_CREATEWORDFIELD -%token PARSEOP_DATABUFFER -%token PARSEOP_DATATABLEREGION -%token PARSEOP_DEBUG -%token PARSEOP_DECODETYPE_POS -%token PARSEOP_DECODETYPE_SUB -%token PARSEOP_DECREMENT -%token PARSEOP_DEFAULT -%token PARSEOP_DEFAULT_ARG -%token PARSEOP_DEFINITIONBLOCK -%token PARSEOP_DEREFOF -%token PARSEOP_DEVICE -%token PARSEOP_DEVICEPOLARITY_HIGH -%token PARSEOP_DEVICEPOLARITY_LOW -%token PARSEOP_DIVIDE -%token PARSEOP_DMA -%token PARSEOP_DMATYPE_A -%token PARSEOP_DMATYPE_COMPATIBILITY -%token PARSEOP_DMATYPE_B -%token PARSEOP_DMATYPE_F -%token PARSEOP_DWORDCONST -%token PARSEOP_DWORDIO -%token PARSEOP_DWORDMEMORY -%token PARSEOP_DWORDSPACE -%token PARSEOP_EISAID -%token PARSEOP_ELSE -%token PARSEOP_ELSEIF -%token PARSEOP_ENDDEPENDENTFN -%token PARSEOP_ENDIAN_BIG -%token PARSEOP_ENDIAN_LITTLE -%token PARSEOP_ENDTAG -%token PARSEOP_ERRORNODE -%token PARSEOP_EVENT -%token PARSEOP_EXTENDEDIO -%token PARSEOP_EXTENDEDMEMORY -%token PARSEOP_EXTENDEDSPACE -%token PARSEOP_EXTERNAL -%token PARSEOP_FATAL -%token PARSEOP_FIELD -%token PARSEOP_FINDSETLEFTBIT -%token PARSEOP_FINDSETRIGHTBIT -%token PARSEOP_FIXEDDMA -%token PARSEOP_FIXEDIO -%token PARSEOP_FLOWCONTROL_HW -%token PARSEOP_FLOWCONTROL_NONE -%token PARSEOP_FLOWCONTROL_SW -%token PARSEOP_FROMBCD -%token PARSEOP_FUNCTION -%token PARSEOP_GPIO_INT -%token PARSEOP_GPIO_IO -%token PARSEOP_I2C_SERIALBUS -%token PARSEOP_IF -%token PARSEOP_INCLUDE -%token PARSEOP_INCLUDE_END -%token PARSEOP_INCREMENT -%token PARSEOP_INDEX -%token PARSEOP_INDEXFIELD -%token PARSEOP_INTEGER -%token PARSEOP_INTERRUPT -%token PARSEOP_INTLEVEL_ACTIVEBOTH -%token PARSEOP_INTLEVEL_ACTIVEHIGH -%token PARSEOP_INTLEVEL_ACTIVELOW -%token PARSEOP_INTTYPE_EDGE -%token PARSEOP_INTTYPE_LEVEL -%token PARSEOP_IO -%token PARSEOP_IODECODETYPE_10 -%token PARSEOP_IODECODETYPE_16 -%token PARSEOP_IORESTRICT_IN -%token PARSEOP_IORESTRICT_NONE -%token PARSEOP_IORESTRICT_OUT -%token PARSEOP_IORESTRICT_PRESERVE -%token PARSEOP_IRQ -%token PARSEOP_IRQNOFLAGS -%token PARSEOP_LAND -%token PARSEOP_LEQUAL -%token PARSEOP_LGREATER -%token PARSEOP_LGREATEREQUAL -%token PARSEOP_LLESS -%token PARSEOP_LLESSEQUAL -%token PARSEOP_LNOT -%token PARSEOP_LNOTEQUAL -%token PARSEOP_LOAD -%token PARSEOP_LOADTABLE -%token PARSEOP_LOCAL0 -%token PARSEOP_LOCAL1 -%token PARSEOP_LOCAL2 -%token PARSEOP_LOCAL3 -%token PARSEOP_LOCAL4 -%token PARSEOP_LOCAL5 -%token PARSEOP_LOCAL6 -%token PARSEOP_LOCAL7 -%token PARSEOP_LOCKRULE_LOCK -%token PARSEOP_LOCKRULE_NOLOCK -%token PARSEOP_LOR -%token PARSEOP_MATCH -%token PARSEOP_MATCHTYPE_MEQ -%token PARSEOP_MATCHTYPE_MGE -%token PARSEOP_MATCHTYPE_MGT -%token PARSEOP_MATCHTYPE_MLE -%token PARSEOP_MATCHTYPE_MLT -%token PARSEOP_MATCHTYPE_MTR -%token PARSEOP_MAXTYPE_FIXED -%token PARSEOP_MAXTYPE_NOTFIXED -%token PARSEOP_MEMORY24 -%token PARSEOP_MEMORY32 -%token PARSEOP_MEMORY32FIXED -%token PARSEOP_MEMTYPE_CACHEABLE -%token PARSEOP_MEMTYPE_NONCACHEABLE -%token PARSEOP_MEMTYPE_PREFETCHABLE -%token PARSEOP_MEMTYPE_WRITECOMBINING -%token PARSEOP_METHOD -%token PARSEOP_METHODCALL -%token PARSEOP_MID -%token PARSEOP_MINTYPE_FIXED -%token PARSEOP_MINTYPE_NOTFIXED -%token PARSEOP_MOD -%token PARSEOP_MULTIPLY -%token PARSEOP_MUTEX -%token PARSEOP_NAME -%token PARSEOP_NAMESEG -%token PARSEOP_NAMESTRING -%token PARSEOP_NAND -%token PARSEOP_NOOP -%token PARSEOP_NOR -%token PARSEOP_NOT -%token PARSEOP_NOTIFY -%token PARSEOP_OBJECTTYPE -%token PARSEOP_OBJECTTYPE_BFF -%token PARSEOP_OBJECTTYPE_BUF -%token PARSEOP_OBJECTTYPE_DDB -%token PARSEOP_OBJECTTYPE_DEV -%token PARSEOP_OBJECTTYPE_EVT -%token PARSEOP_OBJECTTYPE_FLD -%token PARSEOP_OBJECTTYPE_INT -%token PARSEOP_OBJECTTYPE_MTH -%token PARSEOP_OBJECTTYPE_MTX -%token PARSEOP_OBJECTTYPE_OPR -%token PARSEOP_OBJECTTYPE_PKG -%token PARSEOP_OBJECTTYPE_POW -%token PARSEOP_OBJECTTYPE_PRO -%token PARSEOP_OBJECTTYPE_STR -%token PARSEOP_OBJECTTYPE_THZ -%token PARSEOP_OBJECTTYPE_UNK -%token PARSEOP_OFFSET -%token PARSEOP_ONE -%token PARSEOP_ONES -%token PARSEOP_OPERATIONREGION -%token PARSEOP_OR -%token PARSEOP_PACKAGE -%token PARSEOP_PACKAGE_LENGTH -%token PARSEOP_PARITYTYPE_EVEN -%token PARSEOP_PARITYTYPE_MARK -%token PARSEOP_PARITYTYPE_NONE -%token PARSEOP_PARITYTYPE_ODD -%token PARSEOP_PARITYTYPE_SPACE -%token PARSEOP_PIN_NOPULL -%token PARSEOP_PIN_PULLDEFAULT -%token PARSEOP_PIN_PULLDOWN -%token PARSEOP_PIN_PULLUP -%token PARSEOP_POWERRESOURCE -%token PARSEOP_PROCESSOR -%token PARSEOP_QWORDCONST -%token PARSEOP_QWORDIO -%token PARSEOP_QWORDMEMORY -%token PARSEOP_QWORDSPACE -%token PARSEOP_RANGETYPE_ENTIRE -%token PARSEOP_RANGETYPE_ISAONLY -%token PARSEOP_RANGETYPE_NONISAONLY -%token PARSEOP_RAW_DATA -%token PARSEOP_READWRITETYPE_BOTH -%token PARSEOP_READWRITETYPE_READONLY -%token PARSEOP_REFOF -%token PARSEOP_REGIONSPACE_CMOS -%token PARSEOP_REGIONSPACE_EC -%token PARSEOP_REGIONSPACE_FFIXEDHW -%token PARSEOP_REGIONSPACE_GPIO -%token PARSEOP_REGIONSPACE_GSBUS -%token PARSEOP_REGIONSPACE_IO -%token PARSEOP_REGIONSPACE_IPMI -%token PARSEOP_REGIONSPACE_MEM -%token PARSEOP_REGIONSPACE_PCC -%token PARSEOP_REGIONSPACE_PCI -%token PARSEOP_REGIONSPACE_PCIBAR -%token PARSEOP_REGIONSPACE_SMBUS -%token PARSEOP_REGISTER -%token PARSEOP_RELEASE -%token PARSEOP_RESERVED_BYTES -%token PARSEOP_RESET -%token PARSEOP_RESOURCETEMPLATE -%token PARSEOP_RESOURCETYPE_CONSUMER -%token PARSEOP_RESOURCETYPE_PRODUCER -%token PARSEOP_RETURN -%token PARSEOP_REVISION -%token PARSEOP_SCOPE -%token PARSEOP_SERIALIZERULE_NOTSERIAL -%token PARSEOP_SERIALIZERULE_SERIAL -%token PARSEOP_SHARETYPE_EXCLUSIVE -%token PARSEOP_SHARETYPE_EXCLUSIVEWAKE -%token PARSEOP_SHARETYPE_SHARED -%token PARSEOP_SHARETYPE_SHAREDWAKE -%token PARSEOP_SHIFTLEFT -%token PARSEOP_SHIFTRIGHT -%token PARSEOP_SIGNAL -%token PARSEOP_SIZEOF -%token PARSEOP_SLAVEMODE_CONTROLLERINIT -%token PARSEOP_SLAVEMODE_DEVICEINIT -%token PARSEOP_SLEEP -%token PARSEOP_SPI_SERIALBUS -%token PARSEOP_STALL -%token PARSEOP_STARTDEPENDENTFN -%token PARSEOP_STARTDEPENDENTFN_NOPRI -%token PARSEOP_STOPBITS_ONE -%token PARSEOP_STOPBITS_ONEPLUSHALF -%token PARSEOP_STOPBITS_TWO -%token PARSEOP_STOPBITS_ZERO -%token PARSEOP_STORE -%token PARSEOP_STRING_LITERAL -%token PARSEOP_SUBTRACT -%token PARSEOP_SWITCH -%token PARSEOP_THERMALZONE -%token PARSEOP_TIMER -%token PARSEOP_TOBCD -%token PARSEOP_TOBUFFER -%token PARSEOP_TODECIMALSTRING -%token PARSEOP_TOHEXSTRING -%token PARSEOP_TOINTEGER -%token PARSEOP_TOSTRING -%token PARSEOP_TOUUID -%token PARSEOP_TRANSLATIONTYPE_DENSE -%token PARSEOP_TRANSLATIONTYPE_SPARSE -%token PARSEOP_TYPE_STATIC -%token PARSEOP_TYPE_TRANSLATION -%token PARSEOP_UART_SERIALBUS -%token PARSEOP_UNICODE -%token PARSEOP_UNLOAD -%token PARSEOP_UPDATERULE_ONES -%token PARSEOP_UPDATERULE_PRESERVE -%token PARSEOP_UPDATERULE_ZEROS -%token PARSEOP_VAR_PACKAGE -%token PARSEOP_VENDORLONG -%token PARSEOP_VENDORSHORT -%token PARSEOP_WAIT -%token PARSEOP_WHILE -%token PARSEOP_WIREMODE_FOUR -%token PARSEOP_WIREMODE_THREE -%token PARSEOP_WORDBUSNUMBER -%token PARSEOP_WORDCONST -%token PARSEOP_WORDIO -%token PARSEOP_WORDSPACE -%token PARSEOP_XFERSIZE_8 -%token PARSEOP_XFERSIZE_16 -%token PARSEOP_XFERSIZE_32 -%token PARSEOP_XFERSIZE_64 -%token PARSEOP_XFERSIZE_128 -%token PARSEOP_XFERSIZE_256 -%token PARSEOP_XFERTYPE_8 -%token PARSEOP_XFERTYPE_8_16 -%token PARSEOP_XFERTYPE_16 -%token PARSEOP_XOR -%token PARSEOP_ZERO - -/* - * Special functions. These should probably stay at the end of this - * table. - */ -%token PARSEOP___DATE__ -%token PARSEOP___FILE__ -%token PARSEOP___LINE__ -%token PARSEOP___PATH__ - - -/****************************************************************************** - * - * Production names - * - *****************************************************************************/ - -%type ArgList -%type ASLCode -%type BufferData -%type BufferTermData -%type CompilerDirective -%type DataObject -%type DefinitionBlockTerm -%type IntegerData -%type NamedObject -%type NameSpaceModifier -%type Object -%type ObjectList -%type PackageData -%type ParameterTypePackage -%type ParameterTypePackageList -%type ParameterTypesPackage -%type ParameterTypesPackageList -%type RequiredTarget -%type SimpleTarget -%type StringData -%type Target -%type Term -%type TermArg -%type TermList -%type UserTerm - -/* Type4Opcode is obsolete */ - -%type Type1Opcode -%type Type2BufferOpcode -%type Type2BufferOrStringOpcode -%type Type2IntegerOpcode -%type Type2Opcode -%type Type2StringOpcode -%type Type3Opcode -%type Type5Opcode -%type Type6Opcode - -%type AccessAsTerm -%type ExternalTerm -%type FieldUnit -%type FieldUnitEntry -%type FieldUnitList -%type IncludeTerm -%type OffsetTerm -%type OptionalAccessAttribTerm - -/* Named Objects */ - -%type BankFieldTerm -%type CreateBitFieldTerm -%type CreateByteFieldTerm -%type CreateDWordFieldTerm -%type CreateFieldTerm -%type CreateQWordFieldTerm -%type CreateWordFieldTerm -%type DataRegionTerm -%type DeviceTerm -%type EventTerm -%type FieldTerm -%type FunctionTerm -%type IndexFieldTerm -%type MethodTerm -%type MutexTerm -%type OpRegionTerm -%type OpRegionSpaceIdTerm -%type PowerResTerm -%type ProcessorTerm -%type ThermalZoneTerm - -/* Namespace modifiers */ - -%type AliasTerm -%type NameTerm -%type ScopeTerm - -/* Type 1 opcodes */ - -%type BreakPointTerm -%type BreakTerm -%type CaseDefaultTermList -%type CaseTerm -%type ContinueTerm -%type DefaultTerm -%type ElseTerm -%type FatalTerm -%type IfElseTerm -%type IfTerm -%type LoadTerm -%type NoOpTerm -%type NotifyTerm -%type ReleaseTerm -%type ResetTerm -%type ReturnTerm -%type SignalTerm -%type SleepTerm -%type StallTerm -%type SwitchTerm -%type UnloadTerm -%type WhileTerm -/* %type CaseTermList */ - -/* Type 2 opcodes */ - -%type AcquireTerm -%type AddTerm -%type AndTerm -%type ConcatResTerm -%type ConcatTerm -%type CondRefOfTerm -%type CopyObjectTerm -%type DecTerm -%type DerefOfTerm -%type DivideTerm -%type FindSetLeftBitTerm -%type FindSetRightBitTerm -%type FromBCDTerm -%type IncTerm -%type IndexTerm -%type LAndTerm -%type LEqualTerm -%type LGreaterEqualTerm -%type LGreaterTerm -%type LLessEqualTerm -%type LLessTerm -%type LNotEqualTerm -%type LNotTerm -%type LoadTableTerm -%type LOrTerm -%type MatchTerm -%type MidTerm -%type ModTerm -%type MultiplyTerm -%type NAndTerm -%type NOrTerm -%type NotTerm -%type ObjectTypeTerm -%type OrTerm -%type RefOfTerm -%type ShiftLeftTerm -%type ShiftRightTerm -%type SizeOfTerm -%type StoreTerm -%type SubtractTerm -%type TimerTerm -%type ToBCDTerm -%type ToBufferTerm -%type ToDecimalStringTerm -%type ToHexStringTerm -%type ToIntegerTerm -%type ToStringTerm -%type WaitTerm -%type XOrTerm - -/* Keywords */ - -%type AccessAttribKeyword -%type AccessTypeKeyword -%type AddressingModeKeyword -%type AddressKeyword -%type AddressSpaceKeyword -%type BitsPerByteKeyword -%type ClockPhaseKeyword -%type ClockPolarityKeyword -%type DecodeKeyword -%type DevicePolarityKeyword -%type DMATypeKeyword -%type EndianKeyword -%type FlowControlKeyword -%type InterruptLevel -%type InterruptTypeKeyword -%type IODecodeKeyword -%type IoRestrictionKeyword -%type LockRuleKeyword -%type MatchOpKeyword -%type MaxKeyword -%type MemTypeKeyword -%type MinKeyword -%type ObjectTypeKeyword -%type OptionalBusMasterKeyword -%type OptionalReadWriteKeyword -%type ParityTypeKeyword -%type PinConfigByte -%type PinConfigKeyword -%type RangeTypeKeyword -%type RegionSpaceKeyword -%type ResourceTypeKeyword -%type SerializeRuleKeyword -%type ShareTypeKeyword -%type SlaveModeKeyword -%type StopBitsKeyword -%type TranslationKeyword -%type TypeKeyword -%type UpdateRuleKeyword -%type WireModeKeyword -%type XferSizeKeyword -%type XferTypeKeyword - -/* Types */ - -%type SuperName -%type ObjectTypeName -%type ArgTerm -%type LocalTerm -%type DebugTerm - -%type Integer -%type ByteConst -%type WordConst -%type DWordConst -%type QWordConst -%type String - -%type ConstTerm -%type ConstExprTerm -%type ByteConstExpr -%type WordConstExpr -%type DWordConstExpr -%type QWordConstExpr - -%type DWordList -%type BufferTerm -%type ByteList - -%type PackageElement -%type PackageList -%type PackageTerm -%type VarPackageLengthTerm - -/* Macros */ - -%type EISAIDTerm -%type ResourceMacroList -%type ResourceMacroTerm -%type ResourceTemplateTerm -%type ToUUIDTerm -%type UnicodeTerm - -/* Resource Descriptors */ - -%type ConnectionTerm -%type DataBufferTerm -%type DMATerm -%type DWordIOTerm -%type DWordMemoryTerm -%type DWordSpaceTerm -%type EndDependentFnTerm -%type ExtendedIOTerm -%type ExtendedMemoryTerm -%type ExtendedSpaceTerm -%type FixedDmaTerm -%type FixedIOTerm -%type GpioIntTerm -%type GpioIoTerm -%type I2cSerialBusTerm -%type InterruptTerm -%type IOTerm -%type IRQNoFlagsTerm -%type IRQTerm -%type Memory24Term -%type Memory32FixedTerm -%type Memory32Term -%type NameSeg -%type NameString -%type QWordIOTerm -%type QWordMemoryTerm -%type QWordSpaceTerm -%type RegisterTerm -%type SpiSerialBusTerm -%type StartDependentFnNoPriTerm -%type StartDependentFnTerm -%type UartSerialBusTerm -%type VendorLongTerm -%type VendorShortTerm -%type WordBusNumberTerm -%type WordIOTerm -%type WordSpaceTerm - -/* Local types that help construct the AML, not in ACPI spec */ - -%type AmlPackageLengthTerm -%type IncludeEndTerm -%type NameStringItem -%type TermArgItem - -%type OptionalAccessSize -%type OptionalAddressingMode -%type OptionalAddressRange -%type OptionalBitsPerByte -%type OptionalBuffer_Last -%type OptionalByteConstExpr -%type OptionalCount -%type OptionalDecodeType -%type OptionalDevicePolarity -%type OptionalDWordConstExpr -%type OptionalEndian -%type OptionalFlowControl -%type OptionalIoRestriction -%type OptionalListString -%type OptionalMaxType -%type OptionalMemType -%type OptionalMinType -%type OptionalNameString -%type OptionalNameString_First -%type OptionalNameString_Last -%type OptionalObjectTypeKeyword -%type OptionalParameterTypePackage -%type OptionalParameterTypesPackage -%type OptionalParityType -%type OptionalQWordConstExpr -%type OptionalRangeType -%type OptionalReference -%type OptionalResourceType -%type OptionalResourceType_First -%type OptionalReturnArg -%type OptionalSerializeRuleKeyword -%type OptionalShareType -%type OptionalShareType_First -%type OptionalSlaveMode -%type OptionalStopBits -%type OptionalStringData -%type OptionalTermArg -%type OptionalTranslationType_Last -%type OptionalType -%type OptionalType_Last -%type OptionalWireMode -%type OptionalWordConst -%type OptionalWordConstExpr -%type OptionalXferSize - -%% /******************************************************************************* * * Production rules start here @@ -799,10 +52,7 @@ void * AslLocalAllocate (unsigned int Size); /* * ASL Names - */ - - -/* + * * Root rule. Allow multiple #line directives before the definition block * to handle output from preprocessors */ @@ -3511,77 +2761,3 @@ OptionalXferSize | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);} | ',' XferSizeKeyword {$$ = $2;} ; - -%% -/****************************************************************************** - * - * Local support functions - * - *****************************************************************************/ - -int -AslCompilerwrap(void) -{ - return (1); -} - -/*! [End] no source code translation !*/ - -void * -AslLocalAllocate (unsigned int Size) -{ - void *Mem; - - - DbgPrint (ASL_PARSE_OUTPUT, "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); - - Mem = ACPI_ALLOCATE_ZEROED (Size); - if (!Mem) - { - AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_InputByteCount, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); - exit (1); - } - - return (Mem); -} - -ACPI_PARSE_OBJECT * -AslDoError (void) -{ - - - return (TrCreateLeafNode (PARSEOP_ERRORNODE)); - -} - - -/******************************************************************************* - * - * FUNCTION: UtGetOpName - * - * PARAMETERS: ParseOpcode - Parser keyword ID - * - * RETURN: Pointer to the opcode name - * - * DESCRIPTION: Get the ascii name of the parse opcode - * - ******************************************************************************/ - -char * -UtGetOpName ( - UINT32 ParseOpcode) -{ -#ifdef ASL_YYTNAME_START - /* - * First entries (ASL_YYTNAME_START) in yytname are special reserved names. - * Ignore first 8 characters of the name - */ - return ((char *) yytname - [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); -#else - return ("[Unknown parser generator]"); -#endif -} diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c index e50b103c7253..56603be4c3cf 100644 --- a/sys/contrib/dev/acpica/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica/compiler/aslstartup.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -51,18 +50,8 @@ ACPI_MODULE_NAME ("aslstartup") -#define ASL_MAX_FILES 256 -static char *FileList[ASL_MAX_FILES]; -static BOOLEAN AslToFile = TRUE; - - /* Local prototypes */ -static char ** -AsDoWildcard ( - char *DirectoryPathname, - char *FileSpecifier); - static UINT8 AslDetectSourceFileType ( ASL_FILE_INFO *Info); @@ -72,6 +61,11 @@ AslDoDisassembly ( void); +/* Globals */ + +static BOOLEAN AslToFile = TRUE; + + /******************************************************************************* * * FUNCTION: AslInitializeGlobals @@ -131,82 +125,6 @@ AslInitializeGlobals ( } -/****************************************************************************** - * - * FUNCTION: AsDoWildcard - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Process files via wildcards. This function is for the Windows - * case only. - * - ******************************************************************************/ - -static char ** -AsDoWildcard ( - char *DirectoryPathname, - char *FileSpecifier) -{ -#ifdef WIN32 - void *DirInfo; - char *Filename; - int FileCount; - - - FileCount = 0; - - /* Open parent directory */ - - DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY); - if (!DirInfo) - { - /* Either the directory of file does not exist */ - - Gbl_Files[ASL_FILE_INPUT].Filename = FileSpecifier; - FlFileError (ASL_FILE_INPUT, ASL_MSG_OPEN); - AslAbort (); - } - - /* Process each file that matches the wildcard specification */ - - while ((Filename = AcpiOsGetNextFilename (DirInfo))) - { - /* Add the filename to the file list */ - - FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); - strcpy (FileList[FileCount], Filename); - FileCount++; - - if (FileCount >= ASL_MAX_FILES) - { - printf ("Max files reached\n"); - FileList[0] = NULL; - return (FileList); - } - } - - /* Cleanup */ - - AcpiOsCloseDirectory (DirInfo); - FileList[FileCount] = NULL; - return (FileList); - -#else - /* - * Linux/Unix cases - Wildcards are expanded by the shell automatically. - * Just return the filename in a null terminated list - */ - FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); - strcpy (FileList[0], FileSpecifier); - FileList[1] = NULL; - - return (FileList); -#endif -} - - /******************************************************************************* * * FUNCTION: AslDetectSourceFileType @@ -332,7 +250,7 @@ AslDoDisassembly ( AcpiGbl_DbOpt_disasm = TRUE; Status = AdAmlDisassemble (AslToFile, Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix, - &Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_GetAllTables); + &Gbl_Files[ASL_FILE_INPUT].Filename); if (ACPI_FAILURE (Status)) { return (Status); @@ -365,8 +283,11 @@ AslDoDisassembly ( return (AE_CTRL_CONTINUE); } - ACPI_FREE (Gbl_Files[ASL_FILE_INPUT].Filename); + /* No need to free the filename string */ + Gbl_Files[ASL_FILE_INPUT].Filename = NULL; + + CmDeleteCaches (); return (AE_OK); } @@ -395,12 +316,29 @@ AslDoOneFile ( AslInitializeGlobals (); PrInitializeGlobals (); - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + /* + * Extract the directory path. This path is used for possible include + * files and the optional AML filename embedded in the input file + * DefinitionBlock declaration. + */ + Status = FlSplitInputPathname (Filename, &Gbl_DirectoryPath, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Take a copy of the input filename, convert any backslashes */ + + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + UtConvertBackslashes (Gbl_Files[ASL_FILE_INPUT].Filename); /* * AML Disassembly (Optional) */ - if (Gbl_DisasmFlag || Gbl_GetAllTables) + if (Gbl_DisasmFlag) { Status = AslDoDisassembly (); if (Status != AE_CTRL_CONTINUE) @@ -465,7 +403,6 @@ AslDoOneFile ( if (Gbl_Signature) { - ACPI_FREE (Gbl_Signature); Gbl_Signature = NULL; } @@ -541,77 +478,6 @@ AslDoOneFile ( } -/******************************************************************************* - * - * FUNCTION: AslDoOnePathname - * - * PARAMETERS: Pathname - Full pathname, possibly with wildcards - * - * RETURN: Status - * - * DESCRIPTION: Process one pathname, possible terminated with a wildcard - * specification. If a wildcard, it is expanded and the multiple - * files are processed. - * - ******************************************************************************/ - -ACPI_STATUS -AslDoOnePathname ( - char *Pathname, - ASL_PATHNAME_CALLBACK PathCallback) -{ - ACPI_STATUS Status = AE_OK; - char **WildcardList; - char *Filename; - char *FullPathname; - - - /* Split incoming path into a directory/filename combo */ - - Status = FlSplitInputPathname (Pathname, &Gbl_DirectoryPath, &Filename); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Expand possible wildcard into a file list (Windows/DOS only) */ - - WildcardList = AsDoWildcard (Gbl_DirectoryPath, Filename); - while (*WildcardList) - { - FullPathname = ACPI_ALLOCATE ( - strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1); - - /* Construct a full path to the file */ - - strcpy (FullPathname, Gbl_DirectoryPath); - strcat (FullPathname, *WildcardList); - - /* - * If -p not specified, we will use the input filename as the - * output filename prefix - */ - if (Gbl_UseDefaultAmlFilename) - { - Gbl_OutputFilenamePrefix = FullPathname; - } - - /* Save status from all compiles */ - - Status |= (*PathCallback) (FullPathname); - - ACPI_FREE (FullPathname); - ACPI_FREE (*WildcardList); - *WildcardList = NULL; - WildcardList++; - } - - ACPI_FREE (Gbl_DirectoryPath); - ACPI_FREE (Filename); - return (Status); -} - - /******************************************************************************* * * FUNCTION: AslCheckForErrorExit diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index 9ac96980e795..ff05d9ac064f 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,17 +53,10 @@ /* - * Stubs to simplify linkage to the ACPI CA core subsystem. + * Stubs to simplify linkage to the ACPICA core subsystem. * Things like Events, Global Lock, etc. are not used * by the compiler, so they are stubbed out here. */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void) -{ - return (0); -} - void AcpiNsExecModuleCodeList ( void) @@ -232,21 +225,3 @@ AcpiTbFindTable ( { return (AE_SUPPORT); } - -/* OSL interfaces */ - -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (0xFFFF); -} - -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); -} diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l index e7d2b1fac893..7ea43a07dba7 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.l +++ b/sys/contrib/dev/acpica/compiler/aslsupport.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* Configuration */ #define ASL_SPACES_PER_TAB 4 @@ -70,6 +69,15 @@ typedef struct asl_file_node ASL_FILE_NODE *Gbl_IncludeFileStack = NULL; +void +AslParserCleanup ( + void) +{ + + yy_delete_buffer (YY_CURRENT_BUFFER); +} + + /******************************************************************************* * * FUNCTION: AslDoLineDirective @@ -259,7 +267,11 @@ AslPushInputFileStack ( /* Reset the global line count and filename */ - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + Gbl_CurrentLineNumber = 1; yyin = InputFile; } @@ -797,7 +809,7 @@ CompletedString: */ *StringBuffer = 0; - CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); + CleanString = UtStringCacheCalloc (strlen (MsgBuffer) + 1); if (!CleanString) { AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.y b/sys/contrib/dev/acpica/compiler/aslsupport.y new file mode 100644 index 000000000000..dfeca6e9b309 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslsupport.y @@ -0,0 +1,120 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: aslsupport.y - Bison/Yacc C support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/****************************************************************************** + * + * Local support functions + * + *****************************************************************************/ + +/*! [Begin] no source code translation */ +int +AslCompilerwrap(void) +{ + return (1); +} +/*! [End] no source code translation !*/ + + +void * +AslLocalAllocate ( + unsigned int Size) +{ + void *Mem; + + + DbgPrint (ASL_PARSE_OUTPUT, + "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size); + + Mem = ACPI_ALLOCATE_ZEROED (Size); + if (!Mem) + { + AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_InputByteCount, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + exit (1); + } + + return (Mem); +} + +ACPI_PARSE_OBJECT * +AslDoError ( + void) +{ + + return (TrCreateLeafNode (PARSEOP_ERRORNODE)); +} + + +/******************************************************************************* + * + * FUNCTION: UtGetOpName + * + * PARAMETERS: ParseOpcode - Parser keyword ID + * + * RETURN: Pointer to the opcode name + * + * DESCRIPTION: Get the ascii name of the parse opcode + * + ******************************************************************************/ + +char * +UtGetOpName ( + UINT32 ParseOpcode) +{ +#ifdef ASL_YYTNAME_START + /* + * First entries (ASL_YYTNAME_START) in yytname are special reserved names. + * Ignore first 8 characters of the name + */ + return ((char *) yytname + [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8); +#else + return ("[Unknown parser generator]"); +#endif +} diff --git a/sys/contrib/dev/acpica/compiler/asltokens.y b/sys/contrib/dev/acpica/compiler/asltokens.y new file mode 100644 index 000000000000..c296fea30bec --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asltokens.y @@ -0,0 +1,386 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltokens.y - Bison/Yacc token types + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/****************************************************************************** + * + * Token types: These are returned by the lexer + * + * NOTE: This list MUST match the AslKeywordMapping table found + * in aslmap.c EXACTLY! Double check any changes! + * + *****************************************************************************/ + +%token PARSEOP_ACCESSAS +%token PARSEOP_ACCESSATTRIB_BLOCK +%token PARSEOP_ACCESSATTRIB_BLOCK_CALL +%token PARSEOP_ACCESSATTRIB_BYTE +%token PARSEOP_ACCESSATTRIB_MULTIBYTE +%token PARSEOP_ACCESSATTRIB_QUICK +%token PARSEOP_ACCESSATTRIB_RAW_BYTES +%token PARSEOP_ACCESSATTRIB_RAW_PROCESS +%token PARSEOP_ACCESSATTRIB_SND_RCV +%token PARSEOP_ACCESSATTRIB_WORD +%token PARSEOP_ACCESSATTRIB_WORD_CALL +%token PARSEOP_ACCESSTYPE_ANY +%token PARSEOP_ACCESSTYPE_BUF +%token PARSEOP_ACCESSTYPE_BYTE +%token PARSEOP_ACCESSTYPE_DWORD +%token PARSEOP_ACCESSTYPE_QWORD +%token PARSEOP_ACCESSTYPE_WORD +%token PARSEOP_ACQUIRE +%token PARSEOP_ADD +%token PARSEOP_ADDRESSINGMODE_7BIT +%token PARSEOP_ADDRESSINGMODE_10BIT +%token PARSEOP_ADDRESSTYPE_ACPI +%token PARSEOP_ADDRESSTYPE_MEMORY +%token PARSEOP_ADDRESSTYPE_NVS +%token PARSEOP_ADDRESSTYPE_RESERVED +%token PARSEOP_ALIAS +%token PARSEOP_AND +%token PARSEOP_ARG0 +%token PARSEOP_ARG1 +%token PARSEOP_ARG2 +%token PARSEOP_ARG3 +%token PARSEOP_ARG4 +%token PARSEOP_ARG5 +%token PARSEOP_ARG6 +%token PARSEOP_BANKFIELD +%token PARSEOP_BITSPERBYTE_EIGHT +%token PARSEOP_BITSPERBYTE_FIVE +%token PARSEOP_BITSPERBYTE_NINE +%token PARSEOP_BITSPERBYTE_SEVEN +%token PARSEOP_BITSPERBYTE_SIX +%token PARSEOP_BREAK +%token PARSEOP_BREAKPOINT +%token PARSEOP_BUFFER +%token PARSEOP_BUSMASTERTYPE_MASTER +%token PARSEOP_BUSMASTERTYPE_NOTMASTER +%token PARSEOP_BYTECONST +%token PARSEOP_CASE +%token PARSEOP_CLOCKPHASE_FIRST +%token PARSEOP_CLOCKPHASE_SECOND +%token PARSEOP_CLOCKPOLARITY_HIGH +%token PARSEOP_CLOCKPOLARITY_LOW +%token PARSEOP_CONCATENATE +%token PARSEOP_CONCATENATERESTEMPLATE +%token PARSEOP_CONDREFOF +%token PARSEOP_CONNECTION +%token PARSEOP_CONTINUE +%token PARSEOP_COPYOBJECT +%token PARSEOP_CREATEBITFIELD +%token PARSEOP_CREATEBYTEFIELD +%token PARSEOP_CREATEDWORDFIELD +%token PARSEOP_CREATEFIELD +%token PARSEOP_CREATEQWORDFIELD +%token PARSEOP_CREATEWORDFIELD +%token PARSEOP_DATABUFFER +%token PARSEOP_DATATABLEREGION +%token PARSEOP_DEBUG +%token PARSEOP_DECODETYPE_POS +%token PARSEOP_DECODETYPE_SUB +%token PARSEOP_DECREMENT +%token PARSEOP_DEFAULT +%token PARSEOP_DEFAULT_ARG +%token PARSEOP_DEFINITIONBLOCK +%token PARSEOP_DEREFOF +%token PARSEOP_DEVICE +%token PARSEOP_DEVICEPOLARITY_HIGH +%token PARSEOP_DEVICEPOLARITY_LOW +%token PARSEOP_DIVIDE +%token PARSEOP_DMA +%token PARSEOP_DMATYPE_A +%token PARSEOP_DMATYPE_COMPATIBILITY +%token PARSEOP_DMATYPE_B +%token PARSEOP_DMATYPE_F +%token PARSEOP_DWORDCONST +%token PARSEOP_DWORDIO +%token PARSEOP_DWORDMEMORY +%token PARSEOP_DWORDSPACE +%token PARSEOP_EISAID +%token PARSEOP_ELSE +%token PARSEOP_ELSEIF +%token PARSEOP_ENDDEPENDENTFN +%token PARSEOP_ENDIAN_BIG +%token PARSEOP_ENDIAN_LITTLE +%token PARSEOP_ENDTAG +%token PARSEOP_ERRORNODE +%token PARSEOP_EVENT +%token PARSEOP_EXTENDEDIO +%token PARSEOP_EXTENDEDMEMORY +%token PARSEOP_EXTENDEDSPACE +%token PARSEOP_EXTERNAL +%token PARSEOP_FATAL +%token PARSEOP_FIELD +%token PARSEOP_FINDSETLEFTBIT +%token PARSEOP_FINDSETRIGHTBIT +%token PARSEOP_FIXEDDMA +%token PARSEOP_FIXEDIO +%token PARSEOP_FLOWCONTROL_HW +%token PARSEOP_FLOWCONTROL_NONE +%token PARSEOP_FLOWCONTROL_SW +%token PARSEOP_FROMBCD +%token PARSEOP_FUNCTION +%token PARSEOP_GPIO_INT +%token PARSEOP_GPIO_IO +%token PARSEOP_I2C_SERIALBUS +%token PARSEOP_IF +%token PARSEOP_INCLUDE +%token PARSEOP_INCLUDE_END +%token PARSEOP_INCREMENT +%token PARSEOP_INDEX +%token PARSEOP_INDEXFIELD +%token PARSEOP_INTEGER +%token PARSEOP_INTERRUPT +%token PARSEOP_INTLEVEL_ACTIVEBOTH +%token PARSEOP_INTLEVEL_ACTIVEHIGH +%token PARSEOP_INTLEVEL_ACTIVELOW +%token PARSEOP_INTTYPE_EDGE +%token PARSEOP_INTTYPE_LEVEL +%token PARSEOP_IO +%token PARSEOP_IODECODETYPE_10 +%token PARSEOP_IODECODETYPE_16 +%token PARSEOP_IORESTRICT_IN +%token PARSEOP_IORESTRICT_NONE +%token PARSEOP_IORESTRICT_OUT +%token PARSEOP_IORESTRICT_PRESERVE +%token PARSEOP_IRQ +%token PARSEOP_IRQNOFLAGS +%token PARSEOP_LAND +%token PARSEOP_LEQUAL +%token PARSEOP_LGREATER +%token PARSEOP_LGREATEREQUAL +%token PARSEOP_LLESS +%token PARSEOP_LLESSEQUAL +%token PARSEOP_LNOT +%token PARSEOP_LNOTEQUAL +%token PARSEOP_LOAD +%token PARSEOP_LOADTABLE +%token PARSEOP_LOCAL0 +%token PARSEOP_LOCAL1 +%token PARSEOP_LOCAL2 +%token PARSEOP_LOCAL3 +%token PARSEOP_LOCAL4 +%token PARSEOP_LOCAL5 +%token PARSEOP_LOCAL6 +%token PARSEOP_LOCAL7 +%token PARSEOP_LOCKRULE_LOCK +%token PARSEOP_LOCKRULE_NOLOCK +%token PARSEOP_LOR +%token PARSEOP_MATCH +%token PARSEOP_MATCHTYPE_MEQ +%token PARSEOP_MATCHTYPE_MGE +%token PARSEOP_MATCHTYPE_MGT +%token PARSEOP_MATCHTYPE_MLE +%token PARSEOP_MATCHTYPE_MLT +%token PARSEOP_MATCHTYPE_MTR +%token PARSEOP_MAXTYPE_FIXED +%token PARSEOP_MAXTYPE_NOTFIXED +%token PARSEOP_MEMORY24 +%token PARSEOP_MEMORY32 +%token PARSEOP_MEMORY32FIXED +%token PARSEOP_MEMTYPE_CACHEABLE +%token PARSEOP_MEMTYPE_NONCACHEABLE +%token PARSEOP_MEMTYPE_PREFETCHABLE +%token PARSEOP_MEMTYPE_WRITECOMBINING +%token PARSEOP_METHOD +%token PARSEOP_METHODCALL +%token PARSEOP_MID +%token PARSEOP_MINTYPE_FIXED +%token PARSEOP_MINTYPE_NOTFIXED +%token PARSEOP_MOD +%token PARSEOP_MULTIPLY +%token PARSEOP_MUTEX +%token PARSEOP_NAME +%token PARSEOP_NAMESEG +%token PARSEOP_NAMESTRING +%token PARSEOP_NAND +%token PARSEOP_NOOP +%token PARSEOP_NOR +%token PARSEOP_NOT +%token PARSEOP_NOTIFY +%token PARSEOP_OBJECTTYPE +%token PARSEOP_OBJECTTYPE_BFF +%token PARSEOP_OBJECTTYPE_BUF +%token PARSEOP_OBJECTTYPE_DDB +%token PARSEOP_OBJECTTYPE_DEV +%token PARSEOP_OBJECTTYPE_EVT +%token PARSEOP_OBJECTTYPE_FLD +%token PARSEOP_OBJECTTYPE_INT +%token PARSEOP_OBJECTTYPE_MTH +%token PARSEOP_OBJECTTYPE_MTX +%token PARSEOP_OBJECTTYPE_OPR +%token PARSEOP_OBJECTTYPE_PKG +%token PARSEOP_OBJECTTYPE_POW +%token PARSEOP_OBJECTTYPE_PRO +%token PARSEOP_OBJECTTYPE_STR +%token PARSEOP_OBJECTTYPE_THZ +%token PARSEOP_OBJECTTYPE_UNK +%token PARSEOP_OFFSET +%token PARSEOP_ONE +%token PARSEOP_ONES +%token PARSEOP_OPERATIONREGION +%token PARSEOP_OR +%token PARSEOP_PACKAGE +%token PARSEOP_PACKAGE_LENGTH +%token PARSEOP_PARITYTYPE_EVEN +%token PARSEOP_PARITYTYPE_MARK +%token PARSEOP_PARITYTYPE_NONE +%token PARSEOP_PARITYTYPE_ODD +%token PARSEOP_PARITYTYPE_SPACE +%token PARSEOP_PIN_NOPULL +%token PARSEOP_PIN_PULLDEFAULT +%token PARSEOP_PIN_PULLDOWN +%token PARSEOP_PIN_PULLUP +%token PARSEOP_POWERRESOURCE +%token PARSEOP_PROCESSOR +%token PARSEOP_QWORDCONST +%token PARSEOP_QWORDIO +%token PARSEOP_QWORDMEMORY +%token PARSEOP_QWORDSPACE +%token PARSEOP_RANGETYPE_ENTIRE +%token PARSEOP_RANGETYPE_ISAONLY +%token PARSEOP_RANGETYPE_NONISAONLY +%token PARSEOP_RAW_DATA +%token PARSEOP_READWRITETYPE_BOTH +%token PARSEOP_READWRITETYPE_READONLY +%token PARSEOP_REFOF +%token PARSEOP_REGIONSPACE_CMOS +%token PARSEOP_REGIONSPACE_EC +%token PARSEOP_REGIONSPACE_FFIXEDHW +%token PARSEOP_REGIONSPACE_GPIO +%token PARSEOP_REGIONSPACE_GSBUS +%token PARSEOP_REGIONSPACE_IO +%token PARSEOP_REGIONSPACE_IPMI +%token PARSEOP_REGIONSPACE_MEM +%token PARSEOP_REGIONSPACE_PCC +%token PARSEOP_REGIONSPACE_PCI +%token PARSEOP_REGIONSPACE_PCIBAR +%token PARSEOP_REGIONSPACE_SMBUS +%token PARSEOP_REGISTER +%token PARSEOP_RELEASE +%token PARSEOP_RESERVED_BYTES +%token PARSEOP_RESET +%token PARSEOP_RESOURCETEMPLATE +%token PARSEOP_RESOURCETYPE_CONSUMER +%token PARSEOP_RESOURCETYPE_PRODUCER +%token PARSEOP_RETURN +%token PARSEOP_REVISION +%token PARSEOP_SCOPE +%token PARSEOP_SERIALIZERULE_NOTSERIAL +%token PARSEOP_SERIALIZERULE_SERIAL +%token PARSEOP_SHARETYPE_EXCLUSIVE +%token PARSEOP_SHARETYPE_EXCLUSIVEWAKE +%token PARSEOP_SHARETYPE_SHARED +%token PARSEOP_SHARETYPE_SHAREDWAKE +%token PARSEOP_SHIFTLEFT +%token PARSEOP_SHIFTRIGHT +%token PARSEOP_SIGNAL +%token PARSEOP_SIZEOF +%token PARSEOP_SLAVEMODE_CONTROLLERINIT +%token PARSEOP_SLAVEMODE_DEVICEINIT +%token PARSEOP_SLEEP +%token PARSEOP_SPI_SERIALBUS +%token PARSEOP_STALL +%token PARSEOP_STARTDEPENDENTFN +%token PARSEOP_STARTDEPENDENTFN_NOPRI +%token PARSEOP_STOPBITS_ONE +%token PARSEOP_STOPBITS_ONEPLUSHALF +%token PARSEOP_STOPBITS_TWO +%token PARSEOP_STOPBITS_ZERO +%token PARSEOP_STORE +%token PARSEOP_STRING_LITERAL +%token PARSEOP_SUBTRACT +%token PARSEOP_SWITCH +%token PARSEOP_THERMALZONE +%token PARSEOP_TIMER +%token PARSEOP_TOBCD +%token PARSEOP_TOBUFFER +%token PARSEOP_TODECIMALSTRING +%token PARSEOP_TOHEXSTRING +%token PARSEOP_TOINTEGER +%token PARSEOP_TOSTRING +%token PARSEOP_TOUUID +%token PARSEOP_TRANSLATIONTYPE_DENSE +%token PARSEOP_TRANSLATIONTYPE_SPARSE +%token PARSEOP_TYPE_STATIC +%token PARSEOP_TYPE_TRANSLATION +%token PARSEOP_UART_SERIALBUS +%token PARSEOP_UNICODE +%token PARSEOP_UNLOAD +%token PARSEOP_UPDATERULE_ONES +%token PARSEOP_UPDATERULE_PRESERVE +%token PARSEOP_UPDATERULE_ZEROS +%token PARSEOP_VAR_PACKAGE +%token PARSEOP_VENDORLONG +%token PARSEOP_VENDORSHORT +%token PARSEOP_WAIT +%token PARSEOP_WHILE +%token PARSEOP_WIREMODE_FOUR +%token PARSEOP_WIREMODE_THREE +%token PARSEOP_WORDBUSNUMBER +%token PARSEOP_WORDCONST +%token PARSEOP_WORDIO +%token PARSEOP_WORDSPACE +%token PARSEOP_XFERSIZE_8 +%token PARSEOP_XFERSIZE_16 +%token PARSEOP_XFERSIZE_32 +%token PARSEOP_XFERSIZE_64 +%token PARSEOP_XFERSIZE_128 +%token PARSEOP_XFERSIZE_256 +%token PARSEOP_XFERTYPE_8 +%token PARSEOP_XFERTYPE_8_16 +%token PARSEOP_XFERTYPE_16 +%token PARSEOP_XOR +%token PARSEOP_ZERO + +/* + * Special functions. These should probably stay at the end of this + * table. + */ +%token PARSEOP___DATE__ +%token PARSEOP___FILE__ +%token PARSEOP___LINE__ +%token PARSEOP___PATH__ diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index 7e6ad394b2d5..44b9f034025e 100644 --- a/sys/contrib/dev/acpica/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/compiler/asltransform.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" @@ -377,7 +376,6 @@ TrDoDefinitionBlock ( * * RETURN: None * - * * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs. There is * no actual AML opcode for SWITCH -- it must be simulated. * @@ -450,10 +448,6 @@ TrDoSwitch ( { /* Add an ELSE to complete the previous CASE */ - if (!Conditional) - { - return; - } NewOp = TrCreateLeafNode (PARSEOP_ELSE); NewOp->Asl.Parent = Conditional->Asl.Parent; TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent); @@ -620,11 +614,6 @@ TrDoSwitch ( { /* Convert the DEFAULT node to an ELSE */ - if (!Conditional) - { - return; - } - TrAmlInitNode (DefaultOp, PARSEOP_ELSE); DefaultOp->Asl.Parent = Conditional->Asl.Parent; diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c index b2bbbfd1c805..a6e5f7398748 100644 --- a/sys/contrib/dev/acpica/compiler/asltree.c +++ b/sys/contrib/dev/acpica/compiler/asltree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -79,15 +78,29 @@ static ACPI_PARSE_OBJECT * TrGetNextNode ( void) { + ASL_CACHE_INFO *Cache; - if (Gbl_NodeCacheNext >= Gbl_NodeCacheLast) + + if (Gbl_ParseOpCacheNext >= Gbl_ParseOpCacheLast) { - Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ACPI_PARSE_OBJECT) * - ASL_NODE_CACHE_SIZE); - Gbl_NodeCacheLast = Gbl_NodeCacheNext + ASL_NODE_CACHE_SIZE; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_ParseOpCacheList; + Gbl_ParseOpCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_ParseOpCacheNext = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Cache->Buffer); + Gbl_ParseOpCacheLast = Gbl_ParseOpCacheNext + ASL_PARSEOP_CACHE_SIZE; } - return (Gbl_NodeCacheNext++); + Gbl_ParseOpCount++; + return (Gbl_ParseOpCacheNext++); } @@ -517,7 +530,6 @@ TrCreateConstantLeafNode ( /* Get the simple filename from the full path */ FlSplitInputPathname (Op->Asl.Filename, &Path, &Filename); - ACPI_FREE (Path); Op->Asl.Value.String = Filename; break; diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 5ca17b30d603..5f01c80785b5 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ASLTYPES_H #define __ASLTYPES_H @@ -166,15 +165,26 @@ typedef enum ASL_FILE_C_SOURCE_OUTPUT, ASL_FILE_ASM_INCLUDE_OUTPUT, ASL_FILE_C_INCLUDE_OUTPUT, - ASL_FILE_C_OFFSET_OUTPUT + ASL_FILE_C_OFFSET_OUTPUT, + ASL_FILE_MAP_OUTPUT } ASL_FILE_TYPES; -#define ASL_MAX_FILE_TYPE 14 +#define ASL_MAX_FILE_TYPE 15 #define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) +/* Cache block structure for ParseOps and Strings */ + +typedef struct asl_cache_info +{ + void *Next; + char Buffer[1]; + +} ASL_CACHE_INFO; + + typedef struct asl_include_dir { char *Dir; @@ -196,7 +206,7 @@ typedef struct asl_error_msg char *Filename; char *SourceLine; UINT32 FilenameLength; - UINT8 MessageId; + UINT16 MessageId; UINT8 Level; } ASL_ERROR_MSG; @@ -238,4 +248,35 @@ typedef struct asl_event_info } ASL_EVENT_INFO; +/* Hardware mapping file structures */ + +typedef struct acpi_gpio_info +{ + struct acpi_gpio_info *Next; + ACPI_PARSE_OBJECT *Op; + char *DeviceName; + ACPI_NAMESPACE_NODE *TargetNode; + UINT32 References; + UINT32 PinCount; + UINT32 PinIndex; + UINT16 PinNumber; + UINT8 Type; + UINT8 Direction; + UINT8 Polarity; + +} ACPI_GPIO_INFO; + +typedef struct acpi_serial_info +{ + struct acpi_serial_info *Next; + ACPI_PARSE_OBJECT *Op; + char *DeviceName; + ACPI_NAMESPACE_NODE *TargetNode; + AML_RESOURCE *Resource; + UINT32 Speed; + UINT16 Address; + +} ACPI_SERIAL_INFO; + + #endif /* __ASLTYPES_H */ diff --git a/sys/contrib/dev/acpica/compiler/asltypes.y b/sys/contrib/dev/acpica/compiler/asltypes.y new file mode 100644 index 000000000000..b9914531b4e3 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asltypes.y @@ -0,0 +1,381 @@ +NoEcho(' +/****************************************************************************** + * + * Module Name: asltypes.y - Bison/Yacc production types/names + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +') + +/****************************************************************************** + * + * Production names + * + *****************************************************************************/ + +%type ArgList +%type ASLCode +%type BufferData +%type BufferTermData +%type CompilerDirective +%type DataObject +%type DefinitionBlockTerm +%type IntegerData +%type NamedObject +%type NameSpaceModifier +%type Object +%type ObjectList +%type PackageData +%type ParameterTypePackage +%type ParameterTypePackageList +%type ParameterTypesPackage +%type ParameterTypesPackageList +%type RequiredTarget +%type SimpleTarget +%type StringData +%type Target +%type Term +%type TermArg +%type TermList +%type UserTerm + +/* Type4Opcode is obsolete */ + +%type Type1Opcode +%type Type2BufferOpcode +%type Type2BufferOrStringOpcode +%type Type2IntegerOpcode +%type Type2Opcode +%type Type2StringOpcode +%type Type3Opcode +%type Type5Opcode +%type Type6Opcode + +%type AccessAsTerm +%type ExternalTerm +%type FieldUnit +%type FieldUnitEntry +%type FieldUnitList +%type IncludeTerm +%type OffsetTerm +%type OptionalAccessAttribTerm + +/* Named Objects */ + +%type BankFieldTerm +%type CreateBitFieldTerm +%type CreateByteFieldTerm +%type CreateDWordFieldTerm +%type CreateFieldTerm +%type CreateQWordFieldTerm +%type CreateWordFieldTerm +%type DataRegionTerm +%type DeviceTerm +%type EventTerm +%type FieldTerm +%type FunctionTerm +%type IndexFieldTerm +%type MethodTerm +%type MutexTerm +%type OpRegionTerm +%type OpRegionSpaceIdTerm +%type PowerResTerm +%type ProcessorTerm +%type ThermalZoneTerm + +/* Namespace modifiers */ + +%type AliasTerm +%type NameTerm +%type ScopeTerm + +/* Type 1 opcodes */ + +%type BreakPointTerm +%type BreakTerm +%type CaseDefaultTermList +%type CaseTerm +%type ContinueTerm +%type DefaultTerm +%type ElseTerm +%type FatalTerm +%type IfElseTerm +%type IfTerm +%type LoadTerm +%type NoOpTerm +%type NotifyTerm +%type ReleaseTerm +%type ResetTerm +%type ReturnTerm +%type SignalTerm +%type SleepTerm +%type StallTerm +%type SwitchTerm +%type UnloadTerm +%type WhileTerm +/* %type CaseTermList */ + +/* Type 2 opcodes */ + +%type AcquireTerm +%type AddTerm +%type AndTerm +%type ConcatResTerm +%type ConcatTerm +%type CondRefOfTerm +%type CopyObjectTerm +%type DecTerm +%type DerefOfTerm +%type DivideTerm +%type FindSetLeftBitTerm +%type FindSetRightBitTerm +%type FromBCDTerm +%type IncTerm +%type IndexTerm +%type LAndTerm +%type LEqualTerm +%type LGreaterEqualTerm +%type LGreaterTerm +%type LLessEqualTerm +%type LLessTerm +%type LNotEqualTerm +%type LNotTerm +%type LoadTableTerm +%type LOrTerm +%type MatchTerm +%type MidTerm +%type ModTerm +%type MultiplyTerm +%type NAndTerm +%type NOrTerm +%type NotTerm +%type ObjectTypeTerm +%type OrTerm +%type RefOfTerm +%type ShiftLeftTerm +%type ShiftRightTerm +%type SizeOfTerm +%type StoreTerm +%type SubtractTerm +%type TimerTerm +%type ToBCDTerm +%type ToBufferTerm +%type ToDecimalStringTerm +%type ToHexStringTerm +%type ToIntegerTerm +%type ToStringTerm +%type WaitTerm +%type XOrTerm + +/* Keywords */ + +%type AccessAttribKeyword +%type AccessTypeKeyword +%type AddressingModeKeyword +%type AddressKeyword +%type AddressSpaceKeyword +%type BitsPerByteKeyword +%type ClockPhaseKeyword +%type ClockPolarityKeyword +%type DecodeKeyword +%type DevicePolarityKeyword +%type DMATypeKeyword +%type EndianKeyword +%type FlowControlKeyword +%type InterruptLevel +%type InterruptTypeKeyword +%type IODecodeKeyword +%type IoRestrictionKeyword +%type LockRuleKeyword +%type MatchOpKeyword +%type MaxKeyword +%type MemTypeKeyword +%type MinKeyword +%type ObjectTypeKeyword +%type OptionalBusMasterKeyword +%type OptionalReadWriteKeyword +%type ParityTypeKeyword +%type PinConfigByte +%type PinConfigKeyword +%type RangeTypeKeyword +%type RegionSpaceKeyword +%type ResourceTypeKeyword +%type SerializeRuleKeyword +%type ShareTypeKeyword +%type SlaveModeKeyword +%type StopBitsKeyword +%type TranslationKeyword +%type TypeKeyword +%type UpdateRuleKeyword +%type WireModeKeyword +%type XferSizeKeyword +%type XferTypeKeyword + +/* Types */ + +%type SuperName +%type ObjectTypeName +%type ArgTerm +%type LocalTerm +%type DebugTerm + +%type Integer +%type ByteConst +%type WordConst +%type DWordConst +%type QWordConst +%type String + +%type ConstTerm +%type ConstExprTerm +%type ByteConstExpr +%type WordConstExpr +%type DWordConstExpr +%type QWordConstExpr + +%type DWordList +%type BufferTerm +%type ByteList + +%type PackageElement +%type PackageList +%type PackageTerm +%type VarPackageLengthTerm + +/* Macros */ + +%type EISAIDTerm +%type ResourceMacroList +%type ResourceMacroTerm +%type ResourceTemplateTerm +%type ToUUIDTerm +%type UnicodeTerm + +/* Resource Descriptors */ + +%type ConnectionTerm +%type DataBufferTerm +%type DMATerm +%type DWordIOTerm +%type DWordMemoryTerm +%type DWordSpaceTerm +%type EndDependentFnTerm +%type ExtendedIOTerm +%type ExtendedMemoryTerm +%type ExtendedSpaceTerm +%type FixedDmaTerm +%type FixedIOTerm +%type GpioIntTerm +%type GpioIoTerm +%type I2cSerialBusTerm +%type InterruptTerm +%type IOTerm +%type IRQNoFlagsTerm +%type IRQTerm +%type Memory24Term +%type Memory32FixedTerm +%type Memory32Term +%type NameSeg +%type NameString +%type QWordIOTerm +%type QWordMemoryTerm +%type QWordSpaceTerm +%type RegisterTerm +%type SpiSerialBusTerm +%type StartDependentFnNoPriTerm +%type StartDependentFnTerm +%type UartSerialBusTerm +%type VendorLongTerm +%type VendorShortTerm +%type WordBusNumberTerm +%type WordIOTerm +%type WordSpaceTerm + +/* Local types that help construct the AML, not in ACPI spec */ + +%type AmlPackageLengthTerm +%type IncludeEndTerm +%type NameStringItem +%type TermArgItem + +%type OptionalAccessSize +%type OptionalAddressingMode +%type OptionalAddressRange +%type OptionalBitsPerByte +%type OptionalBuffer_Last +%type OptionalByteConstExpr +%type OptionalCount +%type OptionalDecodeType +%type OptionalDevicePolarity +%type OptionalDWordConstExpr +%type OptionalEndian +%type OptionalFlowControl +%type OptionalIoRestriction +%type OptionalListString +%type OptionalMaxType +%type OptionalMemType +%type OptionalMinType +%type OptionalNameString +%type OptionalNameString_First +%type OptionalNameString_Last +%type OptionalObjectTypeKeyword +%type OptionalParameterTypePackage +%type OptionalParameterTypesPackage +%type OptionalParityType +%type OptionalQWordConstExpr +%type OptionalRangeType +%type OptionalReference +%type OptionalResourceType +%type OptionalResourceType_First +%type OptionalReturnArg +%type OptionalSerializeRuleKeyword +%type OptionalShareType +%type OptionalShareType_First +%type OptionalSlaveMode +%type OptionalStopBits +%type OptionalStringData +%type OptionalTermArg +%type OptionalTranslationType_Last +%type OptionalType +%type OptionalType_Last +%type OptionalWireMode +%type OptionalWordConst +%type OptionalWordConstExpr +%type OptionalXferSize diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c index eea5d6891326..0ec4473c0547 100644 --- a/sys/contrib/dev/acpica/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/compiler/aslutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -241,37 +240,6 @@ UtEndEvent ( } -/******************************************************************************* - * - * FUNCTION: UtHexCharToValue - * - * PARAMETERS: HexChar - Hex character in Ascii - * - * RETURN: The binary value of the hex character - * - * DESCRIPTION: Perform ascii-to-hex translation - * - ******************************************************************************/ - -UINT8 -UtHexCharToValue ( - int HexChar) -{ - - if (HexChar <= 0x39) - { - return ((UINT8) (HexChar - 0x30)); - } - - if (HexChar <= 0x46) - { - return ((UINT8) (HexChar - 0x37)); - } - - return ((UINT8) (HexChar - 0x57)); -} - - /******************************************************************************* * * FUNCTION: UtConvertByteToHex @@ -296,8 +264,8 @@ UtConvertByteToHex ( Buffer[0] = '0'; Buffer[1] = 'x'; - Buffer[2] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); } @@ -312,7 +280,7 @@ UtConvertByteToHex ( * RETURN: Ascii hex byte is stored in Buffer. * * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed - * with "0x" + * with '0', and a trailing 'h' is added. * ******************************************************************************/ @@ -323,8 +291,8 @@ UtConvertByteToAsmHex ( { Buffer[0] = '0'; - Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF]; - Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF]; + Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4); + Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0); Buffer[3] = 'h'; } @@ -585,7 +553,7 @@ UtCheckIntegerRange ( /******************************************************************************* * - * FUNCTION: UtGetStringBuffer + * FUNCTION: UtStringCacheCalloc * * PARAMETERS: Length - Size of buffer requested * @@ -598,22 +566,42 @@ UtCheckIntegerRange ( ******************************************************************************/ char * -UtGetStringBuffer ( +UtStringCacheCalloc ( UINT32 Length) { char *Buffer; + ASL_CACHE_INFO *Cache; + if (Length > ASL_STRING_CACHE_SIZE) + { + Buffer = UtLocalCalloc (Length); + return (Buffer); + } + if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast) { - Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length); - Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + - Length; + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + ASL_STRING_CACHE_SIZE); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_StringCacheList; + Gbl_StringCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_StringCacheNext = Cache->Buffer; + Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE; } + Gbl_StringCount++; + Gbl_StringSize += Length; + Buffer = Gbl_StringCacheNext; Gbl_StringCacheNext += Length; - return (Buffer); } @@ -646,7 +634,8 @@ UtExpandLineBuffers ( NewSize = Gbl_LineBufferSize * 2; if (Gbl_CurrentLineBuffer) { - DbgPrint (ASL_DEBUG_OUTPUT,"Increasing line buffer size from %u to %u\n", + DbgPrint (ASL_DEBUG_OUTPUT, + "Increasing line buffer size from %u to %u\n", Gbl_LineBufferSize, NewSize); } @@ -691,6 +680,30 @@ UtExpandLineBuffers ( } +/****************************************************************************** + * + * FUNCTION: UtFreeLineBuffers + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all line buffers + * + *****************************************************************************/ + +void +UtFreeLineBuffers ( + void) +{ + + free (Gbl_CurrentLineBuffer); + free (Gbl_MainTokenBuffer); + free (Gbl_MacroTokenBuffer); + free (Gbl_ExpressionTokenBuffer); +} + + /******************************************************************************* * * FUNCTION: UtInternalizeName @@ -723,9 +736,9 @@ UtInternalizeName ( Info.ExternalName = ExternalName; AcpiNsGetInternalNameLength (&Info); - /* We need a segment to store the internal name */ + /* We need a segment to store the internal name */ - Info.InternalName = UtGetStringBuffer (Info.Length); + Info.InternalName = UtStringCacheCalloc (Info.Length); if (!Info.InternalName) { return (AE_NO_MEMORY); @@ -918,7 +931,7 @@ UtDoConstant ( } -/* TBD: use version in ACPI CA main code base? */ +/* TBD: use version in ACPICA main code base? */ /******************************************************************************* * diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c index ed884dc02f4b..8ba9dd9cbbe6 100644 --- a/sys/contrib/dev/acpica/compiler/asluuid.c +++ b/sys/contrib/dev/acpica/compiler/asluuid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,42 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asluuid") -/* - * UUID support functions. - * - * This table is used to convert an input UUID ascii string to a 16 byte - * buffer and the reverse. The table maps a UUID buffer index 0-15 to - * the index within the 36-byte UUID string where the associated 2-byte - * hex value can be found. - * - * 36-byte UUID strings are of the form: - * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp - * Where aa-pp are one byte hex numbers, made up of two hex digits - * - * Note: This table is basically the inverse of the string-to-offset table - * found in the ACPI spec in the description of the ToUUID macro. - */ -static UINT8 Gbl_MapToUuidOffset[16] = -{ - 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 -}; - -#define UUID_BUFFER_LENGTH 16 -#define UUID_STRING_LENGTH 36 - -/* Positions for required hyphens (dashes) in UUID strings */ - -#define UUID_HYPHEN1_OFFSET 8 -#define UUID_HYPHEN2_OFFSET 13 -#define UUID_HYPHEN3_OFFSET 18 -#define UUID_HYPHEN4_OFFSET 23 +extern UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH]; /******************************************************************************* @@ -135,42 +106,6 @@ AuValidateUuid ( } -/******************************************************************************* - * - * FUNCTION: AuConvertStringToUuid - * - * PARAMETERS: InString - 36-byte formatted UUID string - * UuidBuffer - 16-byte UUID buffer - * - * RETURN: Status - * - * DESCRIPTION: Convert 36-byte formatted UUID string to 16-byte UUID buffer - * - ******************************************************************************/ - -ACPI_STATUS -AuConvertStringToUuid ( - char *InString, - char *UuidBuffer) -{ - UINT32 i; - - - if (!InString || !UuidBuffer) - { - return (AE_BAD_PARAMETER); - } - - for (i = 0; i < UUID_BUFFER_LENGTH; i++) - { - UuidBuffer[i] = (char) (UtHexCharToValue (InString[Gbl_MapToUuidOffset[i]]) << 4); - UuidBuffer[i] |= (char) UtHexCharToValue (InString[Gbl_MapToUuidOffset[i] + 1]); - } - - return (AE_OK); -} - - /******************************************************************************* * * FUNCTION: AuConvertUuidToString @@ -200,8 +135,11 @@ AuConvertUuidToString ( for (i = 0; i < UUID_BUFFER_LENGTH; i++) { - OutString[Gbl_MapToUuidOffset[i]] = (UINT8) AslHexLookup[(UuidBuffer[i] >> 4) & 0xF]; - OutString[Gbl_MapToUuidOffset[i] + 1] = (UINT8) AslHexLookup[UuidBuffer[i] & 0xF]; + OutString[AcpiGbl_MapToUuidOffset[i]] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 4); + + OutString[AcpiGbl_MapToUuidOffset[i] + 1] = + AcpiUtHexToAsciiChar (UuidBuffer[i], 0); } /* Insert required hyphens (dashes) */ diff --git a/sys/contrib/dev/acpica/compiler/aslwalks.c b/sys/contrib/dev/acpica/compiler/aslwalks.c index 7dfa7af7e667..1ce5918faba7 100644 --- a/sys/contrib/dev/acpica/compiler/aslwalks.c +++ b/sys/contrib/dev/acpica/compiler/aslwalks.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -605,6 +604,10 @@ AnOtherSemanticAnalysisWalkBegin ( ArgNode = Op->Asl.Parent; /* Field definition */ ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ Node = ArgNode->Asl.Node; /* OpRegion namespace node */ + if (!Node) + { + break; + } ArgNode = Node->Op; /* OpRegion definition */ ArgNode = ArgNode->Asl.Child; /* First child is the OpRegion Name */ diff --git a/sys/contrib/dev/acpica/compiler/aslxref.c b/sys/contrib/dev/acpica/compiler/aslxref.c index 51addc3b3a0e..3d73d27d6b03 100644 --- a/sys/contrib/dev/acpica/compiler/aslxref.c +++ b/sys/contrib/dev/acpica/compiler/aslxref.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include @@ -86,6 +85,22 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +#ifdef __UNDER_DEVELOPMENT +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op); + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *Node); + +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *MethodOp1, + ACPI_PARSE_OBJECT *MethodOp2); +#endif + /******************************************************************************* * @@ -130,6 +145,8 @@ XfCrossReferenceNamespace ( TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, XfNamespaceLocateEnd, WalkState); + + ACPI_FREE (WalkState); return (AE_OK); } @@ -262,6 +279,182 @@ XfCheckFieldRange ( } } + +#ifdef __UNDER_DEVELOPMENT +/******************************************************************************* + * + * FUNCTION: XfIsObjectParental + * + * PARAMETERS: ChildOp - Op to be checked + * PossibleParentOp - Determine if this op is in the family + * + * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp + * + * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to + * detect if a method is declared within another method. + * + ******************************************************************************/ + +static BOOLEAN +XfIsObjectParental ( + ACPI_PARSE_OBJECT *ChildOp, + ACPI_PARSE_OBJECT *PossibleParentOp) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + /* Search upwards through the tree for possible parent */ + + ParentOp = ChildOp; + while (ParentOp) + { + if (ParentOp == PossibleParentOp) + { + return (TRUE); + } + + ParentOp = ParentOp->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfGetParentMethod + * + * PARAMETERS: Op - Op to be checked + * + * RETURN: Op for parent method. NULL if object is not within a method. + * + * DESCRIPTION: Determine if an object is within a control method. Used to + * implement special rules for named references from within a + * control method. + * + * NOTE: It would be better to have the parser set a flag in the Op if possible. + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +XfGetParentMethod ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *ParentOp; + + + if (!Op) + { + return (NULL); + } + + if (Op->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (NULL); + } + + /* Walk upwards through the parse tree, up to the root if necessary */ + + ParentOp = Op; + while (ParentOp) + { + if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD) + { + return (ParentOp); + } + + ParentOp = ParentOp->Asl.Parent; + } + + /* Object is not within a method */ + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: XfCheckIllegalReference + * + * PARAMETERS: Op - Op referring to the target + * TargetNode - Target of the reference + * + * RETURN: None. Emits error message for an illegal reference + * + * DESCRIPTION: Determine if a named reference is legal. A "named" reference + * is something like: Store(ABCD, ...), where ABCD is an AML + * Nameseg or Namepath. + * + * NOTE: Caller must ensure that the name Op is in fact a reference, and not + * an actual name declaration (creation of a named object). + * + ******************************************************************************/ + +static void +XfCheckIllegalReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *TargetNode) +{ + ACPI_PARSE_OBJECT *MethodOp1; + ACPI_PARSE_OBJECT *MethodOp2; + ACPI_PARSE_OBJECT *TargetOp; + + + /* + * Check for an illegal reference to a named object: + * + * 1) References from one control method to another, non-parent + * method are not allowed, they will fail at runtime. + * + * 2) Forward references within a control method are not allowed. + * AML interpreters use a one-pass parse of control methods + * so these forward references will fail at runtime. + */ + TargetOp = TargetNode->Op; + + MethodOp1 = XfGetParentMethod (Op); + MethodOp2 = XfGetParentMethod (TargetOp); + + /* Are both objects within control method(s)? */ + + if (!MethodOp1 || !MethodOp2) + { + return; + } + + /* Objects not in the same method? */ + + if (MethodOp1 != MethodOp2) + { + /* + * 1) Cross-method named reference + * + * This is OK if and only if the target reference is within in a + * method that is a parent of current method + */ + if (!XfIsObjectParental (MethodOp1, MethodOp2)) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op, + Op->Asl.ExternalName); + } + } + + /* + * 2) Both reference and target are in the same method. Check if this is + * an (illegal) forward reference by examining the exact source code + * location of each (the referenced object and the object declaration). + * This is a bit nasty, yet effective. + */ + else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset) + { + AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op, + Op->Asl.ExternalName); + } + +} +#endif + + /******************************************************************************* * * FUNCTION: XfNamespaceLocateBegin @@ -316,7 +509,7 @@ XfNamespaceLocateBegin ( */ if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* We are only interested in opcodes that have an associated name */ @@ -329,7 +522,7 @@ XfNamespaceLocateBegin ( (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -340,7 +533,7 @@ XfNamespaceLocateBegin ( if ((Op->Asl.Parent) && (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -459,7 +652,8 @@ XfNamespaceLocateBegin ( Status = AE_OK; } - return (Status); + + return_ACPI_STATUS (Status); } /* Check for a reference vs. name declaration */ @@ -470,6 +664,13 @@ XfNamespaceLocateBegin ( /* This node has been referenced, mark it for reference check */ Node->Flags |= ANOBJ_IS_REFERENCED; + +#ifdef __UNDER_DEVELOPMENT + + /* Check for an illegal reference */ + + XfCheckIllegalReference (Op, Node); +#endif } /* Attempt to optimize the NamePath */ @@ -624,7 +825,6 @@ XfNamespaceLocateBegin ( (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { - /* * A reference to a method within one of these opcodes is not an * invocation of the method, it is simply a reference to the method. @@ -634,7 +834,7 @@ XfNamespaceLocateBegin ( (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) || (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* * There are two types of method invocation: @@ -650,7 +850,7 @@ XfNamespaceLocateBegin ( Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Save the method node in the caller's op */ @@ -658,7 +858,7 @@ XfNamespaceLocateBegin ( Op->Asl.Node = Node; if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -822,8 +1022,16 @@ XfNamespaceLocateBegin ( } } + /* 5) Check for a connection object */ +#if 0 + else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONNECTION) + { + return_ACPI_STATUS (Status); + } +#endif + Op->Asl.Node = Node; - return (Status); + return_ACPI_STATUS (Status); } @@ -858,7 +1066,7 @@ XfNamespaceLocateEnd ( OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); if (!(OpInfo->Flags & AML_NAMED)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Not interested in name references, we did not open a scope for them */ @@ -867,7 +1075,7 @@ XfNamespaceLocateEnd ( (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Pop the scope stack if necessary */ @@ -882,5 +1090,5 @@ XfNamespaceLocateEnd ( (void) AcpiDsScopeStackPop (WalkState); } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c index 3407e1ddc355..69344b1d3f79 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompile.c +++ b/sys/contrib/dev/acpica/compiler/dtcompile.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -141,8 +141,6 @@ DtDoCompile ( Status = DtCompileDataTable (&FieldList); UtEndEvent (Event); - DtFreeFieldList (); - if (ACPI_FAILURE (Status)) { /* TBD: temporary error message. Msgs should come from function above */ @@ -170,6 +168,8 @@ DtDoCompile ( CleanupAndExit: + AcpiUtDeleteCaches (); + DtDeleteCaches (); CmCleanupAndExit (); return (Status); } @@ -298,7 +298,7 @@ DtCompileDataTable ( return (AE_ERROR); } - Gbl_Signature = UtLocalCalloc (ACPI_STRLEN (Signature) + 1); + Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1); strcpy (Gbl_Signature, Signature); /* @@ -437,6 +437,7 @@ DtCompileTable ( UINT8 FieldType; UINT8 *Buffer; UINT8 *FlagBuffer = NULL; + char *String; UINT32 CurrentFlagByteOffset = 0; ACPI_STATUS Status; @@ -446,18 +447,29 @@ DtCompileTable ( return (AE_BAD_PARAMETER); } + /* Ignore optional subtable if name does not match */ + + if ((Info->Flags & DT_OPTIONAL) && + ACPI_STRCMP ((*Field)->Name, Info->Name)) + { + *RetSubtable = NULL; + return (AE_OK); + } + Length = DtGetSubtableLength (*Field, Info); if (Length == ASL_EOF) { return (AE_ERROR); } - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); if (Length > 0) { - Subtable->Buffer = UtLocalCalloc (Length); + String = UtStringCacheCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); } + Subtable->Length = Length; Subtable->TotalLength = Length; Buffer = Subtable->Buffer; @@ -558,8 +570,6 @@ DtCompileTable ( DtSetSubtableLength (InlineSubtable); ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); - ACPI_FREE (InlineSubtable->Buffer); - ACPI_FREE (InlineSubtable); LocalField = *Field; break; diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h index 51fec6d5a05b..dbf112593da6 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompiler.h +++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,10 @@ #include +#define ASL_FIELD_CACHE_SIZE 512 +#define ASL_SUBTABLE_CACHE_SIZE 128 + + #undef DT_EXTERN #ifdef _DECLARE_DT_GLOBALS @@ -143,6 +147,18 @@ DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_LabelList, NULL); DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_CurrentTableOffset, 0); +/* Local caches */ + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_SubtableCount, 0); +DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_SubtableCacheList, NULL); +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheNext, NULL); +DT_EXTERN DT_SUBTABLE DT_INIT_GLOBAL (*Gbl_SubtableCacheLast, NULL); + +DT_EXTERN UINT32 DT_INIT_GLOBAL (Gbl_FieldCount, 0); +DT_EXTERN ASL_CACHE_INFO DT_INIT_GLOBAL (*Gbl_FieldCacheList, NULL); +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheNext, NULL); +DT_EXTERN DT_FIELD DT_INIT_GLOBAL (*Gbl_FieldCacheLast, NULL); + /* dtcompiler - main module */ @@ -321,20 +337,20 @@ DtWalkTableTree ( void DtError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage); void DtNameError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage); void DtFatal ( - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage); @@ -343,10 +359,6 @@ DtStrtoul64 ( char *String, UINT64 *ReturnInteger); -UINT32 -DtGetFileSize ( - FILE *Handle); - char* DtGetFieldValue ( DT_FIELD *Field); @@ -372,8 +384,16 @@ void DtSetTableLength( void); +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void); + +DT_FIELD * +UtFieldCacheCalloc ( + void); + void -DtFreeFieldList ( +DtDeleteCaches ( void); @@ -399,6 +419,10 @@ ACPI_STATUS DtCompileCsrt ( void **PFieldList); +ACPI_STATUS +DtCompileDbg2 ( + void **PFieldList); + ACPI_STATUS DtCompileDmar ( void **PFieldList); @@ -419,6 +443,10 @@ ACPI_STATUS DtCompileFpdt ( void **PFieldList); +ACPI_STATUS +DtCompileGtdt ( + void **PFieldList); + ACPI_STATUS DtCompileHest ( void **PFieldList); @@ -427,6 +455,10 @@ ACPI_STATUS DtCompileIvrs ( void **PFieldList); +ACPI_STATUS +DtCompileLpit ( + void **PFieldList); + ACPI_STATUS DtCompileMadt ( void **PFieldList); @@ -451,6 +483,10 @@ ACPI_STATUS DtCompilePmtt ( void **PFieldList); +ACPI_STATUS +DtCompilePcct ( + void **PFieldList); + ACPI_STATUS DtCompileRsdt ( void **PFieldList); @@ -503,6 +539,7 @@ extern const unsigned char TemplateBert[]; extern const unsigned char TemplateBgrt[]; extern const unsigned char TemplateCpep[]; extern const unsigned char TemplateCsrt[]; +extern const unsigned char TemplateDbg2[]; extern const unsigned char TemplateDbgp[]; extern const unsigned char TemplateDmar[]; extern const unsigned char TemplateEcdt[]; @@ -514,12 +551,14 @@ extern const unsigned char TemplateGtdt[]; extern const unsigned char TemplateHest[]; extern const unsigned char TemplateHpet[]; extern const unsigned char TemplateIvrs[]; +extern const unsigned char TemplateLpit[]; extern const unsigned char TemplateMadt[]; extern const unsigned char TemplateMcfg[]; extern const unsigned char TemplateMchi[]; extern const unsigned char TemplateMpst[]; extern const unsigned char TemplateMsct[]; extern const unsigned char TemplateMtmr[]; +extern const unsigned char TemplatePcct[]; extern const unsigned char TemplatePmtt[]; extern const unsigned char TemplateRsdt[]; extern const unsigned char TemplateS3pt[]; diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c index 9689ef6ffc77..59181f3308e8 100644 --- a/sys/contrib/dev/acpica/compiler/dtexpress.c +++ b/sys/contrib/dev/acpica/compiler/dtexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c index 1f273d953389..a19b985fe1f5 100644 --- a/sys/contrib/dev/acpica/compiler/dtfield.c +++ b/sys/contrib/dev/acpica/compiler/dtfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -259,7 +259,7 @@ DtCompileUuid ( } else { - Status = AuConvertStringToUuid (InString, (char *) Buffer); + AcpiUtConvertStringToUuid (InString, Buffer); } return (Status); @@ -311,21 +311,37 @@ DtCompileInteger ( return; } - /* Ensure that reserved fields are set to zero */ - /* TBD: should we set to zero, or just make this an ERROR? */ - /* TBD: Probably better to use a flag */ + /* + * Ensure that reserved fields are set properly. Note: uses + * the DT_NON_ZERO flag to indicate that the reserved value + * must be exactly one. Otherwise, the value must be zero. + * This is sufficient for now. + */ - if (!ACPI_STRCMP (Field->Name, "Reserved") && - (Value != 0)) + /* TBD: Should use a flag rather than compare "Reserved" */ + + if (!ACPI_STRCMP (Field->Name, "Reserved")) { - DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, - "Setting to zero"); - Value = 0; + if (Flags & DT_NON_ZERO) + { + if (Value != 1) + { + DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, + "Must be one, setting to one"); + Value = 1; + } + } + else if (Value != 0) + { + DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, + "Must be zero, setting to zero"); + Value = 0; + } } /* Check if the value must be non-zero */ - if ((Value == 0) && (Flags & DT_NON_ZERO)) + else if ((Flags & DT_NON_ZERO) && (Value == 0)) { DtError (ASL_ERROR, ASL_MSG_ZERO_VALUE, Field, NULL); } @@ -340,7 +356,8 @@ DtCompileInteger ( if (Value > MaxValue) { - sprintf (MsgBuffer, "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Value)); + sprintf (MsgBuffer, "%8.8X%8.8X - max %u bytes", + ACPI_FORMAT_UINT64 (Value), ByteLength); DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); } diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c index 39fb9da3da04..1f5b62034e65 100644 --- a/sys/contrib/dev/acpica/compiler/dtio.c +++ b/sys/contrib/dev/acpica/compiler/dtio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ #include #include +#include #define _COMPONENT DT_COMPILER ACPI_MODULE_NAME ("dtio") @@ -132,7 +133,7 @@ DtTrim ( if (!ACPI_STRCMP (String, " ")) { - ReturnString = UtLocalCalloc (1); + ReturnString = UtStringCacheCalloc (1); return (ReturnString); } @@ -180,7 +181,7 @@ DtTrim ( /* Create the trimmed return string */ Length = ACPI_PTR_DIFF (End, Start) + 1; - ReturnString = UtLocalCalloc (Length + 1); + ReturnString = UtStringCacheCalloc (Length + 1); if (ACPI_STRLEN (Start)) { ACPI_STRNCPY (ReturnString, Start, Length); @@ -369,7 +370,7 @@ DtParseLine ( if ((Value && *Value) || IsNullString) { - Field = UtLocalCalloc (sizeof (DT_FIELD)); + Field = UtFieldCacheCalloc (); Field->Name = Name; Field->Value = Value; Field->Line = Line; @@ -379,11 +380,7 @@ DtParseLine ( DtLinkField (Field); } - else /* Ignore this field, it has no valid data */ - { - ACPI_FREE (Name); - ACPI_FREE (Value); - } + /* Else -- Ignore this field, it has no valid data */ return (AE_OK); } @@ -737,7 +734,11 @@ DtScanFile ( /* Get the file size */ - Gbl_InputByteCount = DtGetFileSize (Handle); + Gbl_InputByteCount = CmGetFileSize (Handle); + if (Gbl_InputByteCount == ACPI_UINT32_MAX) + { + AslAbort (); + } Gbl_CurrentLineNumber = 0; Gbl_CurrentLineOffset = 0; @@ -816,7 +817,12 @@ DtOutputBinary ( /* Walk the entire parse tree, emitting the binary data */ DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL); - Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + + Gbl_TableLength = CmGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (Gbl_TableLength == ACPI_UINT32_MAX) + { + AslAbort (); + } } @@ -1025,6 +1031,8 @@ DtDumpSubtableList ( DbgPrint (ASL_DEBUG_OUTPUT, "\nSubtable Tree: (Depth, Subtable, Length, TotalLength)\n\n"); DtWalkTableTree (Gbl_RootTable, DtDumpSubtableTree, NULL, NULL); + + DbgPrint (ASL_DEBUG_OUTPUT, "\n"); } diff --git a/sys/contrib/dev/acpica/compiler/dtparser.l b/sys/contrib/dev/acpica/compiler/dtparser.l index b0f6d6c978d5..c6578ef91fa7 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.l +++ b/sys/contrib/dev/acpica/compiler/dtparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/dtparser.y b/sys/contrib/dev/acpica/compiler/dtparser.y index 47e74bddbae6..135eaae411b6 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.y +++ b/sys/contrib/dev/acpica/compiler/dtparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c index 67fcb9d22656..fc700cd77703 100644 --- a/sys/contrib/dev/acpica/compiler/dtsubtable.c +++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,13 +73,15 @@ DtCreateSubtable ( DT_SUBTABLE **RetSubtable) { DT_SUBTABLE *Subtable; + char *String; - Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); + Subtable = UtSubtableCacheCalloc (); /* Create a new buffer for the subtable data */ - Subtable->Buffer = UtLocalCalloc (Length); + String = UtStringCacheCalloc (Length); + Subtable->Buffer = ACPI_CAST_PTR (UINT8, String); ACPI_MEMCPY (Subtable->Buffer, Buffer, Length); Subtable->Length = Length; diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c index bb6c7cbdcae3..56eb92299745 100644 --- a/sys/contrib/dev/acpica/compiler/dttable.c +++ b/sys/contrib/dev/acpica/compiler/dttable.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -454,7 +454,7 @@ DtCompileCsrt ( UINT32 GroupLength; - /* Sub-tables (Resource Groups) */ + /* Subtables (Resource Groups) */ while (*PFieldList) { @@ -518,6 +518,156 @@ DtCompileCsrt ( } +/****************************************************************************** + * + * FUNCTION: DtCompileDbg2 + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DBG2. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDbg2 ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 SubtableCount; + ACPI_DBG2_HEADER *Dbg2Header; + ACPI_DBG2_DEVICE *DeviceInfo; + UINT16 CurrentOffset; + UINT32 i; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Main table fields */ + + Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer); + Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF ( + ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header); + + SubtableCount = Dbg2Header->InfoCount; + DtPushSubtable (Subtable); + + /* Process all Device Information subtables (Count = InfoCount) */ + + while (*PFieldList && SubtableCount) + { + /* Subtable: Debug Device Information */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Device, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DeviceInfo = ACPI_CAST_PTR (ACPI_DBG2_DEVICE, Subtable->Buffer); + CurrentOffset = (UINT16) sizeof (ACPI_DBG2_DEVICE); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + ParentTable = DtPeekSubtable (); + + /* BaseAddressRegister GAS array (Required, size is RegisterCount) */ + + DeviceInfo->BaseAddressOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (ACPI_GENERIC_ADDRESS); + DtInsertSubtable (ParentTable, Subtable); + } + + /* AddressSize array (Required, size = RegisterCount) */ + + DeviceInfo->AddressSizeOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (UINT32); + DtInsertSubtable (ParentTable, Subtable); + } + + /* NamespaceString device identifier (Required, size = NamePathLength) */ + + DeviceInfo->NamepathOffset = CurrentOffset; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header */ + + DeviceInfo->NamepathLength = (UINT16) Subtable->Length; + CurrentOffset += (UINT16) DeviceInfo->NamepathLength; + DtInsertSubtable (ParentTable, Subtable); + + /* OemData - Variable-length data (Optional, size = OemDataLength) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2OemData, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header (zeros if no OEM data present) */ + + DeviceInfo->OemDataOffset = 0; + DeviceInfo->OemDataLength = 0; + + /* Optional subtable (OemData) */ + + if (Subtable && Subtable->Length) + { + DeviceInfo->OemDataOffset = CurrentOffset; + DeviceInfo->OemDataLength = (UINT16) Subtable->Length; + + DtInsertSubtable (ParentTable, Subtable); + } + + SubtableCount--; + DtPopSubtable (); /* Get next Device Information subtable */ + } + + DtPopSubtable (); + return (AE_OK); +} + + /****************************************************************************** * * FUNCTION: DtCompileDmar @@ -586,16 +736,21 @@ DtCompileDmar ( InfoTable = AcpiDmTableInfoDmar1; break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: InfoTable = AcpiDmTableInfoDmar2; break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: InfoTable = AcpiDmTableInfoDmar3; break; + case ACPI_DMAR_TYPE_NAMESPACE: + + InfoTable = AcpiDmTableInfoDmar4; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); @@ -612,10 +767,20 @@ DtCompileDmar ( ParentTable = DtPeekSubtable (); DtInsertSubtable (ParentTable, Subtable); + + /* + * Optional Device Scope subtables + */ + if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || + (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) + { + /* These types do not support device scopes */ + + DtPopSubtable (); + continue; + } + DtPushSubtable (Subtable); - - /* Optional Device Scope subtables */ - DeviceScopeLength = DmarHeader->Length - Subtable->Length - ParentTable->Length; while (DeviceScopeLength) @@ -788,6 +953,125 @@ DtCompileFadt ( return (AE_OK); } +/****************************************************************************** + * + * FUNCTION: DtCompileGtdt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile GTDT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileGtdt ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *GtdtHeader; + ACPI_DMTABLE_INFO *InfoTable; + UINT32 GtCount; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdtHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + GtdtHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + InfoTable = AcpiDmTableInfoGtdt0; + break; + + case ACPI_GTDT_TYPE_WATCHDOG: + + InfoTable = AcpiDmTableInfoGtdt1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "GTDT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* + * Additional GT block subtable data + */ + + switch (GtdtHeader->Type) + { + case ACPI_GTDT_TYPE_TIMER_BLOCK: + + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK, + Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount; + while (GtCount) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt0a, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + + DtInsertSubtable (ParentTable, Subtable); + GtCount--; + } + DtPopSubtable (); + break; + + default: + + break; + } + + DtPopSubtable (); + } + + return (AE_OK); +} + /****************************************************************************** * @@ -1152,6 +1436,87 @@ DtCompileIvrs ( } +/****************************************************************************** + * + * FUNCTION: DtCompileLpit + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile LPIT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileLpit ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_LPIT_HEADER *LpitHeader; + + + /* Note: Main table consists only of the standard ACPI table header */ + + while (*PFieldList) + { + SubtableStart = *PFieldList; + + /* LPIT Subtable header */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoLpitHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + LpitHeader = ACPI_CAST_PTR (ACPI_LPIT_HEADER, Subtable->Buffer); + + switch (LpitHeader->Type) + { + case ACPI_LPIT_TYPE_NATIVE_CSTATE: + + InfoTable = AcpiDmTableInfoLpit0; + break; + + case ACPI_LPIT_TYPE_SIMPLE_IO: + + InfoTable = AcpiDmTableInfoLpit1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT"); + return (AE_ERROR); + } + + /* LPIT Subtable */ + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + /****************************************************************************** * * FUNCTION: DtCompileMadt @@ -1270,6 +1635,16 @@ DtCompileMadt ( InfoTable = AcpiDmTableInfoMadt12; break; + case ACPI_MADT_TYPE_GENERIC_MSI_FRAME: + + InfoTable = AcpiDmTableInfoMadt13; + break; + + case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR: + + InfoTable = AcpiDmTableInfoMadt14; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); @@ -1503,6 +1878,90 @@ DtCompileMtmr ( } +/****************************************************************************** + * + * FUNCTION: DtCompilePcct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile PCCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompilePcct ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *PcctHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (PcctHeader->Type) + { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + case ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct1; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + /****************************************************************************** * * FUNCTION: DtCompilePmtt @@ -1961,6 +2420,11 @@ DtCompileSrat ( InfoTable = AcpiDmTableInfoSrat2; break; + case ACPI_SRAT_TYPE_GICC_AFFINITY: + + InfoTable = AcpiDmTableInfoSrat3; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c index ca66d16daa1b..cb3cafde7f7b 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.c +++ b/sys/contrib/dev/acpica/compiler/dttemplate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -187,6 +187,12 @@ DtCreateTemplates ( } Status = DtCreateOneTemplate (Signature, TableData); + + + /* Shutdown ACPICA subsystem */ + + (void) AcpiTerminate (); + CmDeleteCaches (); return (Status); } @@ -397,6 +403,5 @@ DtCreateOneTemplate ( Cleanup: fclose (File); AcpiOsRedirectOutput (stdout); - ACPI_FREE (DisasmFilename); return (Status); } diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h index f620abd21dee..4011f087287b 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.h +++ b/sys/contrib/dev/acpica/compiler/dttemplate.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -174,6 +174,33 @@ const unsigned char TemplateCsrt[] = 0x43,0x48,0x41,0x37 /* 00000148 "CHA7" */ }; +const unsigned char TemplateDbg2[] = +{ + 0x44,0x42,0x47,0x32,0xB2,0x00,0x00,0x00, /* 00000000 "DBG2...." */ + 0x01,0xBA,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x2C,0x00,0x00,0x00, /* 00000020 "... ,..." */ + 0x02,0x00,0x00,0x00,0xEE,0x3F,0x00,0x02, /* 00000028 ".....?.." */ + 0x09,0x00,0x36,0x00,0x00,0x00,0x00,0x00, /* 00000030 "..6....." */ + 0x00,0x80,0x00,0x00,0x00,0x00,0x16,0x00, /* 00000038 "........" */ + 0x2E,0x00,0x01,0x32,0x00,0x03,0x88,0x77, /* 00000040 "...2...w" */ + 0x66,0x55,0x44,0x33,0x22,0x11,0x01,0x64, /* 00000048 "fUD3"..d" */ + 0x00,0x04,0x11,0x00,0xFF,0xEE,0xDD,0xCC, /* 00000050 "........" */ + 0xBB,0xAA,0x10,0x32,0x54,0x76,0x98,0xBA, /* 00000058 "...2Tv.." */ + 0xDC,0xFE,0x4D,0x79,0x44,0x65,0x76,0x69, /* 00000060 "..MyDevi" */ + 0x63,0x65,0x00,0xEE,0x47,0x00,0x01,0x11, /* 00000068 "ce..G..." */ + 0x00,0x26,0x00,0x10,0x00,0x37,0x00,0x00, /* 00000070 ".&...7.." */ + 0x80,0x00,0x00,0x00,0x00,0x16,0x00,0x22, /* 00000078 "......."" */ + 0x00,0x01,0x64,0x00,0x04,0x11,0x00,0xFF, /* 00000080 "..d....." */ + 0xEE,0xDD,0xCC,0xBB,0xAA,0x98,0xBA,0xDC, /* 00000088 "........" */ + 0xFE,0x5C,0x5C,0x5F,0x53,0x42,0x5F,0x2E, /* 00000090 ".\\_SB_." */ + 0x50,0x43,0x49,0x30,0x2E,0x44,0x42,0x47, /* 00000098 "PCI0.DBG" */ + 0x50,0x00,0x41,0x42,0x43,0x44,0x45,0x46, /* 000000A0 "P.ABCDEF" */ + 0x47,0x48,0x49,0x50,0x51,0x52,0x53,0x54, /* 000000A8 "GHIPQRST" */ + 0x55,0x56 /* 000000B0 "UV" */ +}; + const unsigned char TemplateDbgp[] = { 0x44,0x42,0x47,0x50,0x34,0x00,0x00,0x00, /* 00000000 "DBGP4..." */ @@ -353,10 +380,10 @@ const unsigned char TemplateFacs[] = const unsigned char TemplateFadt[] = { 0x46,0x41,0x43,0x50,0x0C,0x01,0x00,0x00, /* 00000000 "FACP...." */ - 0x05,0x18,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x05,0x64,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".dINTEL " */ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x11,0x11,0x20,0x01,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -368,7 +395,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000070 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00, /* 00000080 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02, /* 00000090 "..... .." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ @@ -379,7 +406,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00, /* 000000C0 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ 0x01,0x20,0x00,0x03,0x01,0x00,0x00,0x00, /* 000000D0 ". ......" */ - 0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x01, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x01, /* 000000D8 ".....@.." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 000000F0 "........" */ @@ -407,16 +434,34 @@ const unsigned char TemplateFpdt[] = const unsigned char TemplateGtdt[] = { - 0x47,0x54,0x44,0x54,0x50,0x00,0x00,0x00, /* 00000000 "GTDTP..." */ - 0x01,0xF1,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ - 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000028 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000048 "........" */ + 0x47,0x54,0x44,0x54,0xe0,0x00,0x00,0x00, /* 00000000 "GTDT...." */ + 0x02,0xb0,0x4c,0x49,0x4e,0x41,0x52,0x4f, /* 00000008 "..LINARO" */ + 0x52,0x54,0x53,0x4d,0x56,0x45,0x56,0x38, /* 00000010 "RTSMVEV8" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x1d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ + 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */ + 0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */ + 0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00, /* 00000058 "....`..." */ + 0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 ".d......" */ + 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00, /* 00000068 "........" */ + 0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x1c,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000d8 "........" */ }; const unsigned char TemplateHest[] = @@ -521,41 +566,75 @@ const unsigned char TemplateIvrs[] = 0x00,0x00,0x00,0x00 /* 000000B8 "...." */ }; -/* MADT with ACPI 5.0 subtables */ +const unsigned char TemplateLpit[] = +{ + 0x4C,0x50,0x49,0x54,0xB4,0x00,0x00,0x00, /* 00000000 "LPIT...." */ + 0x01,0x20,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ". INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x25,0x03,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "%.. ...." */ + 0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "8......." */ + 0x00,0x00,0x00,0x00,0x7F,0x01,0x02,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x20,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ". ......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000058 "........" */ + 0x58,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000060 "X......." */ + 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */ + 0x00,0x00,0x00,0x00 /* 000000B0 "...." */ +}; + +/* MADT with ACPI 5.1 subtables */ const unsigned char TemplateMadt[] = { - 0x41,0x50,0x49,0x43,0xF6,0x00,0x00,0x00, /* 00000000 "APIC...." */ - 0x01,0xB0,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ - 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x06,0x11,0x20,0x00,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x41,0x50,0x49,0x43,0x2a,0x01,0x00,0x00, /* 00000000 "APIC*..." */ + 0x04,0x34,0x49,0x4e,0x54,0x45,0x4c,0x20, /* 00000008 ".4INTEL " */ + 0x54,0x45,0x4d,0x50,0x4c,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */ + 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ - 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x0c,0x01,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ - 0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ - 0x00,0x00,0x03,0x08,0x0D,0x00,0x01,0x00, /* 00000048 "........" */ + 0x02,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x03,0x08,0x0d,0x00,0x01,0x00, /* 00000048 "........" */ 0x00,0x00,0x04,0x06,0x00,0x05,0x00,0x01, /* 00000050 "........" */ - 0x05,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x05,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */ 0x00,0x00,0x00,0x00,0x06,0x10,0x00,0x00, /* 00000060 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00, /* 00000070 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000078 "........" */ - 0x00,0x00,0x00,0x00,0x5C,0x43,0x50,0x55, /* 00000080 "....\CPU" */ + 0x00,0x00,0x00,0x00,0x5c,0x43,0x50,0x55, /* 00000080 "....\CPU" */ 0x30,0x00,0x08,0x10,0x05,0x00,0x00,0x00, /* 00000088 "0......." */ 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */ 0x00,0x00,0x09,0x10,0x00,0x00,0x00,0x00, /* 00000098 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ - 0x00,0x00,0x0A,0x0C,0x05,0x00,0x00,0x00, /* 000000A8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x28, /* 000000B0 ".......(" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18, /* 000000D8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00 /* 000000F0 "......" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */ + 0x00,0x00,0x0a,0x0c,0x05,0x00,0x00,0x00, /* 000000a8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x4c, /* 000000b0 ".......L" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000b8 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000c0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f8 "........" */ + 0x00,0x00,0x0e,0x10,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */ + 0x00,0x00,0x0c,0x18,0x00,0x00,0x00,0x00, /* 00000110 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */ + 0x00,0x00 /* 00000128 ".. " */ }; const unsigned char TemplateMcfg[] = @@ -646,6 +725,32 @@ const unsigned char TemplateMtmr[] = 0x00,0x00,0x00,0x00 /* 00000048 "...." */ }; +const unsigned char TemplatePcct[] = +{ + 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ + 0x01,0xCF,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x27,0x06,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "'.. ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ".>......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x32,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ".2......" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, /* 00000058 "........" */ + 0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00, /* 00000060 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x3E, /* 00000068 ".......>" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x32, /* 00000080 ".......2" */ + 0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */ + 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* 00000098 "........" */ + 0xFF,0xFF,0x01,0x00,0x00,0x00,0x01,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x01,0x00 /* 000000A8 "...." */ +}; + const unsigned char TemplatePmtt[] = { 0x50,0x4D,0x54,0x54,0xB4,0x00,0x00,0x00, /* 00000000 "PMTT...." */ @@ -844,10 +949,10 @@ const unsigned char TemplateSpcr[] = const unsigned char TemplateSpmi[] = { 0x53,0x50,0x4D,0x49,0x41,0x00,0x00,0x00, /* 00000000 "SPMIA..." */ - 0x04,0xED,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x04,0x00,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x28,0x05,0x10,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x14,0x01,0x14,0x20,0x00,0x01,0x00,0x00, /* 00000020 "... ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -856,11 +961,11 @@ const unsigned char TemplateSpmi[] = const unsigned char TemplateSrat[] = { - 0x53,0x52,0x41,0x54,0x80,0x00,0x00,0x00, /* 00000000 "SRAT...." */ - 0x03,0x5A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".ZINTEL " */ - 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x53,0x52,0x41,0x54,0x92,0x00,0x00,0x00, /* 00000000 "SRAT...." */ + 0x03,0x50,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".PINTEL " */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x28,0x05,0x10,0x20,0x01,0x00,0x00,0x00, /* 00000020 "(.. ...." */ + 0x24,0x07,0x14,0x20,0x01,0x00,0x00,0x00, /* 00000020 "$.. ...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -871,7 +976,10 @@ const unsigned char TemplateSrat[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ 0x02,0x18,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000070 "........" */ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00 /* 00000090 ".." */ }; const unsigned char TemplateTcpa[] = diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c index d7ef56eff1b5..1cd281a86141 100644 --- a/sys/contrib/dev/acpica/compiler/dtutils.c +++ b/sys/contrib/dev/acpica/compiler/dtutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,7 +77,7 @@ DtSum ( void DtError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage) { @@ -124,7 +124,7 @@ DtError ( void DtNameError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage) { @@ -177,7 +177,7 @@ DtNameError ( void DtFatal ( - UINT8 MessageId, + UINT16 MessageId, DT_FIELD *FieldObject, char *ExtraMessage) { @@ -284,36 +284,6 @@ DtStrtoul64 ( } -/****************************************************************************** - * - * FUNCTION: DtGetFileSize - * - * PARAMETERS: Handle - Open file handler - * - * RETURN: Current file size - * - * DESCRIPTION: Get the current size of a file. Seek to the EOF and get the - * offset. Seek back to the original location. - * - *****************************************************************************/ - -UINT32 -DtGetFileSize ( - FILE *Handle) -{ - int CurrentOffset; - int LastOffset; - - - CurrentOffset = ftell (Handle); - fseek (Handle, 0, SEEK_END); - LastOffset = ftell (Handle); - fseek (Handle, CurrentOffset, SEEK_SET); - - return ((UINT32) LastOffset); -} - - /****************************************************************************** * * FUNCTION: DtGetFieldValue @@ -531,7 +501,9 @@ DtGetFieldLength ( case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: + case ACPI_DMT_GTDT: case ACPI_DMT_MADT: + case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: @@ -541,6 +513,7 @@ DtGetFieldLength ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; @@ -562,6 +535,7 @@ DtGetFieldLength ( case ACPI_DMT_NAME4: case ACPI_DMT_SLIC: case ACPI_DMT_SIG: + case ACPI_DMT_LPIT: ByteLength = 4; break; @@ -871,39 +845,151 @@ DtWalkTableTree ( } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: DtFreeFieldList + * FUNCTION: UtSubtableCacheCalloc + * + * PARAMETERS: None + * + * RETURN: Pointer to the buffer. Aborts on allocation failure + * + * DESCRIPTION: Allocate a subtable object buffer. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +DT_SUBTABLE * +UtSubtableCacheCalloc ( + void) +{ + ASL_CACHE_INFO *Cache; + + + if (Gbl_SubtableCacheNext >= Gbl_SubtableCacheLast) + { + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_SubtableCacheList; + Gbl_SubtableCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_SubtableCacheNext = ACPI_CAST_PTR (DT_SUBTABLE, Cache->Buffer); + Gbl_SubtableCacheLast = Gbl_SubtableCacheNext + ASL_SUBTABLE_CACHE_SIZE; + } + + Gbl_SubtableCount++; + return (Gbl_SubtableCacheNext++); +} + + +/******************************************************************************* + * + * FUNCTION: UtFieldCacheCalloc + * + * PARAMETERS: None + * + * RETURN: Pointer to the buffer. Aborts on allocation failure + * + * DESCRIPTION: Allocate a field object buffer. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +DT_FIELD * +UtFieldCacheCalloc ( + void) +{ + ASL_CACHE_INFO *Cache; + + + if (Gbl_FieldCacheNext >= Gbl_FieldCacheLast) + { + /* Allocate a new buffer */ + + Cache = UtLocalCalloc (sizeof (Cache->Next) + + (sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE)); + + /* Link new cache buffer to head of list */ + + Cache->Next = Gbl_FieldCacheList; + Gbl_FieldCacheList = Cache; + + /* Setup cache management pointers */ + + Gbl_FieldCacheNext = ACPI_CAST_PTR (DT_FIELD, Cache->Buffer); + Gbl_FieldCacheLast = Gbl_FieldCacheNext + ASL_FIELD_CACHE_SIZE; + } + + Gbl_FieldCount++; + return (Gbl_FieldCacheNext++); +} + + +/******************************************************************************* + * + * FUNCTION: DtDeleteCaches * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Free the field list + * DESCRIPTION: Delete all local cache buffer blocks * - *****************************************************************************/ + ******************************************************************************/ void -DtFreeFieldList ( +DtDeleteCaches ( void) { - DT_FIELD *Field = Gbl_FieldList; - DT_FIELD *NextField; + UINT32 BufferCount; + ASL_CACHE_INFO *Next; - /* Walk and free entire field list */ + /* Field cache */ - while (Field) + BufferCount = 0; + while (Gbl_FieldCacheList) { - NextField = Field->Next; /* Save link */ - - if (!(Field->Flags & DT_FIELD_NOT_ALLOCATED)) - { - ACPI_FREE (Field->Name); - ACPI_FREE (Field->Value); - } - - ACPI_FREE (Field); - Field = NextField; + Next = Gbl_FieldCacheList->Next; + ACPI_FREE (Gbl_FieldCacheList); + Gbl_FieldCacheList = Next; + BufferCount++; } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Fields, Buffer size: %u fields (%u bytes), %u Buffers\n", + Gbl_FieldCount, ASL_FIELD_CACHE_SIZE, + (sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE), BufferCount); + + Gbl_FieldCount = 0; + Gbl_FieldCacheNext = NULL; + Gbl_FieldCacheLast = NULL; + + /* Subtable cache */ + + BufferCount = 0; + while (Gbl_SubtableCacheList) + { + Next = Gbl_SubtableCacheList->Next; + ACPI_FREE (Gbl_SubtableCacheList); + Gbl_SubtableCacheList = Next; + BufferCount++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, + "%u Subtables, Buffer size: %u subtables (%u bytes), %u Buffers\n", + Gbl_SubtableCount, ASL_SUBTABLE_CACHE_SIZE, + (sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE), BufferCount); + + Gbl_SubtableCount = 0; + Gbl_SubtableCacheNext = NULL; + Gbl_SubtableCacheLast = NULL; } diff --git a/sys/contrib/dev/acpica/compiler/preprocess.h b/sys/contrib/dev/acpica/compiler/preprocess.h index ae32a8c47f71..532203474af4 100644 --- a/sys/contrib/dev/acpica/compiler/preprocess.h +++ b/sys/contrib/dev/acpica/compiler/preprocess.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -257,7 +257,7 @@ PrGetNextToken ( void PrError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 Column); void diff --git a/sys/contrib/dev/acpica/compiler/prexpress.c b/sys/contrib/dev/acpica/compiler/prexpress.c index c0aa565b4e57..886da89c477e 100644 --- a/sys/contrib/dev/acpica/compiler/prexpress.c +++ b/sys/contrib/dev/acpica/compiler/prexpress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prmacros.c b/sys/contrib/dev/acpica/compiler/prmacros.c index d76de8b845ac..ad7dfa0a9930 100644 --- a/sys/contrib/dev/acpica/compiler/prmacros.c +++ b/sys/contrib/dev/acpica/compiler/prmacros.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -360,7 +360,7 @@ PrAddMacro ( if (ArgCount >= PR_MAX_MACRO_ARGS) { PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, TokenOffset); - return; + goto ErrorExit; } } @@ -400,7 +400,7 @@ PrAddMacro ( PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, THIS_TOKEN_OFFSET (Token)); - return; + goto ErrorExit; } break; } @@ -432,7 +432,7 @@ PrAddMacro ( THIS_TOKEN_OFFSET (Name)); } - return; + goto ErrorExit; } DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID @@ -451,6 +451,13 @@ PrAddMacro ( DefineInfo->Args = Args; DefineInfo->ArgCount = ArgCount; } + + return; + + +ErrorExit: + ACPI_FREE (Args); + return; } diff --git a/sys/contrib/dev/acpica/compiler/prparser.l b/sys/contrib/dev/acpica/compiler/prparser.l index b580d5771ddc..4fc45127aa6b 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.l +++ b/sys/contrib/dev/acpica/compiler/prparser.l @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y index 391ad3fdd214..c7c1123852b9 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.y +++ b/sys/contrib/dev/acpica/compiler/prparser.y @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c index a3ac0c283a57..ef5d52f65492 100644 --- a/sys/contrib/dev/acpica/compiler/prscan.c +++ b/sys/contrib/dev/acpica/compiler/prscan.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c index 0dbf307f0db7..92d810f6bddf 100644 --- a/sys/contrib/dev/acpica/compiler/prutils.c +++ b/sys/contrib/dev/acpica/compiler/prutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,7 +149,7 @@ PrGetNextToken ( void PrError ( UINT8 Level, - UINT8 MessageId, + UINT16 MessageId, UINT32 Column) { #if 0 @@ -340,7 +340,6 @@ PrOpenIncludeWithPrefix ( if (!IncludeFile) { fprintf (stderr, "Could not open include file %s\n", Pathname); - ACPI_FREE (Pathname); return (NULL); } @@ -393,15 +392,17 @@ PrPushInputFileStack ( /* Reset the global line count and filename */ - Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Filename = + UtStringCacheCalloc (strlen (Filename) + 1); + strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename); + Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; Gbl_PreviousLineNumber = 0; Gbl_CurrentLineNumber = 0; /* Emit a new #line directive for the include file */ - FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", - 1, Filename); + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", 1, Filename); } diff --git a/sys/contrib/dev/acpica/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/components/debugger/dbcmds.c index 921f4289e56c..f28ed2f54e00 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/components/debugger/dbcmds.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -116,7 +115,7 @@ AcpiDbConvertToNode ( Node = ACPI_TO_POINTER (Address); if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", + AcpiOsPrintf ("Address %p is invalid", Node); return (NULL); } @@ -125,7 +124,7 @@ AcpiDbConvertToNode ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", + AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n", Node, AcpiUtGetDescriptorName (Node)); return (NULL); } @@ -139,6 +138,8 @@ AcpiDbConvertToNode ( Node = AcpiDbLocalNsLookup (InString); if (!Node) { + AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n", + InString); Node = AcpiGbl_RootNode; } } @@ -337,7 +338,7 @@ AcpiDbDisplayTableInfo ( /* Header */ - AcpiOsPrintf ("Idx ID Status Type Sig Address Len Header\n"); + AcpiOsPrintf ("Idx ID Status Type TableHeader (Sig, Address, Length)\n"); /* Walk the entire root table list */ @@ -362,35 +363,30 @@ AcpiDbDisplayTableInfo ( switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) { - case ACPI_TABLE_ORIGIN_UNKNOWN: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: - AcpiOsPrintf ("Unknown "); + AcpiOsPrintf ("External/virtual "); break; - case ACPI_TABLE_ORIGIN_MAPPED: + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: - AcpiOsPrintf ("Mapped "); + AcpiOsPrintf ("Internal/physical "); break; - case ACPI_TABLE_ORIGIN_ALLOCATED: + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: - AcpiOsPrintf ("Allocated "); - break; - - case ACPI_TABLE_ORIGIN_OVERRIDE: - - AcpiOsPrintf ("Override "); + AcpiOsPrintf ("Internal/virtual "); break; default: - AcpiOsPrintf ("INVALID "); + AcpiOsPrintf ("INVALID TYPE "); break; } /* Make sure that the table is mapped */ - Status = AcpiTbVerifyTable (TableDesc); + Status = AcpiTbValidateTable (TableDesc); if (ACPI_FAILURE (Status)) { return; @@ -440,8 +436,6 @@ AcpiDbUnloadAcpiTable ( Node = AcpiDbConvertToNode (ObjectName); if (!Node) { - AcpiOsPrintf ("Could not find [%s] in namespace\n", - ObjectName); return; } @@ -830,7 +824,7 @@ AcpiDmTestResourceConversion ( /* Convert internal resource list to external AML resource template */ - Status = AcpiRsCreateAmlResources (ResourceBuffer.Pointer, &NewAml); + Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", @@ -842,8 +836,8 @@ AcpiDmTestResourceConversion ( OriginalAml = ReturnBuffer.Pointer; - AcpiDmCompareAmlResources ( - OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, + AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer, + (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length); /* Cleanup and exit */ @@ -1042,7 +1036,7 @@ AcpiDbDeviceResources ( } EndCrs: - ACPI_FREE_BUFFER (ReturnBuffer); + ACPI_FREE (ReturnBuffer.Pointer); } @@ -1192,14 +1186,25 @@ AcpiDbGenerateGpe ( char *GpeArg, char *BlockArg) { - UINT32 BlockNumber; + UINT32 BlockNumber = 0; UINT32 GpeNumber; ACPI_GPE_EVENT_INFO *GpeEventInfo; - GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); - BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); + GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); + /* + * If no block arg, or block arg == 0 or 1, use the FADT-defined + * GPE blocks. + */ + if (BlockArg) + { + BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); + if (BlockNumber == 1) + { + BlockNumber = 0; + } + } GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), GpeNumber); diff --git a/sys/contrib/dev/acpica/components/debugger/dbconvert.c b/sys/contrib/dev/acpica/components/debugger/dbconvert.c index 6daa753a7835..1b23002428fd 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbconvert.c +++ b/sys/contrib/dev/acpica/components/debugger/dbconvert.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/debugger/dbdisply.c b/sys/contrib/dev/acpica/components/debugger/dbdisply.c index 62edea0e4d67..988ab83d3de0 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica/components/debugger/dbdisply.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -303,6 +302,10 @@ AcpiDbDecodeAndDisplayObject ( /* Is not a recognizeable object */ + AcpiOsPrintf ( + "Not a known ACPI internal object, descriptor type %2.2X\n", + ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)); + Size = 16; if (AcpiOsReadable (ObjPtr, 64)) { diff --git a/sys/contrib/dev/acpica/components/debugger/dbexec.c b/sys/contrib/dev/acpica/components/debugger/dbexec.c index 2566e2dbcc64..da907842e062 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbexec.c +++ b/sys/contrib/dev/acpica/components/debugger/dbexec.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -62,7 +61,7 @@ AcpiDbExecuteMethod ( ACPI_DB_METHOD_INFO *Info, ACPI_BUFFER *ReturnObj); -static void +static ACPI_STATUS AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info); @@ -237,10 +236,15 @@ AcpiDbExecuteMethod ( * ******************************************************************************/ -static void +static ACPI_STATUS AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info) { + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (DbExecuteSetup); + /* Catenate the current scope to the supplied name */ @@ -248,10 +252,21 @@ AcpiDbExecuteSetup ( if ((Info->Name[0] != '\\') && (Info->Name[0] != '/')) { - ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); + if (AcpiUtSafeStrcat (Info->Pathname, sizeof (Info->Pathname), + AcpiGbl_DbScopeBuf)) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; + } + } + + if (AcpiUtSafeStrcat (Info->Pathname, sizeof (Info->Pathname), + Info->Name)) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; } - ACPI_STRCAT (Info->Pathname, Info->Name); AcpiDbPrepNamestring (Info->Pathname); AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); @@ -269,6 +284,13 @@ AcpiDbExecuteSetup ( AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); } + + return (AE_OK); + +ErrorExit: + + ACPI_EXCEPTION ((AE_INFO, Status, "During setup for method execution")); + return (Status); } @@ -429,7 +451,12 @@ AcpiDbExecute ( ReturnObj.Pointer = NULL; ReturnObj.Length = ACPI_ALLOCATE_BUFFER; - AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + Status = AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (NameString); + return; + } /* Get the NS node, determines existence also */ @@ -729,7 +756,11 @@ AcpiDbCreateExecutionThreads ( AcpiDbUint32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); - AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + Status = AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); + if (ACPI_FAILURE (Status)) + { + goto CleanupAndExit; + } /* Get the NS node, determines existence also */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/components/debugger/dbfileio.c index 05fa4e7c9e2e..579d2acd5dd7 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbfileio.c +++ b/sys/contrib/dev/acpica/components/debugger/dbfileio.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,48 +42,18 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include - -#ifdef ACPI_APPLICATION #include -#endif - -#ifdef ACPI_ASL_COMPILER -#include -#endif #if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbfileio") -/* - * NOTE: this is here for lack of a better place. It is used in all - * flavors of the debugger, need LCD file - */ -#ifdef ACPI_APPLICATION -#include -FILE *AcpiGbl_DebugFile = NULL; -#endif - - #ifdef ACPI_DEBUGGER -/* Local prototypes */ - -#ifdef ACPI_APPLICATION - -static ACPI_STATUS -AcpiDbCheckTextModeCorruption ( - UINT8 *Table, - UINT32 TableLength, - UINT32 FileLength); - -#endif - /******************************************************************************* * * FUNCTION: AcpiDbCloseDebugFile @@ -152,242 +122,7 @@ AcpiDbOpenDebugFile ( #ifdef ACPI_APPLICATION -/******************************************************************************* - * - * FUNCTION: AcpiDbCheckTextModeCorruption - * - * PARAMETERS: Table - Table buffer - * TableLength - Length of table from the table header - * FileLength - Length of the file that contains the table - * - * RETURN: Status - * - * DESCRIPTION: Check table for text mode file corruption where all linefeed - * characters (LF) have been replaced by carriage return linefeed - * pairs (CR/LF). - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbCheckTextModeCorruption ( - UINT8 *Table, - UINT32 TableLength, - UINT32 FileLength) -{ - UINT32 i; - UINT32 Pairs = 0; - - - if (TableLength != FileLength) - { - ACPI_WARNING ((AE_INFO, - "File length (0x%X) is not the same as the table length (0x%X)", - FileLength, TableLength)); - } - - /* Scan entire table to determine if each LF has been prefixed with a CR */ - - for (i = 1; i < FileLength; i++) - { - if (Table[i] == 0x0A) - { - if (Table[i - 1] != 0x0D) - { - /* The LF does not have a preceding CR, table not corrupted */ - - return (AE_OK); - } - else - { - /* Found a CR/LF pair */ - - Pairs++; - } - i++; - } - } - - if (!Pairs) - { - return (AE_OK); - } - - /* - * Entire table scanned, each CR is part of a CR/LF pair -- - * meaning that the table was treated as a text file somewhere. - * - * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the - * original table are left untouched by the text conversion process -- - * meaning that we cannot simply replace CR/LF pairs with LFs. - */ - AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); - AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); - AcpiOsPrintf ("Table cannot be repaired!\n"); - return (AE_BAD_VALUE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbReadTable - * - * PARAMETERS: fp - File that contains table - * Table - Return value, buffer with table - * TableLength - Return value, length of table - * - * RETURN: Status - * - * DESCRIPTION: Load the DSDT from the file pointer - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiDbReadTable ( - FILE *fp, - ACPI_TABLE_HEADER **Table, - UINT32 *TableLength) -{ - ACPI_TABLE_HEADER TableHeader; - UINT32 Actual; - ACPI_STATUS Status; - UINT32 FileSize; - BOOLEAN StandardHeader = TRUE; - - - /* Get the file size */ - - fseek (fp, 0, SEEK_END); - FileSize = (UINT32) ftell (fp); - fseek (fp, 0, SEEK_SET); - - if (FileSize < 4) - { - return (AE_BAD_HEADER); - } - - /* Read the signature */ - - if (fread (&TableHeader, 1, 4, fp) != 4) - { - AcpiOsPrintf ("Could not read the table signature\n"); - return (AE_BAD_HEADER); - } - - fseek (fp, 0, SEEK_SET); - - /* The RSDP table does not have standard ACPI header */ - - if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ")) - { - *TableLength = FileSize; - StandardHeader = FALSE; - } - else - { - /* Read the table header */ - - if (fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), fp) != - sizeof (ACPI_TABLE_HEADER)) - { - AcpiOsPrintf ("Could not read the table header\n"); - return (AE_BAD_HEADER); - } - -#if 0 - /* Validate the table header/length */ - - Status = AcpiTbValidateTableHeader (&TableHeader); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Table header is invalid!\n"); - return (Status); - } -#endif - - /* File size must be at least as long as the Header-specified length */ - - if (TableHeader.Length > FileSize) - { - AcpiOsPrintf ( - "TableHeader length [0x%X] greater than the input file size [0x%X]\n", - TableHeader.Length, FileSize); - -#ifdef ACPI_ASL_COMPILER - Status = FlCheckForAscii (fp, NULL, FALSE); - if (ACPI_SUCCESS (Status)) - { - AcpiOsPrintf ("File appears to be ASCII only, must be binary\n", - TableHeader.Length, FileSize); - } -#endif - return (AE_BAD_HEADER); - } - -#ifdef ACPI_OBSOLETE_CODE - /* We only support a limited number of table types */ - - if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) && - !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) && - !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT)) - { - AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", - (char *) TableHeader.Signature); - ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); - return (AE_ERROR); - } -#endif - - *TableLength = TableHeader.Length; - } - - /* Allocate a buffer for the table */ - - *Table = AcpiOsAllocate ((size_t) FileSize); - if (!*Table) - { - AcpiOsPrintf ( - "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", - TableHeader.Signature, *TableLength); - return (AE_NO_MEMORY); - } - - /* Get the rest of the table */ - - fseek (fp, 0, SEEK_SET); - Actual = fread (*Table, 1, (size_t) FileSize, fp); - if (Actual == FileSize) - { - if (StandardHeader) - { - /* Now validate the checksum */ - - Status = AcpiTbVerifyChecksum ((void *) *Table, - ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); - - if (Status == AE_BAD_CHECKSUM) - { - Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table, - FileSize, (*Table)->Length); - return (Status); - } - } - return (AE_OK); - } - - if (Actual > 0) - { - AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", - FileSize, Actual); - return (AE_OK); - } - - AcpiOsPrintf ("Error - could not read the table file\n"); - AcpiOsFree (*Table); - *Table = NULL; - *TableLength = 0; - return (AE_ERROR); -} - +#include /******************************************************************************* * @@ -431,7 +166,7 @@ AeLocalLoadTable ( /* Install the new table into the local data structures */ - Status = AcpiTbInstallTable (&TableInfo); + Status = AcpiTbInitTableDescriptor (&TableInfo); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -462,54 +197,6 @@ AeLocalLoadTable ( return_ACPI_STATUS (Status); } - - -/******************************************************************************* - * - * FUNCTION: AcpiDbReadTableFromFile - * - * PARAMETERS: Filename - File where table is located - * Table - Where a pointer to the table is returned - * - * RETURN: Status - * - * DESCRIPTION: Get an ACPI table from a file - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDbReadTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table) -{ - FILE *File; - UINT32 TableLength; - ACPI_STATUS Status; - - - /* Open the file */ - - File = fopen (Filename, "rb"); - if (!File) - { - AcpiOsPrintf ("Could not open input file %s\n", Filename); - return (AE_ERROR); - } - - /* Get the entire file */ - - fprintf (stderr, "Loading Acpi table from file %s\n", Filename); - Status = AcpiDbReadTable (File, Table, &TableLength); - fclose(File); - - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not get table from the file\n"); - return (Status); - } - - return (AE_OK); - } #endif @@ -537,7 +224,7 @@ AcpiDbGetTableFromFile ( BOOLEAN IsAmlTable = TRUE; - Status = AcpiDbReadTableFromFile (Filename, &Table); + Status = AcpiUtReadTableFromFile (Filename, &Table); if (ACPI_FAILURE (Status)) { return (Status); @@ -568,6 +255,8 @@ AcpiDbGetTableFromFile ( return (Status); } + AcpiTbPrintTableHeader (0, Table); + fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", Table->Signature); diff --git a/sys/contrib/dev/acpica/components/debugger/dbhistry.c b/sys/contrib/dev/acpica/components/debugger/dbhistry.c index 4a97ba4acac7..4a6935bd67d9 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica/components/debugger/dbhistry.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -69,7 +68,7 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; static UINT16 AcpiGbl_LoHistory = 0; static UINT16 AcpiGbl_NumHistory = 0; static UINT16 AcpiGbl_NextHistoryIndex = 0; -static UINT32 AcpiGbl_NextCmdNum = 1; +UINT32 AcpiGbl_NextCmdNum = 1; /******************************************************************************* @@ -94,6 +93,11 @@ AcpiDbAddToHistory ( /* Put command into the next available slot */ CmdLen = (UINT16) ACPI_STRLEN (CommandLine); + if (!CmdLen) + { + return; + } + if (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command != NULL) { BufferLen = (UINT16) ACPI_STRLEN ( @@ -203,8 +207,6 @@ char * AcpiDbGetFromHistory ( char *CommandNumArg) { - UINT32 i; - UINT16 HistoryIndex; UINT32 CmdNum; @@ -218,6 +220,31 @@ AcpiDbGetFromHistory ( CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); } + return (AcpiDbGetHistoryByIndex (CmdNum)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetHistoryByIndex + * + * PARAMETERS: CmdNum - Index of the desired history entry. + * Values are 0...(AcpiGbl_NextCmdNum - 1) + * + * RETURN: Pointer to the retrieved command. Null on error. + * + * DESCRIPTION: Get a command from the history buffer + * + ******************************************************************************/ + +char * +AcpiDbGetHistoryByIndex ( + UINT32 CmdNum) +{ + UINT32 i; + UINT16 HistoryIndex; + + /* Search history buffer */ HistoryIndex = AcpiGbl_LoHistory; @@ -230,6 +257,7 @@ AcpiDbGetFromHistory ( return (AcpiGbl_HistoryBuffer[HistoryIndex].Command); } + /* History buffer is circular */ HistoryIndex++; if (HistoryIndex >= HISTORY_SIZE) diff --git a/sys/contrib/dev/acpica/components/debugger/dbinput.c b/sys/contrib/dev/acpica/components/debugger/dbinput.c index c1a51f89c66d..309bcc351fc6 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbinput.c +++ b/sys/contrib/dev/acpica/components/debugger/dbinput.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -93,7 +92,6 @@ enum AcpiExDebuggerCommands CMD_ALLOCATIONS, CMD_ARGS, CMD_ARGUMENTS, - CMD_BATCH, CMD_BREAKPOINT, CMD_BUSINFO, CMD_CALL, @@ -128,7 +126,7 @@ enum AcpiExDebuggerCommands CMD_METHODS, CMD_NAMESPACE, CMD_NOTIFY, - CMD_OBJECT, + CMD_OBJECTS, CMD_OPEN, CMD_OSI, CMD_OWNER, @@ -147,6 +145,7 @@ enum AcpiExDebuggerCommands CMD_TABLES, CMD_TEMPLATE, CMD_TERMINATE, + CMD_TEST, CMD_THREADS, CMD_TRACE, CMD_TREE, @@ -166,7 +165,6 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"ALLOCATIONS", 0}, {"ARGS", 0}, {"ARGUMENTS", 0}, - {"BATCH", 0}, {"BREAKPOINT", 1}, {"BUSINFO", 0}, {"CALL", 0}, @@ -182,7 +180,7 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"EXIT", 0}, {"FIND", 1}, {"GO", 0}, - {"GPE", 2}, + {"GPE", 1}, {"GPES", 0}, {"HANDLERS", 0}, {"HELP", 0}, @@ -201,7 +199,7 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"METHODS", 0}, {"NAMESPACE", 0}, {"NOTIFY", 2}, - {"OBJECT", 1}, + {"OBJECTS", 1}, {"OPEN", 1}, {"OSI", 0}, {"OWNER", 1}, @@ -220,6 +218,7 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"TABLES", 0}, {"TEMPLATE", 1}, {"TERMINATE", 0}, + {"TEST", 1}, {"THREADS", 3}, {"TRACE", 1}, {"TREE", 0}, @@ -246,8 +245,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Locks", "Current status of internal mutexes\n"}, {1, " Osi [Install|Remove ]", "Display or modify global _OSI list\n"}, {1, " Quit or Exit", "Exit this command\n"}, - {9, " Stats [Allocations|Memory|Misc|", "\n"}, - {1, " Objects|Sizes|Stack|Tables]", "Display namespace and memory statistics\n"}, + {8, " Stats ", "Display namespace and memory statistics\n"}, {1, " Allocations", "Display list of current memory allocations\n"}, {1, " Memory", "Dump internal memory lists\n"}, {1, " Misc", "Namespace search and mutex stats\n"}, @@ -306,7 +304,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {0, "\nHardware Related Commands:", "\n"}, {1, " Event ", "Generate AcpiEvent (Fixed/GPE)\n"}, - {1, " Gpe ", "Simulate a GPE\n"}, + {1, " Gpe [GpeBlockDevice]", "Simulate a GPE\n"}, {1, " Gpes", "Display info on all GPEs\n"}, {1, " Sci", "Generate an SCI\n"}, {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"}, @@ -315,6 +313,11 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = {1, " Close", "Close debug output file\n"}, {1, " Load ", "Load ACPI table from a file\n"}, {1, " Open ", "Open a file for debug output\n"}, + + {0, "\nDebug Test Commands:", "\n"}, + {3, " Test ", "Invoke a debug test\n"}, + {1, " Objects", "Read/write/compare all namespace data objects\n"}, + {1, " Predefined", "Execute all ACPI predefined names (_STA, etc.)\n"}, {0, NULL, NULL} }; @@ -635,7 +638,13 @@ AcpiDbGetLine ( char *This; - ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); + if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf), + InputBuffer)) + { + AcpiOsPrintf ("Buffer overflow while parsing input line (max %u characters)\n", + sizeof (AcpiGbl_DbParsedBuf)); + return (0); + } This = AcpiGbl_DbParsedBuf; for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) @@ -740,6 +749,11 @@ AcpiDbCommandDispatch ( return (AE_CTRL_TERMINATE); } + + /* Add all commands that come here to the history buffer */ + + AcpiDbAddToHistory (InputBuffer); + ParamCount = AcpiDbGetLine (InputBuffer); CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); Temp = 0; @@ -781,11 +795,6 @@ AcpiDbCommandDispatch ( AcpiDbDisplayArguments (); break; - case CMD_BATCH: - - AcpiDbBatchExecute (AcpiGbl_DbArgs[1]); - break; - case CMD_BREAKPOINT: AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); @@ -989,7 +998,7 @@ AcpiDbCommandDispatch ( AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); break; - case CMD_OBJECT: + case CMD_OBJECTS: AcpiUtStrupr (AcpiGbl_DbArgs[1]); Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); @@ -1088,6 +1097,11 @@ AcpiDbCommandDispatch ( /* AcpiInitialize (NULL); */ break; + case CMD_TEST: + + AcpiDbExecuteTest (AcpiGbl_DbArgs[1]); + break; + case CMD_THREADS: AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], @@ -1135,7 +1149,7 @@ AcpiDbCommandDispatch ( case CMD_NOT_FOUND: default: - AcpiOsPrintf ("Unknown Command\n"); + AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]); return (AE_CTRL_TRUE); } @@ -1144,9 +1158,6 @@ AcpiDbCommandDispatch ( Status = AE_CTRL_TRUE; } - /* Add all commands that come here to the history buffer */ - - AcpiDbAddToHistory (InputBuffer); return (Status); } diff --git a/sys/contrib/dev/acpica/components/debugger/dbmethod.c b/sys/contrib/dev/acpica/components/debugger/dbmethod.c index ca2d92bc4272..dc8a09a29a23 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbmethod.c +++ b/sys/contrib/dev/acpica/components/debugger/dbmethod.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -58,16 +57,6 @@ ACPI_MODULE_NAME ("dbmethod") -/* Local prototypes */ - -static ACPI_STATUS -AcpiDbWalkForExecute ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - - /******************************************************************************* * * FUNCTION: AcpiDbSetMethodBreakpoint @@ -190,6 +179,11 @@ AcpiDbSetMethodData ( if (Type == 'N') { Node = AcpiDbConvertToNode (IndexArg); + if (!Node) + { + return; + } + if (Node->Type != ACPI_TYPE_INTEGER) { AcpiOsPrintf ("Can only set Integer nodes\n"); @@ -418,195 +412,4 @@ AcpiDbDisassembleMethod ( 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; - 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; - - if (ObjInfo->Type == ACPI_TYPE_METHOD) - { - /* Setup default parameters (with proper types) */ - - 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++) - { - 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.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 */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbnames.c b/sys/contrib/dev/acpica/components/debugger/dbnames.c index 5ac39fd4546a..4345f3a153cf 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbnames.c +++ b/sys/contrib/dev/acpica/components/debugger/dbnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -171,8 +170,7 @@ AcpiDbSetScope ( goto ErrorExit; } - ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); - ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + AcpiGbl_DbScopeBuf[0] = 0; } else { @@ -184,9 +182,22 @@ AcpiDbSetScope ( { goto ErrorExit; } + } - ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); - ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); + /* Build the final pathname */ + + if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), + Name)) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; + } + + if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), + "\\")) + { + Status = AE_BUFFER_OVERFLOW; + goto ErrorExit; } AcpiGbl_DbScopeNode = Node; diff --git a/sys/contrib/dev/acpica/components/debugger/dbstats.c b/sys/contrib/dev/acpica/components/debugger/dbstats.c index ef236346ed10..9430854200d2 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbstats.c +++ b/sys/contrib/dev/acpica/components/debugger/dbstats.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -401,7 +400,7 @@ AcpiDbDisplayStatistics ( AcpiUtStrupr (TypeArg); Temp = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); - if (Temp == (UINT32) -1) + if (Temp == ACPI_TYPE_NOT_FOUND) { AcpiOsPrintf ("Invalid or unsupported argument\n"); return (AE_OK); diff --git a/sys/contrib/dev/acpica/components/debugger/dbtest.c b/sys/contrib/dev/acpica/components/debugger/dbtest.c new file mode 100644 index 000000000000..fe7a33f76aaa --- /dev/null +++ b/sys/contrib/dev/acpica/components/debugger/dbtest.c @@ -0,0 +1,1138 @@ +/******************************************************************************* + * + * Module Name: dbtest - Various debug-related tests + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 ("dbtest") + + +/* Local prototypes */ + +static void +AcpiDbTestAllObjects ( + void); + +static ACPI_STATUS +AcpiDbTestOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbTestIntegerType ( + ACPI_NAMESPACE_NODE *Node, + UINT32 BitLength); + +static ACPI_STATUS +AcpiDbTestBufferType ( + ACPI_NAMESPACE_NODE *Node, + UINT32 BitLength); + +static ACPI_STATUS +AcpiDbTestStringType ( + ACPI_NAMESPACE_NODE *Node, + UINT32 ByteLength); + +static ACPI_STATUS +AcpiDbReadFromObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE ExpectedType, + ACPI_OBJECT **Value); + +static ACPI_STATUS +AcpiDbWriteToObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT *Value); + +static void +AcpiDbEvaluateAllPredefinedNames ( + char *CountArg); + +static ACPI_STATUS +AcpiDbEvaluateOnePredefinedName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +/* + * Test subcommands + */ +static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] = +{ + {"OBJECTS"}, + {"PREDEFINED"}, + {NULL} /* Must be null terminated */ +}; + +#define CMD_TEST_OBJECTS 0 +#define CMD_TEST_PREDEFINED 1 + +#define BUFFER_FILL_VALUE 0xFF + +/* + * Support for the special debugger read/write control methods. + * These methods are installed into the current namespace and are + * used to read and write the various namespace objects. The point + * is to force the AML interpreter do all of the work. + */ +#define ACPI_DB_READ_METHOD "\\_T98" +#define ACPI_DB_WRITE_METHOD "\\_T99" + +static ACPI_HANDLE ReadHandle = NULL; +static ACPI_HANDLE WriteHandle = NULL; + +/* ASL Definitions of the debugger read/write control methods */ + +#if 0 +DefinitionBlock ("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001) +{ + Method (_T98, 1, NotSerialized) /* Read */ + { + Return (DeRefOf (Arg0)) + } +} +DefinitionBlock ("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001) +{ + Method (_T99, 2, NotSerialized) /* Write */ + { + Store (Arg1, Arg0) + } +} +#endif + +static unsigned char ReadMethodCode[] = +{ + 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */ + 0x02,0xC9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ + 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */ + 0x39,0x38,0x01,0xA4,0x83,0x68 /* 00000028 "98...h" */ +}; + +static unsigned char WriteMethodCode[] = +{ + 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */ + 0x02,0x15,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ + 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */ + 0x39,0x39,0x02,0x70,0x69,0x68 /* 00000028 "99.pih" */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteTest + * + * PARAMETERS: TypeArg - Subcommand + * + * RETURN: None + * + * DESCRIPTION: Execute various debug tests. + * + * Note: Code is prepared for future expansion of the TEST command. + * + ******************************************************************************/ + +void +AcpiDbExecuteTest ( + char *TypeArg) +{ + UINT32 Temp; + + + AcpiUtStrupr (TypeArg); + Temp = AcpiDbMatchArgument (TypeArg, AcpiDbTestTypes); + if (Temp == ACPI_TYPE_NOT_FOUND) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return; + } + + switch (Temp) + { + case CMD_TEST_OBJECTS: + + AcpiDbTestAllObjects (); + break; + + case CMD_TEST_PREDEFINED: + + AcpiDbEvaluateAllPredefinedNames (NULL); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbTestAllObjects + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the + * namespace by reading/writing/comparing all data objects such + * as integers, strings, buffers, fields, buffer fields, etc. + * + ******************************************************************************/ + +static void +AcpiDbTestAllObjects ( + void) +{ + ACPI_STATUS Status; + + + /* Install the debugger read-object control method if necessary */ + + if (!ReadHandle) + { + Status = AcpiInstallMethod (ReadMethodCode); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("%s, Could not install debugger read method\n", + AcpiFormatException (Status)); + return; + } + + Status = AcpiGetHandle (NULL, ACPI_DB_READ_METHOD, &ReadHandle); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not obtain handle for debug method %s\n", + ACPI_DB_READ_METHOD); + return; + } + } + + /* Install the debugger write-object control method if necessary */ + + if (!WriteHandle) + { + Status = AcpiInstallMethod (WriteMethodCode); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("%s, Could not install debugger write method\n", + AcpiFormatException (Status)); + return; + } + + Status = AcpiGetHandle (NULL, ACPI_DB_WRITE_METHOD, &WriteHandle); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not obtain handle for debug method %s\n", + ACPI_DB_WRITE_METHOD); + return; + } + } + + /* Walk the entire namespace, testing each supported named data object */ + + (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbTestOneObject + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Test one namespace object. Supported types are Integer, + * String, Buffer, BufferField, and FieldUnit. All other object + * types are simply ignored. + * + * Note: Support for Packages is not implemented. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbTestOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *RegionObj; + ACPI_OBJECT_TYPE LocalType; + UINT32 BitLength = 0; + UINT32 ByteLength = 0; + ACPI_STATUS Status = AE_OK; + + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ObjDesc = Node->Object; + + /* + * For the supported types, get the actual bit length or + * byte length. Map the type to one of Integer/String/Buffer. + */ + switch (Node->Type) + { + case ACPI_TYPE_INTEGER: + + /* Integer width is either 32 or 64 */ + + LocalType = ACPI_TYPE_INTEGER; + BitLength = AcpiGbl_IntegerBitWidth; + break; + + case ACPI_TYPE_STRING: + + LocalType = ACPI_TYPE_STRING; + ByteLength = ObjDesc->String.Length; + break; + + case ACPI_TYPE_BUFFER: + + LocalType = ACPI_TYPE_BUFFER; + ByteLength = ObjDesc->Buffer.Length; + BitLength = ByteLength * 8; + break; + + case ACPI_TYPE_FIELD_UNIT: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + + LocalType = ACPI_TYPE_INTEGER; + if (ObjDesc) + { + /* + * Returned object will be a Buffer if the field length + * is larger than the size of an Integer (32 or 64 bits + * depending on the DSDT version). + */ + BitLength = ObjDesc->CommonField.BitLength; + ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength); + if (BitLength > AcpiGbl_IntegerBitWidth) + { + LocalType = ACPI_TYPE_BUFFER; + } + } + break; + + default: + + /* Ignore all other types */ + + return (AE_OK); + } + + /* Emit the common prefix: Type:Name */ + + AcpiOsPrintf ("%14s: %4.4s", + AcpiUtGetTypeName (Node->Type), Node->Name.Ascii); + if (!ObjDesc) + { + AcpiOsPrintf (" Ignoring, no attached object\n"); + return (AE_OK); + } + + /* + * Check for unsupported region types. Note: AcpiExec simulates + * access to SystemMemory, SystemIO, PCI_Config, and EC. + */ + switch (Node->Type) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + + RegionObj = ObjDesc->Field.RegionObj; + switch (RegionObj->Region.SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + case ACPI_ADR_SPACE_SYSTEM_IO: + case ACPI_ADR_SPACE_PCI_CONFIG: + case ACPI_ADR_SPACE_EC: + + break; + + default: + + AcpiOsPrintf (" %s space is not supported [%4.4s]\n", + AcpiUtGetRegionName (RegionObj->Region.SpaceId), + RegionObj->Region.Node->Name.Ascii); + return (AE_OK); + } + break; + + default: + break; + } + + /* At this point, we have resolved the object to one of the major types */ + + switch (LocalType) + { + case ACPI_TYPE_INTEGER: + + Status = AcpiDbTestIntegerType (Node, BitLength); + break; + + case ACPI_TYPE_STRING: + + Status = AcpiDbTestStringType (Node, ByteLength); + break; + + case ACPI_TYPE_BUFFER: + + Status = AcpiDbTestBufferType (Node, BitLength); + break; + + default: + + AcpiOsPrintf (" Ignoring, type not implemented (%2.2X)", + LocalType); + break; + } + + switch (Node->Type) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + + RegionObj = ObjDesc->Field.RegionObj; + AcpiOsPrintf (" (%s)", + AcpiUtGetRegionName (RegionObj->Region.SpaceId)); + break; + + default: + break; + } + + AcpiOsPrintf ("\n"); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbTestIntegerType + * + * PARAMETERS: Node - Parent NS node for the object + * BitLength - Actual length of the object. Used for + * support of arbitrary length FieldUnit + * and BufferField objects. + * + * RETURN: Status + * + * DESCRIPTION: Test read/write for an Integer-valued object. Performs a + * write/read/compare of an arbitrary new value, then performs + * a write/read/compare of the original value. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbTestIntegerType ( + ACPI_NAMESPACE_NODE *Node, + UINT32 BitLength) +{ + ACPI_OBJECT *Temp1 = NULL; + ACPI_OBJECT *Temp2 = NULL; + ACPI_OBJECT *Temp3 = NULL; + ACPI_OBJECT WriteValue; + UINT64 ValueToWrite; + ACPI_STATUS Status; + + + if (BitLength > 64) + { + AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength); + return (AE_OK); + } + + /* Read the original value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X", + BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength), + ACPI_FORMAT_UINT64 (Temp1->Integer.Value)); + + ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength); + if (Temp1->Integer.Value == ValueToWrite) + { + ValueToWrite = 0; + } + + /* Write a new value */ + + WriteValue.Type = ACPI_TYPE_INTEGER; + WriteValue.Integer.Value = ValueToWrite; + Status = AcpiDbWriteToObject (Node, &WriteValue); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Ensure that we can read back the new value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Temp2->Integer.Value != ValueToWrite) + { + AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Temp2->Integer.Value), + ACPI_FORMAT_UINT64 (ValueToWrite)); + } + + /* Write back the original value */ + + WriteValue.Integer.Value = Temp1->Integer.Value; + Status = AcpiDbWriteToObject (Node, &WriteValue); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Ensure that we can read back the original value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Temp3->Integer.Value != Temp1->Integer.Value) + { + AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Temp3->Integer.Value), + ACPI_FORMAT_UINT64 (Temp1->Integer.Value)); + } + +Exit: + if (Temp1) {AcpiOsFree (Temp1);} + if (Temp2) {AcpiOsFree (Temp2);} + if (Temp3) {AcpiOsFree (Temp3);} + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbTestBufferType + * + * PARAMETERS: Node - Parent NS node for the object + * BitLength - Actual length of the object. + * + * RETURN: Status + * + * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a + * write/read/compare of an arbitrary new value, then performs + * a write/read/compare of the original value. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbTestBufferType ( + ACPI_NAMESPACE_NODE *Node, + UINT32 BitLength) +{ + ACPI_OBJECT *Temp1 = NULL; + ACPI_OBJECT *Temp2 = NULL; + ACPI_OBJECT *Temp3 = NULL; + UINT8 *Buffer; + ACPI_OBJECT WriteValue; + ACPI_STATUS Status; + UINT32 ByteLength; + UINT32 i; + UINT8 ExtraBits; + + + ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength); + if (ByteLength == 0) + { + AcpiOsPrintf (" Ignoring zero length buffer"); + return (AE_OK); + } + + /* Allocate a local buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (ByteLength); + if (!Buffer) + { + return (AE_NO_MEMORY); + } + + /* Read the original value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Emit a few bytes of the buffer */ + + AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length); + for (i = 0; ((i < 4) && (i < ByteLength)); i++) + { + AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]); + } + AcpiOsPrintf ("... "); + + /* + * Write a new value. + * + * Handle possible extra bits at the end of the buffer. Can + * happen for FieldUnits larger than an integer, but the bit + * count is not an integral number of bytes. Zero out the + * unused bits. + */ + ACPI_MEMSET (Buffer, BUFFER_FILL_VALUE, ByteLength); + ExtraBits = BitLength % 8; + if (ExtraBits) + { + Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits); + } + + WriteValue.Type = ACPI_TYPE_BUFFER; + WriteValue.Buffer.Length = ByteLength; + WriteValue.Buffer.Pointer = Buffer; + + Status = AcpiDbWriteToObject (Node, &WriteValue); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Ensure that we can read back the new value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (ACPI_MEMCMP (Temp2->Buffer.Pointer, Buffer, ByteLength)) + { + AcpiOsPrintf (" MISMATCH 2: New buffer value"); + } + + /* Write back the original value */ + + WriteValue.Buffer.Length = ByteLength; + WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer; + + Status = AcpiDbWriteToObject (Node, &WriteValue); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Ensure that we can read back the original value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (ACPI_MEMCMP (Temp1->Buffer.Pointer, Temp3->Buffer.Pointer, ByteLength)) + { + AcpiOsPrintf (" MISMATCH 3: While restoring original buffer"); + } + +Exit: + ACPI_FREE (Buffer); + if (Temp1) {AcpiOsFree (Temp1);} + if (Temp2) {AcpiOsFree (Temp2);} + if (Temp3) {AcpiOsFree (Temp3);} + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbTestStringType + * + * PARAMETERS: Node - Parent NS node for the object + * ByteLength - Actual length of the object. + * + * RETURN: Status + * + * DESCRIPTION: Test read/write for an String-valued object. Performs a + * write/read/compare of an arbitrary new value, then performs + * a write/read/compare of the original value. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbTestStringType ( + ACPI_NAMESPACE_NODE *Node, + UINT32 ByteLength) +{ + ACPI_OBJECT *Temp1 = NULL; + ACPI_OBJECT *Temp2 = NULL; + ACPI_OBJECT *Temp3 = NULL; + char *ValueToWrite = "Test String from AML Debugger"; + ACPI_OBJECT WriteValue; + ACPI_STATUS Status; + + + /* Read the original value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8), + Temp1->String.Length, Temp1->String.Pointer); + + /* Write a new value */ + + WriteValue.Type = ACPI_TYPE_STRING; + WriteValue.String.Length = ACPI_STRLEN (ValueToWrite); + WriteValue.String.Pointer = ValueToWrite; + + Status = AcpiDbWriteToObject (Node, &WriteValue); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Ensure that we can read back the new value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (ACPI_STRCMP (Temp2->String.Pointer, ValueToWrite)) + { + AcpiOsPrintf (" MISMATCH 2: %s, expecting %s", + Temp2->String.Pointer, ValueToWrite); + } + + /* Write back the original value */ + + WriteValue.String.Length = ACPI_STRLEN (Temp1->String.Pointer); + WriteValue.String.Pointer = Temp1->String.Pointer; + + Status = AcpiDbWriteToObject (Node, &WriteValue); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Ensure that we can read back the original value */ + + Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (ACPI_STRCMP (Temp1->String.Pointer, Temp3->String.Pointer)) + { + AcpiOsPrintf (" MISMATCH 3: %s, expecting %s", + Temp3->String.Pointer, Temp1->String.Pointer); + } + +Exit: + if (Temp1) {AcpiOsFree (Temp1);} + if (Temp2) {AcpiOsFree (Temp2);} + if (Temp3) {AcpiOsFree (Temp3);} + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbReadFromObject + * + * PARAMETERS: Node - Parent NS node for the object + * ExpectedType - Object type expected from the read + * Value - Where the value read is returned + * + * RETURN: Status + * + * DESCRIPTION: Performs a read from the specified object by invoking the + * special debugger control method that reads the object. Thus, + * the AML interpreter is doing all of the work, increasing the + * validity of the test. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbReadFromObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE ExpectedType, + ACPI_OBJECT **Value) +{ + ACPI_OBJECT *RetValue; + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[2]; + ACPI_BUFFER ReturnObj; + ACPI_STATUS Status; + + + Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE; + Params[0].Reference.ActualType = Node->Type; + Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + + ParamObjects.Count = 1; + ParamObjects.Pointer = Params; + + ReturnObj.Length = ACPI_ALLOCATE_BUFFER; + + AcpiGbl_MethodExecuting = TRUE; + Status = AcpiEvaluateObject (ReadHandle, NULL, &ParamObjects, &ReturnObj); + AcpiGbl_MethodExecuting = FALSE; + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not read from object, %s", + AcpiFormatException (Status)); + return (Status); + } + + RetValue = (ACPI_OBJECT *) ReturnObj.Pointer; + + switch (RetValue->Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + /* + * Did we receive the type we wanted? Most important for the + * Integer/Buffer case (when a field is larger than an Integer, + * it should return a Buffer). + */ + if (RetValue->Type != ExpectedType) + { + AcpiOsPrintf (" Type mismatch: Expected %s, Received %s", + AcpiUtGetTypeName (ExpectedType), + AcpiUtGetTypeName (RetValue->Type)); + + return (AE_TYPE); + } + + *Value = RetValue; + break; + + default: + + AcpiOsPrintf (" Unsupported return object type, %s", + AcpiUtGetTypeName (RetValue->Type)); + AcpiOsFree (ReturnObj.Pointer); + + return (AE_TYPE); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWriteToObject + * + * PARAMETERS: Node - Parent NS node for the object + * Value - Value to be written + * + * RETURN: Status + * + * DESCRIPTION: Performs a write to the specified object by invoking the + * special debugger control method that writes the object. Thus, + * the AML interpreter is doing all of the work, increasing the + * validity of the test. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbWriteToObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT *Value) +{ + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[2]; + ACPI_STATUS Status; + + + Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE; + Params[0].Reference.ActualType = Node->Type; + Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + + /* Copy the incoming user parameter */ + + ACPI_MEMCPY (&Params[1], Value, sizeof (ACPI_OBJECT)); + + ParamObjects.Count = 2; + ParamObjects.Pointer = Params; + + AcpiGbl_MethodExecuting = TRUE; + Status = AcpiEvaluateObject (WriteHandle, NULL, &ParamObjects, NULL); + AcpiGbl_MethodExecuting = FALSE; + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not write to object, %s", + AcpiFormatException (Status)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbEvaluateAllPredefinedNames + * + * 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. + * + ******************************************************************************/ + +static void +AcpiDbEvaluateAllPredefinedNames ( + 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, + AcpiDbEvaluateOnePredefinedName, NULL, (void *) &Info, NULL); + + AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbEvaluateOnePredefinedName + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Batch execution module. Currently only executes predefined + * ACPI names. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbEvaluateOnePredefinedName ( + 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; + 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)) + { + ACPI_FREE (Pathname); + return (Status); + } + + ParamObjects.Count = 0; + ParamObjects.Pointer = NULL; + + if (ObjInfo->Type == ACPI_TYPE_METHOD) + { + /* Setup default parameters (with proper types) */ + + 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++) + { + 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.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); +} + +#endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/components/debugger/dbutils.c b/sys/contrib/dev/acpica/components/debugger/dbutils.c index 43036fd02bfb..f321608cea64 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbutils.c +++ b/sys/contrib/dev/acpica/components/debugger/dbutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/debugger/dbxface.c b/sys/contrib/dev/acpica/components/debugger/dbxface.c index c154c450c323..b58ef4ecb6d8 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/components/debugger/dbxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -513,6 +512,10 @@ AcpiDbTerminate ( AcpiOsFree (AcpiGbl_DbBuffer); AcpiGbl_DbBuffer = NULL; } + + /* Ensure that debug output is now disabled */ + + AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT; } diff --git a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c index 32a7ddf21b9f..9e479fb8ad72 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,12 +41,13 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include +#include #include #include #include +#include #ifdef ACPI_DISASSEMBLER @@ -56,12 +57,16 @@ /* Local prototypes */ +static void +AcpiDmUuid ( + ACPI_PARSE_OBJECT *Op); + static void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op); static void -AcpiDmIsEisaIdElement ( +AcpiDmGetHardwareIdType ( ACPI_PARSE_OBJECT *Op); static void @@ -71,6 +76,9 @@ AcpiDmPldBuffer ( UINT32 ByteCount); +#define ACPI_BUFFER_BYTES_PER_LINE 8 + + /******************************************************************************* * * FUNCTION: AcpiDmDisasmByteList @@ -93,6 +101,9 @@ AcpiDmDisasmByteList ( UINT32 ByteCount) { UINT32 i; + UINT32 j; + UINT32 CurrentIndex; + UINT8 BufChar; if (!ByteCount) @@ -100,39 +111,68 @@ AcpiDmDisasmByteList ( return; } - /* Dump the byte list */ - - for (i = 0; i < ByteCount; i++) + for (i = 0; i < ByteCount; i += ACPI_BUFFER_BYTES_PER_LINE) { - /* New line every 8 bytes */ + /* Line indent and offset prefix for each new line */ - if (((i % 8) == 0) && (i < ByteCount)) + AcpiDmIndent (Level); + if (ByteCount > ACPI_BUFFER_BYTES_PER_LINE) { - if (i > 0) + AcpiOsPrintf ("/* %04X */ ", i); + } + + /* Dump the actual hex values */ + + for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++) + { + CurrentIndex = i + j; + if (CurrentIndex >= ByteCount) { - AcpiOsPrintf ("\n"); + /* Dump fill spaces */ + + AcpiOsPrintf (" "); + continue; } - AcpiDmIndent (Level); - if (ByteCount > 8) + AcpiOsPrintf (" 0x%2.2X", ByteData[CurrentIndex]); + + /* Add comma if there are more bytes to display */ + + if (CurrentIndex < (ByteCount - 1)) { - AcpiOsPrintf ("/* %04X */ ", i); + AcpiOsPrintf (","); + } + else + { + AcpiOsPrintf (" "); } } - AcpiOsPrintf (" 0x%2.2X", (UINT32) ByteData[i]); + /* Dump the ASCII equivalents within a comment */ - /* Add comma if there are more bytes to display */ - - if (i < (ByteCount -1)) + AcpiOsPrintf (" /* "); + for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++) { - AcpiOsPrintf (","); - } - } + CurrentIndex = i + j; + if (CurrentIndex >= ByteCount) + { + break; + } - if (Level) - { - AcpiOsPrintf ("\n"); + BufChar = ByteData[CurrentIndex]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } + } + + /* Finished with this line */ + + AcpiOsPrintf (" */\n"); } } @@ -181,6 +221,11 @@ AcpiDmByteList ( AcpiOsPrintf ("\n"); break; + case ACPI_DASM_UUID: + + AcpiDmUuid (Op); + break; + case ACPI_DASM_UNICODE: AcpiDmUnicode (Op); @@ -204,6 +249,137 @@ AcpiDmByteList ( } +/******************************************************************************* + * + * FUNCTION: AcpiDmIsUuidBuffer + * + * PARAMETERS: Op - Buffer Object to be examined + * + * RETURN: TRUE if buffer contains a UUID + * + * DESCRIPTION: Determine if a buffer Op contains a UUID + * + * To help determine whether the buffer is a UUID versus a raw data buffer, + * there a are a couple bytes we can look at: + * + * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx + * + * The variant covered by the UUID specification is indicated by the two most + * significant bits of N being 1 0 (i.e., the hexadecimal N will always be + * 8, 9, A, or B). + * + * The variant covered by the UUID specification has five versions. For this + * variant, the four bits of M indicates the UUID version (i.e., the + * hexadecimal M will be either 1, 2, 3, 4, or 5). + * + ******************************************************************************/ + +BOOLEAN +AcpiDmIsUuidBuffer ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *ByteData; + UINT32 ByteCount; + ACPI_PARSE_OBJECT *SizeOp; + ACPI_PARSE_OBJECT *NextOp; + + + /* Buffer size is the buffer argument */ + + SizeOp = Op->Common.Value.Arg; + + /* Next, the initializer byte list to examine */ + + NextOp = SizeOp->Common.Next; + if (!NextOp) + { + return (FALSE); + } + + /* Extract the byte list info */ + + ByteData = NextOp->Named.Data; + ByteCount = (UINT32) NextOp->Common.Value.Integer; + + /* Byte count must be exactly 16 */ + + if (ByteCount != UUID_BUFFER_LENGTH) + { + return (FALSE); + } + + /* Check for valid "M" and "N" values (see function header above) */ + + if (((ByteData[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */ + ((ByteData[7] & 0xF0) > 0x50) || + ((ByteData[8] & 0xF0) < 0x80) || /* N={8,9,A,B} */ + ((ByteData[8] & 0xF0) > 0xB0)) + { + return (FALSE); + } + + /* Ignore the Size argument in the disassembly of this buffer op */ + + SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmUuid + * + * PARAMETERS: Op - Byte List op containing a UUID + * + * RETURN: None + * + * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string. + * + * Output Format: + * In its canonical form, the UUID is represented by a string containing 32 + * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens. + * The complete form is 8-4-4-4-12 for a total of 36 characters (32 + * alphanumeric characters representing hex digits and 4 hyphens). In bytes, + * 4-2-2-2-6. Example: + * + * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644") + * + ******************************************************************************/ + +static void +AcpiDmUuid ( + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *Data; + const char *Description; + + + Data = ACPI_CAST_PTR (UINT8, Op->Named.Data); + + /* Emit the 36-byte UUID string in the proper format/order */ + + AcpiOsPrintf ( + "\"%2.2x%2.2x%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x-" + "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")", + Data[3], Data[2], Data[1], Data[0], + Data[5], Data[4], + Data[7], Data[6], + Data[8], Data[9], + Data[10], Data[11], Data[12], Data[13], Data[14], Data[15]); + + /* Dump the UUID description string if available */ + + Description = AcpiAhMatchUuid (Data); + if (Description) + { + AcpiOsPrintf (" /* %s */", Description); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmIsUnicodeBuffer @@ -537,19 +713,20 @@ AcpiDmUnicode ( /******************************************************************************* * - * FUNCTION: AcpiDmIsEisaIdElement + * FUNCTION: AcpiDmGetHardwareIdType * * PARAMETERS: Op - Op to be examined * * RETURN: None * - * DESCRIPTION: Determine if an Op (argument to _HID or _CID) can be converted - * to an EISA ID. + * DESCRIPTION: Determine the type of the argument to a _HID or _CID + * 1) Strings are allowed + * 2) If Integer, determine if it is a valid EISAID * ******************************************************************************/ static void -AcpiDmIsEisaIdElement ( +AcpiDmGetHardwareIdType ( ACPI_PARSE_OBJECT *Op) { UINT32 BigEndianId; @@ -557,55 +734,66 @@ AcpiDmIsEisaIdElement ( UINT32 i; - /* The parameter must be either a word or a dword */ - - if ((Op->Common.AmlOpcode != AML_DWORD_OP) && - (Op->Common.AmlOpcode != AML_WORD_OP)) + switch (Op->Common.AmlOpcode) { - return; - } + case AML_STRING_OP: - /* Swap from little-endian to big-endian to simplify conversion */ + /* Mark this string as an _HID/_CID string */ - BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer); + Op->Common.DisasmOpcode = ACPI_DASM_HID_STRING; + break; - /* Create the 3 leading ASCII letters */ + case AML_WORD_OP: + case AML_DWORD_OP: - Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40; - Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40; - Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40; + /* Determine if a Word/Dword is a valid encoded EISAID */ - /* Verify that all 3 are ascii and alpha */ + /* Swap from little-endian to big-endian to simplify conversion */ - for (i = 0; i < 3; i++) - { - if (!ACPI_IS_ASCII (Prefix[i]) || - !ACPI_IS_ALPHA (Prefix[i])) + BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer); + + /* Create the 3 leading ASCII letters */ + + Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40; + Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40; + Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40; + + /* Verify that all 3 are ascii and alpha */ + + for (i = 0; i < 3; i++) { - return; + if (!ACPI_IS_ASCII (Prefix[i]) || + !ACPI_IS_ALPHA (Prefix[i])) + { + return; + } } + + /* Mark this node as convertable to an EISA ID string */ + + Op->Common.DisasmOpcode = ACPI_DASM_EISAID; + break; + + default: + break; } - - /* OK - mark this node as convertable to an EISA ID */ - - Op->Common.DisasmOpcode = ACPI_DASM_EISAID; } /******************************************************************************* * - * FUNCTION: AcpiDmIsEisaId + * FUNCTION: AcpiDmCheckForHardwareId * * PARAMETERS: Op - Op to be examined * * RETURN: None * - * DESCRIPTION: Determine if a Name() Op can be converted to an EisaId. + * DESCRIPTION: Determine if a Name() Op is a _HID/_CID. * ******************************************************************************/ void -AcpiDmIsEisaId ( +AcpiDmCheckForHardwareId ( ACPI_PARSE_OBJECT *Op) { UINT32 Name; @@ -630,7 +818,7 @@ AcpiDmIsEisaId ( if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID)) { - AcpiDmIsEisaIdElement (NextOp); + AcpiDmGetHardwareIdType (NextOp); return; } @@ -645,20 +833,24 @@ AcpiDmIsEisaId ( if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP) { - AcpiDmIsEisaIdElement (NextOp); + AcpiDmGetHardwareIdType (NextOp); return; } - /* _CID with Package: get the package length */ + /* _CID with Package: get the package length, check all elements */ NextOp = AcpiPsGetDepthNext (NULL, NextOp); + if (!NextOp) + { + return; + } /* Don't need to use the length, just walk the peer list */ NextOp = NextOp->Common.Next; while (NextOp) { - AcpiDmIsEisaIdElement (NextOp); + AcpiDmGetHardwareIdType (NextOp); NextOp = NextOp->Common.Next; } } @@ -666,41 +858,38 @@ AcpiDmIsEisaId ( /******************************************************************************* * - * FUNCTION: AcpiDmEisaId + * FUNCTION: AcpiDmDecompressEisaId * * PARAMETERS: EncodedId - Raw encoded EISA ID. * * RETURN: None * - * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String. + * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String + * and emit the correct ASL statement. If the ID is known, emit + * a description of the ID as a comment. * ******************************************************************************/ void -AcpiDmEisaId ( +AcpiDmDecompressEisaId ( UINT32 EncodedId) { - UINT32 BigEndianId; + char IdBuffer[ACPI_EISAID_STRING_SIZE]; + const AH_DEVICE_ID *Info; - /* Swap from little-endian to big-endian to simplify conversion */ + /* Convert EISAID to a string an emit the statement */ - BigEndianId = AcpiUtDwordByteSwap (EncodedId); + AcpiExEisaIdToString (IdBuffer, EncodedId); + AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer); + /* If we know about the ID, emit the description */ - /* Split to form "AAANNNN" string */ - - AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")", - - /* Three Alpha characters (AAA), 5 bits each */ - - (int) ((BigEndianId >> 26) & 0x1F) + 0x40, - (int) ((BigEndianId >> 21) & 0x1F) + 0x40, - (int) ((BigEndianId >> 16) & 0x1F) + 0x40, - - /* Numeric part (NNNN) is simply the lower 16 bits */ - - (UINT32) (BigEndianId & 0xFFFF)); + Info = AcpiAhMatchHardwareId (IdBuffer); + if (Info) + { + AcpiOsPrintf (" /* %s */", Info->Description); + } } #endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c b/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c index b047a6033cc0..9fa82b098a2b 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/disassembler/dmnames.c b/sys/contrib/dev/acpica/components/disassembler/dmnames.c index db7434d8b2f2..e0b8545d7334 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmnames.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/disassembler/dmobject.c b/sys/contrib/dev/acpica/components/disassembler/dmobject.c index 5541e5aa8f89..6df0ff51eef7 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmobject.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmobject.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c index 5435e136df15..e8f2c9752fdc 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,8 @@ #include #include #include +#include +#include #ifdef ACPI_DISASSEMBLER @@ -59,6 +61,159 @@ AcpiDmMatchKeyword ( ACPI_PARSE_OBJECT *Op); +/******************************************************************************* + * + * FUNCTION: AcpiDmDisplayTargetPathname + * + * PARAMETERS: Op - Parse object + * + * RETURN: None + * + * DESCRIPTION: For AML opcodes that have a target operand, display the full + * pathname for the target, in a comment field. Handles Return() + * statements also. + * + ******************************************************************************/ + +void +AcpiDmDisplayTargetPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *PrevOp = NULL; + char *Pathname; + const ACPI_OPCODE_INFO *OpInfo; + + + if (Op->Common.AmlOpcode == AML_RETURN_OP) + { + PrevOp = Op->Asl.Value.Arg; + } + else + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (!(OpInfo->Flags & AML_HAS_TARGET)) + { + return; + } + + /* Target is the last Op in the arg list */ + + NextOp = Op->Asl.Value.Arg; + while (NextOp) + { + PrevOp = NextOp; + NextOp = PrevOp->Asl.Next; + } + } + + if (!PrevOp) + { + return; + } + + /* We must have a namepath AML opcode */ + + if (PrevOp->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) + { + return; + } + + /* A null string is the "no target specified" case */ + + if (!PrevOp->Asl.Value.String) + { + return; + } + + /* No node means "unresolved external reference" */ + + if (!PrevOp->Asl.Node) + { + AcpiOsPrintf (" /* External reference */"); + return; + } + + /* Ignore if path is already from the root */ + + if (*PrevOp->Asl.Value.String == '\\') + { + return; + } + + /* Now: we can get the full pathname */ + + Pathname = AcpiNsGetExternalPathname (PrevOp->Asl.Node); + if (!Pathname) + { + return; + } + + AcpiOsPrintf (" /* %s */", Pathname); + ACPI_FREE (Pathname); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmNotifyDescription + * + * PARAMETERS: Op - Name() parse object + * + * RETURN: None + * + * DESCRIPTION: Emit a description comment for the value associated with a + * Notify() operator. + * + ******************************************************************************/ + +void +AcpiDmNotifyDescription ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *NextOp; + ACPI_NAMESPACE_NODE *Node; + UINT8 NotifyValue; + UINT8 Type = ACPI_TYPE_ANY; + + + /* The notify value is the second argument */ + + NextOp = Op->Asl.Value.Arg; + NextOp = NextOp->Asl.Next; + + switch (NextOp->Common.AmlOpcode) + { + case AML_ZERO_OP: + case AML_ONE_OP: + + NotifyValue = (UINT8) NextOp->Common.AmlOpcode; + break; + + case AML_BYTE_OP: + + NotifyValue = (UINT8) NextOp->Asl.Value.Integer; + break; + + default: + return; + } + + /* + * Attempt to get the namespace node so we can determine the object type. + * Some notify values are dependent on the object type (Device, Thermal, + * or Processor). + */ + Node = Op->Asl.Node; + if (Node) + { + Type = Node->Type; + } + + AcpiOsPrintf (" // %s", AcpiUtGetNotifyName (NotifyValue, Type)); +} + + /******************************************************************************* * * FUNCTION: AcpiDmPredefinedDescription @@ -183,14 +338,11 @@ AcpiDmPredefinedDescription ( /* Match the name in the info table */ - for (Info = AslPredefinedInfo; Info->Name; Info++) + Info = AcpiAhMatchPredefinedName (NameString); + if (Info) { - if (ACPI_COMPARE_NAME (NameString, Info->Name)) - { - AcpiOsPrintf (" // %4.4s: %s", - NameString, ACPI_CAST_PTR (char, Info->Description)); - return; - } + AcpiOsPrintf (" // %4.4s: %s", + NameString, ACPI_CAST_PTR (char, Info->Description)); } #endif @@ -267,14 +419,11 @@ AcpiDmFieldPredefinedDescription ( /* Match the name in the info table */ - for (Info = AslPredefinedInfo; Info->Name; Info++) + Info = AcpiAhMatchPredefinedName (Tag); + if (Info) { - if (ACPI_COMPARE_NAME (Tag, Info->Name)) - { - AcpiOsPrintf (" // %4.4s: %s", Tag, - ACPI_CAST_PTR (char, Info->Description)); - return; - } + AcpiOsPrintf (" // %4.4s: %s", Tag, + ACPI_CAST_PTR (char, Info->Description)); } #endif @@ -527,6 +676,7 @@ AcpiDmDisassembleOneOp ( ACPI_PARSE_OBJECT *Child; ACPI_STATUS Status; UINT8 *Aml; + const AH_DEVICE_ID *IdInfo; if (!Op) @@ -605,7 +755,7 @@ AcpiDmDisassembleOneOp ( if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID) { - AcpiDmEisaId ((UINT32) Op->Common.Value.Integer); + AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer); } else { @@ -617,7 +767,7 @@ AcpiDmDisassembleOneOp ( if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID) { - AcpiDmEisaId ((UINT32) Op->Common.Value.Integer); + AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer); } else { @@ -634,6 +784,19 @@ AcpiDmDisassembleOneOp ( case AML_STRING_OP: AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT16_MAX); + + /* For _HID/_CID strings, attempt to output a descriptive comment */ + + if (Op->Common.DisasmOpcode == ACPI_DASM_HID_STRING) + { + /* If we know about the ID, emit the description */ + + IdInfo = AcpiAhMatchHardwareId (Op->Common.Value.String); + if (IdInfo) + { + AcpiOsPrintf (" /* %s */", IdInfo->Description); + } + } break; case AML_BUFFER_OP: @@ -664,7 +827,12 @@ AcpiDmDisassembleOneOp ( } } - if (AcpiDmIsUnicodeBuffer (Op)) + if (AcpiDmIsUuidBuffer (Op)) + { + Op->Common.DisasmOpcode = ACPI_DASM_UUID; + AcpiOsPrintf ("ToUUID ("); + } + else if (AcpiDmIsUnicodeBuffer (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_UNICODE; AcpiOsPrintf ("Unicode ("); @@ -765,7 +933,9 @@ AcpiDmDisassembleOneOp ( Length = (UINT32) Child->Common.Value.Integer; Info->Level += 1; + Info->MappingOp = Op; Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE; + AcpiDmResourceTemplate (Info, Op->Common.Parent, Aml, Length); Info->Level -= 1; diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrc.c b/sys/contrib/dev/acpica/components/disassembler/dmresrc.c index 6cdd07b1b771..04a6fbb02a5d 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrc.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -260,6 +259,11 @@ AcpiDmResourceTemplate ( ACPI_NAMESPACE_NODE *Node; + if (Op->Asl.AmlOpcode != AML_FIELD_OP) + { + Info->MappingOp = Op; + } + Level = Info->Level; ResourceName = ACPI_DEFAULT_RESNAME; Node = Op->Common.Node; @@ -328,7 +332,7 @@ AcpiDmResourceTemplate ( /* Go ahead and insert EndDependentFn() */ - AcpiDmEndDependentDescriptor (Aml, ResourceLength, Level); + AcpiDmEndDependentDescriptor (Info, Aml, ResourceLength, Level); AcpiDmIndent (Level); AcpiOsPrintf ( @@ -350,7 +354,7 @@ AcpiDmResourceTemplate ( } AcpiGbl_DmResourceDispatch [ResourceIndex] ( - Aml, ResourceLength, Level); + Info, Aml, ResourceLength, Level); /* Descriptor post-processing */ diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c index 792ae808d710..a6c38a8d169a 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -576,7 +575,8 @@ AcpiDmResourceSource ( * * FUNCTION: AcpiDmWordDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -588,6 +588,7 @@ AcpiDmResourceSource ( void AcpiDmWordDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -621,7 +622,8 @@ AcpiDmWordDescriptor ( * * FUNCTION: AcpiDmDwordDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -633,6 +635,7 @@ AcpiDmWordDescriptor ( void AcpiDmDwordDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -666,7 +669,8 @@ AcpiDmDwordDescriptor ( * * FUNCTION: AcpiDmQwordDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -678,6 +682,7 @@ AcpiDmDwordDescriptor ( void AcpiDmQwordDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -711,7 +716,8 @@ AcpiDmQwordDescriptor ( * * FUNCTION: AcpiDmExtendedDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -723,6 +729,7 @@ AcpiDmQwordDescriptor ( void AcpiDmExtendedDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -758,7 +765,8 @@ AcpiDmExtendedDescriptor ( * * FUNCTION: AcpiDmMemory24Descriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -770,6 +778,7 @@ AcpiDmExtendedDescriptor ( void AcpiDmMemory24Descriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -797,7 +806,8 @@ AcpiDmMemory24Descriptor ( * * FUNCTION: AcpiDmMemory32Descriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -809,6 +819,7 @@ AcpiDmMemory24Descriptor ( void AcpiDmMemory32Descriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -836,7 +847,8 @@ AcpiDmMemory32Descriptor ( * * FUNCTION: AcpiDmFixedMemory32Descriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -848,6 +860,7 @@ AcpiDmMemory32Descriptor ( void AcpiDmFixedMemory32Descriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -877,7 +890,8 @@ AcpiDmFixedMemory32Descriptor ( * * FUNCTION: AcpiDmGenericRegisterDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -889,6 +903,7 @@ AcpiDmFixedMemory32Descriptor ( void AcpiDmGenericRegisterDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -933,7 +948,8 @@ AcpiDmGenericRegisterDescriptor ( * * FUNCTION: AcpiDmInterruptDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -945,6 +961,7 @@ AcpiDmGenericRegisterDescriptor ( void AcpiDmInterruptDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -1039,7 +1056,8 @@ AcpiDmVendorCommon ( * * FUNCTION: AcpiDmVendorLargeDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -1051,6 +1069,7 @@ AcpiDmVendorCommon ( void AcpiDmVendorLargeDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c index f938f93070d9..452cde04b7be 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -56,24 +55,28 @@ static void AcpiDmI2cSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); static void AcpiDmSpiSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); static void AcpiDmUartSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); static void AcpiDmGpioCommon ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Level); @@ -168,7 +171,8 @@ AcpiDmDumpRawDataBuffer ( * * FUNCTION: AcpiDmGpioCommon * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Level - Current source code indentation level * * RETURN: None @@ -179,12 +183,14 @@ AcpiDmDumpRawDataBuffer ( static void AcpiDmGpioCommon ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Level) { - UINT32 PinCount; UINT16 *PinList; UINT8 *VendorData; + char *DeviceName = NULL; + UINT32 PinCount; UINT32 i; @@ -193,9 +199,8 @@ AcpiDmGpioCommon ( AcpiDmIndent (Level + 1); if (Resource->Gpio.ResSourceOffset) { - AcpiUtPrintString ( - ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), - ACPI_UINT16_MAX); + DeviceName = ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), + AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX); } AcpiOsPrintf (", "); @@ -243,6 +248,10 @@ AcpiDmGpioCommon ( AcpiDmIndent (Level + 1); AcpiOsPrintf ("}\n"); + +#ifndef _KERNEL + MpSaveGpioInfo (Info->MappingOp, Resource, PinCount, PinList, DeviceName); +#endif } @@ -250,7 +259,8 @@ AcpiDmGpioCommon ( * * FUNCTION: AcpiDmGpioIntDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -262,6 +272,7 @@ AcpiDmGpioCommon ( static void AcpiDmGpioIntDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -274,7 +285,7 @@ AcpiDmGpioIntDescriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("GpioInt (%s, %s, %s, ", AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)], - AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->Gpio.IntFlags, 1)], + AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)], AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]); /* PinConfig, DebounceTimeout */ @@ -292,7 +303,7 @@ AcpiDmGpioIntDescriptor ( /* Dump the GpioInt/GpioIo common portion of the descriptor */ - AcpiDmGpioCommon (Resource, Level); + AcpiDmGpioCommon (Info, Resource, Level); } @@ -300,7 +311,8 @@ AcpiDmGpioIntDescriptor ( * * FUNCTION: AcpiDmGpioIoDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -312,6 +324,7 @@ AcpiDmGpioIntDescriptor ( static void AcpiDmGpioIoDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -344,7 +357,7 @@ AcpiDmGpioIoDescriptor ( /* Dump the GpioInt/GpioIo common portion of the descriptor */ - AcpiDmGpioCommon (Resource, Level); + AcpiDmGpioCommon (Info, Resource, Level); } @@ -352,7 +365,8 @@ AcpiDmGpioIoDescriptor ( * * FUNCTION: AcpiDmGpioDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -364,6 +378,7 @@ AcpiDmGpioIoDescriptor ( void AcpiDmGpioDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -377,12 +392,12 @@ AcpiDmGpioDescriptor ( { case AML_RESOURCE_GPIO_TYPE_INT: - AcpiDmGpioIntDescriptor (Resource, Length, Level); + AcpiDmGpioIntDescriptor (Info, Resource, Length, Level); break; case AML_RESOURCE_GPIO_TYPE_IO: - AcpiDmGpioIoDescriptor (Resource, Length, Level); + AcpiDmGpioIoDescriptor (Info, Resource, Length, Level); break; default: @@ -460,7 +475,8 @@ AcpiDmDumpSerialBusVendorData ( * * FUNCTION: AcpiDmI2cSerialBusDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -472,11 +488,13 @@ AcpiDmDumpSerialBusVendorData ( static void AcpiDmI2cSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { UINT32 ResourceSourceOffset; + char *DeviceName; /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */ @@ -496,9 +514,8 @@ AcpiDmI2cSerialBusDescriptor ( ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + Resource->CommonSerialBus.TypeDataLength; - AcpiUtPrintString ( - ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), - ACPI_UINT16_MAX); + DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), + AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX); /* ResourceSourceIndex, ResourceUsage */ @@ -519,6 +536,10 @@ AcpiDmI2cSerialBusDescriptor ( AcpiDmIndent (Level + 1); AcpiDmDumpSerialBusVendorData (Resource, Level); AcpiOsPrintf (")\n"); + +#ifndef _KERNEL + MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName); +#endif } @@ -526,7 +547,8 @@ AcpiDmI2cSerialBusDescriptor ( * * FUNCTION: AcpiDmSpiSerialBusDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -538,11 +560,13 @@ AcpiDmI2cSerialBusDescriptor ( static void AcpiDmSpiSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { UINT32 ResourceSourceOffset; + char *DeviceName; /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */ @@ -571,9 +595,8 @@ AcpiDmSpiSerialBusDescriptor ( ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + Resource->CommonSerialBus.TypeDataLength; - AcpiUtPrintString ( - ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), - ACPI_UINT16_MAX); + DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), + AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX); /* ResourceSourceIndex, ResourceUsage */ @@ -594,6 +617,10 @@ AcpiDmSpiSerialBusDescriptor ( AcpiDmIndent (Level + 1); AcpiDmDumpSerialBusVendorData (Resource, Level); AcpiOsPrintf (")\n"); + +#ifndef _KERNEL + MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName); +#endif } @@ -601,7 +628,8 @@ AcpiDmSpiSerialBusDescriptor ( * * FUNCTION: AcpiDmUartSerialBusDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -613,11 +641,13 @@ AcpiDmSpiSerialBusDescriptor ( static void AcpiDmUartSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { UINT32 ResourceSourceOffset; + char *DeviceName; /* ConnectionSpeed, BitsPerByte, StopBits */ @@ -649,9 +679,8 @@ AcpiDmUartSerialBusDescriptor ( ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + Resource->CommonSerialBus.TypeDataLength; - AcpiUtPrintString ( - ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), - ACPI_UINT16_MAX); + DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), + AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX); /* ResourceSourceIndex, ResourceUsage */ @@ -672,6 +701,10 @@ AcpiDmUartSerialBusDescriptor ( AcpiDmIndent (Level + 1); AcpiDmDumpSerialBusVendorData (Resource, Level); AcpiOsPrintf (")\n"); + +#ifndef _KERNEL + MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName); +#endif } @@ -679,7 +712,8 @@ AcpiDmUartSerialBusDescriptor ( * * FUNCTION: AcpiDmSerialBusDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -691,13 +725,14 @@ AcpiDmUartSerialBusDescriptor ( void AcpiDmSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { SerialBusResourceDispatch [Resource->CommonSerialBus.Type] ( - Resource, Length, Level); + Info, Resource, Length, Level); } #endif diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c index 778d6638bba6..549c3d6b33da 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -57,7 +56,8 @@ * * FUNCTION: AcpiDmIrqDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -69,6 +69,7 @@ void AcpiDmIrqDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -102,7 +103,8 @@ AcpiDmIrqDescriptor ( * * FUNCTION: AcpiDmDmaDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -114,6 +116,7 @@ AcpiDmIrqDescriptor ( void AcpiDmDmaDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -139,7 +142,8 @@ AcpiDmDmaDescriptor ( * * FUNCTION: AcpiDmFixedDmaDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -151,6 +155,7 @@ AcpiDmDmaDescriptor ( void AcpiDmFixedDmaDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -182,7 +187,8 @@ AcpiDmFixedDmaDescriptor ( * * FUNCTION: AcpiDmIoDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -194,6 +200,7 @@ AcpiDmFixedDmaDescriptor ( void AcpiDmIoDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -227,7 +234,8 @@ AcpiDmIoDescriptor ( * * FUNCTION: AcpiDmFixedIoDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -239,6 +247,7 @@ AcpiDmIoDescriptor ( void AcpiDmFixedIoDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -265,7 +274,8 @@ AcpiDmFixedIoDescriptor ( * * FUNCTION: AcpiDmStartDependentDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -277,6 +287,7 @@ AcpiDmFixedIoDescriptor ( void AcpiDmStartDependentDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -304,7 +315,8 @@ AcpiDmStartDependentDescriptor ( * * FUNCTION: AcpiDmEndDependentDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -316,6 +328,7 @@ AcpiDmStartDependentDescriptor ( void AcpiDmEndDependentDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) @@ -332,7 +345,8 @@ AcpiDmEndDependentDescriptor ( * * FUNCTION: AcpiDmVendorSmallDescriptor * - * PARAMETERS: Resource - Pointer to the resource descriptor + * PARAMETERS: Info - Extra resource info + * Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes * Level - Current source code indentation level * @@ -344,6 +358,7 @@ AcpiDmEndDependentDescriptor ( void AcpiDmVendorSmallDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) diff --git a/sys/contrib/dev/acpica/components/disassembler/dmutils.c b/sys/contrib/dev/acpica/components/disassembler/dmutils.c index 5d35d8359865..bb9ef73c917f 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmutils.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c index 5a3fbc65658c..8021a9731864 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -285,7 +284,8 @@ AcpiDmBlockType ( case AML_BUFFER_OP: - if (Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) + if ((Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) || + (Op->Common.DisasmOpcode == ACPI_DASM_UUID)) { return (BLOCK_NONE); } @@ -568,7 +568,7 @@ AcpiDmDescendingOp ( /* Check for _HID and related EISAID() */ - AcpiDmIsEisaId (Op); + AcpiDmCheckForHardwareId (Op); AcpiOsPrintf (", "); break; @@ -842,6 +842,15 @@ AcpiDmAscendingOp ( AcpiDmFieldPredefinedDescription (Op); } + /* Decode Notify() values */ + + if (Op->Common.AmlOpcode == AML_NOTIFY_OP) + { + AcpiDmNotifyDescription (Op); + } + + AcpiDmDisplayTargetPathname (Op); + /* Could be a nested operator, check if comma required */ if (!AcpiDmCommaIfListMember (Op)) @@ -948,6 +957,13 @@ AcpiDmAscendingOp ( return (AE_OK); } + /* + * The parent Op is guaranteed to be valid because of the flag + * ACPI_PARSEOP_PARAMLIST -- which means that this op is part of + * a parameter list and thus has a valid parent. + */ + ParentOp = Op->Common.Parent; + /* * Just completed a parameter node for something like "Buffer (param)". * Close the paren and open up the term list block with a brace @@ -956,25 +972,24 @@ AcpiDmAscendingOp ( { AcpiOsPrintf (")"); - /* Emit description comment for Name() with a predefined ACPI name */ - - ParentOp = Op->Common.Parent; - if (ParentOp) + /* + * Emit a description comment for a Name() operator that is a + * predefined ACPI name. Must check the grandparent. + */ + ParentOp = ParentOp->Common.Parent; + if (ParentOp && + (ParentOp->Asl.AmlOpcode == AML_NAME_OP)) { - ParentOp = ParentOp->Common.Parent; - if (ParentOp && ParentOp->Asl.AmlOpcode == AML_NAME_OP) - { - AcpiDmPredefinedDescription (ParentOp); - } + AcpiDmPredefinedDescription (ParentOp); } + AcpiOsPrintf ("\n"); AcpiDmIndent (Level - 1); AcpiOsPrintf ("{\n"); } else { - Op->Common.Parent->Common.DisasmFlags |= - ACPI_PARSEOP_EMPTY_TERMLIST; + ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST; AcpiOsPrintf (") {"); } } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsargs.c b/sys/contrib/dev/acpica/components/dispatcher/dsargs.c index 2c574ca10a60..fd7c7958b27e 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsargs.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsargs.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c b/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c index 3d256ea0b4e6..c2fac77b8821 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c index ab4f5b94f7f2..262b63a4459a 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -116,7 +116,7 @@ AcpiDsCreateExternalRegion ( * OperationRegion not found. Generate an External for it, and * insert the name into the namespace. */ - AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_REGION, 0); + AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_REGION, 0, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_REGION, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, Node); if (ACPI_FAILURE (Status)) @@ -391,6 +391,7 @@ AcpiDsGetFieldNames ( */ Info->ResourceBuffer = NULL; Info->ConnectionNode = NULL; + Info->PinNumberIndex = 0; /* * A Connection() is either an actual resource descriptor (buffer) @@ -466,6 +467,7 @@ AcpiDsGetFieldNames ( } Info->FieldBitPosition += Info->FieldBitLength; + Info->PinNumberIndex++; /* Index relative to previous Connection() */ break; default: diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c index 5ab1f502863a..6789fe413d6d 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,7 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsinit") + /* Local prototypes */ static ACPI_STATUS @@ -91,8 +92,8 @@ AcpiDsInitOneObject ( { ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - ACPI_OBJECT_TYPE Type; ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_ENTRY (); @@ -111,9 +112,7 @@ AcpiDsInitOneObject ( /* And even then, we are only interested in a few object types */ - Type = AcpiNsGetType (ObjHandle); - - switch (Type) + switch (AcpiNsGetType (ObjHandle)) { case ACPI_TYPE_REGION: @@ -129,8 +128,45 @@ AcpiDsInitOneObject ( break; case ACPI_TYPE_METHOD: - + /* + * Auto-serialization support. We will examine each method that is + * NotSerialized to determine if it creates any Named objects. If + * it does, it will be marked serialized to prevent problems if + * the method is entered by two or more threads and an attempt is + * made to create the same named object twice -- which results in + * an AE_ALREADY_EXISTS exception and method abort. + */ Info->MethodCount++; + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + break; + } + + /* Ignore if already serialized */ + + if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED) + { + Info->SerialMethodCount++; + break; + } + + if (AcpiGbl_AutoSerializeMethods) + { + /* Parse/scan method and serialize it if necessary */ + + AcpiDsAutoSerializeMethod (Node, ObjDesc); + if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED) + { + /* Method was just converted to Serialized */ + + Info->SerialMethodCount++; + Info->SerializedMethodCount++; + break; + } + } + + Info->NonSerialMethodCount++; break; case ACPI_TYPE_DEVICE: @@ -187,7 +223,6 @@ AcpiDsInitializeObjects ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:")); /* Set all init info to zero */ @@ -223,12 +258,14 @@ AcpiDsInitializeObjects ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n", - Table->Signature, OwnerId, Info.ObjectCount, - Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); + "Table [%4.4s] (id %4.4X) - %4u Objects with %3u Devices, " + "%3u Regions, %3u Methods (%u/%u/%u Serial/Non/Cvt)\n", + Table->Signature, OwnerId, Info.ObjectCount, Info.DeviceCount, + Info.OpRegionCount, Info.MethodCount, Info.SerialMethodCount, + Info.NonSerialMethodCount, Info.SerializedMethodCount)); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "%u Methods, %u Regions\n", Info.MethodCount, Info.OpRegionCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n", + Info.MethodCount, Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c index d2dccaf26904..1fd81738bc25 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,6 +49,8 @@ #include #include #include +#include +#include #define _COMPONENT ACPI_DISPATCHER @@ -56,11 +58,155 @@ /* Local prototypes */ +static ACPI_STATUS +AcpiDsDetectNamedOpcodes ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + static ACPI_STATUS AcpiDsCreateMethodMutex ( ACPI_OPERAND_OBJECT *MethodDesc); +/******************************************************************************* + * + * FUNCTION: AcpiDsAutoSerializeMethod + * + * PARAMETERS: Node - Namespace Node of the method + * ObjDesc - Method object attached to node + * + * RETURN: Status + * + * DESCRIPTION: Parse a control method AML to scan for control methods that + * need serialization due to the creation of named objects. + * + * NOTE: It is a bit of overkill to mark all such methods serialized, since + * there is only a problem if the method actually blocks during execution. + * A blocking operation is, for example, a Sleep() operation, or any access + * to an operation region. However, it is probably not possible to easily + * detect whether a method will block or not, so we simply mark all suspicious + * methods as serialized. + * + * NOTE2: This code is essentially a generic routine for parsing a single + * control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsAutoSerializeMethod ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op = NULL; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE_PTR (DsAutoSerializeMethod, Node); + + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Method auto-serialization parse [%4.4s] %p\n", + AcpiUtGetNodeName (Node), Node)); + + /* Create/Init a root op for the method parse tree */ + + Op = AcpiPsAllocOp (AML_METHOD_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiPsSetName (Op, Node->Name.Integer); + Op->Common.Node = Node; + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (Node->OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, Node, ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 0); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + return_ACPI_STATUS (Status); + } + + WalkState->DescendingCallback = AcpiDsDetectNamedOpcodes; + + /* Parse the method, scan for creation of named objects */ + + Status = AcpiPsParseAml (WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDetectNamedOpcodes + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Unused, required for parser interface + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * Currently used to detect methods that must be marked serialized + * in order to avoid problems with the creation of named objects. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsDetectNamedOpcodes ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + + ACPI_FUNCTION_NAME (AcpiDsDetectNamedOpcodes); + + + /* We are only interested in opcodes that create a new name */ + + if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_CREATE | AML_FIELD))) + { + return (AE_OK); + } + + /* + * At this point, we know we have a Named object opcode. + * Mark the method as serialized. Later code will create a mutex for + * this method to enforce serialization. + * + * Note, ACPI_METHOD_IGNORE_SYNC_LEVEL flag means that we will ignore the + * Sync Level mechanism for this method, even though it is now serialized. + * Otherwise, there can be conflicts with existing ASL code that actually + * uses sync levels. + */ + WalkState->MethodDesc->Method.SyncLevel = 0; + WalkState->MethodDesc->Method.InfoFlags |= + (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Method serialized [%4.4s] %p - [%s] (%4.4X)\n", + WalkState->MethodNode->Name.Ascii, WalkState->MethodNode, + WalkState->OpInfo->Name, WalkState->Opcode)); + + /* Abort the parse, no need to examine this method any further */ + + return (AE_CTRL_TERMINATE); +} + + /******************************************************************************* * * FUNCTION: AcpiDsMethodError @@ -238,11 +384,16 @@ AcpiDsBeginMethodExecution ( /* * The CurrentSyncLevel (per-thread) must be less than or equal to * the sync level of the method. This mechanism provides some - * deadlock prevention + * deadlock prevention. + * + * If the method was auto-serialized, we just ignore the sync level + * mechanism, because auto-serialization of methods can interfere + * with ASL code that actually uses sync levels. * * Top-level method invocation has no walk state at this point */ if (WalkState && + (!(ObjDesc->Method.InfoFlags & ACPI_METHOD_IGNORE_SYNC_LEVEL)) && (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) { ACPI_ERROR ((AE_INFO, @@ -710,7 +861,8 @@ AcpiDsTerminateControlMethod ( * thread exits here. */ MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_SERIALIZED_PENDING; - MethodDesc->Method.InfoFlags |= ACPI_METHOD_SERIALIZED; + MethodDesc->Method.InfoFlags |= + (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL); MethodDesc->Method.SyncLevel = 0; } diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c b/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c index 76157f5678c7..8e4555c2a9f2 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c index a853d3d88cad..04515fde6a58 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c b/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c index b7ff59060512..fa225ce1d1bd 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c index 0a386cc0ec9e..cb1c84603fb6 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -779,16 +779,16 @@ AcpiDsCreateOperands ( Index++; } + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "NumOperands %d, ArgCount %d, Index %d\n", + WalkState->NumOperands, ArgCount, Index)); + + /* Create the interpreter arguments, in reverse order */ + Index--; - - /* It is the appropriate order to get objects from the Result stack */ - for (i = 0; i < ArgCount; i++) { Arg = Arguments[Index]; - - /* Force the filling of the operand stack in inverse order */ - WalkState->OperandIndex = (UINT8) Index; Status = AcpiDsCreateOperand (WalkState, Arg, Index); @@ -797,10 +797,10 @@ AcpiDsCreateOperands ( goto Cleanup; } + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Created Arg #%u (%p) %u args total\n", + Index, Arg, ArgCount)); Index--; - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n", - Index, Arg, FirstArg)); } return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswexec.c b/sys/contrib/dev/acpica/components/dispatcher/dswexec.c index 6955f3c00028..c6009fb159fb 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswexec.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswexec.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -541,7 +541,8 @@ AcpiDsExecEndOp ( return_ACPI_STATUS (AE_OK); } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method invocation, Op=%p\n", Op)); /* * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload.c b/sys/contrib/dev/acpica/components/dispatcher/dswload.c index 1cc8d4f2ece2..eca145e384d3 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswload.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,8 +80,21 @@ AcpiDsInitCallbacks ( switch (PassNumber) { + case 0: + + /* Parse only - caller will setup callbacks */ + + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE | + ACPI_PARSE_DISASSEMBLE; + WalkState->DescendingCallback = NULL; + WalkState->AscendingCallback = NULL; + break; + case 1: + /* Load pass 1 */ + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsLoad1BeginOp; @@ -90,6 +103,8 @@ AcpiDsInitCallbacks ( case 2: + /* Load pass 2 */ + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsLoad2BeginOp; @@ -98,6 +113,8 @@ AcpiDsInitCallbacks ( case 3: + /* Execution pass */ + #ifndef ACPI_NO_METHOD_EXECUTION WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; @@ -193,7 +210,7 @@ AcpiDsLoad1BeginOp ( * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ - AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0); + AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &Node); diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload2.c b/sys/contrib/dev/acpica/components/dispatcher/dswload2.c index 2b854133c555..abcc1c3e74d7 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswload2.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswload2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswscope.c b/sys/contrib/dev/acpica/components/dispatcher/dswscope.c index 8530b5de6ec2..5d2152b2fb4b 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswscope.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswscope.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswstate.c b/sys/contrib/dev/acpica/components/dispatcher/dswstate.c index 8fd36bf66356..4071d5f8226d 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswstate.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswstate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __DSWSTATE_C__ #include diff --git a/sys/contrib/dev/acpica/components/events/evevent.c b/sys/contrib/dev/acpica/components/events/evevent.c index dc8457cb461d..3116ac61a7c6 100644 --- a/sys/contrib/dev/acpica/components/events/evevent.c +++ b/sys/contrib/dev/acpica/components/events/evevent.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/events/evglock.c b/sys/contrib/dev/acpica/components/events/evglock.c index 9c5ade03f56e..44c768a753b1 100644 --- a/sys/contrib/dev/acpica/components/events/evglock.c +++ b/sys/contrib/dev/acpica/components/events/evglock.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/events/evgpe.c b/sys/contrib/dev/acpica/components/events/evgpe.c index f4d12144ec25..7d4a5d03d8ec 100644 --- a/sys/contrib/dev/acpica/components/events/evgpe.c +++ b/sys/contrib/dev/acpica/components/events/evgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -432,7 +432,7 @@ AcpiEvGpeDetect ( GpeRegisterInfo->EnableForWake)) { ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "Ignore disabled registers for GPE%02X-GPE%02X: " + "Ignore disabled registers for GPE %02X-%02X: " "RunEnable=%02X, WakeEnable=%02X\n", GpeRegisterInfo->BaseGpeNumber, GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), @@ -458,7 +458,7 @@ AcpiEvGpeDetect ( } ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "Read registers for GPE%02X-GPE%02X: Status=%02X, Enable=%02X, " + "Read registers for GPE %02X-%02X: Status=%02X, Enable=%02X, " "RunEnable=%02X, WakeEnable=%02X\n", GpeRegisterInfo->BaseGpeNumber, GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), @@ -549,6 +549,7 @@ AcpiEvAsynchExecuteGpeMethod ( Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { + ACPI_FREE (LocalGpeEventInfo); return_VOID; } @@ -557,6 +558,7 @@ AcpiEvAsynchExecuteGpeMethod ( if (!AcpiEvValidGpeEvent (GpeEventInfo)) { Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + ACPI_FREE (LocalGpeEventInfo); return_VOID; } @@ -570,6 +572,7 @@ AcpiEvAsynchExecuteGpeMethod ( Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { + ACPI_FREE (LocalGpeEventInfo); return_VOID; } @@ -757,22 +760,6 @@ AcpiEvGpeDispatch ( 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 @@ -786,10 +773,28 @@ AcpiEvGpeDispatch ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to disable GPE%02X", GpeNumber)); + "Unable to disable GPE %02X", GpeNumber)); return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } + /* + * 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)); + (void) AcpiHwLowSetGpe (GpeEventInfo, + ACPI_GPE_CONDITIONAL_ENABLE); + 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 @@ -826,7 +831,7 @@ AcpiEvGpeDispatch ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "Unable to queue handler for GPE%02X - event disabled", + "Unable to queue handler for GPE %02X - event disabled", GpeNumber)); } break; @@ -838,7 +843,7 @@ AcpiEvGpeDispatch ( * 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", + "No handler or method for GPE %02X, disabling event", GpeNumber)); break; } diff --git a/sys/contrib/dev/acpica/components/events/evgpeblk.c b/sys/contrib/dev/acpica/components/events/evgpeblk.c index f0d53a3a21be..e8f0d637f1c9 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeblk.c +++ b/sys/contrib/dev/acpica/components/events/evgpeblk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,10 +97,9 @@ AcpiEvInstallGpeBlock ( return_ACPI_STATUS (Status); } - GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); - if (!GpeXruptBlock) + Status = AcpiEvGetGpeXruptBlock (InterruptNumber, &GpeXruptBlock); + if (ACPI_FAILURE (Status)) { - Status = AE_NO_MEMORY; goto UnlockAndExit; } @@ -128,7 +127,7 @@ AcpiEvInstallGpeBlock ( UnlockAndExit: - Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } @@ -283,17 +282,17 @@ AcpiEvCreateGpeInfoBlocks ( { /* Init the RegisterInfo for this GPE register (8 GPEs) */ - ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber + - (i * ACPI_GPE_REGISTER_WIDTH)); + ThisRegister->BaseGpeNumber = (UINT16) + (GpeBlock->BlockBaseNumber + (i * ACPI_GPE_REGISTER_WIDTH)); ThisRegister->StatusAddress.Address = - GpeBlock->BlockAddress.Address + i; + GpeBlock->Address + i; ThisRegister->EnableAddress.Address = - GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount; + GpeBlock->Address + i + GpeBlock->RegisterCount; - ThisRegister->StatusAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; - ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->StatusAddress.SpaceId = GpeBlock->SpaceId; + ThisRegister->EnableAddress.SpaceId = GpeBlock->SpaceId; ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; ThisRegister->StatusAddress.BitOffset = 0; @@ -366,9 +365,10 @@ AcpiEvCreateGpeInfoBlocks ( ACPI_STATUS AcpiEvCreateGpeBlock ( ACPI_NAMESPACE_NODE *GpeDevice, - ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT64 Address, + UINT8 SpaceId, UINT32 RegisterCount, - UINT8 GpeBlockBaseNumber, + UINT16 GpeBlockBaseNumber, UINT32 InterruptNumber, ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) { @@ -395,15 +395,14 @@ AcpiEvCreateGpeBlock ( /* Initialize the new GPE block */ + GpeBlock->Address = Address; + GpeBlock->SpaceId = SpaceId; GpeBlock->Node = GpeDevice; GpeBlock->GpeCount = (UINT16) (RegisterCount * ACPI_GPE_REGISTER_WIDTH); GpeBlock->Initialized = FALSE; GpeBlock->RegisterCount = RegisterCount; GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; - ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, - sizeof (ACPI_GENERIC_ADDRESS)); - /* * Create the RegisterInfo and EventInfo sub-structures * Note: disables and clears all GPEs in the block @@ -446,11 +445,11 @@ AcpiEvCreateGpeBlock ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - " Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X\n", + " Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X%s\n", (UINT32) GpeBlock->BlockBaseNumber, (UINT32) (GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1)), - GpeDevice->Name.Ascii, GpeBlock->RegisterCount, - InterruptNumber)); + GpeDevice->Name.Ascii, GpeBlock->RegisterCount, InterruptNumber, + InterruptNumber == AcpiGbl_FADT.SciInterrupt ? " (SCI)" : "")); /* Update global count of currently available GPEs */ diff --git a/sys/contrib/dev/acpica/components/events/evgpeinit.c b/sys/contrib/dev/acpica/components/events/evgpeinit.c index 8c74149f1173..d5e00e380bf8 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeinit.c +++ b/sys/contrib/dev/acpica/components/events/evgpeinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -139,7 +138,9 @@ AcpiEvGpeInitialize ( /* Install GPE Block 0 */ Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, + AcpiGbl_FADT.XGpe0Block.Address, + AcpiGbl_FADT.XGpe0Block.SpaceId, + RegisterCount0, 0, AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); if (ACPI_FAILURE (Status)) @@ -177,7 +178,9 @@ AcpiEvGpeInitialize ( /* Install GPE Block 1 */ Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT.XGpe1Block, RegisterCount1, + AcpiGbl_FADT.XGpe1Block.Address, + AcpiGbl_FADT.XGpe1Block.SpaceId, + RegisterCount1, AcpiGbl_FADT.Gpe1Base, AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); @@ -440,6 +443,10 @@ AcpiEvMatchGpeMethod ( return_ACPI_STATUS (AE_OK); } + /* Disable the GPE in case it's been enabled already. */ + + (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE); + /* * Add the GPE information from above to the GpeEventInfo block for * use during dispatch of this GPE. diff --git a/sys/contrib/dev/acpica/components/events/evgpeutil.c b/sys/contrib/dev/acpica/components/events/evgpeutil.c index 35caa5a18f6f..e2a44bc91b9d 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeutil.c +++ b/sys/contrib/dev/acpica/components/events/evgpeutil.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -217,8 +217,9 @@ AcpiEvGetGpeDevice ( * FUNCTION: AcpiEvGetGpeXruptBlock * * PARAMETERS: InterruptNumber - Interrupt for a GPE block + * GpeXruptBlock - Where the block is returned * - * RETURN: A GPE interrupt block + * RETURN: Status * * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt * block per unique interrupt level used for GPEs. Should be @@ -227,9 +228,10 @@ AcpiEvGetGpeDevice ( * ******************************************************************************/ -ACPI_GPE_XRUPT_INFO * +ACPI_STATUS AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber) + UINT32 InterruptNumber, + ACPI_GPE_XRUPT_INFO **GpeXruptBlock) { ACPI_GPE_XRUPT_INFO *NextGpeXrupt; ACPI_GPE_XRUPT_INFO *GpeXrupt; @@ -247,7 +249,8 @@ AcpiEvGetGpeXruptBlock ( { if (NextGpeXrupt->InterruptNumber == InterruptNumber) { - return_PTR (NextGpeXrupt); + *GpeXruptBlock = NextGpeXrupt; + return_ACPI_STATUS (AE_OK); } NextGpeXrupt = NextGpeXrupt->Next; @@ -258,7 +261,7 @@ AcpiEvGetGpeXruptBlock ( GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); if (!GpeXrupt) { - return_PTR (NULL); + return_ACPI_STATUS (AE_NO_MEMORY); } GpeXrupt->InterruptNumber = InterruptNumber; @@ -281,6 +284,7 @@ AcpiEvGetGpeXruptBlock ( { AcpiGbl_GpeXruptListHead = GpeXrupt; } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); /* Install new interrupt handler if not SCI_INT */ @@ -291,14 +295,15 @@ AcpiEvGetGpeXruptBlock ( AcpiEvGpeXruptHandler, GpeXrupt); if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, + ACPI_EXCEPTION ((AE_INFO, Status, "Could not install GPE interrupt handler at level 0x%X", InterruptNumber)); - return_PTR (NULL); + return_ACPI_STATUS (Status); } } - return_PTR (GpeXrupt); + *GpeXruptBlock = GpeXrupt; + return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/events/evhandler.c b/sys/contrib/dev/acpica/components/events/evhandler.c index cb03bc93d0bd..73a2df284858 100644 --- a/sys/contrib/dev/acpica/components/events/evhandler.c +++ b/sys/contrib/dev/acpica/components/events/evhandler.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVHANDLER_C__ #include diff --git a/sys/contrib/dev/acpica/components/events/evmisc.c b/sys/contrib/dev/acpica/components/events/evmisc.c index 547534bd5b23..a710b569f7ed 100644 --- a/sys/contrib/dev/acpica/components/events/evmisc.c +++ b/sys/contrib/dev/acpica/components/events/evmisc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -181,7 +181,7 @@ AcpiEvQueueNotifyRequest ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), - NotifyValue, AcpiUtGetNotifyName (NotifyValue), Node)); + NotifyValue, AcpiUtGetNotifyName (NotifyValue, ACPI_TYPE_ANY), Node)); Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, Info); diff --git a/sys/contrib/dev/acpica/components/events/evregion.c b/sys/contrib/dev/acpica/components/events/evregion.c index d469d6ef675b..8078bf92c49c 100644 --- a/sys/contrib/dev/acpica/components/events/evregion.c +++ b/sys/contrib/dev/acpica/components/events/evregion.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVREGION_C__ #include @@ -159,6 +158,7 @@ AcpiEvAddressSpaceDispatch ( ACPI_OPERAND_OBJECT *RegionObj2; void *RegionContext = NULL; ACPI_CONNECTION_INFO *Context; + ACPI_PHYSICAL_ADDRESS Address; ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch); @@ -248,23 +248,23 @@ AcpiEvAddressSpaceDispatch ( /* 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))); + Address = (RegionObj->Region.Address + RegionOffset); /* * 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. + * 1) Connection buffer, a resource template from Connection() op + * 2) Length of the above buffer + * 3) Actual access length from the AccessAs() op + * + * In addition, for GeneralPurposeIo, the Address and BitWidth fields + * are defined as follows: + * 1) Address is the pin number index of the field (bit offset from + * the previous Connection) + * 2) BitWidth is the actual bit length of the field (number of pins) */ - if (((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) || - (RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) && + if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) && Context && FieldObj) { @@ -274,6 +274,24 @@ AcpiEvAddressSpaceDispatch ( Context->Length = FieldObj->Field.ResourceLength; Context->AccessLength = FieldObj->Field.AccessLength; } + if ((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; + Address = FieldObj->Field.PinNumberIndex; + BitWidth = FieldObj->Field.BitLength; + } + + 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 (Address), + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); if (!(HandlerDesc->AddressSpace.HandlerFlags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) @@ -288,9 +306,8 @@ AcpiEvAddressSpaceDispatch ( /* Call the handler */ - Status = Handler (Function, - (RegionObj->Region.Address + RegionOffset), BitWidth, Value, - Context, RegionObj2->Extra.RegionContext); + Status = Handler (Function, Address, BitWidth, Value, Context, + RegionObj2->Extra.RegionContext); if (ACPI_FAILURE (Status)) { @@ -333,6 +350,7 @@ AcpiEvDetachRegion( { ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *StartDesc; ACPI_OPERAND_OBJECT **LastObjPtr; ACPI_ADR_SPACE_SETUP RegionSetup; void **RegionContext; @@ -363,6 +381,7 @@ AcpiEvDetachRegion( /* Find this region in the handler's list */ ObjDesc = HandlerObj->AddressSpace.RegionList; + StartDesc = ObjDesc; LastObjPtr = &HandlerObj->AddressSpace.RegionList; while (ObjDesc) @@ -457,6 +476,16 @@ AcpiEvDetachRegion( LastObjPtr = &ObjDesc->Region.Next; ObjDesc = ObjDesc->Region.Next; + + /* Prevent infinite loop if list is corrupted */ + + if (ObjDesc == StartDesc) + { + ACPI_ERROR ((AE_INFO, + "Circular handler list in region object %p", + RegionObj)); + return_VOID; + } } /* If we get here, the region was not in the handler's region list */ diff --git a/sys/contrib/dev/acpica/components/events/evrgnini.c b/sys/contrib/dev/acpica/components/events/evrgnini.c index 5a9e9e814c1e..14fea69261cd 100644 --- a/sys/contrib/dev/acpica/components/events/evrgnini.c +++ b/sys/contrib/dev/acpica/components/events/evrgnini.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVRGNINI_C__ #include diff --git a/sys/contrib/dev/acpica/components/events/evsci.c b/sys/contrib/dev/acpica/components/events/evsci.c index 4fa84f3a45e6..8688a31adf1a 100644 --- a/sys/contrib/dev/acpica/components/events/evsci.c +++ b/sys/contrib/dev/acpica/components/events/evsci.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -135,7 +135,7 @@ AcpiEvSciXruptHandler ( /* - * We are guaranteed by the ACPI CA initialization/shutdown code that + * We are guaranteed by the ACPICA initialization/shutdown code that * if this interrupt handler is installed, ACPI is enabled. */ diff --git a/sys/contrib/dev/acpica/components/events/evxface.c b/sys/contrib/dev/acpica/components/events/evxface.c index 4ed32474928c..cdb6fce2753d 100644 --- a/sys/contrib/dev/acpica/components/events/evxface.c +++ b/sys/contrib/dev/acpica/components/events/evxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFACE_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -265,7 +265,7 @@ AcpiRemoveNotifyHandler ( ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *PreviousHandlerObj; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; UINT32 i; @@ -280,16 +280,6 @@ AcpiRemoveNotifyHandler ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Make sure all deferred notify tasks are completed */ - - AcpiOsWaitEventsComplete (); - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* Root Object. Global handlers are removed here */ if (Device == ACPI_ROOT_OBJECT) @@ -298,6 +288,12 @@ AcpiRemoveNotifyHandler ( { if (HandlerType & (i+1)) { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + if (!AcpiGbl_GlobalNotify[i].Handler || (AcpiGbl_GlobalNotify[i].Handler != Handler)) { @@ -310,18 +306,23 @@ AcpiRemoveNotifyHandler ( AcpiGbl_GlobalNotify[i].Handler = NULL; AcpiGbl_GlobalNotify[i].Context = NULL; + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Make sure all deferred notify tasks are completed */ + + AcpiOsWaitEventsComplete (); } } - goto UnlockAndExit; + return_ACPI_STATUS (AE_OK); } /* All other objects: Are Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { - Status = AE_TYPE; - goto UnlockAndExit; + return_ACPI_STATUS (AE_TYPE); } /* Must have an existing internal object */ @@ -329,8 +330,7 @@ AcpiRemoveNotifyHandler ( ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { - Status = AE_NOT_EXIST; - goto UnlockAndExit; + return_ACPI_STATUS (AE_NOT_EXIST); } /* Internal object exists. Find the handler and remove it */ @@ -339,6 +339,12 @@ AcpiRemoveNotifyHandler ( { if (HandlerType & (i+1)) { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + HandlerObj = ObjDesc->CommonNotify.NotifyList[i]; PreviousHandlerObj = NULL; @@ -370,10 +376,17 @@ AcpiRemoveNotifyHandler ( HandlerObj->Notify.Next[i]; } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Make sure all deferred notify tasks are completed */ + + AcpiOsWaitEventsComplete (); AcpiUtRemoveReference (HandlerObj); } } + return_ACPI_STATUS (Status); + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -519,6 +532,8 @@ AcpiInstallSciHandler ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallSciHandler) + /******************************************************************************* * @@ -595,6 +610,8 @@ AcpiRemoveSciHandler ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveSciHandler) + /******************************************************************************* * @@ -969,10 +986,6 @@ AcpiRemoveGpeHandler ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Make sure all deferred GPE tasks are completed */ - - AcpiOsWaitEventsComplete (); - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { @@ -1023,16 +1036,24 @@ AcpiRemoveGpeHandler ( * enabled, it should be enabled at this point to restore the * post-initialization configuration. */ - if ((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) && + if (((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) || + (Handler->OriginalFlags & ACPI_GPE_DISPATCH_NOTIFY)) && Handler->OriginallyEnabled) { (void) AcpiEvAddGpeReference (GpeEventInfo); } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + /* Make sure all deferred GPE tasks are completed */ + + AcpiOsWaitEventsComplete (); + /* Now we can free the handler object */ ACPI_FREE (Handler); - + return_ACPI_STATUS (Status); UnlockAndExit: AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); diff --git a/sys/contrib/dev/acpica/components/events/evxfevnt.c b/sys/contrib/dev/acpica/components/events/evxfevnt.c index eb17a3f88ba3..abb0c0e4e48c 100644 --- a/sys/contrib/dev/acpica/components/events/evxfevnt.c +++ b/sys/contrib/dev/acpica/components/events/evxfevnt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFEVNT_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -364,7 +364,9 @@ AcpiGetEventStatus ( UINT32 Event, ACPI_EVENT_STATUS *EventStatus) { - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status; + ACPI_EVENT_STATUS LocalEventStatus = 0; + UINT32 InByte; ACPI_FUNCTION_TRACE (AcpiGetEventStatus); @@ -382,12 +384,43 @@ AcpiGetEventStatus ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get the status of the requested fixed event */ + /* Fixed event currently can be dispatched? */ + + if (AcpiGbl_FixedEventHandlers[Event].Handler) + { + LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER; + } + + /* Fixed event currently enabled? */ Status = AcpiReadBitRegister ( - AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus); + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &InByte); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - return_ACPI_STATUS (Status); + if (InByte) + { + LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; + } + + /* Fixed event currently active? */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, &InByte); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (InByte) + { + LocalEventStatus |= ACPI_EVENT_FLAG_SET; + } + + (*EventStatus) = LocalEventStatus; + return_ACPI_STATUS (AE_OK); } ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) diff --git a/sys/contrib/dev/acpica/components/events/evxfgpe.c b/sys/contrib/dev/acpica/components/events/evxfgpe.c index 0a40bd9d8f42..c03f5c07d391 100644 --- a/sys/contrib/dev/acpica/components/events/evxfgpe.c +++ b/sys/contrib/dev/acpica/components/events/evxfgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EVXFGPE_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -140,12 +140,23 @@ AcpiEnableGpe ( Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - /* Ensure that we have a valid GPE number */ - + /* + * Ensure that we have a valid GPE number and that there is some way + * of handling the GPE (handler or a GPE method). In other words, we + * won't allow a valid GPE to be enabled if there is no way to handle it. + */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); if (GpeEventInfo) { - Status = AcpiEvAddGpeReference (GpeEventInfo); + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_NONE) + { + Status = AcpiEvAddGpeReference (GpeEventInfo); + } + else + { + Status = AE_NO_HANDLER; + } } AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); @@ -273,6 +284,60 @@ AcpiSetGpe ( ACPI_EXPORT_SYMBOL (AcpiSetGpe) +/******************************************************************************* + * + * FUNCTION: AcpiMarkGpeForWake + * + * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 + * GpeNumber - GPE level within the GPE block + * + * RETURN: Status + * + * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply + * sets the ACPI_GPE_CAN_WAKE flag. + * + * Some potential callers of AcpiSetupGpeForWake may know in advance that + * there won't be any notify handlers installed for device wake notifications + * from the given GPE (one example is a button GPE in Linux). For these cases, + * AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake. + * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to + * setup implicit wake notification for it (since there's no handler method). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiMarkGpeForWake ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_STATUS Status = AE_BAD_PARAMETER; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiMarkGpeForWake); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (GpeEventInfo) + { + /* Mark the GPE as a possible wake event */ + + GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; + Status = AE_OK; + } + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiMarkGpeForWake) + + /******************************************************************************* * * FUNCTION: AcpiSetupGpeForWake @@ -790,11 +855,26 @@ AcpiInstallGpeBlock ( goto UnlockAndExit; } + /* Validate the parent device */ + + if (Node->Type != ACPI_TYPE_DEVICE) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + if (Node->Object) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + /* * For user-installed GPE Block Devices, the GpeBlockBaseNumber * is always zero */ - Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, + Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress->Address, + GpeBlockAddress->SpaceId, RegisterCount, 0, InterruptNumber, &GpeBlock); if (ACPI_FAILURE (Status)) { @@ -883,6 +963,14 @@ AcpiRemoveGpeBlock ( goto UnlockAndExit; } + /* Validate the parent device */ + + if (Node->Type != ACPI_TYPE_DEVICE) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + /* Get the DeviceObject attached to the node */ ObjDesc = AcpiNsGetAttachedObject (Node); diff --git a/sys/contrib/dev/acpica/components/events/evxfregn.c b/sys/contrib/dev/acpica/components/events/evxfregn.c index 432657d89a07..eb53c0d852ff 100644 --- a/sys/contrib/dev/acpica/components/events/evxfregn.c +++ b/sys/contrib/dev/acpica/components/events/evxfregn.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ */ #define __EVXFREGN_C__ +#define EXPORT_ACPI_INTERFACES #include #include diff --git a/sys/contrib/dev/acpica/components/executer/exconfig.c b/sys/contrib/dev/acpica/components/executer/exconfig.c index 2306e8397e7c..c3bb563fbf78 100644 --- a/sys/contrib/dev/acpica/components/executer/exconfig.c +++ b/sys/contrib/dev/acpica/components/executer/exconfig.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -380,8 +380,8 @@ AcpiExLoadOp ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *TableHeader; ACPI_TABLE_HEADER *Table; - ACPI_TABLE_DESC TableDesc; UINT32 TableIndex; ACPI_STATUS Status; UINT32 Length; @@ -390,8 +390,6 @@ AcpiExLoadOp ( 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) @@ -423,16 +421,16 @@ AcpiExLoadOp ( /* Get the table header first so we can get the table length */ - Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); - if (!Table) + TableHeader = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!TableHeader) { return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), - ACPI_CAST_PTR (UINT8, Table)); - Length = Table->Length; - ACPI_FREE (Table); + ACPI_CAST_PTR (UINT8, TableHeader)); + Length = TableHeader->Length; + ACPI_FREE (TableHeader); if (ACPI_FAILURE (Status)) { @@ -464,8 +462,8 @@ AcpiExLoadOp ( /* Allocate a buffer for the table */ - TableDesc.Pointer = ACPI_ALLOCATE (Length); - if (!TableDesc.Pointer) + Table = ACPI_ALLOCATE (Length); + if (!Table) { return_ACPI_STATUS (AE_NO_MEMORY); } @@ -473,14 +471,12 @@ AcpiExLoadOp ( /* Read the entire table */ Status = AcpiExRegionRead (ObjDesc, Length, - ACPI_CAST_PTR (UINT8, TableDesc.Pointer)); + ACPI_CAST_PTR (UINT8, Table)); if (ACPI_FAILURE (Status)) { - ACPI_FREE (TableDesc.Pointer); + ACPI_FREE (Table); return_ACPI_STATUS (Status); } - - TableDesc.Address = ObjDesc->Region.Address; break; case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ @@ -497,8 +493,8 @@ AcpiExLoadOp ( /* Get the actual table length from the table header */ - Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); - Length = Table->Length; + TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + Length = TableHeader->Length; /* Table cannot extend beyond the buffer */ @@ -515,14 +511,13 @@ AcpiExLoadOp ( * 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) + Table = ACPI_ALLOCATE (Length); + if (!Table) { return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMCPY (TableDesc.Pointer, Table, Length); - TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer); + ACPI_MEMCPY (Table, TableHeader, Length); break; default: @@ -530,28 +525,31 @@ AcpiExLoadOp ( 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); + ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, + &TableIndex); + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { /* Delete allocated table buffer */ - AcpiTbDeleteTable (&TableDesc); + ACPI_FREE (Table); + return_ACPI_STATUS (Status); + } + + /* + * Note: Now table is "INSTALLED", it must be validated before + * loading. + */ + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + if (ACPI_FAILURE (Status)) + { return_ACPI_STATUS (Status); } @@ -583,9 +581,6 @@ AcpiExLoadOp ( return_ACPI_STATUS (Status); } - ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); - AcpiTbPrintTableHeader (0, TableDesc.Pointer); - /* Remove the reference by added by AcpiExStore above */ AcpiUtRemoveReference (DdbHandle); @@ -594,7 +589,7 @@ AcpiExLoadOp ( if (AcpiGbl_TableHandler) { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer, + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, AcpiGbl_TableHandlerContext); } @@ -627,6 +622,14 @@ AcpiExUnloadTable ( ACPI_FUNCTION_TRACE (ExUnloadTable); + /* + * Temporarily emit a warning so that the ASL for the machine can be + * hopefully obtained. This is to say that the Unload() operator is + * extremely rare if not completely unused. + */ + ACPI_WARNING ((AE_INFO, + "Received request to unload an ACPI table")); + /* * Validate the handle * Although the handle is partially validated in AcpiExReconfiguration() diff --git a/sys/contrib/dev/acpica/components/executer/exconvrt.c b/sys/contrib/dev/acpica/components/executer/exconvrt.c index f6113a59d8f6..f2557c0239ff 100644 --- a/sys/contrib/dev/acpica/components/executer/exconvrt.c +++ b/sys/contrib/dev/acpica/components/executer/exconvrt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXCONVRT_C__ #include diff --git a/sys/contrib/dev/acpica/components/executer/excreate.c b/sys/contrib/dev/acpica/components/executer/excreate.c index 55715c2e5b42..224249dea1a1 100644 --- a/sys/contrib/dev/acpica/components/executer/excreate.c +++ b/sys/contrib/dev/acpica/components/executer/excreate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exdebug.c b/sys/contrib/dev/acpica/components/executer/exdebug.c index 06f35b815d91..ec8b5a00f5e6 100644 --- a/sys/contrib/dev/acpica/components/executer/exdebug.c +++ b/sys/contrib/dev/acpica/components/executer/exdebug.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,6 +82,7 @@ AcpiExDoDebugObject ( UINT32 Index) { UINT32 i; + UINT32 Timer; ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); @@ -95,13 +96,21 @@ AcpiExDoDebugObject ( return_VOID; } + /* + * We will emit the current timer value (in microseconds) with each + * debug output. Only need the lower 26 bits. This allows for 67 + * million microseconds or 67 seconds before rollover. + */ + Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */ + Timer &= 0x03FFFFFF; + /* * Print line header as long as we are not in the middle of an * object display */ if (!((Level > 0) && Index == 0)) { - AcpiOsPrintf ("[ACPI Debug] %*s", Level, " "); + AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " "); } /* Display the index for package output only */ diff --git a/sys/contrib/dev/acpica/components/executer/exdump.c b/sys/contrib/dev/acpica/components/executer/exdump.c index c37f9ae7995a..153b2c12fbed 100644 --- a/sys/contrib/dev/acpica/components/executer/exdump.c +++ b/sys/contrib/dev/acpica/components/executer/exdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -114,13 +114,14 @@ static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] = {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, {ACPI_EXD_BUFFER, 0, NULL} }; -static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] = +static ACPI_EXDUMP_INFO AcpiExDumpPackage[6] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Package.Node), "Parent Node"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"}, @@ -130,9 +131,9 @@ static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] = static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.NotifyList[0]), "System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.NotifyList[1]), "Device Notify"} + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.NotifyList[1]), "Device Notify"}, + {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (Device.Handler), "Handler"} }; static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = @@ -154,33 +155,36 @@ static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"} }; -static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] = +static ACPI_EXDUMP_INFO AcpiExDumpMutex[6] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.OriginalSyncLevel), "Original Sync Level"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} }; -static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] = +static ACPI_EXDUMP_INFO AcpiExDumpRegion[8] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Region.Node), "Parent Node"}, {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"}, + {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (Region.Handler), "Handler"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"} }; -static ACPI_EXDUMP_INFO AcpiExDumpPower[5] = +static ACPI_EXDUMP_INFO AcpiExDumpPower[6] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.NotifyList[0]), "System Notify"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.NotifyList[1]), "Device Notify"} + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.NotifyList[1]), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.Handler), "Handler"} }; static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] = @@ -243,7 +247,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Reference.Node), "Node"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, {ACPI_EXD_REFERENCE,0, NULL} }; @@ -252,16 +256,16 @@ static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"}, + {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (AddressSpace.Next), "Next"}, + {ACPI_EXD_RGN_LIST, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"} }; static ACPI_EXDUMP_INFO AcpiExDumpNotify[7] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Notify.Node), "Node"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Notify.HandlerType), "Handler Type"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Handler), "Handler"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"}, @@ -269,15 +273,32 @@ static ACPI_EXDUMP_INFO AcpiExDumpNotify[7] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Next[1]), "Next Device Notify"} }; +static ACPI_EXDUMP_INFO AcpiExDumpExtra[6] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpExtra), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Extra.Method_REG), "_REG Method"}, + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (Extra.ScopeNode), "Scope Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Extra.RegionContext), "Region Context"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Extra.AmlStart), "Aml Start"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Extra.AmlLength), "Aml Length"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpData[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpData), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Data.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Data.Pointer), "Raw Data"} +}; /* Miscellaneous tables */ -static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] = +static ACPI_EXDUMP_INFO AcpiExDumpCommon[5] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL}, {ACPI_EXD_TYPE , 0, NULL}, {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"} + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"}, + {ACPI_EXD_LIST, ACPI_EXD_OFFSET (Common.NextObject), "Object List"} }; static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = @@ -288,16 +309,18 @@ static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} + {ACPI_EXD_NODE, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} }; -static ACPI_EXDUMP_INFO AcpiExDumpNode[5] = +static ACPI_EXDUMP_INFO AcpiExDumpNode[7] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"}, {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"}, - {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"}, - {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"} + {ACPI_EXD_LIST, ACPI_EXD_NSOFFSET (Object), "Object List"}, + {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET (Parent), "Parent"}, + {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET (Child), "Child"}, + {ACPI_EXD_NODE, ACPI_EXD_NSOFFSET (Peer), "Peer"} }; @@ -332,7 +355,9 @@ static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] = AcpiExDumpAddressHandler, NULL, NULL, - NULL + NULL, + AcpiExDumpExtra, + AcpiExDumpData }; @@ -359,6 +384,10 @@ AcpiExDumpObject ( char *Name; const char *ReferenceName; UINT8 Count; + ACPI_OPERAND_OBJECT *Start; + ACPI_OPERAND_OBJECT *Data = NULL; + ACPI_OPERAND_OBJECT *Next; + ACPI_NAMESPACE_NODE *Node; if (!Info) @@ -386,7 +415,8 @@ AcpiExDumpObject ( case ACPI_EXD_TYPE: - AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); + AcpiOsPrintf ("%20s : %2.2X [%s]\n", "Type", + ObjDesc->Common.Type, AcpiUtGetObjectTypeName (ObjDesc)); break; case ACPI_EXD_UINT8: @@ -447,6 +477,120 @@ AcpiExDumpObject ( AcpiExDumpReferenceObj (ObjDesc); break; + case ACPI_EXD_LIST: + + Start = *ACPI_CAST_PTR (void *, Target); + Next = Start; + + AcpiOsPrintf ("%20s : %p", Name, Next); + if (Next) + { + AcpiOsPrintf ("(%s %2.2X)", + AcpiUtGetObjectTypeName (Next), Next->Common.Type); + + while (Next->Common.NextObject) + { + if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) && + !Data) + { + Data = Next; + } + + Next = Next->Common.NextObject; + AcpiOsPrintf ("->%p(%s %2.2X)", Next, + AcpiUtGetObjectTypeName (Next), Next->Common.Type); + + if ((Next == Start) || (Next == Data)) + { + AcpiOsPrintf ("\n**** Error: Object list appears to be circular linked"); + break; + } + } + } + + AcpiOsPrintf ("\n"); + break; + + case ACPI_EXD_HDLR_LIST: + + Start = *ACPI_CAST_PTR (void *, Target); + Next = Start; + + AcpiOsPrintf ("%20s : %p", Name, Next); + if (Next) + { + AcpiOsPrintf ("(%s %2.2X)", + AcpiUtGetObjectTypeName (Next), Next->Common.Type); + + while (Next->AddressSpace.Next) + { + if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) && + !Data) + { + Data = Next; + } + + Next = Next->AddressSpace.Next; + AcpiOsPrintf ("->%p(%s %2.2X)", Next, + AcpiUtGetObjectTypeName (Next), Next->Common.Type); + + if ((Next == Start) || (Next == Data)) + { + AcpiOsPrintf ("\n**** Error: Handler list appears to be circular linked"); + break; + } + } + } + + AcpiOsPrintf ("\n"); + break; + + case ACPI_EXD_RGN_LIST: + + Start = *ACPI_CAST_PTR (void *, Target); + Next = Start; + + AcpiOsPrintf ("%20s : %p", Name, Next); + if (Next) + { + AcpiOsPrintf ("(%s %2.2X)", + AcpiUtGetObjectTypeName (Next), Next->Common.Type); + + while (Next->Region.Next) + { + if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) && + !Data) + { + Data = Next; + } + + Next = Next->Region.Next; + AcpiOsPrintf ("->%p(%s %2.2X)", Next, + AcpiUtGetObjectTypeName (Next), Next->Common.Type); + + if ((Next == Start) || (Next == Data)) + { + AcpiOsPrintf ("\n**** Error: Region list appears to be circular linked"); + break; + } + } + } + + AcpiOsPrintf ("\n"); + break; + + case ACPI_EXD_NODE: + + Node = *ACPI_CAST_PTR (ACPI_NAMESPACE_NODE *, Target); + + AcpiOsPrintf ("%20s : %p", Name, Node); + if (Node) + { + AcpiOsPrintf (" [%4.4s]", Node->Name.Ascii); + } + AcpiOsPrintf ("\n"); + break; + default: AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", @@ -864,9 +1008,8 @@ AcpiExDumpNamespaceNode ( } AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); - AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); - AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); - AcpiExOutPointer ("Parent", Node->Parent); + AcpiOsPrintf ("%20s : %2.2X [%s]\n", "Type", + Node->Type, AcpiUtGetTypeName (Node->Type)); AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), AcpiExDumpNode); @@ -1074,24 +1217,30 @@ AcpiExDumpObjectDescriptor ( AcpiOsPrintf ("\nAttached Object (%p):\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); - AcpiExDumpObjectDescriptor ( - ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); - return_VOID; + ObjDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object; + goto DumpObject; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { AcpiOsPrintf ( - "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", + "%p is not an ACPI operand object: [%s]\n", ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); return_VOID; } - if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX) + /* Validate the object type */ + + if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX) { + AcpiOsPrintf ("Not a known object type: %2.2X\n", + ObjDesc->Common.Type); return_VOID; } + +DumpObject: + /* Common Fields */ AcpiExDumpObject (ObjDesc, AcpiExDumpCommon); @@ -1099,6 +1248,22 @@ AcpiExDumpObjectDescriptor ( /* Object-specific fields */ AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); + + if (ObjDesc->Common.Type == ACPI_TYPE_REGION) + { + ObjDesc = ObjDesc->Common.NextObject; + if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX) + { + AcpiOsPrintf ("Secondary object is not a known object type: %2.2X\n", + ObjDesc->Common.Type); + + return_VOID; + } + + AcpiOsPrintf ("\nExtra attached Object (%p):\n", ObjDesc); + AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); + } + return_VOID; } diff --git a/sys/contrib/dev/acpica/components/executer/exfield.c b/sys/contrib/dev/acpica/components/executer/exfield.c index 9cab258266d1..2b61790c0a9a 100644 --- a/sys/contrib/dev/acpica/components/executer/exfield.c +++ b/sys/contrib/dev/acpica/components/executer/exfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,18 +41,86 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXFIELD_C__ #include #include #include #include +#include #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exfield") +/* Local prototypes */ + +static UINT32 +AcpiExGetSerialAccessLength ( + UINT32 AccessorType, + UINT32 AccessLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetSerialAccessLength + * + * PARAMETERS: AccessorType - The type of the protocol indicated by region + * field access attributes + * AccessLength - The access length of the region field + * + * RETURN: Decoded access length + * + * DESCRIPTION: This routine returns the length of the GenericSerialBus + * protocol bytes + * + ******************************************************************************/ + +static UINT32 +AcpiExGetSerialAccessLength ( + UINT32 AccessorType, + UINT32 AccessLength) +{ + UINT32 Length; + + + switch (AccessorType) + { + case AML_FIELD_ATTRIB_QUICK: + + Length = 0; + break; + + case AML_FIELD_ATTRIB_SEND_RCV: + case AML_FIELD_ATTRIB_BYTE: + + Length = 1; + break; + + case AML_FIELD_ATTRIB_WORD: + case AML_FIELD_ATTRIB_WORD_CALL: + + Length = 2; + break; + + case AML_FIELD_ATTRIB_MULTIBYTE: + case AML_FIELD_ATTRIB_RAW_BYTES: + case AML_FIELD_ATTRIB_RAW_PROCESS: + + Length = AccessLength; + break; + + case AML_FIELD_ATTRIB_BLOCK: + case AML_FIELD_ATTRIB_BLOCK_CALL: + default: + + Length = ACPI_GSBUS_BUFFER_SIZE - 2; + break; + } + + return (Length); +} + /******************************************************************************* * @@ -80,6 +148,7 @@ AcpiExReadDataFromField ( ACPI_SIZE Length; void *Buffer; UINT32 Function; + UINT16 AccessorType; ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); @@ -129,8 +198,19 @@ AcpiExReadDataFromField ( } else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) { - Length = ACPI_GSBUS_BUFFER_SIZE; - Function = ACPI_READ | (ObjDesc->Field.Attribute << 16); + AccessorType = ObjDesc->Field.Attribute; + Length = AcpiExGetSerialAccessLength (AccessorType, + ObjDesc->Field.AccessLength); + + /* + * Add additional 2 bytes for the GenericSerialBus data buffer: + * + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + */ + Length += 2; + Function = ACPI_READ | (AccessorType << 16); } else /* IPMI */ { @@ -193,6 +273,39 @@ AcpiExReadDataFromField ( Buffer = &BufferDesc->Integer.Value; } + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) + { + /* + * For GPIO (GeneralPurposeIo), the Address will be the bit offset + * from the previous Connection() operator, making it effectively a + * pin number index. The BitLength is the length of the field, which + * is thus the number of pins. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "GPIO FieldRead [FROM]: Pin %u Bits %u\n", + ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Perform the write */ + + Status = AcpiExAccessRegion (ObjDesc, 0, + (UINT64 *) Buffer, ACPI_READ); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (BufferDesc); + } + else + { + *RetBufferDesc = BufferDesc; + } + return_ACPI_STATUS (Status); + } + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length)); @@ -251,6 +364,7 @@ AcpiExWriteDataToField ( void *Buffer; ACPI_OPERAND_OBJECT *BufferDesc; UINT32 Function; + UINT16 AccessorType; ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); @@ -310,8 +424,19 @@ AcpiExWriteDataToField ( } else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) { - Length = ACPI_GSBUS_BUFFER_SIZE; - Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + AccessorType = ObjDesc->Field.Attribute; + Length = AcpiExGetSerialAccessLength (AccessorType, + ObjDesc->Field.AccessLength); + + /* + * Add additional 2 bytes for the GenericSerialBus data buffer: + * + * Status; (Byte 0 of the data buffer) + * Length; (Byte 1 of the data buffer) + * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) + */ + Length += 2; + Function = ACPI_WRITE | (AccessorType << 16); } else /* IPMI */ { @@ -354,6 +479,41 @@ AcpiExWriteDataToField ( *ResultDesc = BufferDesc; return_ACPI_STATUS (Status); } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) + { + /* + * For GPIO (GeneralPurposeIo), we will bypass the entire field + * mechanism and handoff the bit address and bit width directly to + * the handler. The Address will be the bit offset + * from the previous Connection() operator, making it effectively a + * pin number index. The BitLength is the length of the field, which + * is thus the number of pins. + */ + if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n", + AcpiUtGetTypeName (SourceDesc->Common.Type), + SourceDesc->Common.Type, (UINT32) SourceDesc->Integer.Value, + ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength)); + + Buffer = &SourceDesc->Integer.Value; + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Perform the write */ + + Status = AcpiExAccessRegion (ObjDesc, 0, + (UINT64 *) Buffer, ACPI_WRITE); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + return_ACPI_STATUS (Status); + } /* Get a pointer to the data to be written */ diff --git a/sys/contrib/dev/acpica/components/executer/exfldio.c b/sys/contrib/dev/acpica/components/executer/exfldio.c index c355b7406d9b..5586cad20080 100644 --- a/sys/contrib/dev/acpica/components/executer/exfldio.c +++ b/sys/contrib/dev/acpica/components/executer/exfldio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXFLDIO_C__ #include diff --git a/sys/contrib/dev/acpica/components/executer/exmisc.c b/sys/contrib/dev/acpica/components/executer/exmisc.c index 2abbe2986f2e..b9b331d10d72 100644 --- a/sys/contrib/dev/acpica/components/executer/exmisc.c +++ b/sys/contrib/dev/acpica/components/executer/exmisc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exmutex.c b/sys/contrib/dev/acpica/components/executer/exmutex.c index a6e5e14f03ed..c14d3c049798 100644 --- a/sys/contrib/dev/acpica/components/executer/exmutex.c +++ b/sys/contrib/dev/acpica/components/executer/exmutex.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exnames.c b/sys/contrib/dev/acpica/components/executer/exnames.c index 9c11e7f951f3..af5aa7ec0d74 100644 --- a/sys/contrib/dev/acpica/components/executer/exnames.c +++ b/sys/contrib/dev/acpica/components/executer/exnames.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exoparg1.c b/sys/contrib/dev/acpica/components/executer/exoparg1.c index cd917ef5371c..849c442ed15f 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg1.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg1.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exoparg2.c b/sys/contrib/dev/acpica/components/executer/exoparg2.c index 6f987533e1cb..b11035596bc0 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg2.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXOPARG2_C__ #include diff --git a/sys/contrib/dev/acpica/components/executer/exoparg3.c b/sys/contrib/dev/acpica/components/executer/exoparg3.c index b9c1c1a221bf..79deb8757923 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg3.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg3.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exoparg6.c b/sys/contrib/dev/acpica/components/executer/exoparg6.c index ae675d398a6b..3191f66da912 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg6.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg6.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exprep.c b/sys/contrib/dev/acpica/components/executer/exprep.c index 33c2049ef1fd..bc270b8b6bc1 100644 --- a/sys/contrib/dev/acpica/components/executer/exprep.c +++ b/sys/contrib/dev/acpica/components/executer/exprep.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -515,6 +515,8 @@ AcpiExPrepFieldValue ( ObjDesc->Field.ResourceLength = Info->ResourceLength; } + ObjDesc->Field.PinNumberIndex = Info->PinNumberIndex; + /* Allow full data read from EC address space */ if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) && diff --git a/sys/contrib/dev/acpica/components/executer/exregion.c b/sys/contrib/dev/acpica/components/executer/exregion.c index 753cba6858a1..0b5c6fc56121 100644 --- a/sys/contrib/dev/acpica/components/executer/exregion.c +++ b/sys/contrib/dev/acpica/components/executer/exregion.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __EXREGION_C__ #include diff --git a/sys/contrib/dev/acpica/components/executer/exresnte.c b/sys/contrib/dev/acpica/components/executer/exresnte.c index 267801c5c942..2aeac6cfcf6f 100644 --- a/sys/contrib/dev/acpica/components/executer/exresnte.c +++ b/sys/contrib/dev/acpica/components/executer/exresnte.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -134,8 +134,8 @@ AcpiExResolveNodeToValue ( if (!SourceDesc) { - ACPI_ERROR ((AE_INFO, "No object attached to node %p", - Node)); + ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p", + Node->Name.Ascii, Node)); return_ACPI_STATUS (AE_AML_NO_OPERAND); } diff --git a/sys/contrib/dev/acpica/components/executer/exresolv.c b/sys/contrib/dev/acpica/components/executer/exresolv.c index 837ba872609b..b2aa570b2869 100644 --- a/sys/contrib/dev/acpica/components/executer/exresolv.c +++ b/sys/contrib/dev/acpica/components/executer/exresolv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exresop.c b/sys/contrib/dev/acpica/components/executer/exresop.c index 24df299c7cb2..e861c26f5060 100644 --- a/sys/contrib/dev/acpica/components/executer/exresop.c +++ b/sys/contrib/dev/acpica/components/executer/exresop.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exstore.c b/sys/contrib/dev/acpica/components/executer/exstore.c index 894af0bc7643..fe0cde83a907 100644 --- a/sys/contrib/dev/acpica/components/executer/exstore.c +++ b/sys/contrib/dev/acpica/components/executer/exstore.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,6 +62,12 @@ AcpiExStoreObjectToIndex ( ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState); +static ACPI_STATUS +AcpiExStoreDirectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState); + /******************************************************************************* * @@ -393,7 +399,11 @@ AcpiExStoreObjectToIndex ( * When storing into an object the data is converted to the * target object type then stored in the object. This means * that the target object type (for an initialized target) will - * not be changed by a store operation. + * not be changed by a store operation. A CopyObject can change + * the target type, however. + * + * The ImplicitConversion flag is set to NO/FALSE only when + * storing to an ArgX -- as per the rules of the ACPI spec. * * Assumes parameters are already validated. * @@ -420,7 +430,7 @@ AcpiExStoreObjectToNode ( TargetType = AcpiNsGetType (Node); TargetDesc = AcpiNsGetAttachedObject (Node); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), Node, AcpiUtGetTypeName (TargetType))); @@ -434,49 +444,35 @@ AcpiExStoreObjectToNode ( return_ACPI_STATUS (Status); } - /* If no implicit conversion, drop into the default case below */ - - if ((!ImplicitConversion) || - ((WalkState->Opcode == AML_COPY_OP) && - (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) && - (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) && - (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD))) - { - /* - * Force execution of default (no implicit conversion). Note: - * CopyObject does not perform an implicit conversion, as per the ACPI - * spec -- except in case of region/bank/index fields -- because these - * objects must retain their original type permanently. - */ - TargetType = ACPI_TYPE_ANY; - } - /* Do the actual store operation */ switch (TargetType) { - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - /* For fields, copy the source data to the target field. */ - - Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, - &WalkState->ResultObj); - break; - case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* - * These target types are all of type Integer/String/Buffer, and - * therefore support implicit conversion before the store. - * - * Copy and/or convert the source object to a new target object + * The simple data types all support implicit source operand + * conversion before the store. */ + + if ((WalkState->Opcode == AML_COPY_OP) || + !ImplicitConversion) + { + /* + * However, CopyObject and Stores to ArgX do not perform + * an implicit conversion, as per the ACPI specification. + * A direct store is performed instead. + */ + Status = AcpiExStoreDirectToNode (SourceDesc, Node, + WalkState); + break; + } + + /* Store with implicit source operand conversion support */ + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, - &NewDesc, WalkState); + &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -489,11 +485,12 @@ AcpiExStoreObjectToNode ( * the Name's type to that of the value being stored in it. * SourceDesc reference count is incremented by AttachObject. * - * Note: This may change the type of the node if an explicit store - * has been performed such that the node/object type has been - * changed. + * Note: This may change the type of the node if an explicit + * store has been performed such that the node/object type + * has been changed. */ - Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); + Status = AcpiNsAttachObject (Node, NewDesc, + NewDesc->Common.Type); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Store %s into %s via Convert/Attach\n", @@ -502,33 +499,86 @@ AcpiExStoreObjectToNode ( } break; + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * For all fields, always write the source data to the target + * field. Any required implicit source operand conversion is + * performed in the function below as necessary. Note, field + * objects must retain their original type permanently. + */ + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, + &WalkState->ResultObj); + break; + default: - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Storing [%s] (%p) directly into node [%s] (%p)" - " with no implicit conversion\n", - AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, - AcpiUtGetObjectTypeName (TargetDesc), Node)); - /* * No conversions for all other types. Directly store a copy of - * the source object. NOTE: This is a departure from the ACPI - * spec, which states "If conversion is impossible, abort the - * running control method". + * the source object. This is the ACPI spec-defined behavior for + * the CopyObject operator. * - * This code implements "If conversion is impossible, treat the - * Store operation as a CopyObject". + * NOTE: For the Store operator, this is a departure from the + * ACPI spec, which states "If conversion is impossible, abort + * the running control method". Instead, this code implements + * "If conversion is impossible, treat the Store operation as + * a CopyObject". */ - Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); - AcpiUtRemoveReference (NewDesc); + Status = AcpiExStoreDirectToNode (SourceDesc, Node, + WalkState); break; } return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreDirectToNode + * + * PARAMETERS: SourceDesc - Value to be stored + * Node - Named object to receive the value + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: "Store" an object directly to a node. This involves a copy + * and an attach. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExStoreDirectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *NewDesc; + + + ACPI_FUNCTION_TRACE (ExStoreDirectToNode); + + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Storing [%s] (%p) directly into node [%s] (%p)" + " with no implicit conversion\n", + AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, + AcpiUtGetTypeName (Node->Type), Node)); + + /* Copy the source object to a new object */ + + Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Attach the new object to the node */ + + Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); + AcpiUtRemoveReference (NewDesc); + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/components/executer/exstoren.c b/sys/contrib/dev/acpica/components/executer/exstoren.c index c0302c1b7c02..803b2b68853b 100644 --- a/sys/contrib/dev/acpica/components/executer/exstoren.c +++ b/sys/contrib/dev/acpica/components/executer/exstoren.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exstorob.c b/sys/contrib/dev/acpica/components/executer/exstorob.c index c68263c60190..560a634869a9 100644 --- a/sys/contrib/dev/acpica/components/executer/exstorob.c +++ b/sys/contrib/dev/acpica/components/executer/exstorob.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/executer/exsystem.c b/sys/contrib/dev/acpica/components/executer/exsystem.c index cc18d805ca06..790813c842af 100644 --- a/sys/contrib/dev/acpica/components/executer/exsystem.c +++ b/sys/contrib/dev/acpica/components/executer/exsystem.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,7 +87,7 @@ AcpiExSystemWaitSemaphore ( { /* We must wait, so unlock the interpreter */ - AcpiExRelinquishInterpreter (); + AcpiExExitInterpreter (); Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); @@ -97,7 +97,7 @@ AcpiExSystemWaitSemaphore ( /* Reacquire the interpreter */ - AcpiExReacquireInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); @@ -140,7 +140,7 @@ AcpiExSystemWaitMutex ( { /* We must wait, so unlock the interpreter */ - AcpiExRelinquishInterpreter (); + AcpiExExitInterpreter (); Status = AcpiOsAcquireMutex (Mutex, Timeout); @@ -150,7 +150,7 @@ AcpiExSystemWaitMutex ( /* Reacquire the interpreter */ - AcpiExReacquireInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); @@ -227,7 +227,7 @@ AcpiExSystemDoSleep ( /* Since this thread will sleep, we must release the interpreter */ - AcpiExRelinquishInterpreter (); + AcpiExExitInterpreter (); /* * For compatibility with other ACPI implementations and to prevent @@ -242,7 +242,7 @@ AcpiExSystemDoSleep ( /* And now we must get the interpreter again */ - AcpiExReacquireInterpreter (); + AcpiExEnterInterpreter (); return (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/executer/exutils.c b/sys/contrib/dev/acpica/components/executer/exutils.c index 29abfd1d618b..1958c19f53ef 100644 --- a/sys/contrib/dev/acpica/components/executer/exutils.c +++ b/sys/contrib/dev/acpica/components/executer/exutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,42 +110,6 @@ AcpiExEnterInterpreter ( } -/******************************************************************************* - * - * FUNCTION: AcpiExReacquireInterpreter - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Reacquire the interpreter execution region from within the - * interpreter code. Failure to enter the interpreter region is a - * fatal system error. Used in conjunction with - * RelinquishInterpreter - * - ******************************************************************************/ - -void -AcpiExReacquireInterpreter ( - void) -{ - ACPI_FUNCTION_TRACE (ExReacquireInterpreter); - - - /* - * If the global serialized flag is set, do not release the interpreter, - * since it was not actually released by AcpiExRelinquishInterpreter. - * This forces the interpreter to be single threaded. - */ - if (!AcpiGbl_AllMethodsSerialized) - { - AcpiExEnterInterpreter (); - } - - return_VOID; -} - - /******************************************************************************* * * FUNCTION: AcpiExExitInterpreter @@ -156,7 +120,16 @@ AcpiExReacquireInterpreter ( * * DESCRIPTION: Exit the interpreter execution region. This is the top level * routine used to exit the interpreter when all processing has - * been completed. + * been completed, or when the method blocks. + * + * Cases where the interpreter is unlocked internally: + * 1) Method will be blocked on a Sleep() AML opcode + * 2) Method will be blocked on an Acquire() AML opcode + * 3) Method will be blocked on a Wait() AML opcode + * 4) Method will be blocked to acquire the global lock + * 5) Method will be blocked waiting to execute a serialized control + * method that is currently executing + * 6) About to invoke a user-installed opregion handler * ******************************************************************************/ @@ -180,49 +153,6 @@ AcpiExExitInterpreter ( } -/******************************************************************************* - * - * FUNCTION: AcpiExRelinquishInterpreter - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Exit the interpreter execution region, from within the - * interpreter - before attempting an operation that will possibly - * block the running thread. - * - * Cases where the interpreter is unlocked internally - * 1) Method to be blocked on a Sleep() AML opcode - * 2) Method to be blocked on an Acquire() AML opcode - * 3) Method to be blocked on a Wait() AML opcode - * 4) Method to be blocked to acquire the global lock - * 5) Method to be blocked waiting to execute a serialized control method - * that is currently executing - * 6) About to invoke a user-installed opregion handler - * - ******************************************************************************/ - -void -AcpiExRelinquishInterpreter ( - void) -{ - ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); - - - /* - * If the global serialized flag is set, do not release the interpreter. - * This forces the interpreter to be single threaded. - */ - if (!AcpiGbl_AllMethodsSerialized) - { - AcpiExExitInterpreter (); - } - - return_VOID; -} - - /******************************************************************************* * * FUNCTION: AcpiExTruncateFor32bitTable diff --git a/sys/contrib/dev/acpica/components/hardware/hwacpi.c b/sys/contrib/dev/acpica/components/hardware/hwacpi.c index 3cd3a446b177..947679589636 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwacpi.c +++ b/sys/contrib/dev/acpica/components/hardware/hwacpi.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/hardware/hwesleep.c b/sys/contrib/dev/acpica/components/hardware/hwesleep.c index 671780113e23..d125bccb372c 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwesleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwesleep.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/hardware/hwgpe.c b/sys/contrib/dev/acpica/components/hardware/hwgpe.c index 99c0de6a21d0..e00aeb24d761 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwgpe.c +++ b/sys/contrib/dev/acpica/components/hardware/hwgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -241,6 +241,14 @@ AcpiHwGetGpeStatus ( return (AE_BAD_PARAMETER); } + /* GPE currently handled? */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_NONE) + { + LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER; + } + /* Get the info block for the entire GPE register */ GpeRegisterInfo = GpeEventInfo->RegisterInfo; diff --git a/sys/contrib/dev/acpica/components/hardware/hwpci.c b/sys/contrib/dev/acpica/components/hardware/hwpci.c index a89a3dd831e9..d14bf755987b 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwpci.c +++ b/sys/contrib/dev/acpica/components/hardware/hwpci.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -161,11 +161,12 @@ AcpiHwDerivePciId ( /* Walk the list, updating the PCI device/function/bus numbers */ Status = AcpiHwProcessPciList (PciId, ListHead); + + /* Delete the list */ + + AcpiHwDeletePciList (ListHead); } - /* Always delete the list */ - - AcpiHwDeletePciList (ListHead); return_ACPI_STATUS (Status); } @@ -213,6 +214,9 @@ AcpiHwBuildPciList ( Status = AcpiGetParent (CurrentDevice, &ParentDevice); if (ACPI_FAILURE (Status)) { + /* Must delete the list before exit */ + + AcpiHwDeletePciList (*ReturnListHead); return (Status); } @@ -227,6 +231,9 @@ AcpiHwBuildPciList ( ListElement = ACPI_ALLOCATE (sizeof (ACPI_PCI_DEVICE)); if (!ListElement) { + /* Must delete the list before exit */ + + AcpiHwDeletePciList (*ReturnListHead); return (AE_NO_MEMORY); } diff --git a/sys/contrib/dev/acpica/components/hardware/hwregs.c b/sys/contrib/dev/acpica/components/hardware/hwregs.c index 9c3f2a95159b..155cb4936352 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwregs.c +++ b/sys/contrib/dev/acpica/components/hardware/hwregs.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -310,17 +310,19 @@ AcpiHwClearAcpiStatus ( Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, ACPI_BITMASK_ALL_FIXED_STATUS); + + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + if (ACPI_FAILURE (Status)) { - goto UnlockAndExit; + goto Exit; } /* Clear the GPE Bits in all GPE registers in all GPE blocks */ Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); -UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); +Exit: return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/hardware/hwsleep.c b/sys/contrib/dev/acpica/components/hardware/hwsleep.c index 0e6691a31aea..d4b346b06a83 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwsleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwsleep.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,7 +72,6 @@ AcpiHwLegacySleep ( UINT32 Pm1aControl; UINT32 Pm1bControl; UINT32 InValue; - UINT32 Retry; ACPI_STATUS Status; @@ -192,7 +191,6 @@ AcpiHwLegacySleep ( /* Wait for transition back to Working State */ - Retry = 1000; do { Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); @@ -201,18 +199,6 @@ AcpiHwLegacySleep ( return_ACPI_STATUS (Status); } - if (AcpiGbl_EnableInterpreterSlack) - { - /* - * Some BIOSs don't set WAK_STS at all. Give up waiting after - * 1000 retries if it still isn't set. - */ - if (Retry-- == 0) - { - break; - } - } - } while (!InValue); return_ACPI_STATUS (AE_OK); diff --git a/sys/contrib/dev/acpica/components/hardware/hwtimer.c b/sys/contrib/dev/acpica/components/hardware/hwtimer.c index e1030143020f..643cc6771b1a 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwtimer.c +++ b/sys/contrib/dev/acpica/components/hardware/hwtimer.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,6 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ +#define EXPORT_ACPI_INTERFACES + #include #include diff --git a/sys/contrib/dev/acpica/components/hardware/hwvalid.c b/sys/contrib/dev/acpica/components/hardware/hwvalid.c index 85a87d176ca9..c8046cd0c2ac 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwvalid.c +++ b/sys/contrib/dev/acpica/components/hardware/hwvalid.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/hardware/hwxface.c b/sys/contrib/dev/acpica/components/hardware/hwxface.c index 8e0e5be0bbc3..0ec2f5c96eef 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwxface.c +++ b/sys/contrib/dev/acpica/components/hardware/hwxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,6 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ +#define EXPORT_ACPI_INTERFACES + #include #include #include @@ -90,9 +92,15 @@ AcpiReset ( * 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. + * + * NOTE: + * The ACPI spec requires the reset register width to be 8, so we + * hardcode it here and ignore the FADT value. This maintains + * compatibility with other ACPI implementations that have allowed + * BIOS code with bad register width values to go unnoticed. */ Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address, - AcpiGbl_FADT.ResetValue, ResetReg->BitWidth); + AcpiGbl_FADT.ResetValue, ACPI_RESET_REGISTER_WIDTH); } else { diff --git a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c index 8c3ec4111466..dfc712b34871 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,6 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ +#define EXPORT_ACPI_INTERFACES + #include #include diff --git a/sys/contrib/dev/acpica/components/namespace/nsaccess.c b/sys/contrib/dev/acpica/components/namespace/nsaccess.c index 523e0920b655..d6f1800fe3ef 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsaccess.c +++ b/sys/contrib/dev/acpica/components/namespace/nsaccess.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsalloc.c b/sys/contrib/dev/acpica/components/namespace/nsalloc.c index ecec172ab1b5..a107f7796ba0 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsalloc.c +++ b/sys/contrib/dev/acpica/components/namespace/nsalloc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSALLOC_C__ #include @@ -121,6 +120,7 @@ AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node) { ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NextDesc; ACPI_FUNCTION_NAME (NsDeleteNode); @@ -131,12 +131,13 @@ AcpiNsDeleteNode ( AcpiNsDetachObject (Node); /* - * Delete an attached data object if present (an object that was created - * and attached via AcpiAttachData). Note: After any normal object is - * detached above, the only possible remaining object is a data object. + * Delete an attached data object list if present (objects that were + * attached via AcpiAttachData). Note: After any normal object is + * detached above, the only possible remaining object(s) are data + * objects, in a linked list. */ ObjDesc = Node->Object; - if (ObjDesc && + while (ObjDesc && (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) { /* Invoke the attached data deletion handler if present */ @@ -146,7 +147,16 @@ AcpiNsDeleteNode ( ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); } + NextDesc = ObjDesc->Common.NextObject; AcpiUtRemoveReference (ObjDesc); + ObjDesc = NextDesc; + } + + /* Special case for the statically allocated root node */ + + if (Node == AcpiGbl_RootNode) + { + return; } /* Now we can delete the node */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsarguments.c b/sys/contrib/dev/acpica/components/namespace/nsarguments.c index 52ab8a99122f..98e831d7bf08 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsarguments.c +++ b/sys/contrib/dev/acpica/components/namespace/nsarguments.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsconvert.c b/sys/contrib/dev/acpica/components/namespace/nsconvert.c index 4b12d3db9359..2b39776d650e 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsconvert.c +++ b/sys/contrib/dev/acpica/components/namespace/nsconvert.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsdump.c b/sys/contrib/dev/acpica/components/namespace/nsdump.c index 0ec564273225..ff1f10f94ebc 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdump.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -748,6 +748,13 @@ AcpiNsDumpOneObjectPath ( } Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + /* Ignore bad node during namespace walk */ + + return (AE_OK); + } + Pathname = AcpiNsGetExternalPathname (Node); PathIndent = 1; diff --git a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c index 868b104ca995..a130a03f75eb 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nseval.c b/sys/contrib/dev/acpica/components/namespace/nseval.c index 57098f41e502..fa4465ba6941 100644 --- a/sys/contrib/dev/acpica/components/namespace/nseval.c +++ b/sys/contrib/dev/acpica/components/namespace/nseval.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsinit.c b/sys/contrib/dev/acpica/components/namespace/nsinit.c index cd5044783be6..f40ff58341d8 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsinit.c +++ b/sys/contrib/dev/acpica/components/namespace/nsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFINIT_C__ #include @@ -129,9 +128,8 @@ AcpiNsInitializeObjects ( 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)); + "%u Control Methods found\n%u Op Regions found\n", + Info.MethodCount, Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/namespace/nsload.c b/sys/contrib/dev/acpica/components/namespace/nsload.c index d29a89148bc9..71c3cfc66a70 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsload.c +++ b/sys/contrib/dev/acpica/components/namespace/nsload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -148,12 +148,12 @@ AcpiNsLoadTable ( * parse trees. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Begin Table Method Parsing and Object Initialization\n")); + "**** Begin Table Object Initialization\n")); Status = AcpiDsInitializeObjects (TableIndex, Node); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Completed Table Method Parsing and Object Initialization\n")); + "**** Completed Table Object Initialization\n")); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/namespace/nsnames.c b/sys/contrib/dev/acpica/components/namespace/nsnames.c index cd4d4404433e..2b1057ddf54d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsnames.c +++ b/sys/contrib/dev/acpica/components/namespace/nsnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsobject.c b/sys/contrib/dev/acpica/components/namespace/nsobject.c index b1d1f01220ed..24d546727f90 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsobject.c +++ b/sys/contrib/dev/acpica/components/namespace/nsobject.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSOBJECT_C__ #include @@ -247,17 +246,32 @@ AcpiNsDetachObject ( } } - /* Clear the entry in all cases */ + /* Clear the Node entry in all cases */ Node->Object = NULL; if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) { + /* Unlink object from front of possible object list */ + Node->Object = ObjDesc->Common.NextObject; + + /* Handle possible 2-descriptor object */ + if (Node->Object && - ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) + (Node->Object->Common.Type != ACPI_TYPE_LOCAL_DATA)) { Node->Object = Node->Object->Common.NextObject; } + + /* + * Detach the object from any data objects (which are still held by + * the namespace node) + */ + if (ObjDesc->Common.NextObject && + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + ObjDesc->Common.NextObject = NULL; + } } /* Reset the node type to untyped */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsparse.c b/sys/contrib/dev/acpica/components/namespace/nsparse.c index f327f2605db6..8e6bd0abb031 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsparse.c +++ b/sys/contrib/dev/acpica/components/namespace/nsparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nspredef.c b/sys/contrib/dev/acpica/components/namespace/nspredef.c index 74ed8f7b82e1..66708709bfd0 100644 --- a/sys/contrib/dev/acpica/components/namespace/nspredef.c +++ b/sys/contrib/dev/acpica/components/namespace/nspredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c index cccd2c10772a..62c3847be88e 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c +++ b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -144,13 +144,13 @@ AcpiNsCheckPackage ( * Decode the type of the expected package contents * * PTYPE1 packages contain no subpackages - * PTYPE2 packages contain sub-packages + * PTYPE2 packages contain subpackages */ switch (Package->RetInfo.Type) { case ACPI_PTYPE1_FIXED: /* - * The package count is fixed and there are no sub-packages + * The package count is fixed and there are no subpackages * * If package is too small, exit. * If package is larger than expected, issue warning but continue @@ -177,7 +177,7 @@ AcpiNsCheckPackage ( case ACPI_PTYPE1_VAR: /* - * The package count is variable, there are no sub-packages, and all + * The package count is variable, there are no subpackages, and all * elements must be of the same type */ for (i = 0; i < Count; i++) @@ -194,7 +194,7 @@ AcpiNsCheckPackage ( case ACPI_PTYPE1_OPTION: /* - * The package count is variable, there are no sub-packages. There are + * The package count is variable, there are no subpackages. There are * a fixed number of required elements, and a variable number of * optional elements. * @@ -250,14 +250,14 @@ AcpiNsCheckPackage ( Elements++; Count--; - /* Examine the sub-packages */ + /* Examine the subpackages */ Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); break; case ACPI_PTYPE2_PKG_COUNT: - /* First element is the (Integer) count of sub-packages to follow */ + /* First element is the (Integer) count of subpackages to follow */ Status = AcpiNsCheckObjectType (Info, Elements, ACPI_RTYPE_INTEGER, 0); @@ -279,7 +279,7 @@ AcpiNsCheckPackage ( Count = ExpectedCount; Elements++; - /* Examine the sub-packages */ + /* Examine the subpackages */ Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); break; @@ -291,9 +291,9 @@ AcpiNsCheckPackage ( case ACPI_PTYPE2_FIX_VAR: /* * These types all return a single Package that consists of a - * variable number of sub-Packages. + * variable number of subpackages. * - * First, ensure that the first element is a sub-Package. If not, + * First, ensure that the first element is a subpackage. 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 @@ -316,11 +316,51 @@ AcpiNsCheckPackage ( Count = 1; } - /* Examine the sub-packages */ + /* Examine the subpackages */ Status = AcpiNsCheckPackageList (Info, Package, Elements, Count); break; + case ACPI_PTYPE2_UUID_PAIR: + + /* The package must contain pairs of (UUID + type) */ + + if (Count & 1) + { + ExpectedCount = Count + 1; + goto PackageTooSmall; + } + + while (Count > 0) + { + Status = AcpiNsCheckObjectType(Info, Elements, + Package->RetInfo.ObjectType1, 0); + if (ACPI_FAILURE(Status)) + { + return (Status); + } + + /* Validate length of the UUID buffer */ + + if ((*Elements)->Buffer.Length != 16) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, + Info->NodeFlags, "Invalid length for UUID Buffer")); + return (AE_AML_OPERAND_VALUE); + } + + Status = AcpiNsCheckObjectType(Info, Elements + 1, + Package->RetInfo.ObjectType2, 0); + if (ACPI_FAILURE(Status)) + { + return (Status); + } + + Elements += 2; + Count -= 2; + } + break; + default: /* Should not get here if predefined info table is correct */ @@ -379,9 +419,9 @@ AcpiNsCheckPackageList ( /* - * Validate each sub-Package in the parent Package + * Validate each subpackage in the parent Package * - * NOTE: assumes list of sub-packages contains no NULL elements. + * NOTE: assumes list of subpackages contains no NULL elements. * Any NULL elements should have been removed by earlier call * to AcpiNsRemoveNullElements. */ @@ -400,7 +440,7 @@ AcpiNsCheckPackageList ( return (Status); } - /* Examine the different types of expected sub-packages */ + /* Examine the different types of expected subpackages */ Info->ParentPackage = SubPackage; switch (Package->RetInfo.Type) @@ -452,7 +492,7 @@ AcpiNsCheckPackageList ( case ACPI_PTYPE2_FIXED: - /* Each sub-package has a fixed length */ + /* Each subpackage has a fixed length */ ExpectedCount = Package->RetInfo2.Count; if (SubPackage->Package.Count < ExpectedCount) @@ -460,7 +500,7 @@ AcpiNsCheckPackageList ( goto PackageTooSmall; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ for (j = 0; j < ExpectedCount; j++) { @@ -475,7 +515,7 @@ AcpiNsCheckPackageList ( case ACPI_PTYPE2_MIN: - /* Each sub-package has a variable but minimum length */ + /* Each subpackage has a variable but minimum length */ ExpectedCount = Package->RetInfo.Count1; if (SubPackage->Package.Count < ExpectedCount) @@ -483,7 +523,7 @@ AcpiNsCheckPackageList ( goto PackageTooSmall; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, SubElements, Package->RetInfo.ObjectType1, @@ -532,7 +572,7 @@ AcpiNsCheckPackageList ( (*SubElements)->Integer.Value = ExpectedCount; } - /* Check the type of each sub-package element */ + /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, (SubElements + 1), Package->RetInfo.ObjectType1, @@ -556,10 +596,10 @@ AcpiNsCheckPackageList ( PackageTooSmall: - /* The sub-package count was smaller than required */ + /* The subpackage count was smaller than required */ ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, - "Return Sub-Package[%u] is too small - found %u elements, expected %u", + "Return SubPackage[%u] is too small - found %u elements, expected %u", i, SubPackage->Package.Count, ExpectedCount)); return (AE_AML_OPERAND_VALUE); diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair.c b/sys/contrib/dev/acpica/components/namespace/nsrepair.c index 879c95a84033..f26497cbc1e0 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -212,14 +212,29 @@ AcpiNsSimpleRepair ( * 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. + * Try to fix if there was no return object. Warning if failed to fix. */ if (!ReturnObject) { if (ExpectedBtypes && (!(ExpectedBtypes & ACPI_RTYPE_NONE))) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, - ACPI_WARN_ALWAYS, "Missing expected return value")); + if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, + ACPI_WARN_ALWAYS, "Found unexpected NULL package element")); + + Status = AcpiNsRepairNullElement (Info, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); /* Repair was successful */ + } + } + else + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, + ACPI_WARN_ALWAYS, "Missing expected return value")); + } return (AE_AML_NO_RETURN_VALUE); } @@ -474,7 +489,7 @@ AcpiNsRepairNullElement ( * RETURN: None. * * DESCRIPTION: Remove all NULL package elements from packages that contain - * a variable number of sub-packages. For these types of + * a variable number of subpackages. For these types of * packages, NULL elements can be safely removed. * *****************************************************************************/ @@ -498,7 +513,7 @@ AcpiNsRemoveNullElements ( /* * 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. + * PTYPE2 packages contain a variable number of subpackages. */ switch (PackageType) { diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c index 6bfd17a5666f..664e2810d4d2 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -478,8 +478,8 @@ AcpiNsRepair_CID ( * DESCRIPTION: Repair for the _CST object: * 1. Sort the list ascending by C state type * 2. Ensure type cannot be zero - * 3. A sub-package count of zero means _CST is meaningless - * 4. Count must match the number of C state sub-packages + * 3. A subpackage count of zero means _CST is meaningless + * 4. Count must match the number of C state subpackages * *****************************************************************************/ @@ -672,6 +672,7 @@ AcpiNsRepair_PRT ( ACPI_OPERAND_OBJECT **TopObjectList; ACPI_OPERAND_OBJECT **SubObjectList; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SubPackage; UINT32 ElementCount; UINT32 Index; @@ -681,9 +682,19 @@ AcpiNsRepair_PRT ( TopObjectList = PackageObject->Package.Elements; ElementCount = PackageObject->Package.Count; - for (Index = 0; Index < ElementCount; Index++) + /* Examine each subpackage */ + + for (Index = 0; Index < ElementCount; Index++, TopObjectList++) { - SubObjectList = (*TopObjectList)->Package.Elements; + SubPackage = *TopObjectList; + SubObjectList = SubPackage->Package.Elements; + + /* Check for minimum required element count */ + + if (SubPackage->Package.Count < 4) + { + continue; + } /* * If the BIOS has erroneously reversed the _PRT SourceName (index 2) @@ -698,14 +709,11 @@ AcpiNsRepair_PRT ( SubObjectList[2] = ObjDesc; Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "PRT[%X]: Fixed reversed SourceName and SourceIndex", Index)); } - - /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ - - TopObjectList++; } return (AE_OK); @@ -745,7 +753,7 @@ AcpiNsRepair_PSS ( /* - * Entries (sub-packages) in the _PSS Package must be sorted by power + * Entries (subpackages) 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. @@ -838,9 +846,9 @@ AcpiNsRepair_TSS ( * * PARAMETERS: Info - Method execution information block * ReturnObject - Pointer to the top-level returned object - * StartIndex - Index of the first sub-package - * ExpectedCount - Minimum length of each sub-package - * SortIndex - Sub-package entry to sort on + * StartIndex - Index of the first subpackage + * ExpectedCount - Minimum length of each subpackage + * SortIndex - Subpackage entry to sort on * SortDirection - Ascending or descending * SortKeyName - Name of the SortIndex field * @@ -881,7 +889,7 @@ AcpiNsCheckSortedList ( } /* - * NOTE: assumes list of sub-packages contains no NULL elements. + * NOTE: assumes list of subpackages contains no NULL elements. * Any NULL elements should have been removed by earlier call * to AcpiNsRemoveNullElements. */ @@ -911,7 +919,7 @@ AcpiNsCheckSortedList ( return (AE_AML_OPERAND_TYPE); } - /* Each sub-package must have the minimum length */ + /* Each subpackage must have the minimum length */ if ((*OuterElements)->Package.Count < ExpectedCount) { diff --git a/sys/contrib/dev/acpica/components/namespace/nssearch.c b/sys/contrib/dev/acpica/components/namespace/nssearch.c index 255956f90999..e46403c54385 100644 --- a/sys/contrib/dev/acpica/components/namespace/nssearch.c +++ b/sys/contrib/dev/acpica/components/namespace/nssearch.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/namespace/nsutils.c b/sys/contrib/dev/acpica/components/namespace/nsutils.c index fdde368e4f05..7cb91b84ba87 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsutils.c +++ b/sys/contrib/dev/acpica/components/namespace/nsutils.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -693,27 +693,29 @@ void AcpiNsTerminate ( void) { - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE (NsTerminate); /* - * 1) Free the entire namespace -- all nodes and objects - * - * Delete all object descriptors attached to namepsace nodes + * Free the entire namespace -- all nodes and all objects + * attached to the nodes */ AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); - /* Detach any objects attached to the root */ + /* Delete any objects attached to the root node */ - ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); - if (ObjDesc) + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) { - AcpiNsDetachObject (AcpiGbl_RootNode); + return_VOID; } + AcpiNsDeleteNode (AcpiGbl_RootNode); + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); return_VOID; } diff --git a/sys/contrib/dev/acpica/components/namespace/nswalk.c b/sys/contrib/dev/acpica/components/namespace/nswalk.c index bba76ce656d9..ce5ac9eddc5c 100644 --- a/sys/contrib/dev/acpica/components/namespace/nswalk.c +++ b/sys/contrib/dev/acpica/components/namespace/nswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSWALK_C__ #include diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c index 984ee64b0121..85749d66d32d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,8 +42,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFEVAL_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -91,7 +91,7 @@ AcpiEvaluateObjectTyped ( ACPI_OBJECT_TYPE ReturnType) { ACPI_STATUS Status; - BOOLEAN MustFree = FALSE; + BOOLEAN FreeBufferOnError = FALSE; ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); @@ -106,12 +106,13 @@ AcpiEvaluateObjectTyped ( if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) { - MustFree = TRUE; + FreeBufferOnError = TRUE; } /* Evaluate the object */ - Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); + Status = AcpiEvaluateObject (Handle, Pathname, + ExternalParams, ReturnBuffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -146,10 +147,15 @@ AcpiEvaluateObjectTyped ( AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), AcpiUtGetTypeName (ReturnType))); - if (MustFree) + if (FreeBufferOnError) { - /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ - + /* + * Free a buffer created via ACPI_ALLOCATE_BUFFER. + * Note: We use AcpiOsFree here because AcpiOsAllocate was used + * to allocate the buffer. This purposefully bypasses the + * (optionally enabled) allocation tracking mechanism since we + * only want to track internal allocations. + */ AcpiOsFree (ReturnBuffer->Pointer); ReturnBuffer->Pointer = NULL; } diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfname.c b/sys/contrib/dev/acpica/components/namespace/nsxfname.c index 9a7642e1e6f4..d9595f1f7018 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfname.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfname.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ */ #define __NSXFNAME_C__ +#define EXPORT_ACPI_INTERFACES #include #include diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c index 153dfaa33c14..545ee17b74bc 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,8 +42,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __NSXFOBJ_C__ +#define EXPORT_ACPI_INTERFACES #include #include diff --git a/sys/contrib/dev/acpica/components/parser/psargs.c b/sys/contrib/dev/acpica/components/parser/psargs.c index f61d4e146059..8f1089fb8f24 100644 --- a/sys/contrib/dev/acpica/components/parser/psargs.c +++ b/sys/contrib/dev/acpica/components/parser/psargs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/parser/psloop.c b/sys/contrib/dev/acpica/components/parser/psloop.c index 6a88f4ef3df9..4a3ab9077be6 100644 --- a/sys/contrib/dev/acpica/components/parser/psloop.c +++ b/sys/contrib/dev/acpica/components/parser/psloop.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Parse the AML and build an operation tree as most interpreters, (such as * Perl) do. Parsing is done by hand rather than with a YACC generated parser @@ -489,6 +488,11 @@ AcpiPsParseLoop ( Status = AE_OK; } + if (Status == AE_CTRL_TERMINATE) + { + return_ACPI_STATUS (Status); + } + Status = AcpiPsCompleteOp (WalkState, &Op, Status); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/components/parser/psobject.c b/sys/contrib/dev/acpica/components/parser/psobject.c index 4bdb6dcf4423..11cf35a515e5 100644 --- a/sys/contrib/dev/acpica/components/parser/psobject.c +++ b/sys/contrib/dev/acpica/components/parser/psobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -229,7 +228,10 @@ AcpiPsBuildNamedOp ( Status = WalkState->DescendingCallback (WalkState, Op); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog")); + if (Status != AE_CTRL_TERMINATE) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog")); + } return_ACPI_STATUS (Status); } @@ -243,7 +245,7 @@ AcpiPsBuildNamedOp ( { if (Status == AE_CTRL_PENDING) { - return_ACPI_STATUS (AE_CTRL_PARSE_PENDING); + Status = AE_CTRL_PARSE_PENDING; } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/parser/psopcode.c b/sys/contrib/dev/acpica/components/parser/psopcode.c index 8ae0c800418d..85cb31d36f69 100644 --- a/sys/contrib/dev/acpica/components/parser/psopcode.c +++ b/sys/contrib/dev/acpica/components/parser/psopcode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/parser/psopinfo.c b/sys/contrib/dev/acpica/components/parser/psopinfo.c index 3c6e4a58beb4..6dbdfb619c23 100644 --- a/sys/contrib/dev/acpica/components/parser/psopinfo.c +++ b/sys/contrib/dev/acpica/components/parser/psopinfo.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include @@ -76,6 +75,10 @@ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode) { +#ifdef ACPI_DEBUG_OUTPUT + const char *OpcodeName = "Unknown AML opcode"; +#endif + ACPI_FUNCTION_NAME (PsGetOpcodeInfo); @@ -97,10 +100,56 @@ AcpiPsGetOpcodeInfo ( return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); } +#if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT +#include + + switch (Opcode) + { + case AML_RAW_DATA_BYTE: + OpcodeName = "-Raw Data Byte-"; + break; + + case AML_RAW_DATA_WORD: + OpcodeName = "-Raw Data Word-"; + break; + + case AML_RAW_DATA_DWORD: + OpcodeName = "-Raw Data Dword-"; + break; + + case AML_RAW_DATA_QWORD: + OpcodeName = "-Raw Data Qword-"; + break; + + case AML_RAW_DATA_BUFFER: + OpcodeName = "-Raw Data Buffer-"; + break; + + case AML_RAW_DATA_CHAIN: + OpcodeName = "-Raw Data Buffer Chain-"; + break; + + case AML_PACKAGE_LENGTH: + OpcodeName = "-Package Length-"; + break; + + case AML_UNASSIGNED_OPCODE: + OpcodeName = "-Unassigned Opcode-"; + break; + + case AML_DEFAULT_ARG_OP: + OpcodeName = "-Default Arg-"; + break; + + default: + break; + } +#endif + /* Unknown AML opcode */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Unknown AML opcode [%4.4X]\n", Opcode)); + "%s [%4.4X]\n", OpcodeName, Opcode)); return (&AcpiGbl_AmlOpInfo [_UNK]); } diff --git a/sys/contrib/dev/acpica/components/parser/psparse.c b/sys/contrib/dev/acpica/components/parser/psparse.c index 989abdfef380..52ccdec35f2a 100644 --- a/sys/contrib/dev/acpica/components/parser/psparse.c +++ b/sys/contrib/dev/acpica/components/parser/psparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * Parse the AML and build an operation tree as most interpreters, * like Perl, do. Parsing is done by hand rather than with a YACC diff --git a/sys/contrib/dev/acpica/components/parser/psscope.c b/sys/contrib/dev/acpica/components/parser/psscope.c index 3aa102bdd5ec..c396422a6738 100644 --- a/sys/contrib/dev/acpica/components/parser/psscope.c +++ b/sys/contrib/dev/acpica/components/parser/psscope.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/parser/pstree.c b/sys/contrib/dev/acpica/components/parser/pstree.c index c0eeaf623c67..4dd99794fa7a 100644 --- a/sys/contrib/dev/acpica/components/parser/pstree.c +++ b/sys/contrib/dev/acpica/components/parser/pstree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __PSTREE_C__ #include diff --git a/sys/contrib/dev/acpica/components/parser/psutils.c b/sys/contrib/dev/acpica/components/parser/psutils.c index 4b555cccf79b..1ef18bc6eab1 100644 --- a/sys/contrib/dev/acpica/components/parser/psutils.c +++ b/sys/contrib/dev/acpica/components/parser/psutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/parser/pswalk.c b/sys/contrib/dev/acpica/components/parser/pswalk.c index 6b6e289b72fd..20f32d6ed6a5 100644 --- a/sys/contrib/dev/acpica/components/parser/pswalk.c +++ b/sys/contrib/dev/acpica/components/parser/pswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include #include diff --git a/sys/contrib/dev/acpica/components/parser/psxface.c b/sys/contrib/dev/acpica/components/parser/psxface.c index 6235e197b604..d0922eee7d20 100644 --- a/sys/contrib/dev/acpica/components/parser/psxface.c +++ b/sys/contrib/dev/acpica/components/parser/psxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsaddr.c b/sys/contrib/dev/acpica/components/resources/rsaddr.c index a8fa79d20f1c..bcf76f54afed 100644 --- a/sys/contrib/dev/acpica/components/resources/rsaddr.c +++ b/sys/contrib/dev/acpica/components/resources/rsaddr.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rscalc.c b/sys/contrib/dev/acpica/components/resources/rscalc.c index 7fadb416ebbe..dfeff39e87d8 100644 --- a/sys/contrib/dev/acpica/components/resources/rscalc.c +++ b/sys/contrib/dev/acpica/components/resources/rscalc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -197,6 +197,7 @@ AcpiRsStreamOptionLength ( * FUNCTION: AcpiRsGetAmlLength * * PARAMETERS: Resource - Pointer to the resource linked list + * ResourceListSize - Size of the resource linked list * SizeNeeded - Where the required size is returned * * RETURN: Status @@ -210,9 +211,11 @@ AcpiRsStreamOptionLength ( ACPI_STATUS AcpiRsGetAmlLength ( ACPI_RESOURCE *Resource, + ACPI_SIZE ResourceListSize, ACPI_SIZE *SizeNeeded) { ACPI_SIZE AmlSizeNeeded = 0; + ACPI_RESOURCE *ResourceEnd; ACPI_RS_LENGTH TotalSize; @@ -221,7 +224,8 @@ AcpiRsGetAmlLength ( /* Traverse entire list of internal resource descriptors */ - while (Resource) + ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, ResourceListSize); + while (Resource < ResourceEnd) { /* Validate the descriptor type */ @@ -655,7 +659,7 @@ AcpiRsGetPciRoutingTableLength ( for (Index = 0; Index < NumberOfElements; Index++) { - /* Dereference the sub-package */ + /* Dereference the subpackage */ PackageElement = *TopObjectList; diff --git a/sys/contrib/dev/acpica/components/resources/rscreate.c b/sys/contrib/dev/acpica/components/resources/rscreate.c index b59966683e7f..38472725f617 100644 --- a/sys/contrib/dev/acpica/components/resources/rscreate.c +++ b/sys/contrib/dev/acpica/components/resources/rscreate.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,6 +77,10 @@ AcpiBufferToResource ( void *Resource; void *CurrentResourcePtr; + + ACPI_FUNCTION_TRACE (AcpiBufferToResource); + + /* * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag * is not required here. @@ -92,7 +96,7 @@ AcpiBufferToResource ( } if (ACPI_FAILURE (Status)) { - return (Status); + return_ACPI_STATUS (Status); } /* Allocate a buffer for the converted resource */ @@ -101,7 +105,7 @@ AcpiBufferToResource ( CurrentResourcePtr = Resource; if (!Resource) { - return (AE_NO_MEMORY); + return_ACPI_STATUS (AE_NO_MEMORY); } /* Perform the AML-to-Resource conversion */ @@ -121,9 +125,11 @@ AcpiBufferToResource ( *ResourcePtr = Resource; } - return (Status); + return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiBufferToResource) + /******************************************************************************* * @@ -297,7 +303,7 @@ AcpiRsCreatePciRoutingTable ( */ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); - /* Each sub-package must be of length 4 */ + /* Each subpackage must be of length 4 */ if ((*TopObjectList)->Package.Count != 4) { @@ -308,7 +314,7 @@ AcpiRsCreatePciRoutingTable ( } /* - * Dereference the sub-package. + * Dereference the subpackage. * The SubObjectList will now point to an array of the four IRQ * elements: [Address, Pin, Source, SourceIndex] */ @@ -317,7 +323,7 @@ AcpiRsCreatePciRoutingTable ( /* 1) First subobject: Dereference the PRT.Address */ ObjDesc = SubObjectList[0]; - if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); @@ -329,7 +335,7 @@ AcpiRsCreatePciRoutingTable ( /* 2) Second subobject: Dereference the PRT.Pin */ ObjDesc = SubObjectList[1]; - if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); @@ -410,7 +416,7 @@ AcpiRsCreatePciRoutingTable ( /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ ObjDesc = SubObjectList[3]; - if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%u].SourceIndex) Need Integer, found %s", @@ -435,23 +441,22 @@ AcpiRsCreatePciRoutingTable ( * * FUNCTION: AcpiRsCreateAmlResources * - * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's buffer + * PARAMETERS: ResourceList - Pointer to the resource list buffer + * OutputBuffer - Where the AML buffer is returned * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point * to the size buffer needed. * - * DESCRIPTION: Takes the linked list of device resources and - * creates a bytestream to be used as input for the - * _SRS control method. + * DESCRIPTION: Converts a list of device resources to an AML bytestream + * to be used as input for the _SRS control method. * ******************************************************************************/ ACPI_STATUS AcpiRsCreateAmlResources ( - ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *ResourceList, ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; @@ -461,17 +466,15 @@ AcpiRsCreateAmlResources ( ACPI_FUNCTION_TRACE (RsCreateAmlResources); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", - LinkedListBuffer)); + /* Params already validated, no need to re-validate here */ - /* - * Params already validated, so we don't re-validate here - * - * Pass the LinkedListBuffer into a module that calculates - * the buffer size needed for the byte stream. - */ - Status = AcpiRsGetAmlLength (LinkedListBuffer, - &AmlSizeNeeded); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n", + ResourceList->Pointer)); + + /* Get the buffer size needed for the AML byte stream */ + + Status = AcpiRsGetAmlLength (ResourceList->Pointer, + ResourceList->Length, &AmlSizeNeeded); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); @@ -490,14 +493,14 @@ AcpiRsCreateAmlResources ( /* Do the conversion */ - Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, - OutputBuffer->Pointer); + Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer, + AmlSizeNeeded, OutputBuffer->Pointer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", - OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/resources/rsdump.c b/sys/contrib/dev/acpica/components/resources/rsdump.c index d72979513e66..253347b85cde 100644 --- a/sys/contrib/dev/acpica/components/resources/rsdump.c +++ b/sys/contrib/dev/acpica/components/resources/rsdump.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSDUMP_C__ #include @@ -52,7 +51,7 @@ ACPI_MODULE_NAME ("rsdump") -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER) /* Local prototypes */ diff --git a/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c b/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c index 865209baea34..6fa5cef3f50a 100644 --- a/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c +++ b/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSDUMPINFO_C__ #include @@ -52,7 +51,7 @@ ACPI_MODULE_NAME ("rsdumpinfo") -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER) #define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f) diff --git a/sys/contrib/dev/acpica/components/resources/rsinfo.c b/sys/contrib/dev/acpica/components/resources/rsinfo.c index cb7233279b59..fb60bfdc8a8e 100644 --- a/sys/contrib/dev/acpica/components/resources/rsinfo.c +++ b/sys/contrib/dev/acpica/components/resources/rsinfo.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -141,7 +141,7 @@ ACPI_RSCONVERT_INFO *AcpiGbl_ConvertResourceSerialBusDispatch[] = }; -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER) /* Dispatch table for resource dump functions */ diff --git a/sys/contrib/dev/acpica/components/resources/rsio.c b/sys/contrib/dev/acpica/components/resources/rsio.c index 1a41fb960a4d..008f50423712 100644 --- a/sys/contrib/dev/acpica/components/resources/rsio.c +++ b/sys/contrib/dev/acpica/components/resources/rsio.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsirq.c b/sys/contrib/dev/acpica/components/resources/rsirq.c index b3b5ee57b1ef..8a2223ff1dbd 100644 --- a/sys/contrib/dev/acpica/components/resources/rsirq.c +++ b/sys/contrib/dev/acpica/components/resources/rsirq.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rslist.c b/sys/contrib/dev/acpica/components/resources/rslist.c index 81e729243a6a..6934ad1e0114 100644 --- a/sys/contrib/dev/acpica/components/resources/rslist.c +++ b/sys/contrib/dev/acpica/components/resources/rslist.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsmemory.c b/sys/contrib/dev/acpica/components/resources/rsmemory.c index 049a7b13f2bd..01089eea42b4 100644 --- a/sys/contrib/dev/acpica/components/resources/rsmemory.c +++ b/sys/contrib/dev/acpica/components/resources/rsmemory.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsmisc.c b/sys/contrib/dev/acpica/components/resources/rsmisc.c index e895addb4599..8194faf8e5bc 100644 --- a/sys/contrib/dev/acpica/components/resources/rsmisc.c +++ b/sys/contrib/dev/acpica/components/resources/rsmisc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsserial.c b/sys/contrib/dev/acpica/components/resources/rsserial.c index 69e225938606..dc3ffc251d79 100644 --- a/sys/contrib/dev/acpica/components/resources/rsserial.c +++ b/sys/contrib/dev/acpica/components/resources/rsserial.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/resources/rsutils.c b/sys/contrib/dev/acpica/components/resources/rsutils.c index 499efb9bed1a..c53a9643b072 100644 --- a/sys/contrib/dev/acpica/components/resources/rsutils.c +++ b/sys/contrib/dev/acpica/components/resources/rsutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSUTILS_C__ #include @@ -827,7 +826,7 @@ AcpiRsSetSrsMethodData ( * Convert the linked list into a byte stream */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); + Status = AcpiRsCreateAmlResources (InBuffer, &Buffer); if (ACPI_FAILURE (Status)) { goto Cleanup; diff --git a/sys/contrib/dev/acpica/components/resources/rsxface.c b/sys/contrib/dev/acpica/components/resources/rsxface.c index b2ff3816d76f..d2138927a9d3 100644 --- a/sys/contrib/dev/acpica/components/resources/rsxface.c +++ b/sys/contrib/dev/acpica/components/resources/rsxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __RSXFACE_C__ +#define EXPORT_ACPI_INTERFACES #include #include diff --git a/sys/contrib/dev/acpica/components/tables/tbdata.c b/sys/contrib/dev/acpica/components/tables/tbdata.c new file mode 100644 index 000000000000..19991ce196cb --- /dev/null +++ b/sys/contrib/dev/acpica/components/tables/tbdata.c @@ -0,0 +1,855 @@ +/****************************************************************************** + * + * Module Name: tbdata - Table manager data structure functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 __TBDATA_C__ + +#include +#include +#include +#include + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbdata") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitTableDescriptor + * + * PARAMETERS: TableDesc - Table descriptor + * Address - Physical address of the table + * Flags - Allocation flags of the table + * Table - Pointer to the table + * + * RETURN: None + * + * DESCRIPTION: Initialize a new table descriptor + * + ******************************************************************************/ + +void +AcpiTbInitTableDescriptor ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + ACPI_TABLE_HEADER *Table) +{ + + /* + * Initialize the table descriptor. Set the pointer to NULL, since the + * table is not fully mapped at this time. + */ + ACPI_MEMSET (TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + TableDesc->Address = Address; + TableDesc->Length = Table->Length; + TableDesc->Flags = Flags; + ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAcquireTable + * + * PARAMETERS: TableDesc - Table descriptor + * TablePtr - Where table is returned + * TableLength - Where table length is returned + * TableFlags - Where table allocation flags are returned + * + * RETURN: Status + * + * DESCRIPTION: Acquire an ACPI table. It can be used for tables not + * maintained in the AcpiGbl_RootTableList. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAcquireTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength, + UINT8 *TableFlags) +{ + ACPI_TABLE_HEADER *Table = NULL; + + + switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: + + Table = AcpiOsMapMemory (TableDesc->Address, TableDesc->Length); + break; + + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: + + Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, TableDesc->Address); + break; + + default: + + break; + } + + /* Table is not valid yet */ + + if (!Table) + { + return (AE_NO_MEMORY); + } + + /* Fill the return values */ + + *TablePtr = Table; + *TableLength = TableDesc->Length; + *TableFlags = TableDesc->Flags; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseTable + * + * PARAMETERS: Table - Pointer for the table + * TableLength - Length for the table + * TableFlags - Allocation flags for the table + * + * RETURN: None + * + * DESCRIPTION: Release a table. The inverse of AcpiTbAcquireTable(). + * + ******************************************************************************/ + +void +AcpiTbReleaseTable ( + ACPI_TABLE_HEADER *Table, + UINT32 TableLength, + UINT8 TableFlags) +{ + + switch (TableFlags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: + + AcpiOsUnmapMemory (Table, TableLength); + break; + + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: + default: + + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAcquireTempTable + * + * PARAMETERS: TableDesc - Table descriptor to be acquired + * Address - Address of the table + * Flags - Allocation flags of the table + * + * RETURN: Status + * + * DESCRIPTION: This function validates the table header to obtain the length + * of a table and fills the table descriptor to make its state as + * "INSTALLED". Such a table descriptor is only used for verified + * installation. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAcquireTempTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags) +{ + ACPI_TABLE_HEADER *TableHeader; + + + switch (Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: + + /* Get the length of the full table from the header */ + + TableHeader = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!TableHeader) + { + return (AE_NO_MEMORY); + } + + AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader); + AcpiOsUnmapMemory (TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_OK); + + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: + + TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Address); + if (!TableHeader) + { + return (AE_NO_MEMORY); + } + + AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader); + return (AE_OK); + + default: + + break; + } + + /* Table is not valid yet */ + + return (AE_NO_MEMORY); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseTempTable + * + * PARAMETERS: TableDesc - Table descriptor to be released + * + * RETURN: Status + * + * DESCRIPTION: The inverse of AcpiTbAcquireTempTable(). + * + *****************************************************************************/ + +void +AcpiTbReleaseTempTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + /* + * Note that the .Address is maintained by the callers of + * AcpiTbAcquireTempTable(), thus do not invoke AcpiTbUninstallTable() + * where .Address will be freed. + */ + AcpiTbInvalidateTable (TableDesc); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbValidateTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to validate the table, the returned + * table descriptor is in "VALIDATED" state. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbValidateTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbValidateTable); + + + /* Validate the table if necessary */ + + if (!TableDesc->Pointer) + { + Status = AcpiTbAcquireTable (TableDesc, &TableDesc->Pointer, + &TableDesc->Length, &TableDesc->Flags); + if (!TableDesc->Pointer) + { + Status = AE_NO_MEMORY; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInvalidateTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: None + * + * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of + * AcpiTbValidateTable(). + * + ******************************************************************************/ + +void +AcpiTbInvalidateTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + ACPI_FUNCTION_TRACE (TbInvalidateTable); + + + /* Table must be validated */ + + if (!TableDesc->Pointer) + { + return_VOID; + } + + AcpiTbReleaseTable (TableDesc->Pointer, TableDesc->Length, + TableDesc->Flags); + TableDesc->Pointer = NULL; + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbValidateTempTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to validate the table, the returned + * table descriptor is in "VALIDATED" state. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbValidateTempTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + if (!TableDesc->Pointer && !AcpiGbl_VerifyTableChecksum) + { + /* + * Only validates the header of the table. + * Note that Length contains the size of the mapping after invoking + * this work around, this value is required by + * AcpiTbReleaseTempTable(). + * We can do this because in AcpiInitTableDescriptor(), the Length + * field of the installed descriptor is filled with the actual + * table length obtaining from the table header. + */ + TableDesc->Length = sizeof (ACPI_TABLE_HEADER); + } + + return (AcpiTbValidateTable (TableDesc)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbVerifyTempTable + * + * PARAMETERS: TableDesc - Table descriptor + * Signature - Table signature to verify + * + * RETURN: Status + * + * DESCRIPTION: This function is called to validate and verify the table, the + * returned table descriptor is in "VALIDATED" state. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTempTable ( + ACPI_TABLE_DESC *TableDesc, + char *Signature) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbVerifyTempTable); + + + /* Validate the table */ + + Status = AcpiTbValidateTempTable (TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* If a particular signature is expected (DSDT/FACS), it must match */ + + if (Signature && + !ACPI_COMPARE_NAME (&TableDesc->Signature, Signature)) + { + ACPI_BIOS_ERROR ((AE_INFO, + "Invalid signature 0x%X for ACPI table, expected [%s]", + TableDesc->Signature.Integer, Signature)); + Status = AE_BAD_SIGNATURE; + goto InvalidateAndExit; + } + + /* Verify the checksum */ + + if (AcpiGbl_VerifyTableChecksum) + { + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, + "%4.4s " ACPI_PRINTF_UINT + " Attempted table install failed", + AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ? + TableDesc->Signature.Ascii : "????", + ACPI_FORMAT_TO_UINT (TableDesc->Address))); + goto InvalidateAndExit; + } + } + + return_ACPI_STATUS (AE_OK); + +InvalidateAndExit: + AcpiTbInvalidateTable (TableDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbResizeRootTableList + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Expand the size of global table array + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbResizeRootTableList ( + void) +{ + ACPI_TABLE_DESC *Tables; + UINT32 TableCount; + + + ACPI_FUNCTION_TRACE (TbResizeRootTableList); + + + /* AllowResize flag is a parameter to AcpiInitializeTables */ + + if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + { + ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); + return_ACPI_STATUS (AE_SUPPORT); + } + + /* Increase the Table Array size */ + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + TableCount = AcpiGbl_RootTableList.MaxTableCount; + } + else + { + TableCount = AcpiGbl_RootTableList.CurrentTableCount; + } + + Tables = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC)); + if (!Tables) + { + ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy and free the previous table array */ + + if (AcpiGbl_RootTableList.Tables) + { + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + } + + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.MaxTableCount = + TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetNextRootIndex + * + * PARAMETERS: TableIndex - Where table index is returned + * + * RETURN: Status and table index. + * + * DESCRIPTION: Allocate a new ACPI table entry to the global table list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetNextRootIndex ( + UINT32 *TableIndex) +{ + ACPI_STATUS Status; + + + /* Ensure that there is room for the table in the Root Table List */ + + if (AcpiGbl_RootTableList.CurrentTableCount >= + AcpiGbl_RootTableList.MaxTableCount) + { + Status = AcpiTbResizeRootTableList(); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; + AcpiGbl_RootTableList.CurrentTableCount++; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTerminate + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbTerminate); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Delete the individual tables */ + + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) + { + AcpiTbUninstallTable (&AcpiGbl_RootTableList.Tables[i]); + } + + /* + * Delete the root table array if allocated locally. Array cannot be + * mapped, so we don't need to check for that flag. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + + AcpiGbl_RootTableList.Tables = NULL; + AcpiGbl_RootTableList.Flags = 0; + AcpiGbl_RootTableList.CurrentTableCount = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteNamespaceByOwner + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Delete all namespace objects created when this table was loaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex) +{ + ACPI_OWNER_ID OwnerId; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) + { + /* The table index does not exist */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the owner ID for this table, used to delete namespace nodes */ + + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); + + AcpiNsDeleteNamespaceByOwner (OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAllocateOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Allocates OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbAllocateOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + Status = AcpiUtAllocateOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Releases OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbReleaseOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + AcpiUtReleaseOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetOwnerId + * + * PARAMETERS: TableIndex - Table index + * OwnerId - Where the table OwnerId is returned + * + * RETURN: Status + * + * DESCRIPTION: returns OwnerId for the ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbGetOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbIsTableLoaded + * + * PARAMETERS: TableIndex - Index into the root table + * + * RETURN: Table Loaded Flag + * + ******************************************************************************/ + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex) +{ + BOOLEAN IsLoaded = FALSE; + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + IsLoaded = (BOOLEAN) + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & + ACPI_TABLE_IS_LOADED); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (IsLoaded); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetTableLoadedFlag + * + * PARAMETERS: TableIndex - Table index + * IsLoaded - TRUE if table is loaded, FALSE otherwise + * + * RETURN: None + * + * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. + * + ******************************************************************************/ + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded) +{ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + if (IsLoaded) + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= + ACPI_TABLE_IS_LOADED; + } + else + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= + ~ACPI_TABLE_IS_LOADED; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} diff --git a/sys/contrib/dev/acpica/components/tables/tbfadt.c b/sys/contrib/dev/acpica/components/tables/tbfadt.c index 4a27520d97ed..56a3fbae325d 100644 --- a/sys/contrib/dev/acpica/components/tables/tbfadt.c +++ b/sys/contrib/dev/acpica/components/tables/tbfadt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,20 +58,23 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName); + char *RegisterName, + UINT8 Flags); static void AcpiTbConvertFadt ( void); -static void -AcpiTbValidateFadt ( - void); - static void AcpiTbSetupFadtRegisters ( void); +static UINT64 +AcpiTbSelectAddress ( + char *RegisterName, + UINT32 Address32, + UINT64 Address64); + /* Table for conversion of FADT to common internal format and FADT validation */ @@ -82,13 +85,14 @@ typedef struct acpi_fadt_info UINT16 Address32; UINT16 Length; UINT8 DefaultLength; - UINT8 Type; + UINT8 Flags; } ACPI_FADT_INFO; #define ACPI_FADT_OPTIONAL 0 #define ACPI_FADT_REQUIRED 1 #define ACPI_FADT_SEPARATE_LENGTH 2 +#define ACPI_FADT_GPE_REGISTER 4 static ACPI_FADT_INFO FadtInfoTable[] = { @@ -139,14 +143,14 @@ static ACPI_FADT_INFO FadtInfoTable[] = ACPI_FADT_OFFSET (Gpe0Block), ACPI_FADT_OFFSET (Gpe0BlockLength), 0, - ACPI_FADT_SEPARATE_LENGTH}, + ACPI_FADT_SEPARATE_LENGTH | ACPI_FADT_GPE_REGISTER}, {"Gpe1Block", ACPI_FADT_OFFSET (XGpe1Block), ACPI_FADT_OFFSET (Gpe1Block), ACPI_FADT_OFFSET (Gpe1BlockLength), 0, - ACPI_FADT_SEPARATE_LENGTH} + ACPI_FADT_SEPARATE_LENGTH | ACPI_FADT_GPE_REGISTER} }; #define ACPI_FADT_INFO_ENTRIES \ @@ -194,6 +198,7 @@ static ACPI_FADT_PM_INFO FadtPmInfoTable[] = * SpaceId - ACPI Space ID for this register * ByteWidth - Width of this register * Address - Address of the register + * RegisterName - ASCII name of the ACPI register * * RETURN: None * @@ -209,21 +214,31 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName) + char *RegisterName, + UINT8 Flags) { UINT8 BitWidth; - /* Bit width field in the GAS is only one byte long, 255 max */ - + /* + * Bit width field in the GAS is only one byte long, 255 max. + * Check for BitWidth overflow in GAS. + */ BitWidth = (UINT8) (ByteWidth * 8); - - if (ByteWidth > 31) /* (31*8)=248 */ + if (ByteWidth > 31) /* (31*8)=248, (32*8)=256 */ { - ACPI_ERROR ((AE_INFO, - "%s - 32-bit FADT register is too long (%u bytes, %u bits) " - "to convert to GAS struct - 255 bits max, truncating", - RegisterName, ByteWidth, (ByteWidth * 8))); + /* + * No error for GPE blocks, because we do not use the BitWidth + * for GPEs, the legacy length (ByteWidth) is used instead to + * allow for a large number of GPEs. + */ + if (!(Flags & ACPI_FADT_GPE_REGISTER)) + { + ACPI_ERROR ((AE_INFO, + "%s - 32-bit FADT register is too long (%u bytes, %u bits) " + "to convert to GAS struct - 255 bits max, truncating", + RegisterName, ByteWidth, (ByteWidth * 8))); + } BitWidth = 255; } @@ -243,6 +258,72 @@ AcpiTbInitGenericAddress ( } +/******************************************************************************* + * + * FUNCTION: AcpiTbSelectAddress + * + * PARAMETERS: RegisterName - ASCII name of the ACPI register + * Address32 - 32-bit address of the register + * Address64 - 64-bit address of the register + * + * RETURN: The resolved 64-bit address + * + * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within + * the FADT. Used for the FACS and DSDT addresses. + * + * NOTES: + * + * Check for FACS and DSDT address mismatches. An address mismatch between + * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and + * DSDT/X_DSDT) could be a corrupted address field or it might indicate + * the presence of two FACS or two DSDT tables. + * + * November 2013: + * By default, as per the ACPICA specification, a valid 64-bit address is + * used regardless of the value of the 32-bit address. However, this + * behavior can be overridden via the AcpiGbl_Use32BitFadtAddresses flag. + * + ******************************************************************************/ + +static UINT64 +AcpiTbSelectAddress ( + char *RegisterName, + UINT32 Address32, + UINT64 Address64) +{ + + if (!Address64) + { + /* 64-bit address is zero, use 32-bit address */ + + return ((UINT64) Address32); + } + + if (Address32 && + (Address64 != (UINT64) Address32)) + { + /* Address mismatch between 32-bit and 64-bit versions */ + + ACPI_BIOS_WARNING ((AE_INFO, + "32/64X %s address mismatch in FADT: " + "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", + RegisterName, Address32, ACPI_FORMAT_UINT64 (Address64), + AcpiGbl_Use32BitFadtAddresses ? 32 : 64)); + + /* 32-bit address override */ + + if (AcpiGbl_Use32BitFadtAddresses) + { + return ((UINT64) Address32); + } + } + + /* Default is to use the 64-bit address */ + + return (Address64); +} + + /******************************************************************************* * * FUNCTION: AcpiTbParseFadt @@ -296,14 +377,14 @@ AcpiTbParseFadt ( /* Obtain the DSDT and FACS tables via their addresses within the FADT */ - AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); /* If Hardware Reduced flag is set, there is no FACS */ if (!AcpiGbl_ReducedHardware) { - AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); } } @@ -365,10 +446,6 @@ AcpiTbCreateLocalFadt ( AcpiTbConvertFadt (); - /* Validate FADT values now, before we make any changes */ - - AcpiTbValidateFadt (); - /* Initialize the global ACPI register structures */ AcpiTbSetupFadtRegisters (); @@ -379,33 +456,43 @@ AcpiTbCreateLocalFadt ( * * FUNCTION: AcpiTbConvertFadt * - * PARAMETERS: None, uses AcpiGbl_FADT + * PARAMETERS: None - AcpiGbl_FADT is used. * * RETURN: None * * DESCRIPTION: Converts all versions of the FADT to a common internal format. - * Expand 32-bit addresses to 64-bit as necessary. + * Expand 32-bit addresses to 64-bit as necessary. Also validate + * important fields within the FADT. * - * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), - * and must contain a copy of the actual FADT. + * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), and must + * contain a copy of the actual BIOS-provided FADT. * * Notes on 64-bit register addresses: * * After this FADT conversion, later ACPICA code will only use the 64-bit "X" * fields of the FADT for all ACPI register addresses. * - * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * The 64-bit X fields are optional extensions to the original 32-bit FADT * V1.0 fields. Even if they are present in the FADT, they are optional and * are unused if the BIOS sets them to zero. Therefore, we must copy/expand - * 32-bit V1.0 fields if the corresponding X field is zero. + * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is + * originally zero. * - * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the - * corresponding "X" fields in the internal FADT. + * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address + * fields are expanded to the corresponding 64-bit X fields in the internal + * common FADT. * * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded - * to the corresponding 64-bit X fields. For compatibility with other ACPI - * implementations, we ignore the 64-bit field if the 32-bit field is valid, - * regardless of whether the host OS is 32-bit or 64-bit. + * to the corresponding 64-bit X fields, if the 64-bit field is originally + * zero. Adhering to the ACPI specification, we completely ignore the 32-bit + * field if the 64-bit field is valid, regardless of whether the host OS is + * 32-bit or 64-bit. + * + * Possible additional checks: + * (AcpiGbl_FADT.Pm1EventLength >= 4) + * (AcpiGbl_FADT.Pm1ControlLength >= 2) + * (AcpiGbl_FADT.PmTimerLength >= 4) + * Gpe block lengths must be multiple of 2 * ******************************************************************************/ @@ -413,24 +500,14 @@ static void AcpiTbConvertFadt ( void) { + char *Name; ACPI_GENERIC_ADDRESS *Address64; UINT32 Address32; + UINT8 Length; + UINT8 Flags; UINT32 i; - /* - * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. - * Later code will always use the X 64-bit field. - */ - if (!AcpiGbl_FADT.XFacs) - { - AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; - } - if (!AcpiGbl_FADT.XDsdt) - { - AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; - } - /* * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which * should be zero are indeed zero. This will workaround BIOSs that @@ -458,113 +535,14 @@ AcpiTbConvertFadt ( AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); /* - * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" - * generic address structures as necessary. Later code will always use - * the 64-bit address structures. - * - * March 2009: - * We now always use the 32-bit address if it is valid (non-null). This - * is not in accordance with the ACPI specification which states that - * the 64-bit address supersedes the 32-bit version, but we do this for - * compatibility with other ACPI implementations. Most notably, in the - * case where both the 32 and 64 versions are non-null, we use the 32-bit - * version. This is the only address that is guaranteed to have been - * tested by the BIOS manufacturer. + * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Later ACPICA code will always use the X 64-bit field. */ - for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) - { - Address32 = *ACPI_ADD_PTR (UINT32, - &AcpiGbl_FADT, FadtInfoTable[i].Address32); + AcpiGbl_FADT.XFacs = AcpiTbSelectAddress ("FACS", + AcpiGbl_FADT.Facs, AcpiGbl_FADT.XFacs); - Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, - &AcpiGbl_FADT, FadtInfoTable[i].Address64); - - /* - * If both 32- and 64-bit addresses are valid (non-zero), - * they must match. - */ - if (Address64->Address && Address32 && - (Address64->Address != (UINT64) Address32)) - { - ACPI_BIOS_ERROR ((AE_INFO, - "32/64X address mismatch in FADT/%s: " - "0x%8.8X/0x%8.8X%8.8X, using 32", - FadtInfoTable[i].Name, Address32, - ACPI_FORMAT_UINT64 (Address64->Address))); - } - - /* Always use 32-bit address if it is valid (non-null) */ - - if (Address32) - { - /* - * Copy the 32-bit address to the 64-bit GAS structure. The - * Space ID is always I/O for 32-bit legacy address fields - */ - AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO, - *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), - (UINT64) Address32, FadtInfoTable[i].Name); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbValidateFadt - * - * PARAMETERS: Table - Pointer to the FADT to be validated - * - * RETURN: None - * - * DESCRIPTION: Validate various important fields within the FADT. If a problem - * is found, issue a message, but no status is returned. - * Used by both the table manager and the disassembler. - * - * Possible additional checks: - * (AcpiGbl_FADT.Pm1EventLength >= 4) - * (AcpiGbl_FADT.Pm1ControlLength >= 2) - * (AcpiGbl_FADT.PmTimerLength >= 4) - * Gpe block lengths must be multiple of 2 - * - ******************************************************************************/ - -static void -AcpiTbValidateFadt ( - void) -{ - char *Name; - ACPI_GENERIC_ADDRESS *Address64; - UINT8 Length; - UINT32 i; - - - /* - * Check for FACS and DSDT address mismatches. An address mismatch between - * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and - * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. - */ - if (AcpiGbl_FADT.Facs && - (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs)) - { - ACPI_BIOS_WARNING ((AE_INFO, - "32/64X FACS address mismatch in FADT - " - "0x%8.8X/0x%8.8X%8.8X, using 32", - AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); - - AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; - } - - if (AcpiGbl_FADT.Dsdt && - (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt)) - { - ACPI_BIOS_WARNING ((AE_INFO, - "32/64X DSDT address mismatch in FADT - " - "0x%8.8X/0x%8.8X%8.8X, using 32", - AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); - - AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; - } + AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT", + AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt); /* If Hardware Reduced flag is set, we are all done */ @@ -578,14 +556,81 @@ AcpiTbValidateFadt ( for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { /* - * Generate pointer to the 64-bit address, get the register - * length (width) and the register name + * Get the 32-bit and 64-bit addresses, as well as the register + * length and register name. */ + Address32 = *ACPI_ADD_PTR (UINT32, + &AcpiGbl_FADT, FadtInfoTable[i].Address32); + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, - &AcpiGbl_FADT, FadtInfoTable[i].Address64); + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + Length = *ACPI_ADD_PTR (UINT8, - &AcpiGbl_FADT, FadtInfoTable[i].Length); + &AcpiGbl_FADT, FadtInfoTable[i].Length); + Name = FadtInfoTable[i].Name; + Flags = FadtInfoTable[i].Flags; + + /* + * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" + * generic address structures as necessary. Later code will always use + * the 64-bit address structures. + * + * November 2013: + * Now always use the 64-bit address if it is valid (non-zero), in + * accordance with the ACPI specification which states that a 64-bit + * address supersedes the 32-bit version. This behavior can be + * overridden by the AcpiGbl_Use32BitFadtAddresses flag. + * + * During 64-bit address construction and verification, + * these cases are handled: + * + * Address32 zero, Address64 [don't care] - Use Address64 + * + * Address32 non-zero, Address64 zero - Copy/use Address32 + * Address32 non-zero == Address64 non-zero - Use Address64 + * Address32 non-zero != Address64 non-zero - Warning, use Address64 + * + * Override: if AcpiGbl_Use32BitFadtAddresses is TRUE, and: + * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32 + * + * Note: SpaceId is always I/O for 32-bit legacy address fields + */ + if (Address32) + { + if (!Address64->Address) + { + /* 64-bit address is zero, use 32-bit address */ + + AcpiTbInitGenericAddress (Address64, + ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, + FadtInfoTable[i].Length), + (UINT64) Address32, Name, Flags); + } + else if (Address64->Address != (UINT64) Address32) + { + /* Address mismatch */ + + ACPI_BIOS_WARNING ((AE_INFO, + "32/64X address mismatch in FADT/%s: " + "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", + Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address), + AcpiGbl_Use32BitFadtAddresses ? 32 : 64)); + + if (AcpiGbl_Use32BitFadtAddresses) + { + /* 32-bit address override */ + + AcpiTbInitGenericAddress (Address64, + ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, + FadtInfoTable[i].Length), + (UINT64) Address32, Name, Flags); + } + } + } /* * For each extended field, check for length mismatch between the @@ -603,7 +648,7 @@ AcpiTbValidateFadt ( Name, ACPI_MUL_8 (Length), Address64->BitWidth)); } - if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED) + if (FadtInfoTable[i].Flags & ACPI_FADT_REQUIRED) { /* * Field is required (PM1aEvent, PM1aControl). @@ -617,7 +662,7 @@ AcpiTbValidateFadt ( Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } - else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH) + else if (FadtInfoTable[i].Flags & ACPI_FADT_SEPARATE_LENGTH) { /* * Field is optional (PM2Control, GPE0, GPE1) AND has its own @@ -724,7 +769,7 @@ AcpiTbSetupFadtRegisters ( Source64->SpaceId, Pm1RegisterByteWidth, Source64->Address + (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth), - "PmRegisters"); + "PmRegisters", 0); } } } diff --git a/sys/contrib/dev/acpica/components/tables/tbfind.c b/sys/contrib/dev/acpica/components/tables/tbfind.c index 6cd30e852c99..b59a6c2ecd0c 100644 --- a/sys/contrib/dev/acpica/components/tables/tbfind.c +++ b/sys/contrib/dev/acpica/components/tables/tbfind.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -108,7 +108,7 @@ AcpiTbFindTable ( { /* Table is not currently mapped, map it */ - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/tables/tbinstal.c b/sys/contrib/dev/acpica/components/tables/tbinstal.c index 0652b1623118..b62e0e0531cd 100644 --- a/sys/contrib/dev/acpica/components/tables/tbinstal.c +++ b/sys/contrib/dev/acpica/components/tables/tbinstal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,387 +41,447 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __TBINSTAL_C__ #include #include -#include #include - #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbinstal") +/* Local prototypes */ -/****************************************************************************** - * - * FUNCTION: AcpiTbVerifyTable - * - * PARAMETERS: TableDesc - table - * - * RETURN: Status - * - * DESCRIPTION: this function is called to verify and map table - * - *****************************************************************************/ +static BOOLEAN +AcpiTbCompareTables ( + ACPI_TABLE_DESC *TableDesc, + UINT32 TableIndex); -ACPI_STATUS -AcpiTbVerifyTable ( - ACPI_TABLE_DESC *TableDesc) + +/******************************************************************************* + * + * FUNCTION: AcpiTbCompareTables + * + * PARAMETERS: TableDesc - Table 1 descriptor to be compared + * TableIndex - Index of table 2 to be compared + * + * RETURN: TRUE if both tables are identical. + * + * DESCRIPTION: This function compares a table with another table that has + * already been installed in the root table list. + * + ******************************************************************************/ + +static BOOLEAN +AcpiTbCompareTables ( + ACPI_TABLE_DESC *TableDesc, + UINT32 TableIndex) { ACPI_STATUS Status = AE_OK; + BOOLEAN IsIdentical; + ACPI_TABLE_HEADER *Table; + UINT32 TableLength; + UINT8 TableFlags; - ACPI_FUNCTION_TRACE (TbVerifyTable); - - - /* Map the table if necessary */ - - if (!TableDesc->Pointer) + Status = AcpiTbAcquireTable (&AcpiGbl_RootTableList.Tables[TableIndex], + &Table, &TableLength, &TableFlags); + if (ACPI_FAILURE (Status)) { - if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == - ACPI_TABLE_ORIGIN_MAPPED) - { - TableDesc->Pointer = AcpiOsMapMemory ( - TableDesc->Address, TableDesc->Length); - } - - if (!TableDesc->Pointer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } + return (FALSE); } - /* Always calculate checksum, ignore bad checksum if requested */ + /* + * Check for a table match on the entire table length, + * not just the header. + */ + IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength || + ACPI_MEMCMP (TableDesc->Pointer, Table, TableLength)) ? + FALSE : TRUE); - Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + /* Release the acquired table */ - return_ACPI_STATUS (Status); + AcpiTbReleaseTable (Table, TableLength, TableFlags); + return (IsIdentical); } /******************************************************************************* * - * FUNCTION: AcpiTbAddTable + * FUNCTION: AcpiTbInstallTableWithOverride * - * PARAMETERS: TableDesc - Table descriptor - * TableIndex - Where the table index is returned + * PARAMETERS: TableIndex - Index into root table array + * NewTableDesc - New table descriptor to install + * Override - Whether override should be performed * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: This function is called to add an ACPI table. It is used to - * dynamically load tables via the Load and LoadTable AML - * operators. + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is called to allow the host + * OS to replace any table before it is installed in the root + * table array. * ******************************************************************************/ -ACPI_STATUS -AcpiTbAddTable ( - ACPI_TABLE_DESC *TableDesc, - UINT32 *TableIndex) +void +AcpiTbInstallTableWithOverride ( + UINT32 TableIndex, + ACPI_TABLE_DESC *NewTableDesc, + BOOLEAN Override) { - UINT32 i; - ACPI_STATUS Status = AE_OK; - - ACPI_FUNCTION_TRACE (TbAddTable); - - - if (!TableDesc->Pointer) + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { - Status = AcpiTbVerifyTable (TableDesc); - if (ACPI_FAILURE (Status) || !TableDesc->Pointer) - { - return_ACPI_STATUS (Status); - } - } - - /* - * Validate the incoming table signature. - * - * 1) Originally, we checked the table signature for "SSDT" or "PSDT". - * 2) We added support for OEMx tables, signature "OEM". - * 3) Valid tables were encountered with a null signature, so we just - * gave up on validating the signature, (05/2008). - * 4) We encountered non-AML tables such as the MADT, which caused - * interpreter errors and kernel faults. So now, we once again allow - * only "SSDT", "OEMx", and now, also a null signature. (05/2011). - */ - if ((TableDesc->Pointer->Signature[0] != 0x00) && - (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) && - (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3))) - { - ACPI_BIOS_ERROR ((AE_INFO, - "Table has invalid signature [%4.4s] (0x%8.8X), " - "must be SSDT or OEMx", - AcpiUtValidAcpiName (TableDesc->Pointer->Signature) ? - TableDesc->Pointer->Signature : "????", - *(UINT32 *) TableDesc->Pointer->Signature)); - - return_ACPI_STATUS (AE_BAD_SIGNATURE); - } - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - - /* Check if table is already registered */ - - for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) - { - if (!AcpiGbl_RootTableList.Tables[i].Pointer) - { - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); - if (ACPI_FAILURE (Status) || - !AcpiGbl_RootTableList.Tables[i].Pointer) - { - continue; - } - } - - /* - * Check for a table match on the entire table length, - * not just the header. - */ - if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length) - { - continue; - } - - if (ACPI_MEMCMP (TableDesc->Pointer, - AcpiGbl_RootTableList.Tables[i].Pointer, - AcpiGbl_RootTableList.Tables[i].Length)) - { - continue; - } - - /* - * Note: the current mechanism does not unregister a table if it is - * dynamically unloaded. The related namespace entries are deleted, - * but the table remains in the root table list. - * - * The assumption here is that the number of different tables that - * will be loaded is actually small, and there is minimal overhead - * in just keeping the table in case it is needed again. - * - * If this assumption changes in the future (perhaps on large - * machines with many table load/unload operations), tables will - * need to be unregistered when they are unloaded, and slots in the - * root table list should be reused when empty. - */ - - /* - * Table is already registered. - * We can delete the table that was passed as a parameter. - */ - AcpiTbDeleteTable (TableDesc); - *TableIndex = i; - - if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) - { - /* Table is still loaded, this is an error */ - - Status = AE_ALREADY_EXISTS; - goto Release; - } - else - { - /* Table was unloaded, allow it to be reloaded */ - - TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer; - TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address; - Status = AE_OK; - goto PrintHeader; - } + return; } /* * ACPI Table Override: - * Allow the host to override dynamically loaded tables. - * NOTE: the table is fully mapped at this point, and the mapping will - * be deleted by TbTableOverride if the table is actually overridden. + * + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. */ - (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc); - - /* Add the table to the global root table list */ - - Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, - TableDesc->Length, TableDesc->Flags, TableIndex); - if (ACPI_FAILURE (Status)) + if (Override) { - goto Release; + AcpiTbOverrideTable (NewTableDesc); } -PrintHeader: - AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); + AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[TableIndex], + NewTableDesc->Address, NewTableDesc->Flags, NewTableDesc->Pointer); -Release: - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + AcpiTbPrintTableHeader (NewTableDesc->Address, NewTableDesc->Pointer); + + /* Set the global integer width (based upon revision of the DSDT) */ + + if (TableIndex == ACPI_TABLE_INDEX_DSDT) + { + AcpiUtSetIntegerWidth (NewTableDesc->Pointer->Revision); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallFixedTable + * + * PARAMETERS: Address - Physical address of DSDT or FACS + * Signature - Table signature, NULL if no need to + * match + * TableIndex - Index into root table array + * + * RETURN: Status + * + * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data + * structure. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInstallFixedTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex) +{ + ACPI_TABLE_DESC NewTableDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbInstallFixedTable); + + + if (!Address) + { + ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", + Signature)); + return (AE_NO_MEMORY); + } + + /* Fill a table descriptor for validation */ + + Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not acquire table length at %p", + ACPI_CAST_PTR (void, Address))); + return_ACPI_STATUS (Status); + } + + /* Validate and verify a table before installation */ + + Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature); + if (ACPI_FAILURE (Status)) + { + goto ReleaseAndExit; + } + + AcpiTbInstallTableWithOverride (TableIndex, &NewTableDesc, TRUE); + +ReleaseAndExit: + + /* Release the temporary table descriptor */ + + AcpiTbReleaseTempTable (&NewTableDesc); return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbTableOverride + * FUNCTION: AcpiTbInstallStandardTable * - * PARAMETERS: TableHeader - Header for the original table - * TableDesc - Table descriptor initialized for the - * original table. May or may not be mapped. + * PARAMETERS: Address - Address of the table (might be a virtual + * address depending on the TableFlags) + * Flags - Flags for the table + * Reload - Whether reload should be performed + * Override - Whether override should be performed + * TableIndex - Where the table index is returned * - * RETURN: Pointer to the entire new table. NULL if table not overridden. - * If overridden, installs the new table within the input table - * descriptor. + * RETURN: Status * - * DESCRIPTION: Attempt table override by calling the OSL override functions. - * Note: If the table is overridden, then the entire new table - * is mapped and returned by this function. + * DESCRIPTION: This function is called to install an ACPI table that is + * neither DSDT nor FACS (a "standard" table.) + * When this function is called by "Load" or "LoadTable" opcodes, + * or by AcpiLoadTable() API, the "Reload" parameter is set. + * After sucessfully returning from this function, table is + * "INSTALLED" but not "VALIDATED". * ******************************************************************************/ -ACPI_TABLE_HEADER * -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *TableHeader, - ACPI_TABLE_DESC *TableDesc) +ACPI_STATUS +AcpiTbInstallStandardTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + BOOLEAN Reload, + BOOLEAN Override, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_DESC NewTableDesc; + + + ACPI_FUNCTION_TRACE (TbInstallStandardTable); + + + /* Acquire a temporary table descriptor for validation */ + + Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, Flags); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not acquire table length at %p", + ACPI_CAST_PTR (void, Address))); + return_ACPI_STATUS (Status); + } + + /* + * Optionally do not load any SSDTs from the RSDT/XSDT. This can + * be useful for debugging ACPI problems on some machines. + */ + if (!Reload && + AcpiGbl_DisableSsdtTableInstall && + ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) + { + ACPI_INFO ((AE_INFO, "Ignoring installation of %4.4s at %p", + NewTableDesc.Signature.Ascii, ACPI_CAST_PTR (void, Address))); + goto ReleaseAndExit; + } + + /* Validate and verify a table before installation */ + + Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL); + if (ACPI_FAILURE (Status)) + { + goto ReleaseAndExit; + } + + if (Reload) + { + /* + * Validate the incoming table signature. + * + * 1) Originally, we checked the table signature for "SSDT" or "PSDT". + * 2) We added support for OEMx tables, signature "OEM". + * 3) Valid tables were encountered with a null signature, so we just + * gave up on validating the signature, (05/2008). + * 4) We encountered non-AML tables such as the MADT, which caused + * interpreter errors and kernel faults. So now, we once again allow + * only "SSDT", "OEMx", and now, also a null signature. (05/2011). + */ + if ((NewTableDesc.Signature.Ascii[0] != 0x00) && + (!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) && + (ACPI_STRNCMP (NewTableDesc.Signature.Ascii, "OEM", 3))) + { + ACPI_BIOS_ERROR ((AE_INFO, + "Table has invalid signature [%4.4s] (0x%8.8X), " + "must be SSDT or OEMx", + AcpiUtValidAcpiName (NewTableDesc.Signature.Ascii) ? + NewTableDesc.Signature.Ascii : "????", + NewTableDesc.Signature.Integer)); + + Status = AE_BAD_SIGNATURE; + goto ReleaseAndExit; + } + + /* Check if table is already registered */ + + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) + { + /* + * Check for a table match on the entire table length, + * not just the header. + */ + if (!AcpiTbCompareTables (&NewTableDesc, i)) + { + continue; + } + + /* + * Note: the current mechanism does not unregister a table if it is + * dynamically unloaded. The related namespace entries are deleted, + * but the table remains in the root table list. + * + * The assumption here is that the number of different tables that + * will be loaded is actually small, and there is minimal overhead + * in just keeping the table in case it is needed again. + * + * If this assumption changes in the future (perhaps on large + * machines with many table load/unload operations), tables will + * need to be unregistered when they are unloaded, and slots in the + * root table list should be reused when empty. + */ + if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) + { + /* Table is still loaded, this is an error */ + + Status = AE_ALREADY_EXISTS; + goto ReleaseAndExit; + } + else + { + /* + * Table was unloaded, allow it to be reloaded. + * As we are going to return AE_OK to the caller, we should + * take the responsibility of freeing the input descriptor. + * Refill the input descriptor to ensure + * AcpiTbInstallTableWithOverride() can be called again to + * indicate the re-installation. + */ + AcpiTbUninstallTable (&NewTableDesc); + *TableIndex = i; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_OK); + } + } + } + + /* Add the table to the global root table list */ + + Status = AcpiTbGetNextRootIndex (&i); + if (ACPI_FAILURE (Status)) + { + goto ReleaseAndExit; + } + + *TableIndex = i; + AcpiTbInstallTableWithOverride (i, &NewTableDesc, Override); + +ReleaseAndExit: + + /* Release the temporary table descriptor */ + + AcpiTbReleaseTempTable (&NewTableDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbOverrideTable + * + * PARAMETERS: OldTableDesc - Validated table descriptor to be + * overridden + * + * RETURN: None + * + * DESCRIPTION: Attempt table override by calling the OSL override functions. + * Note: If the table is overridden, then the entire new table + * is acquired and returned by this function. + * Before/after invocation, the table descriptor is in a state + * that is "VALIDATED". + * + ******************************************************************************/ + +void +AcpiTbOverrideTable ( + ACPI_TABLE_DESC *OldTableDesc) { ACPI_STATUS Status; - ACPI_TABLE_HEADER *NewTable = NULL; - ACPI_PHYSICAL_ADDRESS NewAddress = 0; - UINT32 NewTableLength = 0; - UINT8 NewFlags; char *OverrideType; + ACPI_TABLE_DESC NewTableDesc; + ACPI_TABLE_HEADER *Table; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; /* (1) Attempt logical override (returns a logical address) */ - Status = AcpiOsTableOverride (TableHeader, &NewTable); - if (ACPI_SUCCESS (Status) && NewTable) + Status = AcpiOsTableOverride (OldTableDesc->Pointer, &Table); + if (ACPI_SUCCESS (Status) && Table) { - NewAddress = ACPI_PTR_TO_PHYSADDR (NewTable); - NewTableLength = NewTable->Length; - NewFlags = ACPI_TABLE_ORIGIN_OVERRIDE; + AcpiTbAcquireTempTable (&NewTableDesc, ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL); OverrideType = "Logical"; goto FinishOverride; } /* (2) Attempt physical override (returns a physical address) */ - Status = AcpiOsPhysicalTableOverride (TableHeader, - &NewAddress, &NewTableLength); - if (ACPI_SUCCESS (Status) && NewAddress && NewTableLength) + Status = AcpiOsPhysicalTableOverride (OldTableDesc->Pointer, + &Address, &Length); + if (ACPI_SUCCESS (Status) && Address && Length) { - /* Map the entire new table */ - - NewTable = AcpiOsMapMemory (NewAddress, NewTableLength); - if (!NewTable) - { - ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, - "%4.4s %p Attempted physical table override failed", - TableHeader->Signature, - ACPI_CAST_PTR (void, TableDesc->Address))); - return (NULL); - } - + AcpiTbAcquireTempTable (&NewTableDesc, Address, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); OverrideType = "Physical"; - NewFlags = ACPI_TABLE_ORIGIN_MAPPED; goto FinishOverride; } - return (NULL); /* There was no override */ + return; /* There was no override */ FinishOverride: - ACPI_INFO ((AE_INFO, - "%4.4s %p %s table override, new table: %p", - TableHeader->Signature, - ACPI_CAST_PTR (void, TableDesc->Address), - OverrideType, NewTable)); + /* Validate and verify a table before overriding */ - /* We can now unmap/delete the original table (if fully mapped) */ - - AcpiTbDeleteTable (TableDesc); - - /* Setup descriptor for the new table */ - - TableDesc->Address = NewAddress; - TableDesc->Pointer = NewTable; - TableDesc->Length = NewTableLength; - TableDesc->Flags = NewFlags; - - return (NewTable); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbResizeRootTableList - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Expand the size of global table array - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbResizeRootTableList ( - void) -{ - ACPI_TABLE_DESC *Tables; - UINT32 TableCount; - - - ACPI_FUNCTION_TRACE (TbResizeRootTableList); - - - /* AllowResize flag is a parameter to AcpiInitializeTables */ - - if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + Status = AcpiTbVerifyTempTable (&NewTableDesc, NULL); + if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); - return_ACPI_STATUS (AE_SUPPORT); + return; } - /* Increase the Table Array size */ + ACPI_INFO ((AE_INFO, "%4.4s " ACPI_PRINTF_UINT + " %s table override, new table: " ACPI_PRINTF_UINT, + OldTableDesc->Signature.Ascii, + ACPI_FORMAT_TO_UINT (OldTableDesc->Address), + OverrideType, ACPI_FORMAT_TO_UINT (NewTableDesc.Address))); - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) - { - TableCount = AcpiGbl_RootTableList.MaxTableCount; - } - else - { - TableCount = AcpiGbl_RootTableList.CurrentTableCount; - } + /* We can now uninstall the original table */ - Tables = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * - sizeof (ACPI_TABLE_DESC)); - if (!Tables) - { - ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); - return_ACPI_STATUS (AE_NO_MEMORY); - } + AcpiTbUninstallTable (OldTableDesc); - /* Copy and free the previous table array */ + /* + * Replace the original table descriptor and keep its state as + * "VALIDATED". + */ + AcpiTbInitTableDescriptor (OldTableDesc, NewTableDesc.Address, + NewTableDesc.Flags, NewTableDesc.Pointer); + AcpiTbValidateTempTable (OldTableDesc); - if (AcpiGbl_RootTableList.Tables) - { - ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, - (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); + /* Release the temporary table descriptor */ - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) - { - ACPI_FREE (AcpiGbl_RootTableList.Tables); - } - } - - AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.MaxTableCount = - TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; - AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; - - return_ACPI_STATUS (AE_OK); + AcpiTbReleaseTempTable (&NewTableDesc); } @@ -432,7 +492,8 @@ AcpiTbResizeRootTableList ( * PARAMETERS: Address - Table address * Table - Table header * Length - Table length - * Flags - flags + * Flags - Install flags + * TableIndex - Where the table index is returned * * RETURN: Status and table index. * @@ -449,44 +510,29 @@ AcpiTbStoreTable ( UINT32 *TableIndex) { ACPI_STATUS Status; - ACPI_TABLE_DESC *NewTable; + ACPI_TABLE_DESC *TableDesc; - /* Ensure that there is room for the table in the Root Table List */ - - if (AcpiGbl_RootTableList.CurrentTableCount >= - AcpiGbl_RootTableList.MaxTableCount) + Status = AcpiTbGetNextRootIndex (TableIndex); + if (ACPI_FAILURE (Status)) { - Status = AcpiTbResizeRootTableList(); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + return (Status); } - NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount]; - /* Initialize added table */ - NewTable->Address = Address; - NewTable->Pointer = Table; - NewTable->Length = Length; - NewTable->OwnerId = 0; - NewTable->Flags = Flags; - - ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature); - - *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; - AcpiGbl_RootTableList.CurrentTableCount++; + TableDesc = &AcpiGbl_RootTableList.Tables[*TableIndex]; + AcpiTbInitTableDescriptor (TableDesc, Address, Flags, Table); + TableDesc->Pointer = Table; return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiTbDeleteTable + * FUNCTION: AcpiTbUninstallTable * - * PARAMETERS: TableIndex - Table index + * PARAMETERS: TableDesc - Table descriptor * * RETURN: None * @@ -495,324 +541,28 @@ AcpiTbStoreTable ( ******************************************************************************/ void -AcpiTbDeleteTable ( +AcpiTbUninstallTable ( ACPI_TABLE_DESC *TableDesc) { - /* Table must be mapped or allocated */ + ACPI_FUNCTION_TRACE (TbUninstallTable); - if (!TableDesc->Pointer) + + /* Table must be installed */ + + if (!TableDesc->Address) { - return; + return_VOID; } - switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) + AcpiTbInvalidateTable (TableDesc); + + if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) { - case ACPI_TABLE_ORIGIN_MAPPED: - - AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); - break; - - case ACPI_TABLE_ORIGIN_ALLOCATED: - - ACPI_FREE (TableDesc->Pointer); - break; - - /* Not mapped or allocated, there is nothing we can do */ - - default: - - return; + ACPI_FREE (ACPI_CAST_PTR (void, TableDesc->Address)); } - TableDesc->Pointer = NULL; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbTerminate - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Delete all internal ACPI tables - * - ******************************************************************************/ - -void -AcpiTbTerminate ( - void) -{ - UINT32 i; - - - ACPI_FUNCTION_TRACE (TbTerminate); - - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - - /* Delete the individual tables */ - - for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) - { - AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); - } - - /* - * Delete the root table array if allocated locally. Array cannot be - * mapped, so we don't need to check for that flag. - */ - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) - { - ACPI_FREE (AcpiGbl_RootTableList.Tables); - } - - AcpiGbl_RootTableList.Tables = NULL; - AcpiGbl_RootTableList.Flags = 0; - AcpiGbl_RootTableList.CurrentTableCount = 0; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - + TableDesc->Address = ACPI_PTR_TO_PHYSADDR (NULL); return_VOID; } - - -/******************************************************************************* - * - * FUNCTION: AcpiTbDeleteNamespaceByOwner - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Status - * - * DESCRIPTION: Delete all namespace objects created when this table was loaded. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbDeleteNamespaceByOwner ( - UINT32 TableIndex) -{ - ACPI_OWNER_ID OwnerId; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) - { - /* The table index does not exist */ - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_NOT_EXIST); - } - - /* Get the owner ID for this table, used to delete namespace nodes */ - - OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - - /* - * Need to acquire the namespace writer lock to prevent interference - * with any concurrent namespace walks. The interpreter must be - * released during the deletion since the acquisition of the deletion - * lock may block, and also since the execution of a namespace walk - * must be allowed to use the interpreter. - */ - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); - Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); - - AcpiNsDeleteNamespaceByOwner (OwnerId); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); - - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbAllocateOwnerId - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Status - * - * DESCRIPTION: Allocates OwnerId in TableDesc - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbAllocateOwnerId ( - UINT32 TableIndex) -{ - ACPI_STATUS Status = AE_BAD_PARAMETER; - - - ACPI_FUNCTION_TRACE (TbAllocateOwnerId); - - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - Status = AcpiUtAllocateOwnerId - (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbReleaseOwnerId - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Status - * - * DESCRIPTION: Releases OwnerId in TableDesc - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbReleaseOwnerId ( - UINT32 TableIndex) -{ - ACPI_STATUS Status = AE_BAD_PARAMETER; - - - ACPI_FUNCTION_TRACE (TbReleaseOwnerId); - - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - AcpiUtReleaseOwnerId ( - &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); - Status = AE_OK; - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetOwnerId - * - * PARAMETERS: TableIndex - Table index - * OwnerId - Where the table OwnerId is returned - * - * RETURN: Status - * - * DESCRIPTION: returns OwnerId for the ACPI table - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetOwnerId ( - UINT32 TableIndex, - ACPI_OWNER_ID *OwnerId) -{ - ACPI_STATUS Status = AE_BAD_PARAMETER; - - - ACPI_FUNCTION_TRACE (TbGetOwnerId); - - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; - Status = AE_OK; - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbIsTableLoaded - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Table Loaded Flag - * - ******************************************************************************/ - -BOOLEAN -AcpiTbIsTableLoaded ( - UINT32 TableIndex) -{ - BOOLEAN IsLoaded = FALSE; - - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - IsLoaded = (BOOLEAN) - (AcpiGbl_RootTableList.Tables[TableIndex].Flags & - ACPI_TABLE_IS_LOADED); - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return (IsLoaded); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbSetTableLoadedFlag - * - * PARAMETERS: TableIndex - Table index - * IsLoaded - TRUE if table is loaded, FALSE otherwise - * - * RETURN: None - * - * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. - * - ******************************************************************************/ - -void -AcpiTbSetTableLoadedFlag ( - UINT32 TableIndex, - BOOLEAN IsLoaded) -{ - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - if (IsLoaded) - { - AcpiGbl_RootTableList.Tables[TableIndex].Flags |= - ACPI_TABLE_IS_LOADED; - } - else - { - AcpiGbl_RootTableList.Tables[TableIndex].Flags &= - ~ACPI_TABLE_IS_LOADED; - } - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); -} diff --git a/sys/contrib/dev/acpica/components/tables/tbprint.c b/sys/contrib/dev/acpica/components/tables/tbprint.c index e85acce243b3..00b6f1aee1ac 100644 --- a/sys/contrib/dev/acpica/components/tables/tbprint.c +++ b/sys/contrib/dev/acpica/components/tables/tbprint.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -147,15 +147,17 @@ AcpiTbPrintTableHeader ( /* - * The reason that the Address is cast to a void pointer is so that we - * can use %p which will work properly on both 32-bit and 64-bit hosts. + * The reason that we use ACPI_PRINTF_UINT and ACPI_FORMAT_TO_UINT is to + * support both 32-bit and 64-bit hosts/addresses in a consistent manner. + * The %p specifier does not emit uniform output on all hosts. On some, + * leading zeros are not supported. */ if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS)) { /* FACS only has signature and length fields */ - ACPI_INFO ((AE_INFO, "%4.4s %p %05X", - Header->Signature, ACPI_CAST_PTR (void, Address), + ACPI_INFO ((AE_INFO, "%-4.4s " ACPI_PRINTF_UINT " %06X", + Header->Signature, ACPI_FORMAT_TO_UINT (Address), Header->Length)); } else if (ACPI_VALIDATE_RSDP_SIG (Header->Signature)) @@ -166,8 +168,8 @@ AcpiTbPrintTableHeader ( ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); - ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", - ACPI_CAST_PTR (void, Address), + ACPI_INFO ((AE_INFO, "RSDP " ACPI_PRINTF_UINT " %06X (v%.2d %-6.6s)", + ACPI_FORMAT_TO_UINT (Address), (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, @@ -180,8 +182,9 @@ AcpiTbPrintTableHeader ( AcpiTbCleanupTableHeader (&LocalHeader, Header); ACPI_INFO ((AE_INFO, - "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", - LocalHeader.Signature, ACPI_CAST_PTR (void, Address), + "%-4.4s " ACPI_PRINTF_UINT + " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)", + LocalHeader.Signature, ACPI_FORMAT_TO_UINT (Address), LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId, LocalHeader.OemTableId, LocalHeader.OemRevision, LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision)); diff --git a/sys/contrib/dev/acpica/components/tables/tbutils.c b/sys/contrib/dev/acpica/components/tables/tbutils.c index 5cc157d271d5..e86e1d1f3cf3 100644 --- a/sys/contrib/dev/acpica/components/tables/tbutils.c +++ b/sys/contrib/dev/acpica/components/tables/tbutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -193,9 +193,12 @@ AcpiTbCopyDsdt ( } ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length); - AcpiTbDeleteTable (TableDesc); - TableDesc->Pointer = NewTable; - TableDesc->Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + AcpiTbUninstallTable (TableDesc); + + AcpiTbInitTableDescriptor ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT], + ACPI_PTR_TO_PHYSADDR (NewTable), ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, + NewTable); ACPI_INFO ((AE_INFO, "Forced DSDT copy: length 0x%05X copied locally, original unmapped", @@ -205,125 +208,6 @@ AcpiTbCopyDsdt ( } -/******************************************************************************* - * - * FUNCTION: AcpiTbInstallTable - * - * PARAMETERS: Address - Physical address of DSDT or FACS - * Signature - Table signature, NULL if no need to - * match - * TableIndex - Index into root table array - * - * RETURN: None - * - * DESCRIPTION: Install an ACPI table into the global data structure. The - * table override mechanism is called to allow the host - * OS to replace any table before it is installed in the root - * table array. - * - ******************************************************************************/ - -void -AcpiTbInstallTable ( - ACPI_PHYSICAL_ADDRESS Address, - char *Signature, - UINT32 TableIndex) -{ - ACPI_TABLE_HEADER *Table; - ACPI_TABLE_HEADER *FinalTable; - ACPI_TABLE_DESC *TableDesc; - - - if (!Address) - { - ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", - Signature)); - return; - } - - /* Map just the table header */ - - Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); - if (!Table) - { - ACPI_ERROR ((AE_INFO, "Could not map memory for table [%s] at %p", - Signature, ACPI_CAST_PTR (void, Address))); - return; - } - - /* If a particular signature is expected (DSDT/FACS), it must match */ - - if (Signature && - !ACPI_COMPARE_NAME (Table->Signature, Signature)) - { - ACPI_BIOS_ERROR ((AE_INFO, - "Invalid signature 0x%X for ACPI table, expected [%s]", - *ACPI_CAST_PTR (UINT32, Table->Signature), Signature)); - goto UnmapAndExit; - } - - /* - * Initialize the table entry. Set the pointer to NULL, since the - * table is not fully mapped at this time. - */ - TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex]; - - TableDesc->Address = Address; - TableDesc->Pointer = NULL; - TableDesc->Length = Table->Length; - TableDesc->Flags = ACPI_TABLE_ORIGIN_MAPPED; - ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature); - - /* - * ACPI Table Override: - * - * Before we install the table, let the host OS override it with a new - * one if desired. Any table within the RSDT/XSDT can be replaced, - * including the DSDT which is pointed to by the FADT. - * - * NOTE: If the table is overridden, then FinalTable will contain a - * mapped pointer to the full new table. If the table is not overridden, - * or if there has been a physical override, then the table will be - * fully mapped later (in verify table). In any case, we must - * unmap the header that was mapped above. - */ - FinalTable = AcpiTbTableOverride (Table, TableDesc); - if (!FinalTable) - { - FinalTable = Table; /* There was no override */ - } - - AcpiTbPrintTableHeader (TableDesc->Address, FinalTable); - - /* Set the global integer width (based upon revision of the DSDT) */ - - if (TableIndex == ACPI_TABLE_INDEX_DSDT) - { - AcpiUtSetIntegerWidth (FinalTable->Revision); - } - - /* - * If we have a physical override during this early loading of the ACPI - * tables, unmap the table for now. It will be mapped again later when - * it is actually used. This supports very early loading of ACPI tables, - * before virtual memory is fully initialized and running within the - * host OS. Note: A logical override has the ACPI_TABLE_ORIGIN_OVERRIDE - * flag set and will not be deleted below. - */ - if (FinalTable != Table) - { - AcpiTbDeleteTable (TableDesc); - } - - -UnmapAndExit: - - /* Always unmap the table header that we mapped above */ - - AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); -} - - /******************************************************************************* * * FUNCTION: AcpiTbGetRootTableEntry @@ -353,7 +237,7 @@ AcpiTbGetRootTableEntry ( * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT */ - if (TableEntrySize == sizeof (UINT32)) + if (TableEntrySize == ACPI_RSDT_ENTRY_SIZE) { /* * 32-bit platform, RSDT: Return 32-bit table entry @@ -416,14 +300,14 @@ AcpiTbParseRootTable ( UINT32 Length; UINT8 *TableEntry; ACPI_STATUS Status; + UINT32 TableIndex; ACPI_FUNCTION_TRACE (TbParseRootTable); - /* - * Map the entire RSDP and extract the address of the RSDT or XSDT - */ + /* Map the entire RSDP and extract the address of the RSDT or XSDT */ + Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP)); if (!Rsdp) { @@ -433,24 +317,26 @@ AcpiTbParseRootTable ( AcpiTbPrintTableHeader (RsdpAddress, ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); - /* Differentiate between RSDT and XSDT root tables */ + /* Use XSDT if present and not overridden. Otherwise, use RSDT */ - if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress) + if ((Rsdp->Revision > 1) && + Rsdp->XsdtPhysicalAddress && + !AcpiGbl_DoNotUseXsdt) { /* - * Root table is an XSDT (64-bit physical addresses). We must use the - * XSDT if the revision is > 1 and the XSDT pointer is present, as per - * the ACPI specification. + * RSDP contains an XSDT (64-bit physical addresses). We must use + * the XSDT if the revision is > 1 and the XSDT pointer is present, + * as per the ACPI specification. */ Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress; - TableEntrySize = sizeof (UINT64); + TableEntrySize = ACPI_XSDT_ENTRY_SIZE; } else { /* Root table is an RSDT (32-bit physical addresses) */ Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; - TableEntrySize = sizeof (UINT32); + TableEntrySize = ACPI_RSDT_ENTRY_SIZE; } /* @@ -459,7 +345,6 @@ AcpiTbParseRootTable ( */ AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); - /* Map the RSDT/XSDT table header to get the full table length */ Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); @@ -470,12 +355,14 @@ AcpiTbParseRootTable ( AcpiTbPrintTableHeader (Address, Table); - /* Get the length of the full table, verify length and map entire table */ - + /* + * Validate length of the table, and map entire table. + * Minimum length table must contain at least one entry. + */ Length = Table->Length; AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); - if (Length < sizeof (ACPI_TABLE_HEADER)) + if (Length < (sizeof (ACPI_TABLE_HEADER) + TableEntrySize)) { ACPI_BIOS_ERROR ((AE_INFO, "Invalid table length 0x%X in RSDT/XSDT", Length)); @@ -497,71 +384,50 @@ AcpiTbParseRootTable ( return_ACPI_STATUS (Status); } - /* Calculate the number of tables described in the root table */ + /* Get the number of entries and pointer to first entry */ TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / TableEntrySize); + TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER)); /* * First two entries in the table array are reserved for the DSDT * and FACS, which are not actually present in the RSDT/XSDT - they * come from the FADT */ - TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); AcpiGbl_RootTableList.CurrentTableCount = 2; - /* - * Initialize the root table array from the RSDT/XSDT - */ + /* Initialize the root table array from the RSDT/XSDT */ + for (i = 0; i < TableCount; i++) { - if (AcpiGbl_RootTableList.CurrentTableCount >= - AcpiGbl_RootTableList.MaxTableCount) - { - /* There is no more room in the root table array, attempt resize */ - - Status = AcpiTbResizeRootTableList (); - if (ACPI_FAILURE (Status)) - { - ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", - (unsigned) (TableCount - - (AcpiGbl_RootTableList.CurrentTableCount - 2)))); - break; - } - } - /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount].Address = - AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + Address = AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + + /* Skip NULL entries in RSDT/XSDT */ + + if (!Address) + { + goto NextTable; + } + + Status = AcpiTbInstallStandardTable (Address, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, &TableIndex); + + if (ACPI_SUCCESS (Status) && + ACPI_COMPARE_NAME (&AcpiGbl_RootTableList.Tables[TableIndex].Signature, + ACPI_SIG_FADT)) + { + AcpiTbParseFadt (TableIndex); + } + +NextTable: TableEntry += TableEntrySize; - AcpiGbl_RootTableList.CurrentTableCount++; } - /* - * It is not possible to map more than one entry in some environments, - * so unmap the root table here before mapping other tables - */ AcpiOsUnmapMemory (Table, Length); - /* - * Complete the initialization of the root table array by examining - * the header of each table - */ - for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; i++) - { - AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, - NULL, i); - - /* Special case for FADT - get the DSDT and FACS */ - - if (ACPI_COMPARE_NAME ( - &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) - { - AcpiTbParseFadt (i); - } - } - return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/tables/tbxface.c b/sys/contrib/dev/acpica/components/tables/tbxface.c index 80381aa8d38c..126d9ca3c2aa 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxface.c +++ b/sys/contrib/dev/acpica/components/tables/tbxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #define __TBXFACE_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -161,7 +162,7 @@ AcpiInitializeTables ( return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiInitializeTables) +ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeTables) /******************************************************************************* @@ -204,7 +205,7 @@ AcpiReallocateRootTable ( return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) +ACPI_EXPORT_SYMBOL_INIT (AcpiReallocateRootTable) /******************************************************************************* @@ -261,7 +262,7 @@ AcpiGetTableHeader ( { if ((AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_ORIGIN_MASK) == - ACPI_TABLE_ORIGIN_MAPPED) + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) { Header = AcpiOsMapMemory ( AcpiGbl_RootTableList.Tables[i].Address, @@ -344,7 +345,7 @@ AcpiGetTable ( continue; } - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); if (ACPI_SUCCESS (Status)) { *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; @@ -405,7 +406,7 @@ AcpiGetTableByIndex ( { /* Table is not mapped, map it */ - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); diff --git a/sys/contrib/dev/acpica/components/tables/tbxfload.c b/sys/contrib/dev/acpica/components/tables/tbxfload.c index 171f74c0fc70..da34e3d55a20 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxfload.c +++ b/sys/contrib/dev/acpica/components/tables/tbxfload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #define __TBXFLOAD_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -92,7 +93,7 @@ AcpiLoadTables ( return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiLoadTables) +ACPI_EXPORT_SYMBOL_INIT (AcpiLoadTables) /******************************************************************************* @@ -130,7 +131,7 @@ AcpiTbLoadNamespace ( !ACPI_COMPARE_NAME ( &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), ACPI_SIG_DSDT) || - ACPI_FAILURE (AcpiTbVerifyTable ( + ACPI_FAILURE (AcpiTbValidateTable ( &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) { Status = AE_NO_ACPI_TABLES; @@ -141,7 +142,7 @@ AcpiTbLoadNamespace ( * Save the DSDT pointer for simple access. This is the mapped memory * address. We must take care here because the address of the .Tables * array can change dynamically as tables are loaded at run-time. Note: - * .Pointer field is not validated until after call to AcpiTbVerifyTable. + * .Pointer field is not validated until after call to AcpiTbValidateTable. */ AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer; @@ -186,24 +187,12 @@ AcpiTbLoadNamespace ( ACPI_SIG_SSDT) && !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), ACPI_SIG_PSDT)) || - ACPI_FAILURE (AcpiTbVerifyTable ( + ACPI_FAILURE (AcpiTbValidateTable ( &AcpiGbl_RootTableList.Tables[i]))) { continue; } - /* - * Optionally do not load any SSDTs from the RSDT/XSDT. This can - * be useful for debugging ACPI problems on some machines. - */ - if (AcpiGbl_DisableSsdtTableLoad) - { - ACPI_INFO ((AE_INFO, "Ignoring %4.4s at %p", - AcpiGbl_RootTableList.Tables[i].Signature.Ascii, - ACPI_CAST_PTR (void, AcpiGbl_RootTableList.Tables[i].Address))); - continue; - } - /* Ignore errors while loading tables, get as many as possible */ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); @@ -219,6 +208,53 @@ AcpiTbLoadNamespace ( } +/******************************************************************************* + * + * FUNCTION: AcpiInstallTable + * + * PARAMETERS: Address - Address of the ACPI table to be installed. + * Physical - Whether the address is a physical table + * address or not + * + * RETURN: Status + * + * DESCRIPTION: Dynamically install an ACPI table. + * Note: This function should only be invoked after + * AcpiInitializeTables() and before AcpiLoadTables(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + BOOLEAN Physical) +{ + ACPI_STATUS Status; + UINT8 Flags; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (AcpiInstallTable); + + + if (Physical) + { + Flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL; + } + else + { + Flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL; + } + + Status = AcpiTbInstallStandardTable (Address, Flags, + FALSE, FALSE, &TableIndex); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL_INIT (AcpiInstallTable) + + /******************************************************************************* * * FUNCTION: AcpiLoadTable @@ -241,7 +277,6 @@ AcpiLoadTable ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_TABLE_DESC TableDesc; UINT32 TableIndex; @@ -255,14 +290,6 @@ AcpiLoadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Init local table descriptor */ - - ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); - TableDesc.Address = ACPI_PTR_TO_PHYSADDR (Table); - TableDesc.Pointer = Table; - TableDesc.Length = Table->Length; - TableDesc.Flags = ACPI_TABLE_ORIGIN_UNKNOWN; - /* Must acquire the interpreter lock during this operation */ Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); @@ -274,7 +301,23 @@ AcpiLoadTable ( /* Install the table and load it into the namespace */ ACPI_INFO ((AE_INFO, "Host-directed Dynamic ACPI Table Load:")); - Status = AcpiTbAddTable (&TableDesc, &TableIndex); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, TRUE, FALSE, + &TableIndex); + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* + * Note: Now table is "INSTALLED", it must be validated before + * using. + */ + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; diff --git a/sys/contrib/dev/acpica/components/tables/tbxfroot.c b/sys/contrib/dev/acpica/components/tables/tbxfroot.c index 0b9fe7228127..885350ea2ef5 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxfroot.c +++ b/sys/contrib/dev/acpica/components/tables/tbxfroot.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,43 @@ ACPI_MODULE_NAME ("tbxfroot") +/******************************************************************************* + * + * FUNCTION: AcpiTbGetRsdpLength + * + * PARAMETERS: Rsdp - Pointer to RSDP + * + * RETURN: Table length + * + * DESCRIPTION: Get the length of the RSDP + * + ******************************************************************************/ + +UINT32 +AcpiTbGetRsdpLength ( + ACPI_TABLE_RSDP *Rsdp) +{ + + if (!ACPI_VALIDATE_RSDP_SIG (Rsdp->Signature)) + { + /* BAD Signature */ + + return (0); + } + + /* "Length" field is available if table version >= 2 */ + + if (Rsdp->Revision >= 2) + { + return (Rsdp->Length); + } + else + { + return (ACPI_RSDP_CHECKSUM_LENGTH); + } +} + + /******************************************************************************* * * FUNCTION: AcpiTbValidateRsdp diff --git a/sys/contrib/dev/acpica/components/utilities/utaddress.c b/sys/contrib/dev/acpica/components/utilities/utaddress.c index da8b0465d1ff..77d3ecea5291 100644 --- a/sys/contrib/dev/acpica/components/utilities/utaddress.c +++ b/sys/contrib/dev/acpica/components/utilities/utaddress.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -248,10 +248,11 @@ AcpiUtCheckAddressRange ( while (RangeInfo) { /* - * Check if the requested Address/Length overlaps this AddressRange. - * Four cases to consider: + * Check if the requested address/length overlaps this + * address range. There are four cases to consider: * - * 1) Input address/length is contained completely in the address range + * 1) Input address/length is contained completely in the + * address range * 2) Input address/length overlaps range at the range start * 3) Input address/length overlaps range at the range end * 4) Input address/length completely encompasses the range @@ -267,10 +268,13 @@ AcpiUtCheckAddressRange ( Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode); ACPI_WARNING ((AE_INFO, - "0x%p-0x%p %s conflicts with Region %s %d", + "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)", + AcpiUtGetRegionName (SpaceId), ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, EndAddress), - AcpiUtGetRegionName (SpaceId), Pathname, OverlapCount)); + ACPI_CAST_PTR (void, RangeInfo->StartAddress), + ACPI_CAST_PTR (void, RangeInfo->EndAddress), + Pathname)); ACPI_FREE (Pathname); } } diff --git a/sys/contrib/dev/acpica/components/utilities/utalloc.c b/sys/contrib/dev/acpica/components/utilities/utalloc.c index 0bdb2ffac55a..70a813117851 100644 --- a/sys/contrib/dev/acpica/components/utilities/utalloc.c +++ b/sys/contrib/dev/acpica/components/utilities/utalloc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,45 @@ ACPI_MODULE_NAME ("utalloc") +#if !defined (USE_NATIVE_ALLOCATE_ZEROED) +/******************************************************************************* + * + * FUNCTION: AcpiOsAllocateZeroed + * + * PARAMETERS: Size - Size of the allocation + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. + * This is the default implementation. Can be overridden via the + * USE_NATIVE_ALLOCATE_ZEROED flag. + * + ******************************************************************************/ + +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size) +{ + void *Allocation; + + + ACPI_FUNCTION_ENTRY (); + + + Allocation = AcpiOsAllocate (Size); + if (Allocation) + { + /* Clear the memory block */ + + ACPI_MEMSET (Allocation, 0, Size); + } + + return (Allocation); +} + +#endif /* !USE_NATIVE_ALLOCATE_ZEROED */ + + /******************************************************************************* * * FUNCTION: AcpiUtCreateCaches @@ -285,9 +324,13 @@ AcpiUtInitializeBuffer ( return (AE_BUFFER_OVERFLOW); case ACPI_ALLOCATE_BUFFER: - - /* Allocate a new buffer */ - + /* + * Allocate a new buffer. We directectly call AcpiOsAllocate here to + * purposefully bypass the (optionally enabled) internal allocation + * tracking mechanism since we only want to track internal + * allocations. Note: The caller should use AcpiOsFree to free this + * buffer created via ACPI_ALLOCATE_BUFFER. + */ Buffer->Pointer = AcpiOsAllocate (RequiredLength); break; @@ -321,95 +364,3 @@ AcpiUtInitializeBuffer ( ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); return (AE_OK); } - - -/******************************************************************************* - * - * FUNCTION: AcpiUtAllocate - * - * PARAMETERS: Size - Size of the allocation - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: Subsystem equivalent of malloc. - * - ******************************************************************************/ - -void * -AcpiUtAllocate ( - ACPI_SIZE Size, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - void *Allocation; - - - ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size); - - - /* Check for an inadvertent size of zero bytes */ - - if (!Size) - { - ACPI_WARNING ((Module, Line, - "Attempt to allocate zero bytes, allocating 1 byte")); - Size = 1; - } - - Allocation = AcpiOsAllocate (Size); - if (!Allocation) - { - /* Report allocation error */ - - ACPI_WARNING ((Module, Line, - "Could not allocate size %u", (UINT32) Size)); - - return_PTR (NULL); - } - - return_PTR (Allocation); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtAllocateZeroed - * - * PARAMETERS: Size - Size of the allocation - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. - * - ******************************************************************************/ - -void * -AcpiUtAllocateZeroed ( - ACPI_SIZE Size, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - void *Allocation; - - - ACPI_FUNCTION_ENTRY (); - - - Allocation = AcpiUtAllocate (Size, Component, Module, Line); - if (Allocation) - { - /* Clear the memory block */ - - ACPI_MEMSET (Allocation, 0, Size); - } - - return (Allocation); -} diff --git a/sys/contrib/dev/acpica/components/utilities/utbuffer.c b/sys/contrib/dev/acpica/components/utilities/utbuffer.c index 508a940ca5a0..ee7f9e5a8315 100644 --- a/sys/contrib/dev/acpica/components/utilities/utbuffer.c +++ b/sys/contrib/dev/acpica/components/utilities/utbuffer.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -218,3 +218,138 @@ AcpiUtDebugDumpBuffer ( AcpiUtDumpBuffer (Buffer, Count, Display, 0); } + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBufferToFile + * + * PARAMETERS: File - File descriptor + * Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display: + * DB_BYTE_DISPLAY + * DB_WORD_DISPLAY + * DB_DWORD_DISPLAY + * DB_QWORD_DISPLAY + * BaseOffset - Beginning buffer offset (display only) + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii to a file. + * + ******************************************************************************/ + +void +AcpiUtDumpBufferToFile ( + ACPI_FILE File, + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 BaseOffset) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + if (!Buffer) + { + AcpiUtFilePrintf (File, "Null Buffer Pointer in DumpBuffer!\n"); + return; + } + + if ((Count < 4) || (Count & 0x01)) + { + Display = DB_BYTE_DISPLAY; + } + + /* Nasty little dump buffer routine! */ + + while (i < Count) + { + /* Print current offset */ + + AcpiUtFilePrintf (File, "%6.4X: ", (BaseOffset + i)); + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + /* Dump fill spaces */ + + AcpiUtFilePrintf (File, "%*s", ((Display * 2) + 1), " "); + j += Display; + continue; + } + + switch (Display) + { + case DB_BYTE_DISPLAY: + default: /* Default is BYTE display */ + + AcpiUtFilePrintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]); + break; + + case DB_WORD_DISPLAY: + + ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%04X ", Temp32); + break; + + case DB_DWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%08X ", Temp32); + break; + + case DB_QWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiUtFilePrintf (File, "%08X", Temp32); + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); + AcpiUtFilePrintf (File, "%08X ", Temp32); + break; + } + + j += Display; + } + + /* + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) + */ + AcpiUtFilePrintf (File, " "); + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiUtFilePrintf (File, "\n"); + return; + } + + BufChar = Buffer[(ACPI_SIZE) i + j]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiUtFilePrintf (File, "%c", BufChar); + } + else + { + AcpiUtFilePrintf (File, "."); + } + } + + /* Done with that line. */ + + AcpiUtFilePrintf (File, "\n"); + i += 16; + } + + return; +} +#endif diff --git a/sys/contrib/dev/acpica/components/utilities/utcache.c b/sys/contrib/dev/acpica/components/utilities/utcache.c index 2aa3e5bbdbae..f6c2d02a24ba 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcache.c +++ b/sys/contrib/dev/acpica/components/utilities/utcache.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -286,13 +286,13 @@ AcpiOsAcquireObject ( if (!Cache) { - return (NULL); + return_PTR (NULL); } Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) { - return (NULL); + return_PTR (NULL); } ACPI_MEM_TRACKING (Cache->Requests++); @@ -315,7 +315,7 @@ AcpiOsAcquireObject ( Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) { - return (NULL); + return_PTR (NULL); } /* Clear (zero) the previously used Object */ @@ -340,16 +340,16 @@ AcpiOsAcquireObject ( Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) { - return (NULL); + return_PTR (NULL); } Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); if (!Object) { - return (NULL); + return_PTR (NULL); } } - return (Object); + return_PTR (Object); } #endif /* ACPI_USE_LOCAL_CACHE */ diff --git a/sys/contrib/dev/acpica/components/utilities/utcopy.c b/sys/contrib/dev/acpica/components/utilities/utcopy.c index dacbc5cc79d9..68e58ddc04fb 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcopy.c +++ b/sys/contrib/dev/acpica/components/utilities/utcopy.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -564,10 +564,10 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_LOCAL_REFERENCE: - /* TBD: should validate incoming handle */ + /* An incoming reference is defined to be a namespace node */ - InternalObject->Reference.Class = ACPI_REFCLASS_NAME; - InternalObject->Reference.Node = ExternalObject->Reference.Handle; + InternalObject->Reference.Class = ACPI_REFCLASS_REFOF; + InternalObject->Reference.Object = ExternalObject->Reference.Handle; break; default: @@ -1063,5 +1063,12 @@ AcpiUtCopyIobjectToIobject ( Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); } + /* Delete the allocated object if copy failed */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference(*DestDesc); + } + return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/components/utilities/utdebug.c b/sys/contrib/dev/acpica/components/utilities/utdebug.c index 93c036104788..33350ca92382 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdebug.c +++ b/sys/contrib/dev/acpica/components/utilities/utdebug.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #define __UTDEBUG_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -210,6 +211,7 @@ AcpiDebugPrint ( } AcpiGbl_PrevThreadId = ThreadId; + AcpiGbl_NestingLevel = 0; } /* @@ -218,13 +220,22 @@ AcpiDebugPrint ( */ AcpiOsPrintf ("%9s-%04ld ", ModuleName, LineNumber); +#ifdef ACPI_APPLICATION + /* + * For AcpiExec/iASL only, emit the thread ID and nesting level. + * Note: nesting level is really only useful during a single-thread + * execution. Otherwise, multiple threads will keep resetting the + * level. + */ if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ("[%u] ", (UINT32) ThreadId); } - AcpiOsPrintf ("[%02ld] %-22.22s: ", - AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName)); + AcpiOsPrintf ("[%02ld] ", AcpiGbl_NestingLevel); +#endif + + AcpiOsPrintf ("%-22.22s: ", AcpiUtTrimFunctionName (FunctionName)); va_start (args, Format); AcpiOsVprintf (Format, args); @@ -474,7 +485,10 @@ AcpiUtExit ( "%s\n", AcpiGbl_FnExitStr); } - AcpiGbl_NestingLevel--; + if (AcpiGbl_NestingLevel) + { + AcpiGbl_NestingLevel--; + } } ACPI_EXPORT_SYMBOL (AcpiUtExit) @@ -526,7 +540,10 @@ AcpiUtStatusExit ( } } - AcpiGbl_NestingLevel--; + if (AcpiGbl_NestingLevel) + { + AcpiGbl_NestingLevel--; + } } ACPI_EXPORT_SYMBOL (AcpiUtStatusExit) @@ -568,7 +585,10 @@ AcpiUtValueExit ( ACPI_FORMAT_UINT64 (Value)); } - AcpiGbl_NestingLevel--; + if (AcpiGbl_NestingLevel) + { + AcpiGbl_NestingLevel--; + } } ACPI_EXPORT_SYMBOL (AcpiUtValueExit) @@ -609,7 +629,40 @@ AcpiUtPtrExit ( "%s %p\n", AcpiGbl_FnExitStr, Ptr); } - AcpiGbl_NestingLevel--; + if (AcpiGbl_NestingLevel) + { + AcpiGbl_NestingLevel--; + } } #endif + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiLogError + * + * PARAMETERS: Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message to the console, used by applications. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiLogError ( + const char *Format, + ...) +{ + va_list Args; + + va_start (Args, Format); + (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args); + va_end (Args); +} + +ACPI_EXPORT_SYMBOL (AcpiLogError) +#endif diff --git a/sys/contrib/dev/acpica/components/utilities/utdecode.c b/sys/contrib/dev/acpica/components/utilities/utdecode.c index 3075479a6102..9fd52077cd61 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdecode.c +++ b/sys/contrib/dev/acpica/components/utilities/utdecode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,38 +91,6 @@ const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = }; -/******************************************************************************* - * - * FUNCTION: AcpiUtHexToAsciiChar - * - * PARAMETERS: Integer - Contains the hex digit - * Position - bit position of the digit within the - * integer (multiple of 4) - * - * RETURN: The converted Ascii character - * - * DESCRIPTION: Convert a hex digit to an Ascii character - * - ******************************************************************************/ - -/* Hex to ASCII conversion table */ - -static const char AcpiGbl_HexToAscii[] = -{ - '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' -}; - -char -AcpiUtHexToAsciiChar ( - UINT64 Integer, - UINT32 Position) -{ - - return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); -} - - /******************************************************************************* * * FUNCTION: AcpiUtGetRegionName @@ -527,7 +495,7 @@ AcpiUtGetMutexName ( /* Names for Notify() values, used for debug output */ -static const char *AcpiGbl_NotifyValueNames[ACPI_NOTIFY_MAX + 1] = +static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = { /* 00 */ "Bus Check", /* 01 */ "Device Check", @@ -539,32 +507,88 @@ static const char *AcpiGbl_NotifyValueNames[ACPI_NOTIFY_MAX + 1] = /* 07 */ "Power Fault", /* 08 */ "Capabilities Check", /* 09 */ "Device PLD Check", - /* 10 */ "Reserved", - /* 11 */ "System Locality Update", - /* 12 */ "Shutdown Request" + /* 0A */ "Reserved", + /* 0B */ "System Locality Update", + /* 0C */ "Shutdown Request", + /* 0D */ "System Resource Affinity Update" }; +static const char *AcpiGbl_DeviceNotify[4] = +{ + /* 80 */ "Status Change", + /* 81 */ "Information Change", + /* 82 */ "Device-Specific Change", + /* 83 */ "Device-Specific Change" +}; + +static const char *AcpiGbl_ProcessorNotify[4] = +{ + /* 80 */ "Performance Capability Change", + /* 81 */ "C-State Change", + /* 82 */ "Throttling Capability Change", + /* 83 */ "Device-Specific Change" +}; + +static const char *AcpiGbl_ThermalNotify[4] = +{ + /* 80 */ "Thermal Status Change", + /* 81 */ "Thermal Trip Point Change", + /* 82 */ "Thermal Device List Change", + /* 83 */ "Thermal Relationship Change" +}; + + const char * AcpiUtGetNotifyName ( - UINT32 NotifyValue) + UINT32 NotifyValue, + ACPI_OBJECT_TYPE Type) { + /* 00 - 0D are common to all object types */ + if (NotifyValue <= ACPI_NOTIFY_MAX) { - return (AcpiGbl_NotifyValueNames[NotifyValue]); + return (AcpiGbl_GenericNotify[NotifyValue]); } - else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + + /* 0D - 7F are reserved */ + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { return ("Reserved"); } - else if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) + + /* 80 - 83 are per-object-type */ + + if (NotifyValue <= 0x83) { - return ("Device Specific"); + switch (Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_DEVICE: + return (AcpiGbl_DeviceNotify [NotifyValue - 0x80]); + + case ACPI_TYPE_PROCESSOR: + return (AcpiGbl_ProcessorNotify [NotifyValue - 0x80]); + + case ACPI_TYPE_THERMAL: + return (AcpiGbl_ThermalNotify [NotifyValue - 0x80]); + + default: + return ("Target object type does not support notifies"); + } } - else + + /* 84 - BF are device-specific */ + + if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) { - return ("Hardware Specific"); + return ("Device-Specific"); } + + /* C0 and above are hardware-specific */ + + return ("Hardware-Specific"); } #endif diff --git a/sys/contrib/dev/acpica/components/utilities/utdelete.c b/sys/contrib/dev/acpica/components/utilities/utdelete.c index 6f1f89b310d1..60b456fa3bec 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdelete.c +++ b/sys/contrib/dev/acpica/components/utilities/utdelete.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,6 +86,7 @@ AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT *HandlerDesc; ACPI_OPERAND_OBJECT *SecondDesc; ACPI_OPERAND_OBJECT *NextDesc; + ACPI_OPERAND_OBJECT *StartDesc; ACPI_OPERAND_OBJECT **LastObjPtr; @@ -250,9 +251,10 @@ AcpiUtDeleteInternalObj ( if (HandlerDesc) { NextDesc = HandlerDesc->AddressSpace.RegionList; + StartDesc = NextDesc; LastObjPtr = &HandlerDesc->AddressSpace.RegionList; - /* Remove the region object from the handler's list */ + /* Remove the region object from the handler list */ while (NextDesc) { @@ -262,10 +264,20 @@ AcpiUtDeleteInternalObj ( break; } - /* Walk the linked list of handler */ + /* Walk the linked list of handlers */ LastObjPtr = &NextDesc->Region.Next; NextDesc = NextDesc->Region.Next; + + /* Prevent infinite loop if list is corrupted */ + + if (NextDesc == StartDesc) + { + ACPI_ERROR ((AE_INFO, + "Circular region list in address handler object %p", + HandlerDesc)); + return_VOID; + } } if (HandlerDesc->AddressSpace.HandlerFlags & diff --git a/sys/contrib/dev/acpica/components/utilities/uterror.c b/sys/contrib/dev/acpica/components/utilities/uterror.c index b7aef1840c43..3c62b6201c91 100644 --- a/sys/contrib/dev/acpica/components/utilities/uterror.c +++ b/sys/contrib/dev/acpica/components/utilities/uterror.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/uteval.c b/sys/contrib/dev/acpica/components/utilities/uteval.c index ba4d6eef88da..a693c84f4a1f 100644 --- a/sys/contrib/dev/acpica/components/utilities/uteval.c +++ b/sys/contrib/dev/acpica/components/utilities/uteval.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/utexcep.c b/sys/contrib/dev/acpica/components/utilities/utexcep.c index d69dbf035e25..c7f7b9c21521 100644 --- a/sys/contrib/dev/acpica/components/utilities/utexcep.c +++ b/sys/contrib/dev/acpica/components/utilities/utexcep.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTEXCEP_C__ +#define EXPORT_ACPI_INTERFACES #define ACPI_DEFINE_EXCEPTION_TABLE #include diff --git a/sys/contrib/dev/acpica/components/utilities/utfileio.c b/sys/contrib/dev/acpica/components/utilities/utfileio.c new file mode 100644 index 000000000000..936fa6fd01b9 --- /dev/null +++ b/sys/contrib/dev/acpica/components/utilities/utfileio.c @@ -0,0 +1,361 @@ +/******************************************************************************* + * + * Module Name: utfileio - simple file I/O routines + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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_ASL_COMPILER +#include +#endif + + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("utfileio") + + +#ifdef ACPI_APPLICATION + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCheckTextModeCorruption ( + UINT8 *Table, + UINT32 TableLength, + UINT32 FileLength); + +static ACPI_STATUS +AcpiUtReadTable ( + FILE *fp, + ACPI_TABLE_HEADER **Table, + UINT32 *TableLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCheckTextModeCorruption + * + * PARAMETERS: Table - Table buffer + * TableLength - Length of table from the table header + * FileLength - Length of the file that contains the table + * + * RETURN: Status + * + * DESCRIPTION: Check table for text mode file corruption where all linefeed + * characters (LF) have been replaced by carriage return linefeed + * pairs (CR/LF). + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCheckTextModeCorruption ( + UINT8 *Table, + UINT32 TableLength, + UINT32 FileLength) +{ + UINT32 i; + UINT32 Pairs = 0; + + + if (TableLength != FileLength) + { + ACPI_WARNING ((AE_INFO, + "File length (0x%X) is not the same as the table length (0x%X)", + FileLength, TableLength)); + } + + /* Scan entire table to determine if each LF has been prefixed with a CR */ + + for (i = 1; i < FileLength; i++) + { + if (Table[i] == 0x0A) + { + if (Table[i - 1] != 0x0D) + { + /* The LF does not have a preceding CR, table not corrupted */ + + return (AE_OK); + } + else + { + /* Found a CR/LF pair */ + + Pairs++; + } + i++; + } + } + + if (!Pairs) + { + return (AE_OK); + } + + /* + * Entire table scanned, each CR is part of a CR/LF pair -- + * meaning that the table was treated as a text file somewhere. + * + * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the + * original table are left untouched by the text conversion process -- + * meaning that we cannot simply replace CR/LF pairs with LFs. + */ + AcpiOsPrintf ("Table has been corrupted by text mode conversion\n"); + AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs); + AcpiOsPrintf ("Table cannot be repaired!\n"); + return (AE_BAD_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReadTable + * + * PARAMETERS: fp - File that contains table + * Table - Return value, buffer with table + * TableLength - Return value, length of table + * + * RETURN: Status + * + * DESCRIPTION: Load the DSDT from the file pointer + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtReadTable ( + FILE *fp, + ACPI_TABLE_HEADER **Table, + UINT32 *TableLength) +{ + ACPI_TABLE_HEADER TableHeader; + UINT32 Actual; + ACPI_STATUS Status; + UINT32 FileSize; + BOOLEAN StandardHeader = TRUE; + INT32 Count; + + /* Get the file size */ + + FileSize = CmGetFileSize (fp); + if (FileSize == ACPI_UINT32_MAX) + { + return (AE_ERROR); + } + + if (FileSize < 4) + { + return (AE_BAD_HEADER); + } + + /* Read the signature */ + + fseek (fp, 0, SEEK_SET); + + Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), fp); + if (Count != sizeof (ACPI_TABLE_HEADER)) + { + AcpiOsPrintf ("Could not read the table header\n"); + return (AE_BAD_HEADER); + } + + /* The RSDP table does not have standard ACPI header */ + + if (ACPI_VALIDATE_RSDP_SIG (TableHeader.Signature)) + { + *TableLength = FileSize; + StandardHeader = FALSE; + } + else + { + +#if 0 + /* Validate the table header/length */ + + Status = AcpiTbValidateTableHeader (&TableHeader); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Table header is invalid!\n"); + return (Status); + } +#endif + + /* File size must be at least as long as the Header-specified length */ + + if (TableHeader.Length > FileSize) + { + AcpiOsPrintf ( + "TableHeader length [0x%X] greater than the input file size [0x%X]\n", + TableHeader.Length, FileSize); + +#ifdef ACPI_ASL_COMPILER + Status = FlCheckForAscii (fp, NULL, FALSE); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("File appears to be ASCII only, must be binary\n"); + } +#endif + return (AE_BAD_HEADER); + } + +#ifdef ACPI_OBSOLETE_CODE + /* We only support a limited number of table types */ + + if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) && + !ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT)) + { + AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", + (char *) TableHeader.Signature); + ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_ERROR); + } +#endif + + *TableLength = TableHeader.Length; + } + + /* Allocate a buffer for the table */ + + *Table = AcpiOsAllocate ((size_t) FileSize); + if (!*Table) + { + AcpiOsPrintf ( + "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", + TableHeader.Signature, *TableLength); + return (AE_NO_MEMORY); + } + + /* Get the rest of the table */ + + fseek (fp, 0, SEEK_SET); + Actual = fread (*Table, 1, (size_t) FileSize, fp); + if (Actual == FileSize) + { + if (StandardHeader) + { + /* Now validate the checksum */ + + Status = AcpiTbVerifyChecksum ((void *) *Table, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); + + if (Status == AE_BAD_CHECKSUM) + { + Status = AcpiUtCheckTextModeCorruption ((UINT8 *) *Table, + FileSize, (*Table)->Length); + return (Status); + } + } + return (AE_OK); + } + + if (Actual > 0) + { + AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", + FileSize, Actual); + return (AE_OK); + } + + AcpiOsPrintf ("Error - could not read the table file\n"); + AcpiOsFree (*Table); + *Table = NULL; + *TableLength = 0; + return (AE_ERROR); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReadTableFromFile + * + * PARAMETERS: Filename - File where table is located + * Table - Where a pointer to the table is returned + * + * RETURN: Status + * + * DESCRIPTION: Get an ACPI table from a file + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table) +{ + FILE *File; + UINT32 FileSize; + UINT32 TableLength; + ACPI_STATUS Status = AE_ERROR; + + + /* Open the file, get current size */ + + File = fopen (Filename, "rb"); + if (!File) + { + perror ("Could not open input file"); + return (Status); + } + + FileSize = CmGetFileSize (File); + if (FileSize == ACPI_UINT32_MAX) + { + goto Exit; + } + + /* Get the entire file */ + + fprintf (stderr, "Loading Acpi table from file %10s - Length %.8u (%06X)\n", + Filename, FileSize, FileSize); + + Status = AcpiUtReadTable (File, Table, &TableLength); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not get table from the file\n"); + } + +Exit: + fclose(File); + return (Status); +} + +#endif diff --git a/sys/contrib/dev/acpica/components/utilities/utglobal.c b/sys/contrib/dev/acpica/components/utilities/utglobal.c index 6233a4ae4cf2..00aa77786310 100644 --- a/sys/contrib/dev/acpica/components/utilities/utglobal.c +++ b/sys/contrib/dev/acpica/components/utilities/utglobal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #define __UTGLOBAL_C__ +#define EXPORT_ACPI_INTERFACES #define DEFINE_ACPI_GLOBALS #include @@ -57,37 +58,7 @@ * ******************************************************************************/ -/* - * We want the debug switches statically initialized so they - * are already set when the debugger is entered. - */ - -/* Debug switch - level and trace mask */ - -#ifdef ACPI_DEBUG_OUTPUT -UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; -#else -UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; -#endif - -/* Debug switch - layer (component) mask */ - -UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; -UINT32 AcpiGbl_NestingLevel = 0; - -/* Debugger globals */ - -BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; -BOOLEAN AcpiGbl_AbortMethod = FALSE; -BOOLEAN AcpiGbl_MethodExecuting = FALSE; - -/* System flags */ - -UINT32 AcpiGbl_StartupFlags = 0; - -/* System starts uninitialized */ - -BOOLEAN AcpiGbl_Shutdown = TRUE; +/* Various state name strings */ const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = { @@ -202,163 +173,6 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = }; #endif /* !ACPI_REDUCED_HARDWARE */ - -/******************************************************************************* - * - * FUNCTION: AcpiUtInitGlobals - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize ACPICA globals. All globals that require specific - * initialization should be initialized here. This allows for - * a warm restart. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtInitGlobals ( - void) -{ - ACPI_STATUS Status; - UINT32 i; - - - ACPI_FUNCTION_TRACE (UtInitGlobals); - - - /* Create all memory caches */ - - Status = AcpiUtCreateCaches (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Address Range lists */ - - for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) - { - AcpiGbl_AddressRangeList[i] = NULL; - } - - /* Mutex locked flags */ - - for (i = 0; i < ACPI_NUM_MUTEX; i++) - { - AcpiGbl_MutexInfo[i].Mutex = NULL; - AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - AcpiGbl_MutexInfo[i].UseCount = 0; - } - - for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) - { - AcpiGbl_OwnerIdMask[i] = 0; - } - - /* Last OwnerID is never valid */ - - AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; - - /* Event counters */ - - AcpiMethodCount = 0; - AcpiSciCount = 0; - AcpiGpeCount = 0; - - for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) - { - AcpiFixedEventCount[i] = 0; - } - -#if (!ACPI_REDUCED_HARDWARE) - - /* GPE/SCI support */ - - AcpiGbl_AllGpesInitialized = FALSE; - AcpiGbl_GpeXruptListHead = NULL; - AcpiGbl_GpeFadtBlocks[0] = NULL; - AcpiGbl_GpeFadtBlocks[1] = NULL; - AcpiCurrentGpeCount = 0; - - AcpiGbl_GlobalEventHandler = NULL; - AcpiGbl_SciHandlerList = NULL; - -#endif /* !ACPI_REDUCED_HARDWARE */ - - /* Global handlers */ - - AcpiGbl_GlobalNotify[0].Handler = NULL; - AcpiGbl_GlobalNotify[1].Handler = NULL; - AcpiGbl_ExceptionHandler = NULL; - AcpiGbl_InitHandler = NULL; - AcpiGbl_TableHandler = NULL; - AcpiGbl_InterfaceHandler = NULL; - - /* Global Lock support */ - - AcpiGbl_GlobalLockSemaphore = NULL; - AcpiGbl_GlobalLockMutex = NULL; - AcpiGbl_GlobalLockAcquired = FALSE; - AcpiGbl_GlobalLockHandle = 0; - AcpiGbl_GlobalLockPresent = FALSE; - - /* Miscellaneous variables */ - - AcpiGbl_DSDT = NULL; - AcpiGbl_CmSingleStep = FALSE; - AcpiGbl_DbTerminateThreads = FALSE; - AcpiGbl_Shutdown = FALSE; - AcpiGbl_NsLookupCount = 0; - AcpiGbl_PsFindCount = 0; - AcpiGbl_AcpiHardwarePresent = TRUE; - AcpiGbl_LastOwnerIdIndex = 0; - AcpiGbl_NextOwnerIdOffset = 0; - AcpiGbl_TraceMethodName = 0; - AcpiGbl_TraceDbgLevel = 0; - AcpiGbl_TraceDbgLayer = 0; - AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; - AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; - AcpiGbl_OsiMutex = NULL; - AcpiGbl_RegMethodsExecuted = FALSE; - - /* Hardware oriented */ - - AcpiGbl_EventsInitialized = FALSE; - AcpiGbl_SystemAwakeAndRunning = TRUE; - - /* Namespace */ - - AcpiGbl_ModuleCodeList = NULL; - AcpiGbl_RootNode = NULL; - AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; - AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; - AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; - AcpiGbl_RootNodeStruct.Parent = NULL; - AcpiGbl_RootNodeStruct.Child = NULL; - AcpiGbl_RootNodeStruct.Peer = NULL; - AcpiGbl_RootNodeStruct.Object = NULL; - - -#ifdef ACPI_DISASSEMBLER - AcpiGbl_ExternalList = NULL; - AcpiGbl_NumExternalMethods = 0; - AcpiGbl_ResolvedExternalMethods = 0; -#endif - -#ifdef ACPI_DEBUG_OUTPUT - AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); -#endif - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - AcpiGbl_DisplayFinalMemStats = FALSE; - AcpiGbl_DisableMemTracking = FALSE; -#endif - - return_ACPI_STATUS (AE_OK); -} - /* Public globals */ ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) diff --git a/sys/contrib/dev/acpica/components/utilities/uthex.c b/sys/contrib/dev/acpica/components/utilities/uthex.c new file mode 100644 index 000000000000..80032317f28f --- /dev/null +++ b/sys/contrib/dev/acpica/components/utilities/uthex.c @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * Module Name: uthex -- Hex/ASCII support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 __UTHEX_C__ + +#include +#include + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("uthex") + + +/* Hex to ASCII conversion table */ + +static char AcpiGbl_HexToAscii[] = +{ + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexToAsciiChar + * + * PARAMETERS: Integer - Contains the hex digit + * Position - bit position of the digit within the + * integer (multiple of 4) + * + * RETURN: The converted Ascii character + * + * DESCRIPTION: Convert a hex digit to an Ascii character + * + ******************************************************************************/ + +char +AcpiUtHexToAsciiChar ( + UINT64 Integer, + UINT32 Position) +{ + + return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtHexCharToValue + * + * PARAMETERS: AsciiChar - Hex character in Ascii + * + * RETURN: The binary value of the ascii/hex character + * + * DESCRIPTION: Perform ascii-to-hex translation + * + ******************************************************************************/ + +UINT8 +AcpiUtAsciiCharToHex ( + int HexChar) +{ + + if (HexChar <= 0x39) + { + return ((UINT8) (HexChar - 0x30)); + } + + if (HexChar <= 0x46) + { + return ((UINT8) (HexChar - 0x37)); + } + + return ((UINT8) (HexChar - 0x57)); +} diff --git a/sys/contrib/dev/acpica/components/utilities/utids.c b/sys/contrib/dev/acpica/components/utilities/utids.c index b0017678b804..ca2a372b8510 100644 --- a/sys/contrib/dev/acpica/components/utilities/utids.c +++ b/sys/contrib/dev/acpica/components/utilities/utids.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/utinit.c b/sys/contrib/dev/acpica/components/utilities/utinit.c index 760d7895407f..6a07ef6ae895 100644 --- a/sys/contrib/dev/acpica/components/utilities/utinit.c +++ b/sys/contrib/dev/acpica/components/utilities/utinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTINIT_C__ #include @@ -116,6 +115,162 @@ AcpiUtFreeGpeLists ( #endif /* !ACPI_REDUCED_HARDWARE */ +/******************************************************************************* + * + * FUNCTION: AcpiUtInitGlobals + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize ACPICA globals. All globals that require specific + * initialization should be initialized here. This allows for + * a warm restart. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitGlobals ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtInitGlobals); + + + /* Create all memory caches */ + + Status = AcpiUtCreateCaches (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Address Range lists */ + + for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) + { + AcpiGbl_AddressRangeList[i] = NULL; + } + + /* Mutex locked flags */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + AcpiGbl_MutexInfo[i].Mutex = NULL; + AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[i].UseCount = 0; + } + + for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) + { + AcpiGbl_OwnerIdMask[i] = 0; + } + + /* Last OwnerID is never valid */ + + AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; + + /* Event counters */ + + AcpiMethodCount = 0; + AcpiSciCount = 0; + AcpiGpeCount = 0; + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiFixedEventCount[i] = 0; + } + +#if (!ACPI_REDUCED_HARDWARE) + + /* GPE/SCI support */ + + AcpiGbl_AllGpesInitialized = FALSE; + AcpiGbl_GpeXruptListHead = NULL; + AcpiGbl_GpeFadtBlocks[0] = NULL; + AcpiGbl_GpeFadtBlocks[1] = NULL; + AcpiCurrentGpeCount = 0; + + AcpiGbl_GlobalEventHandler = NULL; + AcpiGbl_SciHandlerList = NULL; + +#endif /* !ACPI_REDUCED_HARDWARE */ + + /* Global handlers */ + + AcpiGbl_GlobalNotify[0].Handler = NULL; + AcpiGbl_GlobalNotify[1].Handler = NULL; + AcpiGbl_ExceptionHandler = NULL; + AcpiGbl_InitHandler = NULL; + AcpiGbl_TableHandler = NULL; + AcpiGbl_InterfaceHandler = NULL; + + /* Global Lock support */ + + AcpiGbl_GlobalLockSemaphore = NULL; + AcpiGbl_GlobalLockMutex = NULL; + AcpiGbl_GlobalLockAcquired = FALSE; + AcpiGbl_GlobalLockHandle = 0; + AcpiGbl_GlobalLockPresent = FALSE; + + /* Miscellaneous variables */ + + AcpiGbl_DSDT = NULL; + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_Shutdown = FALSE; + AcpiGbl_NsLookupCount = 0; + AcpiGbl_PsFindCount = 0; + AcpiGbl_AcpiHardwarePresent = TRUE; + AcpiGbl_LastOwnerIdIndex = 0; + AcpiGbl_NextOwnerIdOffset = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; + AcpiGbl_OsiMutex = NULL; + AcpiGbl_RegMethodsExecuted = FALSE; + + /* Hardware oriented */ + + AcpiGbl_EventsInitialized = FALSE; + AcpiGbl_SystemAwakeAndRunning = TRUE; + + /* Namespace */ + + AcpiGbl_ModuleCodeList = NULL; + AcpiGbl_RootNode = NULL; + AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; + AcpiGbl_RootNodeStruct.Parent = NULL; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + + +#ifdef ACPI_DISASSEMBLER + AcpiGbl_ExternalList = NULL; + AcpiGbl_NumExternalMethods = 0; + AcpiGbl_ResolvedExternalMethods = 0; +#endif + +#ifdef ACPI_DEBUG_OUTPUT + AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); +#endif + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisplayFinalMemStats = FALSE; + AcpiGbl_DisableMemTracking = FALSE; +#endif + + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE); + + return_ACPI_STATUS (AE_OK); +} + + /****************************************************************************** * * FUNCTION: AcpiUtTerminate diff --git a/sys/contrib/dev/acpica/components/utilities/utlock.c b/sys/contrib/dev/acpica/components/utilities/utlock.c index da933c284e3e..626a46f50d96 100644 --- a/sys/contrib/dev/acpica/components/utilities/utlock.c +++ b/sys/contrib/dev/acpica/components/utilities/utlock.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/utmath.c b/sys/contrib/dev/acpica/components/utilities/utmath.c index b535ffc7275f..c65317937f62 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmath.c +++ b/sys/contrib/dev/acpica/components/utilities/utmath.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMATH_C__ #include diff --git a/sys/contrib/dev/acpica/components/utilities/utmisc.c b/sys/contrib/dev/acpica/components/utilities/utmisc.c index 6ff6b2ada6b0..356b0ce877bb 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmisc.c +++ b/sys/contrib/dev/acpica/components/utilities/utmisc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMISC_C__ #include diff --git a/sys/contrib/dev/acpica/components/utilities/utmutex.c b/sys/contrib/dev/acpica/components/utilities/utmutex.c index 260f2b53bad4..546adab4bec8 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmutex.c +++ b/sys/contrib/dev/acpica/components/utilities/utmutex.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTMUTEX_C__ #include diff --git a/sys/contrib/dev/acpica/components/utilities/utobject.c b/sys/contrib/dev/acpica/components/utilities/utobject.c index 46c3514c0147..398fae52e9fb 100644 --- a/sys/contrib/dev/acpica/components/utilities/utobject.c +++ b/sys/contrib/dev/acpica/components/utilities/utobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -400,7 +400,7 @@ AcpiUtValidInternalObject ( default: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%p is not not an ACPI operand obj [%s]\n", + "%p is not an ACPI operand obj [%s]\n", Object, AcpiUtGetDescriptorName (Object))); break; } diff --git a/sys/contrib/dev/acpica/components/utilities/utosi.c b/sys/contrib/dev/acpica/components/utilities/utosi.c index 9cf57653cd07..6b618713da8e 100644 --- a/sys/contrib/dev/acpica/components/utilities/utosi.c +++ b/sys/contrib/dev/acpica/components/utilities/utosi.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,34 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utosi") + +/****************************************************************************** + * + * ACPICA policy for new _OSI strings: + * + * It is the stated policy of ACPICA that new _OSI strings will be integrated + * into this module as soon as possible after they are defined. It is strongly + * recommended that all ACPICA hosts mirror this policy and integrate any + * changes to this module as soon as possible. There are several historical + * reasons behind this policy: + * + * 1) New BIOSs tend to test only the case where the host responds TRUE to + * the latest version of Windows, which would respond to the latest/newest + * _OSI string. Not responding TRUE to the latest version of Windows will + * risk executing untested code paths throughout the DSDT and SSDTs. + * + * 2) If a new _OSI string is recognized only after a significant delay, this + * has the potential to cause problems on existing working machines because + * of the possibility that a new and different path through the ASL code + * will be executed. + * + * 3) New _OSI strings are tending to come out about once per year. A delay + * in recognizing a new string for a significant amount of time risks the + * release of another string which only compounds the initial problem. + * + *****************************************************************************/ + + /* * Strings supported by the _OSI predefined control method (which is * implemented internally within this module.) @@ -78,6 +106,7 @@ static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] = {"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 */ + {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */ /* Feature Group Strings */ diff --git a/sys/contrib/dev/acpica/components/utilities/utownerid.c b/sys/contrib/dev/acpica/components/utilities/utownerid.c index 74f4d83c9a76..70919fb61668 100644 --- a/sys/contrib/dev/acpica/components/utilities/utownerid.c +++ b/sys/contrib/dev/acpica/components/utilities/utownerid.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTOWNERID_C__ #include diff --git a/sys/contrib/dev/acpica/components/utilities/utpredef.c b/sys/contrib/dev/acpica/components/utilities/utpredef.c index 886412068d81..9dcbd546b294 100644 --- a/sys/contrib/dev/acpica/components/utilities/utpredef.c +++ b/sys/contrib/dev/acpica/components/utilities/utpredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/components/utilities/utprint.c b/sys/contrib/dev/acpica/components/utilities/utprint.c new file mode 100644 index 000000000000..0c99079fc0dd --- /dev/null +++ b/sys/contrib/dev/acpica/components/utilities/utprint.c @@ -0,0 +1,811 @@ +/****************************************************************************** + * + * Module Name: utprint - Formatted printing routines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utprint") + + +#define ACPI_FORMAT_SIGN 0x01 +#define ACPI_FORMAT_SIGN_PLUS 0x02 +#define ACPI_FORMAT_SIGN_PLUS_SPACE 0x04 +#define ACPI_FORMAT_ZERO 0x08 +#define ACPI_FORMAT_LEFT 0x10 +#define ACPI_FORMAT_UPPER 0x20 +#define ACPI_FORMAT_PREFIX 0x40 + + +/* Local prototypes */ + +static ACPI_SIZE +AcpiUtBoundStringLength ( + const char *String, + ACPI_SIZE Count); + +static char * +AcpiUtBoundStringOutput ( + char *String, + const char *End, + char c); + +static char * +AcpiUtFormatNumber ( + char *String, + char *End, + UINT64 Number, + UINT8 Base, + INT32 Width, + INT32 Precision, + UINT8 Type); + +static char * +AcpiUtPutNumber ( + char *String, + UINT64 Number, + UINT8 Base, + BOOLEAN Upper); + + +/* Module globals */ + +static const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; +static const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtBoundStringLength + * + * PARAMETERS: String - String with boundary + * Count - Boundary of the string + * + * RETURN: Length of the string. Less than or equal to Count. + * + * DESCRIPTION: Calculate the length of a string with boundary. + * + ******************************************************************************/ + +static ACPI_SIZE +AcpiUtBoundStringLength ( + const char *String, + ACPI_SIZE Count) +{ + UINT32 Length = 0; + + + while (*String && Count) + { + Length++; + String++; + Count--; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtBoundStringOutput + * + * PARAMETERS: String - String with boundary + * End - Boundary of the string + * c - Character to be output to the string + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Output a character into a string with boundary check. + * + ******************************************************************************/ + +static char * +AcpiUtBoundStringOutput ( + char *String, + const char *End, + char c) +{ + + if (String < End) + { + *String = c; + } + + ++String; + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPutNumber + * + * PARAMETERS: String - Buffer to hold reverse-ordered string + * Number - Integer to be converted + * Base - Base of the integer + * Upper - Whether or not using upper cased digits + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Convert an integer into a string, note that, the string holds a + * reversed ordered number without the trailing zero. + * + ******************************************************************************/ + +static char * +AcpiUtPutNumber ( + char *String, + UINT64 Number, + UINT8 Base, + BOOLEAN Upper) +{ + const char *Digits; + UINT64 DigitIndex; + char *Pos; + + + Pos = String; + Digits = Upper ? AcpiGbl_UpperHexDigits : AcpiGbl_LowerHexDigits; + + if (Number == 0) + { + *(Pos++) = '0'; + } + else + { + while (Number) + { + (void) AcpiUtDivide (Number, Base, &Number, &DigitIndex); + *(Pos++) = Digits[DigitIndex]; + } + } + + /* *(Pos++) = '0'; */ + return (Pos); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtScanNumber + * + * PARAMETERS: String - String buffer + * NumberPtr - Where the number is returned + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Scan a string for a decimal integer. + * + ******************************************************************************/ + +const char * +AcpiUtScanNumber ( + const char *String, + UINT64 *NumberPtr) +{ + UINT64 Number = 0; + + + while (ACPI_IS_DIGIT (*String)) + { + Number *= 10; + Number += *(String++) - '0'; + } + + *NumberPtr = Number; + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPrintNumber + * + * PARAMETERS: String - String buffer + * Number - The number to be converted + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Print a decimal integer into a string. + * + ******************************************************************************/ + +const char * +AcpiUtPrintNumber ( + char *String, + UINT64 Number) +{ + char AsciiString[20]; + const char *Pos1; + char *Pos2; + + + Pos1 = AcpiUtPutNumber (AsciiString, Number, 10, FALSE); + Pos2 = String; + + while (Pos1 != AsciiString) + { + *(Pos2++) = *(--Pos1); + } + + *Pos2 = 0; + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFormatNumber + * + * PARAMETERS: String - String buffer with boundary + * End - Boundary of the string + * Number - The number to be converted + * Base - Base of the integer + * Width - Field width + * Precision - Precision of the integer + * Type - Special printing flags + * + * RETURN: Updated position for next valid character + * + * DESCRIPTION: Print an integer into a string with any base and any precision. + * + ******************************************************************************/ + +static char * +AcpiUtFormatNumber ( + char *String, + char *End, + UINT64 Number, + UINT8 Base, + INT32 Width, + INT32 Precision, + UINT8 Type) +{ + char *Pos; + char Sign; + char Zero; + BOOLEAN NeedPrefix; + BOOLEAN Upper; + INT32 i; + char ReversedString[66]; + + + /* Parameter validation */ + + if (Base < 2 || Base > 16) + { + return (NULL); + } + + if (Type & ACPI_FORMAT_LEFT) + { + Type &= ~ACPI_FORMAT_ZERO; + } + + NeedPrefix = ((Type & ACPI_FORMAT_PREFIX) && Base != 10) ? TRUE : FALSE; + Upper = (Type & ACPI_FORMAT_UPPER) ? TRUE : FALSE; + Zero = (Type & ACPI_FORMAT_ZERO) ? '0' : ' '; + + /* Calculate size according to sign and prefix */ + + Sign = '\0'; + if (Type & ACPI_FORMAT_SIGN) + { + if ((INT64) Number < 0) + { + Sign = '-'; + Number = - (INT64) Number; + Width--; + } + else if (Type & ACPI_FORMAT_SIGN_PLUS) + { + Sign = '+'; + Width--; + } + else if (Type & ACPI_FORMAT_SIGN_PLUS_SPACE) + { + Sign = ' '; + Width--; + } + } + if (NeedPrefix) + { + Width--; + if (Base == 16) + { + Width--; + } + } + + /* Generate full string in reverse order */ + + Pos = AcpiUtPutNumber (ReversedString, Number, Base, Upper); + i = ACPI_PTR_DIFF (Pos, ReversedString); + + /* Printing 100 using %2d gives "100", not "00" */ + + if (i > Precision) + { + Precision = i; + } + + Width -= Precision; + + /* Output the string */ + + if (!(Type & (ACPI_FORMAT_ZERO | ACPI_FORMAT_LEFT))) + { + while (--Width >= 0) + { + String = AcpiUtBoundStringOutput (String, End, ' '); + } + } + if (Sign) + { + String = AcpiUtBoundStringOutput (String, End, Sign); + } + if (NeedPrefix) + { + String = AcpiUtBoundStringOutput (String, End, '0'); + if (Base == 16) + { + String = AcpiUtBoundStringOutput (String, End, + Upper ? 'X' : 'x'); + } + } + if (!(Type & ACPI_FORMAT_LEFT)) + { + while (--Width >= 0) + { + String = AcpiUtBoundStringOutput (String, End, Zero); + } + } + + while (i <= --Precision) + { + String = AcpiUtBoundStringOutput (String, End, '0'); + } + while (--i >= 0) + { + String = AcpiUtBoundStringOutput (String, End, + ReversedString[i]); + } + while (--Width >= 0) + { + String = AcpiUtBoundStringOutput (String, End, ' '); + } + + return (String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtVsnprintf + * + * PARAMETERS: String - String with boundary + * Size - Boundary of the string + * Format - Standard printf format + * Args - Argument list + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a string using argument list pointer. + * + ******************************************************************************/ + +int +AcpiUtVsnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + va_list Args) +{ + UINT8 Base = 10; + UINT8 Type = 0; + INT32 Width = -1; + INT32 Precision = -1; + char Qualifier = 0; + UINT64 Number; + char *Pos; + char *End; + char c; + const char *s; + const void *p; + INT32 Length; + int i; + + + Pos = String; + End = String + Size; + + for (; *Format; ++Format) + { + if (*Format != '%') + { + Pos = AcpiUtBoundStringOutput (Pos, End, *Format); + continue; + } + + /* Process sign */ + + do + { + ++Format; + if (*Format == '#') + { + Type |= ACPI_FORMAT_PREFIX; + } + else if (*Format == '0') + { + Type |= ACPI_FORMAT_ZERO; + } + else if (*Format == '+') + { + Type |= ACPI_FORMAT_SIGN_PLUS; + } + else if (*Format == ' ') + { + Type |= ACPI_FORMAT_SIGN_PLUS_SPACE; + } + else if (*Format == '-') + { + Type |= ACPI_FORMAT_LEFT; + } + else + { + break; + } + } while (1); + + /* Process width */ + + Width = -1; + if (ACPI_IS_DIGIT (*Format)) + { + Format = AcpiUtScanNumber (Format, &Number); + Width = (INT32) Number; + } + else if (*Format == '*') + { + ++Format; + Width = va_arg (Args, int); + if (Width < 0) + { + Width = -Width; + Type |= ACPI_FORMAT_LEFT; + } + } + + /* Process precision */ + + Precision = -1; + if (*Format == '.') + { + ++Format; + if (ACPI_IS_DIGIT(*Format)) + { + Format = AcpiUtScanNumber (Format, &Number); + Precision = (INT32) Number; + } + else if (*Format == '*') + { + ++Format; + Precision = va_arg (Args, int); + } + if (Precision < 0) + { + Precision = 0; + } + } + + /* Process qualifier */ + + Qualifier = -1; + if (*Format == 'h' || *Format == 'l' || *Format == 'L') + { + Qualifier = *Format; + ++Format; + + if (Qualifier == 'l' && *Format == 'l') + { + Qualifier = 'L'; + ++Format; + } + } + + switch (*Format) + { + case '%': + + Pos = AcpiUtBoundStringOutput (Pos, End, '%'); + continue; + + case 'c': + + if (!(Type & ACPI_FORMAT_LEFT)) + { + while (--Width > 0) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + } + + c = (char) va_arg (Args, int); + Pos = AcpiUtBoundStringOutput (Pos, End, c); + + while (--Width > 0) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + continue; + + case 's': + + s = va_arg (Args, char *); + if (!s) + { + s = ""; + } + Length = AcpiUtBoundStringLength (s, Precision); + if (!(Type & ACPI_FORMAT_LEFT)) + { + while (Length < Width--) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + } + for (i = 0; i < Length; ++i) + { + Pos = AcpiUtBoundStringOutput (Pos, End, *s); + ++s; + } + while (Length < Width--) + { + Pos = AcpiUtBoundStringOutput (Pos, End, ' '); + } + continue; + + case 'o': + + Base = 8; + break; + + case 'X': + + Type |= ACPI_FORMAT_UPPER; + + case 'x': + + Base = 16; + break; + + case 'd': + case 'i': + + Type |= ACPI_FORMAT_SIGN; + + case 'u': + + break; + + case 'p': + + if (Width == -1) + { + Width = 2 * sizeof (void *); + Type |= ACPI_FORMAT_ZERO; + } + + p = va_arg (Args, void *); + Pos = AcpiUtFormatNumber (Pos, End, + ACPI_TO_INTEGER (p), 16, Width, Precision, Type); + continue; + + default: + + Pos = AcpiUtBoundStringOutput (Pos, End, '%'); + if (*Format) + { + Pos = AcpiUtBoundStringOutput (Pos, End, *Format); + } + else + { + --Format; + } + continue; + } + + if (Qualifier == 'L') + { + Number = va_arg (Args, UINT64); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (INT64) Number; + } + } + else if (Qualifier == 'l') + { + Number = va_arg (Args, unsigned long); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (INT32) Number; + } + } + else if (Qualifier == 'h') + { + Number = (UINT16) va_arg (Args, int); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (INT16) Number; + } + } + else + { + Number = va_arg (Args, unsigned int); + if (Type & ACPI_FORMAT_SIGN) + { + Number = (signed int) Number; + } + } + + Pos = AcpiUtFormatNumber (Pos, End, Number, Base, + Width, Precision, Type); + } + + if (Size > 0) + { + if (Pos < End) + { + *Pos = '\0'; + } + else + { + End[-1] = '\0'; + } + } + + return (ACPI_PTR_DIFF (Pos, String)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSnprintf + * + * PARAMETERS: String - String with boundary + * Size - Boundary of the string + * Format, ... - Standard printf format + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a string. + * + ******************************************************************************/ + +int +AcpiUtSnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + ...) +{ + va_list Args; + int Length; + + + va_start (Args, Format); + Length = AcpiUtVsnprintf (String, Size, Format, Args); + va_end (Args); + + return (Length); +} + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiUtFileVprintf + * + * PARAMETERS: File - File descriptor + * Format - Standard printf format + * Args - Argument list + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a file using argument list pointer. + * + ******************************************************************************/ + +int +AcpiUtFileVprintf ( + ACPI_FILE File, + const char *Format, + va_list Args) +{ + ACPI_CPU_FLAGS Flags; + int Length; + + + Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock); + Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer, + sizeof (AcpiGbl_PrintBuffer), Format, Args); + + (void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1); + AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags); + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFilePrintf + * + * PARAMETERS: File - File descriptor + * Format, ... - Standard printf format + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Formatted output to a file. + * + ******************************************************************************/ + +int +AcpiUtFilePrintf ( + ACPI_FILE File, + const char *Format, + ...) +{ + va_list Args; + int Length; + + + va_start (Args, Format); + Length = AcpiUtFileVprintf (File, Format, Args); + va_end (Args); + + return (Length); +} +#endif diff --git a/sys/contrib/dev/acpica/components/utilities/utresrc.c b/sys/contrib/dev/acpica/components/utilities/utresrc.c index 3a47a0cf20c1..3b549fea8438 100644 --- a/sys/contrib/dev/acpica/components/utilities/utresrc.c +++ b/sys/contrib/dev/acpica/components/utilities/utresrc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTRESRC_C__ #include @@ -53,7 +52,7 @@ ACPI_MODULE_NAME ("utresrc") -#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) +#if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) /* * Strings used to decode resource descriptors. @@ -100,7 +99,9 @@ const char *AcpiGbl_IoDecode[] = const char *AcpiGbl_LlDecode[] = { "ActiveHigh", - "ActiveLow" + "ActiveLow", + "ActiveBoth", + "Reserved" }; const char *AcpiGbl_MaxDecode[] = diff --git a/sys/contrib/dev/acpica/components/utilities/utstate.c b/sys/contrib/dev/acpica/components/utilities/utstate.c index e0e5cce67390..2fa8fd663129 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstate.c +++ b/sys/contrib/dev/acpica/components/utilities/utstate.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTSTATE_C__ #include diff --git a/sys/contrib/dev/acpica/components/utilities/utstring.c b/sys/contrib/dev/acpica/components/utilities/utstring.c index 79b5452df4e2..2e3ea03efd61 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstring.c +++ b/sys/contrib/dev/acpica/components/utilities/utstring.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTSTRING_C__ #include @@ -420,7 +419,7 @@ AcpiUtPrintString ( } AcpiOsPrintf ("\""); - for (i = 0; String[i] && (i < MaxLength); i++) + for (i = 0; (i < MaxLength) && String[i]; i++) { /* Escape sequences */ @@ -685,3 +684,81 @@ UtConvertBackslashes ( } } #endif + +#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) +/******************************************************************************* + * + * FUNCTION: AcpiUtSafeStrcpy, AcpiUtSafeStrcat, AcpiUtSafeStrncat + * + * PARAMETERS: Adds a "DestSize" parameter to each of the standard string + * functions. This is the size of the Destination buffer. + * + * RETURN: TRUE if the operation would overflow the destination buffer. + * + * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that + * the result of the operation will not overflow the output string + * buffer. + * + * NOTE: These functions are typically only helpful for processing + * user input and command lines. For most ACPICA code, the + * required buffer length is precisely calculated before buffer + * allocation, so the use of these functions is unnecessary. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtSafeStrcpy ( + char *Dest, + ACPI_SIZE DestSize, + char *Source) +{ + + if (ACPI_STRLEN (Source) >= DestSize) + { + return (TRUE); + } + + ACPI_STRCPY (Dest, Source); + return (FALSE); +} + +BOOLEAN +AcpiUtSafeStrcat ( + char *Dest, + ACPI_SIZE DestSize, + char *Source) +{ + + if ((ACPI_STRLEN (Dest) + ACPI_STRLEN (Source)) >= DestSize) + { + return (TRUE); + } + + ACPI_STRCAT (Dest, Source); + return (FALSE); +} + +#ifndef _KERNEL +BOOLEAN +AcpiUtSafeStrncat ( + char *Dest, + ACPI_SIZE DestSize, + char *Source, + ACPI_SIZE MaxTransferLength) +{ + ACPI_SIZE ActualTransferLength; + + + ActualTransferLength = ACPI_MIN (MaxTransferLength, ACPI_STRLEN (Source)); + + if ((ACPI_STRLEN (Dest) + ActualTransferLength) >= DestSize) + { + return (TRUE); + } + + ACPI_STRNCAT (Dest, Source, MaxTransferLength); + return (FALSE); +} +#endif + +#endif diff --git a/sys/contrib/dev/acpica/components/utilities/uttrack.c b/sys/contrib/dev/acpica/components/utilities/uttrack.c index 5c381f0b2bef..1447bc3c9770 100644 --- a/sys/contrib/dev/acpica/components/utilities/uttrack.c +++ b/sys/contrib/dev/acpica/components/utilities/uttrack.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -151,10 +151,23 @@ AcpiUtAllocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), - Component, Module, Line); + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + ACPI_WARNING ((Module, Line, + "Attempt to allocate zero bytes, allocating 1 byte")); + Size = 1; + } + + Allocation = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER)); if (!Allocation) { + /* Report allocation error */ + + ACPI_WARNING ((Module, Line, + "Could not allocate size %u", (UINT32) Size)); + return (NULL); } @@ -204,8 +217,16 @@ AcpiUtAllocateZeroedAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), - Component, Module, Line); + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + ACPI_WARNING ((Module, Line, + "Attempt to allocate zero bytes, allocating 1 byte")); + Size = 1; + } + + Allocation = AcpiOsAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER)); if (!Allocation) { /* Report allocation error */ @@ -286,7 +307,8 @@ AcpiUtFreeAndTrack ( } AcpiOsFree (DebugBlock); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed (block %p)\n", + Allocation, DebugBlock)); return_VOID; } diff --git a/sys/contrib/dev/acpica/components/utilities/utuuid.c b/sys/contrib/dev/acpica/components/utilities/utuuid.c new file mode 100644 index 000000000000..b9c6a0947f58 --- /dev/null +++ b/sys/contrib/dev/acpica/components/utilities/utuuid.c @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * Module Name: utuuid -- UUID support functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 __UTUUID_C__ + +#include +#include + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("utuuid") + + +/* + * UUID support functions. + * + * This table is used to convert an input UUID ascii string to a 16 byte + * buffer and the reverse. The table maps a UUID buffer index 0-15 to + * the index within the 36-byte UUID string where the associated 2-byte + * hex value can be found. + * + * 36-byte UUID strings are of the form: + * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp + * Where aa-pp are one byte hex numbers, made up of two hex digits + * + * Note: This table is basically the inverse of the string-to-offset table + * found in the ACPI spec in the description of the ToUUID macro. + */ +const UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH] = +{ + 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtConvertStringToUuid + * + * PARAMETERS: InString - 36-byte formatted UUID string + * UuidBuffer - Where the 16-byte UUID buffer is returned + * + * RETURN: None. Output data is returned in the UuidBuffer + * + * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer + * + ******************************************************************************/ + +void +AcpiUtConvertStringToUuid ( + char *InString, + UINT8 *UuidBuffer) +{ + UINT32 i; + + + for (i = 0; i < UUID_BUFFER_LENGTH; i++) + { + UuidBuffer[i] = + (AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i]]) << 4); + + UuidBuffer[i] |= + AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i] + 1]); + } +} diff --git a/sys/contrib/dev/acpica/components/utilities/utxface.c b/sys/contrib/dev/acpica/components/utilities/utxface.c index b6003e6772e7..7ce79c080d92 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxface.c +++ b/sys/contrib/dev/acpica/components/utilities/utxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTXFACE_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -114,7 +114,7 @@ AcpiTerminate ( return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiTerminate) +ACPI_EXPORT_SYMBOL_INIT (AcpiTerminate) #ifndef ACPI_ASL_COMPILER diff --git a/sys/contrib/dev/acpica/components/utilities/utxferror.c b/sys/contrib/dev/acpica/components/utilities/utxferror.c index 8f11b297877a..e5d308300ad0 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxferror.c +++ b/sys/contrib/dev/acpica/components/utilities/utxferror.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ */ #define __UTXFERROR_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -55,6 +56,8 @@ * tools/applications. */ +#ifndef ACPI_NO_ERROR_MESSAGES /* Entire module */ + /******************************************************************************* * * FUNCTION: AcpiError @@ -294,3 +297,5 @@ AcpiBiosWarning ( } ACPI_EXPORT_SYMBOL (AcpiBiosWarning) + +#endif /* ACPI_NO_ERROR_MESSAGES */ diff --git a/sys/contrib/dev/acpica/components/utilities/utxfinit.c b/sys/contrib/dev/acpica/components/utilities/utxfinit.c index c828a710e0f3..061ca19c0abe 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxfinit.c +++ b/sys/contrib/dev/acpica/components/utilities/utxfinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __UTXFINIT_C__ +#define EXPORT_ACPI_INTERFACES #include #include @@ -130,11 +130,19 @@ AcpiInitializeSubsystem ( /* If configured, initialize the AML debugger */ - ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); - return_ACPI_STATUS (Status); +#ifdef ACPI_DEBUGGER + Status = AcpiDbInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization")); + return_ACPI_STATUS (Status); + } +#endif + + return_ACPI_STATUS (AE_OK); } -ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem) +ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem) /******************************************************************************* @@ -256,7 +264,7 @@ AcpiEnableSubsystem ( return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem) +ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem) /******************************************************************************* @@ -355,4 +363,4 @@ AcpiInitializeObjects ( return_ACPI_STATUS (Status); } -ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) +ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects) diff --git a/sys/contrib/dev/acpica/components/utilities/utxfmutex.c b/sys/contrib/dev/acpica/components/utilities/utxfmutex.c index ae5a345e93aa..dfa5225213de 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxfmutex.c +++ b/sys/contrib/dev/acpica/components/utilities/utxfmutex.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acapps.h b/sys/contrib/dev/acpica/include/acapps.h index fc9542358be1..5d46ff479e9d 100644 --- a/sys/contrib/dev/acpica/include/acapps.h +++ b/sys/contrib/dev/acpica/include/acapps.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ /* Common info for tool signons */ #define ACPICA_NAME "Intel ACPI Component Architecture" -#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2013 Intel Corporation" +#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2014 Intel Corporation" #if ACPI_MACHINE_WIDTH == 64 #define ACPI_WIDTH "-64" @@ -84,10 +84,13 @@ /* Macros for usage messages */ #define ACPI_USAGE_HEADER(Usage) \ - printf ("Usage: %s\nOptions:\n", Usage); + AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage); + +#define ACPI_USAGE_TEXT(Description) \ + AcpiOsPrintf (Description); #define ACPI_OPTION(Name, Description) \ - printf (" %-18s%s\n", Name, Description); + AcpiOsPrintf (" %-18s%s\n", Name, Description); #define FILE_SUFFIX_DISASSEMBLY "dsl" @@ -114,6 +117,14 @@ extern int AcpiGbl_SubOptChar; extern char *AcpiGbl_Optarg; +/* + * cmfsize - Common get file size function + */ +UINT32 +CmGetFileSize ( + ACPI_FILE File); + + #ifndef ACPI_DUMP_APP /* * adisasm @@ -123,8 +134,7 @@ AdAmlDisassemble ( BOOLEAN OutToFile, char *Filename, char *Prefix, - char **OutFilename, - BOOLEAN GetAllTables); + char **OutFilename); void AdPrintStatistics ( @@ -141,8 +151,7 @@ AdDumpTables ( ACPI_STATUS AdGetLocalTables ( - char *Filename, - BOOLEAN GetAllTables); + void); ACPI_STATUS AdParseTable ( diff --git a/sys/contrib/dev/acpica/include/acbuffer.h b/sys/contrib/dev/acpica/include/acbuffer.h index 965102472af1..a36a980aa954 100644 --- a/sys/contrib/dev/acpica/include/acbuffer.h +++ b/sys/contrib/dev/acpica/include/acbuffer.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/accommon.h b/sys/contrib/dev/acpica/include/accommon.h index 074b6c19c488..dc6a9b41c1ae 100644 --- a/sys/contrib/dev/acpica/include/accommon.h +++ b/sys/contrib/dev/acpica/include/accommon.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acconfig.h b/sys/contrib/dev/acpica/include/acconfig.h index 6a267fecf413..69242ee61c12 100644 --- a/sys/contrib/dev/acpica/include/acconfig.h +++ b/sys/contrib/dev/acpica/include/acconfig.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,9 @@ * Should the subsystem abort the loading of an ACPI table if the * table checksum is incorrect? */ +#ifndef ACPI_CHECKSUM_ABORT #define ACPI_CHECKSUM_ABORT FALSE +#endif /* * Generate a version of ACPICA that only supports "reduced hardware" @@ -101,7 +103,9 @@ * ACPI PM timer * FACS table (Waking vectors and Global Lock) */ +#ifndef ACPI_REDUCED_HARDWARE #define ACPI_REDUCED_HARDWARE FALSE +#endif /****************************************************************************** @@ -217,6 +221,25 @@ #define ACPI_NUM_SxW_METHODS 5 +/****************************************************************************** + * + * Miscellaneous constants + * + *****************************************************************************/ + +/* UUID constants */ + +#define UUID_BUFFER_LENGTH 16 /* Length of UUID in memory */ +#define UUID_STRING_LENGTH 36 /* Total length of a UUID string */ + +/* Positions for required hyphens (dashes) in UUID strings */ + +#define UUID_HYPHEN1_OFFSET 8 +#define UUID_HYPHEN2_OFFSET 13 +#define UUID_HYPHEN3_OFFSET 18 +#define UUID_HYPHEN4_OFFSET 23 + + /****************************************************************************** * * ACPI AML Debugger diff --git a/sys/contrib/dev/acpica/include/acdebug.h b/sys/contrib/dev/acpica/include/acdebug.h index 37d41d32190f..a85625731b08 100644 --- a/sys/contrib/dev/acpica/include/acdebug.h +++ b/sys/contrib/dev/acpica/include/acdebug.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -164,6 +164,11 @@ void AcpiDbGenerateSci ( void)) +void +AcpiDbExecuteTest ( + char *TypeArg); + + /* * dbconvert - miscellaneous conversion routines */ @@ -372,11 +377,6 @@ AcpiDbGetTableFromFile ( char *Filename, ACPI_TABLE_HEADER **Table); -ACPI_STATUS -AcpiDbReadTableFromFile ( - char *Filename, - ACPI_TABLE_HEADER **Table); - /* * dbhistry - debugger HISTORY command @@ -393,6 +393,10 @@ char * AcpiDbGetFromHistory ( char *CommandNumArg); +char * +AcpiDbGetHistoryByIndex ( + UINT32 CommanddNum); + /* * dbinput - user front-end to the AML debugger diff --git a/sys/contrib/dev/acpica/include/acdisasm.h b/sys/contrib/dev/acpica/include/acdisasm.h index 4fadd407109c..687991ed419a 100644 --- a/sys/contrib/dev/acpica/include/acdisasm.h +++ b/sys/contrib/dev/acpica/include/acdisasm.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,14 +69,14 @@ typedef const struct acpi_dmtable_info } ACPI_DMTABLE_INFO; +/* Values for Flags field above */ + #define DT_LENGTH 0x01 /* Field is a subtable length */ #define DT_FLAG 0x02 /* Field is a flag value */ #define DT_NON_ZERO 0x04 /* Field must be non-zero */ - -/* TBD: Not used at this time */ - -#define DT_OPTIONAL 0x08 -#define DT_COUNT 0x10 +#define DT_OPTIONAL 0x08 /* Field is optional */ +#define DT_DESCRIBES_OPTIONAL 0x10 /* Field describes an optional field (length, etc.) */ +#define DT_COUNT 0x20 /* Currently not used */ /* * Values for Opcode above. @@ -137,16 +137,20 @@ typedef enum ACPI_DMT_ASF, ACPI_DMT_DMAR, + ACPI_DMT_DMAR_SCOPE, ACPI_DMT_EINJACT, ACPI_DMT_EINJINST, ACPI_DMT_ERSTACT, ACPI_DMT_ERSTINST, ACPI_DMT_FADTPM, + ACPI_DMT_GTDT, ACPI_DMT_HEST, ACPI_DMT_HESTNTFY, ACPI_DMT_HESTNTYP, ACPI_DMT_IVRS, + ACPI_DMT_LPIT, ACPI_DMT_MADT, + ACPI_DMT_PCCT, ACPI_DMT_PMTT, ACPI_DMT_SLIC, ACPI_DMT_SRAT, @@ -186,6 +190,7 @@ typedef struct acpi_op_walk_info UINT32 BitOffset; UINT32 Flags; ACPI_WALK_STATE *WalkState; + ACPI_PARSE_OBJECT *MappingOp; } ACPI_OP_WALK_INFO; @@ -203,6 +208,7 @@ ACPI_STATUS (*ASL_WALK_CALLBACK) ( typedef void (*ACPI_RESOURCE_HANDLER) ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); @@ -244,6 +250,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Device[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Addr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Size[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Name[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2OemData[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[]; @@ -252,6 +259,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; @@ -269,6 +277,10 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt0a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGtdt1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; @@ -281,6 +293,9 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest9[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestNotify[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHestBank[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoLpitHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoLpit0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoLpit1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[]; @@ -303,6 +318,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; @@ -324,7 +341,9 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt1a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmttHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt[]; @@ -343,6 +362,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[]; @@ -437,6 +457,10 @@ void AcpiDmDumpFpdt ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpGtdt ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpHest ( ACPI_TABLE_HEADER *Table); @@ -445,6 +469,10 @@ void AcpiDmDumpIvrs ( ACPI_TABLE_HEADER *Table); +void +AcpiDmDumpLpit ( + ACPI_TABLE_HEADER *Table); + void AcpiDmDumpMadt ( ACPI_TABLE_HEADER *Table); @@ -548,6 +576,14 @@ void AcpiDmMethodFlags ( ACPI_PARSE_OBJECT *Op); +void +AcpiDmDisplayTargetPathname ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmNotifyDescription ( + ACPI_PARSE_OBJECT *Op); + void AcpiDmPredefinedDescription ( ACPI_PARSE_OBJECT *Op); @@ -628,13 +664,17 @@ AcpiDmByteList ( ACPI_PARSE_OBJECT *Op); void -AcpiDmIsEisaId ( +AcpiDmCheckForHardwareId ( ACPI_PARSE_OBJECT *Op); void -AcpiDmEisaId ( +AcpiDmDecompressEisaId ( UINT32 EncodedId); +BOOLEAN +AcpiDmIsUuidBuffer ( + ACPI_PARSE_OBJECT *Op); + BOOLEAN AcpiDmIsUnicodeBuffer ( ACPI_PARSE_OBJECT *Op); @@ -668,11 +708,19 @@ AcpiDmClearExternalFileList ( void); void -AcpiDmAddToExternalList ( +AcpiDmAddOpToExternalList ( ACPI_PARSE_OBJECT *Op, char *Path, UINT8 Type, - UINT32 Value); + UINT32 Value, + UINT16 Flags); + +void +AcpiDmAddNodeToExternalList ( + ACPI_NAMESPACE_NODE *Node, + UINT8 Type, + UINT32 Value, + UINT16 Flags); void AcpiDmAddExternalsToNamespace ( @@ -747,72 +795,84 @@ AcpiDmDescriptorName ( */ void AcpiDmWordDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmDwordDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmExtendedDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmQwordDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmMemory24Descriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmMemory32Descriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmFixedMemory32Descriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmGenericRegisterDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmInterruptDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmVendorLargeDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmGpioDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmSerialBusDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); @@ -830,48 +890,56 @@ AcpiDmVendorCommon ( */ void AcpiDmIrqDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmDmaDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmFixedDmaDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmIoDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmFixedIoDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmStartDependentDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmEndDependentDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmVendorSmallDescriptor ( + ACPI_OP_WALK_INFO *Info, AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); diff --git a/sys/contrib/dev/acpica/include/acdispat.h b/sys/contrib/dev/acpica/include/acdispat.h index fc747f1998cf..c4abebb55e8c 100644 --- a/sys/contrib/dev/acpica/include/acdispat.h +++ b/sys/contrib/dev/acpica/include/acdispat.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef _ACDISPAT_H_ #define _ACDISPAT_H_ @@ -173,13 +172,15 @@ AcpiDsInitFieldObjects ( /* - * dsload - Parser/Interpreter interface, pass 1 namespace load callbacks + * dsload - Parser/Interpreter interface */ ACPI_STATUS AcpiDsInitCallbacks ( ACPI_WALK_STATE *WalkState, UINT32 PassNumber); +/* dsload - pass 1 namespace load callbacks */ + ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, @@ -190,9 +191,8 @@ AcpiDsLoad1EndOp ( ACPI_WALK_STATE *WalkState); -/* - * dsload - Parser/Interpreter interface, pass 2 namespace load callbacks - */ +/* dsload - pass 2 namespace load callbacks */ + ACPI_STATUS AcpiDsLoad2BeginOp ( ACPI_WALK_STATE *WalkState, @@ -257,8 +257,9 @@ AcpiDsMethodDataInit ( * dsmethod - Parser/Interpreter interface - control method parsing */ ACPI_STATUS -AcpiDsParseMethod ( - ACPI_NAMESPACE_NODE *Node); +AcpiDsAutoSerializeMethod ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiDsCallControlMethod ( diff --git a/sys/contrib/dev/acpica/include/acevents.h b/sys/contrib/dev/acpica/include/acevents.h index 67095aa0e3dd..43c1d7cc5fd6 100644 --- a/sys/contrib/dev/acpica/include/acevents.h +++ b/sys/contrib/dev/acpica/include/acevents.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -144,9 +144,10 @@ AcpiEvFinishGpe ( ACPI_STATUS AcpiEvCreateGpeBlock ( ACPI_NAMESPACE_NODE *GpeDevice, - ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT64 Address, + UINT8 SpaceId, UINT32 RegisterCount, - UINT8 GpeBlockBaseNumber, + UINT16 GpeBlockBaseNumber, UINT32 InterruptNumber, ACPI_GPE_BLOCK_INFO **ReturnGpeBlock); @@ -206,9 +207,10 @@ AcpiEvGetGpeDevice ( ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context); -ACPI_GPE_XRUPT_INFO * +ACPI_STATUS AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber); + UINT32 InterruptNumber, + ACPI_GPE_XRUPT_INFO **GpeXruptBlock); ACPI_STATUS AcpiEvDeleteGpeXrupt ( diff --git a/sys/contrib/dev/acpica/include/acexcep.h b/sys/contrib/dev/acpica/include/acexcep.h index 7bcfe1d66708..aab6941a3c7e 100644 --- a/sys/contrib/dev/acpica/include/acexcep.h +++ b/sys/contrib/dev/acpica/include/acexcep.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acglobal.h b/sys/contrib/dev/acpica/include/acglobal.h index cb76f653b368..a83f8c34b0eb 100644 --- a/sys/contrib/dev/acpica/include/acglobal.h +++ b/sys/contrib/dev/acpica/include/acglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,167 +45,42 @@ #define __ACGLOBAL_H__ -/* - * Ensure that the globals are actually defined and initialized only once. - * - * The use of these macros allows a single list of globals (here) in order - * to simplify maintenance of the code. - */ -#ifdef DEFINE_ACPI_GLOBALS -#define ACPI_EXTERN -#define ACPI_INIT_GLOBAL(a,b) a=b -#else -#define ACPI_EXTERN extern -#define ACPI_INIT_GLOBAL(a,b) a -#endif - - -#ifdef DEFINE_ACPI_GLOBALS - -/* Public globals, available from outside ACPICA subsystem */ - /***************************************************************************** * - * Runtime configuration (static defaults that can be overriden at runtime) + * Globals related to the ACPI tables * ****************************************************************************/ -/* - * Enable "slack" in the AML interpreter? Default is FALSE, and the - * interpreter strictly follows the ACPI specification. Setting to TRUE - * allows the interpreter to ignore certain errors and/or bad AML constructs. - * - * Currently, these features are enabled by this flag: - * - * 1) Allow "implicit return" of last value in a control method - * 2) Allow access beyond the end of an operation region - * 3) Allow access to uninitialized locals/args (auto-init to integer 0) - * 4) Allow ANY object type to be a source operand for the Store() operator - * 5) Allow unresolved references (invalid target name) in package objects - * 6) Enable warning messages for behavior that is not ACPI spec compliant - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); +/* Master list of all ACPI tables that were found in the RSDT/XSDT */ -/* - * Automatically serialize ALL control methods? Default is FALSE, meaning - * to use the Serialized/NotSerialized method flags on a per method basis. - * Only change this if the ASL code is poorly written and cannot handle - * reentrancy even though methods are marked "NotSerialized". - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); +ACPI_GLOBAL (ACPI_TABLE_LIST, AcpiGbl_RootTableList); -/* - * Create the predefined _OSI method in the namespace? Default is TRUE - * because ACPI CA is fully compatible with other ACPI implementations. - * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); +/* DSDT information. Used to check for DSDT corruption */ -/* - * Optionally use default values for the ACPI register widths. Set this to - * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); - -/* - * Optionally enable output from the AML Debug Object. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableAmlDebugObject, FALSE); - -/* - * Optionally copy the entire DSDT to local memory (instead of simply - * mapping it.) There are some BIOSs that corrupt or replace the original - * DSDT, creating the need for this option. Default is FALSE, do not copy - * the DSDT. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CopyDsdtLocally, FALSE); - -/* - * Optionally truncate I/O addresses to 16 bits. Provides compatibility - * with other ACPI implementations. NOTE: During ACPICA initialization, - * this value is set to TRUE if any Windows OSI strings have been - * requested by the BIOS. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_TruncateIoAddresses, FALSE); - -/* - * Disable runtime checking and repair of values returned by control methods. - * Use only if the repair is causing a problem on a particular machine. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_DisableAutoRepair, FALSE); - -/* - * Optionally do not load any SSDTs from the RSDT/XSDT during initialization. - * This can be useful for debugging ACPI problems on some machines. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_DisableSsdtTableLoad, FALSE); - -/* - * We keep track of the latest version of Windows that has been requested by - * the BIOS. - */ -UINT8 ACPI_INIT_GLOBAL (AcpiGbl_OsiData, 0); - - -/* AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ - -ACPI_TABLE_FADT AcpiGbl_FADT; -UINT32 AcpiCurrentGpeCount; -UINT32 AcpiGbl_TraceFlags; -ACPI_NAME AcpiGbl_TraceMethodName; -BOOLEAN AcpiGbl_SystemAwakeAndRunning; - -/* - * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning - * that the ACPI hardware is no longer required. A flag in the FADT indicates - * a reduced HW machine, and that flag is duplicated here for convenience. - */ -BOOLEAN AcpiGbl_ReducedHardware; - -#endif /* DEFINE_ACPI_GLOBALS */ - -/* Do not disassemble buffers to resource descriptors */ - -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_NoResourceDisassembly, FALSE); - -/***************************************************************************** - * - * ACPI Table globals - * - ****************************************************************************/ - -/* - * AcpiGbl_RootTableList is the master list of ACPI tables that were - * found in the RSDT/XSDT. - */ -ACPI_EXTERN ACPI_TABLE_LIST AcpiGbl_RootTableList; +ACPI_GLOBAL (ACPI_TABLE_HEADER *, AcpiGbl_DSDT); +ACPI_GLOBAL (ACPI_TABLE_HEADER, AcpiGbl_OriginalDsdtHeader); #if (!ACPI_REDUCED_HARDWARE) -ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; +ACPI_GLOBAL (ACPI_TABLE_FACS *, AcpiGbl_FACS); #endif /* !ACPI_REDUCED_HARDWARE */ /* These addresses are calculated from the FADT Event Block addresses */ -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aStatus; -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; +ACPI_GLOBAL (ACPI_GENERIC_ADDRESS, AcpiGbl_XPm1aStatus); +ACPI_GLOBAL (ACPI_GENERIC_ADDRESS, AcpiGbl_XPm1aEnable); -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bStatus; -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; - -/* DSDT information. Used to check for DSDT corruption */ - -ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; -ACPI_EXTERN ACPI_TABLE_HEADER AcpiGbl_OriginalDsdtHeader; +ACPI_GLOBAL (ACPI_GENERIC_ADDRESS, AcpiGbl_XPm1bStatus); +ACPI_GLOBAL (ACPI_GENERIC_ADDRESS, AcpiGbl_XPm1bEnable); /* - * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is + * Handle both ACPI 1.0 and ACPI 2.0+ Integer widths. The integer width is * determined by the revision of the DSDT: If the DSDT revision is less than * 2, use only the lower 32 bits of the internal 64-bit Integer. */ -ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; -ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; -ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; +ACPI_GLOBAL (UINT8, AcpiGbl_IntegerBitWidth); +ACPI_GLOBAL (UINT8, AcpiGbl_IntegerByteWidth); +ACPI_GLOBAL (UINT8, AcpiGbl_IntegerNybbleWidth); /***************************************************************************** @@ -219,36 +94,36 @@ ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. * (The table maps local handles to the real OS handles) */ -ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[ACPI_NUM_MUTEX]; +ACPI_GLOBAL (ACPI_MUTEX_INFO, AcpiGbl_MutexInfo[ACPI_NUM_MUTEX]); /* * Global lock mutex is an actual AML mutex object * Global lock semaphore works in conjunction with the actual global lock * Global lock spinlock is used for "pending" handshake */ -ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_GlobalLockMutex; -ACPI_EXTERN ACPI_SEMAPHORE AcpiGbl_GlobalLockSemaphore; -ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GlobalLockPendingLock; -ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; -ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; -ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; -ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPending; +ACPI_GLOBAL (ACPI_OPERAND_OBJECT *, AcpiGbl_GlobalLockMutex); +ACPI_GLOBAL (ACPI_SEMAPHORE, AcpiGbl_GlobalLockSemaphore); +ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_GlobalLockPendingLock); +ACPI_GLOBAL (UINT16, AcpiGbl_GlobalLockHandle); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_GlobalLockAcquired); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_GlobalLockPresent); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_GlobalLockPending); /* * Spinlocks are used for interfaces that can be possibly called at * interrupt level */ -ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GpeLock; /* For GPE data structs and registers */ -ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_HardwareLock; /* For ACPI H/W except GPE registers */ -ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_ReferenceCountLock; +ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_GpeLock); /* For GPE data structs and registers */ +ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_HardwareLock); /* For ACPI H/W except GPE registers */ +ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_ReferenceCountLock); /* Mutex for _OSI support */ -ACPI_EXTERN ACPI_MUTEX AcpiGbl_OsiMutex; +ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_OsiMutex); /* Reader/Writer lock is used for namespace walk and dynamic table unload */ -ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; +ACPI_GLOBAL (ACPI_RW_LOCK, AcpiGbl_NamespaceRwLock); /***************************************************************************** @@ -259,69 +134,67 @@ ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; /* Object caches */ -ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_NamespaceCache; -ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_StateCache; -ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeCache; -ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeExtCache; -ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_OperandCache; +ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_NamespaceCache); +ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_StateCache); +ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_PsNodeCache); +ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_PsNodeExtCache); +ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_OperandCache); + +/* System */ + +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_StartupFlags, 0); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_Shutdown, TRUE); /* Global handlers */ -ACPI_EXTERN ACPI_GLOBAL_NOTIFY_HANDLER AcpiGbl_GlobalNotify[2]; -ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; -ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; -ACPI_EXTERN ACPI_TABLE_HANDLER AcpiGbl_TableHandler; -ACPI_EXTERN void *AcpiGbl_TableHandlerContext; -ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; -ACPI_EXTERN ACPI_INTERFACE_HANDLER AcpiGbl_InterfaceHandler; -ACPI_EXTERN ACPI_SCI_HANDLER_INFO *AcpiGbl_SciHandlerList; +ACPI_GLOBAL (ACPI_GLOBAL_NOTIFY_HANDLER,AcpiGbl_GlobalNotify[2]); +ACPI_GLOBAL (ACPI_EXCEPTION_HANDLER, AcpiGbl_ExceptionHandler); +ACPI_GLOBAL (ACPI_INIT_HANDLER, AcpiGbl_InitHandler); +ACPI_GLOBAL (ACPI_TABLE_HANDLER, AcpiGbl_TableHandler); +ACPI_GLOBAL (void *, AcpiGbl_TableHandlerContext); +ACPI_GLOBAL (ACPI_INTERFACE_HANDLER, AcpiGbl_InterfaceHandler); +ACPI_GLOBAL (ACPI_SCI_HANDLER_INFO *, AcpiGbl_SciHandlerList); /* Owner ID support */ -ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]; -ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; -ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; +ACPI_GLOBAL (UINT32, AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]); +ACPI_GLOBAL (UINT8, AcpiGbl_LastOwnerIdIndex); +ACPI_GLOBAL (UINT8, AcpiGbl_NextOwnerIdOffset); /* Initialization sequencing */ -ACPI_EXTERN BOOLEAN AcpiGbl_RegMethodsExecuted; +ACPI_GLOBAL (BOOLEAN, AcpiGbl_RegMethodsExecuted); /* Misc */ -ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; -ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; -ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; -ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; -ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; -ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; -ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; -ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; -ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; -ACPI_EXTERN ACPI_INTERFACE_INFO *AcpiGbl_SupportedInterfaces; -ACPI_EXTERN ACPI_ADDRESS_RANGE *AcpiGbl_AddressRangeList[ACPI_ADDRESS_RANGE_MAX]; +ACPI_GLOBAL (UINT32, AcpiGbl_OriginalMode); +ACPI_GLOBAL (UINT32, AcpiGbl_NsLookupCount); +ACPI_GLOBAL (UINT32, AcpiGbl_PsFindCount); +ACPI_GLOBAL (UINT16, AcpiGbl_Pm1EnableRegisterSave); +ACPI_GLOBAL (UINT8, AcpiGbl_DebuggerConfiguration); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_StepToNextCall); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_AcpiHardwarePresent); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_EventsInitialized); +ACPI_GLOBAL (ACPI_INTERFACE_INFO *, AcpiGbl_SupportedInterfaces); +ACPI_GLOBAL (ACPI_ADDRESS_RANGE *, AcpiGbl_AddressRangeList[ACPI_ADDRESS_RANGE_MAX]); -#ifndef DEFINE_ACPI_GLOBALS +/* Other miscellaneous, declared and initialized in utglobal */ -/* Other miscellaneous */ - -extern BOOLEAN AcpiGbl_Shutdown; -extern UINT32 AcpiGbl_StartupFlags; extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; -extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; -#endif +extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; #ifdef ACPI_DBG_TRACK_ALLOCATIONS -/* Lists for tracking memory allocations */ +/* Lists for tracking memory allocations (debug only) */ -ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; -ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; -ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; -ACPI_EXTERN BOOLEAN AcpiGbl_DisableMemTracking; +ACPI_GLOBAL (ACPI_MEMORY_LIST *, AcpiGbl_GlobalList); +ACPI_GLOBAL (ACPI_MEMORY_LIST *, AcpiGbl_NsNodeList); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DisplayFinalMemStats); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DisableMemTracking); #endif @@ -337,22 +210,23 @@ ACPI_EXTERN BOOLEAN AcpiGbl_DisableMemTracking; #define NUM_PREDEFINED_NAMES 9 #endif -ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; -ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; -ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_FadtGpeDevice; -ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ModuleCodeList; +ACPI_GLOBAL (ACPI_NAMESPACE_NODE, AcpiGbl_RootNodeStruct); +ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_RootNode); +ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_FadtGpeDevice); +ACPI_GLOBAL (ACPI_OPERAND_OBJECT *, AcpiGbl_ModuleCodeList); extern const UINT8 AcpiGbl_NsProperties [ACPI_NUM_NS_TYPES]; extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; #ifdef ACPI_DEBUG_OUTPUT -ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; -ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; -ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; -ACPI_EXTERN ACPI_SIZE *AcpiGbl_EntryStackPointer; -ACPI_EXTERN ACPI_SIZE *AcpiGbl_LowestStackPointer; -ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; +ACPI_GLOBAL (UINT32, AcpiGbl_CurrentNodeCount); +ACPI_GLOBAL (UINT32, AcpiGbl_CurrentNodeSize); +ACPI_GLOBAL (UINT32, AcpiGbl_MaxConcurrentNodeCount); +ACPI_GLOBAL (ACPI_SIZE *, AcpiGbl_EntryStackPointer); +ACPI_GLOBAL (ACPI_SIZE *, AcpiGbl_LowestStackPointer); +ACPI_GLOBAL (UINT32, AcpiGbl_DeepestNesting); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); #endif @@ -362,11 +236,11 @@ ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; * ****************************************************************************/ -ACPI_EXTERN ACPI_THREAD_STATE *AcpiGbl_CurrentWalkList; +ACPI_GLOBAL (ACPI_THREAD_STATE *, AcpiGbl_CurrentWalkList); /* Control method single step flag */ -ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; +ACPI_GLOBAL (UINT8, AcpiGbl_CmSingleStep); /***************************************************************************** @@ -375,9 +249,10 @@ ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; * ****************************************************************************/ -extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; -ACPI_EXTERN UINT8 AcpiGbl_SleepTypeA; -ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; +extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; + +ACPI_GLOBAL (UINT8, AcpiGbl_SleepTypeA); +ACPI_GLOBAL (UINT8, AcpiGbl_SleepTypeB); /***************************************************************************** @@ -388,13 +263,14 @@ ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; #if (!ACPI_REDUCED_HARDWARE) -ACPI_EXTERN UINT8 AcpiGbl_AllGpesInitialized; -ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead; -ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]; -ACPI_EXTERN ACPI_GBL_EVENT_HANDLER AcpiGbl_GlobalEventHandler; -ACPI_EXTERN void *AcpiGbl_GlobalEventHandlerContext; -ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; -extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; +ACPI_GLOBAL (UINT8, AcpiGbl_AllGpesInitialized); +ACPI_GLOBAL (ACPI_GPE_XRUPT_INFO *, AcpiGbl_GpeXruptListHead); +ACPI_GLOBAL (ACPI_GPE_BLOCK_INFO *, AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]); +ACPI_GLOBAL (ACPI_GBL_EVENT_HANDLER, AcpiGbl_GlobalEventHandler); +ACPI_GLOBAL (void *, AcpiGbl_GlobalEventHandlerContext); +ACPI_GLOBAL (ACPI_FIXED_EVENT_HANDLER, AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]); + +extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; #endif /* !ACPI_REDUCED_HARDWARE */ @@ -404,23 +280,19 @@ extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EV * ****************************************************************************/ -/* Procedure nesting level for debug output */ - -extern UINT32 AcpiGbl_NestingLevel; - /* Event counters */ -ACPI_EXTERN UINT32 AcpiMethodCount; -ACPI_EXTERN UINT32 AcpiGpeCount; -ACPI_EXTERN UINT32 AcpiSciCount; -ACPI_EXTERN UINT32 AcpiFixedEventCount[ACPI_NUM_FIXED_EVENTS]; +ACPI_GLOBAL (UINT32, AcpiMethodCount); +ACPI_GLOBAL (UINT32, AcpiGpeCount); +ACPI_GLOBAL (UINT32, AcpiSciCount); +ACPI_GLOBAL (UINT32, AcpiFixedEventCount[ACPI_NUM_FIXED_EVENTS]); /* Support for dynamic control method tracing mechanism */ -ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; -ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; -ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; -ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; +ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLevel); +ACPI_GLOBAL (UINT32, AcpiGbl_OriginalDbgLayer); +ACPI_GLOBAL (UINT32, AcpiGbl_TraceDbgLevel); +ACPI_GLOBAL (UINT32, AcpiGbl_TraceDbgLayer); /***************************************************************************** @@ -429,74 +301,90 @@ ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; * ****************************************************************************/ -ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DbOutputFlags, ACPI_DB_CONSOLE_OUTPUT); #ifdef ACPI_DISASSEMBLER -ACPI_EXTERN BOOLEAN ACPI_INIT_GLOBAL (AcpiGbl_IgnoreNoopOperator, FALSE); +/* Do not disassemble buffers to resource descriptors */ -ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_disasm; -ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_verbose; -ACPI_EXTERN BOOLEAN AcpiGbl_NumExternalMethods; -ACPI_EXTERN UINT32 AcpiGbl_ResolvedExternalMethods; -ACPI_EXTERN ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; -ACPI_EXTERN ACPI_EXTERNAL_FILE *AcpiGbl_ExternalFileList; +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_NoResourceDisassembly, FALSE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_IgnoreNoopOperator, FALSE); + +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_disasm); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_verbose); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_NumExternalMethods); +ACPI_GLOBAL (UINT32, AcpiGbl_ResolvedExternalMethods); +ACPI_GLOBAL (ACPI_EXTERNAL_LIST *, AcpiGbl_ExternalList); +ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); #endif - #ifdef ACPI_DEBUGGER -extern BOOLEAN AcpiGbl_MethodExecuting; -extern BOOLEAN AcpiGbl_AbortMethod; -extern BOOLEAN AcpiGbl_DbTerminateThreads; +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DbTerminateThreads, FALSE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE); -ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables; -ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats; -ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; -ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_NoRegionSupport; -ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile; -ACPI_EXTERN char *AcpiGbl_DbBuffer; -ACPI_EXTERN char *AcpiGbl_DbFilename; -ACPI_EXTERN UINT32 AcpiGbl_DbDebugLevel; -ACPI_EXTERN UINT32 AcpiGbl_DbConsoleDebugLevel; -ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_DbScopeNode; +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_tables); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_stats); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_ini_methods); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOutputToFile); +ACPI_GLOBAL (char *, AcpiGbl_DbBuffer); +ACPI_GLOBAL (char *, AcpiGbl_DbFilename); +ACPI_GLOBAL (UINT32, AcpiGbl_DbDebugLevel); +ACPI_GLOBAL (UINT32, AcpiGbl_DbConsoleDebugLevel); +ACPI_GLOBAL (ACPI_NAMESPACE_NODE *, AcpiGbl_DbScopeNode); -ACPI_EXTERN char *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]; -ACPI_EXTERN ACPI_OBJECT_TYPE AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARGS]; +ACPI_GLOBAL (char *, AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]); +ACPI_GLOBAL (ACPI_OBJECT_TYPE, AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARGS]); /* These buffers should all be the same size */ -ACPI_EXTERN char AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]; -ACPI_EXTERN char AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]; -ACPI_EXTERN char AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]; -ACPI_EXTERN char AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]; +ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]); +ACPI_GLOBAL (char, AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]); +ACPI_GLOBAL (char, AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]); +ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]); /* * Statistic globals */ -ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; -ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; -ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCountMisc; -ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCountMisc; -ACPI_EXTERN UINT32 AcpiGbl_NumNodes; -ACPI_EXTERN UINT32 AcpiGbl_NumObjects; - - -ACPI_EXTERN UINT32 AcpiGbl_SizeOfParseTree; -ACPI_EXTERN UINT32 AcpiGbl_SizeOfMethodTrees; -ACPI_EXTERN UINT32 AcpiGbl_SizeOfNodeEntries; -ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; +ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]); +ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]); +ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCountMisc); +ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc); +ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes); +ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects); #endif /* ACPI_DEBUGGER */ +/***************************************************************************** + * + * Application globals + * + ****************************************************************************/ + +#ifdef ACPI_APPLICATION + +ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_DebugFile, NULL); +ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_OutputFile, NULL); + +/* Print buffer */ + +ACPI_GLOBAL (ACPI_SPINLOCK, AcpiGbl_PrintLock); /* For print buffer */ +ACPI_GLOBAL (char, AcpiGbl_PrintBuffer[1024]); + +#endif /* ACPI_APPLICATION */ + + /***************************************************************************** * * Info/help support * ****************************************************************************/ -extern const AH_PREDEFINED_NAME AslPredefinedInfo[]; +extern const AH_PREDEFINED_NAME AslPredefinedInfo[]; +extern const AH_DEVICE_ID AslDeviceIds[]; #endif /* __ACGLOBAL_H__ */ diff --git a/sys/contrib/dev/acpica/include/achware.h b/sys/contrib/dev/acpica/include/achware.h index 9577fd1685d3..1b1331879983 100644 --- a/sys/contrib/dev/acpica/include/achware.h +++ b/sys/contrib/dev/acpica/include/achware.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acinterp.h b/sys/contrib/dev/acpica/include/acinterp.h index ebf4c9882e53..b77864034b72 100644 --- a/sys/contrib/dev/acpica/include/acinterp.h +++ b/sys/contrib/dev/acpica/include/acinterp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -89,6 +89,10 @@ typedef const struct acpi_exdump_info #define ACPI_EXD_PACKAGE 11 #define ACPI_EXD_FIELD 12 #define ACPI_EXD_REFERENCE 13 +#define ACPI_EXD_LIST 14 /* Operand object list */ +#define ACPI_EXD_HDLR_LIST 15 /* Address Handler list */ +#define ACPI_EXD_RGN_LIST 16 /* Region list */ +#define ACPI_EXD_NODE 17 /* Namespace Node */ /* restore default alignment */ @@ -612,14 +616,6 @@ void AcpiExExitInterpreter ( void); -void -AcpiExReacquireInterpreter ( - void); - -void -AcpiExRelinquishInterpreter ( - void); - BOOLEAN AcpiExTruncateFor32bitTable ( ACPI_OPERAND_OBJECT *ObjDesc); diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h index 5ee1430132c5..d911985ed160 100644 --- a/sys/contrib/dev/acpica/include/aclocal.h +++ b/sys/contrib/dev/acpica/include/aclocal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -291,6 +291,7 @@ typedef struct acpi_create_field_info UINT32 FieldBitPosition; UINT32 FieldBitLength; UINT16 ResourceLength; + UINT16 PinNumberIndex; UINT8 FieldFlags; UINT8 Attribute; UINT8 FieldType; @@ -516,9 +517,9 @@ typedef struct acpi_gpe_register_info { ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ + UINT16 BaseGpeNumber; /* Base GPE number for this register */ 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; @@ -534,10 +535,11 @@ typedef struct acpi_gpe_block_info 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 */ + UINT64 Address; /* 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 */ + UINT16 BlockBaseNumber;/* Base GPE number for this block */ + UINT8 SpaceId; BOOLEAN Initialized; /* TRUE if this block is initialized */ } ACPI_GPE_BLOCK_INFO; @@ -877,11 +879,13 @@ typedef union acpi_parse_value #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 */ +#define ACPI_DASM_UUID 0x05 /* Buffer is a UUID/GUID */ +#define ACPI_DASM_EISAID 0x06 /* Integer is an EISAID */ +#define ACPI_DASM_MATCHOP 0x07 /* Parent opcode is a Match() operator */ +#define ACPI_DASM_LNOT_PREFIX 0x08 /* Start of a LNotEqual (etc.) pair of opcodes */ +#define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a LNotEqual (etc.) pair of opcodes */ +#define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */ +#define ACPI_DASM_IGNORE 0x0B /* Not used at this time */ /* * Generic operation (for example: If, While, Store) @@ -1218,17 +1222,17 @@ typedef struct acpi_external_list struct acpi_external_list *Next; UINT32 Value; UINT16 Length; + UINT16 Flags; UINT8 Type; - UINT8 Flags; - BOOLEAN Resolved; - BOOLEAN Emitted; } ACPI_EXTERNAL_LIST; /* Values for Flags field above */ -#define ACPI_IPATH_ALLOCATED 0x01 -#define ACPI_FROM_REFERENCE_FILE 0x02 +#define ACPI_EXT_RESOLVED_REFERENCE 0x01 /* Object was resolved during cross ref */ +#define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */ +#define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */ +#define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */ typedef struct acpi_external_file @@ -1259,7 +1263,7 @@ typedef struct acpi_db_method_info char *Name; UINT32 Flags; UINT32 NumLoops; - char Pathname[128]; + char Pathname[ACPI_DB_LINE_BUFFER_SIZE]; char **Args; ACPI_OBJECT_TYPE *Types; @@ -1286,6 +1290,7 @@ typedef struct acpi_integrity_info } ACPI_INTEGRITY_INFO; +#define ACPI_DB_DISABLE_OUTPUT 0x00 #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 #define ACPI_DB_CONSOLE_OUTPUT 0x02 #define ACPI_DB_DUPLICATE_OUTPUT 0x03 @@ -1348,4 +1353,18 @@ typedef struct ah_predefined_name } AH_PREDEFINED_NAME; +typedef struct ah_device_id +{ + char *Name; + char *Description; + +} AH_DEVICE_ID; + +typedef struct ah_uuid +{ + char *Description; + char *String; + +} AH_UUID; + #endif /* __ACLOCAL_H__ */ diff --git a/sys/contrib/dev/acpica/include/acmacros.h b/sys/contrib/dev/acpica/include/acmacros.h index 28bd2afea2db..19a3e8e23542 100644 --- a/sys/contrib/dev/acpica/include/acmacros.h +++ b/sys/contrib/dev/acpica/include/acmacros.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,17 +64,21 @@ #define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (UINT64) (val)) /* - * printf() format helpers + * printf() format helpers. These macros are workarounds for the difficulties + * with emitting 64-bit integers and 64-bit pointers with the same code + * for both 32-bit and 64-bit hosts. */ - -/* 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) +#define ACPI_FORMAT_TO_UINT(i) ACPI_FORMAT_UINT64(i) +#define ACPI_PRINTF_UINT "0x%8.8X%8.8X" + #else -#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i) +#define ACPI_FORMAT_NATIVE_UINT(i) 0, (UINT32) (i) +#define ACPI_FORMAT_TO_UINT(i) (UINT32) (i) +#define ACPI_PRINTF_UINT "0x%8.8X" #endif @@ -414,32 +418,6 @@ #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 */ diff --git a/sys/contrib/dev/acpica/include/acnames.h b/sys/contrib/dev/acpica/include/acnames.h index d6fdaa6f5774..3297a732f200 100644 --- a/sys/contrib/dev/acpica/include/acnames.h +++ b/sys/contrib/dev/acpica/include/acnames.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,24 +46,31 @@ /* Method names - these methods can appear anywhere in the namespace */ -#define METHOD_NAME__SB_ "_SB_" -#define METHOD_NAME__HID "_HID" -#define METHOD_NAME__CID "_CID" -#define METHOD_NAME__UID "_UID" -#define METHOD_NAME__SUB "_SUB" #define METHOD_NAME__ADR "_ADR" -#define METHOD_NAME__INI "_INI" -#define METHOD_NAME__STA "_STA" -#define METHOD_NAME__REG "_REG" -#define METHOD_NAME__SEG "_SEG" -#define METHOD_NAME__BBN "_BBN" -#define METHOD_NAME__PRT "_PRT" -#define METHOD_NAME__CRS "_CRS" -#define METHOD_NAME__PRS "_PRS" #define METHOD_NAME__AEI "_AEI" -#define METHOD_NAME__PRW "_PRW" -#define METHOD_NAME__SRS "_SRS" +#define METHOD_NAME__BBN "_BBN" +#define METHOD_NAME__CBA "_CBA" +#define METHOD_NAME__CID "_CID" +#define METHOD_NAME__CRS "_CRS" +#define METHOD_NAME__DDN "_DDN" +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__INI "_INI" #define METHOD_NAME__PLD "_PLD" +#define METHOD_NAME__DSD "_DSD" +#define METHOD_NAME__PRS "_PRS" +#define METHOD_NAME__PRT "_PRT" +#define METHOD_NAME__PRW "_PRW" +#define METHOD_NAME__PS0 "_PS0" +#define METHOD_NAME__PS1 "_PS1" +#define METHOD_NAME__PS2 "_PS2" +#define METHOD_NAME__PS3 "_PS3" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SB_ "_SB_" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__SRS "_SRS" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__SUB "_SUB" +#define METHOD_NAME__UID "_UID" /* Method names - these methods must appear at the namespace root */ diff --git a/sys/contrib/dev/acpica/include/acnamesp.h b/sys/contrib/dev/acpica/include/acnamesp.h index 2dba62907129..9fd3841c6c72 100644 --- a/sys/contrib/dev/acpica/include/acnamesp.h +++ b/sys/contrib/dev/acpica/include/acnamesp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acobject.h b/sys/contrib/dev/acpica/include/acobject.h index e755daa61dc7..c08c8272b0b8 100644 --- a/sys/contrib/dev/acpica/include/acobject.h +++ b/sys/contrib/dev/acpica/include/acobject.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -232,7 +232,8 @@ typedef struct acpi_object_method #define ACPI_METHOD_INTERNAL_ONLY 0x02 /* Method is implemented internally (_OSI) */ #define ACPI_METHOD_SERIALIZED 0x04 /* Method is serialized */ #define ACPI_METHOD_SERIALIZED_PENDING 0x08 /* Method is to be marked serialized */ -#define ACPI_METHOD_MODIFIED_NAMESPACE 0x10 /* Method modified the namespace */ +#define ACPI_METHOD_IGNORE_SYNC_LEVEL 0x10 /* Method was auto-serialized at table load time */ +#define ACPI_METHOD_MODIFIED_NAMESPACE 0x20 /* Method modified the namespace */ /****************************************************************************** @@ -337,6 +338,7 @@ typedef struct acpi_object_region_field UINT16 ResourceLength; union acpi_operand_object *RegionObj; /* Containing OpRegion object */ UINT8 *ResourceBuffer; /* ResourceTemplate for serial regions/fields */ + UINT16 PinNumberIndex; /* Index relative to previous Connection/Template */ } ACPI_OBJECT_REGION_FIELD; diff --git a/sys/contrib/dev/acpica/include/acopcode.h b/sys/contrib/dev/acpica/include/acopcode.h index ba37842fa233..b968fc62a772 100644 --- a/sys/contrib/dev/acpica/include/acopcode.h +++ b/sys/contrib/dev/acpica/include/acopcode.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acoutput.h b/sys/contrib/dev/acpica/include/acoutput.h index e7b1248b0142..8f054ae11929 100644 --- a/sys/contrib/dev/acpica/include/acoutput.h +++ b/sys/contrib/dev/acpica/include/acoutput.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acparser.h b/sys/contrib/dev/acpica/include/acparser.h index 7f236d8605f1..8d8adba1fcfd 100644 --- a/sys/contrib/dev/acpica/include/acparser.h +++ b/sys/contrib/dev/acpica/include/acparser.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ACPARSER_H__ #define __ACPARSER_H__ diff --git a/sys/contrib/dev/acpica/include/acpi.h b/sys/contrib/dev/acpica/include/acpi.h index 5450ad40f386..aab3dd3f125b 100644 --- a/sys/contrib/dev/acpica/include/acpi.h +++ b/sys/contrib/dev/acpica/include/acpi.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,5 +62,6 @@ #include /* Resource Descriptor structs */ #include /* OSL interfaces (ACPICA-to-OS) */ #include /* ACPI core subsystem external interfaces */ +#include /* Extra environment-specific items */ #endif /* __ACPI_H__ */ diff --git a/sys/contrib/dev/acpica/include/acpiosxf.h b/sys/contrib/dev/acpica/include/acpiosxf.h index c948d3f367d6..1a1aa1b0076f 100644 --- a/sys/contrib/dev/acpica/include/acpiosxf.h +++ b/sys/contrib/dev/acpica/include/acpiosxf.h @@ -6,9 +6,8 @@ * *****************************************************************************/ - /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,85 +84,111 @@ typedef struct acpi_signal_fatal_info /* * OSL Initialization and shutdown primitives */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitialize ACPI_STATUS AcpiOsInitialize ( void); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminate ACPI_STATUS AcpiOsTerminate ( void); +#endif /* * ACPI Table interfaces */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetRootPointer ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer ( void); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPredefinedOverride ACPI_STATUS AcpiOsPredefinedOverride ( const ACPI_PREDEFINED_NAMES *InitVal, ACPI_STRING *NewVal); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTableOverride ACPI_STATUS AcpiOsTableOverride ( ACPI_TABLE_HEADER *ExistingTable, ACPI_TABLE_HEADER **NewTable); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPhysicalTableOverride ACPI_STATUS AcpiOsPhysicalTableOverride ( ACPI_TABLE_HEADER *ExistingTable, ACPI_PHYSICAL_ADDRESS *NewAddress, UINT32 *NewTableLength); +#endif /* * Spinlock primitives */ -#ifndef AcpiOsCreateLock +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock ACPI_STATUS AcpiOsCreateLock ( ACPI_SPINLOCK *OutHandle); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteLock void AcpiOsDeleteLock ( ACPI_SPINLOCK Handle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireLock ACPI_CPU_FLAGS AcpiOsAcquireLock ( ACPI_SPINLOCK Handle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseLock void AcpiOsReleaseLock ( ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags); +#endif /* * Semaphore primitives */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateSemaphore ACPI_STATUS AcpiOsCreateSemaphore ( UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteSemaphore ACPI_STATUS AcpiOsDeleteSemaphore ( ACPI_SEMAPHORE Handle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitSemaphore ACPI_STATUS AcpiOsWaitSemaphore ( ACPI_SEMAPHORE Handle, UINT32 Units, UINT16 Timeout); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignalSemaphore ACPI_STATUS AcpiOsSignalSemaphore ( ACPI_SEMAPHORE Handle, UINT32 Units); +#endif /* @@ -172,151 +197,208 @@ AcpiOsSignalSemaphore ( */ #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateMutex ACPI_STATUS AcpiOsCreateMutex ( ACPI_MUTEX *OutHandle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteMutex void AcpiOsDeleteMutex ( ACPI_MUTEX Handle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireMutex ACPI_STATUS AcpiOsAcquireMutex ( ACPI_MUTEX Handle, UINT16 Timeout); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseMutex void AcpiOsReleaseMutex ( ACPI_MUTEX Handle); #endif +#endif + /* * Memory allocation and mapping */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate void * AcpiOsAllocate ( ACPI_SIZE Size); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE Size); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree void AcpiOsFree ( void * Memory); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsMapMemory void * AcpiOsMapMemory ( ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsUnmapMemory void AcpiOsUnmapMemory ( void *LogicalAddress, ACPI_SIZE Size); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetPhysicalAddress ACPI_STATUS AcpiOsGetPhysicalAddress ( void *LogicalAddress, ACPI_PHYSICAL_ADDRESS *PhysicalAddress); +#endif /* * Memory/Object Cache */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateCache ACPI_STATUS AcpiOsCreateCache ( char *CacheName, UINT16 ObjectSize, UINT16 MaxDepth, ACPI_CACHE_T **ReturnCache); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteCache ACPI_STATUS AcpiOsDeleteCache ( ACPI_CACHE_T *Cache); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPurgeCache ACPI_STATUS AcpiOsPurgeCache ( ACPI_CACHE_T *Cache); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject void * AcpiOsAcquireObject ( ACPI_CACHE_T *Cache); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseObject ACPI_STATUS AcpiOsReleaseObject ( ACPI_CACHE_T *Cache, void *Object); +#endif /* * Interrupt handlers */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInstallInterruptHandler ACPI_STATUS AcpiOsInstallInterruptHandler ( UINT32 InterruptNumber, ACPI_OSD_HANDLER ServiceRoutine, void *Context); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRemoveInterruptHandler ACPI_STATUS AcpiOsRemoveInterruptHandler ( UINT32 InterruptNumber, ACPI_OSD_HANDLER ServiceRoutine); +#endif /* * Threads and Scheduling */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId ACPI_THREAD_ID AcpiOsGetThreadId ( void); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsExecute ACPI_STATUS AcpiOsExecute ( ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitEventsComplete void AcpiOsWaitEventsComplete ( void); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSleep void AcpiOsSleep ( UINT64 Milliseconds); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsStall void AcpiOsStall ( UINT32 Microseconds); +#endif /* * Platform and hardware-independent I/O interfaces */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPort ACPI_STATUS AcpiOsReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePort ACPI_STATUS AcpiOsWritePort ( ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width); +#endif /* * Platform and hardware-independent physical memory interfaces */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadMemory ACPI_STATUS AcpiOsReadMemory ( ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT32 Width); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteMemory ACPI_STATUS AcpiOsWriteMemory ( ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT32 Width); +#endif /* @@ -324,103 +406,131 @@ AcpiOsWriteMemory ( * Note: Can't use "Register" as a parameter, changed to "Reg" -- * certain compilers complain. */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPciConfiguration ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Reg, UINT64 *Value, UINT32 Width); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePciConfiguration ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, UINT32 Reg, UINT64 Value, UINT32 Width); +#endif /* * Miscellaneous */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable BOOLEAN AcpiOsReadable ( void *Pointer, ACPI_SIZE Length); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable BOOLEAN AcpiOsWritable ( void *Pointer, ACPI_SIZE Length); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTimer UINT64 AcpiOsGetTimer ( void); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignal ACPI_STATUS AcpiOsSignal ( UINT32 Function, void *Info); +#endif /* * Debug print routines */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPrintf void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf ( const char *Format, ...); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsVprintf void AcpiOsVprintf ( const char *Format, va_list Args); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput void AcpiOsRedirectOutput ( void *Destination); +#endif /* * Debug input */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine ACPI_STATUS AcpiOsGetLine ( char *Buffer, UINT32 BufferLength, UINT32 *BytesRead); +#endif /* * Obtain ACPI table(s) */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName ACPI_STATUS AcpiOsGetTableByName ( char *Signature, UINT32 Instance, ACPI_TABLE_HEADER **Table, ACPI_PHYSICAL_ADDRESS *Address); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex ACPI_STATUS AcpiOsGetTableByIndex ( UINT32 Index, ACPI_TABLE_HEADER **Table, UINT32 *Instance, ACPI_PHYSICAL_ADDRESS *Address); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress ACPI_STATUS AcpiOsGetTableByAddress ( ACPI_PHYSICAL_ADDRESS Address, ACPI_TABLE_HEADER **Table); +#endif /* * Directory manipulation */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory void * AcpiOsOpenDirectory ( char *Pathname, char *WildcardSpec, char RequestedFileType); +#endif /* RequesteFileType values */ @@ -428,13 +538,66 @@ AcpiOsOpenDirectory ( #define REQUEST_DIR_ONLY 1 +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename char * AcpiOsGetNextFilename ( void *DirHandle); +#endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory void AcpiOsCloseDirectory ( void *DirHandle); +#endif + + +/* + * File I/O and related support + */ +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenFile +ACPI_FILE +AcpiOsOpenFile ( + const char *Path, + UINT8 Modes); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseFile +void +AcpiOsCloseFile ( + ACPI_FILE File); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadFile +int +AcpiOsReadFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteFile +int +AcpiOsWriteFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetFileOffset +long +AcpiOsGetFileOffset ( + ACPI_FILE File); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSetFileOffset +ACPI_STATUS +AcpiOsSetFileOffset ( + ACPI_FILE File, + long Offset, + UINT8 From); +#endif #endif /* __ACPIOSXF_H__ */ diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h index 80f724a6f97f..93e9c1454174 100644 --- a/sys/contrib/dev/acpica/include/acpixf.h +++ b/sys/contrib/dev/acpica/include/acpixf.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,62 +41,258 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #ifndef __ACXFACE_H__ #define __ACXFACE_H__ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20130823 +#define ACPI_CA_VERSION 0x20140926 #include #include #include #include + +/***************************************************************************** + * + * Macros used for ACPICA globals and configuration + * + ****************************************************************************/ + /* - * Globals that are publically available + * Ensure that global variables are defined and initialized only once. + * + * The use of these macros allows for a single list of globals (here) + * in order to simplify maintenance of the code. */ -extern UINT32 AcpiCurrentGpeCount; -extern ACPI_TABLE_FADT AcpiGbl_FADT; -extern BOOLEAN AcpiGbl_SystemAwakeAndRunning; -extern BOOLEAN AcpiGbl_ReducedHardware; /* ACPI 5.0 */ -extern UINT8 AcpiGbl_OsiData; +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_GLOBAL(type,name) \ + extern type name; \ + type name -/* Runtime configuration of debug print levels */ +#define ACPI_INIT_GLOBAL(type,name,value) \ + type name=value -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; -extern UINT8 AcpiGbl_DisableSsdtTableLoad; +#else +#ifndef ACPI_GLOBAL +#define ACPI_GLOBAL(type,name) \ + extern type name +#endif +#ifndef ACPI_INIT_GLOBAL +#define ACPI_INIT_GLOBAL(type,name,value) \ + extern type name +#endif +#endif /* - * Hardware-reduced prototypes. All interfaces that use these macros will - * be configured out of the ACPICA build if the ACPI_REDUCED_HARDWARE flag + * These macros configure the various ACPICA interfaces. They are + * useful for generating stub inline functions for features that are + * configured out of the current kernel or ACPICA application. + */ +#ifndef ACPI_EXTERNAL_RETURN_STATUS +#define ACPI_EXTERNAL_RETURN_STATUS(Prototype) \ + Prototype; +#endif + +#ifndef ACPI_EXTERNAL_RETURN_OK +#define ACPI_EXTERNAL_RETURN_OK(Prototype) \ + Prototype; +#endif + +#ifndef ACPI_EXTERNAL_RETURN_VOID +#define ACPI_EXTERNAL_RETURN_VOID(Prototype) \ + Prototype; +#endif + +#ifndef ACPI_EXTERNAL_RETURN_UINT32 +#define ACPI_EXTERNAL_RETURN_UINT32(Prototype) \ + Prototype; +#endif + +#ifndef ACPI_EXTERNAL_RETURN_PTR +#define ACPI_EXTERNAL_RETURN_PTR(Prototype) \ + Prototype; +#endif + + +/***************************************************************************** + * + * Public globals and runtime configuration options + * + ****************************************************************************/ + +/* + * Enable "slack mode" of the AML interpreter? Default is FALSE, and the + * interpreter strictly follows the ACPI specification. Setting to TRUE + * allows the interpreter to ignore certain errors and/or bad AML constructs. + * + * Currently, these features are enabled by this flag: + * + * 1) Allow "implicit return" of last value in a control method + * 2) Allow access beyond the end of an operation region + * 3) Allow access to uninitialized locals/args (auto-init to integer 0) + * 4) Allow ANY object type to be a source operand for the Store() operator + * 5) Allow unresolved references (invalid target name) in package objects + * 6) Enable warning messages for behavior that is not ACPI spec compliant + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_EnableInterpreterSlack, FALSE); + +/* + * Automatically serialize all methods that create named objects? Default + * is TRUE, meaning that all NonSerialized methods are scanned once at + * table load time to determine those that create named objects. Methods + * that create named objects are marked Serialized in order to prevent + * possible run-time problems if they are entered by more than one thread. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_AutoSerializeMethods, TRUE); + +/* + * Create the predefined _OSI method in the namespace? Default is TRUE + * because ACPICA is fully compatible with other ACPI implementations. + * Changing this will revert ACPICA (and machine ASL) to pre-OSI behavior. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_CreateOsiMethod, TRUE); + +/* + * Optionally use default values for the ACPI register widths. Set this to + * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_UseDefaultRegisterWidths, TRUE); + +/* + * Whether or not to verify the table checksum before installation. Set + * this to TRUE to verify the table checksum before install it to the table + * manager. Note that enabling this option causes errors to happen in some + * OSPMs during early initialization stages. Default behavior is to do such + * verification. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_VerifyTableChecksum, TRUE); + +/* + * Optionally enable output from the AML Debug Object. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_EnableAmlDebugObject, FALSE); + +/* + * Optionally copy the entire DSDT to local memory (instead of simply + * mapping it.) There are some BIOSs that corrupt or replace the original + * DSDT, creating the need for this option. Default is FALSE, do not copy + * the DSDT. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_CopyDsdtLocally, FALSE); + +/* + * Optionally ignore an XSDT if present and use the RSDT instead. + * Although the ACPI specification requires that an XSDT be used instead + * of the RSDT, the XSDT has been found to be corrupt or ill-formed on + * some machines. Default behavior is to use the XSDT if present. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DoNotUseXsdt, FALSE); + +/* + * Optionally use 32-bit FADT addresses if and when there is a conflict + * (address mismatch) between the 32-bit and 64-bit versions of the + * address. Although ACPICA adheres to the ACPI specification which + * requires the use of the corresponding 64-bit address if it is non-zero, + * some machines have been found to have a corrupted non-zero 64-bit + * address. Default is FALSE, do not favor the 32-bit addresses. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_Use32BitFadtAddresses, FALSE); + +/* + * Optionally truncate I/O addresses to 16 bits. Provides compatibility + * with other ACPI implementations. NOTE: During ACPICA initialization, + * this value is set to TRUE if any Windows OSI strings have been + * requested by the BIOS. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_TruncateIoAddresses, FALSE); + +/* + * Disable runtime checking and repair of values returned by control methods. + * Use only if the repair is causing a problem on a particular machine. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableAutoRepair, FALSE); + +/* + * Optionally do not install any SSDTs from the RSDT/XSDT during initialization. + * This can be useful for debugging ACPI problems on some machines. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableSsdtTableInstall, FALSE); + +/* + * We keep track of the latest version of Windows that has been requested by + * the BIOS. ACPI 5.0. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_OsiData, 0); + +/* + * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning + * that the ACPI hardware is no longer required. A flag in the FADT indicates + * a reduced HW machine, and that flag is duplicated here for convenience. + */ +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_ReducedHardware, FALSE); + +/* + * This mechanism is used to trace a specified AML method. The method is + * traced each time it is executed. + */ +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_TraceFlags, 0); +ACPI_INIT_GLOBAL (ACPI_NAME, AcpiGbl_TraceMethodName, 0); + +/* + * Runtime configuration of debug output control masks. We want the debug + * switches statically initialized so they are already set when the debugger + * is entered. + */ +#ifdef ACPI_DEBUG_OUTPUT +ACPI_INIT_GLOBAL (UINT32, AcpiDbgLevel, ACPI_DEBUG_DEFAULT); +#else +ACPI_INIT_GLOBAL (UINT32, AcpiDbgLevel, ACPI_NORMAL_DEFAULT); +#endif +ACPI_INIT_GLOBAL (UINT32, AcpiDbgLayer, ACPI_COMPONENT_DEFAULT); + +/* + * Other miscellaneous globals + */ +ACPI_GLOBAL (ACPI_TABLE_FADT, AcpiGbl_FADT); +ACPI_GLOBAL (UINT32, AcpiCurrentGpeCount); +ACPI_GLOBAL (BOOLEAN, AcpiGbl_SystemAwakeAndRunning); + + +/***************************************************************************** + * + * ACPICA public interface configuration. + * + * Interfaces that are configured out of the ACPICA build are replaced + * by inlined stubs by default. + * + ****************************************************************************/ + +/* + * Hardware-reduced prototypes (default: Not hardware reduced). + * + * All ACPICA hardware-related interfaces that use these macros will be + * configured out of the ACPICA build if the ACPI_REDUCED_HARDWARE flag * is set to TRUE. + * + * Note: This static build option for reduced hardware is intended to + * reduce ACPICA code size if desired or necessary. However, even if this + * option is not specified, the runtime behavior of ACPICA is dependent + * on the actual FADT reduced hardware flag (HW_REDUCED_ACPI). If set, + * the flag will enable similar behavior -- ACPICA will not attempt + * to access any ACPI-relate hardware (SCI, GPEs, Fixed Events, etc.) */ #if (!ACPI_REDUCED_HARDWARE) #define ACPI_HW_DEPENDENT_RETURN_STATUS(Prototype) \ - Prototype; + ACPI_EXTERNAL_RETURN_STATUS(Prototype) #define ACPI_HW_DEPENDENT_RETURN_OK(Prototype) \ - Prototype; + ACPI_EXTERNAL_RETURN_OK(Prototype) #define ACPI_HW_DEPENDENT_RETURN_VOID(Prototype) \ - Prototype; + ACPI_EXTERNAL_RETURN_VOID(Prototype) #else #define ACPI_HW_DEPENDENT_RETURN_STATUS(Prototype) \ @@ -106,35 +302,100 @@ extern UINT8 AcpiGbl_DisableSsdtTableLoad; static ACPI_INLINE Prototype {return(AE_OK);} #define ACPI_HW_DEPENDENT_RETURN_VOID(Prototype) \ - static ACPI_INLINE Prototype {} + static ACPI_INLINE Prototype {return;} #endif /* !ACPI_REDUCED_HARDWARE */ +/* + * Error message prototypes (default: error messages enabled). + * + * All interfaces related to error and warning messages + * will be configured out of the ACPICA build if the + * ACPI_NO_ERROR_MESSAGE flag is defined. + */ +#ifndef ACPI_NO_ERROR_MESSAGES +#define ACPI_MSG_DEPENDENT_RETURN_VOID(Prototype) \ + Prototype; + +#else +#define ACPI_MSG_DEPENDENT_RETURN_VOID(Prototype) \ + static ACPI_INLINE Prototype {return;} + +#endif /* ACPI_NO_ERROR_MESSAGES */ + + +/* + * Debugging output prototypes (default: no debug output). + * + * All interfaces related to debug output messages + * will be configured out of the ACPICA build unless the + * ACPI_DEBUG_OUTPUT flag is defined. + */ +#ifdef ACPI_DEBUG_OUTPUT +#define ACPI_DBG_DEPENDENT_RETURN_VOID(Prototype) \ + Prototype; + +#else +#define ACPI_DBG_DEPENDENT_RETURN_VOID(Prototype) \ + static ACPI_INLINE Prototype {return;} + +#endif /* ACPI_DEBUG_OUTPUT */ + + +/* + * Application prototypes + * + * All interfaces used by application will be configured + * out of the ACPICA build unless the ACPI_APPLICATION + * flag is defined. + */ +#ifdef ACPI_APPLICATION +#define ACPI_APP_DEPENDENT_RETURN_VOID(Prototype) \ + Prototype; + +#else +#define ACPI_APP_DEPENDENT_RETURN_VOID(Prototype) \ + static ACPI_INLINE Prototype {return;} + +#endif /* ACPI_APPLICATION */ + + +/***************************************************************************** + * + * ACPICA public interface prototypes + * + ****************************************************************************/ + /* * Initialization */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInitializeTables ( ACPI_TABLE_DESC *InitialStorage, UINT32 InitialTableCount, - BOOLEAN AllowResize); + BOOLEAN AllowResize)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInitializeSubsystem ( - void); + void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiEnableSubsystem ( - UINT32 Flags); + UINT32 Flags)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInitializeObjects ( - UINT32 Flags); + UINT32 Flags)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiTerminate ( - void); + void)) /* @@ -150,124 +411,136 @@ ACPI_STATUS AcpiDisable ( void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiSubsystemStatus ( - void); + void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetSystemInfo ( - ACPI_BUFFER *RetBuffer); + ACPI_BUFFER *RetBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetStatistics ( - ACPI_STATISTICS *Stats); + ACPI_STATISTICS *Stats)) +ACPI_EXTERNAL_RETURN_PTR ( const char * AcpiFormatException ( - ACPI_STATUS Exception); + ACPI_STATUS Exception)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiPurgeCachedObjects ( - void); + void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallInterface ( - ACPI_STRING InterfaceName); + ACPI_STRING InterfaceName)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiRemoveInterface ( - ACPI_STRING InterfaceName); + ACPI_STRING InterfaceName)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiUpdateInterfaces ( - UINT8 Action); + UINT8 Action)) +ACPI_EXTERNAL_RETURN_UINT32 ( UINT32 AcpiCheckAddressRange ( ACPI_ADR_SPACE_TYPE SpaceId, ACPI_PHYSICAL_ADDRESS Address, ACPI_SIZE Length, - BOOLEAN Warn); + BOOLEAN Warn)) +ACPI_EXTERNAL_RETURN_STATUS ( 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_PLD_INFO **ReturnBuffer)) /* * ACPI table load/unload interfaces */ +ACPI_EXTERNAL_RETURN_STATUS ( +ACPI_STATUS +AcpiInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + BOOLEAN Physical)) + +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiLoadTable ( - ACPI_TABLE_HEADER *Table); + ACPI_TABLE_HEADER *Table)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiUnloadParentTable ( - ACPI_HANDLE Object); + ACPI_HANDLE Object)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiLoadTables ( - void); + void)) /* * ACPI table manipulation interfaces */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiReallocateRootTable ( - void); + void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiFindRootPointer ( - ACPI_SIZE *RsdpAddress); + ACPI_SIZE *RsdpAddress)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetTableHeader ( ACPI_STRING Signature, UINT32 Instance, - ACPI_TABLE_HEADER *OutTableHeader); + ACPI_TABLE_HEADER *OutTableHeader)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetTable ( ACPI_STRING Signature, UINT32 Instance, - ACPI_TABLE_HEADER **OutTable); + ACPI_TABLE_HEADER **OutTable)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetTableByIndex ( UINT32 TableIndex, - ACPI_TABLE_HEADER **OutTable); + ACPI_TABLE_HEADER **OutTable)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallTableHandler ( ACPI_TABLE_HANDLER Handler, - void *Context); + void *Context)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiRemoveTableHandler ( - ACPI_TABLE_HANDLER Handler); + ACPI_TABLE_HANDLER Handler)) /* * Namespace and name interfaces */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiWalkNamespace ( ACPI_OBJECT_TYPE Type, @@ -276,104 +549,119 @@ AcpiWalkNamespace ( ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, - void **ReturnValue); + void **ReturnValue)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetDevices ( char *HID, ACPI_WALK_CALLBACK UserFunction, void *Context, - void **ReturnValue); + void **ReturnValue)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetName ( ACPI_HANDLE Object, UINT32 NameType, - ACPI_BUFFER *RetPathPtr); + ACPI_BUFFER *RetPathPtr)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetHandle ( ACPI_HANDLE Parent, ACPI_STRING Pathname, - ACPI_HANDLE *RetHandle); + ACPI_HANDLE *RetHandle)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiAttachData ( ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler, - void *Data); + void *Data)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiDetachData ( ACPI_HANDLE Object, - ACPI_OBJECT_HANDLER Handler); + ACPI_OBJECT_HANDLER Handler)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetData ( ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler, - void **Data); + void **Data)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiDebugTrace ( char *Name, UINT32 DebugLevel, UINT32 DebugLayer, - UINT32 Flags); + UINT32 Flags)) /* * Object manipulation and enumeration */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiEvaluateObject ( ACPI_HANDLE Object, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ParameterObjects, - ACPI_BUFFER *ReturnObjectBuffer); + ACPI_BUFFER *ReturnObjectBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiEvaluateObjectTyped ( ACPI_HANDLE Object, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer, - ACPI_OBJECT_TYPE ReturnType); + ACPI_OBJECT_TYPE ReturnType)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetObjectInfo ( ACPI_HANDLE Object, - ACPI_DEVICE_INFO **ReturnBuffer); + ACPI_DEVICE_INFO **ReturnBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallMethod ( - UINT8 *Buffer); + UINT8 *Buffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetNextObject ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE Parent, ACPI_HANDLE Child, - ACPI_HANDLE *OutHandle); + ACPI_HANDLE *OutHandle)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetType ( ACPI_HANDLE Object, - ACPI_OBJECT_TYPE *OutType); + ACPI_OBJECT_TYPE *OutType)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetParent ( ACPI_HANDLE Object, - ACPI_HANDLE *OutHandle); + ACPI_HANDLE *OutHandle)) /* * Handler interfaces */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallInitializationHandler ( ACPI_INIT_HANDLER Handler, - UINT32 Function); + UINT32 Function)) ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS @@ -421,40 +709,46 @@ AcpiRemoveGpeHandler ( UINT32 GpeNumber, ACPI_GPE_HANDLER Address)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallNotifyHandler ( ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler, - void *Context); + void *Context)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiRemoveNotifyHandler ( ACPI_HANDLE Device, UINT32 HandlerType, - ACPI_NOTIFY_HANDLER Handler); + ACPI_NOTIFY_HANDLER Handler)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallAddressSpaceHandler ( ACPI_HANDLE Device, ACPI_ADR_SPACE_TYPE SpaceId, ACPI_ADR_SPACE_HANDLER Handler, ACPI_ADR_SPACE_SETUP Setup, - void *Context); + void *Context)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiRemoveAddressSpaceHandler ( ACPI_HANDLE Device, ACPI_ADR_SPACE_TYPE SpaceId, - ACPI_ADR_SPACE_HANDLER Handler); + ACPI_ADR_SPACE_HANDLER Handler)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallExceptionHandler ( - ACPI_EXCEPTION_HANDLER Handler); + ACPI_EXCEPTION_HANDLER Handler)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiInstallInterfaceHandler ( - ACPI_INTERFACE_HANDLER Handler); + ACPI_INTERFACE_HANDLER Handler)) /* @@ -475,16 +769,18 @@ AcpiReleaseGlobalLock ( /* * Interfaces to AML mutex objects */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiAcquireMutex ( ACPI_HANDLE Handle, ACPI_STRING Pathname, - UINT16 Timeout); + UINT16 Timeout)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiReleaseMutex ( ACPI_HANDLE Handle, - ACPI_STRING Pathname); + ACPI_STRING Pathname)) /* @@ -553,6 +849,12 @@ AcpiFinishGpe ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber)) +ACPI_HW_DEPENDENT_RETURN_STATUS ( +ACPI_STATUS +AcpiMarkGpeForWake ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber)) + ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS AcpiSetupGpeForWake ( @@ -612,79 +914,92 @@ ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( ACPI_RESOURCE *Resource, void *Context); +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetVendorResource ( ACPI_HANDLE Device, char *Name, ACPI_VENDOR_UUID *Uuid, - ACPI_BUFFER *RetBuffer); + ACPI_BUFFER *RetBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetCurrentResources ( ACPI_HANDLE Device, - ACPI_BUFFER *RetBuffer); + ACPI_BUFFER *RetBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetPossibleResources ( ACPI_HANDLE Device, - ACPI_BUFFER *RetBuffer); + ACPI_BUFFER *RetBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetEventResources ( ACPI_HANDLE DeviceHandle, - ACPI_BUFFER *RetBuffer); + ACPI_BUFFER *RetBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiWalkResourceBuffer ( ACPI_BUFFER *Buffer, ACPI_WALK_RESOURCE_CALLBACK UserFunction, - void *Context); + void *Context)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiWalkResources ( ACPI_HANDLE Device, char *Name, ACPI_WALK_RESOURCE_CALLBACK UserFunction, - void *Context); + void *Context)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiSetCurrentResources ( ACPI_HANDLE Device, - ACPI_BUFFER *InBuffer); + ACPI_BUFFER *InBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetIrqRoutingTable ( ACPI_HANDLE Device, - ACPI_BUFFER *RetBuffer); + ACPI_BUFFER *RetBuffer)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiResourceToAddress64 ( ACPI_RESOURCE *Resource, - ACPI_RESOURCE_ADDRESS64 *Out); + ACPI_RESOURCE_ADDRESS64 *Out)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiBufferToResource ( UINT8 *AmlBuffer, UINT16 AmlBufferLength, - ACPI_RESOURCE **ResourcePtr); + ACPI_RESOURCE **ResourcePtr)) /* * Hardware (ACPI device) interfaces */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiReset ( - void); + void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiRead ( UINT64 *Value, - ACPI_GENERIC_ADDRESS *Reg); + ACPI_GENERIC_ADDRESS *Reg)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiWrite ( UINT64 Value, - ACPI_GENERIC_ADDRESS *Reg); + ACPI_GENERIC_ADDRESS *Reg)) ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS @@ -702,32 +1017,37 @@ AcpiWriteBitRegister ( /* * Sleep/Wake interfaces */ +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiGetSleepTypeData ( UINT8 SleepState, UINT8 *Slp_TypA, - UINT8 *Slp_TypB); + UINT8 *Slp_TypB)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiEnterSleepStatePrep ( - UINT8 SleepState); + UINT8 SleepState)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiEnterSleepState ( - UINT8 SleepState); + UINT8 SleepState)) ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS AcpiEnterSleepStateS4bios ( void)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiLeaveSleepStatePrep ( - UINT8 SleepState); + UINT8 SleepState)) +ACPI_EXTERNAL_RETURN_STATUS ( ACPI_STATUS AcpiLeaveSleepState ( - UINT8 SleepState); + UINT8 SleepState)) ACPI_HW_DEPENDENT_RETURN_STATUS ( ACPI_STATUS @@ -766,55 +1086,67 @@ AcpiGetTimerDuration ( /* * Error/Warning output */ +ACPI_MSG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(3) void ACPI_INTERNAL_VAR_XFACE AcpiError ( const char *ModuleName, UINT32 LineNumber, const char *Format, - ...) ACPI_PRINTF_LIKE(3); + ...)) +ACPI_MSG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(4) void ACPI_INTERNAL_VAR_XFACE AcpiException ( const char *ModuleName, UINT32 LineNumber, ACPI_STATUS Status, const char *Format, - ...) ACPI_PRINTF_LIKE(4); + ...)) +ACPI_MSG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(3) void ACPI_INTERNAL_VAR_XFACE AcpiWarning ( const char *ModuleName, UINT32 LineNumber, const char *Format, - ...) ACPI_PRINTF_LIKE(3); + ...)) +ACPI_MSG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(3) void ACPI_INTERNAL_VAR_XFACE AcpiInfo ( const char *ModuleName, UINT32 LineNumber, const char *Format, - ...) ACPI_PRINTF_LIKE(3); + ...)) +ACPI_MSG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(3) void ACPI_INTERNAL_VAR_XFACE AcpiBiosError ( const char *ModuleName, UINT32 LineNumber, const char *Format, - ...) ACPI_PRINTF_LIKE(3); + ...)) +ACPI_MSG_DEPENDENT_RETURN_VOID ( +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 - +ACPI_DBG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(6) void ACPI_INTERNAL_VAR_XFACE AcpiDebugPrint ( UINT32 RequestedDebugLevel, @@ -823,8 +1155,10 @@ AcpiDebugPrint ( const char *ModuleName, UINT32 ComponentId, const char *Format, - ...) ACPI_PRINTF_LIKE(6); + ...)) +ACPI_DBG_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(6) void ACPI_INTERNAL_VAR_XFACE AcpiDebugPrintRaw ( UINT32 RequestedDebugLevel, @@ -833,7 +1167,13 @@ AcpiDebugPrintRaw ( const char *ModuleName, UINT32 ComponentId, const char *Format, - ...) ACPI_PRINTF_LIKE(6); -#endif + ...)) + +ACPI_APP_DEPENDENT_RETURN_VOID ( +ACPI_PRINTF_LIKE(1) +void ACPI_INTERNAL_VAR_XFACE +AcpiLogError ( + const char *Format, + ...)) #endif /* __ACXFACE_H__ */ diff --git a/sys/contrib/dev/acpica/include/acpredef.h b/sys/contrib/dev/acpica/include/acpredef.h index 46f3d695ef1c..c41ab03b5440 100644 --- a/sys/contrib/dev/acpica/include/acpredef.h +++ b/sys/contrib/dev/acpica/include/acpredef.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ * * Return Package types * - * 1) PTYPE1 packages do not contain sub-packages. + * 1) PTYPE1 packages do not contain subpackages. * * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types: * object type @@ -64,8 +64,8 @@ * (Used for _PRW) * * - * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each - * of the different types describe the contents of each of the sub-packages. + * 2) PTYPE2 packages contain a Variable-length number of subpackages. Each + * of the different types describe the contents of each of the subpackages. * * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types. Zero-length * parent package is allowed: @@ -106,6 +106,11 @@ * count = 0 (optional) * (Used for _DLM) * + * ACPI_PTYPE2_UUID_PAIR: Each subpackage is preceded by a UUID Buffer. The UUID + * defines the format of the package. Zero-length parent package is + * allowed. + * (Used for _DSD) + * *****************************************************************************/ enum AcpiReturnPackageTypes @@ -119,7 +124,8 @@ enum AcpiReturnPackageTypes ACPI_PTYPE2_FIXED = 7, ACPI_PTYPE2_MIN = 8, ACPI_PTYPE2_REV_FIXED = 9, - ACPI_PTYPE2_FIX_VAR = 10 + ACPI_PTYPE2_FIX_VAR = 10, + ACPI_PTYPE2_UUID_PAIR = 11 }; @@ -366,6 +372,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_CBA", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */ + {{"_CCA", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* ACPI 5.1 */ + {{"_CDM", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, @@ -434,6 +443,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_DOS", METHOD_1ARGS (ACPI_TYPE_INTEGER), METHOD_NO_RETURN_VALUE}}, + {{"_DSD", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Buf, 1 Pkg */ + PACKAGE_INFO (ACPI_PTYPE2_UUID_PAIR, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_PACKAGE, 1,0), + {{"_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 */ @@ -554,7 +567,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = /* * For _HPX, a single package is returned, containing a variable-length number - * of sub-packages. Each sub-package contains a PCI record setting. + * of subpackages. Each subpackage contains a PCI record setting. * There are several different type of record settings, of different * lengths, but all elements of all settings are Integers. */ @@ -580,6 +593,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_LID", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, + {{"_LPD", METHOD_0ARGS, + METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(rev), n Pkg (2 Int) */ + PACKAGE_INFO (ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_INTEGER, 2,0,0,0), + {{"_MAT", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, diff --git a/sys/contrib/dev/acpica/include/acresrc.h b/sys/contrib/dev/acpica/include/acresrc.h index b894e2f63776..5f7927450683 100644 --- a/sys/contrib/dev/acpica/include/acresrc.h +++ b/sys/contrib/dev/acpica/include/acresrc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -197,7 +197,7 @@ AcpiRsCreateResourceList ( ACPI_STATUS AcpiRsCreateAmlResources ( - ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *ResourceList, ACPI_BUFFER *OutputBuffer); ACPI_STATUS @@ -251,7 +251,8 @@ AcpiRsGetListLength ( ACPI_STATUS AcpiRsGetAmlLength ( - ACPI_RESOURCE *LinkedListBuffer, + ACPI_RESOURCE *ResourceList, + ACPI_SIZE ResourceListSize, ACPI_SIZE *SizeNeeded); ACPI_STATUS diff --git a/sys/contrib/dev/acpica/include/acrestyp.h b/sys/contrib/dev/acpica/include/acrestyp.h index 9d6982526b50..b0412aa63cca 100644 --- a/sys/contrib/dev/acpica/include/acrestyp.h +++ b/sys/contrib/dev/acpica/include/acrestyp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/acstruct.h b/sys/contrib/dev/acpica/include/acstruct.h index a6ba5eac4433..5a0baf4001b0 100644 --- a/sys/contrib/dev/acpica/include/acstruct.h +++ b/sys/contrib/dev/acpica/include/acstruct.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -139,6 +139,9 @@ typedef struct acpi_init_walk_info UINT32 TableIndex; UINT32 ObjectCount; UINT32 MethodCount; + UINT32 SerialMethodCount; + UINT32 NonSerialMethodCount; + UINT32 SerializedMethodCount; UINT32 DeviceCount; UINT32 OpRegionCount; UINT32 FieldCount; diff --git a/sys/contrib/dev/acpica/include/actables.h b/sys/contrib/dev/acpica/include/actables.h index 42958945bca4..2e3065865753 100644 --- a/sys/contrib/dev/acpica/include/actables.h +++ b/sys/contrib/dev/acpica/include/actables.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,10 @@ AcpiAllocateRootTable ( /* * tbxfroot - Root pointer utilities */ +UINT32 +AcpiTbGetRsdpLength ( + ACPI_TABLE_RSDP *Rsdp); + ACPI_STATUS AcpiTbValidateRsdp ( ACPI_TABLE_RSDP *Rsdp); @@ -62,6 +66,49 @@ AcpiTbScanMemoryForRsdp ( UINT32 Length); +/* + * tbdata - table data structure management + */ +ACPI_STATUS +AcpiTbGetNextRootIndex ( + UINT32 *TableIndex); + +void +AcpiTbInitTableDescriptor ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiTbAcquireTempTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags); + +void +AcpiTbReleaseTempTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiTbValidateTempTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiTbVerifyTempTable ( + ACPI_TABLE_DESC *TableDesc, + char *Signature); + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex); + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded); + + /* * tbfadt - FADT parse/convert/validate */ @@ -94,17 +141,36 @@ AcpiTbResizeRootTableList ( void); ACPI_STATUS -AcpiTbVerifyTable ( +AcpiTbValidateTable ( ACPI_TABLE_DESC *TableDesc); -ACPI_TABLE_HEADER * -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *TableHeader, +void +AcpiTbInvalidateTable ( ACPI_TABLE_DESC *TableDesc); +void +AcpiTbOverrideTable ( + ACPI_TABLE_DESC *OldTableDesc); + ACPI_STATUS -AcpiTbAddTable ( +AcpiTbAcquireTable ( ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength, + UINT8 *TableFlags); + +void +AcpiTbReleaseTable ( + ACPI_TABLE_HEADER *Table, + UINT32 TableLength, + UINT8 TableFlags); + +ACPI_STATUS +AcpiTbInstallStandardTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + BOOLEAN Reload, + BOOLEAN Override, UINT32 *TableIndex); ACPI_STATUS @@ -116,7 +182,7 @@ AcpiTbStoreTable ( UINT32 *TableIndex); void -AcpiTbDeleteTable ( +AcpiTbUninstallTable ( ACPI_TABLE_DESC *TableDesc); void @@ -140,15 +206,6 @@ AcpiTbGetOwnerId ( UINT32 TableIndex, ACPI_OWNER_ID *OwnerId); -BOOLEAN -AcpiTbIsTableLoaded ( - UINT32 TableIndex); - -void -AcpiTbSetTableLoadedFlag ( - UINT32 TableIndex, - BOOLEAN IsLoaded); - /* * tbutils - table manager utilities @@ -185,7 +242,13 @@ AcpiTbCopyDsdt ( UINT32 TableIndex); void -AcpiTbInstallTable ( +AcpiTbInstallTableWithOverride ( + UINT32 TableIndex, + ACPI_TABLE_DESC *NewTableDesc, + BOOLEAN Override); + +ACPI_STATUS +AcpiTbInstallFixedTable ( ACPI_PHYSICAL_ADDRESS Address, char *Signature, UINT32 TableIndex); diff --git a/sys/contrib/dev/acpica/include/actbl.h b/sys/contrib/dev/acpica/include/actbl.h index d77d6c4b3199..707511dc0093 100644 --- a/sys/contrib/dev/acpica/include/actbl.h +++ b/sys/contrib/dev/acpica/include/actbl.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,6 +203,9 @@ typedef struct acpi_table_xsdt } ACPI_TABLE_XSDT; +#define ACPI_RSDT_ENTRY_SIZE (sizeof (UINT32)) +#define ACPI_XSDT_ENTRY_SIZE (sizeof (UINT64)) + /******************************************************************************* * @@ -293,7 +296,8 @@ typedef struct acpi_table_fadt UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ - UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT16 ArmBootFlags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ + UINT8 MinorRevision; /* FADT Minor Revision (ACPI 5.1) */ UINT64 XFacs; /* 64-bit physical address of FACS */ UINT64 XDsdt; /* 64-bit physical address of DSDT */ ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ @@ -310,7 +314,7 @@ typedef struct acpi_table_fadt } ACPI_TABLE_FADT; -/* Masks for FADT Boot Architecture Flags (BootFlags) [Vx]=Introduced in this FADT revision */ +/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) [Vx]=Introduced in this FADT revision */ #define ACPI_FADT_LEGACY_DEVICES (1) /* 00: [V2] System has LPC or ISA bus devices */ #define ACPI_FADT_8042 (1<<1) /* 01: [V3] System has an 8042 controller on port 60/64 */ @@ -319,6 +323,11 @@ typedef struct acpi_table_fadt #define ACPI_FADT_NO_ASPM (1<<4) /* 04: [V4] PCIe ASPM control must not be enabled */ #define ACPI_FADT_NO_CMOS_RTC (1<<5) /* 05: [V5] No CMOS real-time clock present */ +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ + +#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ + /* Masks for FADT flags */ #define ACPI_FADT_WBINVD (1) /* 00: [V1] The WBINVD instruction works properly */ @@ -399,12 +408,11 @@ typedef struct acpi_table_desc /* Masks for Flags field above */ -#define ACPI_TABLE_ORIGIN_UNKNOWN (0) -#define ACPI_TABLE_ORIGIN_MAPPED (1) -#define ACPI_TABLE_ORIGIN_ALLOCATED (2) -#define ACPI_TABLE_ORIGIN_OVERRIDE (4) -#define ACPI_TABLE_ORIGIN_MASK (7) -#define ACPI_TABLE_IS_LOADED (8) +#define ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL (0) /* Virtual address, external maintained */ +#define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL (1) /* Physical address, internally mapped */ +#define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL (2) /* Virtual address, internallly allocated */ +#define ACPI_TABLE_ORIGIN_MASK (3) +#define ACPI_TABLE_IS_LOADED (8) /* @@ -433,7 +441,7 @@ typedef struct acpi_table_desc * FADT V5 size: 0x10C */ #define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) -#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (Reserved4[0]) + 3) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1) #define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) #define ACPI_FADT_V5_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) diff --git a/sys/contrib/dev/acpica/include/actbl1.h b/sys/contrib/dev/acpica/include/actbl1.h index 67579da49b83..a781056e1d54 100644 --- a/sys/contrib/dev/acpica/include/actbl1.h +++ b/sys/contrib/dev/acpica/include/actbl1.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -524,7 +524,7 @@ typedef struct acpi_hest_aer_common UINT8 Enabled; UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; - UINT32 Bus; + UINT32 Bus; /* Bus and Segment numbers */ UINT16 Device; UINT16 Function; UINT16 DeviceControl; @@ -541,6 +541,14 @@ typedef struct acpi_hest_aer_common #define ACPI_HEST_FIRMWARE_FIRST (1) #define ACPI_HEST_GLOBAL (1<<1) +/* + * Macros to access the bus/segment numbers in Bus field above: + * Bus number is encoded in bits 7:0 + * Segment number is encoded in bits 23:8 + */ +#define ACPI_HEST_BUS(Bus) ((Bus) & 0xFF) +#define ACPI_HEST_SEGMENT(Bus) (((Bus) >> 8) & 0xFFFF) + /* Hardware Error Notification */ @@ -754,25 +762,27 @@ typedef struct acpi_table_madt enum AcpiMadtType { - ACPI_MADT_TYPE_LOCAL_APIC = 0, - ACPI_MADT_TYPE_IO_APIC = 1, - ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, - ACPI_MADT_TYPE_NMI_SOURCE = 3, - ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, - ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, - ACPI_MADT_TYPE_IO_SAPIC = 6, - ACPI_MADT_TYPE_LOCAL_SAPIC = 7, - ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, - ACPI_MADT_TYPE_LOCAL_X2APIC = 9, - ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, - ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, - ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, - ACPI_MADT_TYPE_RESERVED = 13 /* 13 and greater are reserved */ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11, + ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12, + ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13, + ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14, + ACPI_MADT_TYPE_RESERVED = 15 /* 15 and greater are reserved */ }; /* - * MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + * MADT Subtables, correspond to Type in ACPI_SUBTABLE_HEADER */ /* 0: Processor Local APIC */ @@ -928,16 +938,27 @@ typedef struct acpi_madt_generic_interrupt { ACPI_SUBTABLE_HEADER Header; UINT16 Reserved; /* Reserved - must be zero */ - UINT32 GicId; + UINT32 CpuInterfaceNumber; UINT32 Uid; UINT32 Flags; UINT32 ParkingVersion; UINT32 PerformanceInterrupt; UINT64 ParkedAddress; UINT64 BaseAddress; + UINT64 GicvBaseAddress; + UINT64 GichBaseAddress; + UINT32 VgicInterrupt; + UINT64 GicrBaseAddress; + UINT64 ArmMpidr; } ACPI_MADT_GENERIC_INTERRUPT; +/* Masks for Flags field above */ + +/* ACPI_MADT_ENABLED (1) Processor is usable if set */ +#define ACPI_MADT_PERFORMANCE_IRQ_MODE (1<<1) /* 01: Performance Interrupt Mode */ +#define ACPI_MADT_VGIC_IRQ_MODE (1<<2) /* 02: VGIC Maintenance Interrupt mode */ + /* 12: Generic Distributor (ACPI 5.0) */ @@ -953,11 +974,42 @@ typedef struct acpi_madt_generic_distributor } ACPI_MADT_GENERIC_DISTRIBUTOR; +/* 13: Generic MSI Frame (ACPI 5.1) */ + +typedef struct acpi_madt_generic_msi_frame +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 MsiFrameId; + UINT64 BaseAddress; + UINT32 Flags; + UINT16 SpiCount; + UINT16 SpiBase; + +} ACPI_MADT_GENERIC_MSI_FRAME; + +/* Masks for Flags field above */ + +#define ACPI_MADT_OVERRIDE_SPI_VALUES (1) + + +/* 14: Generic Redistributor (ACPI 5.1) */ + +typedef struct acpi_madt_generic_redistributor +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* reserved - must be zero */ + UINT64 BaseAddress; + UINT32 Length; + +} ACPI_MADT_GENERIC_REDISTRIBUTOR; + + /* * Common flags fields for MADT subtables */ -/* MADT Local APIC flags (LapicFlags) and GIC flags */ +/* MADT Local APIC flags */ #define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ @@ -1066,11 +1118,12 @@ enum AcpiSratType ACPI_SRAT_TYPE_CPU_AFFINITY = 0, ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, - ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ + ACPI_SRAT_TYPE_GICC_AFFINITY = 3, + ACPI_SRAT_TYPE_RESERVED = 4 /* 4 and greater are reserved */ }; /* - * SRAT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + * SRAT Subtables, correspond to Type in ACPI_SUBTABLE_HEADER */ /* 0: Processor Local APIC/SAPIC Affinity */ @@ -1083,7 +1136,7 @@ typedef struct acpi_srat_cpu_affinity UINT32 Flags; UINT8 LocalSapicEid; UINT8 ProximityDomainHi[3]; - UINT32 Reserved; /* Reserved, must be zero */ + UINT32 ClockDomain; } ACPI_SRAT_CPU_AFFINITY; @@ -1133,6 +1186,22 @@ typedef struct acpi_srat_x2apic_cpu_affinity #define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ +/* 3: GICC Affinity (ACPI 5.1) */ + +typedef struct acpi_srat_gicc_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 ProximityDomain; + UINT32 AcpiProcessorUid; + UINT32 Flags; + UINT32 ClockDomain; + +} ACPI_SRAT_GICC_AFFINITY; + +/* Flags for ACPI_SRAT_GICC_AFFINITY */ + +#define ACPI_SRAT_GICC_ENABLED (1) /* 00: Use affinity structure */ + /* Reset to default packing */ #pragma pack() diff --git a/sys/contrib/dev/acpica/include/actbl2.h b/sys/contrib/dev/acpica/include/actbl2.h index 327a8105e6cb..a6f2f2081f64 100644 --- a/sys/contrib/dev/acpica/include/actbl2.h +++ b/sys/contrib/dev/acpica/include/actbl2.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,6 +72,7 @@ #define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ #define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */ #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ +#define ACPI_SIG_LPIT "LPIT" /* Low Power Idle Table */ #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Interface table */ #define ACPI_SIG_MTMR "MTMR" /* MID Timer table */ @@ -373,6 +374,14 @@ typedef struct acpi_table_dbg2 } ACPI_TABLE_DBG2; +typedef struct acpi_dbg2_header +{ + UINT32 InfoOffset; + UINT32 InfoCount; + +} ACPI_DBG2_HEADER; + + /* Debug Device Information Subtable */ typedef struct acpi_dbg2_device @@ -441,7 +450,7 @@ typedef struct acpi_table_dbgp * Version 1 * * Conforms to "Intel Virtualization Technology for Directed I/O", - * Version 1.2, Sept. 2008 + * Version 2.2, Sept. 2013 * ******************************************************************************/ @@ -474,9 +483,10 @@ enum AcpiDmarType { ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, - ACPI_DMAR_TYPE_ATSR = 2, - ACPI_DMAR_HARDWARE_AFFINITY = 3, - ACPI_DMAR_TYPE_RESERVED = 4 /* 4 and greater are reserved */ + ACPI_DMAR_TYPE_ROOT_ATS = 2, + ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3, + ACPI_DMAR_TYPE_NAMESPACE = 4, + ACPI_DMAR_TYPE_RESERVED = 5 /* 5 and greater are reserved */ }; @@ -492,7 +502,7 @@ typedef struct acpi_dmar_device_scope } ACPI_DMAR_DEVICE_SCOPE; -/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE - device types */ enum AcpiDmarScopeType { @@ -501,7 +511,8 @@ enum AcpiDmarScopeType ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, ACPI_DMAR_SCOPE_TYPE_HPET = 4, - ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ + ACPI_DMAR_SCOPE_TYPE_NAMESPACE = 5, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 6 /* 6 and greater are reserved */ }; typedef struct acpi_dmar_pci_path @@ -513,7 +524,7 @@ typedef struct acpi_dmar_pci_path /* - * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER + * DMAR Subtables, correspond to Type in ACPI_DMAR_HEADER */ /* 0: Hardware Unit Definition */ @@ -578,6 +589,18 @@ typedef struct acpi_dmar_rhsa } ACPI_DMAR_RHSA; +/* 4: ACPI Namespace Device Declaration Structure */ + +typedef struct acpi_dmar_andd +{ + ACPI_DMAR_HEADER Header; + UINT8 Reserved[3]; + UINT8 DeviceNumber; + char DeviceName[1]; + +} ACPI_DMAR_ANDD; + + /******************************************************************************* * * HPET - High Precision Event Timer table @@ -926,7 +949,83 @@ typedef struct acpi_ivrs_memory /******************************************************************************* * - * MCFG - PCI Memory Mapped Configuration table and sub-table + * LPIT - Low Power Idle Table + * + * Conforms to "ACPI Low Power Idle Table (LPIT) and _LPD Proposal (DRAFT)" + * + ******************************************************************************/ + +typedef struct acpi_table_lpit +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_LPIT; + + +/* LPIT subtable header */ + +typedef struct acpi_lpit_header +{ + UINT32 Type; /* Subtable type */ + UINT32 Length; /* Subtable length */ + UINT16 UniqueId; + UINT16 Reserved; + UINT32 Flags; + +} ACPI_LPIT_HEADER; + +/* Values for subtable Type above */ + +enum AcpiLpitType +{ + ACPI_LPIT_TYPE_NATIVE_CSTATE = 0x00, + ACPI_LPIT_TYPE_SIMPLE_IO = 0x01 +}; + +/* Masks for Flags field above */ + +#define ACPI_LPIT_STATE_DISABLED (1) +#define ACPI_LPIT_NO_COUNTER (1<<1) + +/* + * LPIT subtables, correspond to Type in ACPI_LPIT_HEADER + */ + +/* 0x00: Native C-state instruction based LPI structure */ + +typedef struct acpi_lpit_native +{ + ACPI_LPIT_HEADER Header; + ACPI_GENERIC_ADDRESS EntryTrigger; + UINT32 Residency; + UINT32 Latency; + ACPI_GENERIC_ADDRESS ResidencyCounter; + UINT64 CounterFrequency; + +} ACPI_LPIT_NATIVE; + + +/* 0x01: Simple I/O based LPI structure */ + +typedef struct acpi_lpit_io +{ + ACPI_LPIT_HEADER Header; + ACPI_GENERIC_ADDRESS EntryTrigger; + UINT32 TriggerAction; + UINT64 TriggerValue; + UINT64 TriggerMask; + ACPI_GENERIC_ADDRESS MinimumIdleState; + UINT32 Residency; + UINT32 Latency; + ACPI_GENERIC_ADDRESS ResidencyCounter; + UINT64 CounterFrequency; + +} ACPI_LPIT_IO; + + +/******************************************************************************* + * + * MCFG - PCI Memory Mapped Configuration table and subtable * Version 1 * * Conforms to "PCI Firmware Specification", Revision 3.0, June 20, 2005 @@ -1050,7 +1149,7 @@ enum AcpiSlicType /* - * SLIC Sub-tables, correspond to Type in ACPI_SLIC_HEADER + * SLIC Subtables, correspond to Type in ACPI_SLIC_HEADER */ /* 0: Public Key Structure */ diff --git a/sys/contrib/dev/acpica/include/actbl3.h b/sys/contrib/dev/acpica/include/actbl3.h index acf2e13560d0..2f98b37203a9 100644 --- a/sys/contrib/dev/acpica/include/actbl3.h +++ b/sys/contrib/dev/acpica/include/actbl3.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -280,35 +280,115 @@ typedef struct acpi_s3pt_suspend /******************************************************************************* * - * GTDT - Generic Timer Description Table (ACPI 5.0) - * Version 1 + * GTDT - Generic Timer Description Table (ACPI 5.1) + * Version 2 * ******************************************************************************/ typedef struct acpi_table_gtdt { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ - UINT64 Address; - UINT32 Flags; - UINT32 SecurePl1Interrupt; - UINT32 SecurePl1Flags; - UINT32 NonSecurePl1Interrupt; - UINT32 NonSecurePl1Flags; + UINT64 CounterBlockAddresss; + UINT32 Reserved; + UINT32 SecureEl1Interrupt; + UINT32 SecureEl1Flags; + UINT32 NonSecureEl1Interrupt; + UINT32 NonSecureEl1Flags; UINT32 VirtualTimerInterrupt; UINT32 VirtualTimerFlags; - UINT32 NonSecurePl2Interrupt; - UINT32 NonSecurePl2Flags; + UINT32 NonSecureEl2Interrupt; + UINT32 NonSecureEl2Flags; + UINT64 CounterReadBlockAddress; + UINT32 PlatformTimerCount; + UINT32 PlatformTimerOffset; } ACPI_TABLE_GTDT; -/* Values for Flags field above */ +/* Flag Definitions: Timer Block Physical Timers and Virtual timers */ -#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 +#define ACPI_GTDT_INTERRUPT_MODE (1) +#define ACPI_GTDT_INTERRUPT_POLARITY (1<<1) +#define ACPI_GTDT_ALWAYS_ON (1<<2) -/* Values for all "TimerFlags" fields above */ -#define ACPI_GTDT_INTERRUPT_MODE 1 -#define ACPI_GTDT_INTERRUPT_POLARITY 2 +/* Common GTDT subtable header */ + +typedef struct acpi_gtdt_header +{ + UINT8 Type; + UINT16 Length; + +} ACPI_GTDT_HEADER; + +/* Values for GTDT subtable type above */ + +enum AcpiGtdtType +{ + ACPI_GTDT_TYPE_TIMER_BLOCK = 0, + ACPI_GTDT_TYPE_WATCHDOG = 1, + ACPI_GTDT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ +}; + + +/* GTDT Subtables, correspond to Type in acpi_gtdt_header */ + +/* 0: Generic Timer Block */ + +typedef struct acpi_gtdt_timer_block +{ + ACPI_GTDT_HEADER Header; + UINT8 Reserved; + UINT64 BlockAddress; + UINT32 TimerCount; + UINT32 TimerOffset; + +} ACPI_GTDT_TIMER_BLOCK; + +/* Timer Sub-Structure, one per timer */ + +typedef struct acpi_gtdt_timer_entry +{ + UINT8 FrameNumber; + UINT8 Reserved[3]; + UINT64 BaseAddress; + UINT64 El0BaseAddress; + UINT32 TimerInterrupt; + UINT32 TimerFlags; + UINT32 VirtualTimerInterrupt; + UINT32 VirtualTimerFlags; + UINT32 CommonFlags; + +} ACPI_GTDT_TIMER_ENTRY; + +/* Flag Definitions: TimerFlags and VirtualTimerFlags above */ + +#define ACPI_GTDT_GT_IRQ_MODE (1) +#define ACPI_GTDT_GT_IRQ_POLARITY (1<<1) + +/* Flag Definitions: CommonFlags above */ + +#define ACPI_GTDT_GT_IS_SECURE_TIMER (1) +#define ACPI_GTDT_GT_ALWAYS_ON (1<<1) + + +/* 1: SBSA Generic Watchdog Structure */ + +typedef struct acpi_gtdt_watchdog +{ + ACPI_GTDT_HEADER Header; + UINT8 Reserved; + UINT64 RefreshFrameAddress; + UINT64 ControlFrameAddress; + UINT32 TimerInterrupt; + UINT32 TimerFlags; + +} ACPI_GTDT_WATCHDOG; + +/* Flag Definitions: TimerFlags above */ + +#define ACPI_GTDT_WATCHDOG_IRQ_MODE (1) +#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY (1<<1) +#define ACPI_GTDT_WATCHDOG_SECURE (1<<2) /******************************************************************************* @@ -440,8 +520,7 @@ typedef struct acpi_table_pcct { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ UINT32 Flags; - UINT32 Latency; - UINT32 Reserved; + UINT64 Reserved; } ACPI_TABLE_PCCT; @@ -449,8 +528,17 @@ typedef struct acpi_table_pcct #define ACPI_PCCT_DOORBELL 1 +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiPcctType +{ + ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE = 1, + ACPI_PCCT_TYPE_RESERVED = 2 /* 2 and greater are reserved */ +}; + /* - * PCCT subtables + * PCCT Subtables, correspond to Type in ACPI_SUBTABLE_HEADER */ /* 0: Generic Communications Subspace */ @@ -464,10 +552,38 @@ typedef struct acpi_pcct_subspace ACPI_GENERIC_ADDRESS DoorbellRegister; UINT64 PreserveMask; UINT64 WriteMask; + UINT32 Latency; + UINT32 MaxAccessRate; + UINT16 MinTurnaroundTime; } ACPI_PCCT_SUBSPACE; +/* 1: HW-reduced Communications Subspace (ACPI 5.1) */ + +typedef struct acpi_pcct_hw_reduced +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 DoorbellInterrupt; + UINT8 Flags; + UINT8 Reserved; + UINT64 BaseAddress; + UINT64 Length; + ACPI_GENERIC_ADDRESS DoorbellRegister; + UINT64 PreserveMask; + UINT64 WriteMask; + UINT32 Latency; + UINT32 MaxAccessRate; + UINT16 MinTurnaroundTime; + +} ACPI_PCCT_HW_REDUCED; + +/* Values for doorbell flags above */ + +#define ACPI_PCCT_INTERRUPT_POLARITY (1) +#define ACPI_PCCT_INTERRUPT_MODE (1<<1) + + /* * PCC memory structures (not part of the ACPI table) */ diff --git a/sys/contrib/dev/acpica/include/actypes.h b/sys/contrib/dev/acpica/include/actypes.h index dafbfd53a62b..0444f5e14e12 100644 --- a/sys/contrib/dev/acpica/include/actypes.h +++ b/sys/contrib/dev/acpica/include/actypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,8 +55,6 @@ #error ACPI_MACHINE_WIDTH not defined #endif -/*! [Begin] no source code translation */ - /* * Data type ranges * Note: These macros are designed to be compiler independent as well as @@ -124,13 +122,16 @@ * ******************************************************************************/ +#ifndef ACPI_USE_SYSTEM_INTTYPES + typedef unsigned char BOOLEAN; typedef unsigned char UINT8; typedef unsigned short UINT16; +typedef short INT16; typedef COMPILER_DEPENDENT_UINT64 UINT64; typedef COMPILER_DEPENDENT_INT64 INT64; -/*! [End] no source code translation !*/ +#endif /* ACPI_USE_SYSTEM_INTTYPES */ /* * Value returned by AcpiOsGetThreadId. There is no standard "thread_id" @@ -151,12 +152,12 @@ typedef COMPILER_DEPENDENT_INT64 INT64; #if ACPI_MACHINE_WIDTH == 64 -/*! [Begin] no source code translation (keep the typedefs as-is) */ +#ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int UINT32; typedef int INT32; -/*! [End] no source code translation !*/ +#endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef INT64 ACPI_NATIVE_INT; @@ -190,12 +191,12 @@ typedef UINT64 ACPI_PHYSICAL_ADDRESS; #elif ACPI_MACHINE_WIDTH == 32 -/*! [Begin] no source code translation (keep the typedefs as-is) */ +#ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int UINT32; typedef int INT32; -/*! [End] no source code translation !*/ +#endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef INT32 ACPI_NATIVE_INT; @@ -303,9 +304,18 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; #endif /* - * All ACPICA functions that are available to the rest of the kernel are - * tagged with this macro which can be defined as appropriate for the host. + * All ACPICA external functions that are available to the rest of the kernel + * are tagged with thes macros which can be defined as appropriate for the host. + * + * Notes: + * ACPI_EXPORT_SYMBOL_INIT is used for initialization and termination + * interfaces that may need special processing. + * ACPI_EXPORT_SYMBOL is used for all other public external functions. */ +#ifndef ACPI_EXPORT_SYMBOL_INIT +#define ACPI_EXPORT_SYMBOL_INIT(Symbol) +#endif + #ifndef ACPI_EXPORT_SYMBOL #define ACPI_EXPORT_SYMBOL(Symbol) #endif @@ -319,6 +329,45 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; #endif +/******************************************************************************* + * + * Configuration + * + ******************************************************************************/ + +#ifdef ACPI_NO_MEM_ALLOCATIONS + +#define ACPI_ALLOCATE(a) NULL +#define ACPI_ALLOCATE_ZEROED(a) NULL +#define ACPI_FREE(a) +#define ACPI_MEM_TRACKING(a) + +#else /* ACPI_NO_MEM_ALLOCATIONS */ + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +/* + * Memory allocation tracking (used by AcpiExec to detect memory leaks) + */ +#define ACPI_MEM_PARAMETERS _COMPONENT, _AcpiModuleName, __LINE__ +#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 + +#else +/* + * Normal memory allocation directly via the OS services layer + */ +#define ACPI_ALLOCATE(a) AcpiOsAllocate ((ACPI_SIZE) (a)) +#define ACPI_ALLOCATE_ZEROED(a) AcpiOsAllocateZeroed ((ACPI_SIZE) (a)) +#define ACPI_FREE(a) AcpiOsFree (a) +#define ACPI_MEM_TRACKING(a) + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + +#endif /* ACPI_NO_MEM_ALLOCATIONS */ + + /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification changes) @@ -335,6 +384,7 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS; #define ACPI_PM1_REGISTER_WIDTH 16 #define ACPI_PM2_REGISTER_WIDTH 8 #define ACPI_PM_TIMER_WIDTH 32 +#define ACPI_RESET_REGISTER_WIDTH 8 /* Names within the namespace are 4 bytes long */ @@ -474,7 +524,7 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) -#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) NULL) #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) @@ -568,8 +618,9 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_RESERVED (UINT8) 0x0A #define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B #define ACPI_NOTIFY_SHUTDOWN_REQUEST (UINT8) 0x0C +#define ACPI_NOTIFY_AFFINITY_UPDATE (UINT8) 0x0D -#define ACPI_NOTIFY_MAX 0x0C +#define ACPI_NOTIFY_MAX 0x0D /* * Types associated with ACPI names and objects. The first group of @@ -669,14 +720,15 @@ typedef UINT32 ACPI_EVENT_TYPE; * The encoding of ACPI_EVENT_STATUS is illustrated below. * Note that a set bit (1) indicates the property is TRUE * (e.g. if bit 0 is set then the event is enabled). - * +-------------+-+-+-+ - * | Bits 31:3 |2|1|0| - * +-------------+-+-+-+ - * | | | | - * | | | +- Enabled? - * | | +--- Enabled for wake? - * | +----- Set? - * +----------- + * +-------------+-+-+-+-+ + * | Bits 31:4 |3|2|1|0| + * +-------------+-+-+-+-+ + * | | | | | + * | | | | +- Enabled? + * | | | +--- Enabled for wake? + * | | +----- Set? + * | +------- Has a handler? + * +------------- */ typedef UINT32 ACPI_EVENT_STATUS; @@ -684,6 +736,7 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 #define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 #define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x04 +#define ACPI_EVENT_FLAG_HAS_HANDLER (ACPI_EVENT_STATUS) 0x08 /* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */ @@ -916,8 +969,18 @@ typedef struct acpi_object_list * Miscellaneous common Data Structures used by the interfaces */ #define ACPI_NO_BUFFER 0 -#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) -#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) + +#ifdef ACPI_NO_MEM_ALLOCATIONS + +#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (0) +#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (0) + +#else /* ACPI_NO_MEM_ALLOCATIONS */ + +#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) /* Let ACPICA allocate buffer */ +#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) /* For internal use only (enables tracking) */ + +#endif /* ACPI_NO_MEM_ALLOCATIONS */ typedef struct acpi_buffer { @@ -926,10 +989,6 @@ typedef struct acpi_buffer } ACPI_BUFFER; -/* Free a buffer created in an ACPI_BUFFER via ACPI_ALLOCATE_LOCAL_BUFFER */ - -#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.Pointer) - /* * NameType for AcpiGetName @@ -1281,4 +1340,19 @@ typedef struct acpi_memory_list #define ACPI_OSI_WIN_8 0x0C +/* Definitions of file IO */ + +#define ACPI_FILE_READING 0x01 +#define ACPI_FILE_WRITING 0x02 +#define ACPI_FILE_BINARY 0x04 + +#define ACPI_FILE_BEGIN 0x01 +#define ACPI_FILE_END 0x02 + + +/* Definitions of getopt */ + +#define ACPI_OPT_END -1 + + #endif /* __ACTYPES_H__ */ diff --git a/sys/contrib/dev/acpica/include/acutils.h b/sys/contrib/dev/acpica/include/acutils.h index c80dd36ca4f6..8031fd3734de 100644 --- a/sys/contrib/dev/acpica/include/acutils.h +++ b/sys/contrib/dev/acpica/include/acutils.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,7 @@ extern const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[]; /* Strings used by the disassembler and debugger resource dump routines */ -#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) +#if defined(ACPI_DEBUG_OUTPUT) || defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) extern const char *AcpiGbl_BmDecode[]; extern const char *AcpiGbl_ConfigDecode[]; @@ -96,7 +96,6 @@ extern const char *AcpiGbl_PtDecode[]; #ifdef ACPI_ASL_COMPILER #include -extern FILE *AcpiGbl_OutputFile; #define ACPI_MSG_REDIRECT_BEGIN \ FILE *OutputFile = AcpiGbl_OutputFile; \ @@ -189,8 +188,8 @@ AcpiUtGetMutexName ( const char * AcpiUtGetNotifyName ( - UINT32 NotifyValue); - + UINT32 NotifyValue, + ACPI_OBJECT_TYPE Type); #endif char * @@ -226,6 +225,10 @@ AcpiUtHexToAsciiChar ( UINT64 Integer, UINT32 Position); +UINT8 +AcpiUtAsciiCharToHex ( + int HexChar); + BOOLEAN AcpiUtValidObjectType ( ACPI_OBJECT_TYPE Type); @@ -252,6 +255,11 @@ ACPI_SIZE AcpiUtStrlen ( const char *String); +char * +AcpiUtStrchr ( + const char *String, + int ch); + char * AcpiUtStrcpy ( char *DstString, @@ -340,7 +348,7 @@ extern const UINT8 _acpi_ctype[]; #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_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU)) #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) #endif /* !ACPI_USE_SYSTEM_CLIBRARY */ @@ -482,6 +490,16 @@ AcpiUtDumpBuffer ( UINT32 Display, UINT32 Offset); +#ifdef ACPI_APPLICATION +void +AcpiUtDumpBufferToFile ( + ACPI_FILE File, + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 BaseOffset); +#endif + void AcpiUtReportError ( char *ModuleName, @@ -550,6 +568,17 @@ AcpiUtExecutePowerMethods ( UINT8 *OutValues); +/* + * utfileio - file operations + */ +#ifdef ACPI_APPLICATION +ACPI_STATUS +AcpiUtReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); +#endif + + /* * utids - device ID support */ @@ -926,6 +955,29 @@ void AcpiUtRepairName ( char *Name); +#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) +BOOLEAN +AcpiUtSafeStrcpy ( + char *Dest, + ACPI_SIZE DestSize, + char *Source); + +BOOLEAN +AcpiUtSafeStrcat ( + char *Dest, + ACPI_SIZE DestSize, + char *Source); + +#ifndef _KERNEL +BOOLEAN +AcpiUtSafeStrncat ( + char *Dest, + ACPI_SIZE DestSize, + char *Source, + ACPI_SIZE MaxTransferLength); +#endif +#endif + /* * utmutex - mutex support @@ -967,20 +1019,6 @@ 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 ( @@ -1092,4 +1130,68 @@ AcpiUtMethodError ( const char *Path, ACPI_STATUS LookupStatus); +/* + * Utility functions for ACPI names and IDs + */ +const AH_PREDEFINED_NAME * +AcpiAhMatchPredefinedName ( + char *Nameseg); + +const AH_DEVICE_ID * +AcpiAhMatchHardwareId ( + char *Hid); + +const char * +AcpiAhMatchUuid ( + UINT8 *Data); + +/* + * utprint - printf/vprintf output functions + */ +const char * +AcpiUtScanNumber ( + const char *String, + UINT64 *NumberPtr); + +const char * +AcpiUtPrintNumber ( + char *String, + UINT64 Number); + +int +AcpiUtVsnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + va_list Args); + +int +AcpiUtSnprintf ( + char *String, + ACPI_SIZE Size, + const char *Format, + ...); + +#ifdef ACPI_APPLICATION +int +AcpiUtFileVprintf ( + ACPI_FILE File, + const char *Format, + va_list Args); + +int +AcpiUtFilePrintf ( + ACPI_FILE File, + const char *Format, + ...); +#endif + +/* + * utuuid -- UUID support functions + */ +void +AcpiUtConvertStringToUuid ( + char *InString, + UINT8 *UuidBuffer); + #endif /* _ACUTILS_H */ diff --git a/sys/contrib/dev/acpica/include/amlcode.h b/sys/contrib/dev/acpica/include/amlcode.h index 66af4c2507d5..bc8c0b0d3dd0 100644 --- a/sys/contrib/dev/acpica/include/amlcode.h +++ b/sys/contrib/dev/acpica/include/amlcode.h @@ -7,7 +7,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/amlresrc.h b/sys/contrib/dev/acpica/include/amlresrc.h index 8e68559064f2..cd8b3b638c9e 100644 --- a/sys/contrib/dev/acpica/include/amlresrc.h +++ b/sys/contrib/dev/acpica/include/amlresrc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -122,6 +122,14 @@ typedef struct asl_resource_node } ASL_RESOURCE_NODE; +typedef struct asl_resource_info +{ + ACPI_PARSE_OBJECT *DescriptorTypeOp; /* Resource descriptor parse node */ + ACPI_PARSE_OBJECT *MappingOp; /* Used for mapfile support */ + UINT32 CurrentByteOffset; /* Offset in resource template */ + +} ASL_RESOURCE_INFO; + /* Macros used to generate AML resource length fields */ @@ -574,4 +582,50 @@ typedef union aml_resource } AML_RESOURCE; + +/* Interfaces used by both the disassembler and compiler */ + +void +MpSaveGpioInfo ( + ACPI_PARSE_OBJECT *Op, + AML_RESOURCE *Resource, + UINT32 PinCount, + UINT16 *PinList, + char *DeviceName); + +void +MpSaveSerialInfo ( + ACPI_PARSE_OBJECT *Op, + AML_RESOURCE *Resource, + char *DeviceName); + +char * +MpGetHidFromParseTree ( + ACPI_NAMESPACE_NODE *HidNode); + +char * +MpGetHidViaNamestring ( + char *DeviceName); + +char * +MpGetConnectionInfo ( + ACPI_PARSE_OBJECT *Op, + UINT32 PinIndex, + ACPI_NAMESPACE_NODE **TargetNode, + char **TargetName); + +char * +MpGetParentDeviceHid ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE **TargetNode, + char **ParentDeviceName); + +char * +MpGetDdnValue ( + char *DeviceName); + +char * +MpGetHidValue ( + ACPI_NAMESPACE_NODE *DeviceNode); + #endif diff --git a/sys/contrib/dev/acpica/include/platform/acenv.h b/sys/contrib/dev/acpica/include/platform/acenv.h index 6866de26d9f8..8b8e890d0bcb 100644 --- a/sys/contrib/dev/acpica/include/platform/acenv.h +++ b/sys/contrib/dev/acpica/include/platform/acenv.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,32 +88,55 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif -/* AcpiNames configuration. Single threaded with debugger output enabled. */ - -#ifdef ACPI_NAMES_APP -#define ACPI_DEBUGGER -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED -#endif - /* - * AcpiBin/AcpiDump/AcpiSrc/AcpiXtract configuration. All single - * threaded, with no debug output. + * AcpiBin/AcpiDump/AcpiHelp/AcpiNames/AcpiSrc/AcpiXtract/Example configuration. + * All single threaded. */ -#if (defined ACPI_BIN_APP) || \ - (defined ACPI_DUMP_APP) || \ - (defined ACPI_SRC_APP) || \ - (defined ACPI_XTRACT_APP) +#if (defined ACPI_BIN_APP) || \ + (defined ACPI_DUMP_APP) || \ + (defined ACPI_HELP_APP) || \ + (defined ACPI_NAMES_APP) || \ + (defined ACPI_SRC_APP) || \ + (defined ACPI_XTRACT_APP) || \ + (defined ACPI_EXAMPLE_APP) #define ACPI_APPLICATION #define ACPI_SINGLE_THREADED #endif +/* AcpiHelp configuration. Error messages disabled. */ + #ifdef ACPI_HELP_APP -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED #define ACPI_NO_ERROR_MESSAGES #endif +/* AcpiNames configuration. Debug output enabled. */ + +#ifdef ACPI_NAMES_APP +#define ACPI_DEBUG_OUTPUT +#endif + +/* AcpiExec/AcpiNames/Example configuration. Native RSDP used. */ + +#if (defined ACPI_EXEC_APP) || \ + (defined ACPI_EXAMPLE_APP) || \ + (defined ACPI_NAMES_APP) +#define ACPI_USE_NATIVE_RSDP_POINTER +#endif + +/* AcpiDump configuration. Native mapping used if provied by OSPMs */ + +#ifdef ACPI_DUMP_APP +#define ACPI_USE_NATIVE_MEMORY_MAPPING +#define USE_NATIVE_ALLOCATE_ZEROED +#endif + +/* AcpiNames/Example configuration. Hardware disabled */ + +#if (defined ACPI_EXAMPLE_APP) || \ + (defined ACPI_NAMES_APP) +#define ACPI_REDUCED_HARDWARE 1 +#endif + /* Linkable ACPICA library */ #ifdef ACPI_LIBRARY @@ -184,6 +207,9 @@ #elif defined(_AED_EFI) #include "acefi.h" +#elif defined(_GNU_EFI) +#include "acefi.h" + #elif defined(__HAIKU__) #include "achaiku.h" @@ -396,4 +422,17 @@ typedef char *va_list; #endif /* ACPI_USE_SYSTEM_CLIBRARY */ +#ifndef ACPI_FILE +#ifdef ACPI_APPLICATION +#include +#define ACPI_FILE FILE * +#define ACPI_FILE_OUT stdout +#define ACPI_FILE_ERR stderr +#else +#define ACPI_FILE void * +#define ACPI_FILE_OUT NULL +#define ACPI_FILE_ERR NULL +#endif /* ACPI_APPLICATION */ +#endif /* ACPI_FILE */ + #endif /* __ACENV_H__ */ diff --git a/sys/contrib/dev/acpica/include/platform/acenvex.h b/sys/contrib/dev/acpica/include/platform/acenvex.h new file mode 100644 index 000000000000..a1de87ffee25 --- /dev/null +++ b/sys/contrib/dev/acpica/include/platform/acenvex.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * + * Name: acenvex.h - Extra host and compiler configuration + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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 __ACENVEX_H__ +#define __ACENVEX_H__ + +/*! [Begin] no source code translation */ + +/****************************************************************************** + * + * Extra host configuration files. All ACPICA headers are included before + * including these files. + * + *****************************************************************************/ + +#if defined(_LINUX) || defined(__linux__) +#include "aclinuxex.h" + +#endif + +/*! [End] no source code translation !*/ + +#endif /* __ACENVEX_H__ */ diff --git a/sys/contrib/dev/acpica/include/platform/acfreebsd.h b/sys/contrib/dev/acpica/include/platform/acfreebsd.h index 34786c32e235..ab4dc9830fcd 100644 --- a/sys/contrib/dev/acpica/include/platform/acfreebsd.h +++ b/sys/contrib/dev/acpica/include/platform/acfreebsd.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/contrib/dev/acpica/include/platform/acgcc.h b/sys/contrib/dev/acpica/include/platform/acgcc.h index 1662a9bb81c7..23db3248f520 100644 --- a/sys/contrib/dev/acpica/include/platform/acgcc.h +++ b/sys/contrib/dev/acpica/include/platform/acgcc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ /* Function name is used for debug output. Non-ANSI, compiler-dependent */ -#define ACPI_GET_FUNCTION_NAME __FUNCTION__ +#define ACPI_GET_FUNCTION_NAME __func__ /* * This macro is used to tag functions as "printf-like" because @@ -64,4 +64,15 @@ */ #define ACPI_UNUSED_VAR __attribute__ ((unused)) +/* + * Some versions of gcc implement strchr() with a buggy macro. So, + * undef it here. Prevents error messages of this form (usually from the + * file getopt.c): + * + * error: logical '&&' with non-zero constant will always evaluate as true + */ +#ifdef strchr +#undef strchr +#endif + #endif /* __ACGCC_H__ */ diff --git a/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c b/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c new file mode 100644 index 000000000000..9f55cc7d9009 --- /dev/null +++ b/sys/contrib/dev/acpica/os_specific/service_layers/oslibcfs.c @@ -0,0 +1,255 @@ +/****************************************************************************** + * + * Module Name: oslibcfs - C library OSL for file I/O + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (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_OS_SERVICES + ACPI_MODULE_NAME ("oslibcfs") + + +/******************************************************************************* + * + * FUNCTION: AcpiOsOpenFile + * + * PARAMETERS: Path - File path + * Modes - File operation type + * + * RETURN: File descriptor. + * + * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing + * (ACPI_FILE_WRITING). + * + ******************************************************************************/ + +ACPI_FILE +AcpiOsOpenFile ( + const char *Path, + UINT8 Modes) +{ + ACPI_FILE File; + UINT32 i = 0; + char ModesStr[4]; + + + if (Modes & ACPI_FILE_READING) + { + ModesStr[i++] = 'r'; + } + if (Modes & ACPI_FILE_WRITING) + { + ModesStr[i++] = 'w'; + } + if (Modes & ACPI_FILE_BINARY) + { + ModesStr[i++] = 'b'; + } + + ModesStr[i++] = '\0'; + + File = fopen (Path, ModesStr); + if (!File) + { + perror ("Could not open file"); + } + + return (File); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsCloseFile + * + * PARAMETERS: File - An open file descriptor + * + * RETURN: None. + * + * DESCRIPTION: Close a file opened via AcpiOsOpenFile. + * + ******************************************************************************/ + +void +AcpiOsCloseFile ( + ACPI_FILE File) +{ + fclose (File); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReadFile + * + * PARAMETERS: File - An open file descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * + * RETURN: Number of bytes actually read. + * + * DESCRIPTION: Read from a file. + * + ******************************************************************************/ + +int +AcpiOsReadFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) +{ + int Length; + + + Length = fread (Buffer, Size, Count, File); + if (Length < 0) + { + perror ("Error reading file"); + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsWriteFile + * + * PARAMETERS: File - An open file descriptor + * Buffer - Data buffer + * Size - Data block size + * Count - Number of data blocks + * + * RETURN: Number of bytes actually written. + * + * DESCRIPTION: Write to a file. + * + ******************************************************************************/ + +int +AcpiOsWriteFile ( + ACPI_FILE File, + void *Buffer, + ACPI_SIZE Size, + ACPI_SIZE Count) +{ + int Length; + + + Length = fwrite (Buffer, Size, Count, File); + if (Length < 0) + { + perror ("Error writing file"); + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsGetFileOffset + * + * PARAMETERS: File - An open file descriptor + * + * RETURN: Current file pointer position. + * + * DESCRIPTION: Get current file offset. + * + ******************************************************************************/ + +long +AcpiOsGetFileOffset ( + ACPI_FILE File) +{ + long Offset; + + + Offset = ftell (File); + return (Offset); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsSetFileOffset + * + * PARAMETERS: File - An open file descriptor + * Offset - New file offset + * From - From begin/end of file + * + * RETURN: Status + * + * DESCRIPTION: Set current file offset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsSetFileOffset ( + ACPI_FILE File, + long Offset, + UINT8 From) +{ + int Ret = 0; + + + if (From == ACPI_FILE_BEGIN) + { + Ret = fseek (File, Offset, SEEK_SET); + } + if (From == ACPI_FILE_END) + { + Ret = fseek (File, Offset, SEEK_END); + } + + if (Ret < 0) + { + return (AE_ERROR); + } + else + { + return (AE_OK); + } +} diff --git a/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c b/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c index 31bb471bb7b0..d4febe283b2c 100644 --- a/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c +++ b/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2013, Intel Corp. + * Copyright (C) 2000 - 2014, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - /* * These interfaces are required in order to compile the ASL compiler and the * various ACPICA tools under Linux or other Unix-like system. @@ -65,16 +64,11 @@ ACPI_MODULE_NAME ("osunixxf") -extern FILE *AcpiGbl_DebugFile; -FILE *AcpiGbl_OutputFile; +BOOLEAN AcpiGbl_DebugTimeout = FALSE; /* Upcalls to AcpiExec */ -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void); - void AeTableOverride ( ACPI_TABLE_HEADER *ExistingTable, @@ -84,7 +78,127 @@ typedef void* (*PTHREAD_CALLBACK) (void *); /* Buffer used by AcpiOsVprintf */ -#define ACPI_VPRINTF_BUFFER_SIZE 512 +#define ACPI_VPRINTF_BUFFER_SIZE 512 +#define _ASCII_NEWLINE '\n' + +/* Terminal support for AcpiExec only */ + +#ifdef ACPI_EXEC_APP +#include + +struct termios OriginalTermAttributes; +int TermAttributesWereSet = 0; + +ACPI_STATUS +AcpiUtReadLine ( + char *Buffer, + UINT32 BufferLength, + UINT32 *BytesRead); + +static void +OsEnterLineEditMode ( + void); + +static void +OsExitLineEditMode ( + void); + + +/****************************************************************************** + * + * FUNCTION: OsEnterLineEditMode, OsExitLineEditMode + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Enter/Exit the raw character input mode for the terminal. + * + * Interactive line-editing support for the AML debugger. Used with the + * common/acgetline module. + * + * readline() is not used because of non-portability. It is not available + * on all systems, and if it is, often the package must be manually installed. + * + * Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line + * editing that we need in AcpiOsGetLine. + * + * If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these + * calls will also work: + * For OsEnterLineEditMode: system ("stty cbreak -echo") + * For OsExitLineEditMode: system ("stty cooked echo") + * + *****************************************************************************/ + +static void +OsEnterLineEditMode ( + void) +{ + struct termios LocalTermAttributes; + + + TermAttributesWereSet = 0; + + /* STDIN must be a terminal */ + + if (!isatty (STDIN_FILENO)) + { + return; + } + + /* Get and keep the original attributes */ + + if (tcgetattr (STDIN_FILENO, &OriginalTermAttributes)) + { + fprintf (stderr, "Could not get terminal attributes!\n"); + return; + } + + /* Set the new attributes to enable raw character input */ + + memcpy (&LocalTermAttributes, &OriginalTermAttributes, + sizeof (struct termios)); + + LocalTermAttributes.c_lflag &= ~(ICANON | ECHO); + LocalTermAttributes.c_cc[VMIN] = 1; + LocalTermAttributes.c_cc[VTIME] = 0; + + if (tcsetattr (STDIN_FILENO, TCSANOW, &LocalTermAttributes)) + { + fprintf (stderr, "Could not set terminal attributes!\n"); + return; + } + + TermAttributesWereSet = 1; +} + + +static void +OsExitLineEditMode ( + void) +{ + + if (!TermAttributesWereSet) + { + return; + } + + /* Set terminal attributes back to the original values */ + + if (tcsetattr (STDIN_FILENO, TCSANOW, &OriginalTermAttributes)) + { + fprintf (stderr, "Could not restore terminal attributes!\n"); + } +} + + +#else + +/* These functions are not needed for other ACPICA utilities */ + +#define OsEnterLineEditMode() +#define OsExitLineEditMode() +#endif /****************************************************************************** @@ -95,7 +209,7 @@ typedef void* (*PTHREAD_CALLBACK) (void *); * * RETURN: Status * - * DESCRIPTION: Init and terminate. Nothing to do. + * DESCRIPTION: Initialize and terminate this module. * *****************************************************************************/ @@ -103,21 +217,33 @@ ACPI_STATUS AcpiOsInitialize ( void) { + ACPI_STATUS Status; + AcpiGbl_OutputFile = stdout; + + OsEnterLineEditMode (); + + Status = AcpiOsCreateLock (&AcpiGbl_PrintLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + return (AE_OK); } - ACPI_STATUS AcpiOsTerminate ( void) { + OsExitLineEditMode (); return (AE_OK); } +#ifndef ACPI_USE_NATIVE_RSDP_POINTER /****************************************************************************** * * FUNCTION: AcpiOsGetRootPointer @@ -135,8 +261,9 @@ AcpiOsGetRootPointer ( void) { - return (AeLocalGetRootPointer ()); + return (0); } +#endif /****************************************************************************** @@ -370,6 +497,7 @@ AcpiOsVprintf ( } +#ifndef ACPI_EXEC_APP /****************************************************************************** * * FUNCTION: AcpiOsGetLine @@ -380,7 +508,9 @@ AcpiOsVprintf ( * * RETURN: Status and actual bytes read * - * DESCRIPTION: Formatted input with argument list pointer + * DESCRIPTION: Get the next input line from the terminal. NOTE: For the + * AcpiExec utility, we use the acgetline module instead to + * provide line-editing and history support. * *****************************************************************************/ @@ -390,44 +520,49 @@ AcpiOsGetLine ( UINT32 BufferLength, UINT32 *BytesRead) { - int Temp; - UINT32 i; + int InputChar; + UINT32 EndOfLine; - for (i = 0; ; i++) + /* Standard AcpiOsGetLine for all utilities except AcpiExec */ + + for (EndOfLine = 0; ; EndOfLine++) { - if (i >= BufferLength) + if (EndOfLine >= BufferLength) { return (AE_BUFFER_OVERFLOW); } - if ((Temp = getchar ()) == EOF) + if ((InputChar = getchar ()) == EOF) { return (AE_ERROR); } - if (!Temp || Temp == '\n') + if (!InputChar || InputChar == _ASCII_NEWLINE) { break; } - Buffer [i] = (char) Temp; + Buffer[EndOfLine] = (char) InputChar; } /* Null terminate the buffer */ - Buffer [i] = 0; + Buffer[EndOfLine] = 0; /* Return the number of bytes in the string */ if (BytesRead) { - *BytesRead = i; + *BytesRead = EndOfLine; } + return (AE_OK); } +#endif +#ifndef ACPI_USE_NATIVE_MEMORY_MAPPING /****************************************************************************** * * FUNCTION: AcpiOsMapMemory @@ -473,6 +608,7 @@ AcpiOsUnmapMemory ( return; } +#endif /****************************************************************************** @@ -499,6 +635,32 @@ AcpiOsAllocate ( } +#ifdef USE_NATIVE_ALLOCATE_ZEROED +/****************************************************************************** + * + * FUNCTION: AcpiOsAllocateZeroed + * + * PARAMETERS: Size - Amount to allocate, in bytes + * + * RETURN: Pointer to the new allocation. Null on error. + * + * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. + * + *****************************************************************************/ + +void * +AcpiOsAllocateZeroed ( + ACPI_SIZE size) +{ + void *Mem; + + + Mem = (void *) calloc (1, (size_t) size); + return (Mem); +} +#endif + + /****************************************************************************** * * FUNCTION: AcpiOsFree @@ -1005,7 +1167,7 @@ AcpiOsGetTimer ( * FUNCTION: AcpiOsReadPciConfiguration * * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register + * PciRegister - Device Register * Value - Buffer where value is placed * Width - Number of bits * @@ -1018,7 +1180,7 @@ AcpiOsGetTimer ( ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 PciRegister, UINT64 *Value, UINT32 Width) { @@ -1033,7 +1195,7 @@ AcpiOsReadPciConfiguration ( * FUNCTION: AcpiOsWritePciConfiguration * * PARAMETERS: PciId - Seg/Bus/Dev - * Register - Device Register + * PciRegister - Device Register * Value - Value to be written * Width - Number of bits * @@ -1046,7 +1208,7 @@ AcpiOsReadPciConfiguration ( ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 PciRegister, UINT64 Value, UINT32 Width) { @@ -1242,7 +1404,7 @@ AcpiOsWritable ( * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function - ACPI CA signal function code + * PARAMETERS: Function - ACPI A signal function code * Info - Pointer to function-dependent structure * * RETURN: Status @@ -1334,6 +1496,26 @@ AcpiOsExecute ( return (0); } +#else /* ACPI_SINGLE_THREADED */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (1); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + + Function (Context); + + return (AE_OK); +} + #endif /* ACPI_SINGLE_THREADED */ diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h index 73b902f1b299..30c55a077ffe 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h @@ -1181,10 +1181,11 @@ struct ath_hal; extern struct ath_hal_9300 * ar9300_new_state(u_int16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status); extern struct ath_hal * ar9300_attach(u_int16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, - HAL_STATUS *status); + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status); extern void ar9300_detach(struct ath_hal *ah); extern void ar9300_read_revisions(struct ath_hal *ah); extern HAL_BOOL ar9300_chip_test(struct ath_hal *ah); diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c index 9cc99ec701f0..80dc2a3b3068 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c @@ -618,7 +618,8 @@ ar9300_read_revisions(struct ath_hal *ah) */ struct ath_hal * ar9300_attach(u_int16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, - HAL_BUS_HANDLE sh, uint16_t *eepromdata, HAL_STATUS *status) + HAL_BUS_HANDLE sh, uint16_t *eepromdata, HAL_OPS_CONFIG *ah_config, + HAL_STATUS *status) { struct ath_hal_9300 *ahp; struct ath_hal *ah; @@ -628,7 +629,7 @@ ar9300_attach(u_int16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_NO_INTERSPERSED_READS; /* NB: memory is returned zero'd */ - ahp = ar9300_new_state(devid, sc, st, sh, eepromdata, status); + ahp = ar9300_new_state(devid, sc, st, sh, eepromdata, ah_config, status); if (ahp == AH_NULL) { return AH_NULL; } @@ -654,12 +655,6 @@ ar9300_attach(u_int16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, /* XXX FreeBSD: enable RX mitigation */ ah->ah_config.ath_hal_intr_mitigation_rx = 1; - /* - * XXX what's this do? Check in the qcamain driver code - * as to what it does. - */ - ah->ah_config.ath_hal_ext_atten_margin_cfg = 0; - /* interrupt mitigation */ #ifdef AR5416_INT_MITIGATION if (ah->ah_config.ath_hal_intr_mitigation_rx != 0) { @@ -2378,7 +2373,9 @@ ar9300_detach(struct ath_hal *ah) struct ath_hal_9300 * ar9300_new_state(u_int16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, - uint16_t *eepromdata, HAL_STATUS *status) + uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, + HAL_STATUS *status) { static const u_int8_t defbssidmask[IEEE80211_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -2430,7 +2427,7 @@ ar9300_new_state(u_int16_t devid, HAL_SOFTC sc, ** Initialize factory defaults in the private space */ // ath_hal_factory_defaults(AH_PRIVATE(ah), hal_conf_parm); - ar9300_config_defaults_freebsd(ah); + ar9300_config_defaults_freebsd(ah, ah_config); /* XXX FreeBSD: cal is always in EEPROM */ #if 0 @@ -2456,6 +2453,7 @@ ar9300_new_state(u_int16_t devid, HAL_SOFTC sc, AH_PRIVATE(ah)->ah_tpScale = HAL_TP_SCALE_MAX; /* no scaling */ ahp->ah_atim_window = 0; /* [0..1000] */ + ahp->ah_diversity_control = ah->ah_config.ath_hal_diversity_control; ahp->ah_antenna_switch_swap = @@ -3835,6 +3833,11 @@ ar9300_ant_div_comb_get_config(struct ath_hal *ah, } else { div_comb_conf->antdiv_configgroup = DEFAULT_ANTDIV_CONFIG_GROUP; } + + /* + * XXX TODO: allow the HAL to override the rssithres and fast_div_bias + * values (eg CUS198.) + */ } void diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c index ba7777e3079b..669104a00c55 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c @@ -1606,6 +1606,7 @@ HAL_BOOL ar9300_ant_ctrl_apply(struct ath_hal *ah, HAL_BOOL is_2ghz) if ( AR_SREV_POSEIDON(ah) && (ahp->ah_lna_div_use_bt_ant_enable == TRUE) ) { value &= ~AR_SWITCH_TABLE_COM2_ALL; value |= ah->ah_config.ath_hal_ant_ctrl_comm2g_switch_enable; + HALDEBUG(ah, HAL_DEBUG_RESET, "%s: com2=0x%08x\n", __func__, value) } #endif /* ATH_ANT_DIV_COMB */ OS_REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value); @@ -1711,6 +1712,8 @@ HAL_BOOL ar9300_ant_ctrl_apply(struct ath_hal *ah, HAL_BOOL is_2ghz) /* For WB225, need to swith ANT2 from BT to Wifi * This will not affect HB125 LNA diversity feature. */ + HALDEBUG(ah, HAL_DEBUG_RESET, "%s: com2=0x%08x\n", __func__, + ah->ah_config.ath_hal_ant_ctrl_comm2g_switch_enable) OS_REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, ah->ah_config.ath_hal_ant_ctrl_comm2g_switch_enable); break; @@ -1776,6 +1779,7 @@ ar9300_attenuation_margin_chain_get(struct ath_hal *ah, int chain, return 0; } +#if 0 HAL_BOOL ar9300_attenuation_apply(struct ath_hal *ah, u_int16_t channel) { u_int32_t value; @@ -1814,6 +1818,75 @@ HAL_BOOL ar9300_attenuation_apply(struct ath_hal *ah, u_int16_t channel) } return 0; } +#endif +HAL_BOOL +ar9300_attenuation_apply(struct ath_hal *ah, u_int16_t channel) +{ + int i; + uint32_t value; + uint32_t ext_atten_reg[3] = { + AR_PHY_EXT_ATTEN_CTL_0, + AR_PHY_EXT_ATTEN_CTL_1, + AR_PHY_EXT_ATTEN_CTL_2 + }; + + /* + * If it's an AR9462 and we're receiving on the second + * chain only, set the chain 0 details from chain 1 + * calibration. + * + * This is from ath9k. + */ + if (AR_SREV_JUPITER(ah) && (AH9300(ah)->ah_rx_chainmask == 0x2)) { + value = ar9300_attenuation_chain_get(ah, 1, channel); + OS_REG_RMW_FIELD(ah, ext_atten_reg[0], + AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value); + value = ar9300_attenuation_margin_chain_get(ah, 1, channel); + OS_REG_RMW_FIELD(ah, ext_atten_reg[0], + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, value); + } + + /* + * Now, loop over the configured transmit chains and + * load in the attenuation/margin settings as appropriate. + */ + for (i = 0; i < 3; i++) { + if ((AH9300(ah)->ah_tx_chainmask & (1 << i)) == 0) + continue; + + value = ar9300_attenuation_chain_get(ah, i, channel); + OS_REG_RMW_FIELD(ah, ext_atten_reg[i], + AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, + value); + + if (AR_SREV_POSEIDON(ah) && + (ar9300_rx_gain_index_get(ah) == 0) && + ah->ah_config.ath_hal_ext_atten_margin_cfg) { + value = 5; + } else { + value = ar9300_attenuation_margin_chain_get(ah, 0, + channel); + } + + /* + * I'm not sure why it's loading in this setting into + * the chain 0 margin regardless of the current chain. + */ + if (ah->ah_config.ath_hal_min_gainidx) + OS_REG_RMW_FIELD(ah, + AR_PHY_EXT_ATTEN_CTL_0, + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, + value); + + OS_REG_RMW_FIELD(ah, + ext_atten_reg[i], + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN, + value); + } + + return (0); +} + static u_int16_t ar9300_quick_drop_get(struct ath_hal *ah, int chain, u_int16_t channel) diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c index a2cc25d741ea..a6968c173484 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c @@ -70,9 +70,6 @@ void ar9300_attach_freebsd_ops(struct ath_hal *ah) { - /* stub everything first */ - ar9300_set_stub_functions(ah); - /* Global functions */ ah->ah_detach = ar9300_detach; ah->ah_getRateTable = ar9300_get_rate_table; @@ -255,9 +252,6 @@ ar9300_attach_freebsd_ops(struct ath_hal *ah) /* LNA diversity functions */ ah->ah_divLnaConfGet = ar9300_ant_div_comb_get_config; ah->ah_divLnaConfSet = ar9300_ant_div_comb_set_config; - - /* Setup HAL configuration defaults */ - ah->ah_config.ath_hal_ant_ctrl_comm2g_switch_enable = 0x000bbb88; } HAL_BOOL @@ -341,9 +335,11 @@ ar9300_ani_poll_freebsd(struct ath_hal *ah, * wants. */ void -ar9300_config_defaults_freebsd(struct ath_hal *ah) +ar9300_config_defaults_freebsd(struct ath_hal *ah, HAL_OPS_CONFIG *ah_config) { + /* Until FreeBSD's HAL does this by default - just copy */ + OS_MEMCPY(&ah->ah_config, ah_config, sizeof(HAL_OPS_CONFIG)); ah->ah_config.ath_hal_enable_ani = AH_TRUE; } @@ -471,11 +467,13 @@ ar9300_freebsd_setup_x_tx_desc(struct ath_hal *ah, struct ath_desc *ds, u_int txRate3, u_int txTries3) { +#if 0 ath_hal_printf(ah, "%s: called, 0x%x/%d, 0x%x/%d, 0x%x/%d\n", __func__, txRate1, txTries1, txRate2, txTries2, txRate3, txTries3); +#endif /* XXX should only be called during probe */ return (AH_TRUE); diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.h b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.h index c07c32fa01b1..524c3f3fce5d 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.h +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.h @@ -11,7 +11,8 @@ extern HAL_STATUS ar9300_eeprom_get_freebsd(struct ath_hal *, int param, extern HAL_BOOL ar9300_stop_tx_dma_freebsd(struct ath_hal *ah, u_int q); extern void ar9300_ani_poll_freebsd(struct ath_hal *ah, const struct ieee80211_channel *chan); -extern void ar9300_config_defaults_freebsd(struct ath_hal *ah); +extern void ar9300_config_defaults_freebsd(struct ath_hal *ah, + HAL_OPS_CONFIG *ah_config); extern HAL_BOOL ar9300_stop_dma_receive_freebsd(struct ath_hal *ah); extern HAL_BOOL ar9300_get_pending_interrupts_freebsd(struct ath_hal *ah, HAL_INT *masked); diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c index 1090c9c59ab7..51ce195ff56c 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_reset.c @@ -6151,6 +6151,7 @@ ar9300_ant_ctrl_set_lna_div_use_bt_ant(struct ath_hal *ah, HAL_BOOL enable, cons value &= ~AR_SWITCH_TABLE_COM2_ALL; value |= ah->ah_config.ath_hal_ant_ctrl_comm2g_switch_enable; } + HALDEBUG(ah, HAL_DEBUG_RESET, "%s: com2=0x%08x\n", __func__, value); OS_REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value); value = ar9300_eeprom_get(ahp, EEP_ANTDIV_control); diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub.c index 2dd9472df269..211e201a1df7 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_stub.c @@ -33,7 +33,7 @@ void ar9300_set_stub_functions(struct ath_hal *ah) { - ath_hal_printf(ah, "%s: setting stub functions\n", __func__); +// ath_hal_printf(ah, "%s: setting stub functions\n", __func__); ah->ah_getRateTable = ar9300_Stub_GetRateTable; // ah->ah_detach = ar9300_Stub_detach; diff --git a/sys/contrib/ipfilter/netinet/ip_dstlist.c b/sys/contrib/ipfilter/netinet/ip_dstlist.c index ce2e72e8130f..d516556c39cc 100644 --- a/sys/contrib/ipfilter/netinet/ip_dstlist.c +++ b/sys/contrib/ipfilter/netinet/ip_dstlist.c @@ -1134,7 +1134,7 @@ ipf_dstlist_select(fin, d) int family; int x; - if (d->ipld_dests == NULL || *d->ipld_dests == NULL) + if (d == NULL || d->ipld_dests == NULL || *d->ipld_dests == NULL) return NULL; family = fin->fin_family; @@ -1222,7 +1222,7 @@ ipf_dstlist_select(fin, d) break; } - if (sel->ipfd_dest.fd_addr.adf_family != family) + if (sel && sel->ipfd_dest.fd_addr.adf_family != family) sel = NULL; d->ipld_selected = sel; diff --git a/sys/contrib/ipfilter/netinet/ip_frag.c b/sys/contrib/ipfilter/netinet/ip_frag.c index fd4ff2449abf..831326c2978a 100644 --- a/sys/contrib/ipfilter/netinet/ip_frag.c +++ b/sys/contrib/ipfilter/netinet/ip_frag.c @@ -930,7 +930,8 @@ ipf_frag_known(fin, passp) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_natforget */ /* Returns: Nil */ -/* Parameters: ptr(I) - pointer to data structure */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* ptr(I) - pointer to data structure */ /* */ /* Search through all of the fragment cache entries for NAT and wherever a */ /* pointer is found to match ptr, reset it to NULL. */ @@ -954,7 +955,8 @@ ipf_frag_natforget(softc, ptr) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_delete */ /* Returns: Nil */ -/* Parameters: fra(I) - pointer to fragment structure to delete */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* fra(I) - pointer to fragment structure to delete */ /* tail(IO) - pointer to the pointer to the tail of the frag */ /* list */ /* */ @@ -991,7 +993,10 @@ ipf_frag_delete(softc, fra, tail) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_free */ /* Returns: Nil */ +/* Parameters: softf(I) - pointer to fragment context information */ +/* fra(I) - pointer to fragment structure to free */ /* */ +/* Free up a fragment cache entry and bump relevent statistics. */ /* ------------------------------------------------------------------------ */ static void ipf_frag_free(softf, fra) @@ -1007,7 +1012,7 @@ ipf_frag_free(softf, fra) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_clear */ /* Returns: Nil */ -/* Parameters: Nil */ +/* Parameters: softc(I) - pointer to soft context main structure */ /* */ /* Free memory in use by fragment state information kept. Do the normal */ /* fragment state stuff first and then the NAT-fragment table. */ @@ -1048,7 +1053,7 @@ ipf_frag_clear(softc) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_expire */ /* Returns: Nil */ -/* Parameters: Nil */ +/* Parameters: softc(I) - pointer to soft context main structure */ /* */ /* Expire entries in the fragment cache table that have been there too long */ /* ------------------------------------------------------------------------ */ @@ -1120,6 +1125,13 @@ ipf_frag_expire(softc) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_pkt_next */ +/* Returns: int - 0 == success, else error */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* token(I) - pointer to token information for this caller */ +/* itp(I) - pointer to generic iterator from caller */ +/* */ +/* This function is used to step through the fragment cache list used for */ +/* filter rules. The hard work is done by the more generic ipf_frag_next. */ /* ------------------------------------------------------------------------ */ int ipf_frag_pkt_next(softc, token, itp) @@ -1140,6 +1152,13 @@ ipf_frag_pkt_next(softc, token, itp) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_nat_next */ +/* Returns: int - 0 == success, else error */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* token(I) - pointer to token information for this caller */ +/* itp(I) - pointer to generic iterator from caller */ +/* */ +/* This function is used to step through the fragment cache list used for */ +/* NAT. The hard work is done by the more generic ipf_frag_next. */ /* ------------------------------------------------------------------------ */ int ipf_frag_nat_next(softc, token, itp) @@ -1160,7 +1179,8 @@ ipf_frag_nat_next(softc, token, itp) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_next */ /* Returns: int - 0 == success, else error */ -/* Parameters: token(I) - pointer to token information for this caller */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* token(I) - pointer to token information for this caller */ /* itp(I) - pointer to generic iterator from caller */ /* top(I) - top of the fragment list */ /* lock(I) - fragment cache lock */ @@ -1239,7 +1259,11 @@ ipf_frag_next(softc, token, itp, top /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_pkt_deref */ /* Returns: Nil */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* data(I) - pointer to frag cache pointer */ /* */ +/* This function is the external interface for dropping a reference to a */ +/* fragment cache entry used by filter rules. */ /* ------------------------------------------------------------------------ */ void ipf_frag_pkt_deref(softc, data) @@ -1261,7 +1285,11 @@ ipf_frag_pkt_deref(softc, data) /* ------------------------------------------------------------------------ */ /* Function: ipf_frag_nat_deref */ /* Returns: Nil */ +/* Parameters: softc(I) - pointer to soft context main structure */ +/* data(I) - pointer to frag cache pointer */ /* */ +/* This function is the external interface for dropping a reference to a */ +/* fragment cache entry used by NAT table entries. */ /* ------------------------------------------------------------------------ */ void ipf_frag_nat_deref(softc, data) diff --git a/sys/ddb/db_main.c b/sys/ddb/db_main.c index 6e9286cbc1c1..bee321cc34ed 100644 --- a/sys/ddb/db_main.c +++ b/sys/ddb/db_main.c @@ -56,7 +56,12 @@ static dbbe_trace_thread_f db_trace_thread_wrapper; KDB_BACKEND(ddb, db_init, db_trace_self_wrapper, db_trace_thread_wrapper, db_trap); -vm_offset_t ksym_start, ksym_end; +/* + * Symbols can be loaded by specifying the exact addresses of + * the symtab and strtab in memory. This is used when loaded from + * boot loaders different than the native one (like Xen). + */ +vm_offset_t ksymtab, kstrtab, ksymtab_size; boolean_t X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t sym, char **file, int *line, @@ -168,24 +173,39 @@ X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym, const char **namep, } } +int +db_fetch_ksymtab(vm_offset_t ksym_start, vm_offset_t ksym_end) +{ + Elf_Size strsz; + + if (ksym_end > ksym_start && ksym_start != 0) { + ksymtab = ksym_start; + ksymtab_size = *(Elf_Size*)ksymtab; + ksymtab += sizeof(Elf_Size); + kstrtab = ksymtab + ksymtab_size; + strsz = *(Elf_Size*)kstrtab; + kstrtab += sizeof(Elf_Size); + if (kstrtab + strsz > ksym_end) { + /* Sizes doesn't match, unset everything. */ + ksymtab = ksymtab_size = kstrtab = 0; + } + } + + if (ksymtab == 0 || ksymtab_size == 0 || kstrtab == 0) + return (-1); + + return (0); +} + static int db_init(void) { - uintptr_t symtab, strtab; - Elf_Size tabsz, strsz; db_command_init(); - if (ksym_end > ksym_start && ksym_start != 0) { - symtab = ksym_start; - tabsz = *((Elf_Size*)symtab); - symtab += sizeof(Elf_Size); - strtab = symtab + tabsz; - strsz = *((Elf_Size*)strtab); - strtab += sizeof(Elf_Size); - if (strtab + strsz <= ksym_end) { - db_add_symbol_table((char *)symtab, - (char *)(symtab + tabsz), "elf", (char *)strtab); - } + + if (ksymtab != 0 && kstrtab != 0 && ksymtab_size != 0) { + db_add_symbol_table((char *)ksymtab, + (char *)(ksymtab + ksymtab_size), "elf", (char *)kstrtab); } db_add_symbol_table(NULL, NULL, "kld", NULL); return (1); /* We're the default debugger. */ diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h index 42fc9025954f..5aa646b3302a 100644 --- a/sys/ddb/ddb.h +++ b/sys/ddb/ddb.h @@ -76,6 +76,13 @@ SYSCTL_DECL(_debug_ddb); int DB_CALL(db_expr_t, db_expr_t *, int, db_expr_t[]); #endif +/* + * Extern variables to set the address and size of the symtab and strtab. + * Most users should use db_fetch_symtab in order to set them from the + * boot loader provided values. + */ +extern vm_offset_t ksymtab, kstrtab, ksymtab_size; + /* * There are three "command tables": * - One for simple commands; a list of these is displayed @@ -218,6 +225,7 @@ int db_value_of_name_vnet(const char *name, db_expr_t *valuep); int db_write_bytes(vm_offset_t addr, size_t size, char *data); void db_command_register(struct command_table *, struct command *); void db_command_unregister(struct command_table *, struct command *); +int db_fetch_ksymtab(vm_offset_t ksym_start, vm_offset_t ksym_end); db_cmdfcn_t db_breakpoint_cmd; db_cmdfcn_t db_capture_cmd; diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index d49f886c9b8b..e998fee7860c 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -59,6 +59,13 @@ static int acpi_max_tasks = ACPI_MAX_TASKS; SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, 0, "Maximum acpi tasks"); +/* + * Track and report the system's demand for task slots. + */ +static int acpi_tasks_hiwater; +SYSCTL_INT(_debug_acpi, OID_AUTO, tasks_hiwater, CTLFLAG_RD, + &acpi_tasks_hiwater, 1, "Peak demand for ACPI event task slots."); + /* * Allow the user to tune the number of task threads we start. It seems * some systems have problems with increased parallelism. @@ -151,6 +158,10 @@ acpi_task_enqueue(int priority, ACPI_OSD_EXEC_CALLBACK Function, void *Context) acpi_task_count++; break; } + + if (i > acpi_tasks_hiwater) + atomic_cmpset_int(&acpi_tasks_hiwater, acpi_tasks_hiwater, i); + if (at == NULL) { printf("AcpiOsExecute: failed to enqueue task, consider increasing " "the debug.acpi.max_tasks tunable\n"); diff --git a/sys/dev/acpica/Osd/OsdTable.c b/sys/dev/acpica/Osd/OsdTable.c index 1e738f8d7f82..006b2ce0268a 100644 --- a/sys/dev/acpica/Osd/OsdTable.c +++ b/sys/dev/acpica/Osd/OsdTable.c @@ -91,8 +91,8 @@ AcpiOsTableOverride(ACPI_TABLE_HEADER *ExistingTable, if (hdr == NULL || sz == 0) return (AE_ERROR); #ifndef notyet - /* Assume SSDT is loaded with DSDT. */ - AcpiGbl_DisableSsdtTableLoad = TRUE; + /* Assume SSDT is installed with DSDT. */ + AcpiGbl_DisableSsdtTableInstall = TRUE; #endif *NewTable = hdr; return (AE_OK); diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index b37e252f2138..37c79a5d4359 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -93,6 +93,7 @@ struct acpi_interface { /* Global mutex for locking access to the ACPI subsystem. */ struct mtx acpi_mutex; +struct callout acpi_sleep_timer; /* Bitmap of device quirks. */ int acpi_quirks; @@ -255,16 +256,6 @@ static char acpi_remove_interface[256]; TUNABLE_STR("hw.acpi.remove_interface", acpi_remove_interface, sizeof(acpi_remove_interface)); -/* - * Allow override of whether methods execute in parallel or not. - * Enable this for serial behavior, which fixes "AE_ALREADY_EXISTS" - * errors for AML that really can't handle parallel method execution. - * It is off by default since this breaks recursive methods and - * some IBMs use such code. - */ -static int acpi_serialize_methods; -TUNABLE_INT("hw.acpi.serialize_methods", &acpi_serialize_methods); - /* Allow users to dump Debug objects without ACPI debugger. */ static int acpi_debug_objects; TUNABLE_INT("debug.acpi.enable_debug_objects", &acpi_debug_objects); @@ -278,6 +269,12 @@ TUNABLE_INT("debug.acpi.interpreter_slack", &acpi_interpreter_slack); SYSCTL_INT(_debug_acpi, OID_AUTO, interpreter_slack, CTLFLAG_RDTUN, &acpi_interpreter_slack, 1, "Turn on interpreter slack mode."); +/* Ignore register widths set by FADT and use default widths instead. */ +static int acpi_ignore_reg_width = 1; +TUNABLE_INT("debug.acpi.default_register_width", &acpi_ignore_reg_width); +SYSCTL_INT(_debug_acpi, OID_AUTO, default_register_width, CTLFLAG_RDTUN, + &acpi_ignore_reg_width, 1, "Ignore register widths set by FADT"); + #ifdef __amd64__ /* Reset system clock while resuming. XXX Remove once tested. */ static int acpi_reset_clock = 1; @@ -473,9 +470,9 @@ acpi_attach(device_t dev) * Set the globals from our tunables. This is needed because ACPI-CA * uses UINT8 for some values and we have no tunable_byte. */ - AcpiGbl_AllMethodsSerialized = acpi_serialize_methods ? TRUE : FALSE; AcpiGbl_EnableInterpreterSlack = acpi_interpreter_slack ? TRUE : FALSE; AcpiGbl_EnableAmlDebugObject = acpi_debug_objects ? TRUE : FALSE; + AcpiGbl_UseDefaultRegisterWidths = acpi_ignore_reg_width ? TRUE : FALSE; #ifndef ACPI_DEBUG /* @@ -683,7 +680,9 @@ acpi_attach(device_t dev) AcpiFormatException(status)); /* Allow sleep request after a while. */ - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + callout_init_mtx(&acpi_sleep_timer, &acpi_mutex, 0); + callout_reset(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME, + acpi_sleep_enable, sc); error = 0; @@ -851,11 +850,18 @@ acpi_child_location_str_method(device_t cbdev, device_t child, char *buf, size_t buflen) { struct acpi_device *dinfo = device_get_ivars(child); + char buf2[32]; + int pxm; - if (dinfo->ad_handle) - snprintf(buf, buflen, "handle=%s", acpi_name(dinfo->ad_handle)); - else - snprintf(buf, buflen, "unknown"); + if (dinfo->ad_handle) { + snprintf(buf, buflen, "handle=%s", acpi_name(dinfo->ad_handle)); + if (ACPI_SUCCESS(acpi_GetInteger(dinfo->ad_handle, "_PXM", &pxm))) { + snprintf(buf2, 32, " _PXM=%d", pxm); + strlcat(buf, buf2, buflen); + } + } else { + snprintf(buf, buflen, "unknown"); + } return (0); } @@ -2483,8 +2489,8 @@ acpi_sleep_force(void *arg) device_printf(sc->acpi_dev, "suspend request timed out, forcing sleep now\n"); /* - * XXX Suspending from callout cause the freeze in DEVICE_SUSPEND(). - * Suspend from acpi_task thread in stead. + * XXX Suspending from callout causes freezes in DEVICE_SUSPEND(). + * Suspend from acpi_task thread instead. */ if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_sleep_force_task, sc))) @@ -2636,15 +2642,15 @@ acpi_sleep_enable(void *arg) { struct acpi_softc *sc = (struct acpi_softc *)arg; + ACPI_LOCK_ASSERT(acpi); + /* Reschedule if the system is not fully up and running. */ if (!AcpiGbl_SystemAwakeAndRunning) { - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + callout_schedule(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME); return; } - ACPI_LOCK(acpi); sc->acpi_sleep_disabled = FALSE; - ACPI_UNLOCK(acpi); } static ACPI_STATUS @@ -2859,7 +2865,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state) EVENTHANDLER_INVOKE(power_resume); /* Allow another sleep request after a while. */ - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + callout_schedule(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME); /* Run /etc/rc.resume after we are back. */ if (devctl_process_running()) diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c index 78d8639fd651..d94b6f0095f4 100644 --- a/sys/dev/acpica/acpi_pci.c +++ b/sys/dev/acpica/acpi_pci.c @@ -149,12 +149,19 @@ acpi_pci_child_location_str_method(device_t cbdev, device_t child, char *buf, size_t buflen) { struct acpi_pci_devinfo *dinfo = device_get_ivars(child); + int pxm; + char buf2[32]; pci_child_location_str_method(cbdev, child, buf, buflen); - + if (dinfo->ap_handle) { - strlcat(buf, " handle=", buflen); - strlcat(buf, acpi_name(dinfo->ap_handle), buflen); + strlcat(buf, " handle=", buflen); + strlcat(buf, acpi_name(dinfo->ap_handle), buflen); + + if (ACPI_SUCCESS(acpi_GetInteger(dinfo->ap_handle, "_PXM", &pxm))) { + snprintf(buf2, 32, " _PXM=%d", pxm); + strlcat(buf, buf2, buflen); + } } return (0); } @@ -275,7 +282,7 @@ acpi_pci_probe(device_t dev) if (acpi_get_handle(dev) == NULL) return (ENXIO); device_set_desc(dev, "ACPI PCI bus"); - return (0); + return (BUS_PROBE_DEFAULT); } static int diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c index ec174091cd70..6108f8192b7b 100644 --- a/sys/dev/ae/if_ae.c +++ b/sys/dev/ae/if_ae.c @@ -1852,9 +1852,9 @@ ae_tx_intr(ae_softc_t *sc) sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT; if ((flags & AE_TXS_SUCCESS) != 0) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->tx_inproc--; } @@ -1897,13 +1897,13 @@ ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd) size = le16toh(rxd->len) - ETHER_CRC_LEN; if (size < (ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)) { if_printf(ifp, "Runt frame received."); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } m = m_devget(&rxd->data[0], size, ETHER_ALIGN, ifp, NULL); if (m == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return; } @@ -1913,7 +1913,7 @@ ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd) m->m_flags |= M_VLANTAG; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* * Pass it through. */ @@ -1959,7 +1959,7 @@ ae_rx_intr(ae_softc_t *sc) if ((flags & AE_RXD_SUCCESS) != 0) ae_rxeof(sc, rxd); else - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } if (count > 0) { @@ -1989,7 +1989,7 @@ ae_watchdog(ae_softc_t *sc) else if_printf(ifp, "watchdog timeout - resetting.\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ae_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c index d5f387cafda0..c3a896203c1f 100644 --- a/sys/dev/age/if_age.c +++ b/sys/dev/age/if_age.c @@ -1792,7 +1792,7 @@ age_watchdog(struct age_softc *sc) ifp = sc->age_ifp; if ((sc->age_flags & AGE_FLAG_LINK) == 0) { if_printf(sc->age_ifp, "watchdog timeout (missed link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; age_init_locked(sc); return; @@ -1805,7 +1805,7 @@ age_watchdog(struct age_softc *sc) return; } if_printf(sc->age_ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; age_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -2087,22 +2087,22 @@ age_stats_update(struct age_softc *sc) stat->tx_mcast_bytes += smb->tx_mcast_bytes; /* Update counters in ifnet. */ - ifp->if_opackets += smb->tx_frames; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, smb->tx_frames); - ifp->if_collisions += smb->tx_single_colls + + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, smb->tx_single_colls + smb->tx_multi_colls + smb->tx_late_colls + - smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT; + smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT); - ifp->if_oerrors += smb->tx_excess_colls + + if_inc_counter(ifp, IFCOUNTER_OERRORS, smb->tx_excess_colls + smb->tx_late_colls + smb->tx_underrun + - smb->tx_pkts_truncated; + smb->tx_pkts_truncated); - ifp->if_ipackets += smb->rx_frames; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, smb->rx_frames); - ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs + - smb->rx_runts + smb->rx_pkts_truncated + + if_inc_counter(ifp, IFCOUNTER_IERRORS, smb->rx_crcerrs + + smb->rx_lenerrs + smb->rx_runts + smb->rx_pkts_truncated + smb->rx_fifo_oflows + smb->rx_desc_oflows + - smb->rx_alignerrs; + smb->rx_alignerrs); /* Update done, clear. */ smb->updated = 0; @@ -2291,7 +2291,7 @@ age_fixup_rx(struct ifnet *ifp, struct mbuf *m) */ MGETHDR(n, M_NOWAIT, MT_DATA); if (n == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); m_freem(m); return (NULL); } @@ -2347,7 +2347,7 @@ age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd) mp = rxd->rx_m; /* Add a new receive buffer to the ring. */ if (age_newbuf(sc, rxd) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* Reuse Rx buffers. */ if (sc->age_cdata.age_rxhead != NULL) m_freem(sc->age_cdata.age_rxhead); diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index b81440aff0d3..69fa76bfab42 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -61,31 +61,31 @@ static void ahci_ch_pm(void *arg); static void ahci_ch_intr(void *arg); static void ahci_ch_intr_direct(void *arg); static void ahci_ch_intr_main(struct ahci_channel *ch, uint32_t istatus); -static void ahci_begin_transaction(device_t dev, union ccb *ccb); +static void ahci_begin_transaction(struct ahci_channel *ch, union ccb *ccb); static void ahci_dmasetprd(void *arg, bus_dma_segment_t *segs, int nsegs, int error); static void ahci_execute_transaction(struct ahci_slot *slot); static void ahci_timeout(struct ahci_slot *slot); static void ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et); -static int ahci_setup_fis(device_t dev, struct ahci_cmd_tab *ctp, union ccb *ccb, int tag); +static int ahci_setup_fis(struct ahci_channel *ch, struct ahci_cmd_tab *ctp, union ccb *ccb, int tag); static void ahci_dmainit(device_t dev); static void ahci_dmasetupc_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int error); static void ahci_dmafini(device_t dev); static void ahci_slotsalloc(device_t dev); static void ahci_slotsfree(device_t dev); -static void ahci_reset(device_t dev); -static void ahci_start(device_t dev, int fbs); -static void ahci_stop(device_t dev); -static void ahci_clo(device_t dev); -static void ahci_start_fr(device_t dev); -static void ahci_stop_fr(device_t dev); +static void ahci_reset(struct ahci_channel *ch); +static void ahci_start(struct ahci_channel *ch, int fbs); +static void ahci_stop(struct ahci_channel *ch); +static void ahci_clo(struct ahci_channel *ch); +static void ahci_start_fr(struct ahci_channel *ch); +static void ahci_stop_fr(struct ahci_channel *ch); static int ahci_sata_connect(struct ahci_channel *ch); -static int ahci_sata_phy_reset(device_t dev); -static int ahci_wait_ready(device_t dev, int t, int t0); +static int ahci_sata_phy_reset(struct ahci_channel *ch); +static int ahci_wait_ready(struct ahci_channel *ch, int t, int t0); -static void ahci_issue_recovery(device_t dev); -static void ahci_process_read_log(device_t dev, union ccb *ccb); -static void ahci_process_request_sense(device_t dev, union ccb *ccb); +static void ahci_issue_recovery(struct ahci_channel *ch); +static void ahci_process_read_log(struct ahci_channel *ch, union ccb *ccb); +static void ahci_process_request_sense(struct ahci_channel *ch, union ccb *ccb); static void ahciaction(struct cam_sim *sim, union ccb *ccb); static void ahcipoll(struct cam_sim *sim); @@ -159,6 +159,7 @@ ahci_attach(device_t dev) device_t child; ctlr->dev = dev; + ctlr->ccc = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "ccc", &ctlr->ccc); @@ -187,10 +188,9 @@ ahci_attach(device_t dev) ctlr->ichannels = ATA_INL(ctlr->r_mem, AHCI_PI); /* Identify and set separate quirks for HBA and RAID f/w Marvells. */ - if ((ctlr->quirks & AHCI_Q_NOBSYRES) && - (ctlr->quirks & AHCI_Q_ALTSIG) && + if ((ctlr->quirks & AHCI_Q_ALTSIG) && (ctlr->caps & AHCI_CAP_SPM) == 0) - ctlr->quirks &= ~AHCI_Q_NOBSYRES; + ctlr->quirks |= AHCI_Q_NOBSYRES; if (ctlr->quirks & AHCI_Q_1CH) { ctlr->caps &= ~AHCI_CAP_NPMASK; @@ -230,6 +230,15 @@ ahci_attach(device_t dev) ahci_ctlr_setup(dev); + /* Setup interrupts. */ + if (ahci_setup_interrupt(dev)) { + bus_dma_tag_destroy(ctlr->dma_tag); + bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, + ctlr->r_mem); + rman_fini(&ctlr->sc_iomem); + return ENXIO; + } + i = 0; for (u = ctlr->ichannels; u != 0; u >>= 1) i += (u & 1); @@ -351,7 +360,9 @@ ahci_setup_interrupt(device_t dev) for (i = 0; i < ctlr->numirqs; i++) { ctlr->irqs[i].ctlr = ctlr; ctlr->irqs[i].r_irq_rid = i + (ctlr->msi ? 1 : 0); - if (ctlr->numirqs == 1 || i >= ctlr->channels || + if (ctlr->channels == 1 && !ctlr->ccc) + ctlr->irqs[i].mode = AHCI_IRQ_MODE_ONE; + else if (ctlr->numirqs == 1 || i >= ctlr->channels || (ctlr->ccc && i == ctlr->cccv)) ctlr->irqs[i].mode = AHCI_IRQ_MODE_ALL; else if (i == ctlr->numirqs - 1) @@ -614,6 +625,7 @@ ahci_ch_attach(device_t dev) ch->subdeviceid = ctlr->subdeviceid; ch->numslots = ((ch->caps & AHCI_CAP_NCS) >> AHCI_CAP_NCS_SHIFT) + 1; mtx_init(&ch->mtx, "AHCI channel lock", NULL, MTX_DEF); + ch->pm_level = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "pm_level", &ch->pm_level); STAILQ_INIT(&ch->doneq); @@ -659,7 +671,7 @@ ahci_ch_attach(device_t dev) } if ((bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL, ctlr->direct ? ahci_ch_intr_direct : ahci_ch_intr, - dev, &ch->ih))) { + ch, &ch->ih))) { device_printf(dev, "Unable to setup interrupt\n"); error = ENXIO; goto err1; @@ -688,7 +700,7 @@ ahci_ch_attach(device_t dev) } /* Construct SIM entry */ ch->sim = cam_sim_alloc(ahciaction, ahcipoll, "ahcich", ch, - device_get_unit(dev), &ch->mtx, + device_get_unit(dev), (struct mtx *)&ch->mtx, min(2, ch->numslots), (ch->caps & AHCI_CAP_SNCQ) ? ch->numslots : 0, devq); @@ -712,7 +724,7 @@ ahci_ch_attach(device_t dev) if (ch->pm_level > 3) { callout_reset(&ch->pm_timer, (ch->pm_level == 4) ? hz / 1000 : hz / 8, - ahci_ch_pm, dev); + ahci_ch_pm, ch); } mtx_unlock(&ch->mtx); return (0); @@ -782,8 +794,8 @@ ahci_ch_init(device_t dev) (AHCI_P_CMD_ACTIVE | AHCI_P_CMD_POD | AHCI_P_CMD_SUD | ((ch->pm_level == 2 || ch->pm_level == 3) ? AHCI_P_CMD_ALPE : 0) | ((ch->pm_level > 2) ? AHCI_P_CMD_ASP : 0 ))); - ahci_start_fr(dev); - ahci_start(dev, 1); + ahci_start_fr(ch); + ahci_start(ch, 1); return (0); } @@ -795,8 +807,8 @@ ahci_ch_deinit(device_t dev) /* Disable port interrupts. */ ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); /* Reset command register. */ - ahci_stop(dev); - ahci_stop_fr(dev); + ahci_stop(ch); + ahci_stop_fr(ch); ATA_OUTL(ch->r_mem, AHCI_P_CMD, 0); /* Allow everything, including partial and slumber modes. */ ATA_OUTL(ch->r_mem, AHCI_P_SCTL, 0); @@ -835,7 +847,7 @@ ahci_ch_resume(device_t dev) mtx_lock(&ch->mtx); ahci_ch_init(dev); - ahci_reset(dev); + ahci_reset(ch); xpt_release_simq(ch->sim, TRUE); mtx_unlock(&ch->mtx); return (0); @@ -966,7 +978,7 @@ ahci_slotsalloc(device_t dev) for (i = 0; i < ch->numslots; i++) { struct ahci_slot *slot = &ch->slot[i]; - slot->dev = dev; + slot->ch = ch; slot->slot = i; slot->state = AHCI_SLOT_EMPTY; slot->ccb = NULL; @@ -996,9 +1008,8 @@ ahci_slotsfree(device_t dev) } static int -ahci_phy_check_events(device_t dev, u_int32_t serr) +ahci_phy_check_events(struct ahci_channel *ch, u_int32_t serr) { - struct ahci_channel *ch = device_get_softc(dev); if (((ch->pm_level == 0) && (serr & ATA_SE_PHY_CHANGED)) || ((ch->pm_level != 0 || ch->listening) && (serr & ATA_SE_EXCHANGED))) { @@ -1007,11 +1018,11 @@ ahci_phy_check_events(device_t dev, u_int32_t serr) if (bootverbose) { if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) - device_printf(dev, "CONNECT requested\n"); + device_printf(ch->dev, "CONNECT requested\n"); else - device_printf(dev, "DISCONNECT requested\n"); + device_printf(ch->dev, "DISCONNECT requested\n"); } - ahci_reset(dev); + ahci_reset(ch); if ((ccb = xpt_alloc_ccb_nowait()) == NULL) return (0); if (xpt_create_path(&ccb->ccb_h.path, NULL, @@ -1027,11 +1038,11 @@ ahci_phy_check_events(device_t dev, u_int32_t serr) } static void -ahci_cpd_check_events(device_t dev) +ahci_cpd_check_events(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); u_int32_t status; union ccb *ccb; + device_t dev; if (ch->pm_level == 0) return; @@ -1041,12 +1052,13 @@ ahci_cpd_check_events(device_t dev) return; if (bootverbose) { + dev = ch->dev; if (status & AHCI_P_CMD_CPS) { device_printf(dev, "COLD CONNECT requested\n"); } else device_printf(dev, "COLD DISCONNECT requested\n"); } - ahci_reset(dev); + ahci_reset(ch); if ((ccb = xpt_alloc_ccb_nowait()) == NULL) return; if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(ch->sim), @@ -1058,16 +1070,15 @@ ahci_cpd_check_events(device_t dev) } static void -ahci_notify_events(device_t dev, u_int32_t status) +ahci_notify_events(struct ahci_channel *ch, u_int32_t status) { - struct ahci_channel *ch = device_get_softc(dev); struct cam_path *dpath; int i; if (ch->caps & AHCI_CAP_SSNTF) ATA_OUTL(ch->r_mem, AHCI_P_SNTF, status); if (bootverbose) - device_printf(dev, "SNTF 0x%04x\n", status); + device_printf(ch->dev, "SNTF 0x%04x\n", status); for (i = 0; i < 16; i++) { if ((status & (1 << i)) == 0) continue; @@ -1096,8 +1107,7 @@ ahci_done(struct ahci_channel *ch, union ccb *ccb) static void ahci_ch_intr(void *arg) { - device_t dev = (device_t)arg; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = (struct ahci_channel *)arg; uint32_t istatus; /* Read interrupt statuses. */ @@ -1113,10 +1123,10 @@ ahci_ch_intr(void *arg) static void ahci_ch_intr_direct(void *arg) { - device_t dev = (device_t)arg; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = (struct ahci_channel *)arg; struct ccb_hdr *ccb_h; uint32_t istatus; + STAILQ_HEAD(, ccb_hdr) tmp_doneq = STAILQ_HEAD_INITIALIZER(tmp_doneq); /* Read interrupt statuses. */ istatus = ATA_INL(ch->r_mem, AHCI_P_IS); @@ -1127,9 +1137,14 @@ ahci_ch_intr_direct(void *arg) ch->batch = 1; ahci_ch_intr_main(ch, istatus); ch->batch = 0; + /* + * Prevent the possibility of issues caused by processing the queue + * while unlocked below by moving the contents to a local queue. + */ + STAILQ_CONCAT(&tmp_doneq, &ch->doneq); mtx_unlock(&ch->mtx); - while ((ccb_h = STAILQ_FIRST(&ch->doneq)) != NULL) { - STAILQ_REMOVE_HEAD(&ch->doneq, sim_links.stqe); + while ((ccb_h = STAILQ_FIRST(&tmp_doneq)) != NULL) { + STAILQ_REMOVE_HEAD(&tmp_doneq, sim_links.stqe); xpt_done_direct((union ccb *)ccb_h); } } @@ -1137,8 +1152,7 @@ ahci_ch_intr_direct(void *arg) static void ahci_ch_pm(void *arg) { - device_t dev = (device_t)arg; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = (struct ahci_channel *)arg; uint32_t work; if (ch->numrslots != 0) @@ -1154,7 +1168,6 @@ ahci_ch_pm(void *arg) static void ahci_ch_intr_main(struct ahci_channel *ch, uint32_t istatus) { - device_t dev = ch->dev; uint32_t cstatus, serr = 0, sntf = 0, ok, err; enum ahci_err_type et; int i, ccs, port, reset = 0; @@ -1196,12 +1209,12 @@ ahci_ch_intr_main(struct ahci_channel *ch, uint32_t istatus) serr = ATA_INL(ch->r_mem, AHCI_P_SERR); if (serr) { ATA_OUTL(ch->r_mem, AHCI_P_SERR, serr); - reset = ahci_phy_check_events(dev, serr); + reset = ahci_phy_check_events(ch, serr); } } /* Process cold presence detection events */ if ((istatus & AHCI_P_IX_CPD) && !reset) - ahci_cpd_check_events(dev); + ahci_cpd_check_events(ch); /* Process command errors */ if (istatus & (AHCI_P_IX_OF | AHCI_P_IX_IF | AHCI_P_IX_HBD | AHCI_P_IX_HBF | AHCI_P_IX_TFE)) { @@ -1296,14 +1309,13 @@ ahci_ch_intr_main(struct ahci_channel *ch, uint32_t istatus) } /* Process NOTIFY events */ if (sntf) - ahci_notify_events(dev, sntf); + ahci_notify_events(ch, sntf); } /* Must be called with channel locked. */ static int -ahci_check_collision(device_t dev, union ccb *ccb) +ahci_check_collision(struct ahci_channel *ch, union ccb *ccb) { - struct ahci_channel *ch = device_get_softc(dev); int t = ccb->ccb_h.target_id; if ((ccb->ccb_h.func_code == XPT_ATA_IO) && @@ -1352,9 +1364,8 @@ ahci_check_collision(device_t dev, union ccb *ccb) /* Must be called with channel locked. */ static void -ahci_begin_transaction(device_t dev, union ccb *ccb) +ahci_begin_transaction(struct ahci_channel *ch, union ccb *ccb) { - struct ahci_channel *ch = device_get_softc(dev); struct ahci_slot *slot; int tag, tags; @@ -1363,14 +1374,14 @@ ahci_begin_transaction(device_t dev, union ccb *ccb) if ((ccb->ccb_h.func_code == XPT_ATA_IO) && (ccb->ataio.cmd.flags & CAM_ATAIO_FPDMA)) tags = ch->curr[ccb->ccb_h.target_id].tags; - tag = ch->lastslot; - while (1) { - if (tag >= tags) - tag = 0; - if (ch->slot[tag].state == AHCI_SLOT_EMPTY) - break; - tag++; - }; + if (ch->lastslot + 1 < tags) + tag = ffs(~(ch->oslots >> (ch->lastslot + 1))); + else + tag = 0; + if (tag == 0 || tag + ch->lastslot >= tags) + tag = ffs(~ch->oslots) - 1; + else + tag += ch->lastslot; ch->lastslot = tag; /* Occupy chosen slot. */ slot = &ch->slot[tag]; @@ -1379,7 +1390,7 @@ ahci_begin_transaction(device_t dev, union ccb *ccb) if (ch->numrslots == 0 && ch->pm_level > 3) callout_stop(&ch->pm_timer); /* Update channel stats. */ - ch->oslots |= (1 << slot->slot); + ch->oslots |= (1 << tag); ch->numrslots++; ch->numrslotspd[ccb->ccb_h.target_id]++; if ((ccb->ccb_h.func_code == XPT_ATA_IO) && @@ -1390,14 +1401,15 @@ ahci_begin_transaction(device_t dev, union ccb *ccb) } if ((ccb->ccb_h.func_code == XPT_ATA_IO) && (ccb->ataio.cmd.flags & (CAM_ATAIO_CONTROL | CAM_ATAIO_NEEDRESULT))) - ch->aslots |= (1 << slot->slot); - slot->dma.nsegs = 0; + ch->aslots |= (1 << tag); if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { slot->state = AHCI_SLOT_LOADING; bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, ccb, ahci_dmasetprd, slot, 0); - } else + } else { + slot->dma.nsegs = 0; ahci_execute_transaction(slot); + } } /* Locked by busdma engine. */ @@ -1405,13 +1417,13 @@ static void ahci_dmasetprd(void *arg, bus_dma_segment_t *segs, int nsegs, int error) { struct ahci_slot *slot = arg; - struct ahci_channel *ch = device_get_softc(slot->dev); + struct ahci_channel *ch = slot->ch; struct ahci_cmd_tab *ctp; struct ahci_dma_prd *prd; int i; if (error) { - device_printf(slot->dev, "DMA load error\n"); + device_printf(ch->dev, "DMA load error\n"); ahci_end_transaction(slot, AHCI_ERR_INVALID); return; } @@ -1436,8 +1448,7 @@ ahci_dmasetprd(void *arg, bus_dma_segment_t *segs, int nsegs, int error) static void ahci_execute_transaction(struct ahci_slot *slot) { - device_t dev = slot->dev; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = slot->ch; struct ahci_cmd_tab *ctp; struct ahci_cmd_list *clp; union ccb *ccb = slot->ccb; @@ -1450,7 +1461,7 @@ ahci_execute_transaction(struct ahci_slot *slot) ctp = (struct ahci_cmd_tab *) (ch->dma.work + AHCI_CT_OFFSET + (AHCI_CT_SIZE * slot->slot)); /* Setup the FIS for this request */ - if (!(fis_size = ahci_setup_fis(dev, ctp, ccb, slot->slot))) { + if (!(fis_size = ahci_setup_fis(ch, ctp, ccb, slot->slot))) { device_printf(ch->dev, "Setting up SATA FIS failed\n"); ahci_end_transaction(slot, AHCI_ERR_INVALID); return; @@ -1471,9 +1482,9 @@ ahci_execute_transaction(struct ahci_slot *slot) if (ccb->ataio.cmd.control & ATA_A_RESET) { softreset = 1; /* Kick controller into sane state */ - ahci_stop(dev); - ahci_clo(dev); - ahci_start(dev, 0); + ahci_stop(ch); + ahci_clo(ch); + ahci_start(ch, 0); clp->cmd_flags |= AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY; } else { softreset = 2; @@ -1533,9 +1544,16 @@ ahci_execute_transaction(struct ahci_slot *slot) } } - /* Marvell controllers do not wait for readyness. */ - if ((ch->quirks & AHCI_Q_NOBSYRES) && softreset == 2 && - et == AHCI_ERR_NONE) { + /* + * Marvell HBAs with non-RAID firmware do not wait for + * readiness after soft reset, so we have to wait here. + * Marvell RAIDs do not have this problem, but instead + * sometimes forget to update FIS receive area, breaking + * this wait. + */ + if ((ch->quirks & AHCI_Q_NOBSYRES) == 0 && + (ch->quirks & AHCI_Q_ATI_PMP_BUG) == 0 && + softreset == 2 && et == AHCI_ERR_NONE) { while ((val = fis[2]) & ATA_S_BUSY) { DELAY(10); if (count++ >= timeout) @@ -1544,9 +1562,9 @@ ahci_execute_transaction(struct ahci_slot *slot) } if (timeout && (count >= timeout)) { - device_printf(dev, "Poll timeout on slot %d port %d\n", + device_printf(ch->dev, "Poll timeout on slot %d port %d\n", slot->slot, port); - device_printf(dev, "is %08x cs %08x ss %08x " + device_printf(ch->dev, "is %08x cs %08x ss %08x " "rs %08x tfd %02x serr %08x cmd %08x\n", ATA_INL(ch->r_mem, AHCI_P_IS), ATA_INL(ch->r_mem, AHCI_P_CI), @@ -1571,9 +1589,8 @@ ahci_execute_transaction(struct ahci_slot *slot) /* Must be called with channel locked. */ static void -ahci_process_timeout(device_t dev) +ahci_process_timeout(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); int i; mtx_assert(&ch->mtx, MA_OWNED); @@ -1588,9 +1605,8 @@ ahci_process_timeout(device_t dev) /* Must be called with channel locked. */ static void -ahci_rearm_timeout(device_t dev) +ahci_rearm_timeout(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); int i; mtx_assert(&ch->mtx, MA_OWNED); @@ -1612,8 +1628,8 @@ ahci_rearm_timeout(device_t dev) static void ahci_timeout(struct ahci_slot *slot) { - device_t dev = slot->dev; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = slot->ch; + device_t dev = ch->dev; uint32_t sstatus; int ccs; int i; @@ -1680,7 +1696,7 @@ ahci_timeout(struct ahci_slot *slot) xpt_freeze_simq(ch->sim, 1); ch->toslots |= (1 << slot->slot); if ((ch->rslots & ~ch->toslots) == 0) - ahci_process_timeout(dev); + ahci_process_timeout(ch); else device_printf(dev, " ... waiting for slots %08x\n", ch->rslots & ~ch->toslots); @@ -1691,8 +1707,7 @@ ahci_timeout(struct ahci_slot *slot) static void ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et) { - device_t dev = slot->dev; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = slot->ch; union ccb *ccb = slot->ccb; struct ahci_cmd_list *clp; int lastto; @@ -1850,15 +1865,15 @@ ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et) (ccb->ataio.cmd.control & ATA_A_RESET) && et == AHCI_ERR_NONE) { ccb->ataio.cmd.control &= ~ATA_A_RESET; - ahci_begin_transaction(dev, ccb); + ahci_begin_transaction(ch, ccb); return; } /* If it was our READ LOG command - process it. */ if (ccb->ccb_h.recovery_type == RECOVERY_READ_LOG) { - ahci_process_read_log(dev, ccb); + ahci_process_read_log(ch, ccb); /* If it was our REQUEST SENSE command - process it. */ } else if (ccb->ccb_h.recovery_type == RECOVERY_REQUEST_SENSE) { - ahci_process_request_sense(dev, ccb); + ahci_process_request_sense(ch, ccb); /* If it was NCQ or ATAPI command error, put result on hold. */ } else if (et == AHCI_ERR_NCQ || ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR && @@ -1871,27 +1886,27 @@ ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et) if (ch->rslots == 0) { /* if there was fatal error - reset port. */ if (ch->toslots != 0 || ch->fatalerr) { - ahci_reset(dev); + ahci_reset(ch); } else { /* if we have slots in error, we can reinit port. */ if (ch->eslots != 0) { - ahci_stop(dev); - ahci_clo(dev); - ahci_start(dev, 1); + ahci_stop(ch); + ahci_clo(ch); + ahci_start(ch, 1); } /* if there commands on hold, we can do READ LOG. */ if (!ch->recoverycmd && ch->numhslots) - ahci_issue_recovery(dev); + ahci_issue_recovery(ch); } /* If all the rest of commands are in timeout - give them chance. */ } else if ((ch->rslots & ~ch->toslots) == 0 && et != AHCI_ERR_TIMEOUT) - ahci_rearm_timeout(dev); + ahci_rearm_timeout(ch); /* Unfreeze frozen command. */ - if (ch->frozen && !ahci_check_collision(dev, ch->frozen)) { + if (ch->frozen && !ahci_check_collision(ch, ch->frozen)) { union ccb *fccb = ch->frozen; ch->frozen = NULL; - ahci_begin_transaction(dev, fccb); + ahci_begin_transaction(ch, fccb); xpt_release_simq(ch->sim, TRUE); } /* Start PM timer. */ @@ -1903,9 +1918,8 @@ ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et) } static void -ahci_issue_recovery(device_t dev) +ahci_issue_recovery(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); union ccb *ccb; struct ccb_ataio *ataio; struct ccb_scsiio *csio; @@ -1918,7 +1932,7 @@ ahci_issue_recovery(device_t dev) } ccb = xpt_alloc_ccb_nowait(); if (ccb == NULL) { - device_printf(dev, "Unable to allocate recovery command\n"); + device_printf(ch->dev, "Unable to allocate recovery command\n"); completeall: /* We can't do anything -- complete held commands. */ for (i = 0; i < ch->numslots; i++) { @@ -1930,7 +1944,7 @@ ahci_issue_recovery(device_t dev) ch->hold[i] = NULL; ch->numhslots--; } - ahci_reset(dev); + ahci_reset(ch); return; } ccb->ccb_h = ch->hold[i]->ccb_h; /* Reuse old header. */ @@ -1944,7 +1958,7 @@ ahci_issue_recovery(device_t dev) ataio->data_ptr = malloc(512, M_AHCI, M_NOWAIT); if (ataio->data_ptr == NULL) { xpt_free_ccb(ccb); - device_printf(dev, + device_printf(ch->dev, "Unable to allocate memory for READ LOG command\n"); goto completeall; } @@ -1976,13 +1990,12 @@ ahci_issue_recovery(device_t dev) /* Freeze SIM while doing recovery. */ ch->recoverycmd = 1; xpt_freeze_simq(ch->sim, 1); - ahci_begin_transaction(dev, ccb); + ahci_begin_transaction(ch, ccb); } static void -ahci_process_read_log(device_t dev, union ccb *ccb) +ahci_process_read_log(struct ahci_channel *ch, union ccb *ccb) { - struct ahci_channel *ch = device_get_softc(dev); uint8_t *data; struct ata_res *res; int i; @@ -2020,9 +2033,9 @@ ahci_process_read_log(device_t dev, union ccb *ccb) } } else { if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) - device_printf(dev, "Error while READ LOG EXT\n"); + device_printf(ch->dev, "Error while READ LOG EXT\n"); else if ((data[0] & 0x80) == 0) { - device_printf(dev, "Non-queued command error in READ LOG EXT\n"); + device_printf(ch->dev, "Non-queued command error in READ LOG EXT\n"); } for (i = 0; i < ch->numslots; i++) { if (!ch->hold[i]) @@ -2040,9 +2053,8 @@ ahci_process_read_log(device_t dev, union ccb *ccb) } static void -ahci_process_request_sense(device_t dev, union ccb *ccb) +ahci_process_request_sense(struct ahci_channel *ch, union ccb *ccb) { - struct ahci_channel *ch = device_get_softc(dev); int i; ch->recoverycmd = 0; @@ -2062,9 +2074,8 @@ ahci_process_request_sense(device_t dev, union ccb *ccb) } static void -ahci_start(device_t dev, int fbs) +ahci_start(struct ahci_channel *ch, int fbs) { - struct ahci_channel *ch = device_get_softc(dev); u_int32_t cmd; /* Clear SATA error register */ @@ -2085,9 +2096,8 @@ ahci_start(device_t dev, int fbs) } static void -ahci_stop(device_t dev) +ahci_stop(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); u_int32_t cmd; int timeout; @@ -2099,7 +2109,7 @@ ahci_stop(device_t dev) do { DELAY(10); if (timeout++ > 50000) { - device_printf(dev, "stopping AHCI engine failed\n"); + device_printf(ch->dev, "stopping AHCI engine failed\n"); break; } } while (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CR); @@ -2107,9 +2117,8 @@ ahci_stop(device_t dev) } static void -ahci_clo(device_t dev) +ahci_clo(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); u_int32_t cmd; int timeout; @@ -2122,7 +2131,7 @@ ahci_clo(device_t dev) do { DELAY(10); if (timeout++ > 50000) { - device_printf(dev, "executing CLO failed\n"); + device_printf(ch->dev, "executing CLO failed\n"); break; } } while (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CLO); @@ -2130,9 +2139,8 @@ ahci_clo(device_t dev) } static void -ahci_stop_fr(device_t dev) +ahci_stop_fr(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); u_int32_t cmd; int timeout; @@ -2144,16 +2152,15 @@ ahci_stop_fr(device_t dev) do { DELAY(10); if (timeout++ > 50000) { - device_printf(dev, "stopping AHCI FR engine failed\n"); + device_printf(ch->dev, "stopping AHCI FR engine failed\n"); break; } } while (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_FR); } static void -ahci_start_fr(device_t dev) +ahci_start_fr(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); u_int32_t cmd; /* Start FIS reception on this channel */ @@ -2162,9 +2169,8 @@ ahci_start_fr(device_t dev) } static int -ahci_wait_ready(device_t dev, int t, int t0) +ahci_wait_ready(struct ahci_channel *ch, int t, int t0) { - struct ahci_channel *ch = device_get_softc(dev); int timeout = 0; uint32_t val; @@ -2172,7 +2178,7 @@ ahci_wait_ready(device_t dev, int t, int t0) (ATA_S_BUSY | ATA_S_DRQ)) { if (timeout > t) { if (t != 0) { - device_printf(dev, + device_printf(ch->dev, "AHCI reset: device not ready after %dms " "(tfd = %08x)\n", MAX(t, 0) + t0, val); @@ -2183,7 +2189,7 @@ ahci_wait_ready(device_t dev, int t, int t0) timeout++; } if (bootverbose) - device_printf(dev, "AHCI reset: device ready after %dms\n", + device_printf(ch->dev, "AHCI reset: device ready after %dms\n", timeout + t0); return (0); } @@ -2191,22 +2197,21 @@ ahci_wait_ready(device_t dev, int t, int t0) static void ahci_reset_to(void *arg) { - device_t dev = arg; - struct ahci_channel *ch = device_get_softc(dev); + struct ahci_channel *ch = arg; if (ch->resetting == 0) return; ch->resetting--; - if (ahci_wait_ready(dev, ch->resetting == 0 ? -1 : 0, + if (ahci_wait_ready(ch, ch->resetting == 0 ? -1 : 0, (310 - ch->resetting) * 100) == 0) { ch->resetting = 0; - ahci_start(dev, 1); + ahci_start(ch, 1); xpt_release_simq(ch->sim, TRUE); return; } if (ch->resetting == 0) { - ahci_clo(dev); - ahci_start(dev, 1); + ahci_clo(ch); + ahci_start(ch, 1); xpt_release_simq(ch->sim, TRUE); return; } @@ -2214,15 +2219,14 @@ ahci_reset_to(void *arg) } static void -ahci_reset(device_t dev) +ahci_reset(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); - struct ahci_controller *ctlr = device_get_softc(device_get_parent(dev)); + struct ahci_controller *ctlr = device_get_softc(device_get_parent(ch->dev)); int i; xpt_freeze_simq(ch->sim, 1); if (bootverbose) - device_printf(dev, "AHCI reset...\n"); + device_printf(ch->dev, "AHCI reset...\n"); /* Forget about previous reset. */ if (ch->resetting) { ch->resetting = 0; @@ -2241,7 +2245,7 @@ ahci_reset(device_t dev) ahci_done(ch, fccb); } /* Kill the engine and requeue all running commands. */ - ahci_stop(dev); + ahci_stop(ch); for (i = 0; i < ch->numslots; i++) { /* Do we have a running request on slot? */ if (ch->slot[i].state < AHCI_SLOT_RUNNING) @@ -2267,9 +2271,9 @@ ahci_reset(device_t dev) /* Disable port interrupts */ ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); /* Reset and reconnect PHY, */ - if (!ahci_sata_phy_reset(dev)) { + if (!ahci_sata_phy_reset(ch)) { if (bootverbose) - device_printf(dev, + device_printf(ch->dev, "AHCI reset: device not found\n"); ch->devices = 0; /* Enable wanted port interrupts */ @@ -2280,11 +2284,11 @@ ahci_reset(device_t dev) return; } if (bootverbose) - device_printf(dev, "AHCI reset: device found\n"); + device_printf(ch->dev, "AHCI reset: device found\n"); /* Wait for clearing busy status. */ - if (ahci_wait_ready(dev, dumping ? 31000 : 0, 0)) { + if (ahci_wait_ready(ch, dumping ? 31000 : 0, 0)) { if (dumping) - ahci_clo(dev); + ahci_clo(ch); else ch->resetting = 310; } @@ -2298,17 +2302,16 @@ ahci_reset(device_t dev) AHCI_P_IX_DP | AHCI_P_IX_UF | (ctlr->ccc ? 0 : AHCI_P_IX_SDB) | AHCI_P_IX_DS | AHCI_P_IX_PS | (ctlr->ccc ? 0 : AHCI_P_IX_DHR))); if (ch->resetting) - callout_reset(&ch->reset_timer, hz / 10, ahci_reset_to, dev); + callout_reset(&ch->reset_timer, hz / 10, ahci_reset_to, ch); else { - ahci_start(dev, 1); + ahci_start(ch, 1); xpt_release_simq(ch->sim, TRUE); } } static int -ahci_setup_fis(device_t dev, struct ahci_cmd_tab *ctp, union ccb *ccb, int tag) +ahci_setup_fis(struct ahci_channel *ch, struct ahci_cmd_tab *ctp, union ccb *ccb, int tag) { - struct ahci_channel *ch = device_get_softc(dev); u_int8_t *fis = &ctp->cfis[0]; bzero(fis, 20); @@ -2400,9 +2403,8 @@ ahci_sata_connect(struct ahci_channel *ch) } static int -ahci_sata_phy_reset(device_t dev) +ahci_sata_phy_reset(struct ahci_channel *ch) { - struct ahci_channel *ch = device_get_softc(dev); int sata_rev; uint32_t val; @@ -2442,9 +2444,8 @@ ahci_sata_phy_reset(device_t dev) } static int -ahci_check_ids(device_t dev, union ccb *ccb) +ahci_check_ids(struct ahci_channel *ch, union ccb *ccb) { - struct ahci_channel *ch = device_get_softc(dev); if (ccb->ccb_h.target_id > ((ch->caps & AHCI_CAP_SPM) ? 15 : 0)) { ccb->ccb_h.status = CAM_TID_INVALID; @@ -2462,19 +2463,17 @@ ahci_check_ids(device_t dev, union ccb *ccb) static void ahciaction(struct cam_sim *sim, union ccb *ccb) { - device_t dev, parent; struct ahci_channel *ch; CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("ahciaction func_code=%x\n", ccb->ccb_h.func_code)); ch = (struct ahci_channel *)cam_sim_softc(sim); - dev = ch->dev; switch (ccb->ccb_h.func_code) { /* Common cases first */ case XPT_ATA_IO: /* Execute the requested I/O operation */ case XPT_SCSI_IO: - if (ahci_check_ids(dev, ccb)) + if (ahci_check_ids(ch, ccb)) return; if (ch->devices == 0 || (ch->pm_present == 0 && @@ -2484,14 +2483,14 @@ ahciaction(struct cam_sim *sim, union ccb *ccb) } ccb->ccb_h.recovery_type = RECOVERY_NONE; /* Check for command collision. */ - if (ahci_check_collision(dev, ccb)) { + if (ahci_check_collision(ch, ccb)) { /* Freeze command. */ ch->frozen = ccb; /* We have only one frozen slot, so freeze simq also. */ xpt_freeze_simq(ch->sim, 1); return; } - ahci_begin_transaction(dev, ccb); + ahci_begin_transaction(ch, ccb); return; case XPT_EN_LUN: /* Enable LUN as a target */ case XPT_TARGET_IO: /* Execute target I/O request */ @@ -2506,7 +2505,7 @@ ahciaction(struct cam_sim *sim, union ccb *ccb) struct ccb_trans_settings *cts = &ccb->cts; struct ahci_device *d; - if (ahci_check_ids(dev, ccb)) + if (ahci_check_ids(ch, ccb)) return; if (cts->type == CTS_TYPE_CURRENT_SETTINGS) d = &ch->curr[ccb->ccb_h.target_id]; @@ -2536,7 +2535,7 @@ ahciaction(struct cam_sim *sim, union ccb *ccb) struct ahci_device *d; uint32_t status; - if (ahci_check_ids(dev, ccb)) + if (ahci_check_ids(ch, ccb)) return; if (cts->type == CTS_TYPE_CURRENT_SETTINGS) d = &ch->curr[ccb->ccb_h.target_id]; @@ -2593,7 +2592,7 @@ ahciaction(struct cam_sim *sim, union ccb *ccb) } case XPT_RESET_BUS: /* Reset the specified SCSI bus */ case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */ - ahci_reset(dev); + ahci_reset(ch); ccb->ccb_h.status = CAM_REQ_CMP; break; case XPT_TERM_IO: /* Terminate the I/O process */ @@ -2604,7 +2603,6 @@ ahciaction(struct cam_sim *sim, union ccb *ccb) { struct ccb_pathinq *cpi = &ccb->cpi; - parent = device_get_parent(dev); cpi->version_num = 1; /* XXX??? */ cpi->hba_inquiry = PI_SDTR_ABLE; if (ch->caps & AHCI_CAP_SNCQ) @@ -2661,7 +2659,7 @@ ahcipoll(struct cam_sim *sim) if (ch->resetting != 0 && (--ch->resetpolldiv <= 0 || !callout_pending(&ch->reset_timer))) { ch->resetpolldiv = 1000; - ahci_reset_to(ch->dev); + ahci_reset_to(ch); } } MODULE_VERSION(ahci, 1); diff --git a/sys/dev/ahci/ahci.h b/sys/dev/ahci/ahci.h index 15d87a2d47ee..f5a3ca8cd98d 100644 --- a/sys/dev/ahci/ahci.h +++ b/sys/dev/ahci/ahci.h @@ -375,7 +375,7 @@ enum ahci_slot_states { }; struct ahci_slot { - device_t dev; /* Device handle */ + struct ahci_channel *ch; /* Channel */ u_int8_t slot; /* Number of this slot */ enum ahci_slot_states state; /* Slot state */ union ccb *ccb; /* CCB occupying slot */ @@ -422,20 +422,19 @@ struct ahci_channel { int quirks; int numslots; /* Number of present slots */ int pm_level; /* power management level */ - - struct ahci_slot slot[AHCI_MAX_SLOTS]; - union ccb *hold[AHCI_MAX_SLOTS]; - struct mtx mtx; /* state lock */ - STAILQ_HEAD(, ccb_hdr) doneq; /* queue of completed CCBs */ - int batch; /* doneq is in use */ int devices; /* What is present */ int pm_present; /* PM presence reported */ int fbs_enabled; /* FIS-based switching enabled */ + + union ccb *hold[AHCI_MAX_SLOTS]; + struct ahci_slot slot[AHCI_MAX_SLOTS]; uint32_t oslots; /* Occupied slots */ uint32_t rslots; /* Running slots */ uint32_t aslots; /* Slots with atomic commands */ uint32_t eslots; /* Slots in error */ uint32_t toslots; /* Slots in timeout */ + int lastslot; /* Last used slot */ + int taggedtarget; /* Last tagged target */ int numrslots; /* Number of running slots */ int numrslotspd[16];/* Number of running slots per dev */ int numtslots; /* Number of tagged slots */ @@ -443,8 +442,6 @@ struct ahci_channel { int numhslots; /* Number of held slots */ int recoverycmd; /* Our READ LOG active */ int fatalerr; /* Fatal error happend */ - int lastslot; /* Last used slot */ - int taggedtarget; /* Last tagged target */ int resetting; /* Hard-reset in progress. */ int resetpolldiv; /* Hard-reset poll divider. */ int listening; /* SUD bit is cleared. */ @@ -455,6 +452,10 @@ struct ahci_channel { struct ahci_device user[16]; /* User-specified settings */ struct ahci_device curr[16]; /* Current settings */ + + struct mtx_padalign mtx; /* state lock */ + STAILQ_HEAD(, ccb_hdr) doneq; /* queue of completed CCBs */ + int batch; /* doneq is in use */ }; struct ahci_enclosure { diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c index 1c01a1e469a4..7b05d8406f63 100644 --- a/sys/dev/ahci/ahci_pci.c +++ b/sys/dev/ahci/ahci_pci.c @@ -179,31 +179,31 @@ static struct { AHCI_Q_EDGEIS | AHCI_Q_NONCQ | AHCI_Q_NOCOUNT}, {0x614511ab, 0x00, "Marvell 88SE6145", AHCI_Q_NOFORCE | AHCI_Q_4CH | AHCI_Q_EDGEIS | AHCI_Q_NONCQ | AHCI_Q_NOCOUNT}, - {0x91201b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_NOBSYRES}, - {0x91231b4b, 0x11, "Marvell 88SE912x", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, - {0x91231b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_SATA2|AHCI_Q_NOBSYRES}, - {0x91251b4b, 0x00, "Marvell 88SE9125", AHCI_Q_NOBSYRES}, - {0x91281b4b, 0x00, "Marvell 88SE9128", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, - {0x91301b4b, 0x00, "Marvell 88SE9130", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, - {0x91721b4b, 0x00, "Marvell 88SE9172", AHCI_Q_NOBSYRES}, - {0x91821b4b, 0x00, "Marvell 88SE9182", AHCI_Q_NOBSYRES}, - {0x91831b4b, 0x00, "Marvell 88SS9183", AHCI_Q_NOBSYRES}, - {0x91a01b4b, 0x00, "Marvell 88SE91Ax", AHCI_Q_NOBSYRES}, - {0x92151b4b, 0x00, "Marvell 88SE9215", AHCI_Q_NOBSYRES}, - {0x92201b4b, 0x00, "Marvell 88SE9220", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, - {0x92301b4b, 0x00, "Marvell 88SE9230", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, - {0x92351b4b, 0x00, "Marvell 88SE9235", AHCI_Q_NOBSYRES}, - {0x06201103, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, - {0x06201b4b, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, - {0x06221103, 0x00, "HighPoint RocketRAID 622", AHCI_Q_NOBSYRES}, - {0x06221b4b, 0x00, "HighPoint RocketRAID 622", AHCI_Q_NOBSYRES}, - {0x06401103, 0x00, "HighPoint RocketRAID 640", AHCI_Q_NOBSYRES}, - {0x06401b4b, 0x00, "HighPoint RocketRAID 640", AHCI_Q_NOBSYRES}, - {0x06441103, 0x00, "HighPoint RocketRAID 644", AHCI_Q_NOBSYRES}, - {0x06441b4b, 0x00, "HighPoint RocketRAID 644", AHCI_Q_NOBSYRES}, - {0x06411103, 0x00, "HighPoint RocketRAID 640L", AHCI_Q_NOBSYRES}, - {0x06421103, 0x00, "HighPoint RocketRAID 642L", AHCI_Q_NOBSYRES}, - {0x06451103, 0x00, "HighPoint RocketRAID 644L", AHCI_Q_NOBSYRES}, + {0x91201b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS}, + {0x91231b4b, 0x11, "Marvell 88SE912x", AHCI_Q_ALTSIG}, + {0x91231b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_SATA2}, + {0x91251b4b, 0x00, "Marvell 88SE9125", 0}, + {0x91281b4b, 0x00, "Marvell 88SE9128", AHCI_Q_ALTSIG}, + {0x91301b4b, 0x00, "Marvell 88SE9130", AHCI_Q_ALTSIG}, + {0x91721b4b, 0x00, "Marvell 88SE9172", 0}, + {0x91821b4b, 0x00, "Marvell 88SE9182", 0}, + {0x91831b4b, 0x00, "Marvell 88SS9183", 0}, + {0x91a01b4b, 0x00, "Marvell 88SE91Ax", 0}, + {0x92151b4b, 0x00, "Marvell 88SE9215", 0}, + {0x92201b4b, 0x00, "Marvell 88SE9220", AHCI_Q_ALTSIG}, + {0x92301b4b, 0x00, "Marvell 88SE9230", AHCI_Q_ALTSIG}, + {0x92351b4b, 0x00, "Marvell 88SE9235", 0}, + {0x06201103, 0x00, "HighPoint RocketRAID 620", 0}, + {0x06201b4b, 0x00, "HighPoint RocketRAID 620", 0}, + {0x06221103, 0x00, "HighPoint RocketRAID 622", 0}, + {0x06221b4b, 0x00, "HighPoint RocketRAID 622", 0}, + {0x06401103, 0x00, "HighPoint RocketRAID 640", 0}, + {0x06401b4b, 0x00, "HighPoint RocketRAID 640", 0}, + {0x06441103, 0x00, "HighPoint RocketRAID 644", 0}, + {0x06441b4b, 0x00, "HighPoint RocketRAID 644", 0}, + {0x06411103, 0x00, "HighPoint RocketRAID 640L", 0}, + {0x06421103, 0x00, "HighPoint RocketRAID 642L", 0}, + {0x06451103, 0x00, "HighPoint RocketRAID 644L", 0}, {0x044c10de, 0x00, "NVIDIA MCP65", AHCI_Q_NOAA}, {0x044d10de, 0x00, "NVIDIA MCP65", AHCI_Q_NOAA}, {0x044e10de, 0x00, "NVIDIA MCP65", AHCI_Q_NOAA}, @@ -273,6 +273,7 @@ static struct { {0x0d8d10de, 0x00, "NVIDIA MCP89", AHCI_Q_NOAA}, {0x0d8e10de, 0x00, "NVIDIA MCP89", AHCI_Q_NOAA}, {0x0d8f10de, 0x00, "NVIDIA MCP89", AHCI_Q_NOAA}, + {0x3781105a, 0x00, "Promise TX8660", 0}, {0x33491106, 0x00, "VIA VT8251", AHCI_Q_NOPMP|AHCI_Q_NONCQ}, {0x62871106, 0x00, "VIA VT8251", AHCI_Q_NOPMP|AHCI_Q_NONCQ}, {0x11841039, 0x00, "SiS 966", 0}, @@ -417,13 +418,6 @@ ahci_pci_attach(device_t dev) ctlr->numirqs = 1; } - if (ahci_setup_interrupt(dev)) { - if (ctlr->msi) - pci_release_msi(dev); - bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem); - return ENXIO; - } - error = ahci_attach(dev); if (error != 0) if (ctlr->msi) diff --git a/sys/dev/ahci/ahciem.c b/sys/dev/ahci/ahciem.c index 8785a7800e40..94185eed253e 100644 --- a/sys/dev/ahci/ahciem.c +++ b/sys/dev/ahci/ahciem.c @@ -344,7 +344,7 @@ ahci_em_led(void *priv, int onoff) } static int -ahci_check_ids(device_t dev, union ccb *ccb) +ahci_check_ids(union ccb *ccb) { if (ccb->ccb_h.target_id != 0) { @@ -554,7 +554,7 @@ ahciemaction(struct cam_sim *sim, union ccb *ccb) dev = enc->dev; switch (ccb->ccb_h.func_code) { case XPT_ATA_IO: /* Execute the requested I/O operation */ - if (ahci_check_ids(dev, ccb)) + if (ahci_check_ids(ccb)) return; ahci_em_begin_transaction(dev, ccb); return; diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index 3f661fdefb7b..ecb3b47d11c8 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -2323,13 +2323,13 @@ alc_watchdog(struct alc_softc *sc) ifp = sc->alc_ifp; if ((sc->alc_flags & ALC_FLAG_LINK) == 0) { if_printf(sc->alc_ifp, "watchdog timeout (lost link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; alc_init_locked(sc); return; } if_printf(sc->alc_ifp, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; alc_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -2608,11 +2608,11 @@ alc_stats_update(struct alc_softc *sc) stat->tx_mcast_bytes += smb->tx_mcast_bytes; /* Update counters in ifnet. */ - ifp->if_opackets += smb->tx_frames; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, smb->tx_frames); - ifp->if_collisions += smb->tx_single_colls + + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, smb->tx_single_colls + smb->tx_multi_colls * 2 + smb->tx_late_colls + - smb->tx_abort * HDPX_CFG_RETRY_DEFAULT; + smb->tx_abort * HDPX_CFG_RETRY_DEFAULT); /* * XXX @@ -2621,15 +2621,16 @@ alc_stats_update(struct alc_softc *sc) * the counter name is not correct one so I've removed the * counter in output errors. */ - ifp->if_oerrors += smb->tx_abort + smb->tx_late_colls + - smb->tx_underrun; + if_inc_counter(ifp, IFCOUNTER_OERRORS, + smb->tx_abort + smb->tx_late_colls + smb->tx_underrun); - ifp->if_ipackets += smb->rx_frames; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, smb->rx_frames); - ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs + + if_inc_counter(ifp, IFCOUNTER_IERRORS, + smb->rx_crcerrs + smb->rx_lenerrs + smb->rx_runts + smb->rx_pkts_truncated + smb->rx_fifo_oflows + smb->rx_rrs_errs + - smb->rx_alignerrs; + smb->rx_alignerrs); if ((sc->alc_flags & ALC_FLAG_SMB_BUG) == 0) { /* Update done, clear. */ @@ -2921,7 +2922,7 @@ alc_fixup_rx(struct ifnet *ifp, struct mbuf *m) */ MGETHDR(n, M_NOWAIT, MT_DATA); if (n == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); m_freem(m); return (NULL); } @@ -2977,7 +2978,7 @@ alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd) mp = rxd->rx_m; /* Add a new receive buffer to the ring. */ if (alc_newbuf(sc, rxd) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* Reuse Rx buffers. */ if (sc->alc_cdata.alc_rxhead != NULL) m_freem(sc->alc_cdata.alc_rxhead); diff --git a/sys/dev/ale/if_ale.c b/sys/dev/ale/if_ale.c index 0b21cf595af7..78dfa0e40b2e 100644 --- a/sys/dev/ale/if_ale.c +++ b/sys/dev/ale/if_ale.c @@ -1953,13 +1953,13 @@ ale_watchdog(struct ale_softc *sc) ifp = sc->ale_ifp; if ((sc->ale_flags & ALE_FLAG_LINK) == 0) { if_printf(sc->ale_ifp, "watchdog timeout (lost link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ale_init_locked(sc); return; } if_printf(sc->ale_ifp, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ale_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -2206,11 +2206,11 @@ ale_stats_update(struct ale_softc *sc) stat->tx_mcast_bytes += smb->tx_mcast_bytes; /* Update counters in ifnet. */ - ifp->if_opackets += smb->tx_frames; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, smb->tx_frames); - ifp->if_collisions += smb->tx_single_colls + + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, smb->tx_single_colls + smb->tx_multi_colls * 2 + smb->tx_late_colls + - smb->tx_abort * HDPX_CFG_RETRY_DEFAULT; + smb->tx_abort * HDPX_CFG_RETRY_DEFAULT); /* * XXX @@ -2219,15 +2219,16 @@ ale_stats_update(struct ale_softc *sc) * the counter name is not correct one so I've removed the * counter in output errors. */ - ifp->if_oerrors += smb->tx_abort + smb->tx_late_colls + - smb->tx_underrun; + if_inc_counter(ifp, IFCOUNTER_OERRORS, + smb->tx_abort + smb->tx_late_colls + smb->tx_underrun); - ifp->if_ipackets += smb->rx_frames; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, smb->rx_frames); - ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs + + if_inc_counter(ifp, IFCOUNTER_IERRORS, + smb->rx_crcerrs + smb->rx_lenerrs + smb->rx_runts + smb->rx_pkts_truncated + smb->rx_fifo_oflows + smb->rx_rrs_errs + - smb->rx_alignerrs; + smb->rx_alignerrs); } static int @@ -2549,7 +2550,7 @@ ale_rxeof(struct ale_softc *sc, int count) m = m_devget((char *)(rs + 1), length - ETHER_CRC_LEN, ETHER_ALIGN, ifp, NULL); if (m == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); ale_rx_update_page(sc, &rx_page, length, &prod); continue; } diff --git a/sys/pci/alpm.c b/sys/dev/alpm/alpm.c similarity index 100% rename from sys/pci/alpm.c rename to sys/dev/alpm/alpm.c diff --git a/sys/dev/altera/atse/a_api.h b/sys/dev/altera/atse/a_api.h index ad34e9ed7a7b..4bd380df6377 100644 --- a/sys/dev/altera/atse/a_api.h +++ b/sys/dev/altera/atse/a_api.h @@ -69,20 +69,20 @@ #define A_ONCHIP_FIFO_MEM_CORE_STATUS_UNDERFLOW (1<<5) /* Table 16-6. Event Bit Field Descriptions. */ -/* XXX Datasheet has weird bit fields. Validate. */ -#define A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY (1<<0) -#define A_ONCHIP_FIFO_MEM_CORE_EVENT_FULL (1<<1) -#define A_ONCHIP_FIFO_MEM_CORE_EVENT_ALMOSTEMPTY (1<<2) -#define A_ONCHIP_FIFO_MEM_CORE_EVENT_ALMOSTFULL (1<<3) +/* XXX Datasheet has incorrect bit fields. Validate. */ +#define A_ONCHIP_FIFO_MEM_CORE_EVENT_FULL (1<<0) +#define A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY (1<<1) +#define A_ONCHIP_FIFO_MEM_CORE_EVENT_ALMOSTFULL (1<<2) +#define A_ONCHIP_FIFO_MEM_CORE_EVENT_ALMOSTEMPTY (1<<3) #define A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW (1<<4) #define A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW (1<<5) /* Table 16-7. InterruptEnable Bit Field Descriptions. */ -/* XXX Datasheet has weird bit fields. Validate. */ -#define A_ONCHIP_FIFO_MEM_CORE_INTR_EMPTY (1<<0) -#define A_ONCHIP_FIFO_MEM_CORE_INTR_FULL (1<<1) -#define A_ONCHIP_FIFO_MEM_CORE_INTR_ALMOSTEMPTY (1<<2) -#define A_ONCHIP_FIFO_MEM_CORE_INTR_ALMOSTFULL (1<<3) +/* XXX Datasheet has incorrect bit fields. Validate. */ +#define A_ONCHIP_FIFO_MEM_CORE_INTR_FULL (1<<0) +#define A_ONCHIP_FIFO_MEM_CORE_INTR_EMPTY (1<<1) +#define A_ONCHIP_FIFO_MEM_CORE_INTR_ALMOSTFULL (1<<2) +#define A_ONCHIP_FIFO_MEM_CORE_INTR_ALMOSTEMPTY (1<<3) #define A_ONCHIP_FIFO_MEM_CORE_INTR_OVERFLOW (1<<4) #define A_ONCHIP_FIFO_MEM_CORE_INTR_UNDERFLOW (1<<5) #define A_ONCHIP_FIFO_MEM_CORE_INTR_ALL \ diff --git a/sys/dev/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c index 64eae9f2d8ab..1c55fbc9666b 100644 --- a/sys/dev/altera/atse/if_atse.c +++ b/sys/dev/altera/atse/if_atse.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2012,2013 Bjoern A. Zeeb + * Copyright (c) 2014 Robert N. M. Watson * All rights reserved. * * This software was developed by SRI International and the University of @@ -103,6 +104,11 @@ static poll_handler_t atse_poll; static int atse_ethernet_option_bits_flag = ATSE_ETHERNET_OPTION_BITS_UNDEF; static uint8_t atse_ethernet_option_bits[ALTERA_ETHERNET_OPTION_BITS_LEN]; +static int atse_intr_debug_enable = 0; +SYSCTL_INT(_debug, OID_AUTO, atse_intr_debug_enable, CTLFLAG_RW, + &atse_intr_debug_enable, 0, + "Extra debugging output for atse interrupts"); + /* * Softc and critical resource locking. */ @@ -110,6 +116,9 @@ static uint8_t atse_ethernet_option_bits[ALTERA_ETHERNET_OPTION_BITS_LEN]; #define ATSE_UNLOCK(_sc) mtx_unlock(&(_sc)->atse_mtx) #define ATSE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->atse_mtx, MA_OWNED) +#define ATSE_TX_PENDING(sc) (sc->atse_tx_m != NULL || \ + !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + #ifdef DEBUG #define DPRINTF(format, ...) printf(format, __VA_ARGS__) #else @@ -169,6 +178,16 @@ a_onchip_fifo_mem_core_read(struct resource *res, uint32_t off, A_ONCHIP_FIFO_MEM_CORE_METADATA, \ "RXM", __func__, __LINE__) +#define ATSE_RX_STATUS_READ(sc) \ + a_onchip_fifo_mem_core_read((sc)->atse_rxc_mem_res, \ + A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_I_STATUS, \ + "RX_EVENT", __func__, __LINE__) + +#define ATSE_TX_STATUS_READ(sc) \ + a_onchip_fifo_mem_core_read((sc)->atse_txc_mem_res, \ + A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_I_STATUS, \ + "TX_EVENT", __func__, __LINE__) + #define ATSE_RX_EVENT_READ(sc) \ a_onchip_fifo_mem_core_read((sc)->atse_rxc_mem_res, \ A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_EVENT, \ @@ -208,24 +227,41 @@ a_onchip_fifo_mem_core_read(struct resource *res, uint32_t off, val4, "TX_EVENT", __func__, __LINE__); \ } while(0) +#define ATSE_RX_EVENTS (A_ONCHIP_FIFO_MEM_CORE_INTR_FULL | \ + A_ONCHIP_FIFO_MEM_CORE_INTR_OVERFLOW | \ + A_ONCHIP_FIFO_MEM_CORE_INTR_UNDERFLOW) #define ATSE_RX_INTR_ENABLE(sc) \ a_onchip_fifo_mem_core_write((sc)->atse_rxc_mem_res, \ A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_INT_ENABLE, \ - A_ONCHIP_FIFO_MEM_CORE_INTR_ALL, \ + ATSE_RX_EVENTS, \ "RX_INTR", __func__, __LINE__) /* XXX-BZ review later. */ #define ATSE_RX_INTR_DISABLE(sc) \ a_onchip_fifo_mem_core_write((sc)->atse_rxc_mem_res, \ A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_INT_ENABLE, 0, \ "RX_INTR", __func__, __LINE__) +#define ATSE_RX_INTR_READ(sc) \ + a_onchip_fifo_mem_core_read((sc)->atse_rxc_mem_res, \ + A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_INT_ENABLE, \ + "RX_INTR", __func__, __LINE__) + +#define ATSE_TX_EVENTS (A_ONCHIP_FIFO_MEM_CORE_INTR_EMPTY | \ + A_ONCHIP_FIFO_MEM_CORE_INTR_OVERFLOW | \ + A_ONCHIP_FIFO_MEM_CORE_INTR_UNDERFLOW) #define ATSE_TX_INTR_ENABLE(sc) \ a_onchip_fifo_mem_core_write((sc)->atse_txc_mem_res, \ A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_INT_ENABLE, \ - A_ONCHIP_FIFO_MEM_CORE_INTR_ALL, \ + ATSE_TX_EVENTS, \ "TX_INTR", __func__, __LINE__) /* XXX-BZ review later. */ #define ATSE_TX_INTR_DISABLE(sc) \ a_onchip_fifo_mem_core_write((sc)->atse_txc_mem_res, \ A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_INT_ENABLE, 0, \ "TX_INTR", __func__, __LINE__) +#define ATSE_TX_INTR_READ(sc) \ + a_onchip_fifo_mem_core_read((sc)->atse_txc_mem_res, \ + A_ONCHIP_FIFO_MEM_CORE_STATUS_REG_INT_ENABLE, \ + "TX_INTR", __func__, __LINE__) + +static int atse_rx_locked(struct atse_softc *sc); /* * Register space access macros. @@ -985,6 +1021,11 @@ atse_init(void *xsc) { struct atse_softc *sc; + /* + * XXXRW: There is some argument that we should immediately do RX + * processing after enabling interrupts, or one may not fire if there + * are buffered packets. + */ sc = (struct atse_softc *)xsc; ATSE_LOCK(sc); atse_init_locked(sc); @@ -1081,6 +1122,33 @@ atse_ioctl(struct ifnet *ifp, u_long command, caddr_t data) return (error); } +static void +atse_intr_debug(struct atse_softc *sc, const char *intrname) +{ + uint32_t rxs, rxe, rxi, rxf, txs, txe, txi, txf; + + if (!atse_intr_debug_enable) + return; + + rxs = ATSE_RX_STATUS_READ(sc); + rxe = ATSE_RX_EVENT_READ(sc); + rxi = ATSE_RX_INTR_READ(sc); + rxf = ATSE_RX_READ_FILL_LEVEL(sc); + + txs = ATSE_TX_STATUS_READ(sc); + txe = ATSE_TX_EVENT_READ(sc); + txi = ATSE_TX_INTR_READ(sc); + txf = ATSE_TX_READ_FILL_LEVEL(sc); + + printf( + "%s - %s: " + "rxs 0x%x rxe 0x%x rxi 0x%x rxf 0x%x " + "txs 0x%x txe 0x%x txi 0x%x txf 0x%x\n", + __func__, intrname, + rxs, rxe, rxi, rxf, + txs, txe, txi, txf); +} + static void atse_watchdog(struct atse_softc *sc) { @@ -1091,11 +1159,14 @@ atse_watchdog(struct atse_softc *sc) return; device_printf(sc->atse_dev, "watchdog timeout\n"); - sc->atse_ifp->if_oerrors++; + if_inc_counter(sc->atse_ifp, IFCOUNTER_OERRORS, 1); + + atse_intr_debug(sc, "poll"); sc->atse_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; atse_init_locked(sc); + atse_rx_locked(sc); if (!IFQ_DRV_IS_EMPTY(&sc->atse_ifp->if_snd)) atse_start_locked(sc->atse_ifp); } @@ -1169,10 +1240,6 @@ atse_rx_locked(struct atse_softc *sc) meta = 0; do { outer: - if (sc->atse_rx_cycles <= 0) - return (rx_npkts); - sc->atse_rx_cycles--; - if (sc->atse_rx_m == NULL) { m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) @@ -1196,7 +1263,7 @@ atse_rx_locked(struct atse_softc *sc) atse_update_rx_err(sc, ((meta & A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >> A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); sc->atse_rx_buf_len = 0; /* * Should still read till EOP or next SOP. @@ -1225,7 +1292,7 @@ atse_rx_locked(struct atse_softc *sc) "without empty buffer: %u\n", __func__, sc->atse_rx_buf_len); /* XXX-BZ any better counter? */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } if ((sc->atse_flags & ATSE_FLAGS_SOP_SEEN) == 0) @@ -1238,12 +1305,13 @@ atse_rx_locked(struct atse_softc *sc) data = ATSE_RX_DATA_READ(sc); #endif /* Make sure to not overflow the mbuf data size. */ - if (sc->atse_rx_buf_len >= sc->atse_rx_m->m_len - 4) { + if (sc->atse_rx_buf_len >= sc->atse_rx_m->m_len - + sizeof(data)) { /* * XXX-BZ Error. We need more mbufs and are * not setup for this yet. */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); sc->atse_flags |= ATSE_FLAGS_ERROR; } if ((sc->atse_flags & ATSE_FLAGS_ERROR) == 0) @@ -1262,7 +1330,7 @@ atse_rx_locked(struct atse_softc *sc) A_ONCHIP_FIFO_MEM_CORE_EMPTY_SHIFT; sc->atse_rx_buf_len += (4 - empty); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); rx_npkts++; m = sc->atse_rx_m; @@ -1275,15 +1343,19 @@ atse_rx_locked(struct atse_softc *sc) if (sc->atse_flags & ATSE_FLAGS_ERROR) { sc->atse_flags &= ~ATSE_FLAGS_ERROR; m_freem(m); - /* Need to start with a new packet. */ - goto outer; + } else { + m->m_pkthdr.rcvif = ifp; + ATSE_UNLOCK(sc); + (*ifp->if_input)(ifp, m); + ATSE_LOCK(sc); } - - m->m_pkthdr.rcvif = ifp; - - ATSE_UNLOCK(sc); - (*ifp->if_input)(ifp, m); - ATSE_LOCK(sc); +#ifdef DEVICE_POLLING + if (ifp->if_capenable & IFCAP_POLLING) { + if (sc->atse_rx_cycles <= 0) + return (rx_npkts); + sc->atse_rx_cycles--; + } +#endif goto outer; /* Need a new mbuf. */ } else { sc->atse_rx_buf_len += sizeof(data); @@ -1291,7 +1363,7 @@ atse_rx_locked(struct atse_softc *sc) } /* for */ /* XXX-BZ could optimize in case of another packet waiting. */ - } while ((meta & A_ONCHIP_FIFO_MEM_CORE_EOP) == 0 || fill > 0); + } while (fill > 0); return (rx_npkts); } @@ -1317,11 +1389,11 @@ atse_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) } static void -atse_intr(void *arg) +atse_rx_intr(void *arg) { struct atse_softc *sc; struct ifnet *ifp; - uint32_t rx, tx; + uint32_t rxe; sc = (struct atse_softc *)arg; ifp = sc->atse_ifp; @@ -1334,54 +1406,94 @@ atse_intr(void *arg) } #endif - ATSE_RX_INTR_DISABLE(sc); - ATSE_TX_INTR_DISABLE(sc); - - rx = ATSE_RX_EVENT_READ(sc); - tx = ATSE_TX_EVENT_READ(sc); - if (rx != 0) { - if (rx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW| - A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) { - /* XXX-BZ ERROR HANDLING. */ - atse_update_rx_err(sc, ((rx & - A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >> - A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff); - ifp->if_ierrors++; - } - if ((rx & A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY) != 0) { - sc->atse_rx_cycles = RX_CYCLES_IN_INTR; - atse_rx_locked(sc); - } + atse_intr_debug(sc, "rx"); + rxe = ATSE_RX_EVENT_READ(sc); + if (rxe & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW| + A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) { + /* XXX-BZ ERROR HANDLING. */ + atse_update_rx_err(sc, ((rxe & + A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >> + A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } - if (tx != 0) { - /* XXX-BZ build histogram. */ - if (tx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW| - A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) { - /* XXX-BZ ERROR HANDLING. */ - ifp->if_oerrors++; - } - if (tx & A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY) - sc->atse_watchdog_timer = 0; + + /* + * There is considerable subtlety in the race-free handling of rx + * interrupts: we must disable interrupts whenever we manipulate the + * FIFO to prevent further interrupts from firing before we are done; + * we must clear the event after processing to prevent the event from + * being immediately reposted due to data remaining; we must clear the + * event mask before reenabling interrupts or risk missing a positive + * edge; and we must recheck everything after completing in case the + * event posted between clearing events and reenabling interrupts. If + * a race is experienced, we must restart the whole mechanism. + */ + do { + ATSE_RX_INTR_DISABLE(sc); #if 0 - if (tx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY| - A_ONCHIP_FIFO_MEM_CORE_EVENT_ALMOSTEMPTY)) - atse_start_locked(ifp); + sc->atse_rx_cycles = RX_CYCLES_IN_INTR; #endif + atse_rx_locked(sc); + ATSE_RX_EVENT_CLEAR(sc); + + /* Disable interrupts if interface is down. */ + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ATSE_RX_INTR_ENABLE(sc); + } while (!(ATSE_RX_STATUS_READ(sc) & + A_ONCHIP_FIFO_MEM_CORE_STATUS_EMPTY)); + ATSE_UNLOCK(sc); + +} + +static void +atse_tx_intr(void *arg) +{ + struct atse_softc *sc; + struct ifnet *ifp; + uint32_t txe; + + sc = (struct atse_softc *)arg; + ifp = sc->atse_ifp; + + ATSE_LOCK(sc); +#ifdef DEVICE_POLLING + if (ifp->if_capenable & IFCAP_POLLING) { + ATSE_UNLOCK(sc); + return; + } +#endif + + /* XXX-BZ build histogram. */ + atse_intr_debug(sc, "tx"); + txe = ATSE_TX_EVENT_READ(sc); + if (txe & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW| + A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) { + /* XXX-BZ ERROR HANDLING. */ + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } - /* Clear events before re-enabling intrs. */ - ATSE_TX_EVENT_CLEAR(sc); - ATSE_RX_EVENT_CLEAR(sc); - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - /* Re-enable interrupts. */ - ATSE_RX_INTR_ENABLE(sc); - ATSE_TX_INTR_ENABLE(sc); - - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - atse_start_locked(ifp); - } + /* + * There is also considerable subtlety in the race-free handling of + * tx interrupts: all processing occurs with interrupts disabled to + * prevent spurious refiring while transmit is in progress (which + * could occur if the FIFO drains while sending -- quite likely); we + * must not clear the event mask until after we've sent, also to + * prevent spurious refiring; once we've cleared the event mask we can + * reenable interrupts, but there is a possible race between clear and + * enable, so we must recheck and potentially repeat the whole process + * if it is detected. + */ + do { + ATSE_TX_INTR_DISABLE(sc); + sc->atse_watchdog_timer = 0; + atse_start_locked(ifp); + ATSE_TX_EVENT_CLEAR(sc); + /* Disable interrupts if interface is down. */ + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + ATSE_TX_INTR_ENABLE(sc); + } while (ATSE_TX_PENDING(sc) && + !(ATSE_TX_STATUS_READ(sc) & A_ONCHIP_FIFO_MEM_CORE_STATUS_FULL)); ATSE_UNLOCK(sc); } @@ -1415,14 +1527,14 @@ atse_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) atse_update_rx_err(sc, ((rx & A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >> A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } if (tx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW| A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) { /* XXX-BZ ERROR HANDLING. */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } - if (tx & A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY) + if (ATSE_TX_READ_FILL_LEVEL(sc) == 0) sc->atse_watchdog_timer = 0; #if 0 @@ -1719,7 +1831,7 @@ atse_attach(device_t dev) /* Hook up interrupts. */ if (sc->atse_rx_irq_res != NULL) { error = bus_setup_intr(dev, sc->atse_rx_irq_res, INTR_TYPE_NET | - INTR_MPSAFE, NULL, atse_intr, sc, &sc->atse_rx_intrhand); + INTR_MPSAFE, NULL, atse_rx_intr, sc, &sc->atse_rx_intrhand); if (error != 0) { device_printf(dev, "enabling RX IRQ failed\n"); ether_ifdetach(ifp); @@ -1729,7 +1841,7 @@ atse_attach(device_t dev) if (sc->atse_tx_irq_res != NULL) { error = bus_setup_intr(dev, sc->atse_tx_irq_res, INTR_TYPE_NET | - INTR_MPSAFE, NULL, atse_intr, sc, &sc->atse_tx_intrhand); + INTR_MPSAFE, NULL, atse_tx_intr, sc, &sc->atse_tx_intrhand); if (error != 0) { bus_teardown_intr(dev, sc->atse_rx_irq_res, sc->atse_rx_intrhand); diff --git a/sys/pci/amdpm.c b/sys/dev/amdpm/amdpm.c similarity index 100% rename from sys/pci/amdpm.c rename to sys/dev/amdpm/amdpm.c diff --git a/sys/pci/amdsmb.c b/sys/dev/amdsmb/amdsmb.c similarity index 100% rename from sys/pci/amdsmb.c rename to sys/dev/amdsmb/amdsmb.c diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 7067520a8398..bee2a0cf5790 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -872,7 +872,7 @@ an_rxeof(struct an_softc *sc) /* read header */ if (an_read_data(sc, id, 0x0, (caddr_t)&rx_frame, sizeof(rx_frame))) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -895,7 +895,7 @@ an_rxeof(struct an_softc *sc) if_printf(ifp, "oversized packet " "received (%d, %d)\n", len, MCLBYTES); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -921,7 +921,7 @@ an_rxeof(struct an_softc *sc) if_printf(ifp, "oversized packet " "received (%d, %d)\n", len, MCLBYTES); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -940,13 +940,13 @@ an_rxeof(struct an_softc *sc) } else { MGETHDR(m, M_NOWAIT, MT_DATA); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } MCLGET(m, M_NOWAIT); if (!(m->m_flags & M_EXT)) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } m->m_pkthdr.rcvif = ifp; @@ -957,7 +957,7 @@ an_rxeof(struct an_softc *sc) if (an_read_data(sc, id, 0, (caddr_t)&rx_frame, sizeof(rx_frame))) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } #endif @@ -966,12 +966,12 @@ an_rxeof(struct an_softc *sc) (caddr_t)&rx_frame_802_3, sizeof(rx_frame_802_3))) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } if (rx_frame_802_3.an_rx_802_3_status != 0) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } /* Check for insane frame length */ @@ -981,7 +981,7 @@ an_rxeof(struct an_softc *sc) if_printf(ifp, "oversized packet " "received (%d, %d)\n", len, MCLBYTES); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } m->m_pkthdr.len = m->m_len = @@ -1001,10 +1001,10 @@ an_rxeof(struct an_softc *sc) if (error) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* Receive packet. */ #ifdef ANCACHE @@ -1031,13 +1031,13 @@ an_rxeof(struct an_softc *sc) MGETHDR(m, M_NOWAIT, MT_DATA); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } MCLGET(m, M_NOWAIT); if (!(m->m_flags & M_EXT)) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } m->m_pkthdr.rcvif = ifp; @@ -1061,7 +1061,7 @@ an_rxeof(struct an_softc *sc) if_printf(ifp, "oversized packet " "received (%d, %d)\n", len, MCLBYTES); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1073,7 +1073,7 @@ an_rxeof(struct an_softc *sc) bcopy(buf, (char *)eh, m->m_pkthdr.len); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* Receive packet. */ #if 0 @@ -1126,9 +1126,9 @@ an_txeof(struct an_softc *sc, int status) id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350)); if (status & AN_EV_TX_EXC) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); for (i = 0; i < AN_TX_RING_CNT; i++) { if (id == sc->an_rdata.an_tx_ring[i]) { @@ -1142,9 +1142,9 @@ an_txeof(struct an_softc *sc, int status) id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350)); if (!sc->an_rdata.an_tx_empty){ if (status & AN_EV_TX_EXC) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); AN_INC(sc->an_rdata.an_tx_cons, AN_MAX_TX_DESC); if (sc->an_rdata.an_tx_prod == sc->an_rdata.an_tx_cons) @@ -2962,7 +2962,7 @@ an_watchdog(struct an_softc *sc) an_init_mpi350_desc(sc); an_init_locked(sc); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } int diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index 099e7f17a988..5933307f3e9c 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -77,6 +77,7 @@ static int asmc_key_read(device_t dev, const char *key, uint8_t *buf, uint8_t); static int asmc_fan_count(device_t dev); static int asmc_fan_getvalue(device_t dev, const char *key, int fan); +static int asmc_fan_setvalue(device_t dev, const char *key, int fan, int speed); static int asmc_temp_getvalue(device_t dev, const char *key); static int asmc_sms_read(device_t, const char *key, int16_t *val); static void asmc_sms_calibrate(device_t dev); @@ -94,6 +95,7 @@ static int asmc_key_dump(device_t, int); /* * Model functions. */ +static int asmc_mb_sysctl_fanid(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_fanspeed(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_fansafespeed(SYSCTL_HANDLER_ARGS); static int asmc_mb_sysctl_fanminspeed(SYSCTL_HANDLER_ARGS); @@ -115,6 +117,7 @@ struct asmc_model { int (*smc_sms_x)(SYSCTL_HANDLER_ARGS); int (*smc_sms_y)(SYSCTL_HANDLER_ARGS); int (*smc_sms_z)(SYSCTL_HANDLER_ARGS); + int (*smc_fan_id)(SYSCTL_HANDLER_ARGS); int (*smc_fan_speed)(SYSCTL_HANDLER_ARGS); int (*smc_fan_safespeed)(SYSCTL_HANDLER_ARGS); int (*smc_fan_minspeed)(SYSCTL_HANDLER_ARGS); @@ -134,7 +137,7 @@ static struct asmc_model *asmc_match(device_t dev); #define ASMC_SMS_FUNCS asmc_mb_sysctl_sms_x, asmc_mb_sysctl_sms_y, \ asmc_mb_sysctl_sms_z -#define ASMC_FAN_FUNCS asmc_mb_sysctl_fanspeed, asmc_mb_sysctl_fansafespeed, \ +#define ASMC_FAN_FUNCS asmc_mb_sysctl_fanid, asmc_mb_sysctl_fanspeed, asmc_mb_sysctl_fansafespeed, \ asmc_mb_sysctl_fanminspeed, \ asmc_mb_sysctl_fanmaxspeed, \ asmc_mb_sysctl_fantargetspeed @@ -196,6 +199,18 @@ struct asmc_model asmc_models[] = { ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, ASMC_MBP4_TEMPS, ASMC_MBP4_TEMPNAMES, ASMC_MBP4_TEMPDESCS }, + + { + "MacBookPro8,2", "Apple SMC MacBook Pro (early 2011)", + ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, + ASMC_MBP8_TEMPS, ASMC_MBP8_TEMPNAMES, ASMC_MBP8_TEMPDESCS + }, + + { + "MacBookPro11,3", "Apple SMC MacBook Pro Retina Core i7 (2013/2014)", + ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, + ASMC_MBP11_TEMPS, ASMC_MBP11_TEMPNAMES, ASMC_MBP11_TEMPDESCS + }, /* The Mac Mini has no SMS */ { @@ -224,12 +239,27 @@ struct asmc_model asmc_models[] = { ASMC_MP_TEMPS, ASMC_MP_TEMPNAMES, ASMC_MP_TEMPDESCS }, + /* Idem for the MacPro 2010*/ + { + "MacPro5,1", "Apple SMC MacPro (2010)", + NULL, NULL, NULL, + ASMC_FAN_FUNCS, + NULL, NULL, NULL, + ASMC_MP5_TEMPS, ASMC_MP5_TEMPNAMES, ASMC_MP5_TEMPDESCS + }, + { "MacBookAir1,1", "Apple SMC MacBook Air", ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, NULL, NULL, NULL, ASMC_MBA_TEMPS, ASMC_MBA_TEMPNAMES, ASMC_MBA_TEMPDESCS }, + { + "MacBookAir3,1", "Apple SMC MacBook Air Core 2 Duo (Late 2010)", + ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, NULL, NULL, NULL, + ASMC_MBA3_TEMPS, ASMC_MBA3_TEMPNAMES, ASMC_MBA3_TEMPDESCS + }, + { NULL, NULL } }; @@ -359,6 +389,12 @@ asmc_attach(device_t dev) OID_AUTO, name, CTLFLAG_RD, 0, "Fan Subtree"); + SYSCTL_ADD_PROC(sysctlctx, + SYSCTL_CHILDREN(sc->sc_fan_tree[i]), + OID_AUTO, "id", CTLTYPE_STRING | CTLFLAG_RD, + dev, j, model->smc_fan_id, "I", + "Fan ID"); + SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_fan_tree[i]), OID_AUTO, "speed", CTLTYPE_INT | CTLFLAG_RD, @@ -375,21 +411,21 @@ asmc_attach(device_t dev) SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_fan_tree[i]), OID_AUTO, "minspeed", - CTLTYPE_INT | CTLFLAG_RD, + CTLTYPE_INT | CTLFLAG_RW, dev, j, model->smc_fan_minspeed, "I", "Fan minimum speed in RPM"); SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_fan_tree[i]), OID_AUTO, "maxspeed", - CTLTYPE_INT | CTLFLAG_RD, + CTLTYPE_INT | CTLFLAG_RW, dev, j, model->smc_fan_maxspeed, "I", "Fan maximum speed in RPM"); SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_fan_tree[i]), OID_AUTO, "targetspeed", - CTLTYPE_INT | CTLFLAG_RD, + CTLTYPE_INT | CTLFLAG_RW, dev, j, model->smc_fan_targetspeed, "I", "Fan target speed in RPM"); } @@ -641,11 +677,10 @@ asmc_init(device_t dev) if (bootverbose) { /* - * XXX: The number of keys is a 32 bit buffer, but - * right now Apple only uses the last 8 bit. + * The number of keys is a 32 bit buffer */ asmc_key_read(dev, ASMC_NKEYS, buf, 4); - device_printf(dev, "number of keys: %d\n", buf[3]); + device_printf(dev, "number of keys: %d\n", ntohl(*(uint32_t*)buf)); } #ifdef DEBUG @@ -906,7 +941,7 @@ asmc_fan_count(device_t dev) { uint8_t buf[1]; - if (asmc_key_read(dev, ASMC_KEY_FANCOUNT, buf, 1) < 0) + if (asmc_key_read(dev, ASMC_KEY_FANCOUNT, buf, sizeof buf) < 0) return (-1); return (buf[0]); @@ -920,13 +955,46 @@ asmc_fan_getvalue(device_t dev, const char *key, int fan) char fankey[5]; snprintf(fankey, sizeof(fankey), key, fan); - if (asmc_key_read(dev, fankey, buf, 2) < 0) + if (asmc_key_read(dev, fankey, buf, sizeof buf) < 0) return (-1); speed = (buf[0] << 6) | (buf[1] >> 2); return (speed); } +static char* +asmc_fan_getstring(device_t dev, const char *key, int fan) +{ + uint8_t buf[16]; + char fankey[5]; + char* desc; + + snprintf(fankey, sizeof(fankey), key, fan); + if (asmc_key_read(dev, fankey, buf, sizeof buf) < 0) + return (NULL); + desc = buf+4; + + return (desc); +} + +static int +asmc_fan_setvalue(device_t dev, const char *key, int fan, int speed) +{ + uint8_t buf[2]; + char fankey[5]; + + speed *= 4; + + buf[0] = speed>>8; + buf[1] = speed; + + snprintf(fankey, sizeof(fankey), key, fan); + if (asmc_key_write(dev, fankey, buf, sizeof buf) < 0) + return (-1); + + return (0); +} + static int asmc_mb_sysctl_fanspeed(SYSCTL_HANDLER_ARGS) { @@ -941,6 +1009,22 @@ asmc_mb_sysctl_fanspeed(SYSCTL_HANDLER_ARGS) return (error); } +static int +asmc_mb_sysctl_fanid(SYSCTL_HANDLER_ARGS) +{ + device_t dev = (device_t) arg1; + int fan = arg2; + int error = true; + char* desc; + + desc = asmc_fan_getstring(dev, ASMC_KEY_FANID, fan); + + if (desc != NULL) + error = sysctl_handle_string(oidp, desc, 0, req); + + return (error); +} + static int asmc_mb_sysctl_fansafespeed(SYSCTL_HANDLER_ARGS) { @@ -967,6 +1051,11 @@ asmc_mb_sysctl_fanminspeed(SYSCTL_HANDLER_ARGS) v = asmc_fan_getvalue(dev, ASMC_KEY_FANMINSPEED, fan); error = sysctl_handle_int(oidp, &v, 0, req); + if (error == 0 && req->newptr != NULL) { + unsigned int newspeed = *(unsigned int *)req->newptr; + asmc_fan_setvalue(dev, ASMC_KEY_FANMINSPEED, fan, newspeed); + } + return (error); } @@ -981,6 +1070,11 @@ asmc_mb_sysctl_fanmaxspeed(SYSCTL_HANDLER_ARGS) v = asmc_fan_getvalue(dev, ASMC_KEY_FANMAXSPEED, fan); error = sysctl_handle_int(oidp, &v, 0, req); + if (error == 0 && req->newptr != NULL) { + unsigned int newspeed = *(unsigned int *)req->newptr; + asmc_fan_setvalue(dev, ASMC_KEY_FANMAXSPEED, fan, newspeed); + } + return (error); } @@ -995,6 +1089,11 @@ asmc_mb_sysctl_fantargetspeed(SYSCTL_HANDLER_ARGS) v = asmc_fan_getvalue(dev, ASMC_KEY_FANTARGETSPEED, fan); error = sysctl_handle_int(oidp, &v, 0, req); + if (error == 0 && req->newptr != NULL) { + unsigned int newspeed = *(unsigned int *)req->newptr; + asmc_fan_setvalue(dev, ASMC_KEY_FANTARGETSPEED, fan, newspeed); + } + return (error); } @@ -1009,7 +1108,7 @@ asmc_temp_getvalue(device_t dev, const char *key) /* * Check for invalid temperatures. */ - if (asmc_key_read(dev, key, buf, 2) < 0) + if (asmc_key_read(dev, key, buf, sizeof buf) < 0) return (-1); return (buf[0]); @@ -1042,7 +1141,7 @@ asmc_sms_read(device_t dev, const char *key, int16_t *val) case 'X': case 'Y': case 'Z': - error = asmc_key_read(dev, key, buf, 2); + error = asmc_key_read(dev, key, buf, sizeof buf); break; default: device_printf(dev, "%s called with invalid argument %s\n", @@ -1197,7 +1296,7 @@ asmc_mbp_sysctl_light_left(SYSCTL_HANDLER_ARGS) int error; int32_t v; - asmc_key_read(dev, ASMC_KEY_LIGHTLEFT, buf, 6); + asmc_key_read(dev, ASMC_KEY_LIGHTLEFT, buf, sizeof buf); v = buf[2]; error = sysctl_handle_int(oidp, &v, sizeof(v), req); @@ -1212,7 +1311,7 @@ asmc_mbp_sysctl_light_right(SYSCTL_HANDLER_ARGS) int error; int32_t v; - asmc_key_read(dev, ASMC_KEY_LIGHTRIGHT, buf, 6); + asmc_key_read(dev, ASMC_KEY_LIGHTRIGHT, buf, sizeof buf); v = buf[2]; error = sysctl_handle_int(oidp, &v, sizeof(v), req); @@ -1236,7 +1335,7 @@ asmc_mbp_sysctl_light_control(SYSCTL_HANDLER_ARGS) v = level; buf[0] = level; buf[1] = 0x00; - asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, 2); + asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof buf); } return (error); diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h index 67e7f3b1ded2..368575babe7f 100644 --- a/sys/dev/asmc/asmcvar.h +++ b/sys/dev/asmc/asmcvar.h @@ -27,7 +27,7 @@ * */ -#define ASMC_MAXFANS 2 +#define ASMC_MAXFANS 6 struct asmc_softc { device_t sc_dev; @@ -83,6 +83,7 @@ struct asmc_softc { */ #define ASMC_KEY_FANCOUNT "FNum" /* RO; 1 byte */ #define ASMC_KEY_FANMANUAL "FS! " /* RW; 2 bytes */ +#define ASMC_KEY_FANID "F%dID" /* RO; 16 bytes */ #define ASMC_KEY_FANSPEED "F%dAc" /* RO; 2 bytes */ #define ASMC_KEY_FANMINSPEED "F%dMn" /* RO; 2 bytes */ #define ASMC_KEY_FANMAXSPEED "F%dMx" /* RO; 2 bytes */ @@ -132,7 +133,7 @@ struct asmc_softc { * */ /* maximum array size for temperatures including the last NULL */ -#define ASMC_TEMP_MAX 36 +#define ASMC_TEMP_MAX 80 #define ASMC_MB_TEMPS { "TB0T", "TN0P", "TN1P", "Th0H", "Th1H", \ "TM0P", NULL } #define ASMC_MB_TEMPNAMES { "enclosure", "northbridge1", \ @@ -175,6 +176,57 @@ struct asmc_softc { "Unknown", "Unknown", \ "Wireless Module", } +#define ASMC_MBP8_TEMPS { "TB0T", "TB1T", "TB2T", "TC0C", "TC0D", \ + "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \ + "TC3C", "TC4C", "TCFC", "TCGC", "TCSA", \ + "TCTD", "TG0D", "TG0P", "THSP", "TM0S", \ + "TMBS", "TP0P", "TPCD", "TW0P", "Th1H", \ + "Th2H", "Tm0P", "Ts0P", "Ts0S", NULL } + +#define ASMC_MBP8_TEMPNAMES { "enclosure", "TB1T", "TB2T", "TC0C", "TC0D", \ + "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \ + "TC3C", "TC4C", "TCFC", "TCGC", "TCSA", \ + "TCTD", "graphics", "TG0P", "THSP", "TM0S", \ + "TMBS", "TP0P", "TPCD", "wireless", "Th1H", \ + "Th2H", "memory", "Ts0P", "Ts0S" } + +#define ASMC_MBP8_TEMPDESCS { "Enclosure Bottomside", "TB1T", "TB2T", "TC0C", "TC0D", \ + "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \ + "TC3C", "TC4C", "TCFC", "TCGC", "TCSA", \ + "TCTD", "TG0D", "TG0P", "THSP", "TM0S", \ + "TMBS", "TP0P", "TPCD", "TW0P", "Th1H", \ + "Th2H", "Tm0P", "Ts0P", "Ts0S" } + +#define ASMC_MBP11_TEMPS { "TB0T", "TB1T", "TB2T", "TBXT", "TC0E", \ + "TC0F", "TC0P", "TC1C", "TC2C", "TC3C", \ + "TC4C", "TCFC", "TCGC", "TCSA", "TCTD", \ + "TCXC", "TG0D", "TG0P", "TG1D", "TG1F", \ + "TG1d", "TH0A", "TH0B", "TH0F", "TH0R", \ + "TH0V", "TH0a", "TH0b", "TH0c", "TM0P", \ + "TM0S", "TP0P", "TPCD", "TW0P", "Ta0P", \ + "TaSP", "Th1H", "Th2H", "Ts0P", "Ts0S", \ + "Ts1S", NULL } + +#define ASMC_MBP11_TEMPNAMES { "TB0T", "TB1T", "TB2T", "TBXT", "TC0E", \ + "TC0F", "TC0P", "TC1C", "TC2C", "TC3C", \ + "TC4C", "TCFC", "TCGC", "TCSA", "TCTD", \ + "TCXC", "TG0D", "TG0P", "TG1D", "TG1F", \ + "TG1d", "TH0A", "TH0B", "TH0F", "TH0R", \ + "TH0V", "TH0a", "TH0b", "TH0c", "TM0P", \ + "TM0S", "TP0P", "TPCD", "TW0P", "Ta0P", \ + "TaSP", "Th1H", "Th2H", "Ts0P", "Ts0S", \ + "Ts1S" } + +#define ASMC_MBP11_TEMPDESCS { "TB0T", "TB1T", "TB2T", "TBXT", "TC0E", \ + "TC0F", "TC0P", "TC1C", "TC2C", "TC3C", \ + "TC4C", "TCFC", "TCGC", "TCSA", "TCTD", \ + "TCXC", "TG0D", "TG0P", "TG1D", "TG1F", \ + "TG1d", "TH0A", "TH0B", "TH0F", "TH0R", \ + "TH0V", "TH0a", "TH0b", "TH0c", "TM0P", \ + "TM0S", "TP0P", "TPCD", "TW0P", "Ta0P", \ + "TaSP", "Th1H", "Th2H", "Ts0P", "Ts0S", \ + "Ts1S" } + #define ASMC_MM_TEMPS { "TN0P", "TN1P", NULL } #define ASMC_MM_TEMPNAMES { "northbridge1", "northbridge2" } #define ASMC_MM_TEMPDESCS { "Northbridge Point 1", \ @@ -214,8 +266,7 @@ struct asmc_softc { "TH0P", "TH1P", "TH2P", "TH3P", "TMAP", \ "TMAS", "TMBS", "TM0P", "TM0S", "TM1P", \ "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", \ - "TM8S", "TM9P", "TM9S", "TN0H", "TS0C", \ - NULL } + "TM8S", "TM9P", "TM9S", "TN0H", "TS0C", } #define ASMC_MP_TEMPDESCS { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", \ "TC0C", "TC0D", "TC0P", "TC1C", "TC1D", \ @@ -223,9 +274,66 @@ struct asmc_softc { "TH0P", "TH1P", "TH2P", "TH3P", "TMAP", \ "TMAS", "TMBS", "TM0P", "TM0S", "TM1P", \ "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", \ - "TM8S", "TM9P", "TM9S", "TN0H", "TS0C", \ + "TM8S", "TM9P", "TM9S", "TN0H", "TS0C", } + +#define ASMC_MP5_TEMPS { "TA0P", "TCAC", "TCAD", "TCAG", "TCAH", \ + "TCAS", "TCBC", "TCBD", "TCBG", "TCBH", \ + "TCBS", "TH1F", "TH1P", "TH1V", "TH2F", \ + "TH2P", "TH2V", "TH3F", "TH3P", "TH3V", \ + "TH4F", "TH4P", "TH4V", "THPS", "THTG", \ + "TM1P", "TM2P", "TM2V", "TM3P", "TM3V", \ + "TM4P", "TM5P", "TM6P", "TM6V", "TM7P", \ + "TM7V", "TM8P", "TM8V", "TM9V", "TMA1", \ + "TMA2", "TMA3", "TMA4", "TMB1", "TMB2", \ + "TMB3", "TMB4", "TMHS", "TMLS", "TMPS", \ + "TMPV", "TMTG", "TN0D", "TN0H", "TNTG", \ + "Te1F", "Te1P", "Te1S", "Te2F", "Te2S", \ + "Te3F", "Te3S", "Te4F", "Te4S", "Te5F", \ + "Te5S", "TeGG", "TeGP", "TeRG", "TeRP", \ + "TeRV", "Tp0C", "Tp1C", "TpPS", "TpTG", \ NULL } +#define ASMC_MP5_TEMPNAMES { "ambient", "TCAC", "TCAD", "TCAG", "TCAH", \ + "TCAS", "TCBC", "TCBD", "TCBG", "TCBH", \ + "TCBS", "TH1F", "TH1P", "TH1V", "TH2F", \ + "TH2P", "TH2V", "TH3F", "TH3P", "TH3V", \ + "TH4F", "TH4P", "TH4V", "THPS", "THTG", \ + "TM1P", "TM2P", "TM2V", "TM3P", "TM3V", \ + "TM4P", "TM5P", "TM6P", "TM6V", "TM7P", \ + "TM7V", "TM8P", "TM8V", "TM9V", "ram_a1", \ + "ram_a2", "ram_a3", "ram_a4", "ram_b1", "ram_b2", \ + "ram_b3", "ram_b4", "TMHS", "TMLS", "TMPS", \ + "TMPV", "TMTG", "TN0D", "TN0H", "TNTG", \ + "Te1F", "Te1P", "Te1S", "Te2F", "Te2S", \ + "Te3F", "Te3S", "Te4F", "Te4S", "Te5F", \ + "Te5S", "TeGG", "TeGP", "TeRG", "TeRP", \ + "TeRV", "Tp0C", "Tp1C", "TpPS", "TpTG", } + +#define ASMC_MP5_TEMPDESCS { "TA0P", "TCAC", "TCAD", "TCAG", "TCAH", \ + "TCAS", "TCBC", "TCBD", "TCBG", "TCBH", \ + "TCBS", "TH1F", "TH1P", "TH1V", "TH2F", \ + "TH2P", "TH2V", "TH3F", "TH3P", "TH3V", \ + "TH4F", "TH4P", "TH4V", "THPS", "THTG", \ + "TM1P", "TM2P", "TM2V", "TM3P", "TM3V", \ + "TM4P", "TM5P", "TM6P", "TM6V", "TM7P", \ + "TM7V", "TM8P", "TM8V", "TM9V", "TMA1", \ + "TMA2", "TMA3", "TMA4", "TMB1", "TMB2", \ + "TMB3", "TMB4", "TMHS", "TMLS", "TMPS", \ + "TMPV", "TMTG", "TN0D", "TN0H", "TNTG", \ + "Te1F", "Te1P", "Te1S", "Te2F", "Te2S", \ + "Te3F", "Te3S", "Te4F", "Te4S", "Te5F", \ + "Te5S", "TeGG", "TeGP", "TeRG", "TeRP", \ + "TeRV", "Tp0C", "Tp1C", "TpPS", "TpTG", } + #define ASMC_MBA_TEMPS { "TB0T", NULL } #define ASMC_MBA_TEMPNAMES { "enclosure" } #define ASMC_MBA_TEMPDESCS { "Enclosure Bottom" } + +#define ASMC_MBA3_TEMPS { "TB0T", "TB1T", "TB2T", \ + "TC0D", "TC0E", "TC0P", NULL } + +#define ASMC_MBA3_TEMPNAMES { "enclosure", "TB1T", "TB2T", \ + "TC0D", "TC0E", "TC0P" } + +#define ASMC_MBA3_TEMPDESCS { "Enclosure Bottom", "TB1T", "TB2T", \ + "TC0D", "TC0E", "TC0P" } diff --git a/sys/dev/ath/ath_hal/ah.c b/sys/dev/ath/ath_hal/ah.c index 750248e1e0a1..2aefc8971e72 100644 --- a/sys/dev/ath/ath_hal/ah.c +++ b/sys/dev/ath/ath_hal/ah.c @@ -55,7 +55,9 @@ ath_hal_probe(uint16_t vendorid, uint16_t devid) */ struct ath_hal* ath_hal_attach(uint16_t devid, HAL_SOFTC sc, - HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, HAL_STATUS *error) + HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, + HAL_STATUS *error) { struct ath_hal_chip * const *pchip; @@ -66,7 +68,8 @@ ath_hal_attach(uint16_t devid, HAL_SOFTC sc, /* XXX don't have vendorid, assume atheros one works */ if (chip->probe(ATHEROS_VENDOR_ID, devid) == AH_NULL) continue; - ah = chip->attach(devid, sc, st, sh, eepromdata, error); + ah = chip->attach(devid, sc, st, sh, eepromdata, ah_config, + error); if (ah != AH_NULL) { /* copy back private state to public area */ ah->ah_devid = AH_PRIVATE(ah)->ah_devid; diff --git a/sys/dev/ath/ath_hal/ah.h b/sys/dev/ath/ath_hal/ah.h index 4f2d3e9a0ba7..239ebc89a41d 100644 --- a/sys/dev/ath/ath_hal/ah.h +++ b/sys/dev/ath/ath_hal/ah.h @@ -1264,6 +1264,7 @@ typedef struct int ath_hal_show_bb_panic; int ath_hal_ant_ctrl_comm2g_switch_enable; int ath_hal_ext_atten_margin_cfg; + int ath_hal_min_gainidx; int ath_hal_war70c; uint32_t ath_hal_mci_config; } HAL_OPS_CONFIG; @@ -1616,7 +1617,8 @@ extern const char *__ahdecl ath_hal_probe(uint16_t vendorid, uint16_t devid); * be returned if the status parameter is non-zero. */ extern struct ath_hal * __ahdecl ath_hal_attach(uint16_t devid, HAL_SOFTC, - HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata, HAL_STATUS* status); + HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, HAL_STATUS* status); extern const char *ath_hal_mac_name(struct ath_hal *); extern const char *ath_hal_rf_name(struct ath_hal *); diff --git a/sys/dev/ath/ath_hal/ah_internal.h b/sys/dev/ath/ath_hal/ah_internal.h index 2e35148636b4..0892a428895a 100644 --- a/sys/dev/ath/ath_hal/ah_internal.h +++ b/sys/dev/ath/ath_hal/ah_internal.h @@ -91,6 +91,7 @@ struct ath_hal_chip { const char *(*probe)(uint16_t vendorid, uint16_t devid); struct ath_hal *(*attach)(uint16_t devid, HAL_SOFTC, HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah, HAL_STATUS *error); }; #ifndef AH_CHIP diff --git a/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c b/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c index ee11ce9e6847..ceafa99f2963 100644 --- a/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c +++ b/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c @@ -183,7 +183,7 @@ static HAL_BOOL ar5210FillCapabilityInfo(struct ath_hal *ah); */ static struct ath_hal * ar5210Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, - uint16_t *eepromdata, HAL_STATUS *status) + uint16_t *eepromdata, HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { #define N(a) (sizeof(a)/sizeof(a[0])) struct ath_hal_5210 *ahp; diff --git a/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c b/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c index 454929523d5f..3416dc0e8809 100644 --- a/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c +++ b/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c @@ -203,7 +203,7 @@ ar5211GetRadioRev(struct ath_hal *ah) static struct ath_hal * ar5211Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, - HAL_STATUS *status) + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { #define N(a) (sizeof(a)/sizeof(a[0])) struct ath_hal_5211 *ahp; diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c b/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c index e0af27c4b42e..a95f24491f0a 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c @@ -317,7 +317,7 @@ ar5212IsMacSupported(uint8_t macVersion, uint8_t macRev) static struct ath_hal * ar5212Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, - HAL_STATUS *status) + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { #define AH_EEPROM_PROTECT(ah) \ (AH_PRIVATE(ah)->ah_ispcie)? AR_EEPROM_PROTECT_PCIE : AR_EEPROM_PROTECT) diff --git a/sys/dev/ath/ath_hal/ar5312/ar5312_attach.c b/sys/dev/ath/ath_hal/ar5312/ar5312_attach.c index 4ca1a4d0b7df..5c84eb87eb0c 100644 --- a/sys/dev/ath/ath_hal/ar5312/ar5312_attach.c +++ b/sys/dev/ath/ath_hal/ar5312/ar5312_attach.c @@ -62,7 +62,7 @@ ar5312AniSetup(struct ath_hal *ah) static struct ath_hal * ar5312Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, - HAL_STATUS *status) + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { struct ath_hal_5212 *ahp = AH_NULL; struct ath_hal *ah; diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c index bdc61118b9cb..a20499a3c025 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c @@ -297,7 +297,7 @@ ar5416GetRadioRev(struct ath_hal *ah) static struct ath_hal * ar5416Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, - HAL_STATUS *status) + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { struct ath_hal_5416 *ahp5416; struct ath_hal_5212 *ahp; diff --git a/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c b/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c index 4f478c06872e..c270babf330c 100644 --- a/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c +++ b/sys/dev/ath/ath_hal/ar9001/ar9130_attach.c @@ -69,7 +69,9 @@ static HAL_BOOL ar9130FillCapabilityInfo(struct ath_hal *ah); */ static struct ath_hal * ar9130Attach(uint16_t devid, HAL_SOFTC sc, - HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, HAL_STATUS *status) + HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, + HAL_STATUS *status) { struct ath_hal_5416 *ahp5416; struct ath_hal_5212 *ahp; diff --git a/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c b/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c index 979ba1a294c7..5bda519e3b5c 100644 --- a/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c +++ b/sys/dev/ath/ath_hal/ar9001/ar9160_attach.c @@ -114,6 +114,7 @@ ar9160InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan) static struct ath_hal * ar9160Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { struct ath_hal_5416 *ahp5416; diff --git a/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c b/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c index 2a67fe56e270..3be3e3539a55 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c @@ -148,6 +148,7 @@ ar9280InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan) static struct ath_hal * ar9280Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { struct ath_hal_9280 *ahp9280; diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c b/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c index edb6f267d42b..eb3490a61ae3 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c @@ -133,6 +133,7 @@ ar9285_eeprom_print_diversity_settings(struct ath_hal *ah) static struct ath_hal * ar9285Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { struct ath_hal_9285 *ahp9285; diff --git a/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c b/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c index 010e2c34b065..0ea565c271c1 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c @@ -111,6 +111,7 @@ ar9287AniSetup(struct ath_hal *ah) static struct ath_hal * ar9287Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, uint16_t *eepromdata, + HAL_OPS_CONFIG *ah_config, HAL_STATUS *status) { struct ath_hal_9287 *ahp9287; diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 3a5ae32969ff..af686f038b97 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -435,6 +435,81 @@ _ath_power_restore_power_state(struct ath_softc *sc, const char *file, int line) } +/* + * Configure the initial HAL configuration values based on bus + * specific parameters. + * + * Some PCI IDs and other information may need tweaking. + * + * XXX TODO: ath9k and the Atheros HAL only program comm2g_switch_enable + * if BT antenna diversity isn't enabled. + * + * So, let's also figure out how to enable BT diversity for AR9485. + */ +static void +ath_setup_hal_config(struct ath_softc *sc, HAL_OPS_CONFIG *ah_config) +{ + /* XXX TODO: only for PCI devices? */ + + if (sc->sc_pci_devinfo & (ATH_PCI_CUS198 | ATH_PCI_CUS230)) { + ah_config->ath_hal_ext_lna_ctl_gpio = 0x200; /* bit 9 */ + ah_config->ath_hal_ext_atten_margin_cfg = AH_TRUE; + ah_config->ath_hal_min_gainidx = AH_TRUE; + ah_config->ath_hal_ant_ctrl_comm2g_switch_enable = 0x000bbb88; + /* XXX low_rssi_thresh */ + /* XXX fast_div_bias */ + device_printf(sc->sc_dev, "configuring for %s\n", + (sc->sc_pci_devinfo & ATH_PCI_CUS198) ? + "CUS198" : "CUS230"); + } + + if (sc->sc_pci_devinfo & ATH_PCI_CUS217) + device_printf(sc->sc_dev, "CUS217 card detected\n"); + + if (sc->sc_pci_devinfo & ATH_PCI_CUS252) + device_printf(sc->sc_dev, "CUS252 card detected\n"); + + if (sc->sc_pci_devinfo & ATH_PCI_AR9565_1ANT) + device_printf(sc->sc_dev, "WB335 1-ANT card detected\n"); + + if (sc->sc_pci_devinfo & ATH_PCI_AR9565_2ANT) + device_printf(sc->sc_dev, "WB335 2-ANT card detected\n"); + + if (sc->sc_pci_devinfo & ATH_PCI_KILLER) + device_printf(sc->sc_dev, "Killer Wireless card detected\n"); + +#if 0 + /* + * Some WB335 cards do not support antenna diversity. Since + * we use a hardcoded value for AR9565 instead of using the + * EEPROM/OTP data, remove the combining feature from + * the HW capabilities bitmap. + */ + if (sc->sc_pci_devinfo & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { + if (!(sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV)) + pCap->hw_caps &= ~ATH9K_HW_CAP_ANT_DIV_COMB; + } + + if (sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV) { + pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV; + device_printf(sc->sc_dev, "Set BT/WLAN RX diversity capability\n"); + } +#endif + + if (sc->sc_pci_devinfo & ATH_PCI_D3_L1_WAR) { + ah_config->ath_hal_pcie_waen = 0x0040473b; + device_printf(sc->sc_dev, "Enable WAR for ASPM D3/L1\n"); + } + +#if 0 + if (sc->sc_pci_devinfo & ATH9K_PCI_NO_PLL_PWRSAVE) { + ah->config.no_pll_pwrsave = true; + device_printf(sc->sc_dev, "Disable PLL PowerSave\n"); + } +#endif + +} + #define HAL_MODE_HT20 (HAL_MODE_11NG_HT20 | HAL_MODE_11NA_HT20) #define HAL_MODE_HT40 \ (HAL_MODE_11NG_HT40PLUS | HAL_MODE_11NG_HT40MINUS | \ @@ -450,6 +525,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) u_int wmodes; uint8_t macaddr[IEEE80211_ADDR_LEN]; int rx_chainmask, tx_chainmask; + HAL_OPS_CONFIG ah_config; DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); @@ -468,8 +544,17 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) device_get_unit(sc->sc_dev)); CURVNET_RESTORE(); + /* + * Configure the initial configuration data. + * + * This is stuff that may be needed early during attach + * rather than done via configuration calls later. + */ + bzero(&ah_config, sizeof(ah_config)); + ath_setup_hal_config(sc, &ah_config); + ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, - sc->sc_eepromdata, &status); + sc->sc_eepromdata, &ah_config, &status); if (ah == NULL) { if_printf(ifp, "unable to attach hardware; HAL status %u\n", status); @@ -1715,12 +1800,22 @@ ath_suspend(struct ath_softc *sc) * 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 TODO: well, that's great, except for non-cardbus + * devices! */ /* - * XXX ensure none of the taskqueues are running + * XXX This doesn't wait until all pending taskqueue + * items and parallel transmit/receive/other threads + * are running! + */ + ath_hal_intrset(sc->sc_ah, 0); + taskqueue_block(sc->sc_tq); + callout_drain(&sc->sc_cal_ch); + + /* * XXX ensure sc_invalid is 1 - * XXX ensure the calibration callout is disabled */ /* Disable the PCIe PHY, complete with workarounds */ @@ -1811,6 +1906,11 @@ ath_resume(struct ath_softc *sc) AH_FALSE, &status); ath_reset_keycache(sc); + ATH_RX_LOCK(sc); + sc->sc_rx_stopped = 1; + sc->sc_rx_resetted = 1; + ATH_RX_UNLOCK(sc); + /* Let DFS at it in case it's a DFS channel */ ath_dfs_radar_enable(sc, ic->ic_curchan); @@ -2015,44 +2115,46 @@ ath_intr(void *arg) if (status & HAL_INT_RXEOL) { int imask; ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXEOL"); - ATH_PCU_LOCK(sc); + if (! sc->sc_isedma) { + 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); + } /* - * 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 + * Enqueue an RX proc to handle whatever * is in the RX queue. - * This will then kick the PCU. + * This will then kick the PCU if required. */ sc->sc_rx.recv_sched(sc, 1); } @@ -2348,6 +2450,12 @@ ath_init(void *arg) ATH_UNLOCK(sc); return; } + + ATH_RX_LOCK(sc); + sc->sc_rx_stopped = 1; + sc->sc_rx_resetted = 1; + ATH_RX_UNLOCK(sc); + ath_chan_change(sc, ic->ic_curchan); /* Let DFS at it in case it's a DFS channel */ @@ -2406,8 +2514,7 @@ ath_init(void *arg) * Enable interrupts. */ sc->sc_imask = HAL_INT_RX | HAL_INT_TX - | HAL_INT_RXEOL | HAL_INT_RXORN - | HAL_INT_TXURN + | HAL_INT_RXORN | HAL_INT_TXURN | HAL_INT_FATAL | HAL_INT_GLOBAL; /* @@ -2417,6 +2524,14 @@ ath_init(void *arg) if (sc->sc_isedma) sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP); + /* + * If we're an EDMA NIC, we don't care about RXEOL. + * Writing a new descriptor in will simply restart + * RX DMA. + */ + if (! sc->sc_isedma) + sc->sc_imask |= HAL_INT_RXEOL; + /* * Enable MIB interrupts when there are hardware phy counters. * Note we only do this (at the moment) for station mode. @@ -2735,6 +2850,11 @@ ath_reset(struct ifnet *ifp, ATH_RESET_TYPE reset_type) __func__, status); sc->sc_diversity = ath_hal_getdiversity(ah); + ATH_RX_LOCK(sc); + sc->sc_rx_stopped = 1; + sc->sc_rx_resetted = 1; + ATH_RX_UNLOCK(sc); + /* Let DFS at it in case it's a DFS channel */ ath_dfs_radar_enable(sc, ic->ic_curchan); @@ -3192,7 +3312,7 @@ ath_transmit(struct ifnet *ifp, struct mbuf *m) DPRINTF(sc, ATH_DEBUG_XMIT, "%s: out of txfrag buffers\n", __func__); sc->sc_stats.ast_tx_nofrag++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ath_freetx(m); goto bad; } @@ -3240,7 +3360,7 @@ ath_transmit(struct ifnet *ifp, struct mbuf *m) * * XXX should use atomics? */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); nextfrag: /* * Pass the frame to the h/w for transmission. @@ -3260,7 +3380,7 @@ ath_transmit(struct ifnet *ifp, struct mbuf *m) next = m->m_nextpkt; if (ath_tx_start(sc, ni, bf, m)) { bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); reclaim: bf->bf_m = NULL; bf->bf_node = NULL; @@ -5333,14 +5453,15 @@ ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan) ATH_PCU_LOCK(sc); + /* Disable interrupts */ + ath_hal_intrset(ah, 0); + /* Stop new RX/TX/interrupt completion */ if (ath_reset_grablock(sc, 1) == 0) { device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", __func__); } - ath_hal_intrset(ah, 0); - /* Stop pending RX/TX completion */ ath_txrx_stop_locked(sc); @@ -5384,6 +5505,11 @@ ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan) } sc->sc_diversity = ath_hal_getdiversity(ah); + ATH_RX_LOCK(sc); + sc->sc_rx_stopped = 1; + sc->sc_rx_resetted = 1; + ATH_RX_UNLOCK(sc); + /* Let DFS at it in case it's a DFS channel */ ath_dfs_radar_enable(sc, chan); @@ -6346,7 +6472,7 @@ ath_watchdog(void *arg) } else if_printf(ifp, "device timeout\n"); do_reset = 1; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->sc_stats.ast_watchdog++; ATH_LOCK(sc); @@ -6530,8 +6656,10 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 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_packets = ifp->if_get_counter(ifp, + IFCOUNTER_OPACKETS); + sc->sc_stats.ast_rx_packets = ifp->if_get_counter(ifp, + IFCOUNTER_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 @@ -7058,6 +7186,6 @@ ath_node_recv_pspoll(struct ieee80211_node *ni, struct mbuf *m) 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) +#if defined(IEEE80211_ALQ) || defined(AH_DEBUG_ALQ) || defined(ATH_DEBUG_ALQ) MODULE_DEPEND(if_ath, alq, 1, 1, 1); #endif diff --git a/sys/dev/ath/if_ath_lna_div.c b/sys/dev/ath/if_ath_lna_div.c index 961b83429c1f..f0a33a5036ef 100644 --- a/sys/dev/ath/if_ath_lna_div.c +++ b/sys/dev/ath/if_ath_lna_div.c @@ -209,6 +209,10 @@ ath_lna_div_ioctl(struct ath_softc *sc, struct ath_diag *ad) return (error); } +/* + * XXX need to low_rssi_thresh config from ath9k, to support CUS198 + * antenna diversity correctly. + */ static HAL_BOOL ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta, int mindelta, int main_rssi_avg, int alt_rssi_avg, int pkt_count) diff --git a/sys/dev/ath/if_ath_pci.c b/sys/dev/ath/if_ath_pci.c index dbbc411cdeaf..057ec2c66b1b 100644 --- a/sys/dev/ath/if_ath_pci.c +++ b/sys/dev/ath/if_ath_pci.c @@ -80,6 +80,98 @@ struct ath_pci_softc { void *sc_ih; /* interrupt handler */ }; +/* + * XXX eventually this should be some system level definition + * so modules will hvae probe/attach information like USB. + * But for now.. + */ +struct pci_device_id { + int vendor_id; + int device_id; + + int sub_vendor_id; + int sub_device_id; + + int driver_data; + + int match_populated:1; + int match_vendor_id:1; + int match_device_id:1; + int match_sub_vendor_id:1; + int match_sub_device_id:1; +}; + +#define PCI_VDEVICE(v, s) \ + .vendor_id = (v), \ + .device_id = (s), \ + .match_populated = 1, \ + .match_vendor_id = 1, \ + .match_device_id = 1 + +#define PCI_DEVICE_SUB(v, d, dv, ds) \ + .match_populated = 1, \ + .vendor_id = (v), .match_vendor_id = 1, \ + .device_id = (d), .match_device_id = 1, \ + .sub_vendor_id = (dv), .match_sub_vendor_id = 1, \ + .sub_device_id = (ds), .match_sub_device_id = 1 + +#define PCI_VENDOR_ID_ATHEROS 0x168c +#define PCI_VENDOR_ID_SAMSUNG 0x144d +#define PCI_VENDOR_ID_AZWAVE 0x1a3b +#define PCI_VENDOR_ID_FOXCONN 0x105b +#define PCI_VENDOR_ID_ATTANSIC 0x1969 +#define PCI_VENDOR_ID_ASUSTEK 0x1043 +#define PCI_VENDOR_ID_DELL 0x1028 +#define PCI_VENDOR_ID_QMI 0x1a32 +#define PCI_VENDOR_ID_LENOVO 0x17aa +#define PCI_VENDOR_ID_HP 0x103c + +#include "if_ath_pci_devlist.h" + +/* + * Attempt to find a match for the given device in + * the given device table. + * + * Returns the device structure or NULL if no matching + * PCI device is found. + */ +static const struct pci_device_id * +ath_pci_probe_device(device_t dev, const struct pci_device_id *dev_table, int nentries) +{ + int i; + int vendor_id, device_id; + int sub_vendor_id, sub_device_id; + + vendor_id = pci_get_vendor(dev); + device_id = pci_get_device(dev); + sub_vendor_id = pci_get_subvendor(dev); + sub_device_id = pci_get_subdevice(dev); + + for (i = 0; i < nentries; i++) { + /* Don't match on non-populated (eg empty) entries */ + if (! dev_table[i].match_populated) + continue; + + if (dev_table[i].match_vendor_id && + (dev_table[i].vendor_id != vendor_id)) + continue; + if (dev_table[i].match_device_id && + (dev_table[i].device_id != device_id)) + continue; + if (dev_table[i].match_sub_vendor_id && + (dev_table[i].sub_vendor_id != sub_vendor_id)) + continue; + if (dev_table[i].match_sub_device_id && + (dev_table[i].sub_device_id != sub_device_id)) + continue; + + /* Match */ + return (&dev_table[i]); + } + + return (NULL); +} + #define BS_BAR 0x10 #define PCIR_RETRY_TIMEOUT 0x41 #define PCIR_CFG_PMCSR 0x48 @@ -150,9 +242,15 @@ ath_pci_attach(device_t dev) const struct firmware *fw = NULL; const char *buf; #endif + const struct pci_device_id *pd; sc->sc_dev = dev; + /* Do this lookup anyway; figure out what to do with it later */ + pd = ath_pci_probe_device(dev, ath_pci_id_table, nitems(ath_pci_id_table)); + if (pd) + sc->sc_pci_devinfo = pd->driver_data; + /* * Enable bus mastering. */ diff --git a/sys/dev/ath/if_ath_pci_devlist.h b/sys/dev/ath/if_ath_pci_devlist.h new file mode 100644 index 000000000000..ae65909b3364 --- /dev/null +++ b/sys/dev/ath/if_ath_pci_devlist.h @@ -0,0 +1,669 @@ +/*- + * Copyright (c) 2014 Qualcomm Atheros. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the 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. + * + * $FreeBSD$ + */ + +static const struct pci_device_id ath_pci_id_table[] = { + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0023) }, /* PCI */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0024) }, /* PCI-E */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0027) }, /* PCI */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0029) }, /* PCI */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x002A) }, /* PCI-E */ + + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + PCI_VENDOR_ID_AZWAVE, + 0x1C71), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + PCI_VENDOR_ID_FOXCONN, + 0xE01F), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + 0x11AD, /* LITEON */ + 0x6632), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + 0x11AD, /* LITEON */ + 0x6642), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + PCI_VENDOR_ID_QMI, + 0x0306), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + 0x185F, /* WNC */ + 0x309D), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + 0x10CF, /* Fujitsu */ + 0x147C), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + 0x10CF, /* Fujitsu */ + 0x147D), + .driver_data = ATH_PCI_D3_L1_WAR }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002A, + 0x10CF, /* Fujitsu */ + 0x1536), + .driver_data = ATH_PCI_D3_L1_WAR }, + + /* AR9285 card for Asus */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x002B, + PCI_VENDOR_ID_AZWAVE, + 0x2C37), + .driver_data = ATH_PCI_BT_ANT_DIV }, + + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x002B) }, /* PCI-E */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x002D) }, /* PCI */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x002E) }, /* PCI-E */ + + /* Killer Wireless (3x3) */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0030, + 0x1A56, + 0x2000), + .driver_data = ATH_PCI_KILLER }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0030, + 0x1A56, + 0x2001), + .driver_data = ATH_PCI_KILLER }, + + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0030) }, /* PCI-E AR9300 */ + + /* PCI-E CUS198 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x2086), + .driver_data = ATH_PCI_CUS198 | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x1237), + .driver_data = ATH_PCI_CUS198 | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x2126), + .driver_data = ATH_PCI_CUS198 | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x126A), + .driver_data = ATH_PCI_CUS198 | ATH_PCI_BT_ANT_DIV }, + + /* PCI-E CUS230 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x2152), + .driver_data = ATH_PCI_CUS230 | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_FOXCONN, + 0xE075), + .driver_data = ATH_PCI_CUS230 | ATH_PCI_BT_ANT_DIV }, + + /* WB225 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_ATHEROS, + 0x3119), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_ATHEROS, + 0x3122), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x185F, /* WNC */ + 0x3119), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x185F, /* WNC */ + 0x3027), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0x4105), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0x4106), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0x410D), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0x410E), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0x410F), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0xC706), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0xC680), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_SAMSUNG, + 0xC708), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_LENOVO, + 0x3218), + .driver_data = ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_LENOVO, + 0x3219), + .driver_data = ATH_PCI_BT_ANT_DIV }, + + /* AR9485 cards with PLL power-save disabled by default. */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x2C97), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x2100), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x1C56, /* ASKEY */ + 0x4001), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x11AD, /* LITEON */ + 0x6627), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x11AD, /* LITEON */ + 0x6628), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_FOXCONN, + 0xE04E), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_FOXCONN, + 0xE04F), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x144F, /* ASKEY */ + 0x7197), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x1B9A, /* XAVI */ + 0x2000), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x1B9A, /* XAVI */ + 0x2001), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x1186), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x1F86), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x1195), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_AZWAVE, + 0x1F95), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x1B9A, /* XAVI */ + 0x1C00), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + 0x1B9A, /* XAVI */ + 0x1C01), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0032, + PCI_VENDOR_ID_ASUSTEK, + 0x850D), + .driver_data = ATH_PCI_NO_PLL_PWRSAVE }, + + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0032) }, /* PCI-E AR9485 */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0033) }, /* PCI-E AR9580 */ + + /* PCI-E CUS217 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_AZWAVE, + 0x2116), + .driver_data = ATH_PCI_CUS217 }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + 0x11AD, /* LITEON */ + 0x6661), + .driver_data = ATH_PCI_CUS217 }, + + /* AR9462 with WoW support */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_ATHEROS, + 0x3117), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_LENOVO, + 0x3214), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_ATTANSIC, + 0x0091), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_AZWAVE, + 0x2110), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_ASUSTEK, + 0x850E), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + 0x11AD, /* LITEON */ + 0x6631), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + 0x11AD, /* LITEON */ + 0x6641), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + PCI_VENDOR_ID_HP, + 0x1864), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + 0x14CD, /* USI */ + 0x0063), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + 0x14CD, /* USI */ + 0x0064), + .driver_data = ATH_PCI_WOW }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0034, + 0x10CF, /* Fujitsu */ + 0x1783), + .driver_data = ATH_PCI_WOW }, + + /* Killer Wireless (2x2) */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0030, + 0x1A56, + 0x2003), + .driver_data = ATH_PCI_KILLER }, + + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0034) }, /* PCI-E AR9462 */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0037) }, /* PCI-E AR1111/AR9485 */ + + /* CUS252 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ATHEROS, + 0x3028), + .driver_data = ATH_PCI_CUS252 | + ATH_PCI_AR9565_2ANT | + ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_AZWAVE, + 0x2176), + .driver_data = ATH_PCI_CUS252 | + ATH_PCI_AR9565_2ANT | + ATH_PCI_BT_ANT_DIV }, + + /* WB335 1-ANT */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_FOXCONN, + 0xE068), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x185F, /* WNC */ + 0xA119), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0632), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x06B2), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0842), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x6671), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x1B9A, /* XAVI */ + 0x2811), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x1B9A, /* XAVI */ + 0x2812), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x1B9A, /* XAVI */ + 0x28A1), + .driver_data = ATH_PCI_AR9565_1ANT }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_AZWAVE, + 0x218A), + .driver_data = ATH_PCI_AR9565_1ANT }, + + /* WB335 1-ANT / Antenna Diversity */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ATHEROS, + 0x3025), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ATHEROS, + 0x3026), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ATHEROS, + 0x302B), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_FOXCONN, + 0xE069), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x185F, /* WNC */ + 0x3028), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0622), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0672), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0662), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x06A2), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0682), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_AZWAVE, + 0x213A), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_HP, + 0x18E3), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_HP, + 0x217F), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_HP, + 0x2005), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_DELL, + 0x020C), + .driver_data = ATH_PCI_AR9565_1ANT | ATH_PCI_BT_ANT_DIV }, + + /* WB335 2-ANT / Antenna-Diversity */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_SAMSUNG, + 0x411A), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_SAMSUNG, + 0x411B), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_SAMSUNG, + 0x411C), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_SAMSUNG, + 0x411D), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_SAMSUNG, + 0x411E), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ATHEROS, + 0x3027), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ATHEROS, + 0x302C), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0642), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0652), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0612), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0832), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x11AD, /* LITEON */ + 0x0692), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_AZWAVE, + 0x2130), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_AZWAVE, + 0x213B), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_AZWAVE, + 0x2182), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x144F, /* ASKEY */ + 0x7202), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x1B9A, /* XAVI */ + 0x2810), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x1B9A, /* XAVI */ + 0x28A2), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x185F, /* WNC */ + 0x3027), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + 0x185F, /* WNC */ + 0xA120), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_FOXCONN, + 0xE07F), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_FOXCONN, + 0xE081), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_LENOVO, + 0x3026), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_LENOVO, + 0x4026), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_ASUSTEK, + 0x85F2), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, + 0x0036, + PCI_VENDOR_ID_DELL, + 0x020E), + .driver_data = ATH_PCI_AR9565_2ANT | ATH_PCI_BT_ANT_DIV }, + + /* PCI-E AR9565 (WB335) */ + { PCI_VDEVICE(PCI_VENDOR_ID_ATHEROS, 0x0036), + .driver_data = ATH_PCI_BT_ANT_DIV }, + + { 0 } +}; + diff --git a/sys/dev/ath/if_ath_rx.c b/sys/dev/ath/if_ath_rx.c index 2f6cb58487d5..bed94887c988 100644 --- a/sys/dev/ath/if_ath_rx.c +++ b/sys/dev/ath/if_ath_rx.c @@ -704,7 +704,7 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status *rs, HAL_STATUS status, rs->rs_keyix-32 : rs->rs_keyix); } } - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); rx_error: /* * Cleanup any pending partial frame. @@ -830,7 +830,7 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status *rs, HAL_STATUS status, rs->rs_antenna |= 0x4; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); sc->sc_stats.ast_ant_rx[rs->rs_antenna]++; /* diff --git a/sys/dev/ath/if_ath_rx_edma.c b/sys/dev/ath/if_ath_rx_edma.c index a8758cfa268b..7aa818fe02aa 100644 --- a/sys/dev/ath/if_ath_rx_edma.c +++ b/sys/dev/ath/if_ath_rx_edma.c @@ -160,10 +160,20 @@ ath_edma_stoprecv(struct ath_softc *sc, int dodelay) struct ath_hal *ah = sc->sc_ah; ATH_RX_LOCK(sc); + ath_hal_stoppcurecv(ah); ath_hal_setrxfilter(ah, 0); - ath_hal_stopdmarecv(ah); + /* + * + */ + if (ath_hal_stopdmarecv(ah) == AH_TRUE) + sc->sc_rx_stopped = 1; + + /* + * Give the various bus FIFOs (not EDMA descriptor FIFO) + * time to finish flushing out data. + */ DELAY(3000); /* Flush RX pending for each queue */ @@ -218,10 +228,6 @@ ath_edma_reinit_fifo(struct ath_softc *sc, HAL_RX_QUEUE qtype) /* * Start receive. - * - * XXX TODO: this needs to reallocate the FIFO entries when a reset - * occurs, in case the FIFO is filled up and no new descriptors get - * thrown into the FIFO. */ static int ath_edma_startrecv(struct ath_softc *sc) @@ -230,35 +236,31 @@ ath_edma_startrecv(struct ath_softc *sc) ATH_RX_LOCK(sc); + /* + * Sanity check - are we being called whilst RX + * isn't stopped? If so, we may end up pushing + * too many entries into the RX FIFO and + * badness occurs. + */ + /* Enable RX FIFO */ ath_hal_rxena(ah); /* - * Entries should only be written out if the - * FIFO is empty. - * - * XXX This isn't correct. I should be looking - * at the value of AR_RXDP_SIZE (0x0070) to determine - * how many entries are in here. - * - * A warm reset will clear the registers but not the FIFO. - * - * And I believe this is actually the address of the last - * handled buffer rather than the current FIFO pointer. - * So if no frames have been (yet) seen, we'll reinit the - * FIFO. - * - * I'll chase that up at some point. + * In theory the hardware has been initialised, right? */ - if (ath_hal_getrxbuf(sc->sc_ah, HAL_RX_QUEUE_HP) == 0) { + if (sc->sc_rx_resetted == 1) { DPRINTF(sc, ATH_DEBUG_EDMA_RX, "%s: Re-initing HP FIFO\n", __func__); ath_edma_reinit_fifo(sc, HAL_RX_QUEUE_HP); - } - if (ath_hal_getrxbuf(sc->sc_ah, HAL_RX_QUEUE_LP) == 0) { DPRINTF(sc, ATH_DEBUG_EDMA_RX, "%s: Re-initing LP FIFO\n", __func__); ath_edma_reinit_fifo(sc, HAL_RX_QUEUE_LP); + sc->sc_rx_resetted = 0; + } else { + device_printf(sc->sc_dev, + "%s: called without resetting chip?\n", + __func__); } /* Add up to m_fifolen entries in each queue */ @@ -266,6 +268,9 @@ ath_edma_startrecv(struct ath_softc *sc) * These must occur after the above write so the FIFO buffers * are pushed/tracked in the same order as the hardware will * process them. + * + * XXX TODO: is this really necessary? We should've stopped + * the hardware already and reinitialised it, so it's a no-op. */ ath_edma_rxfifo_alloc(sc, HAL_RX_QUEUE_HP, sc->sc_rxedma[HAL_RX_QUEUE_HP].m_fifolen); @@ -276,6 +281,11 @@ ath_edma_startrecv(struct ath_softc *sc) ath_mode_init(sc); ath_hal_startpcurecv(ah); + /* + * We're now doing RX DMA! + */ + sc->sc_rx_stopped = 0; + ATH_RX_UNLOCK(sc); return (0); @@ -380,6 +390,21 @@ ath_edma_recv_proc_queue(struct ath_softc *sc, HAL_RX_QUEUE qtype, ATH_RX_LOCK(sc); +#if 1 + if (sc->sc_rx_resetted == 1) { + /* + * XXX We shouldn't ever be scheduled if + * receive has been stopped - so complain + * loudly! + */ + device_printf(sc->sc_dev, + "%s: sc_rx_resetted=1! Bad!\n", + __func__); + ATH_RX_UNLOCK(sc); + return; + } +#endif + do { bf = re->m_fifo[re->m_fifo_head]; /* This shouldn't occur! */ @@ -451,24 +476,6 @@ ath_edma_recv_proc_queue(struct ath_softc *sc, HAL_RX_QUEUE qtype, "ath edma rx proc: npkts=%d\n", npkts); - /* Handle resched and kickpcu appropriately */ - ATH_PCU_LOCK(sc); - if (dosched && sc->sc_kickpcu) { - ATH_KTR(sc, ATH_KTR_ERROR, 0, - "ath_edma_recv_proc_queue(): kickpcu"); - if (npkts > 0) - device_printf(sc->sc_dev, - "%s: handled npkts %d\n", - __func__, npkts); - - /* - * XXX TODO: what should occur here? Just re-poke and - * re-enable the RX FIFO? - */ - sc->sc_kickpcu = 0; - } - ATH_PCU_UNLOCK(sc); - return; } diff --git a/sys/dev/ath/if_ath_tx.c b/sys/dev/ath/if_ath_tx.c index 1b140da6b077..096278eb4519 100644 --- a/sys/dev/ath/if_ath_tx.c +++ b/sys/dev/ath/if_ath_tx.c @@ -2424,7 +2424,7 @@ ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, } } sc->sc_wd_timer = 5; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->sc_stats.ast_tx_raw++; /* @@ -2473,7 +2473,7 @@ ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, badbad: ATH_KTR(sc, ATH_KTR_TX, 2, "ath_raw_xmit: bad0: m=%p, params=%p", m, params); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->sc_stats.ast_tx_raw_fail++; ieee80211_free_node(ni); diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index d1ae089f49b8..e888ca2ee9ed 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -81,6 +81,25 @@ #define ATH_BEACON_CWMIN_DEFAULT 0 /* default cwmin for ap beacon q */ #define ATH_BEACON_CWMAX_DEFAULT 0 /* default cwmax for ap beacon q */ +/* + * The following bits can be set during the PCI (and perhaps non-PCI + * later) device probe path. + * + * It controls some of the driver and HAL behaviour. + */ + +#define ATH_PCI_CUS198 0x0001 +#define ATH_PCI_CUS230 0x0002 +#define ATH_PCI_CUS217 0x0004 +#define ATH_PCI_CUS252 0x0008 +#define ATH_PCI_WOW 0x0010 +#define ATH_PCI_BT_ANT_DIV 0x0020 +#define ATH_PCI_D3_L1_WAR 0x0040 +#define ATH_PCI_AR9565_1ANT 0x0080 +#define ATH_PCI_AR9565_2ANT 0x0100 +#define ATH_PCI_NO_PLL_PWRSAVE 0x0200 +#define ATH_PCI_KILLER 0x0400 + /* * The key cache is used for h/w cipher state and also for * tracking station state such as the current tx antenna. @@ -566,6 +585,8 @@ struct ath_softc { int sc_tx_statuslen; int sc_tx_nmaps; /* Number of TX maps */ int sc_edma_bufsize; + int sc_rx_stopped; /* XXX only for EDMA */ + int sc_rx_resetted; /* XXX only for EDMA */ void (*sc_node_cleanup)(struct ieee80211_node *); void (*sc_node_free)(struct ieee80211_node *); @@ -882,6 +903,9 @@ struct ath_softc { HAL_POWER_MODE sc_cur_powerstate; int sc_powersave_refcnt; + + /* ATH_PCI_* flags */ + uint32_t sc_pci_devinfo; }; #define ATH_LOCK_INIT(_sc) \ diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 199fcb1ed696..0d2b44ba5182 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -62,7 +62,20 @@ __FBSDID("$FreeBSD$"); #include #include -static timeout_t atkbd_timeout; +typedef struct atkbd_state { + KBDC kbdc; /* keyboard controller */ + int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ + int ks_flags; /* flags */ +#define COMPOSE (1 << 0) + int ks_polling; + int ks_state; /* shift/lock key state */ + int ks_accents; /* accent key index (> 0) */ + u_int ks_composed_char; /* composed char code (> 0) */ + u_char ks_prefix; /* AT scan code prefix */ + struct callout ks_timer; +} atkbd_state_t; + +static void atkbd_timeout(void *arg); static void atkbd_shutdown_final(void *v); int @@ -88,6 +101,7 @@ int atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) { keyboard_switch_t *sw; + atkbd_state_t *state; int args[2]; int error; int unit; @@ -120,6 +134,8 @@ atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) * This is a kludge to compensate for lost keyboard interrupts. * A similar code used to be in syscons. See below. XXX */ + state = (atkbd_state_t *)(*kbd)->kb_data; + callout_init(&state->ks_timer, 0); atkbd_timeout(*kbd); if (bootverbose) @@ -134,6 +150,7 @@ atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) static void atkbd_timeout(void *arg) { + atkbd_state_t *state; keyboard_t *kbd; int s; @@ -175,25 +192,14 @@ atkbd_timeout(void *arg) kbdd_intr(kbd, NULL); } splx(s); - timeout(atkbd_timeout, arg, hz/10); + state = (atkbd_state_t *)kbd->kb_data; + callout_reset(&state->ks_timer, hz / 10, atkbd_timeout, arg); } /* LOW-LEVEL */ #define ATKBD_DEFAULT 0 -typedef struct atkbd_state { - KBDC kbdc; /* keyboard controller */ - int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ - int ks_flags; /* flags */ -#define COMPOSE (1 << 0) - int ks_polling; - int ks_state; /* shift/lock key state */ - int ks_accents; /* accent key index (> 0) */ - u_int ks_composed_char; /* composed char code (> 0) */ - u_char ks_prefix; /* AT scan code prefix */ -} atkbd_state_t; - /* keyboard driver declaration */ static int atkbd_configure(int flags); static kbd_probe_t atkbd_probe; @@ -470,7 +476,10 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) static int atkbd_term(keyboard_t *kbd) { + atkbd_state_t *state = (atkbd_state_t *)kbd->kb_data; + kbd_unregister(kbd); + callout_drain(&state->ks_timer); return 0; } diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index 0f6d68b31ec9..2f9f4595a9f5 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -457,9 +457,10 @@ static struct mbuf *bce_tso_setup (struct bce_softc *, struct mbuf **, u16 *); static int bce_tx_encap (struct bce_softc *, struct mbuf **); static void bce_start_locked (struct ifnet *); -static void bce_start (struct ifnet *); -static int bce_ioctl (struct ifnet *, u_long, caddr_t); -static void bce_watchdog (struct bce_softc *); +static void bce_start (struct ifnet *); +static int bce_ioctl (struct ifnet *, u_long, caddr_t); +static uint64_t bce_get_counter (struct ifnet *, ift_counter); +static void bce_watchdog (struct bce_softc *); static int bce_ifmedia_upd (struct ifnet *); static int bce_ifmedia_upd_locked (struct ifnet *); static void bce_ifmedia_sts (struct ifnet *, struct ifmediareq *); @@ -1389,6 +1390,7 @@ bce_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bce_ioctl; ifp->if_start = bce_start; + ifp->if_get_counter = bce_get_counter; ifp->if_init = bce_init; ifp->if_mtu = ETHERMTU; @@ -6747,9 +6749,7 @@ bce_rx_intr(struct bce_softc *sc) L2_FHDR_ERRORS_TOO_SHORT | L2_FHDR_ERRORS_GIANT_FRAME)) { /* Log the error and release the mbuf. */ - ifp->if_ierrors++; sc->l2fhdr_error_count++; - m_freem(m0); m0 = NULL; goto bce_rx_intr_next_rx; @@ -6830,7 +6830,7 @@ bce_rx_intr(struct bce_softc *sc) } /* Increment received packet statistics. */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); bce_rx_intr_next_rx: sw_rx_cons = NEXT_RX_BD(sw_rx_cons); @@ -6988,7 +6988,7 @@ bce_tx_intr(struct bce_softc *sc) sc->tx_mbuf_ptr[sw_tx_chain_cons] = NULL; DBRUN(sc->debug_tx_mbuf_alloc--); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } sc->used_tx_bd--; @@ -7901,7 +7901,7 @@ bce_watchdog(struct bce_softc *sc) sc->bce_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; bce_init_locked(sc); - sc->bce_ifp->if_oerrors++; + sc->watchdog_timeouts++; bce_watchdog_exit: REG_WR(sc, BCE_EMAC_RX_STATUS, status); @@ -8157,27 +8157,14 @@ bce_set_rx_mode(struct bce_softc *sc) static void bce_stats_update(struct bce_softc *sc) { - struct ifnet *ifp; struct statistics_block *stats; DBENTER(BCE_EXTREME_MISC); - ifp = sc->bce_ifp; - bus_dmamap_sync(sc->stats_tag, sc->stats_map, BUS_DMASYNC_POSTREAD); stats = (struct statistics_block *) sc->stats_block; - /* - * Certain controllers don't report - * carrier sense errors correctly. - * See errata E11_5708CA0_1165. - */ - if (!(BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5706) && - !(BCE_CHIP_ID(sc) == BCE_CHIP_ID_5708_A0)) - ifp->if_oerrors += - (u_long) stats->stat_Dot3StatsCarrierSenseErrors; - /* * Update the sysctl statistics from the * hardware statistics. @@ -8359,35 +8346,51 @@ bce_stats_update(struct bce_softc *sc) sc->com_no_buffers = REG_RD_IND(sc, 0x120084); - /* - * Update the interface statistics from the - * hardware statistics. - */ - ifp->if_collisions = - (u_long) sc->stat_EtherStatsCollisions; - - /* ToDo: This method loses soft errors. */ - ifp->if_ierrors = - (u_long) sc->stat_EtherStatsUndersizePkts + - (u_long) sc->stat_EtherStatsOversizePkts + - (u_long) sc->stat_IfInMBUFDiscards + - (u_long) sc->stat_Dot3StatsAlignmentErrors + - (u_long) sc->stat_Dot3StatsFCSErrors + - (u_long) sc->stat_IfInRuleCheckerDiscards + - (u_long) sc->stat_IfInFTQDiscards + - (u_long) sc->com_no_buffers; - - /* ToDo: This method loses soft errors. */ - ifp->if_oerrors = - (u_long) sc->stat_emac_tx_stat_dot3statsinternalmactransmiterrors + - (u_long) sc->stat_Dot3StatsExcessiveCollisions + - (u_long) sc->stat_Dot3StatsLateCollisions; - /* ToDo: Add additional statistics? */ DBEXIT(BCE_EXTREME_MISC); } +static uint64_t +bce_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct bce_softc *sc; + uint64_t rv; + + sc = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_COLLISIONS: + return (sc->stat_EtherStatsCollisions); + case IFCOUNTER_IERRORS: + return (sc->stat_EtherStatsUndersizePkts + + sc->stat_EtherStatsOversizePkts + + sc->stat_IfInMBUFDiscards + + sc->stat_Dot3StatsAlignmentErrors + + sc->stat_Dot3StatsFCSErrors + + sc->stat_IfInRuleCheckerDiscards + + sc->stat_IfInFTQDiscards + + sc->l2fhdr_error_count + + sc->com_no_buffers); + case IFCOUNTER_OERRORS: + rv = sc->stat_Dot3StatsExcessiveCollisions + + sc->stat_emac_tx_stat_dot3statsinternalmactransmiterrors + + sc->stat_Dot3StatsLateCollisions + + sc->watchdog_timeouts; + /* + * Certain controllers don't report + * carrier sense errors correctly. + * See errata E11_5708CA0_1165. + */ + if (!(BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5706) && + !(BCE_CHIP_ID(sc) == BCE_CHIP_ID_5708_A0)) + rv += sc->stat_Dot3StatsCarrierSenseErrors; + return (rv); + default: + return (if_get_counter_default(ifp, cnt)); + } +} + /****************************************************************************/ /* Periodic function to notify the bootcode that the driver is still */ diff --git a/sys/dev/bce/if_bcereg.h b/sys/dev/bce/if_bcereg.h index 16f99ccdf55e..d9df1fa1b513 100644 --- a/sys/dev/bce/if_bcereg.h +++ b/sys/dev/bce/if_bcereg.h @@ -6692,6 +6692,7 @@ struct bce_softc u32 l2fhdr_error_count; u32 dma_map_addr_tx_failed_count; u32 dma_map_addr_rx_failed_count; + u32 watchdog_timeouts; /* Host coalescing block command register */ u32 hc_command; diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c index c4055bb3f360..eaad8f0b5981 100644 --- a/sys/dev/bfe/if_bfe.c +++ b/sys/dev/bfe/if_bfe.c @@ -1310,22 +1310,22 @@ bfe_stats_update(struct bfe_softc *sc) stats->rx_control_frames += mib[MIB_RX_NPAUSE]; /* Update counters in ifnet. */ - ifp->if_opackets += (u_long)mib[MIB_TX_GOOD_P]; - ifp->if_collisions += (u_long)mib[MIB_TX_TCOLS]; - ifp->if_oerrors += (u_long)mib[MIB_TX_URUNS] + + if_inc_counter(ifp, IFCOUNTER_OPACKETS, (u_long)mib[MIB_TX_GOOD_P]); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (u_long)mib[MIB_TX_TCOLS]); + if_inc_counter(ifp, IFCOUNTER_OERRORS, (u_long)mib[MIB_TX_URUNS] + (u_long)mib[MIB_TX_ECOLS] + (u_long)mib[MIB_TX_DEFERED] + - (u_long)mib[MIB_TX_CLOST]; + (u_long)mib[MIB_TX_CLOST]); - ifp->if_ipackets += (u_long)mib[MIB_RX_GOOD_P]; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, (u_long)mib[MIB_RX_GOOD_P]); - ifp->if_ierrors += mib[MIB_RX_JABBER] + + if_inc_counter(ifp, IFCOUNTER_IERRORS, mib[MIB_RX_JABBER] + mib[MIB_RX_MISS] + mib[MIB_RX_CRCA] + mib[MIB_RX_USIZE] + mib[MIB_RX_CRC] + mib[MIB_RX_ALIGN] + - mib[MIB_RX_SYM]; + mib[MIB_RX_SYM]); } static void @@ -1403,7 +1403,7 @@ bfe_rxeof(struct bfe_softc *sc) * reuse mapped buffer from errored frame. */ if (bfe_list_newbuf(sc, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); bfe_discard_buf(sc, cons); continue; } @@ -1818,7 +1818,7 @@ bfe_watchdog(struct bfe_softc *sc) device_printf(sc->bfe_dev, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; bfe_init_locked(sc); diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 384c8f40f1c5..838be4fdd80a 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -434,6 +434,7 @@ static int bge_shutdown(device_t); static int bge_ifmedia_upd_locked(if_t); static int bge_ifmedia_upd(if_t); static void bge_ifmedia_sts(if_t, struct ifmediareq *); +static uint64_t bge_get_counter(if_t, ift_counter); static uint8_t bge_nvram_getbyte(struct bge_softc *, int, uint8_t *); static int bge_read_nvram(struct bge_softc *, caddr_t, int, int); @@ -3738,6 +3739,7 @@ bge_attach(device_t dev) if_setioctlfn(ifp, bge_ioctl); if_setstartfn(ifp, bge_start); if_setinitfn(ifp, bge_init); + if_setgetcounterfn(ifp, bge_get_counter); if_setsendqlen(ifp, BGE_TX_RING_CNT - 1); if_setsendqready(ifp); if_sethwassist(ifp, sc->bge_csum_features); @@ -4364,7 +4366,7 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int holdlck) } if (bge_newbuf_jumbo(sc, rxidx) != 0) { bge_rxreuse_jumbo(sc, rxidx); - if_inciqdrops(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } BGE_INC(sc->bge_jumbo, BGE_JUMBO_RX_RING_CNT); @@ -4377,13 +4379,13 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod, int holdlck) } if (bge_newbuf_std(sc, rxidx) != 0) { bge_rxreuse_std(sc, rxidx); - if_inciqdrops(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } BGE_INC(sc->bge_std, BGE_STD_RX_RING_CNT); } - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); #ifndef __NO_STRICT_ALIGNMENT /* * For architectures with strict alignment we must make sure @@ -4512,7 +4514,7 @@ bge_txeof(struct bge_softc *sc, uint16_t tx_cons) idx = sc->bge_tx_saved_considx; cur_tx = &sc->bge_ldata.bge_tx_ring[idx]; if (cur_tx->bge_flags & BGE_TXBDFLAG_END) - if_incopackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (sc->bge_cdata.bge_tx_chain[idx] != NULL) { bus_dmamap_sync(sc->bge_cdata.bge_tx_mtag, sc->bge_cdata.bge_tx_dmamap[idx], @@ -4917,10 +4919,6 @@ bge_stats_update_regs(struct bge_softc *sc) stats->RecvThresholdHit += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_RXTHRESH_HIT); - if_setcollisions(ifp, (u_long)stats->etherStatsCollisions); - if_setierrors(ifp, (u_long)(stats->NoMoreRxBDs + stats->InputDiscards + - stats->InputErrors)); - if (sc->bge_flags & BGE_FLAG_RDMA_BUG) { /* * If controller transmitted more than BGE_NUM_RDMA_CHANNELS @@ -4997,21 +4995,21 @@ bge_stats_update(struct bge_softc *sc) CSR_READ_4(sc, stats + offsetof(struct bge_stats, stat)) cnt = READ_STAT(sc, stats, txstats.etherStatsCollisions.bge_addr_lo); - if_inccollisions(ifp, (uint32_t)(cnt - sc->bge_tx_collisions)); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cnt - sc->bge_tx_collisions); sc->bge_tx_collisions = cnt; cnt = READ_STAT(sc, stats, nicNoMoreRxBDs.bge_addr_lo); - if_incierrors(ifp, (uint32_t)(cnt - sc->bge_rx_nobds)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, cnt - sc->bge_rx_nobds); sc->bge_rx_nobds = cnt; cnt = READ_STAT(sc, stats, ifInErrors.bge_addr_lo); - if_incierrors(ifp, (uint32_t)(cnt - sc->bge_rx_inerrs)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, cnt - sc->bge_rx_inerrs); sc->bge_rx_inerrs = cnt; cnt = READ_STAT(sc, stats, ifInDiscards.bge_addr_lo); - if_incierrors(ifp, (uint32_t)(cnt - sc->bge_rx_discards)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, cnt - sc->bge_rx_discards); sc->bge_rx_discards = cnt; cnt = READ_STAT(sc, stats, txstats.ifOutDiscards.bge_addr_lo); - if_incoerrors(ifp, (uint32_t)(cnt - sc->bge_tx_discards)); + if_inc_counter(ifp, IFCOUNTER_OERRORS, cnt - sc->bge_tx_discards); sc->bge_tx_discards = cnt; #undef READ_STAT @@ -5830,7 +5828,7 @@ bge_ioctl(if_t ifp, u_long command, caddr_t data) #ifdef DEVICE_POLLING if (mask & IFCAP_POLLING) { if (ifr->ifr_reqcap & IFCAP_POLLING) { - error = ether_poll_register_drv(bge_poll, ifp); + error = ether_poll_register(bge_poll, ifp); if (error) return (error); BGE_LOCK(sc); @@ -5950,7 +5948,7 @@ bge_watchdog(struct bge_softc *sc) if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); bge_init_locked(sc); - if_incoerrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } static void @@ -6770,3 +6768,25 @@ bge_get_eaddr(struct bge_softc *sc, uint8_t eaddr[]) } return (*func == NULL ? ENXIO : 0); } + +static uint64_t +bge_get_counter(if_t ifp, ift_counter cnt) +{ + struct bge_softc *sc; + struct bge_mac_stats *stats; + + sc = if_getsoftc(ifp); + if (!BGE_IS_5705_PLUS(sc)) + return (if_get_counter_default(ifp, cnt)); + stats = &sc->bge_mac_stats; + + switch (cnt) { + case IFCOUNTER_IERRORS: + return (stats->NoMoreRxBDs + stats->InputDiscards + + stats->InputErrors); + case IFCOUNTER_COLLISIONS: + return (stats->etherStatsCollisions); + default: + return (if_get_counter_default(ifp, cnt)); + } +} diff --git a/sys/dev/bm/if_bm.c b/sys/dev/bm/if_bm.c index 8db158343176..860e1771a9b1 100644 --- a/sys/dev/bm/if_bm.c +++ b/sys/dev/bm/if_bm.c @@ -608,7 +608,7 @@ bm_rxintr(void *xsc) m = sc->sc_rxsoft[i].rxs_mbuf; if (bm_add_rxbuf(sc, i)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m = NULL; continue; } @@ -616,7 +616,7 @@ bm_rxintr(void *xsc) if (m == NULL) continue; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_len -= (dbdma_get_residuals(sc->sc_rxdma, i) + 2); m->m_pkthdr.len = m->m_len; @@ -678,7 +678,7 @@ bm_txintr(void *xsc) STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); progress = 1; } @@ -1196,12 +1196,13 @@ bm_tick(void *arg) struct bm_softc *sc = arg; /* Read error counters */ - sc->sc_ifp->if_collisions += CSR_READ_2(sc, BM_TX_NCCNT) + - CSR_READ_2(sc, BM_TX_FCCNT) + CSR_READ_2(sc, BM_TX_EXCNT) + - CSR_READ_2(sc, BM_TX_LTCNT); + if_inc_counter(sc->sc_ifp, IFCOUNTER_COLLISIONS, + CSR_READ_2(sc, BM_TX_NCCNT) + CSR_READ_2(sc, BM_TX_FCCNT) + + CSR_READ_2(sc, BM_TX_EXCNT) + CSR_READ_2(sc, BM_TX_LTCNT)); - sc->sc_ifp->if_ierrors += CSR_READ_2(sc, BM_RX_LECNT) + - CSR_READ_2(sc, BM_RX_AECNT) + CSR_READ_2(sc, BM_RX_FECNT); + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, + CSR_READ_2(sc, BM_RX_LECNT) + CSR_READ_2(sc, BM_RX_AECNT) + + CSR_READ_2(sc, BM_RX_FECNT)); /* Zero collision counters */ CSR_WRITE_2(sc, BM_TX_NCCNT, 0); diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c index ca9612e93436..9e915aac669e 100644 --- a/sys/dev/bwi/if_bwi.c +++ b/sys/dev/bwi/if_bwi.c @@ -1401,7 +1401,7 @@ bwi_start_locked(struct ifnet *ifp) if (k == NULL) { ieee80211_free_node(ni); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -1411,7 +1411,7 @@ bwi_start_locked(struct ifnet *ifp) /* 'm' is freed in bwi_encap() if we reach here */ if (ni != NULL) ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } @@ -1419,7 +1419,7 @@ bwi_start_locked(struct ifnet *ifp) tbd->tbd_used++; idx = (idx + 1) % BWI_TX_NDESC; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) { ifp->if_drv_flags |= IFF_DRV_OACTIVE; @@ -1466,7 +1466,7 @@ bwi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, error = bwi_encap_raw(sc, idx, m, ni, params); } if (error == 0) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (++tbd->tbd_used + BWI_TX_NSPRDESC >= BWI_TX_NDESC) ifp->if_drv_flags |= IFF_DRV_OACTIVE; tbd->tbd_idx = (idx + 1) % BWI_TX_NDESC; @@ -1474,7 +1474,7 @@ bwi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, } else { /* NB: m is reclaimed on encap failure */ ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } BWI_UNLOCK(sc); return error; @@ -1491,7 +1491,7 @@ bwi_watchdog(void *arg) BWI_ASSERT_LOCKED(sc); if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0) { if_printf(ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); taskqueue_enqueue(sc->sc_tq, &sc->sc_restart_task); } callout_reset(&sc->sc_watchdog_timer, hz, bwi_watchdog, sc); @@ -2639,7 +2639,7 @@ bwi_rxeof(struct bwi_softc *sc, int end_idx) BUS_DMASYNC_POSTREAD); if (bwi_newbuf(sc, idx, 0)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto next; } @@ -2655,7 +2655,7 @@ bwi_rxeof(struct bwi_softc *sc, int end_idx) if (buflen < BWI_FRAME_MIN_LEN(wh_ofs)) { if_printf(ifp, "%s: zero length data, hdr_extra %d\n", __func__, hdr_extra); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); goto next; } diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index 4e9a8d9ba36c..6c5b8fd70d96 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -1311,7 +1311,7 @@ bwn_start_locked(struct ifnet *ifp) if (ni == NULL) { device_printf(sc->sc_dev, "unexpected NULL ni\n"); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } KASSERT(ni != NULL, ("%s:%d: fail", __func__, __LINE__)); @@ -1321,7 +1321,7 @@ bwn_start_locked(struct ifnet *ifp) if (k == NULL) { ieee80211_free_node(ni); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -1330,7 +1330,7 @@ bwn_start_locked(struct ifnet *ifp) if (bwn_tx_start(sc, ni, m) != 0) { if (ni != NULL) ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } @@ -1587,7 +1587,7 @@ bwn_watchdog(void *arg) if (sc->sc_watchdog_timer != 0 && --sc->sc_watchdog_timer == 0) { if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } callout_schedule(&sc->sc_watchdog_ch, hz); } @@ -2748,7 +2748,7 @@ bwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, if (bwn_tx_isfull(sc, m)) { ieee80211_free_node(ni); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); BWN_UNLOCK(sc); return (ENOBUFS); } @@ -2756,7 +2756,7 @@ bwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, if (bwn_tx_start(sc, ni, m) != 0) { if (ni != NULL) ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } sc->sc_watchdog_timer = 5; BWN_UNLOCK(sc); @@ -8929,14 +8929,14 @@ bwn_dma_rxeof(struct bwn_dma_ring *dr, int *slot) m = meta->mt_m; if (bwn_dma_newbuf(dr, desc, meta, 0)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } rxhdr = mtod(m, struct bwn_rxhdr4 *); len = le16toh(rxhdr->frame_len); if (len <= 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } if (bwn_dma_check_redzone(dr, m)) { @@ -9366,7 +9366,7 @@ bwn_rxeof(struct bwn_mac *mac, struct mbuf *m, const void *_rxhdr) rssi = rxhdr->phy.abg.rssi; /* XXX incorrect RSSI calculation? */ noise = mac->mac_stats.link_noise; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); BWN_UNLOCK(sc); @@ -9441,7 +9441,7 @@ bwn_dma_handle_txeof(struct bwn_mac *mac, dr->dr_usedslot--; if (meta->mt_islast) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); break; } slot = bwn_dma_nextslot(dr, slot); @@ -9487,7 +9487,7 @@ bwn_pio_handle_txeof(struct bwn_mac *mac, tp->tp_m = NULL; TAILQ_INSERT_TAIL(&tq->tq_pktlist, tp, tp_list); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->sc_watchdog_timer = 0; if (tq->tq_stop) { diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index 50106bf71e20..ac20d781f608 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -3222,7 +3222,7 @@ bxe_tpa_stop(struct bxe_softc *sc, m->m_flags |= M_FLOWID; #endif - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); fp->eth_q_stats.rx_tpa_pkts++; /* pass the frame to the stack */ @@ -3465,7 +3465,7 @@ bxe_rxeof(struct bxe_softc *sc, /* pass the frame to the stack */ if (__predict_true(m != NULL)) { - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); rx_pkts++; if_input(ifp, m); } @@ -13279,6 +13279,7 @@ bxe_init_ifnet(struct bxe_softc *sc) if_setflags(ifp, (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST)); if_setioctlfn(ifp, bxe_ioctl); if_setstartfn(ifp, bxe_tx_start); + if_setgetcounterfn(ifp, bxe_get_counter); #if __FreeBSD_version >= 800000 if_settransmitfn(ifp, bxe_tx_mq_start); if_setqflushfn(ifp, bxe_mq_flush); diff --git a/sys/dev/bxe/bxe_stats.c b/sys/dev/bxe/bxe_stats.c index f6b23975cfed..3d33fb7d8d76 100644 --- a/sys/dev/bxe/bxe_stats.c +++ b/sys/dev/bxe/bxe_stats.c @@ -1164,50 +1164,54 @@ bxe_storm_stats_update(struct bxe_softc *sc) static void bxe_net_stats_update(struct bxe_softc *sc) { - struct bxe_eth_stats *estats = &sc->eth_stats; - if_t ifnet = sc->ifp; - int i; - if_setipackets(ifnet, - bxe_hilo(&estats->total_unicast_packets_received_hi) + - bxe_hilo(&estats->total_multicast_packets_received_hi) + - bxe_hilo(&estats->total_broadcast_packets_received_hi)); + for (int i = 0; i < sc->num_queues; i++) + if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, + le32toh(sc->fp[i].old_tclient.checksum_discard)); +} - if_setopackets(ifnet, - bxe_hilo(&estats->total_unicast_packets_transmitted_hi) + - bxe_hilo(&estats->total_multicast_packets_transmitted_hi) + - bxe_hilo(&estats->total_broadcast_packets_transmitted_hi)); +uint64_t +bxe_get_counter(if_t ifp, ift_counter cnt) +{ + struct bxe_softc *sc; + struct bxe_eth_stats *estats; - if_setibytes(ifnet, bxe_hilo(&estats->total_bytes_received_hi)); + sc = if_getsoftc(ifp); + estats = &sc->eth_stats; - if_setobytes(ifnet, bxe_hilo(&estats->total_bytes_transmitted_hi)); - - for (i = 0; i < sc->num_queues; i++) { - struct tstorm_per_queue_stats *old_tclient = - &sc->fp[i].old_tclient; - if_inciqdrops(ifnet, le32toh(old_tclient->checksum_discard)); - } - - if_setierrors(ifnet, - bxe_hilo(&estats->rx_stat_etherstatsundersizepkts_hi) + - bxe_hilo(&estats->etherstatsoverrsizepkts_hi) + - bxe_hilo(&estats->brb_drop_hi) + - bxe_hilo(&estats->brb_truncate_hi) + - bxe_hilo(&estats->rx_stat_dot3statsfcserrors_hi) + - bxe_hilo(&estats->rx_stat_dot3statsalignmenterrors_hi) + - bxe_hilo(&estats->no_buff_discard_hi)); - - if_setoerrors(ifnet, - bxe_hilo(&estats->rx_stat_dot3statscarriersenseerrors_hi) + - bxe_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi)); - - if_setimcasts(ifnet, - bxe_hilo(&estats->total_multicast_packets_received_hi)); - - if_setcollisions(ifnet, - bxe_hilo(&estats->tx_stat_etherstatscollisions_hi) + - bxe_hilo(&estats->tx_stat_dot3statslatecollisions_hi) + - bxe_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi)); + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (bxe_hilo(&estats->total_unicast_packets_received_hi) + + bxe_hilo(&estats->total_multicast_packets_received_hi) + + bxe_hilo(&estats->total_broadcast_packets_received_hi)); + case IFCOUNTER_OPACKETS: + return (bxe_hilo(&estats->total_unicast_packets_transmitted_hi) + + bxe_hilo(&estats->total_multicast_packets_transmitted_hi) + + bxe_hilo(&estats->total_broadcast_packets_transmitted_hi)); + case IFCOUNTER_IBYTES: + return (bxe_hilo(&estats->total_bytes_received_hi)); + case IFCOUNTER_OBYTES: + return (bxe_hilo(&estats->total_bytes_transmitted_hi)); + case IFCOUNTER_IERRORS: + return (bxe_hilo(&estats->rx_stat_etherstatsundersizepkts_hi) + + bxe_hilo(&estats->etherstatsoverrsizepkts_hi) + + bxe_hilo(&estats->brb_drop_hi) + + bxe_hilo(&estats->brb_truncate_hi) + + bxe_hilo(&estats->rx_stat_dot3statsfcserrors_hi) + + bxe_hilo(&estats->rx_stat_dot3statsalignmenterrors_hi) + + bxe_hilo(&estats->no_buff_discard_hi)); + case IFCOUNTER_OERRORS: + return (bxe_hilo(&estats->rx_stat_dot3statscarriersenseerrors_hi) + + bxe_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi)); + case IFCOUNTER_IMCASTS: + return (bxe_hilo(&estats->total_multicast_packets_received_hi)); + case IFCOUNTER_COLLISIONS: + return (bxe_hilo(&estats->tx_stat_etherstatscollisions_hi) + + bxe_hilo(&estats->tx_stat_dot3statslatecollisions_hi) + + bxe_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi)); + default: + return (if_get_counter_default(ifp, cnt)); + } } static void @@ -1669,15 +1673,6 @@ bxe_stats_init(struct bxe_softc *sc) /* prepare statistics ramrod data */ bxe_prep_fw_stats_req(sc); - if_setipackets(sc->ifp, 0); - if_setopackets(sc->ifp, 0); - if_setibytes(sc->ifp, 0); - if_setobytes(sc->ifp, 0); - if_setierrors(sc->ifp, 0); - if_setoerrors(sc->ifp, 0); - if_setimcasts(sc->ifp, 0); - if_setcollisions(sc->ifp, 0); - if (sc->stats_init) { memset(&sc->net_stats_old, 0, sizeof(sc->net_stats_old)); memset(&sc->fw_stats_old, 0, sizeof(sc->fw_stats_old)); @@ -1731,9 +1726,6 @@ bxe_save_statistics(struct bxe_softc *sc) UPDATE_QSTAT_OLD(total_tpa_bytes_lo); } - /* save net_device_stats statistics */ - sc->net_stats_old.rx_dropped = if_getiqdrops(sc->ifp); - /* store port firmware statistics */ if (sc->port.pmf) { struct bxe_eth_stats *estats = &sc->eth_stats; diff --git a/sys/dev/bxe/bxe_stats.h b/sys/dev/bxe/bxe_stats.h index cb98201abb13..ed37f55c452d 100644 --- a/sys/dev/bxe/bxe_stats.h +++ b/sys/dev/bxe/bxe_stats.h @@ -675,6 +675,7 @@ void bxe_stats_init(struct bxe_softc *sc); void bxe_stats_handle(struct bxe_softc *sc, enum bxe_stats_event event); void bxe_save_statistics(struct bxe_softc *sc); void bxe_afex_collect_stats(struct bxe_softc *sc, void *void_afex_stats, uint32_t stats_type); +uint64_t bxe_get_counter(if_t, ift_counter); #endif /* BXE_STATS_H */ diff --git a/sys/dev/bxe/ecore_sp.h b/sys/dev/bxe/ecore_sp.h index f07921e20481..c5a9222534dd 100644 --- a/sys/dev/bxe/ecore_sp.h +++ b/sys/dev/bxe/ecore_sp.h @@ -246,14 +246,23 @@ ECORE_CRC32_LE(uint32_t seed, uint8_t *mac, uint32_t len) #else +extern unsigned long bxe_debug; + +#define BXE_DEBUG_ECORE_DBG_BREAK_IF 0x01 +#define BXE_DEBUG_ECORE_BUG 0x02 +#define BXE_DEBUG_ECORE_BUG_ON 0x04 + #define ECORE_DBG_BREAK_IF(exp) \ - printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__); + if (bxe_debug & BXE_DEBUG_ECORE_DBG_BREAK_IF) \ + printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__); #define ECORE_BUG(exp) \ - printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__); + if (bxe_debug & BXE_DEBUG_ECORE_BUG) \ + printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__); #define ECORE_BUG_ON(exp) \ - printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__); + if (bxe_debug & BXE_DEBUG_ECORE_BUG_ON) \ + printf("%s (%s,%d)\n", __FUNCTION__, __FILE__, __LINE__); #endif /* #ifdef ECORE_STOP_ON_ERROR */ diff --git a/sys/dev/cadence/if_cgem.c b/sys/dev/cadence/if_cgem.c index 9837e7e92e3b..84b947dfba1f 100644 --- a/sys/dev/cadence/if_cgem.c +++ b/sys/dev/cadence/if_cgem.c @@ -558,7 +558,7 @@ cgem_recv(struct cgem_softc *sc) (CGEM_RXDESC_SOF | CGEM_RXDESC_EOF)) { /* discard. */ m_free(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } @@ -604,7 +604,7 @@ cgem_recv(struct cgem_softc *sc) m = m_hd; m_hd = m_hd->m_next; m->m_next = NULL; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, m); } CGEM_LOCK(sc); @@ -646,9 +646,9 @@ cgem_clean_tx(struct cgem_softc *sc) sc->txring[sc->txring_tl_ptr].addr); } else if ((ctl & (CGEM_TXDESC_RETRY_ERR | CGEM_TXDESC_LATE_COLL)) != 0) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); } else - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); /* If the packet spanned more than one tx descriptor, * skip descriptors until we find the end so that only @@ -821,16 +821,16 @@ cgem_poll_hw_stats(struct cgem_softc *sc) n = RD4(sc, CGEM_SINGLE_COLL_FRAMES); sc->stats.tx_single_collisn += n; - sc->ifp->if_collisions += n; + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n); n = RD4(sc, CGEM_MULTI_COLL_FRAMES); sc->stats.tx_multi_collisn += n; - sc->ifp->if_collisions += n; + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n); n = RD4(sc, CGEM_EXCESSIVE_COLL_FRAMES); sc->stats.tx_excsv_collisn += n; - sc->ifp->if_collisions += n; + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n); n = RD4(sc, CGEM_LATE_COLL); sc->stats.tx_late_collisn += n; - sc->ifp->if_collisions += n; + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, n); sc->stats.tx_deferred_frames += RD4(sc, CGEM_DEFERRED_TX_FRAMES); sc->stats.tx_carrier_sense_errs += RD4(sc, CGEM_CARRIER_SENSE_ERRS); diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c index 4b4ea1f01505..554b245260f5 100644 --- a/sys/dev/cas/if_cas.c +++ b/sys/dev/cas/if_cas.c @@ -642,18 +642,18 @@ cas_tick(void *arg) /* * Unload collision and error counters. */ - ifp->if_collisions += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, CAS_READ_4(sc, CAS_MAC_NORM_COLL_CNT) + - CAS_READ_4(sc, CAS_MAC_FIRST_COLL_CNT); + CAS_READ_4(sc, CAS_MAC_FIRST_COLL_CNT)); v = CAS_READ_4(sc, CAS_MAC_EXCESS_COLL_CNT) + CAS_READ_4(sc, CAS_MAC_LATE_COLL_CNT); - ifp->if_collisions += v; - ifp->if_oerrors += v; - ifp->if_ierrors += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, v); + if_inc_counter(ifp, IFCOUNTER_OERRORS, v); + if_inc_counter(ifp, IFCOUNTER_IERRORS, CAS_READ_4(sc, CAS_MAC_RX_LEN_ERR_CNT) + CAS_READ_4(sc, CAS_MAC_RX_ALIGN_ERR) + CAS_READ_4(sc, CAS_MAC_RX_CRC_ERR_CNT) + - CAS_READ_4(sc, CAS_MAC_RX_CODE_VIOL); + CAS_READ_4(sc, CAS_MAC_RX_CODE_VIOL)); /* * Then clear the hardware counters. @@ -1581,7 +1581,7 @@ cas_tint(struct cas_softc *sc) STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); progress = 1; } @@ -1700,7 +1700,7 @@ cas_rint(struct cas_softc *sc) if (__predict_false( (word4 & (CAS_RC4_BAD | CAS_RC4_LEN_MMATCH)) != 0)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); device_printf(sc->sc_dev, "receive error: CRC error\n"); continue; @@ -1750,7 +1750,7 @@ cas_rint(struct cas_softc *sc) if (m != NULL) { m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) cas_rxcksum(m, CAS_GET(word4, CAS_RC4_TCP_CSUM)); @@ -1759,7 +1759,7 @@ cas_rint(struct cas_softc *sc) (*ifp->if_input)(ifp, m); CAS_LOCK(sc); } else - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if ((word1 & CAS_RC1_RELEASE_HDR) != 0 && refcount_release(&rxds->rxds_refcount) != 0) @@ -1848,7 +1848,7 @@ cas_rint(struct cas_softc *sc) if (m != NULL) { m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = len; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) cas_rxcksum(m, CAS_GET(word4, CAS_RC4_TCP_CSUM)); @@ -1857,7 +1857,7 @@ cas_rint(struct cas_softc *sc) (*ifp->if_input)(ifp, m); CAS_LOCK(sc); } else - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if ((word1 & CAS_RC1_RELEASE_DATA) != 0 && refcount_release(&rxds->rxds_refcount) != 0) @@ -1949,7 +1949,7 @@ cas_eint(struct cas_softc *sc, u_int status) CAS_LOCK_ASSERT(sc, MA_OWNED); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); device_printf(sc->sc_dev, "%s: status 0x%x", __func__, status); if ((status & CAS_INTR_PCI_ERROR_INT) != 0) { @@ -2049,7 +2049,7 @@ cas_intr_task(void *arg, int pending __unused) status2 = CAS_READ_4(sc, CAS_MAC_TX_STATUS); if ((status2 & (CAS_MAC_TX_UNDERRUN | CAS_MAC_TX_MAX_PKT_ERR)) != 0) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else if ((status2 & ~CAS_MAC_TX_FRAME_XMTD) != 0) device_printf(sc->sc_dev, "MAC TX fault, status %x\n", status2); @@ -2058,7 +2058,7 @@ cas_intr_task(void *arg, int pending __unused) if (__predict_false(status & CAS_INTR_RX_MAC_INT)) { status2 = CAS_READ_4(sc, CAS_MAC_RX_STATUS); if ((status2 & CAS_MAC_RX_OVERFLOW) != 0) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); else if ((status2 & ~CAS_MAC_RX_FRAME_RCVD) != 0) device_printf(sc->sc_dev, "MAC RX fault, status %x\n", status2); @@ -2135,7 +2135,7 @@ cas_watchdog(struct cas_softc *sc) device_printf(sc->sc_dev, "device timeout\n"); else if (bootverbose) device_printf(sc->sc_dev, "device timeout (no link)\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* Try to get more packets going. */ ifp->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/dev/ce/if_ce.c b/sys/dev/ce/if_ce.c index 899f33f38dc5..d0dd0c7cc414 100644 --- a/sys/dev/ce/if_ce.c +++ b/sys/dev/ce/if_ce.c @@ -297,22 +297,6 @@ static struct cdevsw ce_cdevsw = { }; #endif -/* - * Print the mbuf chain, for debug purposes only. - */ -static void printmbuf (struct mbuf *m) -{ - printf ("mbuf:"); - for (; m; m=m->m_next) { - if (m->m_flags & M_PKTHDR) - printf (" HDR %d:", m->m_pkthdr.len); - if (m->m_flags & M_EXT) - printf (" EXT:"); - printf (" %d", m->m_len); - } - printf ("\n"); -} - /* * Make an mbuf from data. */ @@ -1113,7 +1097,7 @@ static void ce_transmit (ce_chan_t *c, void *attachment, int len) d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_opackets; + if_inc_counter(d->ifp, IFCOUNTER_OPACKETS, 1); #if __FreeBSD_version >= 600034 d->ifp->if_flags &= ~IFF_DRV_OACTIVE; #else @@ -1135,26 +1119,21 @@ static void ce_receive (ce_chan_t *c, unsigned char *data, int len) if (! m) { CE_DEBUG (d, ("no memory for packet\n")); #ifndef NETGRAPH - ++d->ifp->if_iqdrops; + if_inc_counter(d->ifp, IFCOUNTER_IQDROPS, 1); #endif return; } if (c->debug > 1) - printmbuf (m); + m_print (m, 0); #ifdef NETGRAPH m->m_pkthdr.rcvif = 0; IF_ENQUEUE(&d->rqueue, m); #else - ++d->ifp->if_ipackets; + if_inc_counter(d->ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = d->ifp; /* Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ -#if __FreeBSD_version >= 500000 - BPF_TAP (d->ifp, data, len); -#else - if (d->ifp->if_bpf) - bpf_tap (d->ifp, data, len); -#endif + BPF_MTAP(d->ifp, m); IF_ENQUEUE(&d->rqueue, m); #endif } @@ -1167,33 +1146,33 @@ static void ce_error (ce_chan_t *c, int data) case CE_FRAME: CE_DEBUG (d, ("frame error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CE_CRC: CE_DEBUG (d, ("crc error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CE_OVERRUN: CE_DEBUG (d, ("overrun error\n")); #ifndef NETGRAPH - ++d->ifp->if_collisions; - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_COLLISIONS, 1); + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CE_OVERFLOW: CE_DEBUG (d, ("overflow error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CE_UNDERRUN: CE_DEBUG (d, ("underrun error\n")); d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_oerrors; + if_inc_counter(d->ifp, IFCOUNTER_OERRORS, 1); #if __FreeBSD_version >= 600034 d->ifp->if_flags &= ~IFF_DRV_OACTIVE; #else @@ -2424,7 +2403,6 @@ static int ng_ce_rcvdata (hook_p hook, struct mbuf *m, meta_p meta) #if __FreeBSD_version >= 500000 IF_LOCK (q); if (_IF_QFULL (q)) { - _IF_DROP (q); IF_UNLOCK (q); CE_UNLOCK (bd); splx (s); diff --git a/sys/dev/cm/smc90cx6.c b/sys/dev/cm/smc90cx6.c index e0e8e42fa2b1..a1932ad54ddb 100644 --- a/sys/dev/cm/smc90cx6.c +++ b/sys/dev/cm/smc90cx6.c @@ -512,7 +512,7 @@ cm_srint_locked(vsc) * count it as input error (we dont have any other * detectable) */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto cleanup; } @@ -544,13 +544,13 @@ cm_srint_locked(vsc) /* Insist on getting a cluster */ if ((m->m_flags & M_EXT) == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto cleanup; } } if (m == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto cleanup; } @@ -572,7 +572,7 @@ cm_srint_locked(vsc) CM_LOCK(sc); m = NULL; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); cleanup: @@ -620,7 +620,7 @@ cm_tint_locked(sc, isr) */ if (isr & CM_TMA || sc->sc_broadcast[buffer]) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); #ifdef CMRETRANSMIT else if (ifp->if_flags & IFF_LINK2 && sc->sc_timer > 0 && --sc->sc_retransmits[buffer] > 0) { @@ -630,7 +630,7 @@ cm_tint_locked(sc, isr) } #endif else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* We know we can accept another buffer at this point. */ @@ -730,7 +730,7 @@ cmintr(arg) * PUTREG(CMCMD, CM_CONF(CONF_LONG)); */ PUTREG(CMCMD, CM_CLR(CLR_RECONFIG)); - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); /* * If less than 2 seconds per reconfig: diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c index ec5f04212804..4e70838fcd9d 100644 --- a/sys/dev/cp/if_cp.c +++ b/sys/dev/cp/if_cp.c @@ -181,22 +181,6 @@ static struct cdevsw cp_cdevsw = { .d_name = "cp", }; -/* - * Print the mbuf chain, for debug purposes only. - */ -static void printmbuf (struct mbuf *m) -{ - printf ("mbuf:"); - for (; m; m=m->m_next) { - if (m->m_flags & M_PKTHDR) - printf (" HDR %d:", m->m_pkthdr.len); - if (m->m_flags & M_EXT) - printf (" EXT:"); - printf (" %d", m->m_len); - } - printf ("\n"); -} - /* * Make an mbuf from data. */ @@ -883,7 +867,7 @@ static void cp_transmit (cp_chan_t *c, void *attachment, int len) d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_opackets; + if_inc_counter(d->ifp, IFCOUNTER_OPACKETS, 1); d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; #endif cp_start (d); @@ -904,21 +888,21 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len) if (! m) { CP_DEBUG (d, ("no memory for packet\n")); #ifndef NETGRAPH - ++d->ifp->if_iqdrops; + if_inc_counter(d->ifp, IFCOUNTER_IQDROPS, 1); #endif return; } if (c->debug > 1) - printmbuf (m); + m_print (m, 0); #ifdef NETGRAPH m->m_pkthdr.rcvif = 0; NG_SEND_DATA_ONLY (error, d->hook, m); #else - ++d->ifp->if_ipackets; + if_inc_counter(d->ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = d->ifp; /* Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ - BPF_TAP (d->ifp, data, len); + BPF_MTAP(d->ifp, m); IF_ENQUEUE (&d->queue, m); #endif } @@ -931,33 +915,33 @@ static void cp_error (cp_chan_t *c, int data) case CP_FRAME: CP_DEBUG (d, ("frame error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CP_CRC: CP_DEBUG (d, ("crc error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CP_OVERRUN: CP_DEBUG (d, ("overrun error\n")); #ifndef NETGRAPH - ++d->ifp->if_collisions; - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_COLLISIONS, 1); + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CP_OVERFLOW: CP_DEBUG (d, ("overflow error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CP_UNDERRUN: CP_DEBUG (d, ("underrun error\n")); d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_oerrors; + if_inc_counter(d->ifp, IFCOUNTER_OERRORS, 1); d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; #endif cp_start (d); @@ -2157,7 +2141,6 @@ static int ng_cp_rcvdata (hook_p hook, item_p item) CP_LOCK (bd); IF_LOCK (q); if (_IF_QFULL (q)) { - _IF_DROP (q); IF_UNLOCK (q); CP_UNLOCK (bd); splx (s); diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index e247fe2adbba..8ad50eb23de4 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -707,7 +707,7 @@ cs_get_packet(struct cs_softc *sc) #ifdef CS_DEBUG device_printf(sc->dev, "bad pkt stat %x\n", status); #endif - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (-1); } @@ -742,7 +742,7 @@ cs_get_packet(struct cs_softc *sc) (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) { /* Feed the packet to the upper layer */ (*ifp->if_input)(ifp, m); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if (length == ETHER_MAX_LEN-ETHER_CRC_LEN) DELAY(cs_recv_delay); } else { @@ -780,9 +780,9 @@ csintr(void *arg) case ISQ_TRANSMITTER_EVENT: if (status & TX_OK) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->tx_timeout = 0; break; @@ -796,16 +796,16 @@ csintr(void *arg) if (status & TX_UNDERRUN) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->tx_timeout = 0; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } break; case ISQ_RX_MISS_EVENT: - ifp->if_ierrors+=(status>>6); + if_inc_counter(ifp, IFCOUNTER_IERRORS, status >> 6); break; case ISQ_TX_COL_EVENT: - ifp->if_collisions+=(status>>6); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, status >> 6); break; } } @@ -1114,7 +1114,7 @@ cs_watchdog(void *arg) CS_ASSERT_LOCKED(sc); if (sc->tx_timeout && --sc->tx_timeout == 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); log(LOG_ERR, "%s: device timeout\n", ifp->if_xname); /* Reset the interface */ diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c index 958faa54de84..397c3ac49b25 100644 --- a/sys/dev/ctau/if_ct.c +++ b/sys/dev/ctau/if_ct.c @@ -184,22 +184,6 @@ static struct cdevsw ct_cdevsw = { .d_name = "ct", }; -/* - * Print the mbuf chain, for debug purposes only. - */ -static void printmbuf (struct mbuf *m) -{ - printf ("mbuf:"); - for (; m; m=m->m_next) { - if (m->m_flags & M_PKTHDR) - printf (" HDR %d:", m->m_pkthdr.len); - if (m->m_flags & M_EXT) - printf (" EXT:"); - printf (" %d", m->m_len); - } - printf ("\n"); -} - /* * Make an mbuf from data. */ @@ -1098,7 +1082,7 @@ static void ct_transmit (ct_chan_t *c, void *attachment, int len) return; d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_opackets; + if_inc_counter(d->ifp, IFCOUNTER_OPACKETS, 1); d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; #endif ct_start (d); @@ -1122,21 +1106,21 @@ static void ct_receive (ct_chan_t *c, char *data, int len) if (! m) { CT_DEBUG (d, ("no memory for packet\n")); #ifndef NETGRAPH - ++d->ifp->if_iqdrops; + if_inc_counter(d->ifp, IFCOUNTER_IQDROPS, 1); #endif return; } if (c->debug > 1) - printmbuf (m); + m_print (m, 0); #ifdef NETGRAPH m->m_pkthdr.rcvif = 0; NG_SEND_DATA_ONLY (error, d->hook, m); #else - ++d->ifp->if_ipackets; + if_inc_counter(d->ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = d->ifp; /* Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ - BPF_TAP (d->ifp, data, len); + BPF_MTAP(d->ifp, m); IF_ENQUEUE (&d->queue, m); #endif } @@ -1155,33 +1139,33 @@ static void ct_error (ct_chan_t *c, int data) case CT_FRAME: CT_DEBUG (d, ("frame error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CT_CRC: CT_DEBUG (d, ("crc error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CT_OVERRUN: CT_DEBUG (d, ("overrun error\n")); #ifndef NETGRAPH - ++d->ifp->if_collisions; - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_COLLISIONS, 1); + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CT_OVERFLOW: CT_DEBUG (d, ("overflow error\n")); #ifndef NETGRAPH - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CT_UNDERRUN: CT_DEBUG (d, ("underrun error\n")); d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_oerrors; + if_inc_counter(d->ifp, IFCOUNTER_OERRORS, 1); d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; #endif ct_start (d); @@ -2099,7 +2083,6 @@ static int ng_ct_rcvdata (hook_p hook, item_p item) CT_LOCK (bd); IF_LOCK (q); if (_IF_QFULL (q)) { - _IF_DROP (q); IF_UNLOCK (q); CT_UNLOCK (bd); splx (s); diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c index 27112d5032fe..360e1f689fa9 100644 --- a/sys/dev/cx/if_cx.c +++ b/sys/dev/cx/if_cx.c @@ -231,22 +231,6 @@ static struct cdevsw cx_cdevsw = { static int MY_SOFT_INTR; -/* - * Print the mbuf chain, for debug purposes only. - */ -static void printmbuf (struct mbuf *m) -{ - printf ("mbuf:"); - for (; m; m=m->m_next) { - if (m->m_flags & M_PKTHDR) - printf (" HDR %d:", m->m_pkthdr.len); - if (m->m_flags & M_EXT) - printf (" EXT:"); - printf (" %d", m->m_len); - } - printf ("\n"); -} - /* * Make an mbuf from data. */ @@ -1267,7 +1251,7 @@ static void cx_transmit (cx_chan_t *c, void *attachment, int len) } d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_opackets; + if_inc_counter(d->ifp, IFCOUNTER_OPACKETS, 1); d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; #endif cx_start (d); @@ -1320,21 +1304,21 @@ static void cx_receive (cx_chan_t *c, char *data, int len) if (! m) { CX_DEBUG (d, ("no memory for packet\n")); #ifndef NETGRAPH - ++d->ifp->if_iqdrops; + if_inc_counter(d->ifp, IFCOUNTER_IQDROPS, 1); #endif return; } if (c->debug > 1) - printmbuf (m); + m_print (m, 0); #ifdef NETGRAPH m->m_pkthdr.rcvif = 0; NG_SEND_DATA_ONLY (error, d->hook, m); #else - ++d->ifp->if_ipackets; + if_inc_counter(d->ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = d->ifp; /* Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ - BPF_TAP (d->ifp, data, len); + BPF_MTAP(d->ifp, m); IF_ENQUEUE (&d->queue, m); #endif } @@ -1373,7 +1357,7 @@ static void cx_error (cx_chan_t *c, int data) } #ifndef NETGRAPH else - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CX_CRC: @@ -1390,7 +1374,7 @@ static void cx_error (cx_chan_t *c, int data) } #ifndef NETGRAPH else - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CX_OVERRUN: @@ -1407,8 +1391,8 @@ static void cx_error (cx_chan_t *c, int data) #endif #ifndef NETGRAPH else { - ++d->ifp->if_collisions; - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_COLLISIONS, 1); + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); } #endif break; @@ -1416,7 +1400,7 @@ static void cx_error (cx_chan_t *c, int data) CX_DEBUG (d, ("overflow error\n")); #ifndef NETGRAPH if (c->mode != M_ASYNC) - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; case CX_UNDERRUN: @@ -1424,7 +1408,7 @@ static void cx_error (cx_chan_t *c, int data) if (c->mode != M_ASYNC) { d->timeout = 0; #ifndef NETGRAPH - ++d->ifp->if_oerrors; + if_inc_counter(d->ifp, IFCOUNTER_OERRORS, 1); d->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; #endif cx_start (d); @@ -1443,7 +1427,7 @@ static void cx_error (cx_chan_t *c, int data) } #ifndef NETGRAPH else - ++d->ifp->if_ierrors; + if_inc_counter(d->ifp, IFCOUNTER_IERRORS, 1); #endif break; default: @@ -2437,7 +2421,6 @@ static int ng_cx_rcvdata (hook_p hook, item_p item) CX_LOCK (bd); IF_LOCK (q); if (_IF_QFULL (q)) { - _IF_DROP (q); IF_UNLOCK (q); CX_UNLOCK (bd); splx (s); diff --git a/sys/dev/cxgb/cxgb_adapter.h b/sys/dev/cxgb/cxgb_adapter.h index 6aaacd365533..6f3abe7ee2eb 100644 --- a/sys/dev/cxgb/cxgb_adapter.h +++ b/sys/dev/cxgb/cxgb_adapter.h @@ -97,6 +97,7 @@ struct port_info { const struct port_type_info *port_type; struct cphy phy; struct cmac mac; + struct timeval last_refreshed; struct link_config link_config; struct ifmedia media; struct mtx lock; @@ -575,4 +576,5 @@ void cxgb_tx_watchdog(void *arg); int cxgb_transmit(struct ifnet *ifp, struct mbuf *m); void cxgb_qflush(struct ifnet *ifp); void t3_iterate(void (*)(struct adapter *, void *), void *); +void cxgb_refresh_stats(struct port_info *); #endif diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index 30001293b2bb..b4bacc66c46a 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -96,6 +96,7 @@ static int cxgb_media_change(struct ifnet *); static int cxgb_ifm_type(int); static void cxgb_build_medialist(struct port_info *); static void cxgb_media_status(struct ifnet *, struct ifmediareq *); +static uint64_t cxgb_get_counter(struct ifnet *, ift_counter); static int setup_sge_qsets(adapter_t *); static void cxgb_async_intr(void *); static void cxgb_tick_handler(void *, int); @@ -1022,6 +1023,7 @@ cxgb_port_attach(device_t dev) ifp->if_ioctl = cxgb_ioctl; ifp->if_transmit = cxgb_transmit; ifp->if_qflush = cxgb_qflush; + ifp->if_get_counter = cxgb_get_counter; ifp->if_capabilities = CXGB_CAP; #ifdef TCP_OFFLOAD @@ -2189,6 +2191,71 @@ cxgb_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) speed)); } +static uint64_t +cxgb_get_counter(struct ifnet *ifp, ift_counter c) +{ + struct port_info *pi = ifp->if_softc; + struct adapter *sc = pi->adapter; + struct cmac *mac = &pi->mac; + struct mac_stats *mstats = &mac->stats; + + cxgb_refresh_stats(pi); + + switch (c) { + case IFCOUNTER_IPACKETS: + return (mstats->rx_frames); + + case IFCOUNTER_IERRORS: + return (mstats->rx_jabber + mstats->rx_data_errs + + mstats->rx_sequence_errs + mstats->rx_runt + + mstats->rx_too_long + mstats->rx_mac_internal_errs + + mstats->rx_short + mstats->rx_fcs_errs); + + case IFCOUNTER_OPACKETS: + return (mstats->tx_frames); + + case IFCOUNTER_OERRORS: + return (mstats->tx_excess_collisions + mstats->tx_underrun + + mstats->tx_len_errs + mstats->tx_mac_internal_errs + + mstats->tx_excess_deferral + mstats->tx_fcs_errs); + + case IFCOUNTER_COLLISIONS: + return (mstats->tx_total_collisions); + + case IFCOUNTER_IBYTES: + return (mstats->rx_octets); + + case IFCOUNTER_OBYTES: + return (mstats->tx_octets); + + case IFCOUNTER_IMCASTS: + return (mstats->rx_mcast_frames); + + case IFCOUNTER_OMCASTS: + return (mstats->tx_mcast_frames); + + case IFCOUNTER_IQDROPS: + return (mstats->rx_cong_drops); + + case IFCOUNTER_OQDROPS: { + int i; + uint64_t drops; + + drops = 0; + if (sc->flags & FULL_INIT_DONE) { + for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) + drops += sc->sge.qs[i].txq[TXQ_ETH].txq_mr->br_drops; + } + + return (drops); + + } + + default: + return (if_get_counter_default(ifp, c)); + } +} + static void cxgb_async_intr(void *data) { @@ -2289,6 +2356,23 @@ cxgb_tick(void *arg) callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc); } +void +cxgb_refresh_stats(struct port_info *pi) +{ + struct timeval tv; + const struct timeval interval = {0, 250000}; /* 250ms */ + + getmicrotime(&tv); + timevalsub(&tv, &interval); + if (timevalcmp(&tv, &pi->last_refreshed, <)) + return; + + PORT_LOCK(pi); + t3_mac_update_stats(&pi->mac); + PORT_UNLOCK(pi); + getmicrotime(&pi->last_refreshed); +} + static void cxgb_tick_handler(void *arg, int count) { @@ -2333,48 +2417,12 @@ cxgb_tick_handler(void *arg, int count) for (i = 0; i < sc->params.nports; i++) { struct port_info *pi = &sc->port[i]; - struct ifnet *ifp = pi->ifp; struct cmac *mac = &pi->mac; - struct mac_stats *mstats = &mac->stats; - int drops, j; if (!isset(&sc->open_device_map, pi->port_id)) continue; - PORT_LOCK(pi); - t3_mac_update_stats(mac); - PORT_UNLOCK(pi); - - ifp->if_opackets = mstats->tx_frames; - ifp->if_ipackets = mstats->rx_frames; - ifp->if_obytes = mstats->tx_octets; - ifp->if_ibytes = mstats->rx_octets; - ifp->if_omcasts = mstats->tx_mcast_frames; - ifp->if_imcasts = mstats->rx_mcast_frames; - ifp->if_collisions = mstats->tx_total_collisions; - ifp->if_iqdrops = mstats->rx_cong_drops; - - drops = 0; - for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; j++) - drops += sc->sge.qs[j].txq[TXQ_ETH].txq_mr->br_drops; - ifp->if_snd.ifq_drops = drops; - - ifp->if_oerrors = - mstats->tx_excess_collisions + - mstats->tx_underrun + - mstats->tx_len_errs + - mstats->tx_mac_internal_errs + - mstats->tx_excess_deferral + - mstats->tx_fcs_errs; - ifp->if_ierrors = - mstats->rx_jabber + - mstats->rx_data_errs + - mstats->rx_sequence_errs + - mstats->rx_runt + - mstats->rx_too_long + - mstats->rx_mac_internal_errs + - mstats->rx_short + - mstats->rx_fcs_errs; + cxgb_refresh_stats(pi); if (mac->multiport) continue; diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index fcc0376fab76..88ee7ccd4920 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -3410,10 +3410,8 @@ sysctl_handle_macstat(SYSCTL_HANDLER_ARGS) if (!p) return (EINVAL); + cxgb_refresh_stats(p); parg = (uint64_t *) ((uint8_t *)&p->mac.stats + arg2); - PORT_LOCK(p); - t3_mac_update_stats(&p->mac); - PORT_UNLOCK(p); return (sysctl_handle_64(oidp, parg, 0, req)); } diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 316852b65e6e..8cebdaa7d8ae 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -268,7 +268,10 @@ struct port_info { int linkdnrc; struct link_config link_cfg; - struct port_stats stats; + + struct timeval last_refreshed; + struct port_stats stats; + u_int tnl_cong_drops; eventhandler_tag vlan_c; @@ -790,6 +793,8 @@ struct adapter { TAILQ_HEAD(, sge_fl) sfl; struct callout sfl_callout; + struct mtx regwin_lock; /* for indirect reads and memory windows */ + an_handler_t an_handler __aligned(CACHE_LINE_SIZE); fw_msg_handler_t fw_msg_handler[5]; /* NUM_FW6_TYPES */ cpl_handler_t cpl_handler[0xef]; /* NUM_CPL_CMDS */ diff --git a/sys/dev/cxgbe/common/t4_regs.h b/sys/dev/cxgbe/common/t4_regs.h index f205298841fd..1ea909eb1a3e 100644 --- a/sys/dev/cxgbe/common/t4_regs.h +++ b/sys/dev/cxgbe/common/t4_regs.h @@ -1073,9 +1073,9 @@ #define A_SGE_FL_BUFFER_SIZE0 0x1044 #define S_SIZE 4 -#define M_SIZE 0xfffffffU +#define CXGBE_M_SIZE 0xfffffffU #define V_SIZE(x) ((x) << S_SIZE) -#define G_SIZE(x) (((x) >> S_SIZE) & M_SIZE) +#define G_SIZE(x) (((x) >> S_SIZE) & CXGBE_M_SIZE) #define A_SGE_FL_BUFFER_SIZE1 0x1048 #define A_SGE_FL_BUFFER_SIZE2 0x104c diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 437b2a4dd3b2..77c99b238fae 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -151,6 +151,7 @@ static void cxgbe_init(void *); static int cxgbe_ioctl(struct ifnet *, unsigned long, caddr_t); static int cxgbe_transmit(struct ifnet *, struct mbuf *); static void cxgbe_qflush(struct ifnet *); +static uint64_t cxgbe_get_counter(struct ifnet *, ift_counter); static int cxgbe_media_change(struct ifnet *); static void cxgbe_media_status(struct ifnet *, struct ifmediareq *); @@ -280,6 +281,15 @@ TUNABLE_INT("hw.cxgbe.interrupt_types", &t4_intr_types); static char t4_cfg_file[32] = DEFAULT_CF; TUNABLE_STR("hw.cxgbe.config_file", t4_cfg_file, sizeof(t4_cfg_file)); +/* + * PAUSE settings (bit 0, 1 = rx_pause, tx_pause respectively). + * rx_pause = 1 to heed incoming PAUSE frames, 0 to ignore them. + * tx_pause = 1 to emit PAUSE frames when the rx FIFO reaches its high water + * mark or when signalled to do so, 0 to never emit PAUSE. + */ +static int t4_pause_settings = PAUSE_TX | PAUSE_RX; +TUNABLE_INT("hw.cxgbe.pause_settings", &t4_pause_settings); + /* * Firmware auto-install by driver during attach (0, 1, 2 = prohibited, allowed, * encouraged respectively). @@ -377,6 +387,7 @@ static int t4_free_irq(struct adapter *, struct irq *); static void reg_block_dump(struct adapter *, uint8_t *, unsigned int, unsigned int); static void t4_get_regs(struct adapter *, struct t4_regdump *, uint8_t *); +static void cxgbe_refresh_stats(struct adapter *, struct port_info *); static void cxgbe_tick(void *); static void cxgbe_vlan_config(void *, struct ifnet *, uint16_t); static int cpl_not_handled(struct sge_iq *, const struct rss_header *, @@ -393,6 +404,7 @@ static int sysctl_holdoff_tmr_idx(SYSCTL_HANDLER_ARGS); static int sysctl_holdoff_pktc_idx(SYSCTL_HANDLER_ARGS); static int sysctl_qsize_rxq(SYSCTL_HANDLER_ARGS); static int sysctl_qsize_txq(SYSCTL_HANDLER_ARGS); +static int sysctl_pause_settings(SYSCTL_HANDLER_ARGS); static int sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS); static int sysctl_temperature(SYSCTL_HANDLER_ARGS); #ifdef SBUF_DRAIN @@ -599,6 +611,8 @@ t4_attach(device_t dev) TAILQ_INIT(&sc->sfl); callout_init(&sc->sfl_callout, CALLOUT_MPSAFE); + mtx_init(&sc->regwin_lock, "register and memory window", 0, MTX_DEF); + rc = map_bars_0_and_4(sc); if (rc != 0) goto done; /* error message displayed already */ @@ -697,6 +711,12 @@ t4_attach(device_t dev) sc->port[i] = NULL; goto done; } + + pi->link_cfg.requested_fc &= ~(PAUSE_TX | PAUSE_RX); + pi->link_cfg.requested_fc |= t4_pause_settings; + pi->link_cfg.fc &= ~(PAUSE_TX | PAUSE_RX); + pi->link_cfg.fc |= t4_pause_settings; + rc = -t4_link_start(sc, sc->mbox, pi->tx_chan, &pi->link_cfg); if (rc != 0) { device_printf(dev, "port %d l1cfg failed: %d\n", i, rc); @@ -1008,6 +1028,8 @@ t4_detach(device_t dev) mtx_destroy(&sc->sfl_lock); if (mtx_initialized(&sc->ifp_lock)) mtx_destroy(&sc->ifp_lock); + if (mtx_initialized(&sc->regwin_lock)) + mtx_destroy(&sc->regwin_lock); bzero(sc, sizeof(*sc)); @@ -1057,6 +1079,7 @@ cxgbe_attach(device_t dev) ifp->if_ioctl = cxgbe_ioctl; ifp->if_transmit = cxgbe_transmit; ifp->if_qflush = cxgbe_qflush; + ifp->if_get_counter = cxgbe_get_counter; ifp->if_capabilities = T4_CAP; #ifdef TCP_OFFLOAD @@ -1067,6 +1090,10 @@ cxgbe_attach(device_t dev) ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO | CSUM_UDP_IPV6 | CSUM_TCP_IPV6; + ifp->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + ifp->if_hw_tsomaxsegcount = TX_SGL_SEGS; + ifp->if_hw_tsomaxsegsize = 65536; + /* Initialize ifmedia for this port */ ifmedia_init(&pi->media, IFM_IMASK, cxgbe_media_change, cxgbe_media_status); @@ -1362,6 +1389,31 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data) ifmedia_ioctl(ifp, ifr, &pi->media, cmd); break; + case SIOCGI2C: { + struct ifi2creq i2c; + + rc = copyin(ifr->ifr_data, &i2c, sizeof(i2c)); + if (rc != 0) + break; + if (i2c.dev_addr != 0xA0 && i2c.dev_addr != 0xA2) { + rc = EPERM; + break; + } + if (i2c.len > sizeof(i2c.data)) { + rc = EINVAL; + break; + } + rc = begin_synchronized_op(sc, pi, SLEEP_OK | INTR_OK, "t4i2c"); + if (rc) + return (rc); + rc = -t4_i2c_rd(sc, sc->mbox, pi->port_id, i2c.dev_addr, + i2c.offset, i2c.len, &i2c.data[0]); + end_synchronized_op(sc, 0); + if (rc == 0) + rc = copyout(&i2c, ifr->ifr_data, sizeof(i2c)); + break; + } + default: rc = ether_ioctl(ifp, cmd, data); } @@ -1459,6 +1511,67 @@ cxgbe_qflush(struct ifnet *ifp) if_qflush(ifp); } +static uint64_t +cxgbe_get_counter(struct ifnet *ifp, ift_counter c) +{ + struct port_info *pi = ifp->if_softc; + struct adapter *sc = pi->adapter; + struct port_stats *s = &pi->stats; + + cxgbe_refresh_stats(sc, pi); + + switch (c) { + case IFCOUNTER_IPACKETS: + return (s->rx_frames - s->rx_pause); + + case IFCOUNTER_IERRORS: + return (s->rx_jabber + s->rx_runt + s->rx_too_long + + s->rx_fcs_err + s->rx_len_err); + + case IFCOUNTER_OPACKETS: + return (s->tx_frames - s->tx_pause); + + case IFCOUNTER_OERRORS: + return (s->tx_error_frames); + + case IFCOUNTER_IBYTES: + return (s->rx_octets - s->rx_pause * 64); + + case IFCOUNTER_OBYTES: + return (s->tx_octets - s->tx_pause * 64); + + case IFCOUNTER_IMCASTS: + return (s->rx_mcast_frames - s->rx_pause); + + case IFCOUNTER_OMCASTS: + return (s->tx_mcast_frames - s->tx_pause); + + case IFCOUNTER_IQDROPS: + return (s->rx_ovflow0 + s->rx_ovflow1 + s->rx_ovflow2 + + s->rx_ovflow3 + s->rx_trunc0 + s->rx_trunc1 + s->rx_trunc2 + + s->rx_trunc3 + pi->tnl_cong_drops); + + case IFCOUNTER_OQDROPS: { + uint64_t drops; + + drops = s->tx_drop; + if (pi->flags & PORT_INIT_DONE) { + int i; + struct sge_txq *txq; + + for_each_txq(pi, i, txq) + drops += txq->br->br_drops; + } + + return (drops); + + } + + default: + return (if_get_counter_default(ifp, c)); + } +} + static int cxgbe_media_change(struct ifnet *ifp) { @@ -2990,8 +3103,10 @@ update_mac_settings(struct ifnet *ifp, int flags) TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; - mcaddr[i++] = + mcaddr[i] = LLADDR((struct sockaddr_dl *)ifma->ifma_addr); + MPASS(ETHER_IS_MULTICAST(mcaddr[i])); + i++; if (i == FW_MAC_EXACT_CHUNK) { rc = t4_alloc_mac_filt(sc, sc->mbox, viid, del, @@ -4229,15 +4344,40 @@ t4_get_regs(struct adapter *sc, struct t4_regdump *regs, uint8_t *buf) reg_block_dump(sc, buf, reg_ranges[i], reg_ranges[i + 1]); } +static void +cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) +{ + int i; + u_int v, tnl_cong_drops; + struct timeval tv; + const struct timeval interval = {0, 250000}; /* 250ms */ + + getmicrotime(&tv); + timevalsub(&tv, &interval); + if (timevalcmp(&tv, &pi->last_refreshed, <)) + return; + + tnl_cong_drops = 0; + t4_get_port_stats(sc, pi->tx_chan, &pi->stats); + for (i = 0; i < NCHAN; i++) { + if (pi->rx_chan_map & (1 << i)) { + mtx_lock(&sc->regwin_lock); + t4_read_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, + 1, A_TP_MIB_TNL_CNG_DROP_0 + i); + mtx_unlock(&sc->regwin_lock); + tnl_cong_drops += v; + } + } + pi->tnl_cong_drops = tnl_cong_drops; + getmicrotime(&pi->last_refreshed); +} + static void cxgbe_tick(void *arg) { struct port_info *pi = arg; struct adapter *sc = pi->adapter; struct ifnet *ifp = pi->ifp; - struct sge_txq *txq; - int i, drops; - struct port_stats *s = &pi->stats; PORT_LOCK(pi); if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { @@ -4245,39 +4385,7 @@ cxgbe_tick(void *arg) return; /* without scheduling another callout */ } - t4_get_port_stats(sc, pi->tx_chan, s); - - ifp->if_opackets = s->tx_frames - s->tx_pause; - ifp->if_ipackets = s->rx_frames - s->rx_pause; - ifp->if_obytes = s->tx_octets - s->tx_pause * 64; - ifp->if_ibytes = s->rx_octets - s->rx_pause * 64; - ifp->if_omcasts = s->tx_mcast_frames - s->tx_pause; - ifp->if_imcasts = s->rx_mcast_frames - s->rx_pause; - ifp->if_iqdrops = s->rx_ovflow0 + s->rx_ovflow1 + s->rx_ovflow2 + - s->rx_ovflow3 + s->rx_trunc0 + s->rx_trunc1 + s->rx_trunc2 + - s->rx_trunc3; - for (i = 0; i < 4; i++) { - if (pi->rx_chan_map & (1 << i)) { - uint32_t v; - - /* - * XXX: indirect reads from the same ADDR/DATA pair can - * race with each other. - */ - t4_read_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, - 1, A_TP_MIB_TNL_CNG_DROP_0 + i); - ifp->if_iqdrops += v; - } - } - - drops = s->tx_drop; - for_each_txq(pi, i, txq) - drops += txq->br->br_drops; - ifp->if_oqdrops = drops; - - ifp->if_oerrors = s->tx_error_frames; - ifp->if_ierrors = s->rx_jabber + s->rx_runt + s->rx_too_long + - s->rx_fcs_err + s->rx_len_err; + cxgbe_refresh_stats(sc, pi); callout_schedule(&pi->tick, hz); PORT_UNLOCK(pi); @@ -4771,6 +4879,10 @@ cxgbe_sysctls(struct port_info *pi) CTLTYPE_INT | CTLFLAG_RW, pi, 0, sysctl_qsize_txq, "I", "tx queue size"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "pause_settings", + CTLTYPE_STRING | CTLFLAG_RW, pi, PAUSE_TX, sysctl_pause_settings, + "A", "PAUSE settings (bit 0 = rx_pause, bit 1 = tx_pause)"); + /* * dev.cxgbe.X.stats. */ @@ -5151,6 +5263,65 @@ sysctl_qsize_txq(SYSCTL_HANDLER_ARGS) return (rc); } +static int +sysctl_pause_settings(SYSCTL_HANDLER_ARGS) +{ + struct port_info *pi = arg1; + struct adapter *sc = pi->adapter; + struct link_config *lc = &pi->link_cfg; + int rc; + + if (req->newptr == NULL) { + struct sbuf *sb; + static char *bits = "\20\1PAUSE_RX\2PAUSE_TX"; + + rc = sysctl_wire_old_buffer(req, 0); + if (rc != 0) + return(rc); + + sb = sbuf_new_for_sysctl(NULL, NULL, 128, req); + if (sb == NULL) + return (ENOMEM); + + sbuf_printf(sb, "%b", lc->fc & (PAUSE_TX | PAUSE_RX), bits); + rc = sbuf_finish(sb); + sbuf_delete(sb); + } else { + char s[2]; + int n; + + s[0] = '0' + (lc->requested_fc & (PAUSE_TX | PAUSE_RX)); + s[1] = 0; + + rc = sysctl_handle_string(oidp, s, sizeof(s), req); + if (rc != 0) + return(rc); + + if (s[1] != 0) + return (EINVAL); + if (s[0] < '0' || s[0] > '9') + return (EINVAL); /* not a number */ + n = s[0] - '0'; + if (n & ~(PAUSE_TX | PAUSE_RX)) + return (EINVAL); /* some other bit is set too */ + + rc = begin_synchronized_op(sc, pi, SLEEP_OK | INTR_OK, "t4PAUSE"); + if (rc) + return (rc); + if ((lc->requested_fc & (PAUSE_TX | PAUSE_RX)) != n) { + int link_ok = lc->link_ok; + + lc->requested_fc &= ~(PAUSE_TX | PAUSE_RX); + lc->requested_fc |= n; + rc = -t4_link_start(sc, sc->mbox, pi->tx_chan, lc); + lc->link_ok = link_ok; /* restore */ + } + end_synchronized_op(sc, 0); + } + + return (rc); +} + static int sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS) { @@ -8177,6 +8348,12 @@ t4_activate_uld(struct adapter *sc, int id) SLIST_FOREACH(ui, &t4_uld_list, link) { if (ui->uld_id == id) { + if (!(sc->flags & FULL_INIT_DONE)) { + rc = adapter_full_init(sc); + if (rc != 0) + goto done; + } + rc = ui->activate(sc); if (rc == 0) ui->refcount++; diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 89aef324006e..a0742d0c7d24 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -377,7 +377,7 @@ alloc_nm_txq_hwq(struct port_info *pi, struct sge_nm_txq *nm_txq) nm_txq->pidx = nm_txq->cidx = 0; MPASS(nm_txq->sidx == na->num_tx_desc); - nm_txq->equiqidx = nm_txq-> equeqidx = nm_txq->dbidx = 0; + nm_txq->equiqidx = nm_txq->equeqidx = nm_txq->dbidx = 0; nm_txq->doorbells = sc->doorbells; if (isset(&nm_txq->doorbells, DOORBELL_UDB) || diff --git a/sys/dev/cxgbe/tom/t4_listen.c b/sys/dev/cxgbe/tom/t4_listen.c index 1c25bafd3de4..4380c9ee92ac 100644 --- a/sys/dev/cxgbe/tom/t4_listen.c +++ b/sys/dev/cxgbe/tom/t4_listen.c @@ -1311,7 +1311,7 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss_header *rss, REJECT_PASS_ACCEPT(); rpl = wrtod(wr); - INP_INFO_WLOCK(&V_tcbinfo); /* for 4-tuple check, syncache_add */ + INP_INFO_WLOCK(&V_tcbinfo); /* for 4-tuple check */ /* Don't offload if the 4-tuple is already in use */ if (toe_4tuple_check(&inc, &th, ifp) != 0) { @@ -1319,6 +1319,7 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss_header *rss, free(wr, M_CXGBE); REJECT_PASS_ACCEPT(); } + INP_INFO_WUNLOCK(&V_tcbinfo); inp = lctx->inp; /* listening socket, not owned by TOE */ INP_WLOCK(inp); @@ -1331,7 +1332,6 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss_header *rss, * resources tied to this listen context. */ INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_tcbinfo); free(wr, M_CXGBE); REJECT_PASS_ACCEPT(); } @@ -1378,12 +1378,10 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss_header *rss, /* * If all goes well t4_syncache_respond will get called during - * syncache_add. Also note that syncache_add releases both pcbinfo and - * pcb locks. + * syncache_add. Note that syncache_add releases the pcb lock. */ toe_syncache_add(&inc, &to, &th, inp, tod, synqe); INP_UNLOCK_ASSERT(inp); /* ok to assert, we have a ref on the inp */ - INP_INFO_UNLOCK_ASSERT(&V_tcbinfo); /* * If we replied during syncache_add (synqe->wr has been consumed), diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index e3ce9daf2745..9458a4444307 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2915,9 +2915,9 @@ dc_rxeof(struct dc_softc *sc) (rxstat & (DC_RXSTAT_CRCERR | DC_RXSTAT_DRIBBLE | DC_RXSTAT_MIIERE | DC_RXSTAT_COLLSEEN | DC_RXSTAT_RUNT | DC_RXSTAT_DE))) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (rxstat & DC_RXSTAT_COLLSEEN) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); dc_discard_rxbuf(sc, i); if (rxstat & DC_RXSTAT_CRCERR) continue; @@ -2943,7 +2943,7 @@ dc_rxeof(struct dc_softc *sc) */ if (dc_newbuf(sc, i) != 0) { dc_discard_rxbuf(sc, i); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } m->m_pkthdr.rcvif = ifp; @@ -2956,14 +2956,14 @@ dc_rxeof(struct dc_softc *sc) ETHER_ALIGN, ifp, NULL); dc_discard_rxbuf(sc, i); if (m0 == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } m = m0; } #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); DC_UNLOCK(sc); (*ifp->if_input)(ifp, m); DC_LOCK(sc); @@ -3054,19 +3054,19 @@ dc_txeof(struct dc_softc *sc) } if (txstat & DC_TXSTAT_ERRSUM) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (txstat & DC_TXSTAT_EXCESSCOLL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (txstat & DC_TXSTAT_LATECOLL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (!(txstat & DC_TXSTAT_UNDERRUN)) { ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } } else - ifp->if_opackets++; - ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (txstat & DC_TXSTAT_COLLCNT) >> 3); bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], BUS_DMASYNC_POSTWRITE); @@ -3261,7 +3261,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) if (status & (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF)) { uint32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); - ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); + if_inc_counter(ifp, IFCOUNTER_IERRORS, (r & 0xffff) + ((r >> 17) & 0x7ff)); if (dc_rx_resync(sc)) dc_rxeof(sc); @@ -3343,7 +3343,7 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { r = CSR_READ_4(sc, DC_FRAMESDISCARDED); - ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); + if_inc_counter(ifp, IFCOUNTER_IERRORS, (r & 0xffff) + ((r >> 17) & 0x7ff)); if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); @@ -3941,7 +3941,7 @@ dc_watchdog(void *xsc) } ifp = sc->dc_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); device_printf(sc->dc_dev, "watchdog timeout\n"); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index 147b404fc9f2..6700fabd1efd 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -3439,7 +3439,7 @@ tulip_rx_intr(tulip_softc_t * const sc) } else { CTR1(KTR_TULIP, "tulip_rx_intr: bad packet; status %08x", DESC_STATUS(eop)); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (DESC_STATUS(eop) & (TULIP_DSTS_RxBADLENGTH|TULIP_DSTS_RxOVERFLOW|TULIP_DSTS_RxWATCHDOG)) { sc->tulip_dot3stats.dot3StatsInternalMacReceiveErrors++; } else { @@ -3479,7 +3479,7 @@ tulip_rx_intr(tulip_softc_t * const sc) #if defined(TULIP_DEBUG) cnt++; #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if (++eop == ri->ri_last) eop = ri->ri_first; ri->ri_nextin = eop; @@ -3501,7 +3501,7 @@ tulip_rx_intr(tulip_softc_t * const sc) */ m0 = m_devget(mtod(ms, caddr_t), total_len, ETHER_ALIGN, ifp, NULL); if (m0 == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip_input; } #else @@ -3675,7 +3675,7 @@ tulip_tx_intr(tulip_softc_t * const sc) if (d_status & TULIP_DSTS_ERRSUM) { CTR1(KTR_TULIP, "tulip_tx_intr: output error: %08x", d_status); - sc->tulip_ifp->if_oerrors++; + if_inc_counter(sc->tulip_ifp, IFCOUNTER_OERRORS, 1); if (d_status & TULIP_DSTS_TxEXCCOLL) sc->tulip_dot3stats.dot3StatsExcessiveCollisions++; if (d_status & TULIP_DSTS_TxLATECOLL) @@ -3696,7 +3696,7 @@ tulip_tx_intr(tulip_softc_t * const sc) CTR2(KTR_TULIP, "tulip_tx_intr: output ok, collisions %d, status %08x", collisions, d_status); - sc->tulip_ifp->if_collisions += collisions; + if_inc_counter(sc->tulip_ifp, IFCOUNTER_COLLISIONS, collisions); if (collisions == 1) sc->tulip_dot3stats.dot3StatsSingleCollisionFrames++; else if (collisions > 1) @@ -3730,7 +3730,7 @@ tulip_tx_intr(tulip_softc_t * const sc) sc->tulip_txtimer = 0; else if (xmits > 0) sc->tulip_txtimer = TULIP_TXTIMER; - sc->tulip_ifp->if_opackets += xmits; + if_inc_counter(sc->tulip_ifp, IFCOUNTER_OPACKETS, xmits); TULIP_PERFEND(txintr); return descs; } diff --git a/sys/dev/drm2/drm_gem_names.c b/sys/dev/drm2/drm_gem_names.c index 084d50f04784..03ef2c807183 100644 --- a/sys/dev/drm2/drm_gem_names.c +++ b/sys/dev/drm2/drm_gem_names.c @@ -127,6 +127,24 @@ drm_gem_find_name(struct drm_gem_names *names, void *ptr) return (arg.res); } +void * +drm_gem_find_ptr(struct drm_gem_names *names, uint32_t name) +{ + struct drm_gem_name *n; + void *res; + + mtx_lock(&names->lock); + LIST_FOREACH(n, gem_name_hash_index(names, name), link) { + if (n->name == name) { + res = n->ptr; + mtx_unlock(&names->lock); + return (res); + } + } + mtx_unlock(&names->lock); + return (NULL); +} + int drm_gem_name_create(struct drm_gem_names *names, void *p, uint32_t *name) { diff --git a/sys/dev/drm2/drm_gem_names.h b/sys/dev/drm2/drm_gem_names.h index 0fe4edd99212..08f6fa470786 100644 --- a/sys/dev/drm2/drm_gem_names.h +++ b/sys/dev/drm2/drm_gem_names.h @@ -54,6 +54,7 @@ struct drm_gem_names { void drm_gem_names_init(struct drm_gem_names *names); void drm_gem_names_fini(struct drm_gem_names *names); uint32_t drm_gem_find_name(struct drm_gem_names *names, void *ptr); +void *drm_gem_find_ptr(struct drm_gem_names *names, uint32_t name); void *drm_gem_name_ref(struct drm_gem_names *names, uint32_t name, void (*ref)(void *)); int drm_gem_name_create(struct drm_gem_names *names, void *obj, uint32_t *name); diff --git a/sys/dev/drm2/i915/i915_dma.c b/sys/dev/drm2/i915/i915_dma.c index 24cd2cd18346..3fceaadb433d 100644 --- a/sys/dev/drm2/i915/i915_dma.c +++ b/sys/dev/drm2/i915/i915_dma.c @@ -1357,6 +1357,7 @@ i915_driver_unload_int(struct drm_device *dev, bool locked) DRM_LOCK(dev); i915_gem_free_all_phys_object(dev); i915_gem_cleanup_ringbuffer(dev); + i915_gem_context_fini(dev); if (!locked) DRM_UNLOCK(dev); i915_gem_cleanup_aliasing_ppgtt(dev); @@ -1413,6 +1414,8 @@ i915_driver_open(struct drm_device *dev, struct drm_file *file_priv) INIT_LIST_HEAD(&i915_file_priv->mm.request_list); file_priv->driver_priv = i915_file_priv; + drm_gem_names_init(&i915_file_priv->context_idr); + return (0); } @@ -1437,6 +1440,7 @@ i915_driver_lastclose(struct drm_device * dev) void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) { + i915_gem_context_close(dev, file_priv); i915_gem_release(dev, file_priv); } @@ -1491,6 +1495,8 @@ struct drm_ioctl_desc i915_ioctls[] = { DRM_IOCTL_DEF(DRM_I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_I915_GET_SPRITE_COLORKEY, intel_sprite_get_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), + DRM_IOCTL_DEF(DRM_I915_GEM_CONTEXT_CREATE, i915_gem_context_create_ioctl, DRM_UNLOCKED), + DRM_IOCTL_DEF(DRM_I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_UNLOCKED), }; #ifdef COMPAT_FREEBSD32 diff --git a/sys/dev/drm2/i915/i915_drm.h b/sys/dev/drm2/i915/i915_drm.h index d4b0ae8386d9..cf5227f20be2 100644 --- a/sys/dev/drm2/i915/i915_drm.h +++ b/sys/dev/drm2/i915/i915_drm.h @@ -204,6 +204,8 @@ typedef struct drm_i915_sarea { #define DRM_I915_GEM_EXECBUFFER2 0x29 #define DRM_I915_GET_SPRITE_COLORKEY 0x2a #define DRM_I915_SET_SPRITE_COLORKEY 0x2b +#define DRM_I915_GEM_CONTEXT_CREATE 0x2d +#define DRM_I915_GEM_CONTEXT_DESTROY 0x2e #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -248,6 +250,8 @@ typedef struct drm_i915_sarea { #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs) #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey) +#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create) +#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy) /* Asynchronous page flipping: */ @@ -702,7 +706,7 @@ struct drm_i915_gem_exec_object2 { #define EXEC_OBJECT_NEEDS_FENCE (1<<0) uint64_t flags; - uint64_t rsvd1; + uint64_t rsvd1; /* now used for context info */ uint64_t rsvd2; }; @@ -746,6 +750,12 @@ struct drm_i915_gem_execbuffer2 { /** Resets the SO write offset registers for transform feedback on gen7. */ #define I915_EXEC_GEN7_SOL_RESET (1<<8) +#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) +#define i915_execbuffer2_set_context_id(eb2, context) \ + (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK +#define i915_execbuffer2_get_context_id(eb2) \ + ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK) + struct drm_i915_gem_pin { /** Handle of the buffer to be pinned. */ uint32_t handle; @@ -968,4 +978,15 @@ struct drm_intel_sprite_colorkey { uint32_t flags; }; +struct drm_i915_gem_context_create { + /* output: id of new context*/ + uint32_t ctx_id; + uint32_t pad; +}; + +struct drm_i915_gem_context_destroy { + uint32_t ctx_id; + uint32_t pad; +}; + #endif /* _I915_DRM_H_ */ diff --git a/sys/dev/drm2/i915/i915_drv.c b/sys/dev/drm2/i915/i915_drv.c index 85ac10e0f97c..2380d237f0fa 100644 --- a/sys/dev/drm2/i915/i915_drv.c +++ b/sys/dev/drm2/i915/i915_drv.c @@ -612,7 +612,7 @@ __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv) } static int -i8xx_do_reset(struct drm_device *dev, u8 flags) +i8xx_do_reset(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; int onems; @@ -657,7 +657,7 @@ i965_reset_complete(struct drm_device *dev) } static int -i965_do_reset(struct drm_device *dev, u8 flags) +i965_do_reset(struct drm_device *dev) { u8 gdrst; @@ -667,28 +667,30 @@ i965_do_reset(struct drm_device *dev, u8 flags) * triggers the reset; when done, the hardware will clear it. */ gdrst = pci_read_config(dev->device, I965_GDRST, 1); - pci_write_config(dev->device, I965_GDRST, gdrst | flags | 0x1, 1); + pci_write_config(dev->device, I965_GDRST, + gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE, 1); return (_intel_wait_for(dev, i965_reset_complete(dev), 500, 1, "915rst")); } static int -ironlake_do_reset(struct drm_device *dev, u8 flags) +ironlake_do_reset(struct drm_device *dev) { struct drm_i915_private *dev_priv; u32 gdrst; dev_priv = dev->dev_private; gdrst = I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR); - I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, gdrst | flags | 0x1); + I915_WRITE(MCHBAR_MIRROR_BASE + ILK_GDSR, + gdrst | GRDOM_RENDER | GRDOM_RESET_ENABLE); return (_intel_wait_for(dev, (I915_READ(MCHBAR_MIRROR_BASE + ILK_GDSR) & 0x1) != 0, 500, 1, "915rst")); } static int -gen6_do_reset(struct drm_device *dev, u8 flags) +gen6_do_reset(struct drm_device *dev) { struct drm_i915_private *dev_priv; int ret; @@ -726,8 +728,43 @@ gen6_do_reset(struct drm_device *dev, u8 flags) return (ret); } +int intel_gpu_reset(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + int ret = -ENODEV; + + switch (INTEL_INFO(dev)->gen) { + case 7: + case 6: + ret = gen6_do_reset(dev); + break; + case 5: + ret = ironlake_do_reset(dev); + break; + case 4: + ret = i965_do_reset(dev); + break; + case 2: + ret = i8xx_do_reset(dev); + break; + } + + /* Also reset the gpu hangman. */ + if (dev_priv->stop_rings) { + DRM_DEBUG("Simulated gpu hang, resetting stop_rings\n"); + dev_priv->stop_rings = 0; + if (ret == -ENODEV) { + DRM_ERROR("Reset not implemented, but ignoring " + "error for simulated gpu hangs\n"); + ret = 0; + } + } + + return ret; +} + int -i915_reset(struct drm_device *dev, u8 flags) +i915_reset(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; /* @@ -748,23 +785,9 @@ i915_reset(struct drm_device *dev, u8 flags) ret = -ENODEV; if (time_second - dev_priv->last_gpu_reset < 5) { DRM_ERROR("GPU hanging too fast, declaring wedged!\n"); - } else { - switch (INTEL_INFO(dev)->gen) { - case 7: - case 6: - ret = gen6_do_reset(dev, flags); - break; - case 5: - ret = ironlake_do_reset(dev, flags); - break; - case 4: - ret = i965_do_reset(dev, flags); - break; - case 2: - ret = i8xx_do_reset(dev, flags); - break; - } - } + } else + ret = intel_gpu_reset(dev); + dev_priv->last_gpu_reset = time_second; if (ret) { DRM_ERROR("Failed to reset chip.\n"); @@ -784,6 +807,7 @@ i915_reset(struct drm_device *dev, u8 flags) if (HAS_BLT(dev)) dev_priv->rings[BCS].init(&dev_priv->rings[BCS]); + i915_gem_context_init(dev); i915_gem_init_ppgtt(dev); drm_irq_uninstall(dev); diff --git a/sys/dev/drm2/i915/i915_drv.h b/sys/dev/drm2/i915/i915_drv.h index c332f838804d..b84f4f39a74d 100644 --- a/sys/dev/drm2/i915/i915_drv.h +++ b/sys/dev/drm2/i915/i915_drv.h @@ -174,6 +174,17 @@ struct i915_hw_ppgtt { vm_paddr_t scratch_page_dma_addr; }; + +/* This must match up with the value previously used for execbuf2.rsvd1. */ +#define DEFAULT_CONTEXT_ID 0 +struct i915_hw_context { + uint32_t id; + bool is_initialized; + struct drm_i915_file_private *file_priv; + struct intel_ring_buffer *ring; + struct drm_i915_gem_object *obj; +}; + enum no_fbc_reason { FBC_NO_OUTPUT, /* no outputs enabled to compress */ FBC_STOLEN_TOO_SMALL, /* not enough space to hold compressed buffers */ @@ -700,6 +711,8 @@ typedef struct drm_i915_private { enum no_fbc_reason no_fbc_reason; + unsigned int stop_rings; + unsigned long cfb_size; unsigned int cfb_fb; int cfb_plane; @@ -723,8 +736,16 @@ typedef struct drm_i915_private { struct drm_property *broadcast_rgb_property; struct drm_property *force_audio_property; + + bool hw_contexts_disabled; + uint32_t hw_context_size; } drm_i915_private_t; +/* Iterate over initialised rings */ +#define for_each_ring(ring__, dev_priv__, i__) \ + for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \ + if (((ring__) = &(dev_priv__)->rings[(i__)]), intel_ring_initialized((ring__))) + enum hdmi_force_audio { HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */ HDMI_AUDIO_OFF, /* force turn off HDMI audio */ @@ -832,6 +853,7 @@ struct drm_i915_gem_object { unsigned int cache_level:2; unsigned int has_aliasing_ppgtt_mapping:1; + unsigned int has_global_gtt_mapping:1; vm_page_t *pages; @@ -927,6 +949,7 @@ struct drm_i915_file_private { struct list_head request_list; struct mtx lck; } mm; + struct drm_gem_names context_idr; }; struct drm_i915_error_state { @@ -1026,7 +1049,8 @@ extern int i915_enable_hangcheck; const struct intel_device_info *i915_get_device_id(int device); -int i915_reset(struct drm_device *dev, u8 flags); +extern int intel_gpu_reset(struct drm_device *dev); +int i915_reset(struct drm_device *dev); /* i915_debug.c */ int i915_sysctl_init(struct drm_device *dev, struct sysctl_ctx_list *ctx, @@ -1205,6 +1229,17 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file); int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, enum i915_cache_level cache_level); +/* i915_gem_context.c */ +void i915_gem_context_init(struct drm_device *dev); +void i915_gem_context_fini(struct drm_device *dev); +void i915_gem_context_close(struct drm_device *dev, struct drm_file *file); +int i915_switch_context(struct intel_ring_buffer *ring, + struct drm_file *file, int to_id); +int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); +int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); + void i915_gem_free_all_phys_object(struct drm_device *dev); void i915_gem_detach_phys_object(struct drm_device *dev, struct drm_i915_gem_object *obj); @@ -1444,6 +1479,7 @@ __i915_write(64, 64) #define HAS_LLC(dev) (INTEL_INFO(dev)->has_llc) #define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws) +#define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)->gen >= 6) #define HAS_ALIASING_PPGTT(dev) (INTEL_INFO(dev)->gen >=6) #define HAS_OVERLAY(dev) (INTEL_INFO(dev)->has_overlay) diff --git a/sys/dev/drm2/i915/i915_gem.c b/sys/dev/drm2/i915/i915_gem.c index 6d462071d7b9..45e770d30f3e 100644 --- a/sys/dev/drm2/i915/i915_gem.c +++ b/sys/dev/drm2/i915/i915_gem.c @@ -477,6 +477,7 @@ i915_gem_init_hw(struct drm_device *dev) } dev_priv->next_seqno = 1; + i915_gem_context_init(dev); i915_gem_init_ppgtt(dev); return (0); @@ -2586,11 +2587,16 @@ int i915_gpu_idle(struct drm_device *dev, bool do_retire) { drm_i915_private_t *dev_priv = dev->dev_private; + struct intel_ring_buffer *ring; int ret, i; /* Flush everything onto the inactive list. */ - for (i = 0; i < I915_NUM_RINGS; i++) { - ret = i915_ring_idle(&dev_priv->rings[i], do_retire); + for_each_ring(ring, dev_priv, i) { + ret = i915_switch_context(ring, NULL, DEFAULT_CONTEXT_ID); + if (ret) + return ret; + + ret = i915_ring_idle(ring, do_retire); if (ret) return ret; } diff --git a/sys/dev/drm2/i915/i915_gem_context.c b/sys/dev/drm2/i915/i915_gem_context.c new file mode 100644 index 000000000000..07d7a66d09e2 --- /dev/null +++ b/sys/dev/drm2/i915/i915_gem_context.c @@ -0,0 +1,549 @@ +/* + * Copyright © 2011-2012 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Ben Widawsky + * + */ + +/* + * This file implements HW context support. On gen5+ a HW context consists of an + * opaque GPU object which is referenced at times of context saves and restores. + * With RC6 enabled, the context is also referenced as the GPU enters and exists + * from RC6 (GPU has it's own internal power context, except on gen5). Though + * something like a context does exist for the media ring, the code only + * supports contexts for the render ring. + * + * In software, there is a distinction between contexts created by the user, + * and the default HW context. The default HW context is used by GPU clients + * that do not request setup of their own hardware context. The default + * context's state is never restored to help prevent programming errors. This + * would happen if a client ran and piggy-backed off another clients GPU state. + * The default context only exists to give the GPU some offset to load as the + * current to invoke a save of the context we actually care about. In fact, the + * code could likely be constructed, albeit in a more complicated fashion, to + * never use the default context, though that limits the driver's ability to + * swap out, and/or destroy other contexts. + * + * All other contexts are created as a request by the GPU client. These contexts + * store GPU state, and thus allow GPU clients to not re-emit state (and + * potentially query certain state) at any time. The kernel driver makes + * certain that the appropriate commands are inserted. + * + * The context life cycle is semi-complicated in that context BOs may live + * longer than the context itself because of the way the hardware, and object + * tracking works. Below is a very crude representation of the state machine + * describing the context life. + * refcount pincount active + * S0: initial state 0 0 0 + * S1: context created 1 0 0 + * S2: context is currently running 2 1 X + * S3: GPU referenced, but not current 2 0 1 + * S4: context is current, but destroyed 1 1 0 + * S5: like S3, but destroyed 1 0 1 + * + * The most common (but not all) transitions: + * S0->S1: client creates a context + * S1->S2: client submits execbuf with context + * S2->S3: other clients submits execbuf with context + * S3->S1: context object was retired + * S3->S2: clients submits another execbuf + * S2->S4: context destroy called with current context + * S3->S5->S0: destroy path + * S4->S5->S0: destroy path on current context + * + * There are two confusing terms used above: + * The "current context" means the context which is currently running on the + * GPU. The GPU has loaded it's state already and has stored away the gtt + * offset of the BO. The GPU is not actively referencing the data at this + * offset, but it will on the next context switch. The only way to avoid this + * is to do a GPU reset. + * + * An "active context' is one which was previously the "current context" and is + * on the active list waiting for the next context switch to occur. Until this + * happens, the object must remain at the same gtt offset. It is therefore + * possible to destroy a context, but it is still active. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "i915_drv.h" + +/* This is a HW constraint. The value below is the largest known requirement + * I've seen in a spec to date, and that was a workaround for a non-shipping + * part. It should be safe to decrease this, but it's more future proof as is. + */ +#define CONTEXT_ALIGN (64<<10) + +static struct i915_hw_context * +i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id); +static int do_switch(struct i915_hw_context *to); + +static int get_context_size(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + int ret; + u32 reg; + + switch (INTEL_INFO(dev)->gen) { + case 6: + reg = I915_READ(CXT_SIZE); + ret = GEN6_CXT_TOTAL_SIZE(reg) * 64; + break; + case 7: + reg = I915_READ(GEN7_CXT_SIZE); +#ifdef FREEBSD_WIP + if (IS_HASWELL(dev)) + ret = HSW_CXT_TOTAL_SIZE(reg) * 64; + else +#endif + ret = GEN7_CXT_TOTAL_SIZE(reg) * 64; + break; + default: + panic("i915_gem_context: Unsupported Intel GPU generation %d", + INTEL_INFO(dev)->gen); + } + + return ret; +} + +static void do_destroy(struct i915_hw_context *ctx) +{ +#if defined(INVARIANTS) + struct drm_device *dev = ctx->obj->base.dev; + struct drm_i915_private *dev_priv = dev->dev_private; +#endif + + if (ctx->file_priv) + drm_gem_names_remove(&ctx->file_priv->context_idr, ctx->id); + else + KASSERT(ctx == dev_priv->rings[RCS].default_context, + ("i915_gem_context: ctx != default_context")); + + drm_gem_object_unreference(&ctx->obj->base); + free(ctx, DRM_I915_GEM); +} + +static int +create_hw_context(struct drm_device *dev, + struct drm_i915_file_private *file_priv, + struct i915_hw_context **ret_ctx) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct i915_hw_context *ctx; + int ret, id; + + ctx = malloc(sizeof(*ctx), DRM_I915_GEM, M_NOWAIT | M_ZERO); + if (ctx == NULL) + return (-ENOMEM); + + ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); + if (ctx->obj == NULL) { + free(ctx, DRM_I915_GEM); + DRM_DEBUG_DRIVER("Context object allocated failed\n"); + return (-ENOMEM); + } + + if (INTEL_INFO(dev)->gen >= 7) { + ret = i915_gem_object_set_cache_level(ctx->obj, + I915_CACHE_LLC_MLC); + if (ret) + goto err_out; + } + + /* The ring associated with the context object is handled by the normal + * object tracking code. We give an initial ring value simple to pass an + * assertion in the context switch code. + */ + ctx->ring = &dev_priv->rings[RCS]; + + /* Default context will never have a file_priv */ + if (file_priv == NULL) { + *ret_ctx = ctx; + return (0); + } + + ctx->file_priv = file_priv; + +again: + id = 0; + ret = drm_gem_name_create(&file_priv->context_idr, ctx, &id); + if (ret == 0) + ctx->id = id; + + if (ret == -EAGAIN) + goto again; + else if (ret) + goto err_out; + + *ret_ctx = ctx; + return (0); + +err_out: + do_destroy(ctx); + return (ret); +} + +static inline bool is_default_context(struct i915_hw_context *ctx) +{ + return (ctx == ctx->ring->default_context); +} + +/** + * The default context needs to exist per ring that uses contexts. It stores the + * context state of the GPU for applications that don't utilize HW contexts, as + * well as an idle case. + */ +static int create_default_context(struct drm_i915_private *dev_priv) +{ + struct i915_hw_context *ctx; + int ret; + + DRM_LOCK_ASSERT(dev_priv->dev); + + ret = create_hw_context(dev_priv->dev, NULL, &ctx); + if (ret != 0) + return (ret); + + /* We may need to do things with the shrinker which require us to + * immediately switch back to the default context. This can cause a + * problem as pinning the default context also requires GTT space which + * may not be available. To avoid this we always pin the + * default context. + */ + dev_priv->rings[RCS].default_context = ctx; + ret = i915_gem_object_pin(ctx->obj, CONTEXT_ALIGN, false); + if (ret) + goto err_destroy; + + ret = do_switch(ctx); + if (ret) + goto err_unpin; + + DRM_DEBUG_DRIVER("Default HW context loaded\n"); + return 0; + +err_unpin: + i915_gem_object_unpin(ctx->obj); +err_destroy: + do_destroy(ctx); + return ret; +} + +void i915_gem_context_init(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + uint32_t ctx_size; + + if (!HAS_HW_CONTEXTS(dev)) { + dev_priv->hw_contexts_disabled = true; + return; + } + + /* If called from reset, or thaw... we've been here already */ + if (dev_priv->hw_contexts_disabled || + dev_priv->rings[RCS].default_context) + return; + + ctx_size = get_context_size(dev); + dev_priv->hw_context_size = get_context_size(dev); + dev_priv->hw_context_size = roundup(dev_priv->hw_context_size, 4096); + + if (ctx_size <= 0 || ctx_size > (1<<20)) { + dev_priv->hw_contexts_disabled = true; + return; + } + + if (create_default_context(dev_priv)) { + dev_priv->hw_contexts_disabled = true; + return; + } + + DRM_DEBUG_DRIVER("HW context support initialized\n"); +} + +void i915_gem_context_fini(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + if (dev_priv->hw_contexts_disabled) + return; + + /* The only known way to stop the gpu from accessing the hw context is + * to reset it. Do this as the very last operation to avoid confusing + * other code, leading to spurious errors. */ + intel_gpu_reset(dev); + + i915_gem_object_unpin(dev_priv->rings[RCS].default_context->obj); + + do_destroy(dev_priv->rings[RCS].default_context); +} + +static int context_idr_cleanup(uint32_t id, void *p, void *data) +{ + struct i915_hw_context *ctx = p; + + KASSERT(id != DEFAULT_CONTEXT_ID, ("i915_gem_context: id == DEFAULT_CONTEXT_ID in cleanup")); + + do_destroy(ctx); + + return 0; +} + +void i915_gem_context_close(struct drm_device *dev, struct drm_file *file) +{ + struct drm_i915_file_private *file_priv = file->driver_priv; + + //DRM_LOCK(dev); /* Called from preclose(), the lock is already owned. */ + drm_gem_names_foreach(&file_priv->context_idr, context_idr_cleanup, NULL); + drm_gem_names_fini(&file_priv->context_idr); + //DRM_UNLOCK(dev); +} + +static struct i915_hw_context * +i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id) +{ + return (struct i915_hw_context *)drm_gem_find_ptr(&file_priv->context_idr, id); +} + +static inline int +mi_set_context(struct intel_ring_buffer *ring, + struct i915_hw_context *new_context, + u32 hw_flags) +{ + int ret; + + /* w/a: If Flush TLB Invalidation Mode is enabled, driver must do a TLB + * invalidation prior to MI_SET_CONTEXT. On GEN6 we don't set the value + * explicitly, so we rely on the value at ring init, stored in + * itlb_before_ctx_switch. + */ + if (IS_GEN6(ring->dev) && ring->itlb_before_ctx_switch) { + ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, 0); + if (ret) + return ret; + } + + ret = intel_ring_begin(ring, 6); + if (ret) + return ret; + + if (IS_GEN7(ring->dev)) + intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_DISABLE); + else + intel_ring_emit(ring, MI_NOOP); + + intel_ring_emit(ring, MI_NOOP); + intel_ring_emit(ring, MI_SET_CONTEXT); + intel_ring_emit(ring, new_context->obj->gtt_offset | + MI_MM_SPACE_GTT | + MI_SAVE_EXT_STATE_EN | + MI_RESTORE_EXT_STATE_EN | + hw_flags); + /* w/a: MI_SET_CONTEXT must always be followed by MI_NOOP */ + intel_ring_emit(ring, MI_NOOP); + + if (IS_GEN7(ring->dev)) + intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_ENABLE); + else + intel_ring_emit(ring, MI_NOOP); + + intel_ring_advance(ring); + + return ret; +} + +static int do_switch(struct i915_hw_context *to) +{ + struct intel_ring_buffer *ring = to->ring; + struct drm_i915_gem_object *from_obj = ring->last_context_obj; + u32 hw_flags = 0; + int ret; + + KASSERT(!(from_obj != NULL && from_obj->pin_count == 0), + ("i915_gem_context: invalid \"from\" context")); + + if (from_obj == to->obj) + return 0; + + ret = i915_gem_object_pin(to->obj, CONTEXT_ALIGN, false); + if (ret) + return ret; + + /* Clear this page out of any CPU caches for coherent swap-in/out. Note + * that thanks to write = false in this call and us not setting any gpu + * write domains when putting a context object onto the active list + * (when switching away from it), this won't block. + * XXX: We need a real interface to do this instead of trickery. */ + ret = i915_gem_object_set_to_gtt_domain(to->obj, false); + if (ret) { + i915_gem_object_unpin(to->obj); + return ret; + } + + if (!to->obj->has_global_gtt_mapping) + i915_gem_gtt_bind_object(to->obj); + + if (!to->is_initialized || is_default_context(to)) + hw_flags |= MI_RESTORE_INHIBIT; + else if (from_obj == to->obj) /* not yet expected */ + hw_flags |= MI_FORCE_RESTORE; + + ret = mi_set_context(ring, to, hw_flags); + if (ret) { + i915_gem_object_unpin(to->obj); + return ret; + } + + /* The backing object for the context is done after switching to the + * *next* context. Therefore we cannot retire the previous context until + * the next context has already started running. In fact, the below code + * is a bit suboptimal because the retiring can occur simply after the + * MI_SET_CONTEXT instead of when the next seqno has completed. + */ + if (from_obj != NULL) { + from_obj->base.read_domains = I915_GEM_DOMAIN_INSTRUCTION; + i915_gem_object_move_to_active(from_obj, ring, + i915_gem_next_request_seqno(ring)); + /* As long as MI_SET_CONTEXT is serializing, ie. it flushes the + * whole damn pipeline, we don't need to explicitly mark the + * object dirty. The only exception is that the context must be + * correct in case the object gets swapped out. Ideally we'd be + * able to defer doing this until we know the object would be + * swapped, but there is no way to do that yet. + */ + from_obj->dirty = 1; + KASSERT(from_obj->ring == ring, ("i915_gem_context: from_ring != ring")); + i915_gem_object_unpin(from_obj); + + drm_gem_object_unreference(&from_obj->base); + } + + drm_gem_object_reference(&to->obj->base); + ring->last_context_obj = to->obj; + to->is_initialized = true; + + return 0; +} + +/** + * i915_switch_context() - perform a GPU context switch. + * @ring: ring for which we'll execute the context switch + * @file_priv: file_priv associated with the context, may be NULL + * @id: context id number + * @seqno: sequence number by which the new context will be switched to + * @flags: + * + * The context life cycle is simple. The context refcount is incremented and + * decremented by 1 and create and destroy. If the context is in use by the GPU, + * it will have a refoucnt > 1. This allows us to destroy the context abstract + * object while letting the normal object tracking destroy the backing BO. + */ +int i915_switch_context(struct intel_ring_buffer *ring, + struct drm_file *file, + int to_id) +{ + struct drm_i915_private *dev_priv = ring->dev->dev_private; + struct i915_hw_context *to; + + if (dev_priv->hw_contexts_disabled) + return 0; + + if (ring != &dev_priv->rings[RCS]) + return 0; + + if (to_id == DEFAULT_CONTEXT_ID) { + to = ring->default_context; + } else { + if (file == NULL) + return -EINVAL; + + to = i915_gem_context_get(file->driver_priv, to_id); + if (to == NULL) + return -ENOENT; + } + + return do_switch(to); +} + +int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, + struct drm_file *file) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct drm_i915_gem_context_create *args = data; + struct drm_i915_file_private *file_priv = file->driver_priv; + struct i915_hw_context *ctx; + int ret; + + if (!(dev->driver->driver_features & DRIVER_GEM)) + return -ENODEV; + + if (dev_priv->hw_contexts_disabled) + return -ENODEV; + + ret = i915_mutex_lock_interruptible(dev); + if (ret) + return ret; + + ret = create_hw_context(dev, file_priv, &ctx); + DRM_UNLOCK(dev); + if (ret != 0) + return (ret); + + args->ctx_id = ctx->id; + DRM_DEBUG_DRIVER("HW context %d created\n", args->ctx_id); + + return 0; +} + +int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, + struct drm_file *file) +{ + struct drm_i915_gem_context_destroy *args = data; + struct drm_i915_file_private *file_priv = file->driver_priv; + struct i915_hw_context *ctx; + int ret; + + if (!(dev->driver->driver_features & DRIVER_GEM)) + return -ENODEV; + + ret = i915_mutex_lock_interruptible(dev); + if (ret) + return ret; + + ctx = i915_gem_context_get(file_priv, args->ctx_id); + if (!ctx) { + DRM_UNLOCK(dev); + return -ENOENT; + } + + do_destroy(ctx); + + DRM_UNLOCK(dev); + + DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); + return 0; +} diff --git a/sys/dev/drm2/i915/i915_gem_execbuffer.c b/sys/dev/drm2/i915/i915_gem_execbuffer.c index 21e331f1b9f1..e47141a29aa0 100644 --- a/sys/dev/drm2/i915/i915_gem_execbuffer.c +++ b/sys/dev/drm2/i915/i915_gem_execbuffer.c @@ -1130,6 +1130,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_clip_rect *cliprects = NULL; struct intel_ring_buffer *ring; vm_page_t **relocs_ma; + u32 ctx_id = i915_execbuffer2_get_context_id(*args); u32 exec_start, exec_len; u32 seqno; u32 mask; @@ -1158,6 +1159,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, return -EINVAL; } ring = &dev_priv->rings[VCS]; + if (ctx_id != 0) { + DRM_DEBUG("Ring %s doesn't support contexts\n", + ring->name); + return -EPERM; + } break; case I915_EXEC_BLT: if (!HAS_BLT(dev)) { @@ -1165,6 +1171,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, return -EINVAL; } ring = &dev_priv->rings[BCS]; + if (ctx_id != 0) { + DRM_DEBUG("Ring %s doesn't support contexts\n", + ring->name); + return -EPERM; + } break; default: DRM_DEBUG("execbuf with unknown ring: %d\n", @@ -1306,6 +1317,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, if (ret) goto err; + ret = i915_switch_context(ring, file, ctx_id); + if (ret) + goto err; + seqno = i915_gem_next_request_seqno(ring); for (i = 0; i < I915_NUM_RINGS - 1; i++) { if (seqno < ring->sync_seqno[i]) { @@ -1461,6 +1476,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, exec2.num_cliprects = args->num_cliprects; exec2.cliprects_ptr = args->cliprects_ptr; exec2.flags = I915_EXEC_RENDER; + i915_execbuffer2_set_context_id(exec2, 0); ret = i915_gem_do_execbuffer(dev, data, file, &exec2, exec2_list); if (!ret) { diff --git a/sys/dev/drm2/i915/i915_gem_gtt.c b/sys/dev/drm2/i915/i915_gem_gtt.c index a4ca76fce7ee..6204c06349cb 100644 --- a/sys/dev/drm2/i915/i915_gem_gtt.c +++ b/sys/dev/drm2/i915/i915_gem_gtt.c @@ -291,6 +291,9 @@ i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj) agp_type = cache_level_to_agp_type(obj->base.dev, obj->cache_level); intel_gtt_insert_pages(obj->gtt_space->start >> PAGE_SHIFT, obj->base.size >> PAGE_SHIFT, obj->pages, agp_type); + + obj->has_global_gtt_mapping = 1; + return (0); } @@ -308,6 +311,8 @@ i915_gem_gtt_rebind_object(struct drm_i915_gem_object *obj, intel_gtt_insert_pages(obj->gtt_space->start >> PAGE_SHIFT, obj->base.size >> PAGE_SHIFT, obj->pages, agp_type); + + obj->has_global_gtt_mapping = 0; } void diff --git a/sys/dev/drm2/i915/i915_irq.c b/sys/dev/drm2/i915/i915_irq.c index 16afb25ca6c7..15d0a613d101 100644 --- a/sys/dev/drm2/i915/i915_irq.c +++ b/sys/dev/drm2/i915/i915_irq.c @@ -717,7 +717,7 @@ i915_error_work_func(void *context, int pending) if (atomic_load_acq_int(&dev_priv->mm.wedged)) { DRM_DEBUG("i915: resetting chip\n"); /* kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_event); */ - if (!i915_reset(dev, GRDOM_RENDER)) { + if (!i915_reset(dev)) { atomic_store_rel_int(&dev_priv->mm.wedged, 0); /* kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_done_event); */ } diff --git a/sys/dev/drm2/i915/i915_reg.h b/sys/dev/drm2/i915/i915_reg.h index 754e535f78fc..492fac480429 100644 --- a/sys/dev/drm2/i915/i915_reg.h +++ b/sys/dev/drm2/i915/i915_reg.h @@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$"); #define GRDOM_FULL (0<<2) #define GRDOM_RENDER (1<<2) #define GRDOM_MEDIA (3<<2) +#define GRDOM_RESET_ENABLE (1<<0) #define GEN6_MBCUNIT_SNPCR 0x900c /* for LLC config */ #define GEN6_MBC_SNPCR_SHIFT 21 @@ -200,6 +201,10 @@ __FBSDID("$FreeBSD$"); #define MI_DISPLAY_FLIP MI_INSTR(0x14, 2) #define MI_DISPLAY_FLIP_I915 MI_INSTR(0x14, 1) #define MI_DISPLAY_FLIP_PLANE(n) ((n) << 20) +#define MI_ARB_ON_OFF MI_INSTR(0x08, 0) +#define MI_ARB_ENABLE (1<<0) +#define MI_ARB_DISABLE (0<<0) + #define MI_SET_CONTEXT MI_INSTR(0x18, 0) #define MI_MM_SPACE_GTT (1<<8) #define MI_MM_SPACE_PHYSICAL (0<<8) @@ -1361,6 +1366,31 @@ __FBSDID("$FreeBSD$"); */ #define CCID 0x2180 #define CCID_EN (1<<0) +#define CXT_SIZE 0x21a0 +#define GEN6_CXT_POWER_SIZE(cxt_reg) ((cxt_reg >> 24) & 0x3f) +#define GEN6_CXT_RING_SIZE(cxt_reg) ((cxt_reg >> 18) & 0x3f) +#define GEN6_CXT_RENDER_SIZE(cxt_reg) ((cxt_reg >> 12) & 0x3f) +#define GEN6_CXT_EXTENDED_SIZE(cxt_reg) ((cxt_reg >> 6) & 0x3f) +#define GEN6_CXT_PIPELINE_SIZE(cxt_reg) ((cxt_reg >> 0) & 0x3f) +#define GEN6_CXT_TOTAL_SIZE(cxt_reg) (GEN6_CXT_POWER_SIZE(cxt_reg) + \ + GEN6_CXT_RING_SIZE(cxt_reg) + \ + GEN6_CXT_RENDER_SIZE(cxt_reg) + \ + GEN6_CXT_EXTENDED_SIZE(cxt_reg) + \ + GEN6_CXT_PIPELINE_SIZE(cxt_reg)) +#define GEN7_CXT_SIZE 0x21a8 +#define GEN7_CXT_POWER_SIZE(ctx_reg) ((ctx_reg >> 25) & 0x7f) +#define GEN7_CXT_RING_SIZE(ctx_reg) ((ctx_reg >> 22) & 0x7) +#define GEN7_CXT_RENDER_SIZE(ctx_reg) ((ctx_reg >> 16) & 0x3f) +#define GEN7_CXT_EXTENDED_SIZE(ctx_reg) ((ctx_reg >> 9) & 0x7f) +#define GEN7_CXT_GT1_SIZE(ctx_reg) ((ctx_reg >> 6) & 0x7) +#define GEN7_CXT_VFSTATE_SIZE(ctx_reg) ((ctx_reg >> 0) & 0x3f) +#define GEN7_CXT_TOTAL_SIZE(ctx_reg) (GEN7_CXT_POWER_SIZE(ctx_reg) + \ + GEN7_CXT_RING_SIZE(ctx_reg) + \ + GEN7_CXT_RENDER_SIZE(ctx_reg) + \ + GEN7_CXT_EXTENDED_SIZE(ctx_reg) + \ + GEN7_CXT_GT1_SIZE(ctx_reg) + \ + GEN7_CXT_VFSTATE_SIZE(ctx_reg)) + /* * Overlay regs */ diff --git a/sys/dev/drm2/i915/intel_ringbuffer.c b/sys/dev/drm2/i915/intel_ringbuffer.c index 7d6bd947b906..26bc6957c412 100644 --- a/sys/dev/drm2/i915/intel_ringbuffer.c +++ b/sys/dev/drm2/i915/intel_ringbuffer.c @@ -430,6 +430,13 @@ static int init_render_ring(struct intel_ring_buffer *ring) */ I915_WRITE(CACHE_MODE_0, CM0_STC_EVICT_DISABLE_LRA_SNB << CM0_MASK_SHIFT); + + /* This is not explicitly set for GEN6, so read the register. + * see intel_ring_mi_set_context() for why we care. + * TODO: consider explicitly setting the bit for GEN5 + */ + ring->itlb_before_ctx_switch = + !!(I915_READ(GFX_MODE) & GFX_TLB_INVALIDATE_ALWAYS); } if (INTEL_INFO(dev)->gen >= 6) { diff --git a/sys/dev/drm2/i915/intel_ringbuffer.h b/sys/dev/drm2/i915/intel_ringbuffer.h index c20777fc9869..c391b12c9f9f 100644 --- a/sys/dev/drm2/i915/intel_ringbuffer.h +++ b/sys/dev/drm2/i915/intel_ringbuffer.h @@ -122,11 +122,24 @@ struct intel_ring_buffer { */ uint32_t outstanding_lazy_request; + /** + * Do an explicit TLB flush before MI_SET_CONTEXT + */ + bool itlb_before_ctx_switch; + struct i915_hw_context *default_context; + struct drm_i915_gem_object *last_context_obj; + drm_local_map_t map; void *private; }; +static inline bool +intel_ring_initialized(struct intel_ring_buffer *ring) +{ + return ring->obj != NULL; +} + static inline unsigned intel_ring_flag(struct intel_ring_buffer *ring) { diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c new file mode 100644 index 000000000000..aeb98e9fed65 --- /dev/null +++ b/sys/dev/dwc/if_dwc.c @@ -0,0 +1,1324 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +/* + * Ethernet media access controller (EMAC) + * Chapter 17, Altera Cyclone V Device Handbook (CV-5V2 2014.07.22) + * + * EMAC is an instance of the Synopsys DesignWare 3504-0 + * Universal 10/100/1000 Ethernet MAC (DWC_gmac). + */ + +#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 +#include +#include + +#include +#include +#include "miibus_if.h" + +#define READ4(_sc, _reg) \ + bus_read_4((_sc)->res[0], _reg) +#define WRITE4(_sc, _reg, _val) \ + bus_write_4((_sc)->res[0], _reg, _val) + +#define WATCHDOG_TIMEOUT_SECS 5 +#define STATS_HARVEST_INTERVAL 2 +#define MII_CLK_VAL 2 + +#include + +#define DWC_LOCK(sc) mtx_lock(&(sc)->mtx) +#define DWC_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +#define DWC_ASSERT_LOCKED(sc) mtx_assert(&(sc)->mtx, MA_OWNED); +#define DWC_ASSERT_UNLOCKED(sc) mtx_assert(&(sc)->mtx, MA_NOTOWNED); + +#define DDESC_TDES0_OWN (1 << 31) +#define DDESC_TDES0_TXINT (1 << 30) +#define DDESC_TDES0_TXLAST (1 << 29) +#define DDESC_TDES0_TXFIRST (1 << 28) +#define DDESC_TDES0_TXCRCDIS (1 << 27) +#define DDESC_TDES0_TXRINGEND (1 << 21) +#define DDESC_TDES0_TXCHAIN (1 << 20) + +#define DDESC_RDES0_OWN (1 << 31) +#define DDESC_RDES0_FL_MASK 0x3fff +#define DDESC_RDES0_FL_SHIFT 16 /* Frame Length */ +#define DDESC_RDES1_CHAINED (1 << 14) + +struct dwc_bufmap { + bus_dmamap_t map; + struct mbuf *mbuf; +}; + +/* + * A hardware buffer descriptor. Rx and Tx buffers have the same descriptor + * layout, but the bits in the flags field have different meanings. + */ +struct dwc_hwdesc +{ + uint32_t tdes0; + uint32_t tdes1; + uint32_t addr; /* pointer to buffer data */ + uint32_t addr_next; /* link to next descriptor */ +}; + +/* + * Driver data and defines. + */ +#define RX_DESC_COUNT 1024 +#define RX_DESC_SIZE (sizeof(struct dwc_hwdesc) * RX_DESC_COUNT) +#define TX_DESC_COUNT 1024 +#define TX_DESC_SIZE (sizeof(struct dwc_hwdesc) * TX_DESC_COUNT) + +/* + * The hardware imposes alignment restrictions on various objects involved in + * DMA transfers. These values are expressed in bytes (not bits). + */ +#define DWC_DESC_RING_ALIGN 2048 + +struct dwc_softc { + struct resource *res[2]; + bus_space_tag_t bst; + bus_space_handle_t bsh; + device_t dev; + int mii_clk; + device_t miibus; + struct mii_data * mii_softc; + struct ifnet *ifp; + int if_flags; + struct mtx mtx; + void * intr_cookie; + struct callout dwc_callout; + uint8_t phy_conn_type; + uint8_t mactype; + boolean_t link_is_up; + boolean_t is_attached; + boolean_t is_detaching; + int tx_watchdog_count; + int stats_harvest_count; + + /* RX */ + bus_dma_tag_t rxdesc_tag; + bus_dmamap_t rxdesc_map; + struct dwc_hwdesc *rxdesc_ring; + bus_addr_t rxdesc_ring_paddr; + bus_dma_tag_t rxbuf_tag; + struct dwc_bufmap rxbuf_map[RX_DESC_COUNT]; + uint32_t rx_idx; + + /* TX */ + bus_dma_tag_t txdesc_tag; + bus_dmamap_t txdesc_map; + struct dwc_hwdesc *txdesc_ring; + bus_addr_t txdesc_ring_paddr; + bus_dma_tag_t txbuf_tag; + struct dwc_bufmap txbuf_map[RX_DESC_COUNT]; + uint32_t tx_idx_head; + uint32_t tx_idx_tail; + int txcount; +}; + +static struct resource_spec dwc_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static void dwc_txfinish_locked(struct dwc_softc *sc); +static void dwc_rxfinish_locked(struct dwc_softc *sc); +static void dwc_stop_locked(struct dwc_softc *sc); +static void dwc_setup_rxfilter(struct dwc_softc *sc); + +static inline uint32_t +next_rxidx(struct dwc_softc *sc, uint32_t curidx) +{ + + return ((curidx + 1) % RX_DESC_COUNT); +} + +static inline uint32_t +next_txidx(struct dwc_softc *sc, uint32_t curidx) +{ + + return ((curidx + 1) % TX_DESC_COUNT); +} + +static void +dwc_get1paddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + + if (error != 0) + return; + *(bus_addr_t *)arg = segs[0].ds_addr; +} + +inline static uint32_t +dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr, + uint32_t len) +{ + uint32_t flags; + uint32_t nidx; + + nidx = next_txidx(sc, idx); + + /* Addr/len 0 means we're clearing the descriptor after xmit done. */ + if (paddr == 0 || len == 0) { + flags = 0; + --sc->txcount; + } else { + flags = DDESC_TDES0_TXCHAIN | DDESC_TDES0_TXFIRST + | DDESC_TDES0_TXLAST | DDESC_TDES0_TXINT; + ++sc->txcount; + } + + sc->txdesc_ring[idx].addr = (uint32_t)(paddr); + sc->txdesc_ring[idx].tdes0 = flags; + sc->txdesc_ring[idx].tdes1 = len; + + if (paddr && len) { + wmb(); + sc->txdesc_ring[idx].tdes0 |= DDESC_TDES0_OWN; + wmb(); + } + + return (nidx); +} + +static int +dwc_setup_txbuf(struct dwc_softc *sc, int idx, struct mbuf **mp) +{ + struct bus_dma_segment seg; + int error, nsegs; + struct mbuf * m; + + if ((m = m_defrag(*mp, M_NOWAIT)) == NULL) + return (ENOMEM); + *mp = m; + + error = bus_dmamap_load_mbuf_sg(sc->txbuf_tag, sc->txbuf_map[idx].map, + m, &seg, &nsegs, 0); + if (error != 0) { + return (ENOMEM); + } + + KASSERT(nsegs == 1, ("%s: %d segments returned!", __func__, nsegs)); + + bus_dmamap_sync(sc->txbuf_tag, sc->txbuf_map[idx].map, + BUS_DMASYNC_PREWRITE); + + sc->txbuf_map[idx].mbuf = m; + + dwc_setup_txdesc(sc, idx, seg.ds_addr, seg.ds_len); + + return (0); +} + +static void +dwc_txstart_locked(struct dwc_softc *sc) +{ + struct ifnet *ifp; + struct mbuf *m; + int enqueued; + + DWC_ASSERT_LOCKED(sc); + + if (!sc->link_is_up) + return; + + ifp = sc->ifp; + + if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { + return; + } + + enqueued = 0; + + for (;;) { + if (sc->txcount == (TX_DESC_COUNT-1)) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } + + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + if (m == NULL) + break; + if (dwc_setup_txbuf(sc, sc->tx_idx_head, &m) != 0) { + IFQ_DRV_PREPEND(&ifp->if_snd, m); + break; + } + BPF_MTAP(ifp, m); + sc->tx_idx_head = next_txidx(sc, sc->tx_idx_head); + ++enqueued; + } + + if (enqueued != 0) { + WRITE4(sc, TRANSMIT_POLL_DEMAND, 0x1); + sc->tx_watchdog_count = WATCHDOG_TIMEOUT_SECS; + } +} + +static void +dwc_txstart(struct ifnet *ifp) +{ + struct dwc_softc *sc = ifp->if_softc; + + DWC_LOCK(sc); + dwc_txstart_locked(sc); + DWC_UNLOCK(sc); +} + +static void +dwc_stop_locked(struct dwc_softc *sc) +{ + struct ifnet *ifp; + int reg; + + DWC_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + sc->tx_watchdog_count = 0; + sc->stats_harvest_count = 0; + + callout_stop(&sc->dwc_callout); + + /* Stop DMA TX */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_ST); + WRITE4(sc, OPERATION_MODE, reg); + + /* Flush TX */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_FTF); + WRITE4(sc, OPERATION_MODE, reg); + + /* Stop transmitters */ + reg = READ4(sc, MAC_CONFIGURATION); + reg &= ~(CONF_TE | CONF_RE); + WRITE4(sc, MAC_CONFIGURATION, reg); + + /* Stop DMA RX */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); +} + +static void dwc_clear_stats(struct dwc_softc *sc) +{ + int reg; + + reg = READ4(sc, MMC_CONTROL); + reg |= (MMC_CONTROL_CNTRST); + WRITE4(sc, MMC_CONTROL, reg); +} + +static void +dwc_harvest_stats(struct dwc_softc *sc) +{ + struct ifnet *ifp; + + /* We don't need to harvest too often. */ + if (++sc->stats_harvest_count < STATS_HARVEST_INTERVAL) + return; + + sc->stats_harvest_count = 0; + ifp = sc->ifp; + + if_inc_counter(ifp, IFCOUNTER_IPACKETS, READ4(sc, RXFRAMECOUNT_GB)); + if_inc_counter(ifp, IFCOUNTER_IMCASTS, READ4(sc, RXMULTICASTFRAMES_G)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, + READ4(sc, RXOVERSIZE_G) + READ4(sc, RXUNDERSIZE_G) + + READ4(sc, RXCRCERROR) + READ4(sc, RXALIGNMENTERROR) + + READ4(sc, RXRUNTERROR) + READ4(sc, RXJABBERERROR) + + READ4(sc, RXLENGTHERROR)); + + if_inc_counter(ifp, IFCOUNTER_OPACKETS, READ4(sc, TXFRAMECOUNT_G)); + if_inc_counter(ifp, IFCOUNTER_OMCASTS, READ4(sc, TXMULTICASTFRAMES_G)); + if_inc_counter(ifp, IFCOUNTER_OERRORS, + READ4(sc, TXOVERSIZE_G) + READ4(sc, TXEXCESSDEF) + + READ4(sc, TXCARRIERERR) + READ4(sc, TXUNDERFLOWERROR)); + + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + READ4(sc, TXEXESSCOL) + READ4(sc, TXLATECOL)); + + dwc_clear_stats(sc); +} + +static void +dwc_tick(void *arg) +{ + struct dwc_softc *sc; + struct ifnet *ifp; + int link_was_up; + + sc = arg; + + DWC_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + return; + + /* + * Typical tx watchdog. If this fires it indicates that we enqueued + * packets for output and never got a txdone interrupt for them. Maybe + * it's a missed interrupt somehow, just pretend we got one. + */ + if (sc->tx_watchdog_count > 0) { + if (--sc->tx_watchdog_count == 0) { + dwc_txfinish_locked(sc); + } + } + + /* Gather stats from hardware counters. */ + dwc_harvest_stats(sc); + + /* Check the media status. */ + link_was_up = sc->link_is_up; + mii_tick(sc->mii_softc); + if (sc->link_is_up && !link_was_up) + dwc_txstart_locked(sc); + + /* Schedule another check one second from now. */ + callout_reset(&sc->dwc_callout, hz, dwc_tick, sc); +} + +static void +dwc_init_locked(struct dwc_softc *sc) +{ + struct ifnet *ifp = sc->ifp; + int reg; + + DWC_ASSERT_LOCKED(sc); + + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + return; + + ifp->if_drv_flags |= IFF_DRV_RUNNING; + + dwc_setup_rxfilter(sc); + + /* Initializa DMA and enable transmitters */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_TSF | MODE_OSF | MODE_FUF); + reg &= ~(MODE_RSF); + reg |= (MODE_RTC_LEV32 << MODE_RTC_SHIFT); + WRITE4(sc, OPERATION_MODE, reg); + + WRITE4(sc, INTERRUPT_ENABLE, INT_EN_DEFAULT); + + /* Start DMA */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_ST | MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); + + /* Enable transmitters */ + reg = READ4(sc, MAC_CONFIGURATION); + reg |= (CONF_JD | CONF_ACS | CONF_BE); + reg |= (CONF_TE | CONF_RE); + WRITE4(sc, MAC_CONFIGURATION, reg); + + /* + * Call mii_mediachg() which will call back into dwc_miibus_statchg() + * to set up the remaining config registers based on current media. + */ + mii_mediachg(sc->mii_softc); + callout_reset(&sc->dwc_callout, hz, dwc_tick, sc); +} + +static void +dwc_init(void *if_softc) +{ + struct dwc_softc *sc = if_softc; + + DWC_LOCK(sc); + dwc_init_locked(sc); + DWC_UNLOCK(sc); +} + +inline static uint32_t +dwc_setup_rxdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr) +{ + uint32_t nidx; + + sc->rxdesc_ring[idx].addr = (uint32_t)paddr; + nidx = next_rxidx(sc, idx); + sc->rxdesc_ring[idx].addr_next = sc->rxdesc_ring_paddr + \ + (nidx * sizeof(struct dwc_hwdesc)); + sc->rxdesc_ring[idx].tdes1 = DDESC_RDES1_CHAINED | MCLBYTES; + + wmb(); + sc->rxdesc_ring[idx].tdes0 = DDESC_RDES0_OWN; + wmb(); + + return (nidx); +} + +static int +dwc_setup_rxbuf(struct dwc_softc *sc, int idx, struct mbuf *m) +{ + struct bus_dma_segment seg; + int error, nsegs; + + m_adj(m, ETHER_ALIGN); + + error = bus_dmamap_load_mbuf_sg(sc->rxbuf_tag, sc->rxbuf_map[idx].map, + m, &seg, &nsegs, 0); + if (error != 0) { + return (error); + } + + KASSERT(nsegs == 1, ("%s: %d segments returned!", __func__, nsegs)); + + bus_dmamap_sync(sc->rxbuf_tag, sc->rxbuf_map[idx].map, + BUS_DMASYNC_PREREAD); + + sc->rxbuf_map[idx].mbuf = m; + dwc_setup_rxdesc(sc, idx, seg.ds_addr); + + return (0); +} + +static struct mbuf * +dwc_alloc_mbufcl(struct dwc_softc *sc) +{ + struct mbuf *m; + + m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + m->m_pkthdr.len = m->m_len = m->m_ext.ext_size; + + return (m); +} + +static void +dwc_media_status(struct ifnet * ifp, struct ifmediareq *ifmr) +{ + struct dwc_softc *sc; + struct mii_data *mii; + + sc = ifp->if_softc; + mii = sc->mii_softc; + DWC_LOCK(sc); + mii_pollstat(mii); + ifmr->ifm_active = mii->mii_media_active; + ifmr->ifm_status = mii->mii_media_status; + DWC_UNLOCK(sc); +} + +static int +dwc_media_change_locked(struct dwc_softc *sc) +{ + + return (mii_mediachg(sc->mii_softc)); +} + +static int +dwc_media_change(struct ifnet * ifp) +{ + struct dwc_softc *sc; + int error; + + sc = ifp->if_softc; + + DWC_LOCK(sc); + error = dwc_media_change_locked(sc); + DWC_UNLOCK(sc); + return (error); +} + +static const uint8_t nibbletab[] = { + /* 0x0 0000 -> 0000 */ 0x0, + /* 0x1 0001 -> 1000 */ 0x8, + /* 0x2 0010 -> 0100 */ 0x4, + /* 0x3 0011 -> 1100 */ 0xc, + /* 0x4 0100 -> 0010 */ 0x2, + /* 0x5 0101 -> 1010 */ 0xa, + /* 0x6 0110 -> 0110 */ 0x6, + /* 0x7 0111 -> 1110 */ 0xe, + /* 0x8 1000 -> 0001 */ 0x1, + /* 0x9 1001 -> 1001 */ 0x9, + /* 0xa 1010 -> 0101 */ 0x5, + /* 0xb 1011 -> 1101 */ 0xd, + /* 0xc 1100 -> 0011 */ 0x3, + /* 0xd 1101 -> 1011 */ 0xb, + /* 0xe 1110 -> 0111 */ 0x7, + /* 0xf 1111 -> 1111 */ 0xf, }; + +static uint8_t +bitreverse(uint8_t x) +{ + + return (nibbletab[x & 0xf] << 4) | nibbletab[x >> 4]; +} + +static void +dwc_setup_rxfilter(struct dwc_softc *sc) +{ + struct ifmultiaddr *ifma; + struct ifnet *ifp; + uint8_t *eaddr; + uint32_t crc; + uint8_t val; + int hashbit; + int hashreg; + int ffval; + int reg; + int lo; + int hi; + + DWC_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + + /* + * Set the multicast (group) filter hash. + */ + if ((ifp->if_flags & IFF_ALLMULTI)) + ffval = (FRAME_FILTER_PM); + else { + ffval = (FRAME_FILTER_HMC); + if_maddr_rlock(ifp); + TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + crc = ether_crc32_le(LLADDR((struct sockaddr_dl *) + ifma->ifma_addr), ETHER_ADDR_LEN); + + /* Take lower 8 bits and reverse it */ + val = bitreverse(~crc & 0xff); + hashreg = (val >> 5); + hashbit = (val & 31); + + reg = READ4(sc, HASH_TABLE_REG(hashreg)); + reg |= (1 << hashbit); + WRITE4(sc, HASH_TABLE_REG(hashreg), reg); + } + if_maddr_runlock(ifp); + } + + /* + * Set the individual address filter hash. + */ + if (ifp->if_flags & IFF_PROMISC) + ffval |= (FRAME_FILTER_PR); + + /* + * Set the primary address. + */ + eaddr = IF_LLADDR(ifp); + lo = eaddr[0] | (eaddr[1] << 8) | (eaddr[2] << 16) | + (eaddr[3] << 24); + hi = eaddr[4] | (eaddr[5] << 8); + WRITE4(sc, MAC_ADDRESS_LOW(0), lo); + WRITE4(sc, MAC_ADDRESS_HIGH(0), hi); + WRITE4(sc, MAC_FRAME_FILTER, ffval); +} + +static int +dwc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + struct dwc_softc *sc; + struct mii_data *mii; + struct ifreq *ifr; + int mask, error; + + sc = ifp->if_softc; + ifr = (struct ifreq *)data; + + error = 0; + switch (cmd) { + case SIOCSIFFLAGS: + DWC_LOCK(sc); + if (ifp->if_flags & IFF_UP) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if ((ifp->if_flags ^ sc->if_flags) & + (IFF_PROMISC | IFF_ALLMULTI)) + dwc_setup_rxfilter(sc); + } else { + if (!sc->is_detaching) + dwc_init_locked(sc); + } + } else { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + dwc_stop_locked(sc); + } + sc->if_flags = ifp->if_flags; + DWC_UNLOCK(sc); + break; + case SIOCADDMULTI: + case SIOCDELMULTI: + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + DWC_LOCK(sc); + dwc_setup_rxfilter(sc); + DWC_UNLOCK(sc); + } + break; + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + mii = sc->mii_softc; + error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); + break; + case SIOCSIFCAP: + mask = ifp->if_capenable ^ ifr->ifr_reqcap; + if (mask & IFCAP_VLAN_MTU) { + /* No work to do except acknowledge the change took */ + ifp->if_capenable ^= IFCAP_VLAN_MTU; + } + break; + + default: + error = ether_ioctl(ifp, cmd, data); + break; + } + + return (error); +} + +static void +dwc_txfinish_locked(struct dwc_softc *sc) +{ + struct dwc_bufmap *bmap; + struct dwc_hwdesc *desc; + struct ifnet *ifp; + + DWC_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + + while (sc->tx_idx_tail != sc->tx_idx_head) { + desc = &sc->txdesc_ring[sc->tx_idx_tail]; + if ((desc->tdes0 & DDESC_TDES0_OWN) != 0) + break; + bmap = &sc->txbuf_map[sc->tx_idx_tail]; + bus_dmamap_sync(sc->txbuf_tag, bmap->map, + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->txbuf_tag, bmap->map); + m_freem(bmap->mbuf); + bmap->mbuf = NULL; + dwc_setup_txdesc(sc, sc->tx_idx_tail, 0, 0); + sc->tx_idx_tail = next_txidx(sc, sc->tx_idx_tail); + } + + /* If there are no buffers outstanding, muzzle the watchdog. */ + if (sc->tx_idx_tail == sc->tx_idx_head) { + sc->tx_watchdog_count = 0; + } +} + +static void +dwc_rxfinish_locked(struct dwc_softc *sc) +{ + struct ifnet *ifp; + struct mbuf *m0; + struct mbuf *m; + int error; + int rdes0; + int idx; + int len; + + ifp = sc->ifp; + + for (;;) { + idx = sc->rx_idx; + + rdes0 = sc->rxdesc_ring[idx].tdes0; + if ((rdes0 & DDESC_RDES0_OWN) != 0) + break; + + bus_dmamap_sync(sc->rxbuf_tag, sc->rxbuf_map[idx].map, + BUS_DMASYNC_POSTREAD); + bus_dmamap_unload(sc->rxbuf_tag, sc->rxbuf_map[idx].map); + + len = (rdes0 >> DDESC_RDES0_FL_SHIFT) & DDESC_RDES0_FL_MASK; + if (len != 0) { + m = sc->rxbuf_map[idx].mbuf; + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = len; + m->m_len = len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + + DWC_UNLOCK(sc); + (*ifp->if_input)(ifp, m); + DWC_LOCK(sc); + } else { + /* XXX Zero-length packet ? */ + } + + if ((m0 = dwc_alloc_mbufcl(sc)) != NULL) { + if ((error = dwc_setup_rxbuf(sc, idx, m0)) != 0) { + /* + * XXX Now what? + * We've got a hole in the rx ring. + */ + } + } else + if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, 1); + + sc->rx_idx = next_rxidx(sc, sc->rx_idx); + } +} + +static void +dwc_intr(void *arg) +{ + struct dwc_softc *sc; + uint32_t reg; + + sc = arg; + + DWC_LOCK(sc); + + reg = READ4(sc, INTERRUPT_STATUS); + if (reg) { + mii_mediachg(sc->mii_softc); + READ4(sc, SGMII_RGMII_SMII_CTRL_STATUS); + } + + reg = READ4(sc, DMA_STATUS); + if (reg & DMA_STATUS_NIS) { + if (reg & DMA_STATUS_RI) + dwc_rxfinish_locked(sc); + + if (reg & DMA_STATUS_TI) + dwc_txfinish_locked(sc); + } + + if (reg & DMA_STATUS_AIS) { + if (reg & DMA_STATUS_FBI) { + /* Fatal bus error */ + device_printf(sc->dev, + "Ethernet DMA error, restarting controller.\n"); + dwc_stop_locked(sc); + dwc_init_locked(sc); + } + } + + WRITE4(sc, DMA_STATUS, reg & DMA_STATUS_INTR_MASK); + DWC_UNLOCK(sc); +} + +static int +setup_dma(struct dwc_softc *sc) +{ + struct mbuf *m; + int error; + int nidx; + int idx; + + /* + * Set up TX descriptor ring, descriptors, and dma maps. + */ + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + DWC_DESC_RING_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + TX_DESC_SIZE, 1, /* maxsize, nsegments */ + TX_DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->txdesc_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create TX ring DMA tag.\n"); + goto out; + } + + error = bus_dmamem_alloc(sc->txdesc_tag, (void**)&sc->txdesc_ring, + BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, + &sc->txdesc_map); + if (error != 0) { + device_printf(sc->dev, + "could not allocate TX descriptor ring.\n"); + goto out; + } + + error = bus_dmamap_load(sc->txdesc_tag, sc->txdesc_map, + sc->txdesc_ring, TX_DESC_SIZE, dwc_get1paddr, + &sc->txdesc_ring_paddr, 0); + if (error != 0) { + device_printf(sc->dev, + "could not load TX descriptor ring map.\n"); + goto out; + } + + for (idx = 0; idx < TX_DESC_COUNT; idx++) { + sc->txdesc_ring[idx].tdes0 = DDESC_TDES0_TXCHAIN; + sc->txdesc_ring[idx].tdes1 = 0; + nidx = next_txidx(sc, idx); + sc->txdesc_ring[idx].addr_next = sc->txdesc_ring_paddr + \ + (nidx * sizeof(struct dwc_hwdesc)); + } + + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MCLBYTES, 1, /* maxsize, nsegments */ + MCLBYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->txbuf_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create TX ring DMA tag.\n"); + goto out; + } + + for (idx = 0; idx < TX_DESC_COUNT; idx++) { + error = bus_dmamap_create(sc->txbuf_tag, BUS_DMA_COHERENT, + &sc->txbuf_map[idx].map); + if (error != 0) { + device_printf(sc->dev, + "could not create TX buffer DMA map.\n"); + goto out; + } + dwc_setup_txdesc(sc, idx, 0, 0); + } + + /* + * Set up RX descriptor ring, descriptors, dma maps, and mbufs. + */ + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + DWC_DESC_RING_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + RX_DESC_SIZE, 1, /* maxsize, nsegments */ + RX_DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->rxdesc_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create RX ring DMA tag.\n"); + goto out; + } + + error = bus_dmamem_alloc(sc->rxdesc_tag, (void **)&sc->rxdesc_ring, + BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, + &sc->rxdesc_map); + if (error != 0) { + device_printf(sc->dev, + "could not allocate RX descriptor ring.\n"); + goto out; + } + + error = bus_dmamap_load(sc->rxdesc_tag, sc->rxdesc_map, + sc->rxdesc_ring, RX_DESC_SIZE, dwc_get1paddr, + &sc->rxdesc_ring_paddr, 0); + if (error != 0) { + device_printf(sc->dev, + "could not load RX descriptor ring map.\n"); + goto out; + } + + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* Parent tag. */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MCLBYTES, 1, /* maxsize, nsegments */ + MCLBYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->rxbuf_tag); + if (error != 0) { + device_printf(sc->dev, + "could not create RX buf DMA tag.\n"); + goto out; + } + + for (idx = 0; idx < RX_DESC_COUNT; idx++) { + error = bus_dmamap_create(sc->rxbuf_tag, BUS_DMA_COHERENT, + &sc->rxbuf_map[idx].map); + if (error != 0) { + device_printf(sc->dev, + "could not create RX buffer DMA map.\n"); + goto out; + } + if ((m = dwc_alloc_mbufcl(sc)) == NULL) { + device_printf(sc->dev, "Could not alloc mbuf\n"); + error = ENOMEM; + goto out; + } + if ((error = dwc_setup_rxbuf(sc, idx, m)) != 0) { + device_printf(sc->dev, + "could not create new RX buffer.\n"); + goto out; + } + } + +out: + if (error != 0) + return (ENXIO); + + return (0); +} + +static int +dwc_get_hwaddr(struct dwc_softc *sc, uint8_t *hwaddr) +{ + int rnd; + int lo; + int hi; + + /* + * Try to recover a MAC address from the running hardware. If there's + * something non-zero there, assume the bootloader did the right thing + * and just use it. + * + * Otherwise, set the address to a convenient locally assigned address, + * 'bsd' + random 24 low-order bits. 'b' is 0x62, which has the locally + * assigned bit set, and the broadcast/multicast bit clear. + */ + lo = READ4(sc, MAC_ADDRESS_LOW(0)); + hi = READ4(sc, MAC_ADDRESS_HIGH(0)) & 0xffff; + if ((lo != 0xffffffff) || (hi != 0xffff)) { + hwaddr[0] = (lo >> 0) & 0xff; + hwaddr[1] = (lo >> 8) & 0xff; + hwaddr[2] = (lo >> 16) & 0xff; + hwaddr[3] = (lo >> 24) & 0xff; + hwaddr[4] = (hi >> 0) & 0xff; + hwaddr[5] = (hi >> 8) & 0xff; + } else { + rnd = arc4random() & 0x00ffffff; + hwaddr[0] = 'b'; + hwaddr[1] = 's'; + hwaddr[2] = 'd'; + hwaddr[3] = rnd >> 16; + hwaddr[4] = rnd >> 8; + hwaddr[5] = rnd >> 0; + } + + return (0); +} + +static int +dwc_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "snps,dwmac")) + return (ENXIO); + + device_set_desc(dev, "Gigabit Ethernet Controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +dwc_attach(device_t dev) +{ + uint8_t macaddr[ETHER_ADDR_LEN]; + struct dwc_softc *sc; + struct ifnet *ifp; + int error; + int reg; + int i; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->mii_clk = MII_CLK_VAL; + sc->rx_idx = 0; + + sc->txcount = TX_DESC_COUNT; + + if (bus_alloc_resources(dev, dwc_spec, sc->res)) { + device_printf(dev, "could not allocate resources\n"); + return (ENXIO); + } + + /* Memory interface */ + sc->bst = rman_get_bustag(sc->res[0]); + sc->bsh = rman_get_bushandle(sc->res[0]); + + mtx_init(&sc->mtx, device_get_nameunit(sc->dev), + MTX_NETWORK_LOCK, MTX_DEF); + + callout_init_mtx(&sc->dwc_callout, &sc->mtx, 0); + + /* Setup interrupt handler. */ + error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_NET | INTR_MPSAFE, + NULL, dwc_intr, sc, &sc->intr_cookie); + if (error != 0) { + device_printf(dev, "could not setup interrupt handler.\n"); + return (ENXIO); + } + + /* Read MAC before reset */ + if (dwc_get_hwaddr(sc, macaddr)) { + device_printf(sc->dev, "can't get mac\n"); + return (ENXIO); + } + + /* Reset */ + reg = READ4(sc, BUS_MODE); + reg |= (BUS_MODE_SWR); + WRITE4(sc, BUS_MODE, reg); + + for (i = 0; i < 100; i++) { + if ((READ4(sc, BUS_MODE) & BUS_MODE_SWR) == 0) + break; + DELAY(10); + } + if (i == 0) { + device_printf(sc->dev, "Can't reset DWC.\n"); + return (ENXIO); + } + + reg = READ4(sc, BUS_MODE); + reg |= (BUS_MODE_EIGHTXPBL); + reg |= (BUS_MODE_PBL_BEATS_8 << BUS_MODE_PBL_SHIFT); + WRITE4(sc, BUS_MODE, reg); + + /* + * DMA must be stop while changing descriptor list addresses. + */ + reg = READ4(sc, OPERATION_MODE); + reg &= ~(MODE_ST | MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); + + if (setup_dma(sc)) + return (ENXIO); + + /* Setup addresses */ + WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr); + WRITE4(sc, TX_DESCR_LIST_ADDR, sc->txdesc_ring_paddr); + + /* Set up the ethernet interface. */ + sc->ifp = ifp = if_alloc(IFT_ETHER); + + ifp->if_softc = sc; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_capabilities = IFCAP_VLAN_MTU; + ifp->if_capenable = ifp->if_capabilities; + ifp->if_start = dwc_txstart; + ifp->if_ioctl = dwc_ioctl; + ifp->if_init = dwc_init; + IFQ_SET_MAXLEN(&ifp->if_snd, TX_DESC_COUNT - 1); + ifp->if_snd.ifq_drv_maxlen = TX_DESC_COUNT - 1; + IFQ_SET_READY(&ifp->if_snd); + ifp->if_hdrlen = sizeof(struct ether_vlan_header); + + /* Attach the mii driver. */ + error = mii_attach(dev, &sc->miibus, ifp, dwc_media_change, + dwc_media_status, BMSR_DEFCAPMASK, MII_PHY_ANY, + MII_OFFSET_ANY, 0); + + if (error != 0) { + device_printf(dev, "PHY attach failed\n"); + return (ENXIO); + } + sc->mii_softc = device_get_softc(sc->miibus); + + /* All ready to run, attach the ethernet interface. */ + ether_ifattach(ifp, macaddr); + sc->is_attached = true; + + return (0); +} + +static int +dwc_miibus_read_reg(device_t dev, int phy, int reg) +{ + struct dwc_softc *sc; + uint16_t mii; + size_t cnt; + int rv = 0; + + sc = device_get_softc(dev); + + mii = ((phy & GMII_ADDRESS_PA_MASK) << GMII_ADDRESS_PA_SHIFT) + | ((reg & GMII_ADDRESS_GR_MASK) << GMII_ADDRESS_GR_SHIFT) + | (sc->mii_clk << GMII_ADDRESS_CR_SHIFT) + | GMII_ADDRESS_GB; /* Busy flag */ + + WRITE4(sc, GMII_ADDRESS, mii); + + for (cnt = 0; cnt < 1000; cnt++) { + if (!(READ4(sc, GMII_ADDRESS) & GMII_ADDRESS_GB)) { + rv = READ4(sc, GMII_DATA); + break; + } + DELAY(10); + } + + return rv; +} + +static int +dwc_miibus_write_reg(device_t dev, int phy, int reg, int val) +{ + struct dwc_softc *sc; + uint16_t mii; + size_t cnt; + + sc = device_get_softc(dev); + + mii = ((phy & GMII_ADDRESS_PA_MASK) << GMII_ADDRESS_PA_SHIFT) + | ((reg & GMII_ADDRESS_GR_MASK) << GMII_ADDRESS_GR_SHIFT) + | (sc->mii_clk << GMII_ADDRESS_CR_SHIFT) + | GMII_ADDRESS_GB | GMII_ADDRESS_GW; + + WRITE4(sc, GMII_DATA, val); + WRITE4(sc, GMII_ADDRESS, mii); + + for (cnt = 0; cnt < 1000; cnt++) { + if (!(READ4(sc, GMII_ADDRESS) & GMII_ADDRESS_GB)) { + break; + } + DELAY(10); + } + + return (0); +} + +static void +dwc_miibus_statchg(device_t dev) +{ + struct dwc_softc *sc; + struct mii_data *mii; + int reg; + + /* + * Called by the MII bus driver when the PHY establishes + * link to set the MAC interface registers. + */ + + sc = device_get_softc(dev); + + DWC_ASSERT_LOCKED(sc); + + mii = sc->mii_softc; + + if (mii->mii_media_status & IFM_ACTIVE) + sc->link_is_up = true; + else + sc->link_is_up = false; + + reg = READ4(sc, MAC_CONFIGURATION); + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_1000_T: + case IFM_1000_SX: + reg &= ~(CONF_FES | CONF_PS); + break; + case IFM_100_TX: + reg |= (CONF_FES | CONF_PS); + break; + case IFM_10_T: + reg &= ~(CONF_FES); + reg |= (CONF_PS); + break; + case IFM_NONE: + sc->link_is_up = false; + return; + default: + sc->link_is_up = false; + device_printf(dev, "Unsupported media %u\n", + IFM_SUBTYPE(mii->mii_media_active)); + return; + } + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) + reg |= (CONF_DM); + else + reg &= ~(CONF_DM); + WRITE4(sc, MAC_CONFIGURATION, reg); +} + +static device_method_t dwc_methods[] = { + DEVMETHOD(device_probe, dwc_probe), + DEVMETHOD(device_attach, dwc_attach), + + /* MII Interface */ + DEVMETHOD(miibus_readreg, dwc_miibus_read_reg), + DEVMETHOD(miibus_writereg, dwc_miibus_write_reg), + DEVMETHOD(miibus_statchg, dwc_miibus_statchg), + + { 0, 0 } +}; + +static driver_t dwc_driver = { + "dwc", + dwc_methods, + sizeof(struct dwc_softc), +}; + +static devclass_t dwc_devclass; + +DRIVER_MODULE(dwc, simplebus, dwc_driver, dwc_devclass, 0, 0); +DRIVER_MODULE(miibus, dwc, miibus_driver, miibus_devclass, 0, 0); + +MODULE_DEPEND(dwc, ether, 1, 1, 1); +MODULE_DEPEND(dwc, miibus, 1, 1, 1); diff --git a/sys/dev/dwc/if_dwc.h b/sys/dev/dwc/if_dwc.h new file mode 100644 index 000000000000..918ef0085edf --- /dev/null +++ b/sys/dev/dwc/if_dwc.h @@ -0,0 +1,262 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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$ + */ + +/* + * Register names were taken almost as is from the documentation. + */ + +#define MAC_CONFIGURATION 0x0 +#define CONF_JD (1 << 22) /* jabber timer disable */ +#define CONF_BE (1 << 21) /* Frame Burst Enable */ +#define CONF_PS (1 << 15) /* GMII/MII */ +#define CONF_FES (1 << 14) /* MII speed select */ +#define CONF_DM (1 << 11) /* Full Duplex Enable */ +#define CONF_ACS (1 << 7) +#define CONF_TE (1 << 3) +#define CONF_RE (1 << 2) +#define MAC_FRAME_FILTER 0x4 +#define FRAME_FILTER_RA (1 << 31) /* Receive All */ +#define FRAME_FILTER_HPF (1 << 10) /* Hash or Perfect Filter */ +#define FRAME_FILTER_PM (1 << 4) /* Pass multicast */ +#define FRAME_FILTER_HMC (1 << 2) +#define FRAME_FILTER_HUC (1 << 1) +#define FRAME_FILTER_PR (1 << 0) /* All Incoming Frames */ +#define GMII_ADDRESS 0x10 +#define GMII_ADDRESS_PA_MASK 0x1f /* Phy device */ +#define GMII_ADDRESS_PA_SHIFT 11 +#define GMII_ADDRESS_GR_MASK 0x1f /* Phy register */ +#define GMII_ADDRESS_GR_SHIFT 6 +#define GMII_ADDRESS_CR_MASK 0xf +#define GMII_ADDRESS_CR_SHIFT 2 /* Clock */ +#define GMII_ADDRESS_GW (1 << 1) /* Write operation */ +#define GMII_ADDRESS_GB (1 << 0) /* Busy */ +#define GMII_DATA 0x14 +#define FLOW_CONTROL 0x18 +#define GMAC_VLAN_TAG 0x1C +#define VERSION 0x20 +#define DEBUG 0x24 +#define LPI_CONTROL_STATUS 0x30 +#define LPI_TIMERS_CONTROL 0x34 +#define INTERRUPT_STATUS 0x38 +#define INTERRUPT_MASK 0x3C +#define MAC_ADDRESS_HIGH(n) ((n > 15 ? 0x800 : 0x40) + 0x8 * n) +#define MAC_ADDRESS_LOW(n) ((n > 15 ? 0x804 : 0x44) + 0x8 * n) + +#define SGMII_RGMII_SMII_CTRL_STATUS 0xD8 +#define MMC_CONTROL 0x100 +#define MMC_CONTROL_CNTRST (1 << 0) +#define MMC_RECEIVE_INTERRUPT 0x104 +#define MMC_TRANSMIT_INTERRUPT 0x108 +#define MMC_RECEIVE_INTERRUPT_MASK 0x10C +#define MMC_TRANSMIT_INTERRUPT_MASK 0x110 +#define TXOCTETCOUNT_GB 0x114 +#define TXFRAMECOUNT_GB 0x118 +#define TXBROADCASTFRAMES_G 0x11C +#define TXMULTICASTFRAMES_G 0x120 +#define TX64OCTETS_GB 0x124 +#define TX65TO127OCTETS_GB 0x128 +#define TX128TO255OCTETS_GB 0x12C +#define TX256TO511OCTETS_GB 0x130 +#define TX512TO1023OCTETS_GB 0x134 +#define TX1024TOMAXOCTETS_GB 0x138 +#define TXUNICASTFRAMES_GB 0x13C +#define TXMULTICASTFRAMES_GB 0x140 +#define TXBROADCASTFRAMES_GB 0x144 +#define TXUNDERFLOWERROR 0x148 +#define TXSINGLECOL_G 0x14C +#define TXMULTICOL_G 0x150 +#define TXDEFERRED 0x154 +#define TXLATECOL 0x158 +#define TXEXESSCOL 0x15C +#define TXCARRIERERR 0x160 +#define TXOCTETCNT 0x164 +#define TXFRAMECOUNT_G 0x168 +#define TXEXCESSDEF 0x16C +#define TXPAUSEFRAMES 0x170 +#define TXVLANFRAMES_G 0x174 +#define TXOVERSIZE_G 0x178 +#define RXFRAMECOUNT_GB 0x180 +#define RXOCTETCOUNT_GB 0x184 +#define RXOCTETCOUNT_G 0x188 +#define RXBROADCASTFRAMES_G 0x18C +#define RXMULTICASTFRAMES_G 0x190 +#define RXCRCERROR 0x194 +#define RXALIGNMENTERROR 0x198 +#define RXRUNTERROR 0x19C +#define RXJABBERERROR 0x1A0 +#define RXUNDERSIZE_G 0x1A4 +#define RXOVERSIZE_G 0x1A8 +#define RX64OCTETS_GB 0x1AC +#define RX65TO127OCTETS_GB 0x1B0 +#define RX128TO255OCTETS_GB 0x1B4 +#define RX256TO511OCTETS_GB 0x1B8 +#define RX512TO1023OCTETS_GB 0x1BC +#define RX1024TOMAXOCTETS_GB 0x1C0 +#define RXUNICASTFRAMES_G 0x1C4 +#define RXLENGTHERROR 0x1C8 +#define RXOUTOFRANGETYPE 0x1CC +#define RXPAUSEFRAMES 0x1D0 +#define RXFIFOOVERFLOW 0x1D4 +#define RXVLANFRAMES_GB 0x1D8 +#define RXWATCHDOGERROR 0x1DC +#define RXRCVERROR 0x1E0 +#define RXCTRLFRAMES_G 0x1E4 +#define MMC_IPC_RECEIVE_INT_MASK 0x200 +#define MMC_IPC_RECEIVE_INT 0x208 +#define RXIPV4_GD_FRMS 0x210 +#define RXIPV4_HDRERR_FRMS 0x214 +#define RXIPV4_NOPAY_FRMS 0x218 +#define RXIPV4_FRAG_FRMS 0x21C +#define RXIPV4_UDSBL_FRMS 0x220 +#define RXIPV6_GD_FRMS 0x224 +#define RXIPV6_HDRERR_FRMS 0x228 +#define RXIPV6_NOPAY_FRMS 0x22C +#define RXUDP_GD_FRMS 0x230 +#define RXUDP_ERR_FRMS 0x234 +#define RXTCP_GD_FRMS 0x238 +#define RXTCP_ERR_FRMS 0x23C +#define RXICMP_GD_FRMS 0x240 +#define RXICMP_ERR_FRMS 0x244 +#define RXIPV4_GD_OCTETS 0x250 +#define RXIPV4_HDRERR_OCTETS 0x254 +#define RXIPV4_NOPAY_OCTETS 0x258 +#define RXIPV4_FRAG_OCTETS 0x25C +#define RXIPV4_UDSBL_OCTETS 0x260 +#define RXIPV6_GD_OCTETS 0x264 +#define RXIPV6_HDRERR_OCTETS 0x268 +#define RXIPV6_NOPAY_OCTETS 0x26C +#define RXUDP_GD_OCTETS 0x270 +#define RXUDP_ERR_OCTETS 0x274 +#define RXTCP_GD_OCTETS 0x278 +#define RXTCPERROCTETS 0x27C +#define RXICMP_GD_OCTETS 0x280 +#define RXICMP_ERR_OCTETS 0x284 +#define L3_L4_CONTROL0 0x400 +#define LAYER4_ADDRESS0 0x404 +#define LAYER3_ADDR0_REG0 0x410 +#define LAYER3_ADDR1_REG0 0x414 +#define LAYER3_ADDR2_REG0 0x418 +#define LAYER3_ADDR3_REG0 0x41C +#define L3_L4_CONTROL1 0x430 +#define LAYER4_ADDRESS1 0x434 +#define LAYER3_ADDR0_REG1 0x440 +#define LAYER3_ADDR1_REG1 0x444 +#define LAYER3_ADDR2_REG1 0x448 +#define LAYER3_ADDR3_REG1 0x44C +#define L3_L4_CONTROL2 0x460 +#define LAYER4_ADDRESS2 0x464 +#define LAYER3_ADDR0_REG2 0x470 +#define LAYER3_ADDR1_REG2 0x474 +#define LAYER3_ADDR2_REG2 0x478 +#define LAYER3_ADDR3_REG2 0x47C +#define L3_L4_CONTROL3 0x490 +#define LAYER4_ADDRESS3 0x494 +#define LAYER3_ADDR0_REG3 0x4A0 +#define LAYER3_ADDR1_REG3 0x4A4 +#define LAYER3_ADDR2_REG3 0x4A8 +#define LAYER3_ADDR3_REG3 0x4AC +#define HASH_TABLE_REG(n) 0x500 + (0x4 * n) +#define VLAN_INCL_REG 0x584 +#define VLAN_HASH_TABLE_REG 0x588 +#define TIMESTAMP_CONTROL 0x700 +#define SUB_SECOND_INCREMENT 0x704 +#define SYSTEM_TIME_SECONDS 0x708 +#define SYSTEM_TIME_NANOSECONDS 0x70C +#define SYSTEM_TIME_SECONDS_UPDATE 0x710 +#define SYSTEM_TIME_NANOSECONDS_UPDATE 0x714 +#define TIMESTAMP_ADDEND 0x718 +#define TARGET_TIME_SECONDS 0x71C +#define TARGET_TIME_NANOSECONDS 0x720 +#define SYSTEM_TIME_HIGHER_WORD_SECONDS 0x724 +#define TIMESTAMP_STATUS 0x728 +#define PPS_CONTROL 0x72C +#define AUXILIARY_TIMESTAMP_NANOSECONDS 0x730 +#define AUXILIARY_TIMESTAMP_SECONDS 0x734 +#define PPS0_INTERVAL 0x760 +#define PPS0_WIDTH 0x764 + +/* DMA */ +#define BUS_MODE 0x1000 +#define BUS_MODE_EIGHTXPBL (1 << 24) /* Multiplies PBL by 8 */ +#define BUS_MODE_PBL_SHIFT 8 /* Single block transfer size */ +#define BUS_MODE_PBL_BEATS_8 8 +#define BUS_MODE_SWR (1 << 0) /* Reset */ +#define TRANSMIT_POLL_DEMAND 0x1004 +#define RECEIVE_POLL_DEMAND 0x1008 +#define RX_DESCR_LIST_ADDR 0x100C +#define TX_DESCR_LIST_ADDR 0x1010 +#define DMA_STATUS 0x1014 +#define DMA_STATUS_NIS (1 << 16) +#define DMA_STATUS_AIS (1 << 15) +#define DMA_STATUS_FBI (1 << 13) +#define DMA_STATUS_RI (1 << 6) +#define DMA_STATUS_TI (1 << 0) +#define DMA_STATUS_INTR_MASK 0x1ffff +#define OPERATION_MODE 0x1018 +#define MODE_RSF (1 << 25) /* RX Full Frame */ +#define MODE_TSF (1 << 21) /* TX Full Frame */ +#define MODE_FTF (1 << 20) /* Flush TX FIFO */ +#define MODE_ST (1 << 13) /* Start DMA TX */ +#define MODE_FUF (1 << 6) /* TX frames < 64bytes */ +#define MODE_RTC_LEV32 0x1 +#define MODE_RTC_SHIFT 3 +#define MODE_OSF (1 << 2) /* Process Second frame */ +#define MODE_SR (1 << 1) /* Start DMA RX */ +#define INTERRUPT_ENABLE 0x101C +#define INT_EN_NIE (1 << 16) /* Normal/Summary */ +#define INT_EN_AIE (1 << 15) /* Abnormal/Summary */ +#define INT_EN_ERE (1 << 14) /* Early receive */ +#define INT_EN_FBE (1 << 13) /* Fatal bus error */ +#define INT_EN_ETE (1 << 10) /* Early transmit */ +#define INT_EN_RWE (1 << 9) /* Receive watchdog */ +#define INT_EN_RSE (1 << 8) /* Receive stopped */ +#define INT_EN_RUE (1 << 7) /* Recv buf unavailable */ +#define INT_EN_RIE (1 << 6) /* Receive interrupt */ +#define INT_EN_UNE (1 << 5) /* Tx underflow */ +#define INT_EN_OVE (1 << 4) /* Receive overflow */ +#define INT_EN_TJE (1 << 3) /* Transmit jabber */ +#define INT_EN_TUE (1 << 2) /* Tx. buf unavailable */ +#define INT_EN_TSE (1 << 1) /* Transmit stopped */ +#define INT_EN_TIE (1 << 0) /* Transmit interrupt */ +#define INT_EN_DEFAULT (INT_EN_TIE|INT_EN_RIE| \ + INT_EN_NIE|INT_EN_AIE| \ + INT_EN_FBE|INT_EN_UNE) + +#define MISSED_FRAMEBUF_OVERFLOW_CNTR 0x1020 +#define RECEIVE_INT_WATCHDOG_TMR 0x1024 +#define AXI_BUS_MODE 0x1028 +#define AHB_OR_AXI_STATUS 0x102C +#define CURRENT_HOST_TRANSMIT_DESCR 0x1048 +#define CURRENT_HOST_RECEIVE_DESCR 0x104C +#define CURRENT_HOST_TRANSMIT_BUF_ADDR 0x1050 +#define CURRENT_HOST_RECEIVE_BUF_ADDR 0x1054 +#define HW_FEATURE 0x1058 diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 99ecbf359aa0..070bb5b2f3ea 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -215,6 +215,7 @@ static void em_start(if_t); static void em_start_locked(if_t, struct tx_ring *); #endif static int em_ioctl(if_t, u_long, caddr_t); +static uint64_t em_get_counter(if_t, ift_counter); static void em_init(void *); static void em_init_locked(struct adapter *); static void em_stop(void *); @@ -306,7 +307,7 @@ static int em_sysctl_eee(SYSCTL_HANDLER_ARGS); static __inline void em_rx_discard(struct rx_ring *, int); #ifdef DEVICE_POLLING -static poll_handler_drv_t em_poll; +static poll_handler_t em_poll; #endif /* POLLING */ /********************************************************************* @@ -786,7 +787,7 @@ em_detach(device_t dev) #ifdef DEVICE_POLLING if (if_getcapenable(ifp) & IFCAP_POLLING) - ether_poll_deregister_drv(ifp); + ether_poll_deregister(ifp); #endif if (adapter->led_dev != NULL) @@ -934,9 +935,9 @@ em_mq_start_locked(if_t ifp, struct tx_ring *txr, struct mbuf *m) } drbr_advance(ifp, txr->br); enq++; - if_incobytes(ifp, next->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len); if (next->m_flags & M_MCAST) - if_incomcasts(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); if_etherbpfmtap(ifp, next); if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) break; @@ -1207,7 +1208,7 @@ em_ioctl(if_t ifp, u_long command, caddr_t data) #ifdef DEVICE_POLLING if (mask & IFCAP_POLLING) { if (ifr->ifr_reqcap & IFCAP_POLLING) { - error = ether_poll_register_drv(em_poll, ifp); + error = ether_poll_register(em_poll, ifp); if (error) return (error); EM_CORE_LOCK(adapter); @@ -1215,7 +1216,7 @@ em_ioctl(if_t ifp, u_long command, caddr_t data) if_setcapenablebit(ifp, IFCAP_POLLING, 0); EM_CORE_UNLOCK(adapter); } else { - error = ether_poll_deregister_drv(ifp); + error = ether_poll_deregister(ifp); /* Enable interrupt even in error case */ EM_CORE_LOCK(adapter); em_enable_intr(adapter); @@ -2940,6 +2941,7 @@ em_setup_interface(device_t dev, struct adapter *adapter) if_setsoftc(ifp, adapter); if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); if_setioctlfn(ifp, em_ioctl); + if_setgetcounterfn(ifp, em_get_counter); #ifdef EM_MULTIQUEUE /* Multiqueue stack interface */ if_settransmitfn(ifp, em_mq_start); @@ -3850,7 +3852,7 @@ em_txeof(struct tx_ring *txr) tx_buffer = &txr->tx_buffers[first]; tx_desc = &txr->tx_base[first]; } - if_incopackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* See if we can continue to the next packet */ last = tx_buffer->next_eop; if (last != -1) { @@ -4450,7 +4452,7 @@ em_rxeof(struct rx_ring *rxr, int count, int *done) --count; sendmp = rxr->fmp; if_setrcvif(sendmp, ifp); - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); em_receive_checksum(cur, sendmp); #ifndef __NO_STRICT_ALIGNMENT if (adapter->hw.mac.max_frame_size > @@ -5107,7 +5109,6 @@ em_disable_aspm(struct adapter *adapter) static void em_update_stats_counters(struct adapter *adapter) { - if_t ifp; if(adapter->hw.phy.media_type == e1000_media_type_copper || (E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) { @@ -5199,19 +5200,29 @@ em_update_stats_counters(struct adapter *adapter) adapter->stats.tsctfc += E1000_READ_REG(&adapter->hw, E1000_TSCTFC); } - ifp = adapter->ifp; +} - if_setcollisions(ifp, adapter->stats.colc); +static uint64_t +em_get_counter(if_t ifp, ift_counter cnt) +{ + struct adapter *adapter; - /* Rx Errors */ - if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc + - adapter->stats.crcerrs + adapter->stats.algnerrc + - adapter->stats.ruc + adapter->stats.roc + - adapter->stats.mpc + adapter->stats.cexterr); + adapter = if_getsoftc(ifp); - /* Tx Errors */ - if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol + - adapter->watchdog_events); + switch (cnt) { + case IFCOUNTER_COLLISIONS: + return (adapter->stats.colc); + case IFCOUNTER_IERRORS: + return (adapter->dropped_pkts + adapter->stats.rxerrc + + adapter->stats.crcerrs + adapter->stats.algnerrc + + adapter->stats.ruc + adapter->stats.roc + + adapter->stats.mpc + adapter->stats.cexterr); + case IFCOUNTER_OERRORS: + return (adapter->stats.ecol + adapter->stats.latecol + + adapter->watchdog_events); + default: + return (if_get_counter_default(ifp, cnt)); + } } /* Export a single 32-bit register via a read-only sysctl. */ diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 5f0557833a3f..c8cb5d4ea8e2 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -204,6 +204,7 @@ static void igb_start(struct ifnet *); static void igb_start_locked(struct tx_ring *, struct ifnet *ifp); #endif static int igb_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t igb_get_counter(if_t, ift_counter); static void igb_init(void *); static void igb_init_locked(struct adapter *); static void igb_stop(void *); @@ -1045,9 +1046,9 @@ igb_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr) } drbr_advance(ifp, txr->br); enq++; - ifp->if_obytes += next->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len); if (next->m_flags & M_MCAST) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); ETHER_BPF_MTAP(ifp, next); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) break; @@ -3211,6 +3212,7 @@ igb_setup_interface(device_t dev, struct adapter *adapter) ifp->if_softc = adapter; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = igb_ioctl; + ifp->if_get_counter = igb_get_counter; #ifndef IGB_LEGACY_TX ifp->if_transmit = igb_mq_start; ifp->if_qflush = igb_qflush; @@ -4127,7 +4129,7 @@ igb_txeof(struct tx_ring *txr) } ++txr->packets; ++processed; - ++ifp->if_opackets; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); txr->watchdog_time = ticks; /* Try the next packet */ @@ -4495,7 +4497,6 @@ igb_setup_receive_ring(struct rx_ring *rxr) rxr->fmp = NULL; rxr->lmp = NULL; - rxr->discard = FALSE; bus_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); @@ -4712,6 +4713,18 @@ igb_initialize_receive_units(struct adapter *adapter) rctl |= E1000_RCTL_SZ_2048; } + /* + * If TX flow control is disabled and there's >1 queue defined, + * enable DROP. + * + * This drops frames rather than hanging the RX MAC for all queues. + */ + if ((adapter->num_queues > 1) && + (adapter->fc == e1000_fc_none || + adapter->fc == e1000_fc_rx_pause)) { + srrctl |= E1000_SRRCTL_DROP_EN; + } + /* Setup the Base and Length of the Rx Descriptor Rings */ for (int i = 0; i < adapter->num_queues; i++, rxr++) { u64 bus_addr = rxr->rxdma.dma_paddr; @@ -5027,15 +5040,16 @@ igb_rxeof(struct igb_queue *que, int count, int *done) pkt_info = le16toh(cur->wb.lower.lo_dword.hs_rss.pkt_info); eop = ((staterr & E1000_RXD_STAT_EOP) == E1000_RXD_STAT_EOP); - /* Make sure all segments of a bad packet are discarded */ - if (((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) != 0) || - (rxr->discard)) { + /* + * Free the frame (all segments) if we're at EOP and + * it's an error. + * + * The datasheet states that EOP + status is only valid for + * the final segment in a multi-segment frame. + */ + if (eop && ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) != 0)) { adapter->dropped_pkts++; ++rxr->rx_discarded; - if (!eop) /* Catch subsequent segs */ - rxr->discard = TRUE; - else - rxr->discard = FALSE; igb_rx_discard(rxr, i); goto next_desc; } @@ -5109,7 +5123,7 @@ igb_rxeof(struct igb_queue *que, int count, int *done) if (eop) { rxr->fmp->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); rxr->rx_packets++; /* capture data for AIM */ rxr->packets++; @@ -5536,6 +5550,30 @@ igb_led_func(void *arg, int onoff) IGB_CORE_UNLOCK(adapter); } +static uint64_t +igb_get_counter(if_t ifp, ift_counter cnt) +{ + struct adapter *adapter; + struct e1000_hw_stats *stats; + + adapter = if_getsoftc(ifp); + stats = (struct e1000_hw_stats *)adapter->stats; + + switch (cnt) { + case IFCOUNTER_IERRORS: + return (adapter->dropped_pkts + stats->rxerrc + + stats->crcerrs + stats->algnerrc + + stats->ruc + stats->roc + stats->mpc + stats->cexterr); + case IFCOUNTER_OERRORS: + return (stats->ecol + stats->latecol + + adapter->watchdog_events); + case IFCOUNTER_COLLISIONS: + return (stats->colc); + default: + return (if_get_counter_default(ifp, cnt)); + } +} + /********************************************************************** * * Update the board statistics counters. @@ -5544,7 +5582,6 @@ igb_led_func(void *arg, int onoff) static void igb_update_stats_counters(struct adapter *adapter) { - struct ifnet *ifp; struct e1000_hw *hw = &adapter->hw; struct e1000_hw_stats *stats; @@ -5662,18 +5699,6 @@ igb_update_stats_counters(struct adapter *adapter) stats->tsctc += E1000_READ_REG(hw, E1000_TSCTC); stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC); - ifp = adapter->ifp; - ifp->if_collisions = stats->colc; - - /* Rx Errors */ - ifp->if_ierrors = adapter->dropped_pkts + stats->rxerrc + - stats->crcerrs + stats->algnerrc + - stats->ruc + stats->roc + stats->mpc + stats->cexterr; - - /* Tx Errors */ - ifp->if_oerrors = stats->ecol + - stats->latecol + adapter->watchdog_events; - /* Driver specific counters */ adapter->device_control = E1000_READ_REG(hw, E1000_CTRL); adapter->rx_control = E1000_READ_REG(hw, E1000_RCTL); @@ -6255,6 +6280,7 @@ igb_set_flowcntl(SYSCTL_HANDLER_ARGS) adapter->hw.fc.current_mode = adapter->hw.fc.requested_mode; e1000_force_mac_fc(&adapter->hw); + /* XXX TODO: update DROP_EN on each RX queue if appropriate */ return (error); } diff --git a/sys/dev/e1000/if_igb.h b/sys/dev/e1000/if_igb.h index 0c4474126f70..f2d0926cab30 100644 --- a/sys/dev/e1000/if_igb.h +++ b/sys/dev/e1000/if_igb.h @@ -336,7 +336,6 @@ struct rx_ring { struct lro_ctrl lro; bool lro_enabled; bool hdr_split; - bool discard; struct mtx rx_mtx; char mtx_name[16]; u32 next_to_refresh; diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c index 8424870c7570..d29c7f1e8d66 100644 --- a/sys/dev/e1000/if_lem.c +++ b/sys/dev/e1000/if_lem.c @@ -180,6 +180,7 @@ static int lem_resume(device_t); static void lem_start(if_t); static void lem_start_locked(if_t ifp); static int lem_ioctl(if_t, u_long, caddr_t); +static uint64_t lem_get_counter(if_t, ift_counter); static void lem_init(void *); static void lem_init_locked(struct adapter *); static void lem_stop(void *); @@ -259,7 +260,7 @@ static void lem_add_rx_process_limit(struct adapter *, const char *, const char *, int *, int); #ifdef DEVICE_POLLING -static poll_handler_drv_t lem_poll; +static poll_handler_t lem_poll; #endif /* POLLING */ /********************************************************************* @@ -788,7 +789,7 @@ lem_detach(device_t dev) #ifdef DEVICE_POLLING if (if_getcapenable(ifp) & IFCAP_POLLING) - ether_poll_deregister_drv(ifp); + ether_poll_deregister(ifp); #endif if (adapter->led_dev != NULL) @@ -1118,7 +1119,7 @@ lem_ioctl(if_t ifp, u_long command, caddr_t data) #ifdef DEVICE_POLLING if (mask & IFCAP_POLLING) { if (ifr->ifr_reqcap & IFCAP_POLLING) { - error = ether_poll_register_drv(lem_poll, ifp); + error = ether_poll_register(lem_poll, ifp); if (error) return (error); EM_CORE_LOCK(adapter); @@ -1126,7 +1127,7 @@ lem_ioctl(if_t ifp, u_long command, caddr_t data) if_setcapenablebit(ifp, IFCAP_POLLING, 0); EM_CORE_UNLOCK(adapter); } else { - error = ether_poll_deregister_drv(ifp); + error = ether_poll_deregister(ifp); /* Enable interrupt even in error case */ EM_CORE_LOCK(adapter); lem_enable_intr(adapter); @@ -2464,6 +2465,7 @@ lem_setup_interface(device_t dev, struct adapter *adapter) if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); if_setioctlfn(ifp, lem_ioctl); if_setstartfn(ifp, lem_start); + if_setgetcounterfn(ifp, lem_get_counter); if_setsendqlen(ifp, adapter->num_tx_desc - 1); if_setsendqready(ifp); @@ -3122,7 +3124,7 @@ lem_txeof(struct adapter *adapter) ++num_avail; if (tx_buffer->m_head) { - if_incopackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); bus_dmamap_sync(adapter->txtag, tx_buffer->map, BUS_DMASYNC_POSTWRITE); @@ -3681,7 +3683,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done) if (accept_frame) { if (lem_get_buf(adapter, i) != 0) { - if_inciqdrops(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); goto discard; } @@ -3712,7 +3714,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done) if (eop) { if_setrcvif(adapter->fmp, ifp); - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); lem_receive_checksum(adapter, current_desc, adapter->fmp); #ifndef __NO_STRICT_ALIGNMENT @@ -4397,7 +4399,6 @@ lem_fill_descriptors (bus_addr_t address, u32 length, static void lem_update_stats_counters(struct adapter *adapter) { - if_t ifp; if(adapter->hw.phy.media_type == e1000_media_type_copper || (E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) { @@ -4472,19 +4473,29 @@ lem_update_stats_counters(struct adapter *adapter) adapter->stats.tsctfc += E1000_READ_REG(&adapter->hw, E1000_TSCTFC); } - ifp = adapter->ifp; +} - if_setcollisions(ifp, adapter->stats.colc); +static uint64_t +lem_get_counter(if_t ifp, ift_counter cnt) +{ + struct adapter *adapter; - /* Rx Errors */ - if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc + - adapter->stats.crcerrs + adapter->stats.algnerrc + - adapter->stats.ruc + adapter->stats.roc + - adapter->stats.mpc + adapter->stats.cexterr); + adapter = if_getsoftc(ifp); - /* Tx Errors */ - if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol + - adapter->watchdog_events); + switch (cnt) { + case IFCOUNTER_COLLISIONS: + return (adapter->stats.colc); + case IFCOUNTER_IERRORS: + return (adapter->dropped_pkts + adapter->stats.rxerrc + + adapter->stats.crcerrs + adapter->stats.algnerrc + + adapter->stats.ruc + adapter->stats.roc + + adapter->stats.mpc + adapter->stats.cexterr); + case IFCOUNTER_OERRORS: + return (adapter->stats.ecol + adapter->stats.latecol + + adapter->watchdog_events); + default: + return (if_get_counter_default(ifp, cnt)); + } } /* Export a single 32-bit register via a read-only sysctl. */ diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index eec895488843..46524dd9d6b8 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -485,7 +485,7 @@ ed_watchdog(struct ed_softc *sc) ifp = sc->ifp; log(LOG_ERR, "%s: device timeout\n", ifp->if_xname); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ed_reset(ifp); } @@ -900,7 +900,7 @@ ed_rint(struct ed_softc *sc) */ ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring), len - sizeof(struct ed_ring)); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } else { /* * Really BAD. The ring pointers are corrupted. @@ -908,7 +908,7 @@ ed_rint(struct ed_softc *sc) log(LOG_ERR, "%s: NIC memory corrupt - invalid packet length %d\n", ifp->if_xname, len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ed_reset(ifp); return; } @@ -1055,14 +1055,14 @@ edintr(void *arg) /* * update output errors counter */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else { /* * Update total number of successfully * transmitted packets. */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } /* @@ -1080,7 +1080,7 @@ edintr(void *arg) * Add in total number of collisions on last * transmission. */ - ifp->if_collisions += collisions; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, collisions); switch(collisions) { case 0: case 16: @@ -1123,7 +1123,7 @@ edintr(void *arg) * fixed in later revs. -DG */ if (isr & ED_ISR_OVW) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); #ifdef DIAGNOSTIC log(LOG_WARNING, "%s: warning - receiver ring buffer overrun\n", @@ -1150,7 +1150,7 @@ edintr(void *arg) sc->mibdata.dot3StatsAlignmentErrors++; if (rsr & ED_RSR_FO) sc->mibdata.dot3StatsInternalMacReceiveErrors++; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); #ifdef ED_DEBUG if_printf(ifp, "receive error %x\n", ed_nic_inb(sc, ED_P0_RSR)); diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c index a2aed43e0a1f..3175d61477dd 100644 --- a/sys/dev/en/midway.c +++ b/sys/dev/en/midway.c @@ -774,7 +774,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot) } EN_COUNT(sc->stats.launch); - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); sc->vccs[tx.vci]->opackets++; sc->vccs[tx.vci]->obytes += tx.datalen; @@ -1851,7 +1851,7 @@ en_rx_drain(struct en_softc *sc, u_int drq) EN_DQ_LEN(drq), vc->rxhand)); m->m_pkthdr.rcvif = sc->ifp; - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); vc->ipackets++; vc->ibytes += m->m_pkthdr.len; @@ -2249,13 +2249,13 @@ en_service(struct en_softc *sc) device_printf(sc->dev, "invalid AAL5 length\n"); rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ; mlen = 0; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } else if (rbd & MID_RBD_CRCERR) { device_printf(sc->dev, "CRC error\n"); rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ; mlen = 0; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } else { mlen = MID_PDU_LEN(pdu); diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index 74c6a865b0ab..cd7afb530a46 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -512,7 +512,7 @@ epstart_locked(struct ifnet *ifp) */ if (len + pad > ETHER_MAX_LEN) { /* packet is obviously too large: toss it */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m0); goto readcheck; } @@ -564,7 +564,7 @@ epstart_locked(struct ifnet *ifp) BPF_MTAP(ifp, m0); sc->tx_timer = 2; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(m0); /* @@ -640,7 +640,8 @@ ep_intr_locked(struct ep_softc *sc) CSR_READ_2(sc, EP_W4_FIFO_DIAG)); printf("\tStat: %x\n", sc->stat); printf("\tIpackets=%d, Opackets=%d\n", - ifp->if_ipackets, ifp->if_opackets); + ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS), + ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS)); printf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n", sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf, sc->rx_overrunl, sc->tx_underrun); @@ -650,7 +651,7 @@ ep_intr_locked(struct ep_softc *sc) device_printf(sc->dev, "Status: %x (input buffer overflow)\n", status); #else - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); #endif #endif @@ -683,9 +684,9 @@ ep_intr_locked(struct ep_softc *sc) * TXS_MAX_COLLISION we * shouldn't get here */ - ++ifp->if_collisions; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); CSR_WRITE_2(sc, EP_COMMAND, TX_ENABLE); /* * To have a tx_avail_int but giving @@ -731,7 +732,7 @@ epread(struct ep_softc *sc) read_again: if (status & ERR_RX) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (status & ERR_RX_OVERRUN) { /* * We can think the rx latency is actually @@ -829,7 +830,7 @@ epread(struct ep_softc *sc) return; } CSR_WRITE_2(sc, EP_COMMAND, RX_DISCARD_TOP_PACK); - ++ifp->if_ipackets; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); EP_FSET(sc, F_RX_FIRST); top->m_pkthdr.rcvif = sc->ifp; top->m_pkthdr.len = sc->cur_len; diff --git a/sys/dev/et/if_et.c b/sys/dev/et/if_et.c index cd714b08ea77..97fbdcf19495 100644 --- a/sys/dev/et/if_et.c +++ b/sys/dev/et/if_et.c @@ -104,6 +104,7 @@ static int et_watchdog(struct et_softc *); static int et_ifmedia_upd_locked(struct ifnet *); static int et_ifmedia_upd(struct ifnet *); static void et_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static uint64_t et_get_counter(struct ifnet *, ift_counter); static void et_add_sysctls(struct et_softc *); static int et_sysctl_rx_intr_npkts(SYSCTL_HANDLER_ARGS); @@ -324,6 +325,7 @@ et_attach(device_t dev) ifp->if_init = et_init; ifp->if_ioctl = et_ioctl; ifp->if_start = et_start; + ifp->if_get_counter = et_get_counter; ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_VLAN_MTU; ifp->if_capenable = ifp->if_capabilities; ifp->if_snd.ifq_drv_maxlen = ET_TX_NDESC - 1; @@ -1413,7 +1415,7 @@ et_start_locked(struct ifnet *ifp) if (et_encap(sc, &m_head)) { if (m_head == NULL) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } IFQ_DRV_PREPEND(&ifp->if_snd, m_head); @@ -1465,7 +1467,7 @@ et_watchdog(struct et_softc *sc) if_printf(sc->ifp, "watchdog timed out (0x%08x) -- resetting\n", status); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; et_init_locked(sc); return (EJUSTRETURN); @@ -2093,12 +2095,12 @@ et_rxeof(struct et_softc *sc) CSR_WRITE_4(sc, ET_RXSTAT_POS, rxstat_pos); if (ring_idx >= ET_RX_NRING) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if_printf(ifp, "invalid ring index %d\n", ring_idx); continue; } if (buf_idx >= ET_RX_NDESC) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if_printf(ifp, "invalid buf index %d\n", buf_idx); continue; } @@ -2110,13 +2112,13 @@ et_rxeof(struct et_softc *sc) rbd->rbd_discard(rbd, buf_idx); } else if (rbd->rbd_newbuf(rbd, buf_idx) != 0) { /* No available mbufs, discard it. */ - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); rbd->rbd_discard(rbd, buf_idx); } else { buflen -= ETHER_CRC_LEN; if (buflen < ETHER_HDR_LEN) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } else { m->m_pkthdr.len = m->m_len = buflen; m->m_pkthdr.rcvif = ifp; @@ -2625,7 +2627,6 @@ et_sysctl_rx_intr_delay(SYSCTL_HANDLER_ARGS) static void et_stats_update(struct et_softc *sc) { - struct ifnet *ifp; struct et_hw_stats *stats; stats = &sc->sc_stats; @@ -2675,18 +2676,35 @@ et_stats_update(struct et_softc *sc) stats->tx_oversize += CSR_READ_4(sc, ET_STAT_TX_OVERSIZE); stats->tx_undersize += CSR_READ_4(sc, ET_STAT_TX_UNDERSIZE); stats->tx_fragments += CSR_READ_4(sc, ET_STAT_TX_FRAG); +} - /* Update ifnet counters. */ - ifp = sc->ifp; - ifp->if_opackets = (u_long)stats->tx_frames; - ifp->if_collisions = stats->tx_total_colls; - ifp->if_oerrors = stats->tx_drop + stats->tx_jabbers + - stats->tx_crcerrs + stats->tx_excess_deferred + - stats->tx_late_colls; - ifp->if_ipackets = (u_long)stats->rx_frames; - ifp->if_ierrors = stats->rx_crcerrs + stats->rx_alignerrs + - stats->rx_lenerrs + stats->rx_codeerrs + stats->rx_cserrs + - stats->rx_runts + stats->rx_jabbers + stats->rx_drop; +static uint64_t +et_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct et_softc *sc; + struct et_hw_stats *stats; + + sc = if_getsoftc(ifp); + stats = &sc->sc_stats; + + switch (cnt) { + case IFCOUNTER_OPACKETS: + return (stats->tx_frames); + case IFCOUNTER_COLLISIONS: + return (stats->tx_total_colls); + case IFCOUNTER_OERRORS: + return (stats->tx_drop + stats->tx_jabbers + + stats->tx_crcerrs + stats->tx_excess_deferred + + stats->tx_late_colls); + case IFCOUNTER_IPACKETS: + return (stats->rx_frames); + case IFCOUNTER_IERRORS: + return (stats->rx_crcerrs + stats->rx_alignerrs + + stats->rx_lenerrs + stats->rx_codeerrs + stats->rx_cserrs + + stats->rx_runts + stats->rx_jabbers + stats->rx_drop); + default: + return (if_get_counter_default(ifp, cnt)); + } } static int diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c index e85ee5f580c0..40723512cc0c 100644 --- a/sys/dev/ex/if_ex.c +++ b/sys/dev/ex/if_ex.c @@ -571,7 +571,7 @@ ex_start_locked(struct ifnet *ifp) BPF_MTAP(ifp, opkt); sc->tx_timeout = 2; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(opkt); } else { ifp->if_drv_flags |= IFF_DRV_OACTIVE; @@ -684,12 +684,12 @@ ex_tx_intr(struct ex_softc *sc) sc->tx_head = CSR_READ_2(sc, IO_PORT_REG); if (tx_status & TX_OK_bit) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } else { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } - ifp->if_collisions += tx_status & No_Collisions_bits; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, tx_status & No_Collisions_bits); } /* @@ -737,7 +737,7 @@ ex_rx_intr(struct ex_softc *sc) MGETHDR(m, M_NOWAIT, MT_DATA); ipkt = m; if (ipkt == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); } else { ipkt->m_pkthdr.rcvif = ifp; ipkt->m_pkthdr.len = pkt_len; @@ -750,7 +750,7 @@ ex_rx_intr(struct ex_softc *sc) m->m_len = MCLBYTES; } else { m_freem(ipkt); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); goto rx_another; } } @@ -773,7 +773,7 @@ ex_rx_intr(struct ex_softc *sc) MGET(m->m_next, M_NOWAIT, MT_DATA); if (m->m_next == NULL) { m_freem(ipkt); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); goto rx_another; } m = m->m_next; @@ -792,10 +792,10 @@ ex_rx_intr(struct ex_softc *sc) EX_UNLOCK(sc); (*ifp->if_input)(ifp, ipkt); EX_LOCK(sc); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } } else { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } CSR_WRITE_2(sc, HOST_ADDR_REG, sc->rx_head); rx_another: ; @@ -983,7 +983,7 @@ ex_watchdog(void *arg) DODEBUG(Status, printf("OIDLE watchdog\n");); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ex_reset(sc); ex_start_locked(ifp); diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c index b6b4e13db2a3..b3281fe1a47f 100644 --- a/sys/dev/fatm/if_fatm.c +++ b/sys/dev/fatm/if_fatm.c @@ -1564,7 +1564,7 @@ fatm_intr_drain_rx(struct fatm_softc *sc) ATM_PH_SETVCI(&aph, vci); ifp = sc->ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); vc->ipackets++; vc->ibytes += m0->m_pkthdr.len; @@ -1974,7 +1974,7 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen) error = bus_dmamap_load_mbuf(sc->tx_tag, q->map, m, fatm_tpd_load, tpd, BUS_DMA_NOWAIT); if(error) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); if_printf(sc->ifp, "mbuf loaded error=%d\n", error); m_freem(m); return (0); @@ -2025,7 +2025,7 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen) BARRIER_W(sc); sc->txcnt++; - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); vc->obytes += m->m_pkthdr.len; vc->opackets++; diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 9fe1e7ef8bd4..5c5ffbec2a34 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -82,9 +82,13 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef PC98 +#include +#else #include -#include #include +#endif +#include #include @@ -136,33 +140,56 @@ __FBSDID("$FreeBSD$"); */ static struct fd_type fd_searchlist_360k[] = { +#ifndef PC98 { FDF_5_360 }, +#endif { 0 } }; static struct fd_type fd_searchlist_12m[] = { +#ifdef PC98 + { FDF_5_1200 | FL_AUTO }, + { FDF_5_720 | FL_AUTO }, + { FDF_5_360 | FL_AUTO }, + { FDF_5_640 | FL_AUTO }, + { FDF_5_1230 | FL_AUTO }, +#else { FDF_5_1200 | FL_AUTO }, { FDF_5_360 | FL_2STEP | FL_AUTO}, +#endif { 0 } }; static struct fd_type fd_searchlist_720k[] = { +#ifndef PC98 { FDF_3_720 }, +#endif { 0 } }; static struct fd_type fd_searchlist_144m[] = { +#ifdef PC98 + { FDF_3_1440 | FL_AUTO}, + { FDF_3_1200 | FL_AUTO}, + { FDF_3_720 | FL_AUTO}, + { FDF_3_360 | FL_AUTO}, + { FDF_3_640 | FL_AUTO}, + { FDF_3_1230 | FL_AUTO}, +#else { FDF_3_1440 | FL_AUTO}, { FDF_3_720 | FL_AUTO}, +#endif { 0 } }; static struct fd_type fd_searchlist_288m[] = { +#ifndef PC98 { FDF_3_1440 | FL_AUTO }, #if 0 { FDF_3_2880 | FL_AUTO }, /* XXX: probably doesn't work */ #endif { FDF_3_720 | FL_AUTO}, +#endif { 0 } }; @@ -183,6 +210,26 @@ static struct fd_type *fd_native_types[] = { * Internals start here */ +#ifdef PC98 +/* registers */ +#define FDSTS 0 /* NEC 765 Main Status Register (R) */ +#define FDDATA 1 /* NEC 765 Data Register (R/W) */ +#define FDCTL 2 /* FD Control Register */ +#define FDC_RST 0x80 /* FDC RESET */ +#define FDC_RDY 0x40 /* force READY */ +#define FDC_DD 0x20 /* FDD Mode Exchange 0:1M 1:640K */ +#define FDC_DMAE 0x10 /* enable floppy DMA */ +#define FDC_MTON 0x08 /* MOTOR ON (when EMTON=1)*/ +#define FDC_TMSK 0x04 /* TIMER MASK */ +#define FDC_TTRG 0x01 /* TIMER TRIGER */ + +#define FDP 3 +#define FDP_EMTON 0x04 /* enable MTON */ +#define FDP_FDDEXC 0x02 /* FDD Mode Exchange 1:1M 0:640K */ +#define FDP_PORTEXC 0x01 /* PORT Exchane 1:1M 0:640K */ + +#define FDEM 4 +#else /* registers */ #define FDOUT 2 /* Digital Output Register (W) */ #define FDO_FDSEL 0x03 /* floppy device select */ @@ -197,6 +244,7 @@ static struct fd_type *fd_native_types[] = { #define FDDSR 4 /* Data Rate Select Register (W) */ #define FDDATA 5 /* NEC 765 Data Register (R/W) */ #define FDCTL 7 /* Control Register (W) */ +#endif /* PC98 */ /* * The YE-DATA PC Card floppies use PIO to read in the data rather @@ -219,9 +267,11 @@ static struct fd_type *fd_native_types[] = { #define FDBCDR 0 /* And 1 */ #define FD_YE_DATAPORT 6 /* Drive Data port */ +#ifndef PC98 #define FDI_DCHG 0x80 /* diskette has been changed */ /* requires drive and motor being selected */ /* is cleared by any step pulse to drive */ +#endif /* * We have three private BIO commands. @@ -258,6 +308,9 @@ struct fd_data { struct g_provider *fd_provider; device_t dev; struct bio_queue_head fd_bq; +#ifdef PC98 + int pc98_trans; +#endif }; #define FD_NOT_VALID -2 @@ -281,11 +334,19 @@ static int retries = 10; SYSCTL_INT(_debug_fdc, OID_AUTO, retries, CTLFLAG_RW, &retries, 0, "Number of retries to attempt"); -static int spec1 = 0xaf; +#ifdef PC98 +static int spec1 = NE7_SPEC_1(4, 240); +#else +static int spec1 = NE7_SPEC_1(6, 240); +#endif SYSCTL_INT(_debug_fdc, OID_AUTO, spec1, CTLFLAG_RW, &spec1, 0, "Specification byte one (step-rate + head unload)"); -static int spec2 = 0x10; +#ifdef PC98 +static int spec2 = NE7_SPEC_2(2, 0); +#else +static int spec2 = NE7_SPEC_2(16, 0); +#endif SYSCTL_INT(_debug_fdc, OID_AUTO, spec2, CTLFLAG_RW, &spec2, 0, "Specification byte two (head load time + no-dma)"); @@ -335,12 +396,14 @@ fdctl_wr(struct fdc_data *fdc, u_int8_t v) fdregwr(fdc, FDCTL, v); } +#ifndef PC98 static void fdout_wr(struct fdc_data *fdc, u_int8_t v) { fdregwr(fdc, FDOUT, v); } +#endif static u_int8_t fdsts_rd(struct fdc_data *fdc) @@ -349,12 +412,14 @@ fdsts_rd(struct fdc_data *fdc) return fdregrd(fdc, FDSTS); } +#ifndef PC98 static void fddsr_wr(struct fdc_data *fdc, u_int8_t v) { fdregwr(fdc, FDDSR, v); } +#endif static void fddata_wr(struct fdc_data *fdc, u_int8_t v) @@ -370,12 +435,14 @@ fddata_rd(struct fdc_data *fdc) return fdregrd(fdc, FDDATA); } +#ifndef PC98 static u_int8_t fdin_rd(struct fdc_data *fdc) { return fdregrd(fdc, FDCTL); } +#endif /* * Magic pseudo-DMA initialization for YE FDC. Sets count and @@ -502,11 +569,90 @@ fdc_cmd(struct fdc_data *fdc, int n_out, ...) return (0); } +#ifdef PC98 +static void fd_motor(struct fd_data *fd, int turnon); + +static int pc98_trans = 0; /* 0 : HD , 1 : DD , 2 : 1.44 */ +static int pc98_trans_prev = -1; + +static void +set_density(struct fdc_data *fdc) +{ + /* always motor on */ + fdregwr(fdc, FDP, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC); + DELAY(100); + fdctl_wr(fdc, FDC_RST | FDC_DMAE); + /* in the case of note W, always inhibit 100ms timer */ +} + +static int +pc98_fd_check_ready(struct fd_data *fd) +{ + struct fdc_data *fdc = fd->fdc; + int retry = 0, status; + int fdu = device_get_unit(fd->dev); + + while (retry++ < 30000) { + fd_motor(fd, 1); + fdc_out(fdc, NE7CMD_SENSED); /* Sense Drive Status */ + DELAY(100); + fdc_out(fdc, fdu); /* Drive number */ + DELAY(100); + if ((fdc_in(fdc, &status) == 0) && (status & NE7_ST3_RD)) { + fdctl_wr(fdc, FDC_DMAE | FDC_MTON); + DELAY(10); + return (0); + } + } + return (-1); +} + +static void +pc98_fd_check_type(struct fd_data *fd, int unit) +{ + struct fdc_data *fdc; + + if (fd->type != FDT_NONE || unit < 0 || unit > 3) + return; + + fdc = fd->fdc; + + /* Look up what the BIOS thinks we have. */ + if (!((PC98_SYSTEM_PARAMETER(0x55c) >> unit) & 0x01)) { + fd->type = FDT_NONE; + return; + } + if ((PC98_SYSTEM_PARAMETER(0x5ae) >> unit) & 0x01) { + /* Check 3mode I/F */ + fd->pc98_trans = 0; + fdregwr(fdc, FDEM, (unit << 5) | 0x10); + if (!(fdregrd(fdc, FDEM) & 0x01)) { + fd->type = FDT_144M; + return; + } + device_printf(fd->dev, + "Warning: can't control 3mode I/F, fallback to 2mode.\n"); + } + + fd->type = FDT_12M; +} +#endif /* PC98 */ + static void fdc_reset(struct fdc_data *fdc) { int i, r[10]; +#ifdef PC98 + set_density(fdc); + if (pc98_machine_type & M_EPSON_PC98) + fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DD | FDC_MTON); + else + fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DMAE | FDC_MTON); + DELAY(200); + fdctl_wr(fdc, FDC_DMAE | FDC_MTON); + DELAY(10); +#else if (fdc->fdct == FDC_ENHANCED) { /* Try a software reset, default precomp, and 500 kb/s */ fddsr_wr(fdc, I8207X_DSR_SR); @@ -519,6 +665,7 @@ fdc_reset(struct fdc_data *fdc) } DELAY(100); fdout_wr(fdc, fdc->fdout); +#endif /* XXX after a reset, silently believe the FDC will accept commands */ if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, spec1, spec2, 0)) @@ -612,6 +759,7 @@ fdc_read_status(struct fdc_data *fdc) return ret; } +#ifndef PC98 /* * Select this drive */ @@ -649,6 +797,7 @@ fd_turnon(void *arg) if (once) wakeup(&fd->fdc->head); } +#endif static void fd_motor(struct fd_data *fd, int turnon) @@ -659,6 +808,11 @@ fd_motor(struct fd_data *fd, int turnon) /* mtx_assert(&fdc->fdc_mtx, MA_OWNED); */ +#ifdef PC98 + fdregwr(fdc, FDP, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC); + DELAY(10); + fdctl_wr(fdc, FDC_DMAE | FDC_MTON); +#else if (turnon) { fd->flags |= FD_MOTORWAIT; fdc->fdout |= (FDO_MOEN0 << fd->fdsu); @@ -669,6 +823,7 @@ fd_motor(struct fd_data *fd, int turnon) fdc->fdout &= ~(FDO_MOEN0 << fd->fdsu); } fdout_wr(fdc, fdc->fdout); +#endif } static void @@ -836,15 +991,41 @@ fdc_worker(struct fdc_data *fdc) } /* Select drive, setup params */ +#ifdef PC98 + pc98_trans = fd->ft->trans; + if (pc98_trans_prev != pc98_trans) { + int i; + + set_density(fdc); + for (i = 0; i < 10; i++) { + outb(0x5f, 0); + outb(0x5f, 0); + } + pc98_trans_prev = pc98_trans; + } + if (pc98_trans != fd->pc98_trans) { + if (fd->type == FDT_144M) { + fdregwr(fdc, FDEM, + (device_get_unit(fd->dev) << 5) | 0x10 | + (pc98_trans >> 1)); + outb(0x5f, 0); + outb(0x5f, 0); + } + fd->pc98_trans = pc98_trans; + } +#else fd_select(fd); if (fdc->fdct == FDC_ENHANCED) fddsr_wr(fdc, fd->ft->trans); else fdctl_wr(fdc, fd->ft->trans); +#endif if (bp->bio_cmd & BIO_PROBE) { if ((!(device_get_flags(fd->dev) & FD_NO_CHLINE) && +#ifndef PC98 !(fdin_rd(fdc) & FDI_DCHG) && +#endif !(fd->flags & FD_EMPTY)) || fd_probe_disk(fd, &need_recal) == 0) return (fdc_biodone(fdc, 0)); @@ -857,6 +1038,7 @@ fdc_worker(struct fdc_data *fdc) if (fd->flags & FD_EMPTY) return (fdc_biodone(fdc, ENXIO)); +#ifndef PC98 /* Check if we lost our media */ if (fdin_rd(fdc) & FDI_DCHG) { if (debugflags & 0x40) @@ -874,9 +1056,10 @@ fdc_worker(struct fdc_data *fdc) g_topology_unlock(); return (fdc_biodone(fdc, ENXIO)); } +#endif /* Check if the floppy is write-protected */ - if(bp->bio_cmd & (BIO_FMT | BIO_WRITE)) { + if (bp->bio_cmd & (BIO_FMT | BIO_WRITE)) { retry_line = __LINE__; if(fdc_sense_drive(fdc, &st3) != 0) return (1); @@ -907,6 +1090,9 @@ fdc_worker(struct fdc_data *fdc) if ((need_recal & (1 << fd->fdsu)) || (cylinder == 0 && fd->track != 0) || fdc->retry > 2) { +#ifdef PC98 + pc98_fd_check_ready(fd); +#endif retry_line = __LINE__; if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0)) return (1); @@ -928,6 +1114,9 @@ fdc_worker(struct fdc_data *fdc) * SEEK to where we want to be */ if (cylinder != fd->track) { +#ifdef PC98 + pc98_fd_check_ready(fd); +#endif retry_line = __LINE__; if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, descyl, 0)) return (1); @@ -1230,6 +1419,7 @@ fd_probe_disk(struct fd_data *fd, int *recal) if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID) goto done; /* XXX */ *recal |= (1 << fd->fdsu); +#ifndef PC98 if (fdin_rd(fdc) & FDI_DCHG) { if (debugflags & 0x40) printf("Empty in probe\n"); @@ -1237,6 +1427,9 @@ fd_probe_disk(struct fd_data *fd, int *recal) fd->flags |= FD_EMPTY; mtx_unlock(&fdc->fdc_mtx); } else { +#else + { +#endif if (fdc_sense_drive(fdc, &st3) != 0) goto done; if (debugflags & 0x40) @@ -1372,7 +1565,12 @@ fdautoselect(struct fd_data *fd) } else { if (debugflags & 0x40) { device_printf(fd->dev, - "autoselected %d KB medium\n", fd->ft->size / 2); + "autoselected %d KB medium\n", +#ifdef PC98 + (128 << (fd->ft->secsize)) * fd->ft->size / 1024); +#else + fd->ft->size / 2); +#endif fdprinttype(fd->ft); } return (0); @@ -1425,6 +1623,10 @@ fd_access(struct g_provider *pp, int r, int w, int e) busy = 0; if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) { +#ifdef PC98 + if (pc98_fd_check_ready(fd) == -1) + return (ENXIO); +#endif if (fdmisccmd(fd, BIO_PROBE, NULL)) return (ENXIO); if (fd->flags & FD_EMPTY) @@ -1494,6 +1696,10 @@ fd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread fd = pp->geom->softc; +#ifdef PC98 + pc98_fd_check_ready(fd); +#endif + switch (cmd) { case FD_GTYPE: /* get drive type */ *(struct fd_type *)data = *fd->ft; @@ -1661,6 +1867,12 @@ fdc_initial_reset(device_t dev, struct fdc_data *fdc) { int ic_type, part_id; +#ifdef PC98 + /* See if it can handle a command. */ + if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(4, 240), + NE7_SPEC_2(2, 0), 0)) + return (ENXIO); +#else /* * A status value of 0xff is very unlikely, but not theoretically * impossible, but it is far more likely to indicate an empty bus. @@ -1686,8 +1898,10 @@ fdc_initial_reset(device_t dev, struct fdc_data *fdc) return (ENXIO); /* Then, see if it can handle a command. */ - if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, 0xaf, 0x1e, 0)) + if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(6, 240), + NE7_SPEC_2(31, 0), 0)) return (ENXIO); +#endif /* * Try to identify the chip. @@ -1749,7 +1963,11 @@ fdc_detach(device_t dev) mtx_unlock(&fdc->fdc_mtx); /* reset controller, turn motor off */ +#ifdef PC98 + fdc_reset(fdc); +#else fdout_wr(fdc, 0); +#endif if (!(fdc->flags & FDC_NODMA)) isa_dma_release(fdc->dmachan); @@ -1823,7 +2041,11 @@ fdc_attach(device_t dev) mtx_init(&fdc->fdc_mtx, "fdc lock", NULL, MTX_DEF); /* reset controller, turn motor off, clear fdout mirror reg */ +#ifdef PC98 + fdc_reset(fdc); +#else fdout_wr(fdc, fdc->fdout = 0); +#endif bioq_init(&fdc->head); kproc_create(fdc_thread, fdc, &fdc->fdc_thread, 0, 0, @@ -1877,8 +2099,11 @@ fdc_print_child(device_t me, device_t child) static int fd_probe(device_t dev) { - int i, unit; + int unit; +#ifndef PC98 + int i; u_int st0, st3; +#endif struct fd_data *fd; struct fdc_data *fdc; int fdsu; @@ -1905,7 +2130,9 @@ fd_probe(device_t dev) fd->type = type; } -#if (defined(__i386__) && !defined(PC98)) || defined(__amd64__) +#ifdef PC98 + pc98_fd_check_type(fd, unit); +#elif defined(__i386__) || defined(__amd64__) if (fd->type == FDT_NONE && (unit == 0 || unit == 1)) { /* Look up what the BIOS thinks we have. */ if (unit == 0) @@ -1920,6 +2147,7 @@ fd_probe(device_t dev) if (fd->type == FDT_NONE) return (ENXIO); +#ifndef PC98 /* mtx_lock(&fdc->fdc_mtx); */ @@ -1972,10 +2200,19 @@ fd_probe(device_t dev) if ((flags & FD_NO_PROBE) == 0 && (st0 & NE7_ST0_EC) != 0) /* no track 0 -> no drive present */ return (ENXIO); +#endif /* PC98 */ done: switch (fd->type) { +#ifdef PC98 + case FDT_144M: + device_set_desc(dev, "1.44M FDD"); + break; + case FDT_12M: + device_set_desc(dev, "1M/640K FDD"); + break; +#else case FDT_12M: device_set_desc(dev, "1200-KB 5.25\" drive"); break; @@ -1991,6 +2228,7 @@ fd_probe(device_t dev) case FDT_720K: device_set_desc(dev, "720-KB 3.5\" drive"); break; +#endif default: return (ENXIO); } @@ -1998,6 +2236,9 @@ fd_probe(device_t dev) fd->fdc = fdc; fd->fdsu = fdsu; fd->options = 0; +#ifdef PC98 + fd->pc98_trans = 0; +#endif callout_init_mtx(&fd->toffhandle, &fd->fdc->fdc_mtx, 0); /* initialize densities for subdevices */ diff --git a/sys/pc98/cbus/fdc_cbus.c b/sys/dev/fdc/fdc_cbus.c similarity index 71% rename from sys/pc98/cbus/fdc_cbus.c rename to sys/dev/fdc/fdc_cbus.c index 098ee5daefe2..ee1598dccb07 100644 --- a/sys/pc98/cbus/fdc_cbus.c +++ b/sys/dev/fdc/fdc_cbus.c @@ -33,15 +33,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include #include -#include -#include +#include #include @@ -50,62 +51,70 @@ static bus_addr_t fdc_iat[] = {0, 2, 4}; static int fdc_cbus_alloc_resources(device_t dev, struct fdc_data *fdc) { - int rid; + struct resource *res; + int i, rid; fdc->fdc_dev = dev; - fdc->rid_ioport = 0; - fdc->rid_irq = 0; - fdc->rid_drq = 0; - fdc->res_irq = 0; - fdc->res_drq = 0; - - fdc->res_ioport = isa_alloc_resourcev(dev, SYS_RES_IOPORT, - &fdc->rid_ioport, fdc_iat, - 3, RF_ACTIVE); - if (fdc->res_ioport == 0) { + rid = 0; + res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, fdc_iat, 3, + RF_ACTIVE); + if (res == NULL) { device_printf(dev, "cannot reserve I/O port range\n"); - return ENXIO; + return (ENXIO); } - isa_load_resourcev(fdc->res_ioport, fdc_iat, 3); - fdc->portt = rman_get_bustag(fdc->res_ioport); - fdc->porth = rman_get_bushandle(fdc->res_ioport); - + isa_load_resourcev(res, fdc_iat, 3); + for (i = 0; i < 3; i++) { + fdc->resio[i] = res; + fdc->ridio[i] = rid; + fdc->ioff[i] = i; + fdc->ioh[i] = rman_get_bushandle(res); + } + fdc->iot = rman_get_bustag(res); + rid = 3; bus_set_resource(dev, SYS_RES_IOPORT, rid, IO_FDPORT, 1); - fdc->res_fdsio = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, - RF_ACTIVE); - if (fdc->res_fdsio == 0) - return ENXIO; - fdc->sc_fdsiot = rman_get_bustag(fdc->res_fdsio); - fdc->sc_fdsioh = rman_get_bushandle(fdc->res_fdsio); + res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); + if (res == NULL) { + device_printf(dev, "cannot reserve I/O port range\n"); + return (ENXIO); + } + fdc->resio[3] = res; + fdc->ridio[3] = rid; + fdc->ioff[3] = 0; + fdc->ioh[3] = rman_get_bushandle(res); + /* XXX: Reuses fdc->iot */ rid = 4; bus_set_resource(dev, SYS_RES_IOPORT, rid, 0x4be, 1); - fdc->res_fdemsio = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, - RF_ACTIVE); - if (fdc->res_fdemsio == 0) - return ENXIO; - fdc->sc_fdemsiot = rman_get_bustag(fdc->res_fdemsio); - fdc->sc_fdemsioh = rman_get_bushandle(fdc->res_fdemsio); + res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); + if (res == NULL) { + device_printf(dev, "cannot reserve I/O port range\n"); + return (ENXIO); + } + fdc->resio[4] = res; + fdc->ridio[4] = rid; + fdc->ioff[4] = 0; + fdc->ioh[4] = rman_get_bushandle(res); + /* XXX: Reuses fdc->iot */ fdc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fdc->rid_irq, - RF_ACTIVE); - if (fdc->res_irq == 0) { + RF_ACTIVE); + if (fdc->res_irq == NULL) { device_printf(dev, "cannot reserve interrupt line\n"); - return ENXIO; + return (ENXIO); } if ((fdc->flags & FDC_NODMA) == 0) { fdc->res_drq = bus_alloc_resource_any(dev, SYS_RES_DRQ, - &fdc->rid_drq, RF_ACTIVE); - if (fdc->res_drq == 0) { + &fdc->rid_drq, RF_ACTIVE); + if (fdc->res_drq == NULL) { device_printf(dev, "cannot reserve DMA request line\n"); - return ENXIO; + return (ENXIO); } fdc->dmachan = rman_get_start(fdc->res_drq); } - return 0; + return (0); } static int @@ -122,8 +131,8 @@ fdc_cbus_probe(device_t dev) /* Attempt to allocate our resources for the duration of the probe */ error = fdc_cbus_alloc_resources(dev, fdc); - if (!error) - error = fdc_initial_reset(fdc); + if (error == 0) + error = fdc_initial_reset(dev, fdc); fdc_release_resources(fdc); return (error); @@ -136,15 +145,14 @@ fdc_cbus_attach(device_t dev) int error; fdc = device_get_softc(dev); - - if ((error = fdc_cbus_alloc_resources(dev, fdc)) != 0 || - (error = fdc_attach(dev)) != 0 || - (error = fdc_hints_probe(dev)) != 0) { + error = fdc_cbus_alloc_resources(dev, fdc); + if (error == 0) + error = fdc_attach(dev); + if (error == 0) + error = fdc_hints_probe(dev); + if (error) fdc_release_resources(fdc); - return (error); - } - - return (0); + return (error); } static device_method_t fdc_methods[] = { diff --git a/sys/dev/fdc/fdcvar.h b/sys/dev/fdc/fdcvar.h index 5ab60a6a6443..b09bfa19c405 100644 --- a/sys/dev/fdc/fdcvar.h +++ b/sys/dev/fdc/fdcvar.h @@ -49,7 +49,9 @@ struct fdc_data { #define FDC_KTHREAD_ALIVE 0x2000 /* worker thread is alive */ struct fd_data *fd; /* The active drive */ int retry; +#ifndef PC98 int fdout; /* mirror of the w/o digital output reg */ +#endif u_int status[7]; /* copy of the registers */ enum fdc_type fdct; /* chip version of FDC */ int fdc_errs; /* number of logged errors */ diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 77cf8baeba33..9d0c0f038ba7 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -493,46 +493,6 @@ fdt_reg_to_rl(phandle_t node, struct resource_list *rl) return (rv); } -int -fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl, - struct fdt_sense_level *intr_sl) -{ - phandle_t iparent; - uint32_t *intr, icells; - int nintr, i, k; - - nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - if (OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)) == -1) { - device_printf(dev, "No interrupt-parent found, " - "assuming direct parent\n"); - iparent = OF_parent(node); - } - if (OF_searchencprop(OF_node_from_xref(iparent), - "#interrupt-cells", &icells, sizeof(icells)) == -1) { - device_printf(dev, "Missing #interrupt-cells property, " - "assuming <1>\n"); - icells = 1; - } - if (icells < 1 || icells > nintr) { - device_printf(dev, "Invalid #interrupt-cells property " - "value <%d>, assuming <1>\n", icells); - icells = 1; - } - for (i = 0, k = 0; i < nintr; i += icells, k++) { - intr[i] = ofw_bus_map_intr(dev, iparent, icells, - &intr[i]); - resource_list_add(rl, SYS_RES_IRQ, k, intr[i], intr[i], - 1); - } - free(intr, M_OFWPROP); - } - - return (0); -} - int fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc) { diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h index d306f65b83ad..0a79ce03baf8 100644 --- a/sys/dev/fdt/fdt_common.h +++ b/sys/dev/fdt/fdt_common.h @@ -88,7 +88,6 @@ int fdt_get_phyaddr(phandle_t, device_t, int *, void **); int fdt_get_range(phandle_t, int, u_long *, u_long *); int fdt_immr_addr(vm_offset_t); int fdt_regsize(phandle_t, u_long *, u_long *); -int fdt_intr_to_rl(device_t, phandle_t, struct resource_list *, struct fdt_sense_level *); int fdt_is_compatible(phandle_t, const char *); int fdt_is_compatible_strict(phandle_t, const char *); int fdt_is_enabled(phandle_t); diff --git a/sys/dev/fdt/fdt_pinctrl.c b/sys/dev/fdt/fdt_pinctrl.c new file mode 100644 index 000000000000..474fb00e22a9 --- /dev/null +++ b/sys/dev/fdt/fdt_pinctrl.c @@ -0,0 +1,151 @@ +/*- + * Copyright (c) 2014 Ian Lepore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 "fdt_pinctrl_if.h" + +#include +#include + +int +fdt_pinctrl_configure(device_t client, u_int index) +{ + device_t pinctrl; + phandle_t *configs; + int i, nconfigs; + char name[16]; + + snprintf(name, sizeof(name), "pinctrl-%u", index); + nconfigs = OF_getprop_alloc(ofw_bus_get_node(client), name, + sizeof(*configs), (void **)&configs); + if (nconfigs < 0) + return (ENOENT); + if (nconfigs == 0) + return (0); /* Empty property is documented as valid. */ + for (i = 0; i < nconfigs; i++) { + if ((pinctrl = OF_device_from_xref(configs[i])) != NULL) + FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]); + } + free(configs, M_OFWPROP); + return (0); +} + +int +fdt_pinctrl_configure_by_name(device_t client, const char * name) +{ + char * names; + int i, offset, nameslen; + + nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names", + sizeof(*names), (void **)&names); + if (nameslen <= 0) + return (ENOENT); + for (i = 0, offset = 0; offset < nameslen; i++) { + if (strcmp(name, &names[offset]) == 0) + break; + offset += strlen(&names[offset]) + 1; + } + free(names, M_OFWPROP); + if (offset < nameslen) + return (fdt_pinctrl_configure(client, i)); + else + return (ENOENT); +} + +static int +pinctrl_register_children(device_t pinctrl, phandle_t parent, + const char *pinprop) +{ + phandle_t node; + + /* + * Recursively descend from parent, looking for nodes that have the + * given property, and associate the pinctrl device_t with each one. + */ + for (node = OF_child(parent); node != 0; node = OF_peer(node)) { + pinctrl_register_children(pinctrl, node, pinprop); + if (pinprop == NULL || OF_hasprop(node, pinprop)) { + OF_device_register_xref(OF_xref_from_node(node), + pinctrl); + } + } + return (0); +} + +int +fdt_pinctrl_register(device_t pinctrl, const char *pinprop) +{ + phandle_t node; + + node = ofw_bus_get_node(pinctrl); + OF_device_register_xref(OF_xref_from_node(node), pinctrl); + return (pinctrl_register_children(pinctrl, node, pinprop)); +} + +static int +pinctrl_configure_children(device_t pinctrl, phandle_t parent) +{ + phandle_t node, *configs; + int i, nconfigs; + + for (node = OF_child(parent); node != 0; node = OF_peer(node)) { + if (!fdt_is_enabled(node)) + continue; + pinctrl_configure_children(pinctrl, node); + nconfigs = OF_getencprop_alloc(node, "pinctrl-0", + sizeof(*configs), (void **)&configs); +#ifdef DEBUG + { + char name[32]; + OF_getprop(node, "name", &name, sizeof(name)); + printf("%d items in pinctrl-0 for %s\n", nconfigs, name); + } +#endif + if (nconfigs <= 0) + continue; + for (i = 0; i < nconfigs; i++) { + if (OF_device_from_xref(configs[i]) == pinctrl) + FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]); + } + free(configs, M_OFWPROP); + } + return (0); +} + +int +fdt_pinctrl_configure_tree(device_t pinctrl) +{ + + return (pinctrl_configure_children(pinctrl, OF_peer(0))); +} + diff --git a/sys/dev/fdt/fdt_pinctrl.h b/sys/dev/fdt/fdt_pinctrl.h new file mode 100644 index 000000000000..6ac7d60a52eb --- /dev/null +++ b/sys/dev/fdt/fdt_pinctrl.h @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2014 Ian Lepore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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 DEV_FDT_PINCTRL_H +#define DEV_FDT_PINCTRL_H + +#include "fdt_pinctrl_if.h" + +/* + * Configure pins by name or index. This looks up the pinctrl-N property in + * client's fdt data by index or name, and passes each handle in it to the + * pinctrl driver for configuration. + */ +int fdt_pinctrl_configure(device_t client, u_int index); +int fdt_pinctrl_configure_by_name(device_t client, const char * name); + +/* + * Register a pinctrl driver so that it can be used by other devices which call + * fdt_pinctrl_configure(). The pinprop argument is the name of a property that + * identifies each descendent of the pinctrl node which is a pin configuration + * node whose xref phandle can be passed to FDT_PINCTRL_CONFIGURE(). If this is + * NULL, every descendant node is registered. + */ +int fdt_pinctrl_register(device_t pinctrl, const char *pinprop); + +/* + * Walk the device tree and configure pins for each enabled device whose + * pinctrl-0 property contains references to nodes which are children of the + * given pinctrl device. This helper routine is for use by pinctrl drivers. + */ +int fdt_pinctrl_configure_tree(device_t pinctrl); + +#endif /* DEV_FDT_PINCTRL_H */ + diff --git a/sys/dev/fdt/fdt_pinctrl_if.m b/sys/dev/fdt/fdt_pinctrl_if.m new file mode 100644 index 000000000000..c499cdf3cb81 --- /dev/null +++ b/sys/dev/fdt/fdt_pinctrl_if.m @@ -0,0 +1,47 @@ +#- +# Copyright (c) 2014 Ian Lepore +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that 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 + +# +# This is the interface that fdt_pinctrl drivers provide to other drivers. +# + +INTERFACE fdt_pinctrl; + +# +# Set pins to the specified configuration. The cfgxref arg is an xref phandle +# to a descendent node (child, grandchild, ...) of the pinctrl device node. +# Returns 0 on success or a standard errno value. +# +METHOD int configure { + device_t pinctrl; + phandle_t cfgxref; +}; + diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index e21b913d8634..41597837bd6b 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -247,11 +247,9 @@ simplebus_setup_dinfo(device_t dev, phandle_t node) { struct simplebus_softc *sc; struct simplebus_devinfo *ndi; - uint32_t *reg, *intr, icells; + uint32_t *reg; uint64_t phys, size; - phandle_t iparent; int i, j, k; - int nintr; int nreg; sc = device_get_softc(dev); @@ -289,34 +287,7 @@ simplebus_setup_dinfo(device_t dev, phandle_t node) } free(reg, M_OFWPROP); - nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - if (OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)) == -1) { - device_printf(dev, "No interrupt-parent found, " - "assuming direct parent\n"); - iparent = OF_parent(node); - } - if (OF_searchencprop(OF_node_from_xref(iparent), - "#interrupt-cells", &icells, sizeof(icells)) == -1) { - device_printf(dev, "Missing #interrupt-cells property, " - "assuming <1>\n"); - icells = 1; - } - if (icells < 1 || icells > nintr) { - device_printf(dev, "Invalid #interrupt-cells property " - "value <%d>, assuming <1>\n", icells); - icells = 1; - } - for (i = 0, k = 0; i < nintr; i += icells, k++) { - intr[i] = ofw_bus_map_intr(dev, iparent, icells, - &intr[i]); - resource_list_add(&ndi->rl, SYS_RES_IRQ, k, intr[i], - intr[i], 1); - } - free(intr, M_OFWPROP); - } + ofw_bus_intr_to_rl(dev, node, &ndi->rl); return (ndi); } diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index e7d6fa63c30c..2123dfc08263 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -930,7 +930,7 @@ static void fe_reset (struct fe_softc *sc) { /* Record how many packets are lost by this accident. */ - sc->ifp->if_oerrors += sc->txb_sched + sc->txb_count; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, sc->txb_sched + sc->txb_count); sc->mibdata.dot3StatsInternalMacTransmitErrors++; /* Put the interface into known initial state. */ @@ -997,12 +997,15 @@ fe_watchdog (void *arg) FE_ASSERT_LOCKED(sc); if (sc->tx_timeout && --sc->tx_timeout == 0) { + struct ifnet *ifp = sc->ifp; + /* A "debug" message. */ - if_printf(sc->ifp, "transmission timeout (%d+%d)%s\n", + if_printf(ifp, "transmission timeout (%d+%d)%s\n", sc->txb_sched, sc->txb_count, - (sc->ifp->if_flags & IFF_UP) ? "" : " when down"); - if (sc->ifp->if_opackets == 0 && sc->ifp->if_ipackets == 0) - if_printf(sc->ifp, "wrong IRQ setting in config?\n"); + (ifp->if_flags & IFF_UP) ? "" : " when down"); + if (ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS) == 0 && + ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS) == 0) + if_printf(ifp, "wrong IRQ setting in config?\n"); fe_reset(sc); } callout_reset(&sc->timer, hz, fe_watchdog, sc); @@ -1519,7 +1522,7 @@ fe_tint (struct fe_softc * sc, u_char tstat) */ col = 1; } - sc->ifp->if_collisions += col; + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, col); if (col == 1) sc->mibdata.dot3StatsSingleCollisionFrames++; else @@ -1532,9 +1535,9 @@ fe_tint (struct fe_softc * sc, u_char tstat) * Be sure to reflect number of excessive collisions. */ col = sc->tx_excolls; - sc->ifp->if_opackets += sc->txb_sched - col; - sc->ifp->if_oerrors += col; - sc->ifp->if_collisions += col * 16; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, sc->txb_sched - col); + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, col); + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, col * 16); sc->mibdata.dot3StatsExcessiveCollisions += col; sc->mibdata.dot3StatsCollFrequencies[15] += col; sc->txb_sched = 0; @@ -1591,7 +1594,7 @@ fe_rint (struct fe_softc * sc, u_char rstat) if (rstat & FE_D1_SRTPKT) sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */ #endif - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } /* @@ -1651,7 +1654,7 @@ fe_rint (struct fe_softc * sc, u_char rstat) len < ETHER_MIN_LEN - ETHER_CRC_LEN) { if_printf(sc->ifp, "RX buffer out-of-sync\n"); - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); sc->mibdata.dot3StatsInternalMacReceiveErrors++; fe_reset(sc); return; @@ -1668,14 +1671,14 @@ fe_rint (struct fe_softc * sc, u_char rstat) * in the buffer. We hope we can get more * mbuf next time. */ - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); sc->mibdata.dot3StatsMissedFrames++; fe_droppacket(sc, len); return; } /* Successfully received a packet. Update stat. */ - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); } /* Maximum number of frames has been received. Something @@ -1961,7 +1964,7 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m) length > ETHER_MAX_LEN - ETHER_CRC_LEN) { if_printf(sc->ifp, "got an out-of-spec packet (%u bytes) to send\n", length); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); sc->mibdata.dot3StatsInternalMacTransmitErrors++; return; } diff --git a/sys/dev/ffec/if_ffec.c b/sys/dev/ffec/if_ffec.c index ce8b43537b13..b8230164367d 100644 --- a/sys/dev/ffec/if_ffec.c +++ b/sys/dev/ffec/if_ffec.c @@ -499,23 +499,21 @@ ffec_harvest_stats(struct ffec_softc *sc) sc->stats_harvest_count = 0; ifp = sc->ifp; - ifp->if_ipackets += RD4(sc, FEC_RMON_R_PACKETS); - ifp->if_imcasts += RD4(sc, FEC_RMON_R_MC_PKT); - ifp->if_ierrors += RD4(sc, FEC_RMON_R_CRC_ALIGN); - ifp->if_ierrors += RD4(sc, FEC_RMON_R_UNDERSIZE); - ifp->if_ierrors += RD4(sc, FEC_RMON_R_OVERSIZE); - ifp->if_ierrors += RD4(sc, FEC_RMON_R_FRAG); - ifp->if_ierrors += RD4(sc, FEC_RMON_R_JAB); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, RD4(sc, FEC_RMON_R_PACKETS)); + if_inc_counter(ifp, IFCOUNTER_IMCASTS, RD4(sc, FEC_RMON_R_MC_PKT)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, + RD4(sc, FEC_RMON_R_CRC_ALIGN) + RD4(sc, FEC_RMON_R_UNDERSIZE) + + RD4(sc, FEC_RMON_R_OVERSIZE) + RD4(sc, FEC_RMON_R_FRAG) + + RD4(sc, FEC_RMON_R_JAB)); - ifp->if_opackets += RD4(sc, FEC_RMON_T_PACKETS); - ifp->if_omcasts += RD4(sc, FEC_RMON_T_MC_PKT); - ifp->if_oerrors += RD4(sc, FEC_RMON_T_CRC_ALIGN); - ifp->if_oerrors += RD4(sc, FEC_RMON_T_UNDERSIZE); - ifp->if_oerrors += RD4(sc, FEC_RMON_T_OVERSIZE ); - ifp->if_oerrors += RD4(sc, FEC_RMON_T_FRAG); - ifp->if_oerrors += RD4(sc, FEC_RMON_T_JAB); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, RD4(sc, FEC_RMON_T_PACKETS)); + if_inc_counter(ifp, IFCOUNTER_OMCASTS, RD4(sc, FEC_RMON_T_MC_PKT)); + if_inc_counter(ifp, IFCOUNTER_OERRORS, + RD4(sc, FEC_RMON_T_CRC_ALIGN) + RD4(sc, FEC_RMON_T_UNDERSIZE) + + RD4(sc, FEC_RMON_T_OVERSIZE) + RD4(sc, FEC_RMON_T_FRAG) + + RD4(sc, FEC_RMON_T_JAB)); - ifp->if_collisions += RD4(sc, FEC_RMON_T_COL); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, RD4(sc, FEC_RMON_T_COL)); ffec_clear_stats(sc); } @@ -784,7 +782,7 @@ ffec_rxfinish_onebuf(struct ffec_softc *sc, int len) * mbuf, which is still mapped and loaded. */ if ((newmbuf = ffec_alloc_mbufcl(sc)) == NULL) { - ++sc->ifp->if_iqdrops; + if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, 1); ffec_setup_rxdesc(sc, sc->rx_idx, sc->rxdesc_ring[sc->rx_idx].buf_paddr); return; diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index 0a6180a7a7ae..c5f5dbac1a7a 100644 --- a/sys/dev/firewire/firewire.c +++ b/sys/dev/firewire/firewire.c @@ -48,27 +48,14 @@ __FBSDID("$FreeBSD$"); #include #include - -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#include /* for DELAY() */ -#endif - #include /* used by smbus and newbus */ #include -#ifdef __DragonFly__ -#include "firewire.h" -#include "firewirereg.h" -#include "fwmem.h" -#include "iec13213.h" -#include "iec68113.h" -#else #include #include #include #include #include -#endif struct crom_src_buf { struct crom_src src; @@ -77,7 +64,7 @@ struct crom_src_buf { struct crom_chunk hw; }; -int firewire_debug=0, try_bmr=1, hold_count=0; +int firewire_debug = 0, try_bmr = 1, hold_count = 0; SYSCTL_INT(_debug, OID_AUTO, firewire_debug, CTLFLAG_RW, &firewire_debug, 0, "FireWire driver debug flag"); SYSCTL_NODE(_hw, OID_AUTO, firewire, CTLFLAG_RD, 0, "FireWire Subsystem"); @@ -93,22 +80,19 @@ MALLOC_DEFINE(M_FWXFER, "fw_xfer", "XFER/FireWire"); devclass_t firewire_devclass; -static void firewire_identify (driver_t *, device_t); -static int firewire_probe (device_t); -static int firewire_attach (device_t); -static int firewire_detach (device_t); -static int firewire_resume (device_t); +static void firewire_identify(driver_t *, device_t); +static int firewire_probe(device_t); +static int firewire_attach(device_t); +static int firewire_detach(device_t); +static int firewire_resume(device_t); static void firewire_xfer_timeout(void *, int); -#if 0 -static int firewire_shutdown (device_t); -#endif static device_t firewire_add_child(device_t, u_int, const char *, int); -static void fw_try_bmr (void *); -static void fw_try_bmr_callback (struct fw_xfer *); -static void fw_asystart (struct fw_xfer *); -static int fw_get_tlabel (struct firewire_comm *, struct fw_xfer *); -static void fw_bus_probe (struct firewire_comm *); -static void fw_attach_dev (struct firewire_comm *); +static void fw_try_bmr(void *); +static void fw_try_bmr_callback(struct fw_xfer *); +static void fw_asystart(struct fw_xfer *); +static int fw_get_tlabel(struct firewire_comm *, struct fw_xfer *); +static void fw_bus_probe(void *); +static void fw_attach_dev(struct firewire_comm *); static void fw_bus_probe_thread(void *); #ifdef FW_VMACCESS static void fw_vmaccess (struct fw_xfer *); @@ -131,6 +115,7 @@ static device_method_t firewire_methods[] = { DEVMETHOD_END }; + char *linkspeed[] = { "S100", "S200", "S400", "S800", "S1600", "S3200", "undef", "undef" @@ -189,8 +174,10 @@ fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui) FW_GUNLOCK(fc); splx(s); - if(fwdev == NULL) return NULL; - if(fwdev->status == FWDEVINVAL) return NULL; + if (fwdev == NULL) + return NULL; + if (fwdev->status == FWDEVINVAL) + return NULL; return fwdev; } @@ -207,8 +194,9 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) int tcode; struct tcode_info *info; - if(xfer == NULL) return EINVAL; - if(xfer->hand == NULL){ + if (xfer == NULL) + return EINVAL; + if (xfer->hand == NULL) { printf("hand == NULL\n"); return EINVAL; } @@ -246,17 +234,17 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) len = fp->mode.rresb.len; else len = 0; - if (len != xfer->send.pay_len){ + if (len != xfer->send.pay_len) { printf("len(%d) != send.pay_len(%d) %s(%x)\n", len, xfer->send.pay_len, tcode_str[tcode], tcode); - return EINVAL; + return EINVAL; } - if(xferq->start == NULL){ + if (xferq->start == NULL) { printf("xferq->start == NULL\n"); return EINVAL; } - if(!(xferq->queued < xferq->maxq)){ + if (!(xferq->queued < xferq->maxq)) { device_printf(fc->bdev, "Discard a packet (queued=%d)\n", xferq->queued); return EAGAIN; @@ -275,6 +263,7 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) fw_asystart(xfer); return err; } + /* * Wakeup blocked process. */ @@ -298,8 +287,8 @@ fw_xferwait(struct fw_xfer *xfer) int err = 0; mtx_lock(lock); - if ((xfer->flag & FWXF_WAKE) == 0) - err = msleep((void *)xfer, lock, PWAIT|PCATCH, "fw_xferwait", 0); + while ((xfer->flag & FWXF_WAKE) == 0) + err = msleep(xfer, lock, PWAIT|PCATCH, "fw_xferwait", 0); mtx_unlock(lock); return (err); @@ -313,13 +302,14 @@ fw_asystart(struct fw_xfer *xfer) { struct firewire_comm *fc = xfer->fc; int s; + s = splfw(); /* Protect from interrupt/timeout */ FW_GLOCK(fc); xfer->flag = FWXF_INQ; STAILQ_INSERT_TAIL(&xfer->q->q, xfer, link); #if 0 - xfer->q->queued ++; + xfer->q->queued++; #endif FW_GUNLOCK(fc); splx(s); @@ -361,7 +351,7 @@ firewire_xfer_timeout(void *arg, int pending) s = splfw(); mtx_lock(&fc->tlabel_lock); - for (i = 0; i < 0x40; i ++) { + for (i = 0; i < 0x40; i++) { while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { if ((xfer->flag & FWXF_SENT) == 0) /* not sent yet */ @@ -370,8 +360,8 @@ firewire_xfer_timeout(void *arg, int pending) /* the rests are newer than this */ break; device_printf(fc->bdev, - "split transaction timeout: " - "tl=0x%x flag=0x%02x\n", i, xfer->flag); + "split transaction timeout: tl=0x%x flag=0x%02x\n", + i, xfer->flag); fw_dump_hdr(&xfer->send.hdr, "send"); xfer->resp = ETIMEDOUT; xfer->tl = -1; @@ -384,7 +374,7 @@ firewire_xfer_timeout(void *arg, int pending) fc->timeout(fc); STAILQ_FOREACH_SAFE(xfer, &xfer_timeout, tlabel, txfer) - xfer->hand(xfer); + xfer->hand(xfer); } #define WATCHDOG_HZ 10 @@ -394,7 +384,7 @@ firewire_watchdog(void *arg) struct firewire_comm *fc; static int watchdog_clock = 0; - fc = (struct firewire_comm *)arg; + fc = arg; /* * At boot stage, the device interrupt is disabled and @@ -404,10 +394,10 @@ firewire_watchdog(void *arg) if (watchdog_clock > WATCHDOG_HZ * 15) taskqueue_enqueue(fc->taskqueue, &fc->task_timeout); else - watchdog_clock ++; + watchdog_clock++; callout_reset(&fc->timeout_callout, hz / WATCHDOG_HZ, - (void *)firewire_watchdog, (void *)fc); + firewire_watchdog, fc); } /* @@ -421,35 +411,36 @@ firewire_attach(device_t dev) device_t pa = device_get_parent(dev); struct firewire_comm *fc; - fc = (struct firewire_comm *)device_get_softc(pa); + fc = device_get_softc(pa); sc->fc = fc; fc->status = FWBUSNOTREADY; unit = device_get_unit(dev); - if( fc->nisodma > FWMAXNDMA) fc->nisodma = FWMAXNDMA; + if (fc->nisodma > FWMAXNDMA) + fc->nisodma = FWMAXNDMA; fwdev_makedev(sc); - fc->crom_src_buf = (struct crom_src_buf *)malloc( - sizeof(struct crom_src_buf), - M_FW, M_NOWAIT | M_ZERO); + fc->crom_src_buf = malloc(sizeof(struct crom_src_buf), + M_FW, M_NOWAIT | M_ZERO); if (fc->crom_src_buf == NULL) { - device_printf(fc->dev, "%s: Malloc Failure crom src buff\n", __func__); + device_printf(fc->dev, + "%s: unable to allocate crom src buffer\n", __func__); return ENOMEM; } - fc->topology_map = (struct fw_topology_map *)malloc( - sizeof(struct fw_topology_map), - M_FW, M_NOWAIT | M_ZERO); + fc->topology_map = malloc(sizeof(struct fw_topology_map), + M_FW, M_NOWAIT | M_ZERO); if (fc->topology_map == NULL) { - device_printf(fc->dev, "%s: Malloc Failure topology map\n", __func__); + device_printf(fc->dev, "%s: unable to allocate topology map\n", + __func__); free(fc->crom_src_buf, M_FW); return ENOMEM; } - fc->speed_map = (struct fw_speed_map *)malloc( - sizeof(struct fw_speed_map), - M_FW, M_NOWAIT | M_ZERO); + fc->speed_map = malloc(sizeof(struct fw_speed_map), + M_FW, M_NOWAIT | M_ZERO); if (fc->speed_map == NULL) { - device_printf(fc->dev, "%s: Malloc Failure speed map\n", __func__); + device_printf(fc->dev, "%s: unable to allocate speed map\n", + __func__); free(fc->crom_src_buf, M_FW); free(fc->topology_map, M_FW); return ENOMEM; @@ -460,14 +451,14 @@ firewire_attach(device_t dev) CALLOUT_INIT(&fc->timeout_callout); CALLOUT_INIT(&fc->bmr_callout); CALLOUT_INIT(&fc->busprobe_callout); - TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, (void *)fc); + TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, fc); callout_reset(&sc->fc->timeout_callout, hz, - (void *)firewire_watchdog, (void *)sc->fc); + firewire_watchdog, sc->fc); /* create thread */ - kproc_create(fw_bus_probe_thread, (void *)fc, &fc->probe_thread, - 0, 0, "fw%d_probe", unit); + kproc_create(fw_bus_probe_thread, fc, &fc->probe_thread, + 0, 0, "fw%d_probe", unit); /* Locate our children */ bus_generic_probe(dev); @@ -490,10 +481,10 @@ firewire_attach(device_t dev) static device_t firewire_add_child(device_t dev, u_int order, const char *name, int unit) { - device_t child; + device_t child; struct firewire_softc *sc; - sc = (struct firewire_softc *)device_get_softc(dev); + sc = device_get_softc(dev); child = device_add_child(dev, name, unit); if (child) { device_set_ivars(child, sc->fc); @@ -508,16 +499,16 @@ firewire_resume(device_t dev) { struct firewire_softc *sc; - sc = (struct firewire_softc *)device_get_softc(dev); + sc = device_get_softc(dev); sc->fc->status = FWBUSNOTREADY; - + bus_generic_resume(dev); - return(0); + return (0); } /* - * Dettach it. + * Detach it. */ static int firewire_detach(device_t dev) @@ -527,7 +518,7 @@ firewire_detach(device_t dev) struct fw_device *fwdev, *fwdev_next; int err; - sc = (struct firewire_softc *)device_get_softc(dev); + sc = device_get_softc(dev); fc = sc->fc; mtx_lock(&fc->wait_lock); fc->status = FWBUSDETACH; @@ -536,7 +527,7 @@ firewire_detach(device_t dev) printf("firewire probe thread didn't die\n"); mtx_unlock(&fc->wait_lock); - if (fc->arq !=0 && fc->arq->maxq > 0) + if (fc->arq != 0 && fc->arq->maxq > 0) fw_drain_txq(fc); if ((err = fwdev_destroydev(sc)) != 0) @@ -551,7 +542,7 @@ firewire_detach(device_t dev) /* XXX xfer_free and untimeout on all xfers */ for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL; - fwdev = fwdev_next) { + fwdev = fwdev_next) { fwdev_next = STAILQ_NEXT(fwdev, link); free(fwdev, M_FW); } @@ -561,16 +552,8 @@ firewire_detach(device_t dev) mtx_destroy(&fc->tlabel_lock); mtx_destroy(&fc->wait_lock); - return(0); + return (0); } -#if 0 -static int -firewire_shutdown( device_t dev ) -{ - return 0; -} -#endif - static void fw_xferq_drain(struct fw_xferq *xferq) @@ -580,7 +563,7 @@ fw_xferq_drain(struct fw_xferq *xferq) while ((xfer = STAILQ_FIRST(&xferq->q)) != NULL) { STAILQ_REMOVE_HEAD(&xferq->q, link); #if 0 - xferq->queued --; + xferq->queued--; #endif xfer->resp = EAGAIN; xfer->flag = FWXF_SENTERR; @@ -600,12 +583,12 @@ fw_drain_txq(struct firewire_comm *fc) FW_GLOCK(fc); fw_xferq_drain(fc->atq); fw_xferq_drain(fc->ats); - for(i = 0; i < fc->nisodma; i++) + for (i = 0; i < fc->nisodma; i++) fw_xferq_drain(fc->it[i]); FW_GUNLOCK(fc); mtx_lock(&fc->tlabel_lock); - for (i = 0; i < 0x40; i ++) + for (i = 0; i < 0x40; i++) while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) { if (firewire_debug) printf("tl=%d flag=%d\n", i, xfer->flag); @@ -617,7 +600,7 @@ fw_drain_txq(struct firewire_comm *fc) mtx_unlock(&fc->tlabel_lock); STAILQ_FOREACH_SAFE(xfer, &xfer_drain, tlabel, txfer) - xfer->hand(xfer); + xfer->hand(xfer); } static void @@ -626,7 +609,7 @@ fw_reset_csr(struct firewire_comm *fc) int i; CSRARC(fc, STATE_CLEAR) - = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14 ; + = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14; CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); CSRARC(fc, NODE_IDS) = 0x3f; @@ -635,10 +618,10 @@ fw_reset_csr(struct firewire_comm *fc) fc->max_node = -1; - for(i = 2; i < 0x100/4 - 2 ; i++){ + for (i = 2; i < 0x100 / 4 - 2; i++) { CSRARC(fc, SPED_MAP + i * 4) = 0; } - CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14 ; + CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14; CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); CSRARC(fc, RESET_START) = 0; CSRARC(fc, SPLIT_TIMEOUT_HI) = 0; @@ -654,14 +637,14 @@ fw_reset_csr(struct firewire_comm *fc) CSRARC(fc, CONF_ROM) = 0x04 << 24; CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */ CSRARC(fc, CONF_ROM + 8) = 1 << 31 | 1 << 30 | 1 << 29 | - 1 << 28 | 0xff << 16 | 0x09 << 8; + 1 << 28 | 0xff << 16 | 0x09 << 8; CSRARC(fc, CONF_ROM + 0xc) = 0; -/* DV depend CSRs see blue book */ - CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; - CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; + /* DV depend CSRs see blue book */ + CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; + CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; - CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14 ); + CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14); CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); } @@ -717,13 +700,8 @@ fw_reset_crom(struct firewire_comm *fc) crom_add_entry(root, CSRKEY_NCAP, 0x0083c0); /* XXX */ /* private company_id */ crom_add_entry(root, CSRKEY_VENDOR, CSRVAL_VENDOR_PRIVATE); -#ifdef __DragonFly__ - crom_add_simple_text(src, root, &buf->vendor, "DragonFly Project"); - crom_add_entry(root, CSRKEY_HW, __DragonFly_cc_version); -#else crom_add_simple_text(src, root, &buf->vendor, "FreeBSD Project"); crom_add_entry(root, CSRKEY_HW, __FreeBSD_version); -#endif mtx_lock(&prison0.pr_mtx); crom_add_simple_text(src, root, &buf->hw, prison0.pr_hostname); mtx_unlock(&prison0.pr_mtx); @@ -754,8 +732,8 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status) fw_reset_crom(fc); if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { - for( i = 0 ; i < devcnt ; i++) - if (device_get_state(devlistp[i]) >= DS_ATTACHED) { + for (i = 0; i < devcnt; i++) + if (device_get_state(devlistp[i]) >= DS_ATTACHED) { fdc = device_get_softc(devlistp[i]); if (fdc->post_busreset != NULL) fdc->post_busreset(fdc); @@ -764,31 +742,30 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status) } src = &fc->crom_src_buf->src; - /* - * If the old config rom needs to be overwritten, - * bump the businfo.generation indicator to - * indicate that we need to be reprobed - * See 1394a-2000 8.3.2.5.4 for more details. - * generation starts at 2 and rolls over at 0xF - * back to 2. - * - * A generation of 0 indicates a device - * that is not 1394a-2000 compliant. - * A generation of 1 indicates a device that - * does not change it's Bus Info Block or - * Configuration ROM. - */ + /* + * If the old config rom needs to be overwritten, + * bump the businfo.generation indicator to + * indicate that we need to be reprobed + * See 1394a-2000 8.3.2.5.4 for more details. + * generation starts at 2 and rolls over at 0xF + * back to 2. + * + * A generation of 0 indicates a device + * that is not 1394a-2000 compliant. + * A generation of 1 indicates a device that + * does not change it's Bus Info Block or + * Configuration ROM. + */ #define FW_MAX_GENERATION 0xF newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO); src = &fc->crom_src_buf->src; crom_load(src, newrom, CROMSIZE); if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) { - if ( src->businfo.generation++ > FW_MAX_GENERATION ) + if (src->businfo.generation++ > FW_MAX_GENERATION) src->businfo.generation = FW_GENERATION_CHANGEABLE; - bcopy(newrom, (void *)fc->config_rom, CROMSIZE); + bcopy(newrom, fc->config_rom, CROMSIZE); } free(newrom, M_FW); - } /* Call once after reboot */ @@ -818,7 +795,7 @@ void fw_init(struct firewire_comm *fc) STAILQ_INIT(&fc->atq->q); STAILQ_INIT(&fc->ats->q); - for( i = 0 ; i < fc->nisodma ; i ++ ){ + for (i = 0; i < fc->nisodma; i++) { fc->it[i]->queued = 0; fc->ir[i]->queued = 0; @@ -840,7 +817,7 @@ void fw_init(struct firewire_comm *fc) fc->atq->maxq = FWMAXQUEUE; fc->ats->maxq = FWMAXQUEUE; - for( i = 0 ; i < fc->nisodma ; i++){ + for (i = 0; i < fc->nisodma; i++) { fc->ir[i]->maxq = FWMAXQUEUE; fc->it[i]->maxq = FWMAXQUEUE; } @@ -852,9 +829,9 @@ void fw_init(struct firewire_comm *fc) STAILQ_INIT(&fc->devices); -/* Initialize Async handlers */ + /* Initialize Async handlers */ STAILQ_INIT(&fc->binds); - for( i = 0 ; i < 0x40 ; i++){ + for (i = 0; i < 0x40; i++) { STAILQ_INIT(&fc->tlabels[i]); } @@ -862,14 +839,14 @@ void fw_init(struct firewire_comm *fc) #if 0 CSRARC(fc, oMPR) = 0x3fff0001; /* # output channel = 1 */ CSRARC(fc, oPCR) = 0x8000007a; - for(i = 4 ; i < 0x7c/4 ; i+=4){ - CSRARC(fc, i + oPCR) = 0x8000007a; + for (i = 4; i < 0x7c/4; i += 4) { + CSRARC(fc, i + oPCR) = 0x8000007a; } - + CSRARC(fc, iMPR) = 0x00ff0001; /* # input channel = 1 */ CSRARC(fc, iPCR) = 0x803f0000; - for(i = 4 ; i < 0x7c/4 ; i+=4){ - CSRARC(fc, i + iPCR) = 0x0; + for (i = 4; i < 0x7c/4; i += 4) { + CSRARC(fc, i + iPCR) = 0x0; } #endif @@ -877,10 +854,11 @@ void fw_init(struct firewire_comm *fc) #ifdef FW_VMACCESS xfer = fw_xfer_alloc(); - if(xfer == NULL) return; + if (xfer == NULL) + return; - fwb = (struct fw_bind *)malloc(sizeof (struct fw_bind), M_FW, M_NOWAIT); - if(fwb == NULL){ + fwb = malloc(sizeof(struct fw_bind), M_FW, M_NOWAIT); + if (fwb == NULL) { fw_xfer_free(xfer); return; } @@ -896,8 +874,8 @@ void fw_init(struct firewire_comm *fc) #endif } -#define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)?-1:\ - ((fwb)->end < (addr))?1:0) +#define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)? -1 : \ + ((fwb)->end < (addr)) ? 1 : 0) /* * To lookup bound process from IEEE1394 address. @@ -916,7 +894,7 @@ fw_bindlookup(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo) break; } FW_GUNLOCK(fc); - return(r); + return (r); } /* @@ -1001,7 +979,7 @@ fw_xferlist_add(struct fw_xferlist *q, struct malloc_type *type, for (i = 0; i < n; i++) { xfer = fw_xfer_alloc_buf(type, slen, rlen); if (xfer == NULL) - return (n); + return (i); xfer->fc = fc; xfer->sc = sc; xfer->hand = hand; @@ -1018,10 +996,10 @@ fw_xferlist_remove(struct fw_xferlist *q) struct fw_xfer *xfer, *next; for (xfer = STAILQ_FIRST(q); xfer != NULL; xfer = next) { - next = STAILQ_NEXT(xfer, link); - fw_xfer_free_buf(xfer); - } - STAILQ_INIT(q); + next = STAILQ_NEXT(xfer, link); + fw_xfer_free_buf(xfer); + } + STAILQ_INIT(q); } /* * dump packet header @@ -1052,9 +1030,9 @@ fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) mtx_unlock(&fc->tlabel_lock); return; } -#if 1 /* make sure the label is allocated */ + /* make sure the label is allocated */ STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel) - if(txfer == xfer) + if (txfer == xfer) break; if (txfer == NULL) { printf("%s: the xfer is not in the queue " @@ -1067,7 +1045,6 @@ fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer) splx(s); return; } -#endif STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel); xfer->tl = -1; @@ -1088,7 +1065,7 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) mtx_lock(&fc->tlabel_lock); STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) - if(xfer->send.hdr.mode.hdr.dst == node) { + if (xfer->send.hdr.mode.hdr.dst == node) { mtx_unlock(&fc->tlabel_lock); splx(s); KASSERT(xfer->tl == tlabel, @@ -1099,18 +1076,18 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) printf("%s: invalid response tcode " "(0x%x for 0x%x)\n", __FUNCTION__, tcode, req); - return(NULL); + return (NULL); } - + if (firewire_debug > 2) printf("fw_tl2xfer: found tl=%d\n", tlabel); - return(xfer); + return (xfer); } mtx_unlock(&fc->tlabel_lock); if (firewire_debug > 1) printf("fw_tl2xfer: not found tl=%d\n", tlabel); splx(s); - return(NULL); + return (NULL); } /* @@ -1137,14 +1114,14 @@ fw_xfer_alloc_buf(struct malloc_type *type, int send_len, int recv_len) xfer = fw_xfer_alloc(type); if (xfer == NULL) - return(NULL); + return (NULL); xfer->send.pay_len = send_len; xfer->recv.pay_len = recv_len; if (send_len > 0) { xfer->send.payload = malloc(send_len, type, M_NOWAIT | M_ZERO); if (xfer->send.payload == NULL) { fw_xfer_free(xfer); - return(NULL); + return (NULL); } } if (recv_len > 0) { @@ -1153,10 +1130,10 @@ fw_xfer_alloc_buf(struct malloc_type *type, int send_len, int recv_len) if (xfer->send.payload != NULL) free(xfer->send.payload, type); fw_xfer_free(xfer); - return(NULL); + return (NULL); } } - return(xfer); + return (xfer); } /* @@ -1178,18 +1155,19 @@ fw_xfer_done(struct fw_xfer *xfer) } void -fw_xfer_unload(struct fw_xfer* xfer) +fw_xfer_unload(struct fw_xfer *xfer) { int s; - if(xfer == NULL ) return; - if(xfer->flag & FWXF_INQ){ + if (xfer == NULL) + return; + if (xfer->flag & FWXF_INQ) { printf("fw_xfer_free FWXF_INQ\n"); s = splfw(); FW_GLOCK(xfer->fc); STAILQ_REMOVE(&xfer->q->q, xfer, fw_xfer, link); #if 0 - xfer->q->queued --; + xfer->q->queued--; #endif FW_GUNLOCK(xfer->fc); splx(s); @@ -1201,7 +1179,7 @@ fw_xfer_unload(struct fw_xfer* xfer) */ fw_tl_free(xfer->fc, xfer); #if 1 - if(xfer->flag & FWXF_START) + if (xfer->flag & FWXF_START) /* * This could happen if: * 1. We call fwohci_arcv() before fwohci_txd(). @@ -1213,28 +1191,27 @@ fw_xfer_unload(struct fw_xfer* xfer) xfer->flag = FWXF_INIT; xfer->resp = 0; } + /* - * To free IEEE1394 XFER structure. + * To free IEEE1394 XFER structure. */ void -fw_xfer_free_buf( struct fw_xfer* xfer) +fw_xfer_free_buf(struct fw_xfer *xfer) { if (xfer == NULL) { printf("%s: xfer == NULL\n", __func__); return; } fw_xfer_unload(xfer); - if(xfer->send.payload != NULL){ + if (xfer->send.payload != NULL) free(xfer->send.payload, xfer->malloc); - } - if(xfer->recv.payload != NULL){ + if (xfer->recv.payload != NULL) free(xfer->recv.payload, xfer->malloc); - } free(xfer, xfer->malloc); } void -fw_xfer_free( struct fw_xfer* xfer) +fw_xfer_free(struct fw_xfer *xfer) { if (xfer == NULL) { printf("%s: xfer == NULL\n", __func__); @@ -1255,7 +1232,7 @@ fw_asy_callback_free(struct fw_xfer *xfer) } /* - * To configure PHY. + * To configure PHY. */ static void fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) @@ -1274,9 +1251,9 @@ fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) fp = &xfer->send.hdr; fp->mode.ld[1] = 0; if (root_node >= 0) - fp->mode.ld[1] |= (root_node & 0x3f) << 24 | 1 << 23; + fp->mode.ld[1] |= (1 << 23) | (root_node & 0x3f) << 24; if (gap_count >= 0) - fp->mode.ld[1] |= 1 << 22 | (gap_count & 0x3f) << 16; + fp->mode.ld[1] |= (1 << 22) | (gap_count & 0x3f) << 16; fp->mode.ld[2] = ~fp->mode.ld[1]; /* XXX Dangerous, how to pass PHY packet to device driver */ fp->mode.common.tcode |= FWTCODE_PHY; @@ -1288,113 +1265,107 @@ fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) } /* - * Dump self ID. + * Dump self ID. */ static void fw_print_sid(uint32_t sid) { union fw_self_id *s; s = (union fw_self_id *) &sid; - if ( s->p0.sequel ) { - if ( s->p1.sequence_num == FW_SELF_ID_PAGE0 ) { + if (s->p0.sequel) { + if (s->p1.sequence_num == FW_SELF_ID_PAGE0) { printf("node:%d p3:%d p4:%d p5:%d p6:%d p7:%d" - "p8:%d p9:%d p10:%d\n", - s->p1.phy_id, s->p1.port3, s->p1.port4, - s->p1.port5, s->p1.port6, s->p1.port7, - s->p1.port8, s->p1.port9, s->p1.port10); - } else if (s->p2.sequence_num == FW_SELF_ID_PAGE1 ){ + "p8:%d p9:%d p10:%d\n", + s->p1.phy_id, s->p1.port3, s->p1.port4, + s->p1.port5, s->p1.port6, s->p1.port7, + s->p1.port8, s->p1.port9, s->p1.port10); + } else if (s->p2.sequence_num == FW_SELF_ID_PAGE1) { printf("node:%d p11:%d p12:%d p13:%d p14:%d p15:%d\n", - s->p2.phy_id, s->p2.port11, s->p2.port12, - s->p2.port13, s->p2.port14, s->p2.port15); + s->p2.phy_id, s->p2.port11, s->p2.port12, + s->p2.port13, s->p2.port14, s->p2.port15); } else { printf("node:%d Unknown Self ID Page number %d\n", - s->p1.phy_id, s->p1.sequence_num); + s->p1.phy_id, s->p1.sequence_num); } } else { printf("node:%d link:%d gap:%d spd:%d con:%d pwr:%d" - " p0:%d p1:%d p2:%d i:%d m:%d\n", - s->p0.phy_id, s->p0.link_active, s->p0.gap_count, - s->p0.phy_speed, s->p0.contender, - s->p0.power_class, s->p0.port0, s->p0.port1, - s->p0.port2, s->p0.initiated_reset, s->p0.more_packets); + " p0:%d p1:%d p2:%d i:%d m:%d\n", + s->p0.phy_id, s->p0.link_active, s->p0.gap_count, + s->p0.phy_speed, s->p0.contender, + s->p0.power_class, s->p0.port0, s->p0.port1, + s->p0.port2, s->p0.initiated_reset, s->p0.more_packets); } } /* - * To receive self ID. + * To receive self ID. */ -void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) +void fw_sidrcv(struct firewire_comm *fc, uint32_t *sid, u_int len) { uint32_t *p; union fw_self_id *self_id; u_int i, j, node, c_port = 0, i_branch = 0; - fc->sid_cnt = len /(sizeof(uint32_t) * 2); + fc->sid_cnt = len / (sizeof(uint32_t) * 2); fc->max_node = fc->nodeid & 0x3f; CSRARC(fc, NODE_IDS) = ((uint32_t)fc->nodeid) << 16; fc->status = FWBUSCYMELECT; fc->topology_map->crc_len = 2; - fc->topology_map->generation ++; + fc->topology_map->generation++; fc->topology_map->self_id_count = 0; - fc->topology_map->node_count = 0; - fc->speed_map->generation ++; - fc->speed_map->crc_len = 1 + (64*64 + 3) / 4; + fc->topology_map->node_count= 0; + fc->speed_map->generation++; + fc->speed_map->crc_len = 1 + (64 * 64 + 3) / 4; self_id = &fc->topology_map->self_id[0]; - for(i = 0; i < fc->sid_cnt; i ++){ + for (i = 0; i < fc->sid_cnt; i++) { if (sid[1] != ~sid[0]) { - device_printf(fc->bdev, "%s: ERROR invalid self-id packet\n", - __func__); + device_printf(fc->bdev, + "%s: ERROR invalid self-id packet\n", __func__); sid += 2; continue; } *self_id = *((union fw_self_id *)sid); fc->topology_map->crc_len++; - if(self_id->p0.sequel == 0){ - fc->topology_map->node_count ++; + if (self_id->p0.sequel == 0) { + fc->topology_map->node_count++; c_port = 0; if (firewire_debug) fw_print_sid(sid[0]); node = self_id->p0.phy_id; - if(fc->max_node < node){ + if (fc->max_node < node) fc->max_node = self_id->p0.phy_id; - } /* XXX I'm not sure this is the right speed_map */ - fc->speed_map->speed[node][node] - = self_id->p0.phy_speed; - for (j = 0; j < node; j ++) { - fc->speed_map->speed[j][node] - = fc->speed_map->speed[node][j] - = min(fc->speed_map->speed[j][j], - self_id->p0.phy_speed); + fc->speed_map->speed[node][node] = + self_id->p0.phy_speed; + for (j = 0; j < node; j++) { + fc->speed_map->speed[j][node] = + fc->speed_map->speed[node][j] = + min(fc->speed_map->speed[j][j], + self_id->p0.phy_speed); } if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) && - (self_id->p0.link_active && self_id->p0.contender)) { + (self_id->p0.link_active && self_id->p0.contender)) fc->irm = self_id->p0.phy_id; - } - if(self_id->p0.port0 >= 0x2){ + if (self_id->p0.port0 >= 0x2) c_port++; - } - if(self_id->p0.port1 >= 0x2){ + if (self_id->p0.port1 >= 0x2) c_port++; - } - if(self_id->p0.port2 >= 0x2){ + if (self_id->p0.port2 >= 0x2) c_port++; - } } - if(c_port > 2){ + if (c_port > 2) i_branch += (c_port - 2); - } sid += 2; self_id++; - fc->topology_map->self_id_count ++; + fc->topology_map->self_id_count++; } /* CRC */ fc->topology_map->crc = fw_crc16( - (uint32_t *)&fc->topology_map->generation, - fc->topology_map->crc_len * 4); + (uint32_t *)&fc->topology_map->generation, + fc->topology_map->crc_len * 4); fc->speed_map->crc = fw_crc16( - (uint32_t *)&fc->speed_map->generation, - fc->speed_map->crc_len * 4); + (uint32_t *)&fc->speed_map->generation, + fc->speed_map->crc_len * 4); /* byteswap and copy to CSR */ p = (uint32_t *)fc->topology_map; for (i = 0; i <= fc->topology_map->crc_len; i++) @@ -1403,14 +1374,13 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) CSRARC(fc, SPED_MAP) = htonl(*p++); CSRARC(fc, SPED_MAP + 4) = htonl(*p++); /* don't byte-swap uint8_t array */ - bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1)*4); + bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1) * 4); fc->max_hop = fc->max_node - i_branch; device_printf(fc->bdev, "%d nodes, maxhop <= %d %s irm(%d) %s\n", - fc->max_node + 1, fc->max_hop, - (fc->irm == -1) ? "Not IRM capable" : "cable IRM", - fc->irm, - (fc->irm == fc->nodeid) ? " (me) " : ""); + fc->max_node + 1, fc->max_hop, + (fc->irm == -1) ? "Not IRM capable" : "cable IRM", + fc->irm, (fc->irm == fc->nodeid) ? " (me) " : ""); if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) { if (fc->irm == fc->nodeid) { @@ -1419,26 +1389,27 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) fw_bmr(fc); } else { fc->status = FWBUSMGRELECT; - callout_reset(&fc->bmr_callout, hz/8, - (void *)fw_try_bmr, (void *)fc); + callout_reset(&fc->bmr_callout, hz / 8, + fw_try_bmr, fc); } } else fc->status = FWBUSMGRDONE; - callout_reset(&fc->busprobe_callout, hz/4, - (void *)fw_bus_probe, (void *)fc); + callout_reset(&fc->busprobe_callout, hz / 4, fw_bus_probe, fc); } /* - * To probe devices on the IEEE1394 bus. + * To probe devices on the IEEE1394 bus. */ static void -fw_bus_probe(struct firewire_comm *fc) +fw_bus_probe(void *arg) { - int s; + struct firewire_comm *fc; struct fw_device *fwdev; + int s; s = splfw(); + fc = arg; fc->status = FWBUSEXPLORE; /* Invalidate all devices, just after bus reset. */ @@ -1462,7 +1433,7 @@ fw_bus_probe(struct firewire_comm *fc) } splx(s); - wakeup((void *)fc); + wakeup(fc); } static int @@ -1473,10 +1444,9 @@ fw_explore_read_quads(struct fw_device *fwdev, int offset, uint32_t tmp; int i, error; - for (i = 0; i < length; i ++, offset += sizeof(uint32_t)) { - xfer = fwmem_read_quad(fwdev, NULL, -1, - 0xffff, 0xf0000000 | offset, (void *)&tmp, - fw_xferwake); + for (i = 0; i < length; i++, offset += sizeof(uint32_t)) { + xfer = fwmem_read_quad(fwdev, NULL, -1, 0xffff, + 0xf0000000 | offset, &tmp, fw_xferwake); if (xfer == NULL) return (-1); fw_xferwait(xfer); @@ -1500,14 +1470,14 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur) struct csrdirectory *dir; struct csrreg *reg; - dir = (struct csrdirectory *)&fwdev->csrrom[offset/sizeof(uint32_t)]; + dir = (struct csrdirectory *)&fwdev->csrrom[offset / sizeof(uint32_t)]; err = fw_explore_read_quads(fwdev, CSRROMOFF + offset, (uint32_t *)dir, 1); if (err) return (-1); offset += sizeof(uint32_t); - reg = (struct csrreg *)&fwdev->csrrom[offset/sizeof(uint32_t)]; + reg = (struct csrreg *)&fwdev->csrrom[offset / sizeof(uint32_t)]; err = fw_explore_read_quads(fwdev, CSRROMOFF + offset, (uint32_t *)reg, dir->crc_len); if (err) @@ -1522,7 +1492,7 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur) if (recur == 0) return (0); - for (i = 0; i < dir->crc_len; i ++, offset += sizeof(uint32_t)) { + for (i = 0; i < dir->crc_len; i++, offset += sizeof(uint32_t)) { if ((reg[i].key & CSRTYPE_MASK) == CSRTYPE_D) recur = 1; else if ((reg[i].key & CSRTYPE_MASK) == CSRTYPE_L) @@ -1533,7 +1503,7 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur) off = offset + reg[i].val * sizeof(uint32_t); if (off > CROMSIZE) { printf("%s: invalid offset %d\n", __FUNCTION__, off); - return(-1); + return (-1); } err = fw_explore_csrblock(fwdev, off, recur); if (err) @@ -1560,15 +1530,14 @@ fw_explore_node(struct fw_device *dfwdev) /* First quad */ err = fw_explore_read_quads(dfwdev, CSRROMOFF, &csr[0], 1); if (err) { - device_printf(fc->bdev, "%s: node%d: explore_read_quads failure\n", - __func__, node); dfwdev->status = FWDEVINVAL; return (-1); } hdr = (struct csrhdr *)&csr[0]; if (hdr->info_len != 4) { if (firewire_debug) - device_printf(fc->bdev, "%s: node%d: wrong bus info len(%d)\n", + device_printf(fc->bdev, + "%s: node%d: wrong bus info len(%d)\n", __func__, node, hdr->info_len); dfwdev->status = FWDEVINVAL; return (-1); @@ -1577,29 +1546,25 @@ fw_explore_node(struct fw_device *dfwdev) /* bus info */ err = fw_explore_read_quads(dfwdev, CSRROMOFF + 0x04, &csr[1], 4); if (err) { - device_printf(fc->bdev, "%s: node%d: error reading 0x04\n", - __func__, node); dfwdev->status = FWDEVINVAL; return (-1); } binfo = (struct bus_info *)&csr[1]; if (binfo->bus_name != CSR_BUS_NAME_IEEE1394) { - device_printf(fc->bdev, "%s: node%d: invalid bus name 0x%08x\n", - __func__, node, binfo->bus_name); dfwdev->status = FWDEVINVAL; return (-1); } if (firewire_debug) device_printf(fc->bdev, "%s: node(%d) BUS INFO BLOCK:\n" - "irmc(%d) cmc(%d) isc(%d) bmc(%d) pmc(%d) " - "cyc_clk_acc(%d) max_rec(%d) max_rom(%d) " - "generation(%d) link_spd(%d)\n", - __func__, node, - binfo->irmc, binfo->cmc, binfo->isc, - binfo->bmc, binfo->pmc, binfo->cyc_clk_acc, - binfo->max_rec, binfo->max_rom, - binfo->generation, binfo->link_spd); + "irmc(%d) cmc(%d) isc(%d) bmc(%d) pmc(%d) " + "cyc_clk_acc(%d) max_rec(%d) max_rom(%d) " + "generation(%d) link_spd(%d)\n", + __func__, node, + binfo->irmc, binfo->cmc, binfo->isc, + binfo->bmc, binfo->pmc, binfo->cyc_clk_acc, + binfo->max_rec, binfo->max_rom, + binfo->generation, binfo->link_spd); STAILQ_FOREACH(fwdev, &fc->devices, link) if (FW_EUI64_EQUAL(fwdev->eui, binfo->eui64)) @@ -1607,7 +1572,7 @@ fw_explore_node(struct fw_device *dfwdev) if (fwdev == NULL) { /* new device */ fwdev = malloc(sizeof(struct fw_device), M_FW, - M_NOWAIT | M_ZERO); + M_NOWAIT | M_ZERO); if (fwdev == NULL) { device_printf(fc->bdev, "%s: node%d: no memory\n", __func__, node); @@ -1621,16 +1586,15 @@ fw_explore_node(struct fw_device *dfwdev) /* * Pre-1394a-2000 didn't have link_spd in - * the Bus Info block, so try and use the + * the Bus Info block, so try and use the * speed map value. * 1394a-2000 compliant devices only use * the Bus Info Block link spd value, so * ignore the speed map alltogether. SWB */ - if ( binfo->link_spd == FWSPD_S100 /* 0 */) { + if (binfo->link_spd == FWSPD_S100 /* 0 */) { device_printf(fc->bdev, "%s: " - "Pre 1394a-2000 detected\n", - __func__); + "Pre 1394a-2000 detected\n", __func__); fwdev->speed = fc->speed_map->speed[fc->nodeid][node]; } else fwdev->speed = binfo->link_spd; @@ -1640,20 +1604,19 @@ fw_explore_node(struct fw_device *dfwdev) */ while (fwdev->speed > FWSPD_S100 /* 0 */) { err = fw_explore_read_quads(fwdev, CSRROMOFF, - &speed_test, 1); + &speed_test, 1); if (err) { - device_printf(fc->bdev, "%s: fwdev->speed(%s)" - " decremented due to negotiation\n", - __func__, - linkspeed[fwdev->speed]); + device_printf(fc->bdev, + "%s: fwdev->speed(%s) decremented due to negotiation\n", + __func__, linkspeed[fwdev->speed]); fwdev->speed--; } else break; - + } /* - * If the fwdev is not found in the + * If the fwdev is not found in the * fc->devices TAILQ, then we will add it. */ pfwdev = NULL; @@ -1668,17 +1631,14 @@ fw_explore_node(struct fw_device *dfwdev) STAILQ_INSERT_HEAD(&fc->devices, fwdev, link); else STAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link); - - device_printf(fc->bdev, "New %s device ID:%08x%08x\n", - linkspeed[fwdev->speed], - fwdev->eui.hi, fwdev->eui.lo); } else { fwdev->dst = node; fwdev->status = FWDEVINIT; /* unchanged ? */ if (bcmp(&csr[0], &fwdev->csrrom[0], sizeof(uint32_t) * 5) == 0) { if (firewire_debug) - device_printf(fc->dev, "node%d: crom unchanged\n", node); + device_printf(fc->dev, + "node%d: crom unchanged\n", node); return (0); } } @@ -1736,53 +1696,54 @@ fw_explore(struct firewire_comm *fc) dfwdev.maxrec = 8; /* 512 */ dfwdev.status = FWDEVINIT; - for (node = 0; node <= fc->max_node; node ++) { + for (node = 0; node <= fc->max_node; node++) { /* We don't probe myself and linkdown nodes */ if (node == fc->nodeid) { if (firewire_debug) device_printf(fc->bdev, "%s:" - "found myself node(%d) fc->nodeid(%d) fc->max_node(%d)\n", - __func__, node, fc->nodeid, fc->max_node); + "found myself node(%d) fc->nodeid(%d) fc->max_node(%d)\n", + __func__, node, fc->nodeid, fc->max_node); continue; } else if (firewire_debug) { device_printf(fc->bdev, "%s:" - "node(%d) fc->max_node(%d) found\n", - __func__, node, fc->max_node); + "node(%d) fc->max_node(%d) found\n", + __func__, node, fc->max_node); } fwsid = fw_find_self_id(fc, node); if (!fwsid || !fwsid->p0.link_active) { if (firewire_debug) - device_printf(fc->bdev, "%s: node%d: link down\n", - __func__, node); + device_printf(fc->bdev, + "%s: node%d: link down\n", + __func__, node); continue; } nodes[todo++] = node; } s = splfw(); - for (trys = 0; todo > 0 && trys < 3; trys ++) { + for (trys = 0; todo > 0 && trys < 3; trys++) { todo2 = 0; - for (i = 0; i < todo; i ++) { + for (i = 0; i < todo; i++) { dfwdev.dst = nodes[i]; err = fw_explore_node(&dfwdev); if (err) nodes[todo2++] = nodes[i]; if (firewire_debug) - device_printf(fc->bdev, "%s: node %d, err = %d\n", - __func__, node, err); + device_printf(fc->bdev, + "%s: node %d, err = %d\n", + __func__, node, err); } todo = todo2; } splx(s); } - static void fw_bus_probe_thread(void *arg) { struct firewire_comm *fc; - fc = (struct firewire_comm *)arg; + fc = arg; mtx_lock(&fc->wait_lock); while (fc->status != FWBUSDETACH) { @@ -1818,19 +1779,16 @@ fw_attach_dev(struct firewire_comm *fc) if (fwdev->status == FWDEVINIT) { fwdev->status = FWDEVATTACHED; } else if (fwdev->status == FWDEVINVAL) { - fwdev->rcnt ++; + fwdev->rcnt++; if (firewire_debug) device_printf(fc->bdev, "%s:" - "fwdev->rcnt(%d), hold_count(%d)\n", - __func__, fwdev->rcnt, hold_count); + "fwdev->rcnt(%d), hold_count(%d)\n", + __func__, fwdev->rcnt, hold_count); if (fwdev->rcnt > hold_count) { /* * Remove devices which have not been seen * for a while. */ - device_printf(fc->bdev, "%s:" - "Removing missing device ID:%08x%08x\n", - __func__, fwdev->eui.hi, fwdev->eui.lo); STAILQ_REMOVE(&fc->devices, fwdev, fw_device, link); free(fwdev, M_FW); @@ -1839,9 +1797,9 @@ fw_attach_dev(struct firewire_comm *fc) } err = device_get_children(fc->bdev, &devlistp, &devcnt); - if( err == 0 ) { - for( i = 0 ; i < devcnt ; i++){ - if (device_get_state(devlistp[i]) >= DS_ATTACHED) { + if (err == 0) { + for (i = 0; i < devcnt; i++) { + if (device_get_state(devlistp[i]) >= DS_ATTACHED) { fdc = device_get_softc(devlistp[i]); if (fdc->post_explore != NULL) fdc->post_explore(fdc); @@ -1869,8 +1827,8 @@ fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer) new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f; STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel) if ((txfer->send.hdr.mode.hdr.dst & 0x3f) == dst) - break; - if(txfer == NULL) { + break; + if (txfer == NULL) { fc->last_tlabel[dst] = new_tlabel; STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel); mtx_unlock(&fc->tlabel_lock); @@ -1902,7 +1860,7 @@ fw_rcv_copy(struct fw_rcv_buf *rb) pkt = (struct fw_pkt *)rb->vec->iov_base; tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode]; - /* Copy header */ + /* Copy header */ p = (u_char *)&rb->xfer->recv.hdr; bcopy(rb->vec->iov_base, p, tinfo->hdr_len); rb->vec->iov_base = (u_char *)rb->vec->iov_base + tinfo->hdr_len; @@ -1941,7 +1899,6 @@ fw_rcv_copy(struct fw_rcv_buf *rb) break; } rb->xfer->recv.pay_len -= res; - } /* @@ -1960,11 +1917,11 @@ fw_rcv(struct fw_rcv_buf *rb) int i; qld = (uint32_t *)buf; printf("spd %d len:%d\n", spd, len); - for( i = 0 ; i <= len && i < 32; i+= 4){ + for (i = 0; i <= len && i < 32; i+= 4) { printf("0x%08x ", ntohl(qld[i/4])); - if((i % 16) == 15) printf("\n"); + if ((i % 16) == 15) printf("\n"); } - if((i % 16) != 15) printf("\n"); + if ((i % 16) != 15) printf("\n"); } #endif fp = (struct fw_pkt *)rb->vec[0].iov_base; @@ -1976,20 +1933,19 @@ fw_rcv(struct fw_rcv_buf *rb) case FWTCODE_LRES: rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, fp->mode.hdr.tlrt >> 2, fp->mode.hdr.tcode); - if(rb->xfer == NULL) { - device_printf(rb->fc->bdev, "%s: " - "unknown response " - "%s(%x) src=0x%x tl=0x%x rt=%d data=0x%x\n", - __func__, - tcode_str[tcode], tcode, - fp->mode.hdr.src, - fp->mode.hdr.tlrt >> 2, - fp->mode.hdr.tlrt & 3, - fp->mode.rresq.data); + if (rb->xfer == NULL) { + device_printf(rb->fc->bdev, "%s: unknown response " + "%s(%x) src=0x%x tl=0x%x rt=%d data=0x%x\n", + __func__, + tcode_str[tcode], tcode, + fp->mode.hdr.src, + fp->mode.hdr.tlrt >> 2, + fp->mode.hdr.tlrt & 3, + fp->mode.rresq.data); #if 0 printf("try ad-hoc work around!!\n"); rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src, - (fp->mode.hdr.tlrt >> 2)^3); + (fp->mode.hdr.tlrt >> 2)^3); if (rb->xfer == NULL) { printf("no use...\n"); return; @@ -2018,7 +1974,8 @@ fw_rcv(struct fw_rcv_buf *rb) break; default: device_printf(rb->fc->bdev, "%s: " - "unexpected flag 0x%02x\n", __func__, rb->xfer->flag); + "unexpected flag 0x%02x\n", __func__, + rb->xfer->flag); } return; case FWTCODE_WREQQ: @@ -2027,29 +1984,26 @@ fw_rcv(struct fw_rcv_buf *rb) case FWTCODE_RREQB: case FWTCODE_LREQ: bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi, - fp->mode.rreqq.dest_lo); - if(bind == NULL){ + fp->mode.rreqq.dest_lo); + if (bind == NULL) { device_printf(rb->fc->bdev, "%s: " - "Unknown service addr 0x%04x:0x%08x %s(%x)" -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - " src=0x%x data=%lx\n", -#else - " src=0x%x data=%x\n", -#endif - __func__, - fp->mode.wreqq.dest_hi, - fp->mode.wreqq.dest_lo, - tcode_str[tcode], tcode, - fp->mode.hdr.src, - ntohl(fp->mode.wreqq.data)); + "Unknown service addr 0x%04x:0x%08x %s(%x)" + " src=0x%x data=%x\n", + __func__, + fp->mode.wreqq.dest_hi, + fp->mode.wreqq.dest_lo, + tcode_str[tcode], tcode, + fp->mode.hdr.src, + ntohl(fp->mode.wreqq.data)); if (rb->fc->status == FWBUSINIT) { - device_printf(rb->fc->bdev, "%s: cannot respond(bus reset)!\n", - __func__); + device_printf(rb->fc->bdev, + "%s: cannot respond(bus reset)!\n", + __func__); return; } rb->xfer = fw_xfer_alloc(M_FWXFER); - if(rb->xfer == NULL){ + if (rb->xfer == NULL) { return; } rb->xfer->send.spd = rb->spd; @@ -2080,20 +2034,16 @@ fw_rcv(struct fw_rcv_buf *rb) rb->xfer->hand = fw_xferwake; */ rb->xfer->hand = fw_xfer_free; - if(fw_asyreq(rb->fc, -1, rb->xfer)){ + if (fw_asyreq(rb->fc, -1, rb->xfer)) fw_xfer_free(rb->xfer); - return; - } - return; } len = 0; - for (i = 0; i < rb->nvec; i ++) + for (i = 0; i < rb->nvec; i++) len += rb->vec[i].iov_len; rb->xfer = STAILQ_FIRST(&bind->xferlist); if (rb->xfer == NULL) { device_printf(rb->fc->bdev, "%s: " - "Discard a packet for this bind.\n", - __func__); + "Discard a packet for this bind.\n", __func__); return; } STAILQ_REMOVE_HEAD(&bind->xferlist, link); @@ -2110,11 +2060,11 @@ fw_rcv(struct fw_rcv_buf *rb) printf("stream rcv dma %d len %d off %d spd %d\n", sub, len, off, spd); #endif - if(xferq->queued >= xferq->maxq) { + if (xferq->queued >= xferq->maxq) { printf("receive queue is full\n"); return; } - /* XXX get xfer from xfer queue, we don't need copy for + /* XXX get xfer from xfer queue, we don't need copy for per packet mode */ rb->xfer = fw_xfer_alloc_buf(M_FWXFER, 0, /* XXX */ vec[0].iov_len); @@ -2126,11 +2076,7 @@ fw_rcv(struct fw_rcv_buf *rb) STAILQ_INSERT_TAIL(&xferq->q, rb->xfer, link); splx(s); sc = device_get_softc(rb->fc->bdev); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - if (&xferq->rsel.si_pid != 0) -#else if (SEL_WAITING(&xferq->rsel)) -#endif selwakeuppri(&xferq->rsel, FWPRI); if (xferq->flag & FWXFERQ_WAKEUP) { xferq->flag &= ~FWXFERQ_WAKEUP; @@ -2145,7 +2091,7 @@ fw_rcv(struct fw_rcv_buf *rb) #endif default: device_printf(rb->fc->bdev,"%s: unknown tcode %d\n", - __func__, tcode); + __func__, tcode); break; } } @@ -2191,14 +2137,13 @@ static void fw_try_bmr(void *arg) { struct fw_xfer *xfer; - struct firewire_comm *fc = (struct firewire_comm *)arg; + struct firewire_comm *fc = arg; struct fw_pkt *fp; int err = 0; xfer = fw_xfer_alloc_buf(M_FWXFER, 8, 4); - if(xfer == NULL){ + if (xfer == NULL) return; - } xfer->send.spd = 0; fc->status = FWBUSMGRELECT; @@ -2217,7 +2162,7 @@ fw_try_bmr(void *arg) xfer->hand = fw_try_bmr_callback; err = fw_asyreq(fc, -1, xfer); - if(err){ + if (err) { fw_xfer_free_buf(xfer); return; } @@ -2227,33 +2172,37 @@ fw_try_bmr(void *arg) #ifdef FW_VMACCESS /* * Software implementation for physical memory block access. - * XXX:Too slow, usef for debug purpose only. + * XXX:Too slow, useful for debug purpose only. */ static void -fw_vmaccess(struct fw_xfer *xfer){ +fw_vmaccess(struct fw_xfer *xfer) +{ struct fw_pkt *rfp, *sfp = NULL; uint32_t *ld = (uint32_t *)xfer->recv.buf; printf("vmaccess spd:%2x len:%03x data:%08x %08x %08x %08x\n", - xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]), ntohl(ld[3])); - printf("vmaccess data:%08x %08x %08x %08x\n", ntohl(ld[4]), ntohl(ld[5]), ntohl(ld[6]), ntohl(ld[7])); - if(xfer->resp != 0){ - fw_xfer_free( xfer); + xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]), + ntohl(ld[3])); + printf("vmaccess data:%08x %08x %08x %08x\n", ntohl(ld[4]), + ntohl(ld[5]), ntohl(ld[6]), ntohl(ld[7])); + if (xfer->resp != 0) { + fw_xfer_free(xfer); return; } - if(xfer->recv.buf == NULL){ - fw_xfer_free( xfer); + if (xfer->recv.buf == NULL) { + fw_xfer_free(xfer); return; } rfp = (struct fw_pkt *)xfer->recv.buf; - switch(rfp->mode.hdr.tcode){ + switch (rfp->mode.hdr.tcode) { /* XXX need fix for 64bit arch */ case FWTCODE_WREQB: xfer->send.buf = malloc(12, M_FW, M_NOWAIT); xfer->send.len = 12; sfp = (struct fw_pkt *)xfer->send.buf; bcopy(rfp->mode.wreqb.payload, - (caddr_t)ntohl(rfp->mode.wreqb.dest_lo), ntohs(rfp->mode.wreqb.len)); + (caddr_t)ntohl(rfp->mode.wreqb.dest_lo),s + ntohs(rfp->mode.wreqb.len)); sfp->mode.wres.tcode = FWTCODE_WRES; sfp->mode.wres.rtcode = 0; break; @@ -2261,15 +2210,18 @@ fw_vmaccess(struct fw_xfer *xfer){ xfer->send.buf = malloc(12, M_FW, M_NOWAIT); xfer->send.len = 12; sfp->mode.wres.tcode = FWTCODE_WRES; - *((uint32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) = rfp->mode.wreqq.data; + *((uint32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) = + rfp->mode.wreqq.data; sfp->mode.wres.rtcode = 0; break; case FWTCODE_RREQB: - xfer->send.buf = malloc(16 + rfp->mode.rreqb.len, M_FW, M_NOWAIT); + xfer->send.buf = malloc(16 + rfp->mode.rreqb.len, + M_FW, M_NOWAIT); xfer->send.len = 16 + ntohs(rfp->mode.rreqb.len); sfp = (struct fw_pkt *)xfer->send.buf; bcopy((caddr_t)ntohl(rfp->mode.rreqb.dest_lo), - sfp->mode.rresb.payload, (uint16_t)ntohs(rfp->mode.rreqb.len)); + sfp->mode.rresb.payload, + ntohs(rfp->mode.rreqb.len)); sfp->mode.rresb.tcode = FWTCODE_RRESB; sfp->mode.rresb.len = rfp->mode.rreqb.len; sfp->mode.rresb.rtcode = 0; @@ -2279,12 +2231,13 @@ fw_vmaccess(struct fw_xfer *xfer){ xfer->send.buf = malloc(16, M_FW, M_NOWAIT); xfer->send.len = 16; sfp = (struct fw_pkt *)xfer->send.buf; - sfp->mode.rresq.data = *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo)); + sfp->mode.rresq.data = + *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo)); sfp->mode.wres.tcode = FWTCODE_RRESQ; sfp->mode.rresb.rtcode = 0; break; default: - fw_xfer_free( xfer); + fw_xfer_free(xfer); return; } sfp->mode.hdr.dst = rfp->mode.hdr.src; @@ -2298,24 +2251,25 @@ fw_vmaccess(struct fw_xfer *xfer){ /**/ return; } -#endif +#endif /* * CRC16 check-sum for IEEE1394 register blocks. */ uint16_t -fw_crc16(uint32_t *ptr, uint32_t len){ +fw_crc16(uint32_t *ptr, uint32_t len) +{ uint32_t i, sum, crc = 0; int shift; len = (len + 3) & ~3; - for(i = 0 ; i < len ; i+= 4){ - for( shift = 28 ; shift >= 0 ; shift -= 4){ + for (i = 0; i < len; i += 4) { + for (shift = 28; shift >= 0; shift -= 4) { sum = ((crc >> 12) ^ (ptr[i/4] >> shift)) & 0xf; - crc = (crc << 4) ^ ( sum << 12 ) ^ ( sum << 5) ^ sum; + crc = (crc << 4) ^ (sum << 12) ^ (sum << 5) ^ sum; } crc &= 0xffff; } - return((uint16_t) crc); + return ((uint16_t) crc); } /* @@ -2340,7 +2294,7 @@ fw_bmr(struct firewire_comm *fc) cmstr = fc->max_node; else { device_printf(fc->bdev, - "root node is not cycle master capable\n"); + "root node is not cycle master capable\n"); /* XXX shall we be the cycle master? */ cmstr = fc->nodeid; /* XXX need bus reset */ @@ -2351,13 +2305,13 @@ fw_bmr(struct firewire_comm *fc) device_printf(fc->bdev, "bus manager %d %s\n", CSRARC(fc, BUS_MGR_ID), (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) ? "(me)" : ""); - if(CSRARC(fc, BUS_MGR_ID) != fc->nodeid) { + if (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) { /* We are not the bus manager */ - return(0); + return (0); } /* Optimize gapcount */ - if(fc->max_hop <= MAX_GAPHOP ) + if (fc->max_hop <= MAX_GAPHOP) fw_phy_config(fc, cmstr, gap_cnt[fc->max_hop]); /* If we are the cycle master, nothing to do */ if (cmstr == fc->nodeid || cmstr == -1) @@ -2372,7 +2326,7 @@ fw_bmr(struct firewire_comm *fc) /* Set cmstr bit on the cycle master */ quad = htonl(1 << 8); fwmem_write_quad(&fwdev, NULL, 0/*spd*/, - 0xffff, 0xf0000000 | STATE_SET, &quad, fw_asy_callback_free); + 0xffff, 0xf0000000 | STATE_SET, &quad, fw_asy_callback_free); return 0; } @@ -2390,7 +2344,7 @@ fw_open_isodma(struct firewire_comm *fc, int tx) xferqa = &fc->ir[0]; FW_GLOCK(fc); - for (i = 0; i < fc->nisodma; i ++) { + for (i = 0; i < fc->nisodma; i++) { xferq = xferqa[i]; if ((xferq->flag & FWXFERQ_OPEN) == 0) { xferq->flag |= FWXFERQ_OPEN; @@ -2409,22 +2363,16 @@ static int fw_modevent(module_t mode, int type, void *data) { int err = 0; -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 static eventhandler_tag fwdev_ehtag = NULL; -#endif switch (type) { case MOD_LOAD: -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 fwdev_ehtag = EVENTHANDLER_REGISTER(dev_clone, - fwdev_clone, 0, 1000); -#endif + fwdev_clone, 0, 1000); break; case MOD_UNLOAD: -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 if (fwdev_ehtag != NULL) EVENTHANDLER_DEREGISTER(dev_clone, fwdev_ehtag); -#endif break; case MOD_SHUTDOWN: break; @@ -2435,8 +2383,6 @@ fw_modevent(module_t mode, int type, void *data) } -#ifdef __DragonFly__ -DECLARE_DUMMY_MODULE(firewire); -#endif -DRIVER_MODULE(firewire,fwohci,firewire_driver,firewire_devclass,fw_modevent,0); +DRIVER_MODULE(firewire, fwohci, firewire_driver, firewire_devclass, + fw_modevent,0); MODULE_VERSION(firewire, 1); diff --git a/sys/dev/firewire/firewire.h b/sys/dev/firewire/firewire.h index f147f6104036..442fd6f624fb 100644 --- a/sys/dev/firewire/firewire.h +++ b/sys/dev/firewire/firewire.h @@ -30,7 +30,7 @@ * STRICT LIABILITY, OR 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$ * */ @@ -42,8 +42,8 @@ #define DEV_DV 2 struct fw_isochreq { - unsigned char ch:6, - tag:2; + unsigned char ch:6; + unsigned char tag:2; }; struct fw_isobufreq { @@ -247,15 +247,15 @@ struct fw_eui64 { uint32_t hi, lo; }; #define FW_EUI64_BYTE(eui, x) \ - ((((x)<4)? \ - ((eui)->hi >> (8*(3-(x)))): \ - ((eui)->lo >> (8*(7-(x)))) \ + ((((x) < 4)? \ + ((eui)->hi >> (8 * (3 - (x)))): \ + ((eui)->lo >> (8 * (7 - (x)))) \ ) & 0xff) #define FW_EUI64_EQUAL(x, y) \ ((x).hi == (y).hi && (x).lo == (y).lo) struct fw_asyreq { - struct fw_asyreq_t{ + struct fw_asyreq_t { unsigned char sped; unsigned int type; #define FWASREQNODE 0 @@ -265,8 +265,8 @@ struct fw_asyreq { unsigned short len; union { struct fw_eui64 eui; - }dst; - }req; + } dst; + } req; struct fw_pkt pkt; uint32_t data[512]; }; @@ -406,7 +406,7 @@ struct fw_topology_map { uint32_t generation; uint32_t self_id_count:16, node_count:16; - union fw_self_id self_id[4*64]; + union fw_self_id self_id[4 * 64]; }; struct fw_speed_map { @@ -454,11 +454,6 @@ struct fw_crom_buf { #define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */ -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8)) -#define unit2minor(x) (((x) & 0xff) | (((x) << 8) & ~0xffff)) -#endif - #define MAKEMINOR(f, u, s) \ ((f) | (((u) & 0xff) << 8) | (s & 0xff)) #define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8) diff --git a/sys/dev/firewire/firewire_phy.h b/sys/dev/firewire/firewire_phy.h index 42feff2d27c8..a420a4a9f04e 100644 --- a/sys/dev/firewire/firewire_phy.h +++ b/sys/dev/firewire/firewire_phy.h @@ -29,7 +29,7 @@ * STRICT LIABILITY, OR 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$ * */ diff --git a/sys/dev/firewire/firewirereg.h b/sys/dev/firewire/firewirereg.h index 73445e023d43..e9a86060b45c 100644 --- a/sys/dev/firewire/firewirereg.h +++ b/sys/dev/firewire/firewirereg.h @@ -30,21 +30,13 @@ * STRICT LIABILITY, OR 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$ * */ -#ifdef __DragonFly__ -typedef d_thread_t fw_proc; -#include -#elif __FreeBSD_version >= 500000 typedef struct thread fw_proc; #include -#else -typedef struct proc fw_proc; -#include -#endif #include #include @@ -54,7 +46,7 @@ typedef struct proc fw_proc; STAILQ_HEAD(fw_xferlist, fw_xfer); -struct fw_device{ +struct fw_device { uint16_t dst; struct fw_eui64 eui; uint8_t speed; @@ -64,7 +56,7 @@ struct fw_device{ #define CSRROMOFF 0x400 #define CSRROMSIZE 0x400 int rommax; /* offset from 0xffff f000 0000 */ - uint32_t csrrom[CSRROMSIZE/4]; + uint32_t csrrom[CSRROMSIZE / 4]; int rcnt; struct firewire_comm *fc; uint32_t status; @@ -75,9 +67,7 @@ struct fw_device{ }; struct firewire_softc { -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 struct cdev *dev; -#endif struct firewire_comm *fc; }; @@ -103,11 +93,11 @@ struct tcode_info { u_char valid_res; }; -struct firewire_comm{ +struct firewire_comm { device_t dev; device_t bdev; uint16_t busid:10, - nodeid:6; + nodeid:6; u_int mode; u_int nport; u_int speed; @@ -139,7 +129,7 @@ struct firewire_comm{ STAILQ_HEAD(, fw_device) devices; u_int sid_cnt; #define CSRSIZE 0x4000 - uint32_t csr_arc[CSRSIZE/4]; + uint32_t csr_arc[CSRSIZE / 4]; #define CROMSIZE 0x400 uint32_t *config_rom; struct crom_src_buf *crom_src_buf; @@ -151,7 +141,7 @@ struct firewire_comm{ struct callout bmr_callout; struct callout timeout_callout; struct task task_timeout; - uint32_t (*cyctimer) (struct firewire_comm *); + uint32_t (*cyctimer) (struct firewire_comm *); void (*ibr) (struct firewire_comm *); uint32_t (*set_bmr) (struct firewire_comm *, uint32_t); int (*ioctl) (struct cdev *, u_long, caddr_t, int, fw_proc *); @@ -171,7 +161,7 @@ struct firewire_comm{ struct taskqueue *taskqueue; struct proc *probe_thread; }; -#define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4]) +#define CSRARC(sc, offset) ((sc)->csr_arc[(offset) / 4]) #define FW_GMTX(fc) (&(fc)->mtx) #define FW_GLOCK(fc) mtx_lock(FW_GMTX(fc)) @@ -192,7 +182,7 @@ struct fw_xferq { #define FWXFERQ_HANDLER (1 << 16) #define FWXFERQ_WAKEUP (1 << 17) - void (*start) (struct firewire_comm*); + void (*start) (struct firewire_comm *); int dmach; struct fw_xferlist q; u_int queued; @@ -211,7 +201,7 @@ struct fw_xferq { void (*hand) (struct fw_xferq *); }; -struct fw_bulkxfer{ +struct fw_bulkxfer { int poffset; struct mbuf *mbuf; STAILQ_ENTRY(fw_bulkxfer) link; @@ -220,7 +210,7 @@ struct fw_bulkxfer{ int resp; }; -struct fw_bind{ +struct fw_bind { u_int64_t start; u_int64_t end; struct fw_xferlist xferlist; @@ -229,7 +219,7 @@ struct fw_bind{ void *sc; }; -struct fw_xfer{ +struct fw_xfer { caddr_t sc; struct firewire_comm *fc; struct fw_xferq *q; @@ -269,9 +259,9 @@ struct fw_rcv_buf { void fw_sidrcv (struct firewire_comm *, uint32_t *, u_int); void fw_rcv (struct fw_rcv_buf *); -void fw_xfer_unload ( struct fw_xfer*); -void fw_xfer_free_buf ( struct fw_xfer*); -void fw_xfer_free ( struct fw_xfer*); +void fw_xfer_unload (struct fw_xfer *); +void fw_xfer_free_buf (struct fw_xfer *); +void fw_xfer_free (struct fw_xfer*); struct fw_xfer *fw_xfer_alloc (struct malloc_type *); struct fw_xfer *fw_xfer_alloc_buf (struct malloc_type *, int, int); void fw_init (struct firewire_comm *); @@ -282,7 +272,7 @@ int fw_bindremove (struct firewire_comm *, struct fw_bind *); int fw_xferlist_add (struct fw_xferlist *, struct malloc_type *, int, int, int, struct firewire_comm *, void *, void (*)(struct fw_xfer *)); void fw_xferlist_remove (struct fw_xferlist *); -int fw_asyreq (struct firewire_comm *, int, struct fw_xfer*); +int fw_asyreq (struct firewire_comm *, int, struct fw_xfer *); void fw_busreset (struct firewire_comm *, uint32_t); uint16_t fw_crc16 (uint32_t *, uint32_t); void fw_xfer_timeout (void *); @@ -303,36 +293,9 @@ extern int firewire_debug; extern devclass_t firewire_devclass; extern int firewire_phydma_enable; -#ifdef __DragonFly__ -#define FWPRI PCATCH -#else -#define FWPRI ((PZERO+8)|PCATCH) -#endif +#define FWPRI ((PZERO + 8) | PCATCH) -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#define CALLOUT_INIT(x) callout_init(x) -#else #define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */) -#endif - -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -/* compatibility shim for 4.X */ -#define bio buf -#define bio_bcount b_bcount -#define bio_cmd b_flags -#define bio_count b_count -#define bio_data b_data -#define bio_dev b_dev -#define bio_error b_error -#define bio_flags b_flags -#define bio_offset b_offset -#define bio_resid b_resid -#define BIO_ERROR B_ERROR -#define BIO_READ B_READ -#define BIO_WRITE B_WRITE -#define MIN(a,b) (((a)<(b))?(a):(b)) -#define MAX(a,b) (((a)>(b))?(a):(b)) -#endif MALLOC_DECLARE(M_FW); MALLOC_DECLARE(M_FWXFER); diff --git a/sys/dev/firewire/fwcrom.c b/sys/dev/firewire/fwcrom.c index 8a53bc7fae71..e53d3b678cd6 100644 --- a/sys/dev/firewire/fwcrom.c +++ b/sys/dev/firewire/fwcrom.c @@ -59,13 +59,8 @@ __FBSDID("$FreeBSD$"); #endif #endif -#ifdef __DragonFly__ -#include "firewire.h" -#include "iec13213.h" -#else #include #include -#endif #define MAX_ROM (1024 - sizeof(uint32_t) * 5) #define CROM_END(cc) ((vm_offset_t)(cc)->stack[0].dir + MAX_ROM - 1) @@ -116,7 +111,7 @@ crom_next(struct crom_context *cc) printf("crom_next: too deep\n"); goto again; } - cc->depth ++; + cc->depth++; ptr = &cc->stack[cc->depth]; ptr->dir = (struct csrdirectory *) (reg + reg->val); @@ -125,10 +120,10 @@ crom_next(struct crom_context *cc) } again: ptr = &cc->stack[cc->depth]; - ptr->index ++; + ptr->index++; check: if (ptr->index < ptr->dir->crc_len && - (vm_offset_t)crom_get(cc) <= CROM_END(cc)) + (vm_offset_t)crom_get(cc) <= CROM_END(cc)) return; if (ptr->index < ptr->dir->crc_len) @@ -148,7 +143,7 @@ crom_search_key(struct crom_context *cc, uint8_t key) { struct csrreg *reg; - while(cc->depth >= 0) { + while (cc->depth >= 0) { reg = crom_get(cc); if (reg->key == key) return reg; @@ -166,7 +161,7 @@ crom_has_specver(uint32_t *p, uint32_t spec, uint32_t ver) cc = &c; crom_init_context(cc, p); - while(cc->depth >= 0) { + while (cc->depth >= 0) { reg = crom_get(cc); if (state == 0) { if (reg->key == CSRKEY_SPEC && reg->val == spec) @@ -198,7 +193,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len) reg = crom_get(cc); if (reg->key != CROM_TEXTLEAF || - (vm_offset_t)(reg + reg->val) > CROM_END(cc)) { + (vm_offset_t)(reg + reg->val) > CROM_END(cc)) { strncpy(buf, nullstr, len); return; } @@ -215,7 +210,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len) qlen = textleaf->crc_len - 2; if (len < qlen * 4) qlen = len/4; - for (i = 0; i < qlen; i ++) + for (i = 0; i < qlen; i++) *bp++ = ntohl(textleaf->text[i]); /* make sure to terminate the string */ if (len <= qlen * 4) @@ -238,7 +233,7 @@ crom_crc(uint32_t *ptr, int len) } crc &= 0xffff; } - return((uint16_t) crc); + return ((uint16_t) crc); } #if !defined(_KERNEL) && !defined(_BOOT) @@ -315,17 +310,17 @@ crom_desc(struct crom_context *cc, char *buf, int len) break; case CSRTYPE_C: len -= snprintf(buf, len, "offset=0x%04x(%d)", - reg->val, reg->val); + reg->val, reg->val); buf += strlen(buf); break; case CSRTYPE_L: /* XXX fall through */ case CSRTYPE_D: - dir = (struct csrdirectory *) (reg + reg->val); + dir = (struct csrdirectory *)(reg + reg->val); crc = crom_crc((uint32_t *)&dir->entry[0], dir->crc_len); len -= snprintf(buf, len, "len=%d crc=0x%04x(%s) ", - dir->crc_len, dir->crc, - (crc == dir->crc) ? "OK" : "NG"); + dir->crc_len, dir->crc, + (crc == dir->crc) ? "OK" : "NG"); buf += strlen(buf); } switch (reg->key) { @@ -399,11 +394,11 @@ crom_add_quad(struct crom_chunk *chunk, uint32_t entry) index = chunk->data.crc_len; if (index >= CROM_MAX_CHUNK_LEN - 1) { printf("too large chunk %d\n", index); - return(-1); + return (-1); } chunk->data.buf[index] = entry; chunk->data.crc_len++; - return(index); + return (index); } int @@ -414,7 +409,7 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val) struct csrreg reg; uint32_t i; } foo; - + foo.reg.key = key; foo.reg.val = val; return (crom_add_quad(chunk, foo.i)); @@ -422,29 +417,29 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val) int crom_add_chunk(struct crom_src *src, struct crom_chunk *parent, - struct crom_chunk *child, int key) + struct crom_chunk *child, int key) { int index; if (parent == NULL) { STAILQ_INSERT_TAIL(&src->chunk_list, child, link); - return(0); + return (0); } index = crom_add_entry(parent, key, 0); if (index < 0) { - return(-1); + return (-1); } child->ref_chunk = parent; child->ref_index = index; STAILQ_INSERT_TAIL(&src->chunk_list, child, link); - return(index); + return (index); } #define MAX_TEXT ((CROM_MAX_CHUNK_LEN + 1) * 4 - sizeof(struct csrtext)) int crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent, - struct crom_chunk *chunk, char *buf) + struct crom_chunk *chunk, char *buf) { struct csrtext *tl; uint32_t *p; @@ -453,11 +448,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent, len = strlen(buf); if (len > MAX_TEXT) { -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf("text(%d) trancated to %d.\n", len, MAX_TEXT); -#else - printf("text(%d) trancated to %td.\n", len, MAX_TEXT); -#endif + printf("text(%d) truncated to %td.\n", len, MAX_TEXT); len = MAX_TEXT; } @@ -469,7 +460,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent, bzero(&t[0], roundup2(len, sizeof(uint32_t))); bcopy(buf, &t[0], len); p = (uint32_t *)&t[0]; - for (i = 0; i < howmany(len, sizeof(uint32_t)); i ++) + for (i = 0; i < howmany(len, sizeof(uint32_t)); i++) tl->text[i] = ntohl(*p++); return (crom_add_chunk(src, parent, chunk, CROM_TEXTLEAF)); } @@ -479,11 +470,11 @@ crom_copy(uint32_t *src, uint32_t *dst, int *offset, int len, int maxlen) { if (*offset + len > maxlen) { printf("Config. ROM is too large for the buffer\n"); - return(-1); + return (-1); } bcopy(src, (char *)(dst + *offset), len * sizeof(uint32_t)); *offset += len; - return(0); + return (0); } int @@ -507,9 +498,9 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen) if (parent != NULL) { struct csrreg *reg; reg = (struct csrreg *) - &parent->data.buf[chunk->ref_index]; + &parent->data.buf[chunk->ref_index]; reg->val = offset - - (parent->offset + 1 + chunk->ref_index); + (parent->offset + 1 + chunk->ref_index); } offset += 1 + chunk->data.crc_len; } @@ -518,15 +509,15 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen) len = 1 + src->hdr.info_len; count = 0; if (crom_copy((uint32_t *)&src->hdr, buf, &count, len, maxlen) < 0) - return(-1); + return (-1); STAILQ_FOREACH(chunk, &src->chunk_list, link) { chunk->data.crc = - crom_crc(&chunk->data.buf[0], chunk->data.crc_len); + crom_crc(&chunk->data.buf[0], chunk->data.crc_len); len = 1 + chunk->data.crc_len; if (crom_copy((uint32_t *)&chunk->data, buf, - &count, len, maxlen) < 0) - return(-1); + &count, len, maxlen) < 0) + return (-1); } hdr = (struct csrhdr *)buf; hdr->crc_len = count - 1; @@ -535,19 +526,20 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen) #if defined(_KERNEL) || defined(_BOOT) /* byte swap */ ptr = buf; - for (i = 0; i < count; i ++) { + for (i = 0; i < count; i++) { *ptr = htonl(*ptr); ptr++; } #endif - return(count); + return (count); } #endif #ifdef TEST int -main () { +main() +{ struct crom_src src; struct crom_chunk root,unit1,unit2,unit3; struct crom_chunk text1,text2,text3,text4,text5,text6,text7; @@ -591,15 +583,9 @@ main () { /* private company_id */ crom_add_entry(&root, CSRKEY_VENDOR, 0xacde48); -#ifdef __DragonFly__ - crom_add_simple_text(&src, &root, &text1, "DragonFly"); - crom_add_entry(&root, CSRKEY_HW, __DragonFly_cc_version); - crom_add_simple_text(&src, &root, &text2, "DragonFly-1"); -#else crom_add_simple_text(&src, &root, &text1, "FreeBSD"); crom_add_entry(&root, CSRKEY_HW, __FreeBSD_version); crom_add_simple_text(&src, &root, &text2, "FreeBSD-5"); -#endif /* SBP unit directory */ crom_add_chunk(&src, &root, &unit1, CROM_UDIR); @@ -632,11 +618,11 @@ main () { crom_load(&src, buf, 256); p = buf; #define DUMP_FORMAT "%08x %08x %08x %08x %08x %08x %08x %08x\n" - for (i = 0; i < 256/8; i ++) { + for (i = 0; i < 256/8; i++) { printf(DUMP_FORMAT, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); p += 8; } - return(0); + return (0); } #endif diff --git a/sys/dev/firewire/fwdev.c b/sys/dev/firewire/fwdev.c index d26810d30545..e09ce2c947bf 100644 --- a/sys/dev/firewire/fwdev.c +++ b/sys/dev/firewire/fwdev.c @@ -30,7 +30,7 @@ * STRICT LIABILITY, OR 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$ * */ @@ -39,11 +39,7 @@ #include #include #include -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#include -#else #include -#endif #include #include @@ -56,19 +52,11 @@ #include -#ifdef __DragonFly__ -#include "firewire.h" -#include "firewirereg.h" -#include "fwdma.h" -#include "fwmem.h" -#include "iec68113.h" -#else #include #include #include #include #include -#endif #define FWNODE_INVAL 0xffff @@ -82,12 +70,6 @@ static d_mmap_t fw_mmap; static d_strategy_t fw_strategy; struct cdevsw firewire_cdevsw = { -#ifdef __DragonFly__ -#define CDEV_MAJOR 127 - "fw", CDEV_MAJOR, D_MEM, NULL, 0, - fw_open, fw_close, fw_read, fw_write, fw_ioctl, - fw_poll, fw_mmap, fw_strategy, nodump, nopsize, -#elif __FreeBSD_version >= 500104 .d_version = D_VERSION, .d_open = fw_open, .d_close = fw_close, @@ -99,12 +81,6 @@ struct cdevsw firewire_cdevsw = { .d_strategy = fw_strategy, .d_name = "fw", .d_flags = D_MEM -#else -#define CDEV_MAJOR 127 - fw_open, fw_close, fw_read, fw_write, fw_ioctl, - fw_poll, fw_mmap, fw_strategy, "fw", CDEV_MAJOR, - nodump, nopsize, D_MEM, -1 -#endif }; struct fw_drv1 { @@ -123,22 +99,21 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q, int i; if (q->flag & (FWXFERQ_RUNNING | FWXFERQ_EXTBUF)) - return(EBUSY); + return (EBUSY); - q->bulkxfer = (struct fw_bulkxfer *) malloc( - sizeof(struct fw_bulkxfer) * b->nchunk, - M_FW, M_WAITOK); + q->bulkxfer = malloc(sizeof(struct fw_bulkxfer) * b->nchunk, + M_FW, M_WAITOK); if (q->bulkxfer == NULL) - return(ENOMEM); + return (ENOMEM); b->psize = roundup2(b->psize, sizeof(uint32_t)); q->buf = fwdma_malloc_multiseg(fc, sizeof(uint32_t), - b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK); + b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK); if (q->buf == NULL) { free(q->bulkxfer, M_FW); q->bulkxfer = NULL; - return(ENOMEM); + return (ENOMEM); } q->bnchunk = b->nchunk; q->bnpacket = b->npacket; @@ -150,7 +125,7 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q, STAILQ_INIT(&q->stdma); q->stproc = NULL; - for(i = 0 ; i < q->bnchunk; i++){ + for (i = 0; i < q->bnchunk; i++) { q->bulkxfer[i].poffset = i * q->bnpacket; q->bulkxfer[i].mbuf = NULL; STAILQ_INSERT_TAIL(&q->stfree, &q->bulkxfer[i], link); @@ -181,7 +156,7 @@ fwdev_freebuf(struct fw_xferq *q) static int -fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td) +fw_open(struct cdev *dev, int flags, int fmt, fw_proc *td) { int err = 0; int unit = DEV2UNIT(dev); @@ -208,17 +183,15 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td) if (dev->si_drv1 == NULL) return (ENOMEM); -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 if ((dev->si_flags & SI_NAMED) == 0) { int unit = DEV2UNIT(dev); int sub = DEV2SUB(dev); make_dev(&firewire_cdevsw, dev2unit(dev), - UID_ROOT, GID_OPERATOR, 0660, - "fw%d.%d", unit, sub); + UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, sub); } -#endif - d = (struct fw_drv1 *)dev->si_drv1; + + d = dev->si_drv1; d->fc = sc->fc; STAILQ_INIT(&d->binds); STAILQ_INIT(&d->rq); @@ -227,7 +200,7 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td) } static int -fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td) +fw_close(struct cdev *dev, int flags, int fmt, fw_proc *td) { struct firewire_comm *fc; struct fw_drv1 *d; @@ -238,12 +211,12 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td) if (DEV_FWMEM(dev)) return fwmem_close(dev, flags, fmt, td); - d = (struct fw_drv1 *)dev->si_drv1; + d = dev->si_drv1; fc = d->fc; /* remove binding */ for (fwb = STAILQ_FIRST(&d->binds); fwb != NULL; - fwb = STAILQ_FIRST(&d->binds)) { + fwb = STAILQ_FIRST(&d->binds)) { fw_bindremove(fc, fwb); STAILQ_REMOVE_HEAD(&d->binds, chlist); fw_xferlist_remove(&fwb->xferlist); @@ -262,15 +235,15 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td) fwdev_freebuf(ir); /* drain receiving buffer */ for (xfer = STAILQ_FIRST(&ir->q); - xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) { - ir->queued --; + xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) { + ir->queued--; STAILQ_REMOVE_HEAD(&ir->q, link); xfer->resp = 0; fw_xfer_done(xfer); } - ir->flag &= ~(FWXFERQ_OPEN | - FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); + ir->flag &= ~(FWXFERQ_OPEN | FWXFERQ_MODEMASK | + FWXFERQ_CHTAGMASK); d->ir = NULL; } @@ -286,7 +259,7 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td) /* free extbuf */ fwdev_freebuf(it); it->flag &= ~(FWXFERQ_OPEN | - FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); + FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); d->it = NULL; } free(dev->si_drv1, M_FW); @@ -323,10 +296,10 @@ fw_read_async(struct fw_drv1 *d, struct uio *uio, int ioflag) fc->irx_post(fc, fp->mode.ld); #endif tinfo = &xfer->fc->tcode[fp->mode.hdr.tcode]; - err = uiomove((void *)fp, tinfo->hdr_len, uio); + err = uiomove(fp, tinfo->hdr_len, uio); if (err) goto out; - err = uiomove((void *)xfer->recv.payload, xfer->recv.pay_len, uio); + err = uiomove(xfer->recv.payload, xfer->recv.pay_len, uio); out: /* recycle this xfer */ @@ -343,7 +316,7 @@ fw_read_async(struct fw_drv1 *d, struct uio *uio, int ioflag) * read request. */ static int -fw_read (struct cdev *dev, struct uio *uio, int ioflag) +fw_read(struct cdev *dev, struct uio *uio, int ioflag) { struct fw_drv1 *d; struct fw_xferq *ir; @@ -354,7 +327,7 @@ fw_read (struct cdev *dev, struct uio *uio, int ioflag) if (DEV_FWMEM(dev)) return (physio(dev, uio, ioflag)); - d = (struct fw_drv1 *)dev->si_drv1; + d = dev->si_drv1; fc = d->fc; ir = d->ir; @@ -389,21 +362,21 @@ fw_read (struct cdev *dev, struct uio *uio, int ioflag) err = EIO; FW_GUNLOCK(fc); return err; - } else if(ir->stproc != NULL) { + } else if (ir->stproc != NULL) { /* iso bulkxfer */ FW_GUNLOCK(fc); - fp = (struct fw_pkt *)fwdma_v_addr(ir->buf, - ir->stproc->poffset + ir->queued); - if(fc->irx_post != NULL) + fp = (struct fw_pkt *)fwdma_v_addr(ir->buf, + ir->stproc->poffset + ir->queued); + if (fc->irx_post != NULL) fc->irx_post(fc, fp->mode.ld); - if(fp->mode.stream.len == 0){ + if (fp->mode.stream.len == 0) { err = EIO; return err; } err = uiomove((caddr_t)fp, fp->mode.stream.len + sizeof(uint32_t), uio); - ir->queued ++; - if(ir->queued >= ir->bnpacket){ + ir->queued++; + if (ir->queued >= ir->bnpacket) { s = splfw(); STAILQ_INSERT_TAIL(&ir->stfree, ir->stproc, link); splx(s); @@ -476,7 +449,7 @@ fw_write_async(struct fw_drv1 *d, struct uio *uio, int ioflag) } static int -fw_write (struct cdev *dev, struct uio *uio, int ioflag) +fw_write(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; int s, slept = 0; @@ -488,7 +461,7 @@ fw_write (struct cdev *dev, struct uio *uio, int ioflag) if (DEV_FWMEM(dev)) return (physio(dev, uio, ioflag)); - d = (struct fw_drv1 *)dev->si_drv1; + d = dev->si_drv1; fc = d->fc; it = d->it; @@ -529,7 +502,7 @@ fw_write (struct cdev *dev, struct uio *uio, int ioflag) err = uiomove((caddr_t)fp, sizeof(struct fw_isohdr), uio); err = uiomove((caddr_t)fp->mode.stream.payload, fp->mode.stream.len, uio); - it->queued ++; + it->queued++; if (it->queued >= it->bnpacket) { s = splfw(); STAILQ_INSERT_TAIL(&it->stvalid, it->stproc, link); @@ -556,7 +529,7 @@ fw_hand(struct fw_xfer *xfer) struct fw_drv1 *d; fwb = (struct fw_bind *)xfer->sc; - d = (struct fw_drv1 *)fwb->sc; + d = fwb->sc; FW_GLOCK(xfer->fc); STAILQ_INSERT_TAIL(&d->rq, xfer, link); FW_GUNLOCK(xfer->fc); @@ -567,7 +540,7 @@ fw_hand(struct fw_xfer *xfer) * ioctl support. */ int -fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) +fw_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) { struct firewire_comm *fc; struct fw_drv1 *d; @@ -591,9 +564,9 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) return fwmem_ioctl(dev, cmd, data, flag, td); if (!data) - return(EINVAL); + return (EINVAL); - d = (struct fw_drv1 *)dev->si_drv1; + d = dev->si_drv1; fc = d->fc; ir = d->ir; it = d->it; @@ -709,7 +682,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) bcopy(fp, (void *)&xfer->send.hdr, tinfo->hdr_len); if (pay_len > 0) bcopy((char *)fp + tinfo->hdr_len, - (void *)xfer->send.payload, pay_len); + xfer->send.payload, pay_len); xfer->send.spd = asyreq->req.sped; xfer->hand = fw_xferwake; @@ -731,7 +704,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) pay_len = xfer->recv.pay_len; if (asyreq->req.len >= xfer->recv.pay_len + tinfo->hdr_len) { asyreq->req.len = xfer->recv.pay_len + - tinfo->hdr_len; + tinfo->hdr_len; } else { err = EINVAL; pay_len = 0; @@ -751,7 +724,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) case FW_CBINDADDR: fwb = fw_bindlookup(fc, bindreq->start.hi, bindreq->start.lo); - if(fwb == NULL){ + if (fwb == NULL) { err = EINVAL; break; } @@ -761,30 +734,30 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) free(fwb, M_FW); break; case FW_SBINDADDR: - if(bindreq->len <= 0 ){ + if (bindreq->len <= 0) { err = EINVAL; break; } - if(bindreq->start.hi > 0xffff ){ + if (bindreq->start.hi > 0xffff) { err = EINVAL; break; } - fwb = (struct fw_bind *)malloc(sizeof (struct fw_bind), M_FW, M_WAITOK); - if(fwb == NULL){ + fwb = malloc(sizeof(struct fw_bind), M_FW, M_WAITOK); + if (fwb == NULL) { err = ENOMEM; break; } fwb->start = ((u_int64_t)bindreq->start.hi << 32) | bindreq->start.lo; fwb->end = fwb->start + bindreq->len; - fwb->sc = (void *)d; + fwb->sc = d; STAILQ_INIT(&fwb->xferlist); err = fw_bindadd(fc, fwb); if (err == 0) { fw_xferlist_add(&fwb->xferlist, M_FWXFER, /* XXX */ PAGE_SIZE, PAGE_SIZE, 5, - fc, (void *)fwb, fw_hand); + fc, fwb, fw_hand); STAILQ_INSERT_TAIL(&d->binds, fwb, chlist); } break; @@ -797,11 +770,11 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) devinfo->eui.hi = fc->eui.hi; devinfo->eui.lo = fc->eui.lo; STAILQ_FOREACH(fwdev, &fc->devices, link) { - if(len < FW_MAX_DEVLST){ + if (len < FW_MAX_DEVLST) { devinfo = &fwdevlst->dev[len++]; devinfo->dst = fwdev->dst; - devinfo->status = - (fwdev->status == FWDEVINVAL)?0:1; + devinfo->status = + (fwdev->status == FWDEVINVAL) ? 0 : 1; devinfo->eui.hi = fwdev->eui.hi; devinfo->eui.lo = fwdev->eui.lo; } @@ -812,7 +785,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) break; case FW_GTPMAP: bcopy(fc->topology_map, data, - (fc->topology_map->crc_len + 1) * 4); + (fc->topology_map->crc_len + 1) * 4); break; case FW_GCROM: STAILQ_FOREACH(fwdev, &fc->devices, link) @@ -847,7 +820,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) free(ptr, M_FW); break; default: - fc->ioctl (dev, cmd, data, flag, td); + fc->ioctl(dev, cmd, data, flag, td); break; } return err; @@ -873,7 +846,7 @@ fw_poll(struct cdev *dev, int events, fw_proc *td) } tmp = POLLOUT | POLLWRNORM; if (events & tmp) { - /* XXX should be fixed */ + /* XXX should be fixed */ revents |= tmp; } @@ -881,20 +854,12 @@ fw_poll(struct cdev *dev, int events, fw_proc *td) } static int -#if defined(__DragonFly__) || __FreeBSD_version < 500102 -fw_mmap (struct cdev *dev, vm_offset_t offset, int nproto) -#else fw_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nproto, vm_memattr_t *memattr) -#endif -{ +{ if (DEV_FWMEM(dev)) -#if defined(__DragonFly__) || __FreeBSD_version < 500102 - return fwmem_mmap(dev, offset, nproto); -#else return fwmem_mmap(dev, offset, paddr, nproto, memattr); -#endif return EINVAL; } @@ -921,24 +886,17 @@ fwdev_makedev(struct firewire_softc *sc) { int err = 0; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - cdevsw_add(&firewire_cdevsw); -#else struct cdev *d; int unit; unit = device_get_unit(sc->fc->bdev); sc->dev = make_dev(&firewire_cdevsw, MAKEMINOR(0, unit, 0), - UID_ROOT, GID_OPERATOR, 0660, - "fw%d.%d", unit, 0); - d = make_dev(&firewire_cdevsw, - MAKEMINOR(FWMEM_FLAG, unit, 0), - UID_ROOT, GID_OPERATOR, 0660, - "fwmem%d.%d", unit, 0); + UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, 0); + d = make_dev(&firewire_cdevsw, MAKEMINOR(FWMEM_FLAG, unit, 0), + UID_ROOT, GID_OPERATOR, 0660, "fwmem%d.%d", unit, 0); dev_depends(sc->dev, d); make_dev_alias(sc->dev, "fw%d", unit); make_dev_alias(d, "fwmem%d", unit); -#endif return (err); } @@ -948,15 +906,10 @@ fwdev_destroydev(struct firewire_softc *sc) { int err = 0; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - cdevsw_remove(&firewire_cdevsw); -#else destroy_dev(sc->dev); -#endif return (err); } -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 #define NDEVTYPE 2 void fwdev_clone(void *arg, struct ucred *cred, char *name, int namelen, @@ -998,4 +951,3 @@ fwdev_clone(void *arg, struct ucred *cred, char *name, int namelen, dev_depends(sc->dev, *dev); return; } -#endif diff --git a/sys/dev/firewire/fwdma.c b/sys/dev/firewire/fwdma.c index bf3bb6f5fcf6..c8378f0fc091 100644 --- a/sys/dev/firewire/fwdma.c +++ b/sys/dev/firewire/fwdma.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author 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 @@ -30,7 +30,7 @@ * LIABILITY, OR 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. - * + * */ #ifdef __FreeBSD__ @@ -43,23 +43,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 #include #include -#endif #include #include -#ifdef __DragonFly__ -#include -#include -#include -#else #include #include #include -#endif static void fwdma_map_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) @@ -90,14 +82,12 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size, /*nsegments*/ 1, /*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT, /*flags*/ BUS_DMA_ALLOCNOW, -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 /*lockfunc*/busdma_lock_mutex, /*lockarg*/FW_GMTX(fc), -#endif &dma->dma_tag); if (err) { printf("fwdma_malloc: failed(1)\n"); - return(NULL); + return (NULL); } err = bus_dmamem_alloc(dma->dma_tag, &dma->v_addr, @@ -105,13 +95,13 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size, if (err) { printf("fwdma_malloc: failed(2)\n"); /* XXX destroy tag */ - return(NULL); + return (NULL); } bus_dmamap_load(dma->dma_tag, dma->dma_map, dma->v_addr, size, fwdma_map_cb, &dma->bus_addr, /*flags*/0); - return(dma->v_addr); + return (dma->v_addr); } void @@ -131,11 +121,11 @@ fwdma_malloc_size(bus_dma_tag_t dmat, bus_dmamap_t *dmamap, if (bus_dmamem_alloc(dmat, &v_addr, flag, dmamap)) { printf("fwdma_malloc_size: failed(1)\n"); - return(NULL); + return (NULL); } bus_dmamap_load(dmat, *dmamap, v_addr, size, fwdma_map_cb, bus_addr, /*flags*/0); - return(v_addr); + return (v_addr); } void @@ -144,7 +134,7 @@ fwdma_free_size(bus_dma_tag_t dmat, bus_dmamap_t dmamap, { bus_dmamap_unload(dmat, dmamap); bus_dmamem_free(dmat, vaddr, dmamap); -} +} /* * Allocate multisegment dma buffers @@ -172,7 +162,7 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment, + sizeof(struct fwdma_seg)*nseg, M_FW, M_WAITOK); if (am == NULL) { printf("fwdma_malloc_multiseg: malloc failed\n"); - return(NULL); + return (NULL); } am->ssize = ssize; am->esize = esize; @@ -188,35 +178,26 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment, /*nsegments*/ 1, /*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT, /*flags*/ BUS_DMA_ALLOCNOW, -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 /*lockfunc*/busdma_lock_mutex, /*lockarg*/FW_GMTX(fc), -#endif &am->dma_tag)) { printf("fwdma_malloc_multiseg: tag_create failed\n"); free(am, M_FW); - return(NULL); + return (NULL); } -#if 0 -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf("malloc_multi: ssize=%d nseg=%d\n", ssize, nseg); -#else - printf("malloc_multi: ssize=%td nseg=%d\n", ssize, nseg); -#endif -#endif - for (seg = &am->seg[0]; nseg --; seg ++) { + for (seg = &am->seg[0]; nseg--; seg++) { seg->v_addr = fwdma_malloc_size(am->dma_tag, &seg->dma_map, ssize, &seg->bus_addr, flag); if (seg->v_addr == NULL) { printf("fwdma_malloc_multi: malloc_size failed %d\n", am->nseg); fwdma_free_multiseg(am); - return(NULL); + return (NULL); } am->nseg++; } - return(am); + return (am); } void @@ -224,7 +205,7 @@ fwdma_free_multiseg(struct fwdma_alloc_multi *am) { struct fwdma_seg *seg; - for (seg = &am->seg[0]; am->nseg --; seg ++) { + for (seg = &am->seg[0]; am->nseg--; seg++) { fwdma_free_size(am->dma_tag, seg->dma_map, seg->v_addr, am->ssize); } diff --git a/sys/dev/firewire/fwdma.h b/sys/dev/firewire/fwdma.h index 3a8278c1c709..ec67971ad229 100644 --- a/sys/dev/firewire/fwdma.h +++ b/sys/dev/firewire/fwdma.h @@ -1,7 +1,7 @@ /*- * Copyright (C) 2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author 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 @@ -30,20 +30,20 @@ * LIABILITY, OR 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$ */ struct fwdma_alloc { bus_dma_tag_t dma_tag; bus_dmamap_t dma_map; - void * v_addr; + void *v_addr; bus_addr_t bus_addr; }; struct fwdma_seg { bus_dmamap_t dma_map; - void * v_addr; + void *v_addr; bus_addr_t bus_addr; }; @@ -74,20 +74,20 @@ fwdma_bus_addr(struct fwdma_alloc_multi *am, int index) } static __inline void -fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op) +fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op) { bus_dmamap_sync(dma->dma_tag, dma->dma_map, op); } static __inline void fwdma_sync_multiseg(struct fwdma_alloc_multi *am, - int start, int end, bus_dmasync_op_t op) + int start, int end, bus_dmasync_op_t op) { struct fwdma_seg *seg, *eseg; seg = &am->seg[am->esize * start / am->ssize]; eseg = &am->seg[am->esize * end / am->ssize]; - for (; seg <= eseg; seg ++) + for (; seg <= eseg; seg++) bus_dmamap_sync(am->dma_tag, seg->dma_map, op); } diff --git a/sys/dev/firewire/fwmem.c b/sys/dev/firewire/fwmem.c index a342d1428ded..182fc8aba51a 100644 --- a/sys/dev/firewire/fwmem.c +++ b/sys/dev/firewire/fwmem.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 2002-2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author 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 @@ -30,7 +30,7 @@ * LIABILITY, OR 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. - * + * */ #ifdef __FreeBSD__ @@ -46,11 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#include -#else #include -#endif #include #include @@ -60,17 +56,11 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __DragonFly__ -#include "firewire.h" -#include "firewirereg.h" -#include "fwmem.h" -#else #include #include #include -#endif -static int fwmem_speed=2, fwmem_debug=0; +static int fwmem_speed = 2, fwmem_debug = 0; static struct fw_eui64 fwmem_eui64; SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwmem, CTLFLAG_RD, 0, @@ -136,7 +126,7 @@ fwmem_read_quad( struct fw_xfer *xfer; struct fw_pkt *fp; - xfer = fwmem_xfer_req(fwdev, (void *)sc, spd, 0, 4, hand); + xfer = fwmem_xfer_req(fwdev, sc, spd, 0, 4, hand); if (xfer == NULL) { return NULL; } @@ -151,7 +141,7 @@ fwmem_read_quad( if (fwmem_debug) printf("fwmem_read_quad: %d %04x:%08x\n", fwdev->dst, - dst_hi, dst_lo); + dst_hi, dst_lo); if (fw_asyreq(xfer->fc, -1, xfer) == 0) return xfer; @@ -187,7 +177,7 @@ fwmem_write_quad( if (fwmem_debug) printf("fwmem_write_quad: %d %04x:%08x %08x\n", fwdev->dst, - dst_hi, dst_lo, *(uint32_t *)data); + dst_hi, dst_lo, *(uint32_t *)data); if (fw_asyreq(xfer->fc, -1, xfer) == 0) return xfer; @@ -209,7 +199,7 @@ fwmem_read_block( { struct fw_xfer *xfer; struct fw_pkt *fp; - + xfer = fwmem_xfer_req(fwdev, sc, spd, 0, roundup2(len, 4), hand); if (xfer == NULL) return NULL; @@ -226,7 +216,7 @@ fwmem_read_block( if (fwmem_debug) printf("fwmem_read_block: %d %04x:%08x %d\n", fwdev->dst, - dst_hi, dst_lo, len); + dst_hi, dst_lo, len); if (fw_asyreq(xfer->fc, -1, xfer) == 0) return xfer; @@ -272,9 +262,8 @@ fwmem_write_block( return NULL; } - int -fwmem_open (struct cdev *dev, int flags, int fmt, fw_proc *td) +fwmem_open(struct cdev *dev, int flags, int fmt, fw_proc *td) { struct fwmem_softc *fms; struct firewire_softc *sc; @@ -288,20 +277,20 @@ fwmem_open (struct cdev *dev, int flags, int fmt, fw_proc *td) if (dev->si_drv1 != NULL) { if ((flags & FWRITE) != 0) { FW_GUNLOCK(sc->fc); - return(EBUSY); + return (EBUSY); } FW_GUNLOCK(sc->fc); - fms = (struct fwmem_softc *)dev->si_drv1; - fms->refcount ++; + fms = dev->si_drv1; + fms->refcount++; } else { dev->si_drv1 = (void *)-1; FW_GUNLOCK(sc->fc); dev->si_drv1 = malloc(sizeof(struct fwmem_softc), - M_FWMEM, M_WAITOK); + M_FWMEM, M_WAITOK); if (dev->si_drv1 == NULL) - return(ENOMEM); + return (ENOMEM); dev->si_iosize_max = DFLTPHYS; - fms = (struct fwmem_softc *)dev->si_drv1; + fms = dev->si_drv1; bcopy(&fwmem_eui64, &fms->eui, sizeof(struct fw_eui64)); fms->sc = sc; fms->refcount = 1; @@ -317,10 +306,10 @@ fwmem_close (struct cdev *dev, int flags, int fmt, fw_proc *td) { struct fwmem_softc *fms; - fms = (struct fwmem_softc *)dev->si_drv1; + fms = dev->si_drv1; FW_GLOCK(fms->sc->fc); - fms->refcount --; + fms->refcount--; FW_GUNLOCK(fms->sc->fc); if (fwmem_debug) printf("%s: refcount=%d\n", __func__, fms->refcount); @@ -359,18 +348,18 @@ fwmem_strategy(struct bio *bp) struct fw_device *fwdev; struct fw_xfer *xfer; struct cdev *dev; - int err=0, s, iolen; + int err = 0, s, iolen; dev = bp->bio_dev; /* XXX check request length */ s = splfw(); - fms = (struct fwmem_softc *)dev->si_drv1; + fms = dev->si_drv1; fwdev = fw_noderesolve_eui64(fms->sc->fc, &fms->eui); if (fwdev == NULL) { if (fwmem_debug) printf("fwmem: no such device ID:%08x%08x\n", - fms->eui.hi, fms->eui.lo); + fms->eui.hi, fms->eui.lo); err = EINVAL; goto error; } @@ -379,12 +368,12 @@ fwmem_strategy(struct bio *bp) if ((bp->bio_cmd & BIO_READ) == BIO_READ) { if (iolen == 4 && (bp->bio_offset & 3) == 0) xfer = fwmem_read_quad(fwdev, - (void *) bp, fwmem_speed, + (void *)bp, fwmem_speed, bp->bio_offset >> 32, bp->bio_offset & 0xffffffff, bp->bio_data, fwmem_biodone); else xfer = fwmem_read_block(fwdev, - (void *) bp, fwmem_speed, + (void *)bp, fwmem_speed, bp->bio_offset >> 32, bp->bio_offset & 0xffffffff, iolen, bp->bio_data, fwmem_biodone); } else { @@ -418,12 +407,12 @@ fwmem_strategy(struct bio *bp) } int -fwmem_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) +fwmem_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) { struct fwmem_softc *fms; int err = 0; - fms = (struct fwmem_softc *)dev->si_drv1; + fms = dev->si_drv1; switch (cmd) { case FW_SDEUI64: bcopy(data, &fms->eui, sizeof(struct fw_eui64)); @@ -434,20 +423,18 @@ fwmem_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) default: err = EINVAL; } - return(err); + return (err); } + int -fwmem_poll (struct cdev *dev, int events, fw_proc *td) -{ +fwmem_poll(struct cdev *dev, int events, fw_proc *td) +{ return EINVAL; } + int -#if defined(__DragonFly__) || __FreeBSD_version < 500102 -fwmem_mmap (struct cdev *dev, vm_offset_t offset, int nproto) -#else -fwmem_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, +fwmem_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nproto, vm_memattr_t *memattr) -#endif -{ +{ return EINVAL; } diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index 4ac43027bd40..00a54e28da6d 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -30,18 +30,11 @@ * STRICT LIABILITY, OR 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$ * */ -#define ATRQ_CH 0 -#define ATRS_CH 1 -#define ARRQ_CH 2 -#define ARRS_CH 3 -#define ITX_CH 4 -#define IRX_CH 0x24 - #include #include #include @@ -56,25 +49,12 @@ #include -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#include /* for DELAY() */ -#endif - -#ifdef __DragonFly__ -#include "firewire.h" -#include "firewirereg.h" -#include "fwdma.h" -#include "fwohcireg.h" -#include "fwohcivar.h" -#include "firewire_phy.h" -#else #include #include #include #include #include #include -#endif #undef OHCI_DEBUG @@ -86,25 +66,25 @@ SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RWTUN, SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RWTUN, &firewire_phydma_enable, 0, "Allow physical request DMA from firewire"); -static char dbcode[16][0x10]={"OUTM", "OUTL","INPM","INPL", - "STOR","LOAD","NOP ","STOP",}; +static char dbcode[16][0x10] = {"OUTM", "OUTL", "INPM", "INPL", + "STOR", "LOAD", "NOP ", "STOP",}; -static char dbkey[8][0x10]={"ST0", "ST1","ST2","ST3", - "UNDEF","REG","SYS","DEV"}; -static char dbcond[4][0x10]={"NEV","C=1", "C=0", "ALL"}; -char fwohcicode[32][0x20]={ - "No stat","Undef","long","miss Ack err", - "FIFO underrun","FIFO overrun","desc err", "data read err", - "data write err","bus reset","timeout","tcode err", - "Undef","Undef","unknown event","flushed", - "Undef","ack complete","ack pend","Undef", - "ack busy_X","ack busy_A","ack busy_B","Undef", - "Undef","Undef","Undef","ack tardy", - "Undef","ack data_err","ack type_err",""}; +static char dbkey[8][0x10] = {"ST0", "ST1", "ST2", "ST3", + "UNDEF", "REG", "SYS", "DEV"}; +static char dbcond[4][0x10] = {"NEV", "C=1", "C=0", "ALL"}; +char fwohcicode[32][0x20]= { + "No stat", "Undef", "long", "miss Ack err", + "FIFO underrun", "FIFO overrun", "desc err", "data read err", + "data write err", "bus reset", "timeout", "tcode err", + "Undef", "Undef", "unknown event", "flushed", + "Undef" ,"ack complete", "ack pend", "Undef", + "ack busy_X", "ack busy_A", "ack busy_B", "Undef", + "Undef", "Undef", "Undef", "ack tardy", + "Undef", "ack data_err", "ack type_err", ""}; #define MAX_SPEED 3 extern char *linkspeed[]; -uint32_t tagbit[4] = { 1 << 28, 1 << 29, 1 << 30, 1 << 31}; +uint32_t tagbit[4] = {1 << 28, 1 << 29, 1 << 30, 1 << 31}; static struct tcode_info tinfo[] = { /* hdr_len block flag valid_response */ @@ -126,6 +106,13 @@ static struct tcode_info tinfo[] = { /* f XXX */ { 0, 0, 0xff} }; +#define ATRQ_CH 0 +#define ATRS_CH 1 +#define ARRQ_CH 2 +#define ARRS_CH 3 +#define ITX_CH 4 +#define IRX_CH 0x24 + #define OHCI_WRITE_SIGMASK 0xffff0000 #define OHCI_READ_SIGMASK 0xffff0000 @@ -140,8 +127,8 @@ static void fwohci_txd (struct fwohci_softc *, struct fwohci_dbch *); static void fwohci_start_atq (struct firewire_comm *); static void fwohci_start_ats (struct firewire_comm *); static void fwohci_start (struct fwohci_softc *, struct fwohci_dbch *); -static uint32_t fwphy_wrdata ( struct fwohci_softc *, uint32_t, uint32_t); -static uint32_t fwphy_rddata ( struct fwohci_softc *, uint32_t); +static uint32_t fwphy_wrdata (struct fwohci_softc *, uint32_t, uint32_t); +static uint32_t fwphy_rddata (struct fwohci_softc *, uint32_t); static int fwohci_rx_enable (struct fwohci_softc *, struct fwohci_dbch *); static int fwohci_tx_enable (struct fwohci_softc *, struct fwohci_dbch *); static int fwohci_irx_enable (struct firewire_comm *, int); @@ -156,9 +143,9 @@ static void fwohci_set_intr (struct firewire_comm *, int); static int fwohci_add_rx_buf (struct fwohci_dbch *, struct fwohcidb_tr *, int, struct fwdma_alloc *); static int fwohci_add_tx_buf (struct fwohci_dbch *, struct fwohcidb_tr *, int); -static void dump_db (struct fwohci_softc *, uint32_t); -static void print_db (struct fwohcidb_tr *, struct fwohcidb *, uint32_t , uint32_t); -static void dump_dma (struct fwohci_softc *, uint32_t); +static void dump_db (struct fwohci_softc *, uint32_t); +static void print_db (struct fwohcidb_tr *, struct fwohcidb *, uint32_t , uint32_t); +static void dump_dma (struct fwohci_softc *, uint32_t); static uint32_t fwohci_cyctimer (struct firewire_comm *); static void fwohci_rbuf_update (struct fwohci_softc *, int); static void fwohci_tbuf_update (struct fwohci_softc *, int); @@ -270,18 +257,19 @@ d_ioctl_t fwohci_ioctl; */ /* XXX need lock for phy access */ static uint32_t -fwphy_wrdata( struct fwohci_softc *sc, uint32_t addr, uint32_t data) +fwphy_wrdata(struct fwohci_softc *sc, uint32_t addr, uint32_t data) { uint32_t fun; addr &= 0xf; data &= 0xff; - fun = (PHYDEV_WRCMD | (addr << PHYDEV_REGADDR) | (data << PHYDEV_WRDATA)); + fun = (PHYDEV_WRCMD | (addr << PHYDEV_REGADDR) | + (data << PHYDEV_WRDATA)); OWRITE(sc, OHCI_PHYACCESS, fun); DELAY(100); - return(fwphy_rddata( sc, addr)); + return (fwphy_rddata(sc, addr)); } static uint32_t @@ -302,17 +290,16 @@ fwohci_set_bus_manager(struct firewire_comm *fc, u_int node) for (i = 0; !(OREAD(sc, OHCI_CSR_CONT) & (1<<31)) && (i < 1000); i++) DELAY(10); bm = OREAD(sc, OHCI_CSR_DATA); - if((bm & 0x3f) == 0x3f) + if ((bm & 0x3f) == 0x3f) bm = node; if (firewire_debug) device_printf(sc->fc.dev, "%s: %d->%d (loop=%d)\n", __func__, bm, node, i); - - return(bm); + return (bm); } static uint32_t -fwphy_rddata(struct fwohci_softc *sc, u_int addr) +fwphy_rddata(struct fwohci_softc *sc, u_int addr) { uint32_t fun, stat; u_int i, retry = 0; @@ -323,13 +310,13 @@ fwphy_rddata(struct fwohci_softc *sc, u_int addr) OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_REG_FAIL); fun = PHYDEV_RDCMD | (addr << PHYDEV_REGADDR); OWRITE(sc, OHCI_PHYACCESS, fun); - for ( i = 0 ; i < MAX_RETRY ; i ++ ){ + for (i = 0; i < MAX_RETRY; i++) { fun = OREAD(sc, OHCI_PHYACCESS); if ((fun & PHYDEV_RDCMD) == 0 && (fun & PHYDEV_RDDONE) != 0) break; DELAY(100); } - if(i >= MAX_RETRY) { + if (i >= MAX_RETRY) { if (firewire_debug) device_printf(sc->fc.dev, "%s: failed(1).\n", __func__); if (++retry < MAX_RETRY) { @@ -349,12 +336,13 @@ fwphy_rddata(struct fwohci_softc *sc, u_int addr) } } if (firewire_debug > 1 || retry >= MAX_RETRY) - device_printf(sc->fc.dev, + device_printf(sc->fc.dev, "%s:: 0x%x loop=%d, retry=%d\n", __func__, addr, i, retry); #undef MAX_RETRY - return((fun >> PHYDEV_RDDATA )& 0xff); + return ((fun >> PHYDEV_RDDATA) & 0xff); } + /* Device specific ioctl. */ int fwohci_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) @@ -363,41 +351,41 @@ fwohci_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td) struct fwohci_softc *fc; int unit = DEV2UNIT(dev); int err = 0; - struct fw_reg_req_t *reg = (struct fw_reg_req_t *) data; + struct fw_reg_req_t *reg = (struct fw_reg_req_t *) data; uint32_t *dmach = (uint32_t *) data; sc = devclass_get_softc(firewire_devclass, unit); - if(sc == NULL){ - return(EINVAL); - } + if (sc == NULL) + return (EINVAL); + fc = (struct fwohci_softc *)sc->fc; if (!data) - return(EINVAL); + return (EINVAL); switch (cmd) { case FWOHCI_WRREG: #define OHCI_MAX_REG 0x800 - if(reg->addr <= OHCI_MAX_REG){ + if (reg->addr <= OHCI_MAX_REG) { OWRITE(fc, reg->addr, reg->data); reg->data = OREAD(fc, reg->addr); - }else{ + } else { err = EINVAL; } break; case FWOHCI_RDREG: - if(reg->addr <= OHCI_MAX_REG){ + if (reg->addr <= OHCI_MAX_REG) { reg->data = OREAD(fc, reg->addr); - }else{ + } else { err = EINVAL; } break; /* Read DMA descriptors for debug */ case DUMPDMA: - if(*dmach <= OHCI_MAX_DMA_CH ){ + if (*dmach <= OHCI_MAX_DMA_CH) { dump_dma(fc, *dmach); dump_db(fc, *dmach); - }else{ + } else { err = EINVAL; } break; @@ -427,19 +415,20 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev) { uint32_t reg, reg2; int e1394a = 1; -/* - * probe PHY parameters - * 0. to prove PHY version, whether compliance of 1394a. - * 1. to probe maximum speed supported by the PHY and - * number of port supported by core-logic. - * It is not actually available port on your PC . - */ + + /* + * probe PHY parameters + * 0. to prove PHY version, whether compliance of 1394a. + * 1. to probe maximum speed supported by the PHY and + * number of port supported by core-logic. + * It is not actually available port on your PC . + */ OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_LPS); DELAY(500); reg = fwphy_rddata(sc, FW_PHY_SPD_REG); - if((reg >> 5) != 7 ){ + if ((reg >> 5) != 7) { sc->fc.mode &= ~FWPHYASYST; sc->fc.nport = reg & FW_PHY_NP; sc->fc.speed = reg & FW_PHY_SPD >> 6; @@ -451,7 +440,7 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev) device_printf(dev, "Phy 1394 only %s, %d ports.\n", linkspeed[sc->fc.speed], sc->fc.nport); - }else{ + } else { reg2 = fwphy_rddata(sc, FW_PHY_ESPD_REG); sc->fc.mode |= FWPHYASYST; sc->fc.nport = reg & FW_PHY_NP; @@ -488,7 +477,7 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev) } reg = fwphy_rddata(sc, FW_PHY_SPD_REG); - if((reg >> 5) == 7 ){ + if ((reg >> 5) == 7) { reg = fwphy_rddata(sc, 4); reg |= 1 << 6; fwphy_wrdata(sc, 4, reg); @@ -505,19 +494,19 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev) uint32_t reg, reg2; struct fwohcidb_tr *db_tr; - /* Disable interrupts */ + /* Disable interrupts */ OWRITE(sc, FWOHCI_INTMASKCLR, ~0); /* Now stopping all DMA channels */ - OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_IR_MASKCLR, ~0); - for( i = 0 ; i < sc->fc.nisodma ; i ++ ){ - OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_IR_MASKCLR, ~0); + for (i = 0; i < sc->fc.nisodma; i++) { + OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN); } /* FLUSH FIFO and reset Transmitter/Reciever */ @@ -525,7 +514,7 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev) if (firewire_debug) device_printf(dev, "resetting OHCI..."); i = 0; - while(OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_RESET) { + while (OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_RESET) { if (i++ > 100) break; DELAY(1000); } @@ -536,7 +525,7 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev) fwohci_probe_phy(sc, dev); /* Probe link */ - reg = OREAD(sc, OHCI_BUS_OPT); + reg = OREAD(sc, OHCI_BUS_OPT); reg2 = reg | OHCI_BUSFNC; max_rec = (reg & 0x0000f000) >> 12; speed = (reg & 0x00000007); @@ -551,7 +540,7 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev) } if (firewire_debug) device_printf(dev, "BUS_OPT 0x%x -> 0x%x\n", reg, reg2); - OWRITE(sc, OHCI_BUS_OPT, reg2); + OWRITE(sc, OHCI_BUS_OPT, reg2); /* Initialize registers */ OWRITE(sc, OHCI_CROMHDR, sc->fc.config_rom[0]); @@ -577,33 +566,31 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev) /* AT Retries */ OWRITE(sc, FWOHCI_RETRY, /* CycleLimit PhyRespRetries ATRespRetries ATReqRetries */ - (0xffff << 16 ) | (0x0f << 8) | (0x0f << 4) | 0x0f) ; + (0xffff << 16) | (0x0f << 8) | (0x0f << 4) | 0x0f); sc->atrq.top = STAILQ_FIRST(&sc->atrq.db_trq); sc->atrs.top = STAILQ_FIRST(&sc->atrs.db_trq); sc->atrq.bottom = sc->atrq.top; sc->atrs.bottom = sc->atrs.top; - for( i = 0, db_tr = sc->atrq.top; i < sc->atrq.ndb ; - i ++, db_tr = STAILQ_NEXT(db_tr, link)){ + for (i = 0, db_tr = sc->atrq.top; i < sc->atrq.ndb; + i++, db_tr = STAILQ_NEXT(db_tr, link)) { db_tr->xfer = NULL; } - for( i = 0, db_tr = sc->atrs.top; i < sc->atrs.ndb ; - i ++, db_tr = STAILQ_NEXT(db_tr, link)){ + for (i = 0, db_tr = sc->atrs.top; i < sc->atrs.ndb; + i++, db_tr = STAILQ_NEXT(db_tr, link)) { db_tr->xfer = NULL; } - /* Enable interrupts */ sc->intmask = (OHCI_INT_ERR | OHCI_INT_PHY_SID - | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS + | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS | OHCI_INT_DMA_PRRQ | OHCI_INT_DMA_PRRS | OHCI_INT_PHY_BUS_R | OHCI_INT_PW_ERR); sc->intmask |= OHCI_INT_DMA_IR | OHCI_INT_DMA_IT; sc->intmask |= OHCI_INT_CYC_LOST | OHCI_INT_PHY_INT; OWRITE(sc, FWOHCI_INTMASK, sc->intmask); fwohci_set_intr(&sc->fc, 1); - } int @@ -617,7 +604,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) reg = OREAD(sc, OHCI_VERSION); mver = (reg >> 16) & 0xff; device_printf(dev, "OHCI version %x.%x (ROM=%d)\n", - mver, reg & 0xff, (reg>>24) & 1); + mver, reg & 0xff, (reg >> 24) & 1); if (mver < 1 || mver > 9) { device_printf(dev, "invalid OHCI version\n"); return (ENXIO); @@ -672,7 +659,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) sc->atrq.ndb = NDB; sc->atrs.ndb = NDB / 2; - for( i = 0 ; i < sc->fc.nisodma ; i ++ ){ + for (i = 0; i < sc->fc.nisodma; i++) { sc->fc.it[i] = &sc->it[i].xferq; sc->fc.ir[i] = &sc->ir[i].xferq; sc->it[i].xferq.dmach = i; @@ -686,7 +673,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) sc->fc.config_rom = fwdma_malloc(&sc->fc, CROMSIZE, CROMSIZE, &sc->crom_dma, BUS_DMA_WAITOK | BUS_DMA_COHERENT); - if(sc->fc.config_rom == NULL){ + if (sc->fc.config_rom == NULL) { device_printf(dev, "config_rom alloc failed."); return ENOMEM; } @@ -703,7 +690,6 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) sc->fc.config_rom[0] |= fw_crc16(&sc->fc.config_rom[1], 5*4); #endif - /* SID recieve buffer must align 2^11 */ #define OHCI_SIDSIZE (1 << 11) sc->sid_buf = fwdma_malloc(&sc->fc, OHCI_SIDSIZE, OHCI_SIDSIZE, @@ -714,7 +700,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) } fwdma_malloc(&sc->fc, sizeof(uint32_t), sizeof(uint32_t), - &sc->dummy_dma, BUS_DMA_WAITOK); + &sc->dummy_dma, BUS_DMA_WAITOK); if (sc->dummy_dma.v_addr == NULL) { device_printf(dev, "dummy_dma alloc failed."); @@ -739,7 +725,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) sc->fc.eui.hi = OREAD(sc, FWOHCIGUID_H); sc->fc.eui.lo = OREAD(sc, FWOHCIGUID_L); - for( i = 0 ; i < 8 ; i ++) + for (i = 0; i < 8; i++) ui[i] = FW_EUI64_BYTE(&sc->fc.eui,i); device_printf(dev, "EUI64 %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", ui[0], ui[1], ui[2], ui[3], ui[4], ui[5], ui[6], ui[7]); @@ -769,7 +755,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) sc->fc.taskqueue = taskqueue_create_fast("fw_taskq", M_WAITOK, taskqueue_thread_enqueue, &sc->fc.taskqueue); taskqueue_start_threads(&sc->fc.taskqueue, 1, PI_NET, "fw%d_taskq", - device_get_unit(dev)); + device_get_unit(dev)); TASK_INIT(&sc->fwohci_task_busreset, 2, fwohci_task_busreset, sc); TASK_INIT(&sc->fwohci_task_sid, 1, fwohci_task_sid, sc); TASK_INIT(&sc->fwohci_task_dma, 0, fwohci_task_dma, sc); @@ -792,7 +778,7 @@ uint32_t fwohci_cyctimer(struct firewire_comm *fc) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; - return(OREAD(sc, OHCI_CYCLETIMER)); + return (OREAD(sc, OHCI_CYCLETIMER)); } int @@ -811,7 +797,7 @@ fwohci_detach(struct fwohci_softc *sc, device_t dev) fwohci_db_free(&sc->atrq); fwohci_db_free(&sc->atrs); - for( i = 0 ; i < sc->fc.nisodma ; i ++ ){ + for (i = 0; i < sc->fc.nisodma; i++) { fwohci_db_free(&sc->it[i]); fwohci_db_free(&sc->ir[i]); } @@ -832,7 +818,7 @@ fwohci_detach(struct fwohci_softc *sc, device_t dev) int _cnt = _dbtr->dbcnt; \ db = &_dbtr->db[ (_cnt > 2) ? (_cnt -1) : 0]; \ } while (0) - + static void fwohci_execute_db(void *arg, bus_dma_segment_t *segs, int nseg, int error) { @@ -860,7 +846,7 @@ fwohci_execute_db(void *arg, bus_dma_segment_t *segs, int nseg, int error) static void fwohci_execute_db2(void *arg, bus_dma_segment_t *segs, int nseg, - bus_size_t size, int error) + bus_size_t size, int error) { fwohci_execute_db(arg, segs, nseg, error); } @@ -883,11 +869,11 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) FW_GLOCK_ASSERT(&sc->fc); - if(&sc->atrq == dbch){ + if (&sc->atrq == dbch) { off = OHCI_ATQOFF; - }else if(&sc->atrs == dbch){ + } else if (&sc->atrs == dbch) { off = OHCI_ATSOFF; - }else{ + } else { return; } @@ -898,11 +884,11 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) db_tr = dbch->top; txloop: xfer = STAILQ_FIRST(&dbch->xferq.q); - if(xfer == NULL){ + if (xfer == NULL) { goto kick; } #if 0 - if(dbch->xferq.queued == 0 ){ + if (dbch->xferq.queued == 0) { device_printf(sc->fc.dev, "TX queue empty\n"); } #endif @@ -919,11 +905,11 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) ld = &ohcifp->mode.ld[0]; ld[0] = ld[1] = ld[2] = ld[3] = 0; - for( i = 0 ; i < pl_off ; i+= 4) + for (i = 0; i < pl_off; i+= 4) ld[i/4] = fp->mode.ld[i/4]; ohcifp->mode.common.spd = xfer->send.spd & 0x7; - if (tcode == FWTCODE_STREAM ){ + if (tcode == FWTCODE_STREAM) { hdr_len = 8; ohcifp->mode.stream.len = fp->mode.stream.len; } else if (tcode == FWTCODE_PHY) { @@ -943,14 +929,14 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) FWOHCI_DMA_WRITE(db->db.desc.addr, 0); FWOHCI_DMA_WRITE(db->db.desc.res, 0); /* Specify bound timer of asy. responce */ - if(&sc->atrs == dbch){ + if (&sc->atrs == dbch) { FWOHCI_DMA_WRITE(db->db.desc.res, (OREAD(sc, OHCI_CYCLETIMER) >> 12) + (1 << 13)); } #if BYTE_ORDER == BIG_ENDIAN if (tcode == FWTCODE_WREQQ || tcode == FWTCODE_RRESQ) hdr_len = 12; - for (i = 0; i < hdr_len/4; i ++) + for (i = 0; i < hdr_len/4; i++) FWOHCI_DMA_WRITE(ld[i], ld[i]); #endif @@ -981,7 +967,7 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) m_copydata(xfer->mbuf, 0, xfer->mbuf->m_pkthdr.len, mtod(m0, caddr_t)); - m0->m_len = m0->m_pkthdr.len = + m0->m_len = m0->m_pkthdr.len = xfer->mbuf->m_pkthdr.len; m_freem(xfer->mbuf); xfer->mbuf = m0; @@ -1012,16 +998,16 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) FWOHCI_DMA_WRITE(db->db.desc.depend, STAILQ_NEXT(db_tr, link)->bus_addr); - if(fsegment == -1 ) + if (fsegment == -1) fsegment = db_tr->dbcnt; if (dbch->pdb_tr != NULL) { LAST_DB(dbch->pdb_tr, db); FWOHCI_DMA_SET(db->db.desc.depend, db_tr->dbcnt); } - dbch->xferq.queued ++; + dbch->xferq.queued++; dbch->pdb_tr = db_tr; db_tr = STAILQ_NEXT(db_tr, link); - if(db_tr != dbch->bottom){ + if (db_tr != dbch->bottom) { goto txloop; } else { device_printf(sc->fc.dev, "fwohci_start: lack of db_trq\n"); @@ -1032,7 +1018,7 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREREAD); fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREWRITE); - if(dbch->xferq.flag & FWXFERQ_RUNNING) { + if (dbch->xferq.flag & FWXFERQ_RUNNING) { OWRITE(sc, OHCI_DMACTL(off), OHCI_CNTL_DMA_WAKE); } else { if (firewire_debug) @@ -1053,7 +1039,7 @@ fwohci_start_atq(struct firewire_comm *fc) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; FW_GLOCK(&sc->fc); - fwohci_start( sc, &(sc->atrq)); + fwohci_start(sc, &(sc->atrq)); FW_GUNLOCK(&sc->fc); return; } @@ -1063,7 +1049,7 @@ fwohci_start_ats(struct firewire_comm *fc) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; FW_GLOCK(&sc->fc); - fwohci_start( sc, &(sc->atrs)); + fwohci_start(sc, &(sc->atrs)); FW_GUNLOCK(&sc->fc); return; } @@ -1080,13 +1066,13 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) int packets; struct firewire_comm *fc = (struct firewire_comm *)sc; - if(&sc->atrq == dbch){ + if (&sc->atrq == dbch) { off = OHCI_ATQOFF; ch = ATRQ_CH; - }else if(&sc->atrs == dbch){ + } else if (&sc->atrs == dbch) { off = OHCI_ATSOFF; ch = ATRS_CH; - }else{ + } else { return; } s = splfw(); @@ -1094,11 +1080,11 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) packets = 0; fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_POSTREAD); fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_POSTWRITE); - while(dbch->xferq.queued > 0){ + while (dbch->xferq.queued > 0) { LAST_DB(tr, db); status = FWOHCI_DMA_READ(db->db.desc.res) >> OHCI_STATUS_SHIFT; - if(!(status & OHCI_CNTL_DMA_ACTIVE)){ - if (fc->status != FWBUSINIT) + if (!(status & OHCI_CNTL_DMA_ACTIVE)) { + if (fc->status != FWBUSINIT) /* maybe out of order?? */ goto out; } @@ -1109,7 +1095,7 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) if (firewire_debug > 1) dump_db(sc, ch); #endif - if(status & OHCI_CNTL_DMA_DEAD) { + if (status & OHCI_CNTL_DMA_DEAD) { /* Stop DMA */ OWRITE(sc, OHCI_DMACTLCLR(off), OHCI_CNTL_DMA_RUN); device_printf(sc->fc.dev, "force reset AT FIFO\n"); @@ -1118,7 +1104,7 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) OWRITE(sc, OHCI_DMACTLCLR(off), OHCI_CNTL_DMA_RUN); } stat = status & FWOHCIEV_MASK; - switch(stat){ + switch (stat) { case FWOHCIEV_ACKPEND: case FWOHCIEV_ACKCOMPL: err = 0; @@ -1126,12 +1112,10 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) case FWOHCIEV_ACKBSA: case FWOHCIEV_ACKBSB: case FWOHCIEV_ACKBSX: - device_printf(sc->fc.dev, "txd err=%2x %s\n", stat, fwohcicode[stat]); err = EBUSY; break; case FWOHCIEV_FLUSHED: case FWOHCIEV_ACKTARD: - device_printf(sc->fc.dev, "txd err=%2x %s\n", stat, fwohcicode[stat]); err = EAGAIN; break; case FWOHCIEV_MISSACK: @@ -1145,8 +1129,6 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) case FWOHCIEV_ACKDERR: case FWOHCIEV_ACKTERR: default: - device_printf(sc->fc.dev, "txd err=%2x %s\n", - stat, fwohcicode[stat]); err = EINVAL; break; } @@ -1176,17 +1158,17 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) } /* * The watchdog timer takes care of split - * transcation timeout for ACKPEND case. + * transaction timeout for ACKPEND case. */ } else { printf("this shouldn't happen\n"); } FW_GLOCK(fc); - dbch->xferq.queued --; + dbch->xferq.queued--; FW_GUNLOCK(fc); tr->xfer = NULL; - packets ++; + packets++; tr = STAILQ_NEXT(tr, link); dbch->bottom = tr; if (dbch->bottom == dbch->top) { @@ -1216,10 +1198,10 @@ fwohci_db_free(struct fwohci_dbch *dbch) if ((dbch->flags & FWOHCI_DBCH_INIT) == 0) return; - for(db_tr = STAILQ_FIRST(&dbch->db_trq), idb = 0; idb < dbch->ndb; - db_tr = STAILQ_NEXT(db_tr, link), idb++){ + for (db_tr = STAILQ_FIRST(&dbch->db_trq), idb = 0; idb < dbch->ndb; + db_tr = STAILQ_NEXT(db_tr, link), idb++) { if ((dbch->xferq.flag & FWXFERQ_EXTBUF) == 0 && - db_tr->buf != NULL) { + db_tr->buf != NULL) { fwdma_free_size(dbch->dmat, db_tr->dma_map, db_tr->buf, dbch->xferq.psize); db_tr->buf = NULL; @@ -1254,10 +1236,8 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) /*nsegments*/ dbch->ndesc > 3 ? dbch->ndesc - 2 : 1, /*maxsegsz*/ MAX_REQCOUNT, /*flags*/ 0, -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 /*lockfunc*/busdma_lock_mutex, /*lockarg*/FW_GMTX(&sc->fc), -#endif &dbch->dmat)) return; @@ -1267,13 +1247,13 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) db_tr = (struct fwohcidb_tr *) malloc(sizeof(struct fwohcidb_tr) * dbch->ndb, M_FW, M_WAITOK | M_ZERO); - if(db_tr == NULL){ + if (db_tr == NULL) { printf("fwohci_db_init: malloc(1) failed\n"); return; } #define DB_SIZE(x) (sizeof(struct fwohcidb) * (x)->ndesc) - dbch->am = fwdma_malloc_multiseg(&sc->fc, DB_SIZE(dbch), + dbch->am = fwdma_malloc_multiseg(&sc->fc, sizeof(struct fwohcidb), DB_SIZE(dbch), dbch->ndb, BUS_DMA_WAITOK); if (dbch->am == NULL) { printf("fwohci_db_init: fwdma_malloc_multiseg failed\n"); @@ -1281,7 +1261,7 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) return; } /* Attach DB to DMA ch. */ - for(idb = 0 ; idb < dbch->ndb ; idb++){ + for (idb = 0; idb < dbch->ndb; idb++) { db_tr->dbcnt = 0; db_tr->db = (struct fwohcidb *)fwdma_v_addr(dbch->am, idb); db_tr->bus_addr = fwdma_bus_addr(dbch->am, idb); @@ -1320,7 +1300,7 @@ fwohci_itx_disable(struct firewire_comm *fc, int dmach) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; - OWRITE(sc, OHCI_ITCTLCLR(dmach), + OWRITE(sc, OHCI_ITCTLCLR(dmach), OHCI_CNTL_DMA_RUN | OHCI_CNTL_CYCMATCH_S); OWRITE(sc, OHCI_IT_MASKCLR, 1 << dmach); OWRITE(sc, OHCI_IT_STATCLR, 1 << dmach); @@ -1364,31 +1344,31 @@ fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) struct fwohcidb_tr *db_tr; struct fwohcidb *db; - if(!(dbch->xferq.flag & FWXFERQ_EXTBUF)){ + if (!(dbch->xferq.flag & FWXFERQ_EXTBUF)) { err = EINVAL; return err; } z = dbch->ndesc; - for(dmach = 0 ; dmach < sc->fc.nisodma ; dmach++){ - if( &sc->it[dmach] == dbch){ + for (dmach = 0; dmach < sc->fc.nisodma; dmach++) { + if (&sc->it[dmach] == dbch) { off = OHCI_ITOFF(dmach); break; } } - if(off == 0){ + if (off == 0) { err = EINVAL; return err; } - if(dbch->xferq.flag & FWXFERQ_RUNNING) + if (dbch->xferq.flag & FWXFERQ_RUNNING) return err; dbch->xferq.flag |= FWXFERQ_RUNNING; - for( i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++){ + for (i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++) { dbch->bottom = STAILQ_NEXT(dbch->bottom, link); } db_tr = dbch->top; - for (idb = 0; idb < dbch->ndb; idb ++) { + for (idb = 0; idb < dbch->ndb; idb++) { fwohci_add_tx_buf(dbch, db_tr, idb); - if(STAILQ_NEXT(db_tr, link) == NULL){ + if (STAILQ_NEXT(db_tr, link) == NULL) { break; } db = db_tr->db; @@ -1396,8 +1376,8 @@ fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) FWOHCI_DMA_WRITE(db[0].db.desc.depend, STAILQ_NEXT(db_tr, link)->bus_addr | z); db[ldesc].db.desc.depend = db[0].db.desc.depend; - if(dbch->xferq.flag & FWXFERQ_EXTBUF){ - if(((idb + 1 ) % dbch->xferq.bnpacket) == 0){ + if (dbch->xferq.flag & FWXFERQ_EXTBUF) { + if (((idb + 1) % dbch->xferq.bnpacket) == 0) { FWOHCI_DMA_SET( db[ldesc].db.desc.cmd, OHCI_INTERRUPT_ALWAYS); @@ -1424,38 +1404,38 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) struct fwohcidb *db; z = dbch->ndesc; - if(&sc->arrq == dbch){ + if (&sc->arrq == dbch) { off = OHCI_ARQOFF; - }else if(&sc->arrs == dbch){ + } else if (&sc->arrs == dbch) { off = OHCI_ARSOFF; - }else{ - for(dmach = 0 ; dmach < sc->fc.nisodma ; dmach++){ - if( &sc->ir[dmach] == dbch){ + } else { + for (dmach = 0; dmach < sc->fc.nisodma; dmach++) { + if (&sc->ir[dmach] == dbch) { off = OHCI_IROFF(dmach); break; } } } - if(off == 0){ + if (off == 0) { err = EINVAL; return err; } - if(dbch->xferq.flag & FWXFERQ_STREAM){ - if(dbch->xferq.flag & FWXFERQ_RUNNING) + if (dbch->xferq.flag & FWXFERQ_STREAM) { + if (dbch->xferq.flag & FWXFERQ_RUNNING) return err; - }else{ - if(dbch->xferq.flag & FWXFERQ_RUNNING){ + } else { + if (dbch->xferq.flag & FWXFERQ_RUNNING) { err = EBUSY; return err; } } dbch->xferq.flag |= FWXFERQ_RUNNING; dbch->top = STAILQ_FIRST(&dbch->db_trq); - for( i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++){ + for (i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++) { dbch->bottom = STAILQ_NEXT(dbch->bottom, link); } db_tr = dbch->top; - for (idb = 0; idb < dbch->ndb; idb ++) { + for (idb = 0; idb < dbch->ndb; idb++) { fwohci_add_rx_buf(dbch, db_tr, idb, &sc->dummy_dma); if (STAILQ_NEXT(db_tr, link) == NULL) break; @@ -1463,8 +1443,8 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) ldesc = db_tr->dbcnt - 1; FWOHCI_DMA_WRITE(db[ldesc].db.desc.depend, STAILQ_NEXT(db_tr, link)->bus_addr | z); - if(dbch->xferq.flag & FWXFERQ_EXTBUF){ - if(((idb + 1 ) % dbch->xferq.bnpacket) == 0){ + if (dbch->xferq.flag & FWXFERQ_EXTBUF) { + if (((idb + 1) % dbch->xferq.bnpacket) == 0) { FWOHCI_DMA_SET( db[ldesc].db.desc.cmd, OHCI_INTERRUPT_ALWAYS); @@ -1480,9 +1460,9 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) dbch->buf_offset = 0; fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREREAD); fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREWRITE); - if(dbch->xferq.flag & FWXFERQ_STREAM){ + if (dbch->xferq.flag & FWXFERQ_STREAM) { return err; - }else{ + } else { OWRITE(sc, OHCI_DMACMD(off), dbch->top->bus_addr | z); } OWRITE(sc, OHCI_DMACTL(off), OHCI_CNTL_DMA_RUN); @@ -1504,12 +1484,12 @@ fwohci_next_cycle(struct firewire_comm *fc, int cycle_now) #endif cycle = cycle + CYCLE_DELAY; if (cycle >= 8000) { - sec ++; + sec++; cycle -= 8000; } cycle = roundup2(cycle, CYCLE_MOD); if (cycle >= 8000) { - sec ++; + sec++; if (cycle == 8000) cycle = 0; else @@ -1517,7 +1497,7 @@ fwohci_next_cycle(struct firewire_comm *fc, int cycle_now) } cycle_match = ((sec << 13) | cycle) & 0x7ffff; - return(cycle_match); + return (cycle_match); } static int @@ -1546,7 +1526,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach) err = fwohci_tx_enable(sc, dbch); } - if(err) + if (err) return err; ldesc = dbch->ndesc - 1; @@ -1566,7 +1546,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach) OHCI_BRANCH_ALWAYS); #endif #if 0 /* if bulkxfer->npacket changes */ - db[ldesc].db.desc.depend = db[0].db.desc.depend = + db[ldesc].db.desc.depend = db[0].db.desc.depend = ((struct fwohcidb_tr *) (chunk->start))->bus_addr | dbch->ndesc; #else @@ -1669,7 +1649,7 @@ fwohci_irx_enable(struct firewire_comm *fc, int dmach) return ENOMEM; err = fwohci_rx_enable(sc, dbch); } - if(err) + if (err) return err; first = STAILQ_FIRST(&ir->stfree); @@ -1748,28 +1728,28 @@ fwohci_stop(struct fwohci_softc *sc, device_t dev) fwohci_set_intr(&sc->fc, 0); /* Now stopping all DMA channel */ - OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); - for( i = 0 ; i < sc->fc.nisodma ; i ++ ){ - OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN); - OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN); + for (i = 0; i < sc->fc.nisodma; i++) { + OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN); } -#if 0 /* Let dcons(4) be accessed */ +#if 0 /* Let dcons(4) be accessed */ /* Stop interrupt */ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_EN | OHCI_INT_ERR | OHCI_INT_PHY_SID | OHCI_INT_PHY_INT - | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS + | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS | OHCI_INT_DMA_PRRQ | OHCI_INT_DMA_PRRS - | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS + | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS | OHCI_INT_PHY_BUS_R); /* FLUSH FIFO and reset Transmitter/Reciever */ - OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_RESET); + OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_RESET); #endif /* XXX Link down? Bus reset? */ @@ -1785,14 +1765,14 @@ fwohci_resume(struct fwohci_softc *sc, device_t dev) fwohci_reset(sc, dev); /* XXX resume isochronous receive automatically. (how about TX?) */ - for(i = 0; i < sc->fc.nisodma; i ++) { + for (i = 0; i < sc->fc.nisodma; i++) { ir = &sc->ir[i].xferq; - if((ir->flag & FWXFERQ_RUNNING) != 0) { + if ((ir->flag & FWXFERQ_RUNNING) != 0) { device_printf(sc->fc.dev, "resume iso receive ch: %d\n", i); ir->flag &= ~FWXFERQ_RUNNING; /* requeue stdma to stfree */ - while((chunk = STAILQ_FIRST(&ir->stdma)) != NULL) { + while ((chunk = STAILQ_FIRST(&ir->stdma)) != NULL) { STAILQ_REMOVE_HEAD(&ir->stdma, link); STAILQ_INSERT_TAIL(&ir->stfree, chunk, link); } @@ -1809,7 +1789,7 @@ fwohci_resume(struct fwohci_softc *sc, device_t dev) static void fwohci_dump_intr(struct fwohci_softc *sc, uint32_t stat) { - if(stat & OREAD(sc, FWOHCI_INTMASK)) + if (stat & OREAD(sc, FWOHCI_INTMASK)) device_printf(fc->dev, "INTERRUPT < %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s> 0x%08x, 0x%08x\n", stat & OHCI_INT_EN ? "DMA_EN ":"", stat & OHCI_INT_PHY_REG ? "PHY_REG ":"", @@ -1832,10 +1812,11 @@ fwohci_dump_intr(struct fwohci_softc *sc, uint32_t stat) stat & OHCI_INT_DMA_ARRQ ? "DMA_ARRQ " :"", stat & OHCI_INT_DMA_ATRS ? "DMA_ATRS " :"", stat & OHCI_INT_DMA_ATRQ ? "DMA_ATRQ " :"", - stat, OREAD(sc, FWOHCI_INTMASK) + stat, OREAD(sc, FWOHCI_INTMASK) ); } #endif + static void fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) { @@ -1846,15 +1827,15 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) if ((stat & OHCI_INT_PHY_BUS_R) && (fc->status != FWBUSRESET)) { fc->status = FWBUSRESET; /* Disable bus reset interrupt until sid recv. */ - OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); - + OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); + device_printf(fc->dev, "%s: BUS reset\n", __func__); - OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); + OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); - OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); sc->atrq.xferq.flag &= ~FWXFERQ_RUNNING; - OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); + OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); sc->atrs.xferq.flag &= ~FWXFERQ_RUNNING; if (!kdb_active) @@ -1875,10 +1856,10 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) OWRITE(sc, OHCI_PREQUPPER, 0x10000); } /* Set ATRetries register */ - OWRITE(sc, OHCI_ATRETRY, 1<<(13+16) | 0xfff); + OWRITE(sc, OHCI_ATRETRY, 1<<(13 + 16) | 0xfff); /* - * Checking whether the node is root or not. If root, turn on + * Checking whether the node is root or not. If root, turn on * cycle master. */ node_id = OREAD(sc, FWOHCI_NODEID); @@ -1895,7 +1876,7 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) /* cycle timer */ sc->cycle_lost = 0; - OWRITE(sc, FWOHCI_INTMASK, OHCI_INT_CYC_LOST); + OWRITE(sc, FWOHCI_INTMASK, OHCI_INT_CYC_LOST); if ((node_id & OHCI_NODE_ROOT) && !nocyclemaster) { printf("CYCLEMASTER mode\n"); OWRITE(sc, OHCI_LNKCTL, @@ -1925,10 +1906,10 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) if (stat & OHCI_INT_DMA_IR) { irstat = atomic_readandclear_int(&sc->irstat); - for(i = 0; i < fc->nisodma ; i++){ + for (i = 0; i < fc->nisodma; i++) { struct fwohci_dbch *dbch; - if((irstat & (1 << i)) != 0){ + if ((irstat & (1 << i)) != 0) { dbch = &sc->ir[i]; if ((dbch->xferq.flag & FWXFERQ_OPEN) == 0) { device_printf(sc->fc.dev, @@ -1941,8 +1922,8 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) } if (stat & OHCI_INT_DMA_IT) { itstat = atomic_readandclear_int(&sc->itstat); - for(i = 0; i < fc->nisodma ; i++){ - if((itstat & (1 << i)) != 0){ + for (i = 0; i < fc->nisodma; i++) { + if ((itstat & (1 << i)) != 0) { fwohci_tbuf_update(sc, i); } } @@ -1963,13 +1944,13 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) } if (stat & OHCI_INT_CYC_LOST) { if (sc->cycle_lost >= 0) - sc->cycle_lost ++; + sc->cycle_lost++; if (sc->cycle_lost > 10) { sc->cycle_lost = -1; #if 0 OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCTIMER); #endif - OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); + OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); device_printf(fc->dev, "too many cycles lost, " "no cycle master present?\n"); } @@ -1989,8 +1970,6 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) if (stat & OHCI_INT_PHY_INT) { device_printf(fc->dev, "phy int\n"); } - - return; } static void @@ -2035,8 +2014,8 @@ fwohci_task_sid(void *arg, int pending) device_printf(fc->dev, "malloc failed\n"); return; } - for (i = 0; i < plen / 4; i ++) - buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i+1]); + for (i = 0; i < plen / 4; i++) + buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i + 1]); /* pending all pre-bus_reset packets */ fwohci_txd(sc, &sc->atrq); @@ -2155,7 +2134,7 @@ fwohci_tbuf_update(struct fwohci_softc *sc, int dmach) dump_db(sc, ITX_CH + dmach); while ((chunk = STAILQ_FIRST(&it->stdma)) != NULL) { db = ((struct fwohcidb_tr *)(chunk->end))->db; - stat = FWOHCI_DMA_READ(db[ldesc].db.desc.res) + stat = FWOHCI_DMA_READ(db[ldesc].db.desc.res) >> OHCI_STATUS_SHIFT; db = ((struct fwohcidb_tr *)(chunk->start))->db; /* timestamp */ @@ -2164,7 +2143,7 @@ fwohci_tbuf_update(struct fwohci_softc *sc, int dmach) if (stat == 0) break; STAILQ_REMOVE_HEAD(&it->stdma, link); - switch (stat & FWOHCIEV_MASK){ + switch (stat & FWOHCIEV_MASK) { case FWOHCIEV_ACKCOMPL: #if 0 device_printf(fc->dev, "0x%08x\n", count); @@ -2243,7 +2222,7 @@ fwohci_rbuf_update(struct fwohci_softc *sc, int dmach) if (w == 0) return; - if (ir->flag & FWXFERQ_HANDLER) + if (ir->flag & FWXFERQ_HANDLER) ir->hand(ir); else wakeup(ir); @@ -2254,17 +2233,17 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch) { uint32_t off, cntl, stat, cmd, match; - if(ch == 0){ + if (ch == 0) { off = OHCI_ATQOFF; - }else if(ch == 1){ + } else if (ch == 1) { off = OHCI_ATSOFF; - }else if(ch == 2){ + } else if (ch == 2) { off = OHCI_ARQOFF; - }else if(ch == 3){ + } else if (ch == 3) { off = OHCI_ARSOFF; - }else if(ch < IRX_CH){ + } else if (ch < IRX_CH) { off = OHCI_ITCTL(ch - ITX_CH); - }else{ + } else { off = OHCI_IRCTL(ch - IRX_CH); } cntl = stat = OREAD(sc, off); @@ -2273,10 +2252,10 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch) device_printf(sc->fc.dev, "ch %1x cntl:0x%08x cmd:0x%08x match:0x%08x\n", ch, - cntl, - cmd, + cntl, + cmd, match); - stat &= 0xffff ; + stat &= 0xffff; if (stat) { device_printf(sc->fc.dev, "dma %d ch:%s%s%s%s%s%s %s(%x)\n", ch, @@ -2289,7 +2268,7 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch) fwohcicode[stat & 0x1f], stat & 0x1f ); - }else{ + } else { device_printf(sc->fc.dev, "dma %d ch: Nostat\n", ch); } } @@ -2302,60 +2281,61 @@ dump_db(struct fwohci_softc *sc, uint32_t ch) struct fwohcidb *curr = NULL, *prev, *next = NULL; int idb, jdb; uint32_t cmd, off; - if(ch == 0){ + + if (ch == 0) { off = OHCI_ATQOFF; dbch = &sc->atrq; - }else if(ch == 1){ + } else if (ch == 1) { off = OHCI_ATSOFF; dbch = &sc->atrs; - }else if(ch == 2){ + } else if (ch == 2) { off = OHCI_ARQOFF; dbch = &sc->arrq; - }else if(ch == 3){ + } else if (ch == 3) { off = OHCI_ARSOFF; dbch = &sc->arrs; - }else if(ch < IRX_CH){ + } else if (ch < IRX_CH) { off = OHCI_ITCTL(ch - ITX_CH); dbch = &sc->it[ch - ITX_CH]; - }else { + } else { off = OHCI_IRCTL(ch - IRX_CH); dbch = &sc->ir[ch - IRX_CH]; } cmd = OREAD(sc, off + 0xc); - if( dbch->ndb == 0 ){ + if (dbch->ndb == 0) { device_printf(sc->fc.dev, "No DB is attached ch=%d\n", ch); return; } pp = dbch->top; prev = pp->db; - for(idb = 0 ; idb < dbch->ndb ; idb ++ ){ + for (idb = 0; idb < dbch->ndb; idb++) { cp = STAILQ_NEXT(pp, link); - if(cp == NULL){ + if (cp == NULL) { curr = NULL; goto outdb; } np = STAILQ_NEXT(cp, link); - for(jdb = 0 ; jdb < dbch->ndesc ; jdb ++ ){ + for (jdb = 0; jdb < dbch->ndesc; jdb++) { if ((cmd & 0xfffffff0) == cp->bus_addr) { curr = cp->db; - if(np != NULL){ + if (np != NULL) { next = np->db; - }else{ + } else { next = NULL; } goto outdb; } } pp = STAILQ_NEXT(pp, link); - if(pp == NULL){ + if (pp == NULL) { curr = NULL; goto outdb; } prev = pp->db; } outdb: - if( curr != NULL){ + if (curr != NULL) { #if 0 printf("Prev DB %d\n", ch); print_db(pp, prev, ch, dbch->ndesc); @@ -2366,7 +2346,7 @@ dump_db(struct fwohci_softc *sc, uint32_t ch) printf("Next DB %d\n", ch); print_db(np, next, ch, dbch->ndesc); #endif - }else{ + } else { printf("dbdump err ch = %d cmd = 0x%08x\n", ch, cmd); } return; @@ -2380,7 +2360,7 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, int i, key; uint32_t cmd, res; - if(db == NULL){ + if (db == NULL) { printf("No Descriptor is found\n"); return; } @@ -2397,18 +2377,13 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, "Depend", "Stat", "Cnt"); - for( i = 0 ; i <= max ; i ++){ + for (i = 0; i <= max; i++) { cmd = FWOHCI_DMA_READ(db[i].db.desc.cmd); res = FWOHCI_DMA_READ(db[i].db.desc.res); key = cmd & OHCI_KEY_MASK; stat = res >> OHCI_STATUS_SHIFT; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf("%08x %s %s %s %s %5d %08x %08x %04x:%04x", - db_tr->bus_addr, -#else printf("%08jx %s %s %s %s %5d %08x %08x %04x:%04x", (uintmax_t)db_tr->bus_addr, -#endif dbcode[(cmd >> 28) & 0xf], dbkey[(cmd >> 24) & 0x7], dbcond[(cmd >> 20) & 0x3], @@ -2418,7 +2393,7 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, FWOHCI_DMA_READ(db[i].db.desc.depend), stat, res & OHCI_COUNT_MASK); - if(stat & 0xff00){ + if (stat & 0xff00) { printf(" %s%s%s%s%s%s %s(%x)\n", stat & OHCI_CNTL_DMA_RUN ? "RUN," : "", stat & OHCI_CNTL_DMA_WAKE ? "WAKE," : "", @@ -2429,32 +2404,32 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, fwohcicode[stat & 0x1f], stat & 0x1f ); - }else{ + } else { printf(" Nostat\n"); } - if(key == OHCI_KEY_ST2 ){ - printf("0x%08x 0x%08x 0x%08x 0x%08x\n", - FWOHCI_DMA_READ(db[i+1].db.immed[0]), - FWOHCI_DMA_READ(db[i+1].db.immed[1]), - FWOHCI_DMA_READ(db[i+1].db.immed[2]), - FWOHCI_DMA_READ(db[i+1].db.immed[3])); + if (key == OHCI_KEY_ST2) { + printf("0x%08x 0x%08x 0x%08x 0x%08x\n", + FWOHCI_DMA_READ(db[i + 1].db.immed[0]), + FWOHCI_DMA_READ(db[i + 1].db.immed[1]), + FWOHCI_DMA_READ(db[i + 1].db.immed[2]), + FWOHCI_DMA_READ(db[i + 1].db.immed[3])); } - if(key == OHCI_KEY_DEVICE){ + if (key == OHCI_KEY_DEVICE) { return; } - if((cmd & OHCI_BRANCH_MASK) - == OHCI_BRANCH_ALWAYS){ + if ((cmd & OHCI_BRANCH_MASK) + == OHCI_BRANCH_ALWAYS) { return; } - if((cmd & OHCI_CMD_MASK) - == OHCI_OUTPUT_LAST){ + if ((cmd & OHCI_CMD_MASK) + == OHCI_OUTPUT_LAST) { return; } - if((cmd & OHCI_CMD_MASK) - == OHCI_INPUT_LAST){ + if ((cmd & OHCI_CMD_MASK) + == OHCI_INPUT_LAST) { return; } - if(key == OHCI_KEY_ST2 ){ + if (key == OHCI_KEY_ST2) { i++; } } @@ -2515,7 +2490,7 @@ fwohci_txbufdb(struct fwohci_softc *sc, int dmach, struct fw_bulkxfer *bulkxfer) /* device_printf(sc->fc.dev, "DB %08x %08x %08x\n", bulkxfer, db_tr->bus_addr, fdb_tr->bus_addr); */ - for (idb = 0; idb < dbch->xferq.bnpacket; idb ++) { + for (idb = 0; idb < dbch->xferq.bnpacket; idb++) { db = db_tr->db; fp = (struct fw_pkt *)db_tr->buf; ohcifp = (struct fwohci_txpkthdr *) db[1].db.immed; @@ -2525,8 +2500,8 @@ device_printf(sc->fc.dev, "DB %08x %08x %08x\n", bulkxfer, db_tr->bus_addr, fdb_ ohcifp->mode.stream.chtag = chtag; ohcifp->mode.stream.tcode = 0xa; #if BYTE_ORDER == BIG_ENDIAN - FWOHCI_DMA_WRITE(db[1].db.immed[0], db[1].db.immed[0]); - FWOHCI_DMA_WRITE(db[1].db.immed[1], db[1].db.immed[1]); + FWOHCI_DMA_WRITE(db[1].db.immed[0], db[1].db.immed[0]); + FWOHCI_DMA_WRITE(db[1].db.immed[1], db[1].db.immed[1]); #endif FWOHCI_DMA_CLEAR(db[2].db.desc.cmd, OHCI_COUNT_MASK); @@ -2571,7 +2546,7 @@ fwohci_add_tx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, int err = 0; it = &dbch->xferq; - if(it->buf == 0){ + if (it->buf == 0) { err = EINVAL; return err; } @@ -2611,7 +2586,7 @@ fwohci_add_rx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, &db_tr->dma_map, ir->psize, &dbuf[0], BUS_DMA_NOWAIT); if (db_tr->buf == NULL) - return(ENOMEM); + return (ENOMEM); } db_tr->dbcnt = 1; dsiz[0] = ir->psize; @@ -2626,11 +2601,11 @@ fwohci_add_rx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, dsiz[db_tr->dbcnt] = ir->psize; if (ir->buf != NULL) { db_tr->buf = fwdma_v_addr(ir->buf, poffset); - dbuf[db_tr->dbcnt] = fwdma_bus_addr( ir->buf, poffset); + dbuf[db_tr->dbcnt] = fwdma_bus_addr(ir->buf, poffset); } db_tr->dbcnt++; } - for(i = 0 ; i < db_tr->dbcnt ; i++){ + for (i = 0; i < db_tr->dbcnt; i++) { FWOHCI_DMA_WRITE(db[i].db.desc.addr, dbuf[i]); FWOHCI_DMA_WRITE(db[i].db.desc.cmd, OHCI_INPUT_MORE | dsiz[i]); if (ir->flag & FWXFERQ_STREAM) { @@ -2680,19 +2655,19 @@ fwohci_arcv_swap(struct fw_pkt *fp, int len) break; default: printf("Unknown tcode %d\n", fp0->mode.common.tcode); - return(0); + return (0); } hlen = tinfo[fp0->mode.common.tcode].hdr_len; if (hlen > len) { if (firewire_debug) printf("splitted header\n"); - return(-hlen); + return (-hlen); } #if BYTE_ORDER == BIG_ENDIAN - for(i = 0; i < slen/4; i ++) + for (i = 0; i < slen/4; i++) fp->mode.ld[i] = FWOHCI_DMA_READ(fp->mode.ld[i]); #endif - return(hlen); + return (hlen); } static int @@ -2754,11 +2729,11 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) caddr_t buf; int resCount; - if(&sc->arrq == dbch){ + if (&sc->arrq == dbch) { off = OHCI_ARQOFF; - }else if(&sc->arrs == dbch){ + } else if (&sc->arrs == dbch) { off = OHCI_ARSOFF; - }else{ + } else { return; } @@ -2786,10 +2761,10 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) if (len > 0) bus_dmamap_sync(dbch->dmat, db_tr->dma_map, BUS_DMASYNC_POSTREAD); - while (len > 0 ) { + while (len > 0) { if (count >= 0 && count-- == 0) goto out; - if(dbch->pdb_tr != NULL){ + if (dbch->pdb_tr != NULL) { /* we have a fragment in previous buffer */ int rlen; @@ -2841,7 +2816,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) dbch->pdb_tr = db_tr; dbch->buf_offset = - dbch->buf_offset; /* sanity check */ - if (resCount != 0) { + if (resCount != 0) { printf("resCount=%d hlen=%d\n", resCount, hlen); goto err; @@ -2866,7 +2841,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) if (firewire_debug) printf("splitted payload\n"); /* sanity check */ - if (resCount != 0) { + if (resCount != 0) { printf("resCount=%d plen=%d" " len=%d\n", resCount, plen, len); @@ -2876,7 +2851,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) } vec[nvec].iov_base = ld; vec[nvec].iov_len = plen; - nvec ++; + nvec++; ld += plen; } dbch->buf_offset = ld - (uint8_t *)db_tr->buf; @@ -2903,7 +2878,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) if ((vec[nvec-1].iov_len -= sizeof(struct fwohci_trailer)) == 0) - nvec--; + nvec--; rb.fc = &sc->fc; rb.vec = vec; rb.nvec = nvec; @@ -2930,7 +2905,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) #endif break; } - pcnt ++; + pcnt++; if (dbch->pdb_tr != NULL) { fwohci_arcv_free_buf(sc, dbch, dbch->pdb_tr, off, 1); diff --git a/sys/dev/firewire/fwohci_pci.c b/sys/dev/firewire/fwohci_pci.c index e1e20b5da95a..7523f2cbc54f 100644 --- a/sys/dev/firewire/fwohci_pci.c +++ b/sys/dev/firewire/fwohci_pci.c @@ -46,34 +46,12 @@ __FBSDID("$FreeBSD$"); #include #include #include -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 #include #include -#endif #include -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -#include /* for DELAY() */ -#endif - -#ifdef __DragonFly__ -#include -#include - -#include "firewire.h" -#include "firewirereg.h" - -#include "fwdma.h" -#include "fwohcireg.h" -#include "fwohcivar.h" -#else -#if __FreeBSD_version < 500000 -#include -#include -#else #include #include -#endif #include #include @@ -81,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#endif static int fwohci_pci_attach(device_t self); static int fwohci_pci_detach(device_t self); @@ -90,9 +67,8 @@ static int fwohci_pci_detach(device_t self); * The probe routine. */ static int -fwohci_pci_probe( device_t dev ) +fwohci_pci_probe(device_t dev) { -#if 1 uint32_t id; id = pci_get_devid(dev); @@ -213,7 +189,6 @@ fwohci_pci_probe( device_t dev ) device_set_desc(dev, "Sun PCIO-2"); return BUS_PROBE_DEFAULT; } -#endif if (pci_get_class(dev) == PCIC_SERIALBUS && pci_get_subclass(dev) == PCIS_SERIALBUS_FW && pci_get_progif(dev) == PCI_INTERFACE_OHCI) { @@ -227,14 +202,6 @@ fwohci_pci_probe( device_t dev ) return ENXIO; } -#if defined(__DragonFly__) || __FreeBSD_version < 500000 -static void -fwohci_dummy_intr(void *arg) -{ - /* XXX do nothing */ -} -#endif - static int fwohci_pci_init(device_t self) { @@ -244,7 +211,7 @@ fwohci_pci_init(device_t self) cmd = pci_read_config(self, PCIR_COMMAND, 2); cmd |= PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN; #if 1 /* for broken hardware */ - cmd &= ~PCIM_CMD_MWRICEN; + cmd &= ~PCIM_CMD_MWRICEN; #endif pci_write_config(self, PCIR_COMMAND, cmd, 2); @@ -286,17 +253,6 @@ fwohci_pci_attach(device_t self) fwohci_softc_t *sc = device_get_softc(self); int err; int rid; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - int intr; - /* For the moment, put in a message stating what is wrong */ - intr = pci_read_config(self, PCIR_INTLINE, 1); - if (intr == 0 || intr == 255) { - device_printf(self, "Invalid irq %d\n", intr); -#ifdef __i386__ - device_printf(self, "Please switch PNP-OS to 'No' in BIOS\n"); -#endif - } -#endif #if 0 if (bootverbose) @@ -307,12 +263,7 @@ fwohci_pci_attach(device_t self) fwohci_pci_init(self); rid = PCI_CBMEM; -#if __FreeBSD_version >= 502109 sc->bsr = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); -#else - sc->bsr = bus_alloc_resource(self, SYS_RES_MEMORY, &rid, - 0, ~0, 1, RF_ACTIVE); -#endif if (!sc->bsr) { device_printf(self, "Could not map memory\n"); return ENXIO; @@ -322,13 +273,8 @@ fwohci_pci_attach(device_t self) sc->bsh = rman_get_bushandle(sc->bsr); rid = 0; -#if __FreeBSD_version >= 502109 sc->irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE); -#else - sc->irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1, - RF_SHAREABLE | RF_ACTIVE); -#endif if (sc->irq_res == NULL) { device_printf(self, "Could not allocate irq\n"); fwohci_pci_detach(self); @@ -340,14 +286,6 @@ fwohci_pci_attach(device_t self) NULL, (driver_intr_t *) fwohci_intr, sc, &sc->ih); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - /* XXX splcam() should mask this irq for sbp.c*/ - err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_CAM, - (driver_intr_t *) fwohci_dummy_intr, sc, &sc->ih_cam); - /* XXX splbio() should mask this irq for physio()/fwmem_strategy() */ - err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_BIO, - (driver_intr_t *) fwohci_dummy_intr, sc, &sc->ih_bio); -#endif if (err) { device_printf(self, "Could not setup irq, %d\n", err); fwohci_pci_detach(self); @@ -355,11 +293,7 @@ fwohci_pci_attach(device_t self) } err = bus_dma_tag_create( -#if defined(__FreeBSD__) && __FreeBSD_version >= 700020 /*parent*/bus_get_dma_tag(self), -#else - /*parent*/NULL, -#endif /*alignment*/1, /*boundary*/0, #if BOUNCE_BUFFER_TEST @@ -373,20 +307,19 @@ fwohci_pci_attach(device_t self) /*nsegments*/0x20, /*maxsegsz*/0x8000, /*flags*/BUS_DMA_ALLOCNOW, -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 /*lockfunc*/busdma_lock_mutex, /*lockarg*/FW_GMTX(&sc->fc), -#endif &sc->fc.dmat); if (err != 0) { - printf("fwohci_pci_attach: Could not allocate DMA tag " - "- error %d\n", err); - return (ENOMEM); + device_printf(self, "fwohci_pci_attach: Could not allocate DMA " + "tag - error %d\n", err); + fwohci_pci_detach(self); + return (ENOMEM); } err = fwohci_init(sc, self); - if (err) { + if (err != 0) { device_printf(self, "fwohci_init failed with err=%d\n", err); fwohci_pci_detach(self); return EIO; @@ -405,13 +338,13 @@ fwohci_pci_detach(device_t self) fwohci_softc_t *sc = device_get_softc(self); int s; - s = splfw(); if (sc->bsr) fwohci_stop(sc, self); bus_generic_detach(self); + if (sc->fc.bdev) { device_delete_child(self, sc->fc.bdev); sc->fc.bdev = NULL; @@ -429,10 +362,6 @@ fwohci_pci_detach(device_t self) if (err) device_printf(self, "Could not tear down irq, %d\n", err); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - bus_teardown_intr(self, sc->irq_res, sc->ih_cam); - bus_teardown_intr(self, sc->irq_res, sc->ih_bio); -#endif sc->ih = NULL; } bus_release_resource(self, SYS_RES_IRQ, 0, sc->irq_res); @@ -440,7 +369,7 @@ fwohci_pci_detach(device_t self) } if (sc->bsr) { - bus_release_resource(self, SYS_RES_MEMORY,PCI_CBMEM,sc->bsr); + bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, sc->bsr); sc->bsr = NULL; sc->bst = 0; sc->bsh = 0; @@ -500,7 +429,7 @@ fwohci_pci_add_child(device_t dev, u_int order, const char *name, int unit) return (child); sc->fc.bdev = child; - device_set_ivars(child, (void *)&sc->fc); + device_set_ivars(child, &sc->fc); err = device_probe_and_attach(child); if (err) { @@ -519,7 +448,7 @@ fwohci_pci_add_child(device_t dev, u_int order, const char *name, int unit) int s; DELAY(250); /* 2 cycles */ s = splfw(); - fwohci_poll((void *)sc, 0, -1); + fwohci_poll(&sc->fc, 0, -1); splx(s); } diff --git a/sys/dev/firewire/fwohcireg.h b/sys/dev/firewire/fwohcireg.h index d8deca8f3214..95fe26ed2b22 100644 --- a/sys/dev/firewire/fwohcireg.h +++ b/sys/dev/firewire/fwohcireg.h @@ -184,7 +184,7 @@ struct fwohcidb { #define FWOHCIEV_MASK 0x1f -struct ohci_dma{ +struct ohci_dma { fwohcireg_t cntl; #define OHCI_CNTL_CYCMATCH_S (0x1 << 31) @@ -211,7 +211,7 @@ struct ohci_dma{ fwohcireg_t dummy3; }; -struct ohci_itdma{ +struct ohci_itdma { fwohcireg_t cntl; fwohcireg_t cntl_clr; fwohcireg_t dummy0; @@ -237,7 +237,7 @@ struct ohci_registers { fwohcireg_t config_rom; /* config ROM map 0x34 */ fwohcireg_t post_wr_lo; /* post write addr lo 0x38 */ fwohcireg_t post_wr_hi; /* post write addr hi 0x3c */ - fwohcireg_t vender; /* vender ID 0x40 */ + fwohcireg_t vendor; /* vendor ID 0x40 */ fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */ fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */ fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */ @@ -308,7 +308,7 @@ struct ohci_registers { fwohcireg_t pys_upper; /* Physical Upper bound 0x120 */ fwohcireg_t dummy7[23]; /* dummy 0x124-0x17c */ - + /* 0x180, 0x184, 0x188, 0x18c */ /* 0x190, 0x194, 0x198, 0x19c */ /* 0x1a0, 0x1a4, 0x1a8, 0x1ac */ @@ -328,7 +328,7 @@ struct ohci_registers { struct ohci_dma dma_irch[0x20]; }; -struct fwohcidb_tr{ +struct fwohcidb_tr { STAILQ_ENTRY(fwohcidb_tr) link; struct fw_xfer *xfer; struct fwohcidb *db; @@ -341,8 +341,8 @@ struct fwohcidb_tr{ /* * OHCI info structure. */ -struct fwohci_txpkthdr{ - union{ +struct fwohci_txpkthdr { + union { uint32_t ld[4]; struct { #if BYTE_ORDER == BIG_ENDIAN @@ -376,7 +376,7 @@ struct fwohci_txpkthdr{ :8; #endif BIT16x2(dst, ); - }asycomm; + } asycomm; struct { #if BYTE_ORDER == BIG_ENDIAN uint32_t :13, @@ -392,16 +392,17 @@ struct fwohci_txpkthdr{ :13; #endif BIT16x2(len, ); - }stream; - }mode; + } stream; + } mode; }; -struct fwohci_trailer{ + +struct fwohci_trailer { #if BYTE_ORDER == BIG_ENDIAN uint32_t stat:16, - time:16; + time:16; #else uint32_t time:16, - stat:16; + stat:16; #endif }; @@ -412,7 +413,7 @@ struct fwohci_trailer{ #define OHCI_CNTL_SID (0x1 << 9) /* - * defined in OHCI 1.1 + * defined in OHCI 1.1 * chapter 6.1 */ #define OHCI_INT_DMA_ATRQ (0x1 << 0) diff --git a/sys/dev/firewire/fwohcivar.h b/sys/dev/firewire/fwohcivar.h index 6f9729096023..985bc6aff5ee 100644 --- a/sys/dev/firewire/fwohcivar.h +++ b/sys/dev/firewire/fwohcivar.h @@ -42,13 +42,9 @@ typedef struct fwohci_softc { bus_space_tag_t bst; bus_space_handle_t bsh; void *ih; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - void *ih_cam; - void *ih_bio; -#endif struct resource *bsr; struct resource *irq_res; - struct fwohci_dbch{ + struct fwohci_dbch { u_int ndb; u_int ndesc; STAILQ_HEAD(, fwohcidb_tr) db_trq; diff --git a/sys/dev/firewire/iec68113.h b/sys/dev/firewire/iec68113.h index 11f3042ff9b0..393d93156b7d 100644 --- a/sys/dev/firewire/iec68113.h +++ b/sys/dev/firewire/iec68113.h @@ -97,7 +97,7 @@ struct ciphdr { } fdf; }; -struct dvdbc{ +struct dvdbc { #if BYTE_ORDER == BIG_ENDIAN uint8_t sct:3, /* Section type */ :1, /* Reserved */ diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index 5797cc795704..5d15ead0db54 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 2002-2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author 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 @@ -30,7 +30,7 @@ * LIABILITY, OR 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$ */ @@ -57,18 +57,11 @@ #include #include #include -#ifdef __DragonFly__ -#include -#include -#include -#include "if_fwevar.h" -#else #include #include #include #include -#endif #define FWEDEBUG if (fwedebug) if_printf #define TX_MAX_QUEUE (FWMAXQUEUE - 1) @@ -130,8 +123,8 @@ fwe_probe(device_t dev) device_t pa; pa = device_get_parent(dev); - if(device_get_unit(dev) != device_get_unit(pa)){ - return(ENXIO); + if (device_get_unit(dev) != device_get_unit(pa)) { + return (ENXIO); } device_set_desc(dev, "Ethernet over FireWire"); @@ -144,11 +137,7 @@ fwe_attach(device_t dev) struct fwe_softc *fwe; struct ifnet *ifp; int unit, s; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - u_char *eaddr; -#else u_char eaddr[6]; -#endif struct fw_eui64 *eui; fwe = ((struct fwe_softc *)device_get_softc(dev)); @@ -175,10 +164,6 @@ fwe_attach(device_t dev) /* generate fake MAC address: first and last 3bytes from eui64 */ #define LOCAL (0x02) #define GROUP (0x01) -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - eaddr = &IFP2ENADDR(fwe->eth_softc.ifp)[0]; -#endif - eui = &fwe->fd.fc->eui; eaddr[0] = (FW_EUI64_BYTE(eui, 0) | LOCAL) & ~GROUP; @@ -191,7 +176,7 @@ fwe_attach(device_t dev) "%02x:%02x:%02x:%02x:%02x:%02x\n", unit, eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]); - /* fill the rest and attach interface */ + /* fill the rest and attach interface */ ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(dev, "can not if_alloc()\n"); @@ -199,36 +184,21 @@ fwe_attach(device_t dev) } ifp->if_softc = &fwe->eth_softc; -#if __FreeBSD_version >= 501113 || defined(__DragonFly__) if_initname(ifp, device_get_name(dev), unit); -#else - ifp->if_unit = unit; - ifp->if_name = "fwe"; -#endif ifp->if_init = fwe_init; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - ifp->if_output = ether_output; -#endif ifp->if_start = fwe_start; ifp->if_ioctl = fwe_ioctl; ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST); ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE; s = splimp(); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - ether_ifattach(ifp, 1); -#else ether_ifattach(ifp, eaddr); -#endif splx(s); /* Tell the upper layer(s) we support long frames. */ ifp->if_hdrlen = sizeof(struct ether_vlan_header); -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 ifp->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_POLLING; ifp->if_capenable |= IFCAP_VLAN_MTU; -#endif - FWEDEBUG(ifp, "interface created\n"); return 0; @@ -250,12 +220,12 @@ fwe_stop(struct fwe_softc *fwe) if (xferq->flag & FWXFERQ_RUNNING) fc->irx_disable(fc, fwe->dma_ch); - xferq->flag &= + xferq->flag &= ~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM | FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK); xferq->hand = NULL; - for (i = 0; i < xferq->bnchunk; i ++) + for (i = 0; i < xferq->bnchunk; i++) m_freem(xferq->bulkxfer[i].mbuf); free(xferq->bulkxfer, M_FWE); @@ -270,11 +240,7 @@ fwe_stop(struct fwe_softc *fwe) fwe->dma_ch = -1; } -#if defined(__FreeBSD__) ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); -#else - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); -#endif } static int @@ -294,12 +260,8 @@ fwe_detach(device_t dev) s = splimp(); fwe_stop(fwe); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - ether_ifdetach(ifp, 1); -#else ether_ifdetach(ifp); if_free(ifp); -#endif splx(s); mtx_destroy(&fwe->mtx); @@ -353,7 +315,7 @@ fwe_init(void *arg) STAILQ_INIT(&xferq->stfree); STAILQ_INIT(&xferq->stdma); xferq->stproc = NULL; - for (i = 0; i < xferq->bnchunk; i ++) { + for (i = 0; i < xferq->bnchunk; i++) { m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR); xferq->bulkxfer[i].mbuf = m; m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; @@ -379,13 +341,8 @@ fwe_init(void *arg) if ((xferq->flag & FWXFERQ_RUNNING) == 0) fc->irx_enable(fc, fwe->dma_ch); -#if defined(__FreeBSD__) ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; -#else - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; -#endif #if 0 /* attempt to start output */ @@ -405,18 +362,10 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFFLAGS: s = splimp(); if (ifp->if_flags & IFF_UP) { -#if defined(__FreeBSD__) if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) -#else - if (!(ifp->if_flags & IFF_RUNNING)) -#endif fwe_init(&fwe->eth_softc); } else { -#if defined(__FreeBSD__) if (ifp->if_drv_flags & IFF_DRV_RUNNING) -#else - if (ifp->if_flags & IFF_RUNNING) -#endif fwe_stop(fwe); } /* XXX keep promiscoud mode */ @@ -444,7 +393,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) !(ifp->if_capenable & IFCAP_POLLING)) { error = ether_poll_register(fwe_poll, ifp); if (error) - return(error); + return (error); /* Disable interrupts */ fc->set_intr(fc, 0); ifp->if_capenable |= IFCAP_POLLING; @@ -463,21 +412,11 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } #endif /* DEVICE_POLLING */ break; -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 default: -#else - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: -#endif s = splimp(); error = ether_ioctl(ifp, cmd, data); splx(s); return (error); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - default: - return (EINVAL); -#endif } return (0); @@ -495,8 +434,7 @@ fwe_output_callback(struct fw_xfer *xfer) /* XXX error check */ FWEDEBUG(ifp, "resp = %d\n", xfer->resp); if (xfer->resp != 0) - ifp->if_oerrors ++; - + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(xfer->mbuf); fw_xfer_unload(xfer); @@ -529,7 +467,7 @@ fwe_start(struct ifnet *ifp) IF_DEQUEUE(&ifp->if_snd, m); if (m != NULL) m_freem(m); - ifp->if_oerrors ++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } while (m != NULL); splx(s); @@ -537,20 +475,12 @@ fwe_start(struct ifnet *ifp) } s = splimp(); -#if defined(__FreeBSD__) ifp->if_drv_flags |= IFF_DRV_OACTIVE; -#else - ifp->if_flags |= IFF_OACTIVE; -#endif if (ifp->if_snd.ifq_len != 0) fwe_as_output(fwe, ifp); -#if defined(__FreeBSD__) ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; -#else - ifp->if_flags &= ~IFF_OACTIVE; -#endif splx(s); } @@ -591,12 +521,7 @@ fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp) FWE_UNLOCK(fwe); break; } -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - if (ifp->if_bpf != NULL) - bpf_mtap(ifp, m); -#else BPF_MTAP(ifp, m); -#endif /* keep ip packet alignment for alpha */ M_PREPEND(m, ETHER_ALIGN, M_NOWAIT); @@ -608,11 +533,11 @@ fwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp) if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) { /* error */ - ifp->if_oerrors ++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* XXX set error code */ fwe_output_callback(xfer); } else { - ifp->if_opackets ++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); i++; } } @@ -634,9 +559,6 @@ fwe_as_input(struct fw_xferq *xferq) struct fw_bulkxfer *sxfer; struct fw_pkt *fp; u_char *c; -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - struct ether_header *eh; -#endif fwe = (struct fwe_softc *)xferq->sc; ifp = fwe->eth_softc.ifp; @@ -660,20 +582,13 @@ fwe_as_input(struct fw_xferq *xferq) if (sxfer->resp != 0 || fp->mode.stream.len < ETHER_ALIGN + sizeof(struct ether_header)) { m_freem(m); - ifp->if_ierrors ++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } m->m_data += HDR_LEN + ETHER_ALIGN; c = mtod(m, u_char *); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - eh = (struct ether_header *)c; - m->m_data += sizeof(struct ether_header); - m->m_len = m->m_pkthdr.len = fp->mode.stream.len - ETHER_ALIGN - - sizeof(struct ether_header); -#else m->m_len = m->m_pkthdr.len = fp->mode.stream.len - ETHER_ALIGN; -#endif m->m_pkthdr.rcvif = ifp; #if 0 FWEDEBUG(ifp, "%02x %02x %02x %02x %02x %02x\n" @@ -688,14 +603,10 @@ fwe_as_input(struct fw_xferq *xferq) c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23], c[20], c[21], c[22], c[23] - ); + ); #endif -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - ether_input(ifp, eh, m); -#else (*ifp->if_input)(ifp, m); -#endif - ifp->if_ipackets ++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } if (STAILQ_FIRST(&xferq->stfree) != NULL) fwe->fd.fc->irx_enable(fwe->fd.fc, fwe->dma_ch); @@ -720,9 +631,6 @@ static driver_t fwe_driver = { }; -#ifdef __DragonFly__ -DECLARE_DUMMY_MODULE(fwe); -#endif DRIVER_MODULE(fwe, firewire, fwe_driver, fwe_devclass, 0, 0); MODULE_VERSION(fwe, 1); MODULE_DEPEND(fwe, firewire, 1, 1, 1); diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c index df3e1f6446d3..0617a9c1cc07 100644 --- a/sys/dev/firewire/if_fwip.c +++ b/sys/dev/firewire/if_fwip.c @@ -60,16 +60,10 @@ #include #include #include -#ifdef __DragonFly__ -#include -#include -#include "if_fwipvar.h" -#else #include #include #include #include -#endif /* * We really need a mechanism for allocating regions in the FIFO @@ -139,8 +133,8 @@ fwip_probe(device_t dev) device_t pa; pa = device_get_parent(dev); - if(device_get_unit(dev) != device_get_unit(pa)){ - return(ENXIO); + if (device_get_unit(dev) != device_get_unit(pa)) { + return (ENXIO); } device_set_desc(dev, "IP over FireWire"); @@ -189,12 +183,7 @@ fwip_attach(device_t dev) /* fill the rest and attach interface */ ifp->if_softc = &fwip->fw_softc; -#if __FreeBSD_version >= 501113 || defined(__DragonFly__) if_initname(ifp, device_get_name(dev), unit); -#else - ifp->if_unit = unit; - ifp->if_name = "fwip"; -#endif ifp->if_init = fwip_init; ifp->if_start = fwip_start; ifp->if_ioctl = fwip_ioctl; @@ -233,7 +222,7 @@ fwip_stop(struct fwip_softc *fwip) FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK); xferq->hand = NULL; - for (i = 0; i < xferq->bnchunk; i ++) + for (i = 0; i < xferq->bnchunk; i++) m_freem(xferq->bulkxfer[i].mbuf); free(xferq->bulkxfer, M_FWIP); @@ -255,11 +244,7 @@ fwip_stop(struct fwip_softc *fwip) fwip->dma_ch = -1; } -#if defined(__FreeBSD__) ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); -#else - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); -#endif } static int @@ -331,7 +316,7 @@ fwip_init(void *arg) STAILQ_INIT(&xferq->stfree); STAILQ_INIT(&xferq->stdma); xferq->stproc = NULL; - for (i = 0; i < xferq->bnchunk; i ++) { + for (i = 0; i < xferq->bnchunk; i++) { m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR); xferq->bulkxfer[i].mbuf = m; m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; @@ -344,7 +329,7 @@ fwip_init(void *arg) /* pre-allocate xfer */ STAILQ_INIT(&fwip->fwb.xferlist); - for (i = 0; i < rx_queue_len; i ++) { + for (i = 0; i < rx_queue_len; i++) { xfer = fw_xfer_alloc(M_FWIP); if (xfer == NULL) break; @@ -380,13 +365,8 @@ fwip_init(void *arg) if ((xferq->flag & FWXFERQ_RUNNING) == 0) fc->irx_enable(fc, fwip->dma_ch); -#if defined(__FreeBSD__) ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; -#else - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; -#endif #if 0 /* attempt to start output */ @@ -404,18 +384,10 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFFLAGS: s = splimp(); if (ifp->if_flags & IFF_UP) { -#if defined(__FreeBSD__) if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) -#else - if (!(ifp->if_flags & IFF_RUNNING)) -#endif fwip_init(&fwip->fw_softc); } else { -#if defined(__FreeBSD__) if (ifp->if_drv_flags & IFF_DRV_RUNNING) -#else - if (ifp->if_flags & IFF_RUNNING) -#endif fwip_stop(fwip); } splx(s); @@ -433,13 +405,12 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) !(ifp->if_capenable & IFCAP_POLLING)) { error = ether_poll_register(fwip_poll, ifp); if (error) - return(error); + return (error); /* Disable interrupts */ fc->set_intr(fc, 0); ifp->if_capenable |= IFCAP_POLLING | IFCAP_POLLING_NOCOUNT; return (error); - } if (!(ifr->ifr_reqcap & IFCAP_POLLING) && ifp->if_capenable & IFCAP_POLLING) { @@ -453,21 +424,11 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } #endif /* DEVICE_POLLING */ break; -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 default: -#else - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: -#endif s = splimp(); error = firewire_ioctl(ifp, cmd, data); splx(s); return (error); -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - default: - return (EINVAL); -#endif } return (0); @@ -516,8 +477,7 @@ fwip_output_callback(struct fw_xfer *xfer) /* XXX error check */ FWIPDEBUG(ifp, "resp = %d\n", xfer->resp); if (xfer->resp != 0) - ifp->if_oerrors ++; - + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(xfer->mbuf); fw_xfer_unload(xfer); @@ -551,7 +511,7 @@ fwip_start(struct ifnet *ifp) IF_DEQUEUE(&ifp->if_snd, m); if (m != NULL) m_freem(m); - ifp->if_oerrors ++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } while (m != NULL); splx(s); @@ -559,20 +519,12 @@ fwip_start(struct ifnet *ifp) } s = splimp(); -#if defined(__FreeBSD__) ifp->if_drv_flags |= IFF_DRV_OACTIVE; -#else - ifp->if_flags |= IFF_OACTIVE; -#endif if (ifp->if_snd.ifq_len != 0) fwip_async_output(fwip, ifp); -#if defined(__FreeBSD__) ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; -#else - ifp->if_flags &= ~IFF_OACTIVE; -#endif splx(s); } @@ -686,7 +638,7 @@ fwip_async_output(struct fwip_softc *fwip, struct ifnet *ifp) fd = fw_noderesolve_eui64(fc, &eui); if (!fd) { /* error */ - ifp->if_oerrors ++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* XXX set error code */ fwip_output_callback(xfer); continue; @@ -727,12 +679,12 @@ fwip_async_output(struct fwip_softc *fwip, struct ifnet *ifp) } if (error) { /* error */ - ifp->if_oerrors ++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* XXX set error code */ fwip_output_callback(xfer); continue; } else { - ifp->if_opackets ++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); i++; } } @@ -794,7 +746,7 @@ fwip_stream_input(struct fw_xferq *xferq) if (sxfer->resp != 0 || fp->mode.stream.len < 2*sizeof(uint32_t)) { m_freem(m); - ifp->if_ierrors ++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } m->m_len = m->m_pkthdr.len = fp->mode.stream.len @@ -820,7 +772,7 @@ fwip_stream_input(struct fw_xferq *xferq) FWIPDEBUG(ifp, "Unrecognised GASP header %#08x %#08x\n", ntohl(p[1]), ntohl(p[2])); m_freem(m); - ifp->if_ierrors ++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } @@ -855,7 +807,7 @@ fwip_stream_input(struct fw_xferq *xferq) m_adj(m, 3*sizeof(uint32_t)); m->m_pkthdr.rcvif = ifp; firewire_input(ifp, m, src); - ifp->if_ipackets ++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } if (STAILQ_FIRST(&xferq->stfree) != NULL) fwip->fd.fc->irx_enable(fwip->fd.fc, fwip->dma_ch); @@ -921,7 +873,7 @@ fwip_unicast_input(struct fw_xfer *xfer) */ if (rtcode != FWRCODE_COMPLETE) { m_freem(m); - ifp->if_ierrors ++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -956,7 +908,7 @@ fwip_unicast_input(struct fw_xfer *xfer) m->m_len = m->m_pkthdr.len = fp->mode.wreqb.len; m->m_pkthdr.rcvif = ifp; firewire_input(ifp, m, fp->mode.wreqb.src); - ifp->if_ipackets ++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } static devclass_t fwip_devclass; @@ -977,9 +929,6 @@ static driver_t fwip_driver = { }; -#ifdef __DragonFly__ -DECLARE_DUMMY_MODULE(fwip); -#endif DRIVER_MODULE(fwip, firewire, fwip_driver, fwip_devclass, 0, 0); MODULE_VERSION(fwip, 1); MODULE_DEPEND(fwip, firewire, 1, 1, 1); diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index eeca4c77b4e7..69e83c4690d5 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -30,7 +30,7 @@ * STRICT LIABILITY, OR 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$ * */ @@ -43,30 +43,9 @@ #include #include #include -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 #include #include -#endif -#if defined(__DragonFly__) || __FreeBSD_version < 500106 -#include /* for struct devstat */ -#endif - -#ifdef __DragonFly__ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "sbp.h" -#else #include #include #include @@ -80,7 +59,6 @@ #include #include #include -#endif #define ccb_sdev_ptr spriv_ptr0 #define ccb_sbp_ptr spriv_ptr1 @@ -97,16 +75,16 @@ #define SBP_QUEUE_LEN ((SBP_DMA_SIZE - SBP_LOGIN_SIZE) / sizeof(struct sbp_ocb)) #define SBP_NUM_OCB (SBP_QUEUE_LEN * SBP_NUM_TARGETS) -/* +/* * STATUS FIFO addressing * bit - * ----------------------- + *----------------------- * 0- 1( 2): 0 (alignment) * 2- 7( 6): target * 8-15( 8): lun * 16-31( 8): reserved - * 32-47(16): SBP_BIND_HI - * 48-64(16): bus_id, node_id + * 32-47(16): SBP_BIND_HI + * 48-64(16): bus_id, node_id */ #define SBP_BIND_HI 0x1 #define SBP_DEV2ADDR(t, l) \ @@ -176,7 +154,7 @@ struct sbp_ocb { #define OCB_ACT_CMD 1 #define OCB_MATCH(o,s) ((o)->bus_addr == ntohl((s)->orb_lo)) -struct sbp_dev{ +struct sbp_dev { #define SBP_DEV_RESET 0 /* accept login */ #define SBP_DEV_LOGIN 1 /* to login */ #if 0 @@ -254,7 +232,7 @@ static void sbp_cmd_callback (struct fw_xfer *); #endif static void sbp_orb_pointer (struct sbp_dev *, struct sbp_ocb *); static void sbp_doorbell(struct sbp_dev *); -static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int); +static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int); static void sbp_free_ocb (struct sbp_dev *, struct sbp_ocb *); static void sbp_abort_ocb (struct sbp_ocb *, int); static void sbp_abort_all_ocbs (struct sbp_dev *, int); @@ -410,7 +388,7 @@ sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev) /* XXX wired-down configuration should be gotten from tunable or device hint */ - for (i = 0; wired[i].bus >= 0; i ++) { + for (i = 0; wired[i].bus >= 0; i++) { if (wired[i].bus == bus) { w[wired[i].target] = 1; if (wired[i].eui.hi == fwdev->eui.hi && @@ -419,16 +397,16 @@ sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev) } } if (target >= 0) { - if(target < SBP_NUM_TARGETS && + if (target < SBP_NUM_TARGETS && sbp->targets[target].fwdev == NULL) - return(target); + return (target); device_printf(sbp->fd.dev, - "target %d is not free for %08x:%08x\n", + "target %d is not free for %08x:%08x\n", target, fwdev->eui.hi, fwdev->eui.lo); target = -1; } /* non-wired target */ - for (i = 0; i < SBP_NUM_TARGETS; i ++) + for (i = 0; i < SBP_NUM_TARGETS; i++) if (sbp->targets[i].fwdev == NULL && w[i] == 0) { target = i; break; @@ -467,12 +445,12 @@ END_DEBUG device_printf(target->sbp->fd.dev, "%d no LUN found\n", target->target_id); - maxlun ++; + maxlun++; if (maxlun >= SBP_NUM_LUNS) maxlun = SBP_NUM_LUNS; /* Invalidiate stale devices */ - for (lun = 0; lun < target->num_lun; lun ++) { + for (lun = 0; lun < target->num_lun; lun++) { sdev = target->luns[lun]; if (sdev == NULL) continue; @@ -490,7 +468,7 @@ END_DEBUG newluns = (struct sbp_dev **) realloc(target->luns, sizeof(struct sbp_dev *) * maxlun, M_SBP, M_NOWAIT | M_ZERO); - + if (newluns == NULL) { printf("%s: realloc failed\n", __func__); newluns = target->luns; @@ -549,7 +527,7 @@ END_DEBUG if (new == 0) goto next; - fwdma_malloc(sbp->fd.fc, + fwdma_malloc(sbp->fd.fc, /* alignment */ sizeof(uint32_t), SBP_DMA_SIZE, &sdev->dma, BUS_DMA_NOWAIT | BUS_DMA_COHERENT); @@ -564,7 +542,7 @@ END_DEBUG sdev->ocb = (struct sbp_ocb *) ((char *)sdev->dma.v_addr + SBP_LOGIN_SIZE); bzero((char *)sdev->ocb, - sizeof (struct sbp_ocb) * SBP_QUEUE_LEN); + sizeof(struct sbp_ocb) * SBP_QUEUE_LEN); STAILQ_INIT(&sdev->free_ocbs); for (i = 0; i < SBP_QUEUE_LEN; i++) { @@ -586,7 +564,7 @@ END_DEBUG crom_next(&cc); } - for (lun = 0; lun < target->num_lun; lun ++) { + for (lun = 0; lun < target->num_lun; lun++) { sdev = target->luns[lun]; if (sdev != NULL && (sdev->flags & VALID_LUN) == 0) { sbp_cam_detach_sdev(sdev); @@ -735,7 +713,7 @@ END_DEBUG if (alive && (sdev->status != SBP_DEV_DEAD)) { if (sdev->path != NULL) { xpt_freeze_devq(sdev->path, 1); - sdev->freeze ++; + sdev->freeze++; } sbp_probe_lun(sdev); sbp_show_sdev_info(sdev); @@ -765,7 +743,7 @@ SBP_DEBUG(0) END_DEBUG if (sdev->path) { xpt_freeze_devq(sdev->path, 1); - sdev->freeze ++; + sdev->freeze++; } sdev->status = SBP_DEV_RETRY; sbp_cam_detach_sdev(sdev); @@ -819,7 +797,7 @@ END_DEBUG return; if (sbp_cold > 0) - sbp_cold --; + sbp_cold--; SBP_LOCK(sbp); #if 0 @@ -831,7 +809,7 @@ END_DEBUG #endif /* Garbage Collection */ - for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){ + for (i = 0; i < SBP_NUM_TARGETS; i++) { target = &sbp->targets[i]; STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) if (target->fwdev == NULL || target->fwdev == fwdev) @@ -851,14 +829,14 @@ SBP_DEBUG(0) fwdev->status); END_DEBUG alive = SBP_FWDEV_ALIVE(fwdev); - for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){ + for (i = 0; i < SBP_NUM_TARGETS; i++) { target = &sbp->targets[i]; - if(target->fwdev == fwdev ) { + if (target->fwdev == fwdev) { /* known target */ break; } } - if(i == SBP_NUM_TARGETS){ + if (i == SBP_NUM_TARGETS) { if (alive) { /* new target */ target = sbp_alloc_target(sbp, fwdev); @@ -879,7 +857,8 @@ END_DEBUG #if NEED_RESPONSE static void -sbp_loginres_callback(struct fw_xfer *xfer){ +sbp_loginres_callback(struct fw_xfer *xfer) +{ struct sbp_dev *sdev; sdev = (struct sbp_dev *)xfer->sc; SBP_DEBUG(1) @@ -972,8 +951,8 @@ sbp_next_dev(struct sbp_target *target, int lun) for (i = lun, sdevp = &target->luns[lun]; i < target->num_lun; i++, sdevp++) if (*sdevp != NULL && (*sdevp)->status == SBP_DEV_PROBE) - return(*sdevp); - return(NULL); + return (*sdevp); + return (NULL); } #define SCAN_PRI 1 @@ -1169,7 +1148,7 @@ END_DEBUG fp = &xfer->send.hdr; fp->mode.wreqq.dest_hi = 0xffff; fp->mode.wreqq.dest_lo = 0xf0000000 | BUSY_TIMEOUT; - fp->mode.wreqq.data = htonl((1 << (13+12)) | 0xf); + fp->mode.wreqq.data = htonl((1 << (13 + 12)) | 0xf); fw_asyreq(xfer->fc, -1, xfer); } @@ -1235,8 +1214,8 @@ END_DEBUG fp = &xfer->send.hdr; fp->mode.wreqb.len = 8; fp->mode.wreqb.extcode = 0; - xfer->send.payload[0] = - htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS )<< 16)); + xfer->send.payload[0] = + htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS) << 16)); xfer->send.payload[1] = htonl((uint32_t)ocb->bus_addr); if (fw_asyreq(xfer->fc, -1, xfer) != 0) { @@ -1310,14 +1289,14 @@ sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset) if (xfer == NULL) { if (target->n_xfer > 5 /* XXX */) { printf("sbp: no more xfer for this target\n"); - return(NULL); + return (NULL); } xfer = fw_xfer_alloc_buf(M_SBP, 8, 0); - if(xfer == NULL){ + if (xfer == NULL) { printf("sbp: fw_xfer_alloc_buf failed\n"); return NULL; } - target->n_xfer ++; + target->n_xfer++; if (debug) printf("sbp: alloc %d xfer\n", target->n_xfer); new = 1; @@ -1384,7 +1363,7 @@ SBP_DEBUG(0) device_printf(sdev->target->sbp->fd.dev, "%s:%s %s\n", __func__,sdev->bustgtlun, - orb_fun_name[(func>>16)&0xf]); + orb_fun_name[(func >> 16) & 0xf]); END_DEBUG switch (func) { case ORB_FUN_LGI: @@ -1421,7 +1400,7 @@ END_DEBUG callout_reset(&target->mgm_ocb_timeout, 5*hz, sbp_mgm_timeout, (caddr_t)ocb); xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0); - if(xfer == NULL){ + if (xfer == NULL) { return; } xfer->hand = sbp_mgm_callback; @@ -1492,25 +1471,25 @@ END_DEBUG case SCSI_STATUS_CHECK_COND: case SCSI_STATUS_BUSY: case SCSI_STATUS_CMD_TERMINATED: - if(sbp_cmd_status->sfmt == SBP_SFMT_CURR){ + if (sbp_cmd_status->sfmt == SBP_SFMT_CURR) { sense->error_code = SSD_CURRENT_ERROR; - }else{ + } else { sense->error_code = SSD_DEFERRED_ERROR; } - if(sbp_cmd_status->valid) + if (sbp_cmd_status->valid) sense->error_code |= SSD_ERRCODE_VALID; sense->flags = sbp_cmd_status->s_key; - if(sbp_cmd_status->mark) + if (sbp_cmd_status->mark) sense->flags |= SSD_FILEMARK; - if(sbp_cmd_status->eom) + if (sbp_cmd_status->eom) sense->flags |= SSD_EOM; - if(sbp_cmd_status->ill_len) + if (sbp_cmd_status->ill_len) sense->flags |= SSD_ILI; bcopy(&sbp_cmd_status->info, &sense->info[0], 4); if (sbp_status->len <= 1) - /* XXX not scsi status. shouldn't be happened */ + /* XXX not scsi status. shouldn't be happened */ sense->extra_len = 0; else if (sbp_status->len <= 4) /* add_sense_code(_qual), info, cmd_spec_info */ @@ -1535,10 +1514,10 @@ END_DEBUG { uint8_t j, *tmp; tmp = sense; - for( j = 0 ; j < 32 ; j+=8){ - printf("sense %02x%02x %02x%02x %02x%02x %02x%02x\n", - tmp[j], tmp[j+1], tmp[j+2], tmp[j+3], - tmp[j+4], tmp[j+5], tmp[j+6], tmp[j+7]); + for (j = 0; j < 32; j += 8) { + printf("sense %02x%02x %02x%02x %02x%02x %02x%02x\n", + tmp[j], tmp[j + 1], tmp[j + 2], tmp[j + 3], + tmp[j + 4], tmp[j + 5], tmp[j + 6], tmp[j + 7]); } } @@ -1572,7 +1551,7 @@ END_DEBUG switch (SID_TYPE(inq)) { case T_DIRECT: #if 0 - /* + /* * XXX Convert Direct Access device to RBC. * I've never seen FireWire DA devices which support READ_6. */ @@ -1588,7 +1567,7 @@ END_DEBUG #if 1 bcopy(sdev->vendor, inq->vendor, sizeof(inq->vendor)); bcopy(sdev->product, inq->product, sizeof(inq->product)); - bcopy(sdev->revision+2, inq->revision, sizeof(inq->revision)); + bcopy(sdev->revision + 2, inq->revision, sizeof(inq->revision)); #endif break; } @@ -1628,16 +1607,16 @@ printf("sbp %08x %08x %08x %08x\n", ntohl(ld[8]), ntohl(ld[9]), ntohl(ld[10]), n */ sbp = (struct sbp_softc *)xfer->sc; SBP_LOCK_ASSERT(sbp); - if (xfer->resp != 0){ + if (xfer->resp != 0) { printf("sbp_recv: xfer->resp = %d\n", xfer->resp); goto done0; } - if (xfer->recv.payload == NULL){ + if (xfer->recv.payload == NULL) { printf("sbp_recv: xfer->recv.payload == NULL\n"); goto done0; } rfp = &xfer->recv.hdr; - if(rfp->mode.wreqb.tcode != FWTCODE_WREQB){ + if (rfp->mode.wreqb.tcode != FWTCODE_WREQB) { printf("sbp_recv: tcode = %d\n", rfp->mode.wreqb.tcode); goto done0; } @@ -1677,11 +1656,7 @@ END_DEBUG ocb = sbp_dequeue_ocb(sdev, sbp_status); if (ocb == NULL) { device_printf(sdev->target->sbp->fd.dev, -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - "%s:%s No ocb(%lx) on the queue\n", -#else "%s:%s No ocb(%x) on the queue\n", -#endif __func__,sdev->bustgtlun, ntohl(sbp_status->orb_lo)); } @@ -1703,16 +1678,12 @@ END_DEBUG && sbp_status->dead == 0); status_valid = (status_valid0 && sbp_status->status == 0); - if (!status_valid0 || debug > 2){ + if (!status_valid0 || debug > 2) { int status; SBP_DEBUG(0) device_printf(sdev->target->sbp->fd.dev, "%s:%s ORB status src:%x resp:%x dead:%x" -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - " len:%x stat:%x orb:%x%08lx\n", -#else " len:%x stat:%x orb:%x%08x\n", -#endif __func__, sdev->bustgtlun, sbp_status->src, sbp_status->resp, sbp_status->dead, sbp_status->len, sbp_status->status, @@ -1721,7 +1692,7 @@ END_DEBUG device_printf(sdev->target->sbp->fd.dev, "%s\n", sdev->bustgtlun); status = sbp_status->status; - switch(sbp_status->resp) { + switch (sbp_status->resp) { case 0: if (status > MAX_ORB_STATUS0) printf("%s\n", orb_status0[MAX_ORB_STATUS0]); @@ -1730,7 +1701,7 @@ END_DEBUG break; case 1: printf("Obj: %s, Error: %s\n", - orb_status1_object[(status>>6) & 3], + orb_status1_object[(status >> 6) & 3], orb_status1_serial_bus_error[status & 0xf]); break; case 2: @@ -1748,7 +1719,7 @@ END_DEBUG if (sbp_status->dead) { if (sdev->path) { xpt_freeze_devq(sdev->path, 1); - sdev->freeze ++; + sdev->freeze++; } reset_agent = 1; } @@ -1756,17 +1727,17 @@ END_DEBUG if (ocb == NULL) goto done; - switch(ntohl(ocb->orb[4]) & ORB_FMT_MSK){ + switch (ntohl(ocb->orb[4]) & ORB_FMT_MSK) { case ORB_FMT_NOP: break; case ORB_FMT_VED: break; case ORB_FMT_STD: - switch(ocb->flags) { + switch (ocb->flags) { case OCB_ACT_MGM: orb_fun = ntohl(ocb->orb[4]) & ORB_FUN_MSK; reset_agent = 0; - switch(orb_fun) { + switch (orb_fun) { case ORB_FUN_LGI: fwdma_sync(&sdev->dma, BUS_DMASYNC_POSTREAD); login_res = sdev->login; @@ -1837,16 +1808,16 @@ END_DEBUG break; case OCB_ACT_CMD: sdev->timeout = 0; - if(ocb->ccb != NULL){ + if (ocb->ccb != NULL) { union ccb *ccb; ccb = ocb->ccb; - if(sbp_status->len > 1){ + if (sbp_status->len > 1) { sbp_scsi_status(sbp_status, ocb); - }else{ - if(sbp_status->resp != ORB_RES_CMPL){ + } else { + if (sbp_status->resp != ORB_RES_CMPL) { ccb->ccb_h.status = CAM_REQ_CMP_ERR; - }else{ + } else { ccb->ccb_h.status = CAM_REQ_CMP; } } @@ -1873,7 +1844,7 @@ END_DEBUG * the buffer. In that case, the controller return ack_complete and * no respose is necessary. * - * XXX fwohci.c and firewire.c should inform event_code such as + * XXX fwohci.c and firewire.c should inform event_code such as * ack_complete or ack_pending to upper driver. */ #if NEED_RESPONSE @@ -1930,7 +1901,7 @@ SBP_DEBUG(0) END_DEBUG if (cold) - sbp_cold ++; + sbp_cold++; sbp = device_get_softc(dev); sbp->fd.dev = dev; sbp->fd.fc = fc = device_get_ivars(dev); @@ -1949,10 +1920,8 @@ END_DEBUG /*maxsize*/0x100000, /*nsegments*/SBP_IND_MAX, /*maxsegsz*/SBP_SEG_MAX, /*flags*/BUS_DMA_ALLOCNOW, -#if defined(__FreeBSD__) && __FreeBSD_version >= 501102 /*lockfunc*/busdma_lock_mutex, /*lockarg*/&sbp->mtx, -#endif &sbp->dmat); if (error != 0) { printf("sbp_attach: Could not allocate DMA tag " @@ -1964,7 +1933,7 @@ END_DEBUG if (devq == NULL) return (ENXIO); - for( i = 0 ; i < SBP_NUM_TARGETS ; i++){ + for (i = 0; i < SBP_NUM_TARGETS; i++) { sbp->targets[i].fwdev = NULL; sbp->targets[i].luns = NULL; sbp->targets[i].sbp = sbp; @@ -2033,7 +2002,7 @@ SBP_DEBUG(0) printf("sbp_logout_all\n"); END_DEBUG SBP_LOCK_ASSERT(sbp); - for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) { + for (i = 0; i < SBP_NUM_TARGETS; i++) { target = &sbp->targets[i]; if (target->luns == NULL) continue; @@ -2122,7 +2091,7 @@ SBP_DEBUG(0) END_DEBUG SBP_LOCK(sbp); - for (i = 0; i < SBP_NUM_TARGETS; i ++) + for (i = 0; i < SBP_NUM_TARGETS; i++) sbp_cam_detach_target(&sbp->targets[i]); xpt_async(AC_LOST_DEVICE, sbp->path, NULL); @@ -2137,7 +2106,7 @@ END_DEBUG pause("sbpdtc", hz/2); SBP_LOCK(sbp); - for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) + for (i = 0; i < SBP_NUM_TARGETS; i++) sbp_free_target(&sbp->targets[i]); SBP_UNLOCK(sbp); @@ -2204,12 +2173,12 @@ sbp_target_reset(struct sbp_dev *sdev, int method) if (tsdev->status == SBP_DEV_RESET) continue; xpt_freeze_devq(tsdev->path, 1); - tsdev->freeze ++; + tsdev->freeze++; sbp_abort_all_ocbs(tsdev, CAM_CMD_TIMEOUT); if (method == 2) tsdev->status = SBP_DEV_LOGIN; } - switch(method) { + switch (method) { case 1: printf("target reset\n"); sbp_mgm_orb(sdev, ORB_FUN_RST, NULL); @@ -2219,7 +2188,7 @@ sbp_target_reset(struct sbp_dev *sdev, int method) sbp_reset_start(sdev); break; } - + } static void @@ -2257,12 +2226,12 @@ sbp_timeout(void *arg) __func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr); SBP_LOCK_ASSERT(sdev->target->sbp); - sdev->timeout ++; - switch(sdev->timeout) { + sdev->timeout++; + switch (sdev->timeout) { case 1: printf("agent reset\n"); xpt_freeze_devq(sdev->path, 1); - sdev->freeze ++; + sdev->freeze++; sbp_abort_all_ocbs(sdev, CAM_CMD_TIMEOUT); sbp_agent_reset(sdev); break; @@ -2341,7 +2310,7 @@ END_DEBUG * sometimes aimed at the SIM (sc is invalid and target is * CAM_TARGET_WILDCARD) */ - if (sbp == NULL && + if (sbp == NULL && ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) { SBP_DEBUG(0) printf("%s:%d:%jx func_code 0x%04x: " @@ -2393,7 +2362,7 @@ SBP_DEBUG(2) csio->cdb_len, csio->dxfer_len, csio->sense_len); END_DEBUG - if(sdev == NULL){ + if (sdev == NULL) { ccb->ccb_h.status = CAM_DEV_NOT_THERE; xpt_done(ccb); return; @@ -2415,7 +2384,7 @@ END_DEBUG ccb->ccb_h.status = CAM_RESRC_UNAVAIL; if (sdev->freeze == 0) { xpt_freeze_devq(sdev->path, 1); - sdev->freeze ++; + sdev->freeze++; } xpt_done(ccb); return; @@ -2427,12 +2396,12 @@ END_DEBUG ccb->ccb_h.ccb_sdev_ptr = sdev; ocb->orb[0] = htonl(1U << 31); ocb->orb[1] = 0; - ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS )<< 16) ); + ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS) << 16)); ocb->orb[3] = htonl(ocb->bus_addr + IND_PTR_OFFSET); speed = min(target->fwdev->speed, max_speed); ocb->orb[4] = htonl(ORB_NOTIFY | ORB_CMD_SPD(speed) | ORB_CMD_MAXP(speed + 7)); - if((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN){ + if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { ocb->orb[4] |= htonl(ORB_CMD_IN); } @@ -2463,11 +2432,6 @@ printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntoh case XPT_CALC_GEOMETRY: { struct ccb_calc_geometry *ccg; -#if defined(__DragonFly__) || __FreeBSD_version < 501100 - uint32_t size_mb; - uint32_t secs_per_cylinder; - int extended = 1; -#endif ccg = &ccb->ccg; if (ccg->block_size == 0) { @@ -2478,37 +2442,14 @@ printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntoh } SBP_DEBUG(1) printf("%s:%d:%d:%jx:XPT_CALC_GEOMETRY: " -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - "Volume size = %d\n", -#else "Volume size = %jd\n", -#endif device_get_nameunit(sbp->fd.dev), cam_sim_path(sbp->sim), ccb->ccb_h.target_id, (uintmax_t)ccb->ccb_h.target_lun, -#if defined(__FreeBSD__) && __FreeBSD_version >= 500000 - (uintmax_t) -#endif - ccg->volume_size); + (uintmax_t)ccg->volume_size); END_DEBUG -#if defined(__DragonFly__) || __FreeBSD_version < 501100 - size_mb = ccg->volume_size - / ((1024L * 1024L) / ccg->block_size); - - if (size_mb > 1024 && extended) { - ccg->heads = 255; - ccg->secs_per_track = 63; - } else { - ccg->heads = 64; - ccg->secs_per_track = 32; - } - secs_per_cylinder = ccg->heads * ccg->secs_per_track; - ccg->cylinders = ccg->volume_size / secs_per_cylinder; - ccb->ccb_h.status = CAM_REQ_CMP; -#else cam_calc_geometry(ccg, /*extended*/1); -#endif xpt_done(ccb); break; } @@ -2527,7 +2468,7 @@ END_DEBUG case XPT_PATH_INQ: /* Path routing inquiry */ { struct ccb_pathinq *cpi = &ccb->cpi; - + SBP_DEBUG(1) printf("%s:%d:%jx XPT_PATH_INQ:.\n", device_get_nameunit(sbp->fd.dev), @@ -2596,7 +2537,7 @@ END_DEBUG } static void -sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error) +sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error) { int i; struct sbp_ocb *ocb; @@ -2611,12 +2552,8 @@ sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error) SBP_DEBUG(2) printf("sbp_execute_ocb: seg %d", seg); for (i = 0; i < seg; i++) -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf(", %x:%d", segments[i].ds_addr, segments[i].ds_len); -#else printf(", %jx:%jd", (uintmax_t)segments[i].ds_addr, (uintmax_t)segments[i].ds_len); -#endif printf("\n"); END_DEBUG @@ -2627,7 +2564,7 @@ END_DEBUG panic("ds_len > SBP_SEG_MAX, fix busdma code"); ocb->orb[3] = htonl(s->ds_addr); ocb->orb[4] |= htonl(s->ds_len); - } else if(seg > 1) { + } else if (seg > 1) { /* page table */ for (i = 0; i < seg; i++) { s = &segments[i]; @@ -2635,12 +2572,8 @@ SBP_DEBUG(0) /* XXX LSI Logic "< 16 byte" bug might be hit */ if (s->ds_len < 16) printf("sbp_execute_ocb: warning, " -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - "segment length(%d) is less than 16." -#else "segment length(%zd) is less than 16." -#endif - "(seg=%d/%d)\n", (size_t)s->ds_len, i+1, seg); + "(seg=%d/%d)\n", (size_t)s->ds_len, i + 1, seg); END_DEBUG if (s->ds_len > SBP_SEG_MAX) panic("ds_len > SBP_SEG_MAX, fix busdma code"); @@ -2649,7 +2582,7 @@ END_DEBUG } ocb->orb[4] |= htonl(ORB_CMD_PTBL | seg); } - + if (seg > 0) bus_dmamap_sync(ocb->sdev->target->sbp->dmat, ocb->dmamap, (ntohl(ocb->orb[4]) & ORB_CMD_IN) ? @@ -2661,19 +2594,19 @@ END_DEBUG if (ocb->sdev->last_ocb != NULL) sbp_doorbell(ocb->sdev); else - sbp_orb_pointer(ocb->sdev, ocb); + sbp_orb_pointer(ocb->sdev, ocb); } } else { if (prev == NULL || (ocb->sdev->flags & ORB_LINK_DEAD) != 0) { ocb->sdev->flags &= ~ORB_LINK_DEAD; - sbp_orb_pointer(ocb->sdev, ocb); + sbp_orb_pointer(ocb->sdev, ocb); } } } static void sbp_poll(struct cam_sim *sim) -{ +{ struct sbp_softc *sbp; struct firewire_comm *fc; @@ -2694,11 +2627,7 @@ sbp_dequeue_ocb(struct sbp_dev *sdev, struct sbp_status *sbp_status) SBP_DEBUG(1) device_printf(sdev->target->sbp->fd.dev, -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - "%s:%s 0x%08lx src %d\n", -#else "%s:%s 0x%08x src %d\n", -#endif __func__, sdev->bustgtlun, ntohl(sbp_status->orb_lo), sbp_status->src); END_DEBUG SBP_LOCK_ASSERT(sdev->target->sbp); @@ -2720,7 +2649,7 @@ END_DEBUG if (!use_doorbell) { if (sbp_status->src == SRC_NO_NEXT) { if (next != NULL) - sbp_orb_pointer(sdev, next); + sbp_orb_pointer(sdev, next); else if (order > 0) { /* * Unordered execution @@ -2733,7 +2662,7 @@ END_DEBUG } else { /* * XXX this is not correct for unordered - * execution. + * execution. */ if (sdev->last_ocb != NULL) { sbp_free_ocb(sdev, sdev->last_ocb); @@ -2745,7 +2674,7 @@ END_DEBUG } break; } else - order ++; + order++; } SBP_DEBUG(0) if (ocb && order > 0) { @@ -2765,11 +2694,7 @@ sbp_enqueue_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb) SBP_LOCK_ASSERT(sdev->target->sbp); SBP_DEBUG(1) device_printf(sdev->target->sbp->fd.dev, -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - "%s:%s 0x%08x\n", __func__, sdev->bustgtlun, ocb->bus_addr); -#else "%s:%s 0x%08jx\n", __func__, sdev->bustgtlun, (uintmax_t)ocb->bus_addr); -#endif END_DEBUG prev2 = prev = STAILQ_LAST(&sdev->ocbs, sbp_ocb, ocb); STAILQ_INSERT_TAIL(&sdev->ocbs, ocb, ocb); @@ -2783,13 +2708,8 @@ END_DEBUG if (prev2 != NULL && (ocb->sdev->flags & ORB_LINK_DEAD) == 0) { SBP_DEBUG(1) -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - printf("linking chain 0x%x -> 0x%x\n", - prev2->bus_addr, ocb->bus_addr); -#else printf("linking chain 0x%jx -> 0x%jx\n", (uintmax_t)prev2->bus_addr, (uintmax_t)ocb->bus_addr); -#endif END_DEBUG /* * Suppress compiler optimization so that orb[1] must be written first. @@ -2847,11 +2767,7 @@ sbp_abort_ocb(struct sbp_ocb *ocb, int status) SBP_LOCK_ASSERT(sdev->target->sbp); SBP_DEBUG(0) device_printf(sdev->target->sbp->fd.dev, -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - "%s:%s 0x%x\n", __func__, sdev->bustgtlun, ocb->bus_addr); -#else "%s:%s 0x%jx\n", __func__, sdev->bustgtlun, (uintmax_t)ocb->bus_addr); -#endif END_DEBUG SBP_DEBUG(1) if (ocb->ccb != NULL) @@ -2909,9 +2825,6 @@ static driver_t sbp_driver = { sbp_methods, sizeof(struct sbp_softc), }; -#ifdef __DragonFly__ -DECLARE_DUMMY_MODULE(sbp); -#endif DRIVER_MODULE(sbp, firewire, sbp_driver, sbp_devclass, 0, 0); MODULE_VERSION(sbp, 1); MODULE_DEPEND(sbp, firewire, 1, 1, 1); diff --git a/sys/dev/firewire/sbp.h b/sys/dev/firewire/sbp.h index 84d522afba24..79f2e2840eb8 100644 --- a/sys/dev/firewire/sbp.h +++ b/sys/dev/firewire/sbp.h @@ -76,7 +76,7 @@ struct ind_ptr { #define SBP_RECV_LEN 32 -struct sbp_login_res{ +struct sbp_login_res { uint16_t len; uint16_t id; uint16_t res0; @@ -86,7 +86,7 @@ struct sbp_login_res{ uint16_t recon_hold; }; -struct sbp_status{ +struct sbp_status { #if BYTE_ORDER == BIG_ENDIAN uint8_t src:2, resp:2, @@ -155,7 +155,7 @@ struct sbp_status{ /* F: Address error */ -struct sbp_cmd_status{ +struct sbp_cmd_status { #define SBP_SFMT_CURR 0 #define SBP_SFMT_DEFER 1 #if BYTE_ORDER == BIG_ENDIAN diff --git a/sys/dev/firewire/sbp_targ.c b/sys/dev/firewire/sbp_targ.c index 8026b79dcb6a..0d78e9f1e8b3 100644 --- a/sys/dev/firewire/sbp_targ.c +++ b/sys/dev/firewire/sbp_targ.c @@ -1,7 +1,7 @@ /*- * Copyright (C) 2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author 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 @@ -30,7 +30,7 @@ * LIABILITY, OR 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$ */ @@ -42,9 +42,6 @@ #include #include #include -#if __FreeBSD_version < 500000 -#include -#endif #include #include @@ -107,16 +104,16 @@ struct sbp_targ_login { struct sbp_targ_lstate *lstate; struct fw_device *fwdev; struct sbp_login_res loginres; - uint16_t fifo_hi; + uint16_t fifo_hi; uint16_t last_hi; - uint32_t fifo_lo; + uint32_t fifo_lo; uint32_t last_lo; STAILQ_HEAD(, orb_info) orbs; STAILQ_ENTRY(sbp_targ_login) link; uint16_t hold_sec; uint16_t id; - uint8_t flags; - uint8_t spd; + uint8_t flags; + uint8_t spd; struct callout hold_callout; }; @@ -127,7 +124,7 @@ struct sbp_targ_lstate { struct ccb_hdr_slist accept_tios; struct ccb_hdr_slist immed_notifies; struct crom_chunk model; - uint32_t flags; + uint32_t flags; STAILQ_HEAD(, sbp_targ_login) logins; }; @@ -208,7 +205,7 @@ struct orb_info { struct sbp_targ_login *login; union ccb *ccb; struct ccb_accept_tio *atio; - uint8_t state; + uint8_t state; #define ORBI_STATUS_NONE 0 #define ORBI_STATUS_FETCH 1 #define ORBI_STATUS_ATIO 2 @@ -216,7 +213,7 @@ struct orb_info { #define ORBI_STATUS_STATUS 4 #define ORBI_STATUS_POINTER 5 #define ORBI_STATUS_ABORTED 7 - uint8_t refcount; + uint8_t refcount; uint16_t orb_hi; uint32_t orb_lo; uint32_t data_hi; @@ -253,8 +250,8 @@ sbp_targ_probe(device_t dev) device_t pa; pa = device_get_parent(dev); - if(device_get_unit(dev) != device_get_unit(pa)){ - return(ENXIO); + if (device_get_unit(dev) != device_get_unit(pa)) { + return (ENXIO); } device_set_desc(dev, "SBP-2/SCSI over FireWire target mode"); @@ -339,7 +336,7 @@ sbp_targ_post_busreset(void *arg) crom_add_entry(unit, CROM_MGM, SBP_TARG_MGM >> 2); crom_add_entry(unit, CSRKEY_UNIT_CH, (10<<8) | 8); - for (i = 0; i < MAX_LUN; i ++) { + for (i = 0; i < MAX_LUN; i++) { lstate = sc->lstate[i]; if (lstate == NULL) continue; @@ -350,7 +347,7 @@ sbp_targ_post_busreset(void *arg) } /* Process for reconnection hold time */ - for (i = 0; i < MAX_LOGINS; i ++) { + for (i = 0; i < MAX_LOGINS; i++) { login = sc->logins[i]; if (login == NULL) continue; @@ -358,7 +355,7 @@ sbp_targ_post_busreset(void *arg) if (login->flags & F_LOGIN) { login->flags |= F_HOLD; callout_reset(&login->hold_callout, - hz * login->hold_sec, + hz * login->hold_sec, sbp_targ_hold_expire, (void *)login); } } @@ -395,7 +392,7 @@ sbp_targ_find_devs(struct sbp_targ_softc *sc, union ccb *ccb, lun = ccb->ccb_h.target_lun; if (lun >= MAX_LUN) return (CAM_LUN_INVALID); - + *lstate = sc->lstate[lun]; if (notfound_failure != 0 && *lstate == NULL) { @@ -843,7 +840,7 @@ sbp_targ_cam_done(struct fw_xfer *xfer) sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link)); } - orbi->refcount --; + orbi->refcount--; ccb = orbi->ccb; if (orbi->refcount == 0) { @@ -919,7 +916,7 @@ sbp_targ_abort_ccb(struct sbp_targ_softc *sc, union ccb *ccb) found = 1; SLIST_REMOVE_HEAD(list, sim_links.sle); } else { - while(curelm != NULL) { + while (curelm != NULL) { struct ccb_hdr *nextelm; nextelm = SLIST_NEXT(curelm, sim_links.sle); @@ -985,7 +982,7 @@ sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset, if (xfer == NULL) { printf("%s: xfer == NULL", __func__); /* XXX what should we do?? */ - orbi->refcount --; + orbi->refcount--; } off += len; } @@ -1357,7 +1354,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb) ccb->ccb_h.status = CAM_UA_ABORT; break; default: - printf("%s: aborting unknown function %d\n", + printf("%s: aborting unknown function %d\n", __func__, accb->ccb_h.func_code); ccb->ccb_h.status = CAM_REQ_INVALID; break; @@ -1467,7 +1464,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer) orb = orbi->orb; /* swap payload except SCSI command */ - for (i = 0; i < 5; i ++) + for (i = 0; i < 5; i++) orb[i] = ntohl(orb[i]); orb4 = (struct corb4 *)&orb[4]; @@ -1548,12 +1545,12 @@ sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun) int i; lstate = sc->lstate[lun]; - + STAILQ_FOREACH(login, &lstate->logins, link) if (login->fwdev == fwdev) return (login); - for (i = 0; i < MAX_LOGINS; i ++) + for (i = 0; i < MAX_LOGINS; i++) if (sc->logins[i] == NULL) goto found; @@ -1610,7 +1607,7 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer) orb = orbi->orb; /* swap payload */ - for (i = 0; i < 8; i ++) { + for (i = 0; i < 8; i++) { orb[i] = ntohl(orb[i]); } orb4 = (struct morb4 *)&orb[4]; @@ -1631,10 +1628,10 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer) lstate = orbi->sc->lstate[lun]; if (lun >= MAX_LUN || lstate == NULL || - (exclusive && + (exclusive && STAILQ_FIRST(&lstate->logins) != NULL && STAILQ_FIRST(&lstate->logins)->fwdev != orbi->fwdev) - ) { + ) { /* error */ orbi->status.dead = 1; orbi->status.status = STATUS_ACCESS_DENY; @@ -1822,16 +1819,16 @@ sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id, int rtcode = 0; if (login_id < 0 || login_id >= MAX_LOGINS) - return(RESP_ADDRESS_ERROR); + return (RESP_ADDRESS_ERROR); sc = (struct sbp_targ_softc *)xfer->sc; login = sc->logins[login_id]; if (login == NULL) - return(RESP_ADDRESS_ERROR); + return (RESP_ADDRESS_ERROR); if (login->fwdev != fwdev) { /* XXX */ - return(RESP_ADDRESS_ERROR); + return (RESP_ADDRESS_ERROR); } switch (reg) { @@ -1898,17 +1895,17 @@ sbp_targ_mgm(struct fw_xfer *xfer, struct fw_device *fwdev) sc = (struct sbp_targ_softc *)xfer->sc; fp = &xfer->recv.hdr; - if (fp->mode.wreqb.tcode != FWTCODE_WREQB){ + if (fp->mode.wreqb.tcode != FWTCODE_WREQB) { printf("%s: tcode = %d\n", __func__, fp->mode.wreqb.tcode); - return(RESP_TYPE_ERROR); + return (RESP_TYPE_ERROR); } sbp_targ_fetch_orb(sc, fwdev, ntohl(xfer->recv.payload[0]), ntohl(xfer->recv.payload[1]), NULL, FETCH_MGM); - - return(0); + + return (0); } static void @@ -2026,9 +2023,9 @@ sbp_targ_detach(device_t dev) xpt_free_path(sc->path); xpt_bus_deregister(cam_sim_path(sc->sim)); SBP_UNLOCK(sc); - cam_sim_free(sc->sim, /*free_devq*/TRUE); + cam_sim_free(sc->sim, /*free_devq*/TRUE); - for (i = 0; i < MAX_LUN; i ++) { + for (i = 0; i < MAX_LUN; i++) { lstate = sc->lstate[i]; if (lstate != NULL) { xpt_free_path(lstate->path); @@ -2039,7 +2036,7 @@ sbp_targ_detach(device_t dev) xpt_free_path(sc->black_hole->path); free(sc->black_hole, M_SBP_TARG); } - + fw_bindremove(sc->fd.fc, &sc->fwb); fw_xferlist_remove(&sc->fwb.xferlist); diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 4b288bc9c707..947f057365d5 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -1008,7 +1008,7 @@ fxp_detach(device_t dev) #ifdef DEVICE_POLLING if (if_getcapenable(sc->ifp) & IFCAP_POLLING) - ether_poll_deregister_drv(sc->ifp); + ether_poll_deregister(sc->ifp); #endif FXP_LOCK(sc); @@ -1670,7 +1670,7 @@ fxp_encap(struct fxp_softc *sc, struct mbuf **m_head) } #ifdef DEVICE_POLLING -static poll_handler_drv_t fxp_poll; +static poll_handler_t fxp_poll; static int fxp_poll(if_t ifp, enum poll_cmd cmd, int count) @@ -2012,7 +2012,7 @@ fxp_intr_body(struct fxp_softc *sc, if_t ifp, uint8_t statack, return (rx_npkts); } else { /* Reuse RFA and loaded DMA map. */ - if_inciqdrops(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); fxp_discard_rfabuf(sc, rxp); } fxp_add_rfabuf(sc, rxp); @@ -2070,10 +2070,12 @@ fxp_update_stats(struct fxp_softc *sc) hsp->tx_tco += le16toh(sp->tx_tco); hsp->rx_tco += le16toh(sp->rx_tco); - if_incopackets(ifp, le32toh(sp->tx_good)); - if_inccollisions(ifp, le32toh(sp->tx_total_collisions)); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, le32toh(sp->tx_good)); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + le32toh(sp->tx_total_collisions)); if (sp->rx_good) { - if_incipackets(ifp, le32toh(sp->rx_good)); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, + le32toh(sp->rx_good)); sc->rx_idle_secs = 0; } else if (sc->flags & FXP_FLAG_RXBUG) { /* @@ -2081,7 +2083,7 @@ fxp_update_stats(struct fxp_softc *sc) */ sc->rx_idle_secs++; } - if_incierrors(ifp, + if_inc_counter(ifp, IFCOUNTER_IERRORS, le32toh(sp->rx_crc_errors) + le32toh(sp->rx_alignment_errors) + le32toh(sp->rx_rnr_errors) + @@ -2091,7 +2093,8 @@ fxp_update_stats(struct fxp_softc *sc) * threshold by another 512 bytes (64 * 8). */ if (sp->tx_underruns) { - if_incoerrors(ifp, le32toh(sp->tx_underruns)); + if_inc_counter(ifp, IFCOUNTER_OERRORS, + le32toh(sp->tx_underruns)); if (tx_threshold < 192) tx_threshold += 64; } @@ -2244,7 +2247,7 @@ fxp_watchdog(struct fxp_softc *sc) return; device_printf(sc->dev, "device timeout\n"); - if_incoerrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); fxp_init_body(sc, 1); @@ -2887,7 +2890,7 @@ fxp_ioctl(if_t ifp, u_long command, caddr_t data) #ifdef DEVICE_POLLING if (mask & IFCAP_POLLING) { if (ifr->ifr_reqcap & IFCAP_POLLING) { - error = ether_poll_register_drv(fxp_poll, ifp); + error = ether_poll_register(fxp_poll, ifp); if (error) return(error); FXP_LOCK(sc); @@ -2896,7 +2899,7 @@ fxp_ioctl(if_t ifp, u_long command, caddr_t data) if_setcapenablebit(ifp, IFCAP_POLLING, 0); FXP_UNLOCK(sc); } else { - error = ether_poll_deregister_drv(ifp); + error = ether_poll_deregister(ifp); /* Enable interrupts in any case */ FXP_LOCK(sc); CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, 0); diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index ce83f2ff7315..b2a828dbbd54 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -568,18 +568,18 @@ gem_tick(void *arg) /* * Unload collision and error counters. */ - ifp->if_collisions += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, GEM_BANK1_READ_4(sc, GEM_MAC_NORM_COLL_CNT) + - GEM_BANK1_READ_4(sc, GEM_MAC_FIRST_COLL_CNT); + GEM_BANK1_READ_4(sc, GEM_MAC_FIRST_COLL_CNT)); v = GEM_BANK1_READ_4(sc, GEM_MAC_EXCESS_COLL_CNT) + GEM_BANK1_READ_4(sc, GEM_MAC_LATE_COLL_CNT); - ifp->if_collisions += v; - ifp->if_oerrors += v; - ifp->if_ierrors += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, v); + if_inc_counter(ifp, IFCOUNTER_OERRORS, v); + if_inc_counter(ifp, IFCOUNTER_IERRORS, GEM_BANK1_READ_4(sc, GEM_MAC_RX_LEN_ERR_CNT) + GEM_BANK1_READ_4(sc, GEM_MAC_RX_ALIGN_ERR) + GEM_BANK1_READ_4(sc, GEM_MAC_RX_CRC_ERR_CNT) + - GEM_BANK1_READ_4(sc, GEM_MAC_RX_CODE_VIOL); + GEM_BANK1_READ_4(sc, GEM_MAC_RX_CODE_VIOL)); /* * Then clear the hardware counters. @@ -1485,7 +1485,7 @@ gem_tint(struct gem_softc *sc) STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); progress = 1; } @@ -1580,7 +1580,7 @@ gem_rint(struct gem_softc *sc) } if (rxstat & GEM_RD_BAD_CRC) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); device_printf(sc->sc_dev, "receive error: CRC error\n"); GEM_INIT_RXDESC(sc, sc->sc_rxptr); m = NULL; @@ -1606,7 +1606,7 @@ gem_rint(struct gem_softc *sc) * the buffer that's already attached to this descriptor. */ if (gem_add_rxbuf(sc, sc->sc_rxptr) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); GEM_INIT_RXDESC(sc, sc->sc_rxptr); m = NULL; } @@ -1634,7 +1634,7 @@ gem_rint(struct gem_softc *sc) continue; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_data += ETHER_ALIGN; /* first byte offset */ m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = GEM_RD_BUFLEN(rxstat); @@ -1706,7 +1706,7 @@ static void gem_eint(struct gem_softc *sc, u_int status) { - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); if ((status & GEM_INTR_RX_TAG_ERR) != 0) { gem_reset_rxdma(sc); return; @@ -1784,7 +1784,7 @@ gem_intr(void *v) "MAC TX fault, status %x\n", status2); if ((status2 & (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) != 0) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; gem_init_locked(sc); } @@ -1798,7 +1798,7 @@ gem_intr(void *v) * likely that the receiver has hung so we reset it. */ if ((status2 & GEM_MAC_RX_OVERFLOW) != 0) { - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); gem_reset_rxdma(sc); } else if ((status2 & ~(GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT)) != 0) @@ -1835,7 +1835,7 @@ gem_watchdog(struct gem_softc *sc) device_printf(sc->sc_dev, "device timeout\n"); else if (bootverbose) device_printf(sc->sc_dev, "device timeout (no link)\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* Try to get more packets going. */ ifp->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/dev/gxemul/ether/if_gx.c b/sys/dev/gxemul/ether/if_gx.c index 63483f8a52c6..886fb590441b 100644 --- a/sys/dev/gxemul/ether/if_gx.c +++ b/sys/dev/gxemul/ether/if_gx.c @@ -248,8 +248,8 @@ gx_transmit(struct ifnet *ifp, struct mbuf *m) ETHER_BPF_MTAP(ifp, m); - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); m_freem(m); @@ -366,14 +366,14 @@ gx_rx_intr(void *arg) break; length = GXEMUL_ETHER_DEV_READ(GXEMUL_ETHER_DEV_LENGTH); if (length > MCLBYTES - ETHER_ALIGN) { - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); continue; } m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) { device_printf(sc->sc_dev, "no memory for receive mbuf.\n"); - sc->sc_ifp->if_iqdrops++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1); GXEMUL_ETHER_UNLOCK(sc); return; } @@ -386,7 +386,7 @@ gx_rx_intr(void *arg) m->m_pkthdr.rcvif = sc->sc_ifp; m->m_pkthdr.len = m->m_len = length; - sc->sc_ifp->if_ipackets++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); GXEMUL_ETHER_UNLOCK(sc); diff --git a/sys/dev/hatm/if_hatm_rx.c b/sys/dev/hatm/if_hatm_rx.c index bf17294df211..af0b925410ff 100644 --- a/sys/dev/hatm/if_hatm_rx.c +++ b/sys/dev/hatm/if_hatm_rx.c @@ -149,7 +149,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, m_freem(vcc->chain); vcc->chain = vcc->last = NULL; sc->istats.crc_error++; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); return; } if (flags & HE_REGM_RBRQ_LEN_ERROR) { @@ -157,7 +157,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, m_freem(vcc->chain); vcc->chain = vcc->last = NULL; sc->istats.len_error++; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); return; } @@ -240,9 +240,9 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0, ATM_PH_VPI(&aph) = vpi; ATM_PH_SETVCI(&aph, vci); - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); /* this is in if_atmsubr.c */ - /* sc->ifp->if_ibytes += len; */ + /* if_inc_counter(sc->ifp, IFCOUNTER_IBYTES, len); */ vcc->ibytes += len; vcc->ipackets++; diff --git a/sys/dev/hatm/if_hatm_tx.c b/sys/dev/hatm/if_hatm_tx.c index 8e03e9d55cb6..d0a28bad679a 100644 --- a/sys/dev/hatm/if_hatm_tx.c +++ b/sys/dev/hatm/if_hatm_tx.c @@ -452,7 +452,7 @@ hatm_start(struct ifnet *ifp) if ((tpd = hatm_alloc_tpd(sc, M_NOWAIT)) == NULL) { hatm_free_txmbuf(sc); m_freem(m); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } tpd->cid = cid; @@ -472,7 +472,7 @@ hatm_start(struct ifnet *ifp) tpd->mbuf = NULL; hatm_free_txmbuf(sc); hatm_free_tpd(sc, tpd); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } arg.mbuf = m; @@ -484,17 +484,17 @@ hatm_start(struct ifnet *ifp) if_printf(sc->ifp, "mbuf loaded error=%d\n", error); hatm_free_tpd(sc, tpd); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } if (arg.error) { hatm_free_tpd(sc, tpd); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } arg.vcc->opackets++; arg.vcc->obytes += len; - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); } mtx_unlock(&sc->mtx); } diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c index e5ad831cc896..5645c147452b 100644 --- a/sys/dev/hme/if_hme.c +++ b/sys/dev/hme/if_hme.c @@ -477,11 +477,11 @@ hme_tick(void *arg) /* * Unload collision counters */ - ifp->if_collisions += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, HME_MAC_READ_4(sc, HME_MACI_NCCNT) + HME_MAC_READ_4(sc, HME_MACI_FCCNT) + HME_MAC_READ_4(sc, HME_MACI_EXCNT) + - HME_MAC_READ_4(sc, HME_MACI_LTCNT); + HME_MAC_READ_4(sc, HME_MACI_LTCNT)); /* * then clear the hardware counters. @@ -1072,7 +1072,7 @@ hme_read(struct hme_softc *sc, int ix, int len, u_int32_t flags) HME_WHINE(sc->sc_dev, "invalid packet size %d; dropping\n", len); #endif - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); hme_discard_rxbuf(sc, ix); return; } @@ -1086,12 +1086,12 @@ hme_read(struct hme_softc *sc, int ix, int len, u_int32_t flags) * it is sure that a new buffer can be mapped. If it can not, * drop the packet, but leave the interface up. */ - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); hme_discard_rxbuf(sc, ix); return; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len + HME_RXOFFS; @@ -1193,7 +1193,7 @@ hme_tint(struct hme_softc *sc) BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_tdmatag, htx->htx_dmamap); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(htx->htx_m); htx->htx_m = NULL; STAILQ_REMOVE_HEAD(&sc->sc_rb.rb_txbusyq, htx_q); @@ -1299,7 +1299,7 @@ hme_rint(struct hme_softc *sc) if ((flags & HME_XD_OFL) != 0) { device_printf(sc->sc_dev, "buffer overflow, ri=%d; " "flags=0x%x\n", ri, flags); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); hme_discard_rxbuf(sc, ri); } else { len = HME_XD_DECODE_RSIZE(flags); @@ -1374,7 +1374,7 @@ hme_watchdog(struct hme_softc *sc) device_printf(sc->sc_dev, "device timeout\n"); else if (bootverbose) device_printf(sc->sc_dev, "device timeout (no link)\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; hme_init_locked(sc); diff --git a/sys/dev/hwpmc/hwpmc_powerpc.c b/sys/dev/hwpmc/hwpmc_powerpc.c index 462805935c4b..ad251d3a42b3 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -40,14 +40,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* For VM_MIN_KERNEL_ADDRESS/VM_MAX_KERNEL_ADDRESS */ +#include #include "hwpmc_powerpc.h" -#define INKERNEL(x) (((vm_offset_t)(x)) <= VM_MAX_KERNEL_ADDRESS && \ - ((vm_offset_t)(x)) >= VM_MIN_KERNEL_ADDRESS) -#define INUSER(x) (((vm_offset_t)(x)) <= VM_MAXUSER_ADDRESS && \ - ((vm_offset_t)(x)) >= VM_MIN_ADDRESS) +#ifdef __powerpc64__ +#define OFFSET 4 /* Account for the TOC reload slot */ +#else +#define OFFSET 0 +#endif struct powerpc_cpu **powerpc_pcpu; @@ -56,20 +57,33 @@ pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples, struct trapframe *tf) { uintptr_t *osp, *sp; + uintptr_t pc; int frames = 0; cc[frames++] = PMC_TRAPFRAME_TO_PC(tf); sp = (uintptr_t *)PMC_TRAPFRAME_TO_FP(tf); - osp = NULL; + osp = (uintptr_t *)PAGE_SIZE; for (; frames < maxsamples; frames++) { - if (!INKERNEL(sp) || sp <= osp) + if (sp <= osp) break; -#ifdef __powerpc64__ - cc[frames] = sp[2]; -#else - cc[frames] = sp[1]; -#endif + #ifdef __powerpc64__ + pc = sp[2]; + #else + pc = sp[1]; + #endif + if ((pc & 3) || (pc < 0x100)) + break; + + /* + * trapexit() and asttrapexit() are sentinels + * for kernel stack tracing. + * */ + if (pc + OFFSET == (uintptr_t) &trapexit || + pc + OFFSET == (uintptr_t) &asttrapexit) + break; + + cc[frames] = pc; osp = sp; sp = (uintptr_t *)*sp; } @@ -194,7 +208,7 @@ pmc_save_user_callchain(uintptr_t *cc, int maxsamples, osp = NULL; for (; frames < maxsamples; frames++) { - if (!INUSER(sp) || sp <= osp) + if (sp <= osp) break; osp = sp; #ifdef __powerpc64__ diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h index 4257b371c717..8a45d89cd063 100644 --- a/sys/dev/hyperv/include/hyperv.h +++ b/sys/dev/hyperv/include/hyperv.h @@ -795,5 +795,34 @@ hv_get_phys_addr(void *virt) return (ret); } + +/** + * KVP related structures + * + */ +typedef struct hv_vmbus_service { + hv_guid guid; /* Hyper-V GUID */ + char *name; /* name of service */ + boolean_t enabled; /* service enabled */ + hv_work_queue *work_queue; /* background work queue */ + + /* + * function to initialize service + */ + int (*init)(struct hv_vmbus_service *); + + /* + * function to process Hyper-V messages + */ + void (*callback)(void *); +} hv_vmbus_service; + +extern uint8_t* receive_buffer[]; +extern hv_vmbus_service service_table[]; + +void hv_kvp_callback(void *context); +int hv_kvp_init(hv_vmbus_service *serv); +void hv_kvp_deinit(void); + #endif /* __HYPERV_H__ */ diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c index 3b60c3fd0574..41d869fe87b8 100644 --- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c +++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c @@ -500,7 +500,7 @@ hn_start_locked(struct ifnet *ifp) ret = hv_rf_on_send(device_ctx, packet); if (ret == 0) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* if bpf && mc_head, call bpf_mtap code */ if (mc_head) { ETHER_BPF_MTAP(ifp, mc_head); @@ -702,7 +702,7 @@ netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet) * messages (not just data messages) will trigger a response. */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* We're not holding the lock here, so don't release it */ (*ifp->if_input)(ifp, m_new); @@ -988,7 +988,7 @@ hn_watchdog(struct ifnet *ifp) printf("hn%d: watchdog timeout -- resetting\n", sc->hn_unit); hn_ifinit(sc); /*???*/ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } #endif diff --git a/sys/dev/hyperv/utilities/hv_kvp.c b/sys/dev/hyperv/utilities/hv_kvp.c new file mode 100644 index 000000000000..848d364a4b33 --- /dev/null +++ b/sys/dev/hyperv/utilities/hv_kvp.c @@ -0,0 +1,1001 @@ +/*- + * Copyright (c) 2014 Microsoft Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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 ``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. + */ + +/* + * Author: Sainath Varanasi. + * Date: 4/2012 + * Email: bsdic@microsoft.com + */ + +#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 "unicode.h" +#include "hv_kvp.h" + +/* hv_kvp defines */ +#define BUFFERSIZE sizeof(struct hv_kvp_msg) +#define KVP_SUCCESS 0 +#define KVP_ERROR 1 +#define kvp_hdr hdr.kvp_hdr + +/* hv_kvp debug control */ +static int hv_kvp_log = 0; +SYSCTL_INT(_dev, OID_AUTO, hv_kvp_log, CTLFLAG_RW, &hv_kvp_log, 0, + "hv_kvp log"); + +#define hv_kvp_log_error(...) do { \ + if (hv_kvp_log > 0) \ + log(LOG_ERR, "hv_kvp: " __VA_ARGS__); \ +} while (0) + +#define hv_kvp_log_info(...) do { \ + if (hv_kvp_log > 1) \ + log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ +} while (0) + +/* character device prototypes */ +static d_open_t hv_kvp_dev_open; +static d_close_t hv_kvp_dev_close; +static d_read_t hv_kvp_dev_daemon_read; +static d_write_t hv_kvp_dev_daemon_write; +static d_poll_t hv_kvp_dev_daemon_poll; + +/* hv_kvp prototypes */ +static int hv_kvp_req_in_progress(void); +static void hv_kvp_transaction_init(uint32_t, hv_vmbus_channel *, uint64_t, uint8_t *); +static void hv_kvp_send_msg_to_daemon(void); +static void hv_kvp_process_request(void *context); + +/* hv_kvp character device structure */ +static struct cdevsw hv_kvp_cdevsw = +{ + .d_version = D_VERSION, + .d_open = hv_kvp_dev_open, + .d_close = hv_kvp_dev_close, + .d_read = hv_kvp_dev_daemon_read, + .d_write = hv_kvp_dev_daemon_write, + .d_poll = hv_kvp_dev_daemon_poll, + .d_name = "hv_kvp_dev", +}; +static struct cdev *hv_kvp_dev; +static struct hv_kvp_msg *hv_kvp_dev_buf; +struct proc *daemon_task; + +/* + * Global state to track and synchronize multiple + * KVP transaction requests from the host. + */ +static struct { + + /* Pre-allocated work item for queue */ + hv_work_item work_item; + + /* Unless specified the pending mutex should be + * used to alter the values of the following paramters: + * 1. req_in_progress + * 2. req_timed_out + * 3. pending_reqs. + */ + struct mtx pending_mutex; + + /* To track if transaction is active or not */ + boolean_t req_in_progress; + /* Tracks if daemon did not reply back in time */ + boolean_t req_timed_out; + /* Tracks if daemon is serving a request currently */ + boolean_t daemon_busy; + /* Count of KVP requests from Hyper-V. */ + uint64_t pending_reqs; + + + /* Length of host message */ + uint32_t host_msg_len; + + /* Pointer to channel */ + hv_vmbus_channel *channelp; + + /* Host message id */ + uint64_t host_msg_id; + + /* Current kvp message from the host */ + struct hv_kvp_msg *host_kvp_msg; + + /* Current kvp message for daemon */ + struct hv_kvp_msg daemon_kvp_msg; + + /* Rcv buffer for communicating with the host*/ + uint8_t *rcv_buf; + + /* Device semaphore to control communication */ + struct sema dev_sema; + + /* Indicates if daemon registered with driver */ + boolean_t register_done; + + /* Character device status */ + boolean_t dev_accessed; +} kvp_globals; + +/* global vars */ +MALLOC_DECLARE(M_HV_KVP_DEV_BUF); +MALLOC_DEFINE(M_HV_KVP_DEV_BUF, "hv_kvp_dev buffer", "buffer for hv_kvp_dev module"); + +/* + * hv_kvp low level functions + */ + +/* + * Check if kvp transaction is in progres + */ +static int +hv_kvp_req_in_progress(void) +{ + + return (kvp_globals.req_in_progress); +} + + +/* + * This routine is called whenever a message is received from the host + */ +static void +hv_kvp_transaction_init(uint32_t rcv_len, hv_vmbus_channel *rcv_channel, + uint64_t request_id, uint8_t *rcv_buf) +{ + + /* Store all the relevant message details in the global structure */ + /* Do not need to use mutex for req_in_progress here */ + kvp_globals.req_in_progress = true; + kvp_globals.host_msg_len = rcv_len; + kvp_globals.channelp = rcv_channel; + kvp_globals.host_msg_id = request_id; + kvp_globals.rcv_buf = rcv_buf; + kvp_globals.host_kvp_msg = (struct hv_kvp_msg *)&rcv_buf[ + sizeof(struct hv_vmbus_pipe_hdr) + + sizeof(struct hv_vmbus_icmsg_hdr)]; +} + + +/* + * hv_kvp - version neogtiation function + */ +static void +hv_kvp_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, + struct hv_vmbus_icmsg_negotiate *negop, + uint8_t *buf) +{ + int icframe_vercnt; + int icmsg_vercnt; + + icmsghdrp->icmsgsize = 0x10; + + negop = (struct hv_vmbus_icmsg_negotiate *)&buf[ + sizeof(struct hv_vmbus_pipe_hdr) + + sizeof(struct hv_vmbus_icmsg_hdr)]; + icframe_vercnt = negop->icframe_vercnt; + icmsg_vercnt = negop->icmsg_vercnt; + + /* + * Select the framework version number we will support + */ + if ((icframe_vercnt >= 2) && (negop->icversion_data[1].major == 3)) { + icframe_vercnt = 3; + if (icmsg_vercnt >= 2) + icmsg_vercnt = 4; + else + icmsg_vercnt = 3; + } else { + icframe_vercnt = 1; + icmsg_vercnt = 1; + } + + negop->icframe_vercnt = 1; + negop->icmsg_vercnt = 1; + negop->icversion_data[0].major = icframe_vercnt; + negop->icversion_data[0].minor = 0; + negop->icversion_data[1].major = icmsg_vercnt; + negop->icversion_data[1].minor = 0; +} + + +/* + * Convert ip related info in umsg from utf8 to utf16 and store in hmsg + */ +static int +hv_kvp_convert_utf8_ipinfo_to_utf16(struct hv_kvp_msg *umsg, + struct hv_kvp_ip_msg *host_ip_msg) +{ + int err_ip, err_subnet, err_gway, err_dns, err_adap; + int UNUSED_FLAG = 1; + + utf8_to_utf16((uint16_t *)host_ip_msg->kvp_ip_val.ip_addr, + MAX_IP_ADDR_SIZE, + (char *)umsg->body.kvp_ip_val.ip_addr, + strlen((char *)umsg->body.kvp_ip_val.ip_addr), + UNUSED_FLAG, + &err_ip); + utf8_to_utf16((uint16_t *)host_ip_msg->kvp_ip_val.sub_net, + MAX_IP_ADDR_SIZE, + (char *)umsg->body.kvp_ip_val.sub_net, + strlen((char *)umsg->body.kvp_ip_val.sub_net), + UNUSED_FLAG, + &err_subnet); + utf8_to_utf16((uint16_t *)host_ip_msg->kvp_ip_val.gate_way, + MAX_GATEWAY_SIZE, + (char *)umsg->body.kvp_ip_val.gate_way, + strlen((char *)umsg->body.kvp_ip_val.gate_way), + UNUSED_FLAG, + &err_gway); + utf8_to_utf16((uint16_t *)host_ip_msg->kvp_ip_val.dns_addr, + MAX_IP_ADDR_SIZE, + (char *)umsg->body.kvp_ip_val.dns_addr, + strlen((char *)umsg->body.kvp_ip_val.dns_addr), + UNUSED_FLAG, + &err_dns); + utf8_to_utf16((uint16_t *)host_ip_msg->kvp_ip_val.adapter_id, + MAX_IP_ADDR_SIZE, + (char *)umsg->body.kvp_ip_val.adapter_id, + strlen((char *)umsg->body.kvp_ip_val.adapter_id), + UNUSED_FLAG, + &err_adap); + + host_ip_msg->kvp_ip_val.dhcp_enabled = umsg->body.kvp_ip_val.dhcp_enabled; + host_ip_msg->kvp_ip_val.addr_family = umsg->body.kvp_ip_val.addr_family; + + return (err_ip | err_subnet | err_gway | err_dns | err_adap); +} + + +/* + * Convert ip related info in hmsg from utf16 to utf8 and store in umsg + */ +static int +hv_kvp_convert_utf16_ipinfo_to_utf8(struct hv_kvp_ip_msg *host_ip_msg, + struct hv_kvp_msg *umsg) +{ + int err_ip, err_subnet, err_gway, err_dns, err_adap; + int UNUSED_FLAG = 1; + int guid_index; + struct hv_device *hv_dev; /* GUID Data Structure */ + hn_softc_t *sc; /* hn softc structure */ + char if_name[4]; + unsigned char guid_instance[40]; + char *guid_data = NULL; + char buf[39]; + + struct guid_extract { + char a1[2]; + char a2[2]; + char a3[2]; + char a4[2]; + char b1[2]; + char b2[2]; + char c1[2]; + char c2[2]; + char d[4]; + char e[12]; + }; + + struct guid_extract *id; + device_t *devs; + int devcnt; + + /* IP Address */ + utf16_to_utf8((char *)umsg->body.kvp_ip_val.ip_addr, + MAX_IP_ADDR_SIZE, + (uint16_t *)host_ip_msg->kvp_ip_val.ip_addr, + MAX_IP_ADDR_SIZE, + UNUSED_FLAG, + &err_ip); + + /* Adapter ID : GUID */ + utf16_to_utf8((char *)umsg->body.kvp_ip_val.adapter_id, + MAX_ADAPTER_ID_SIZE, + (uint16_t *)host_ip_msg->kvp_ip_val.adapter_id, + MAX_ADAPTER_ID_SIZE, + UNUSED_FLAG, + &err_adap); + + if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) { + for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { + sc = device_get_softc(devs[devcnt]); + + /* Trying to find GUID of Network Device */ + hv_dev = sc->hn_dev_obj; + + for (guid_index = 0; guid_index < 16; guid_index++) { + sprintf(&guid_instance[guid_index * 2], "%02x", + hv_dev->device_id.data[guid_index]); + } + + guid_data = (char *)guid_instance; + id = (struct guid_extract *)guid_data; + snprintf(buf, sizeof(buf), "{%.2s%.2s%.2s%.2s-%.2s%.2s-%.2s%.2s-%.4s-%s}", + id->a4, id->a3, id->a2, id->a1, + id->b2, id->b1, id->c2, id->c1, id->d, id->e); + guid_data = NULL; + sprintf(if_name, "%s%d", "hn", device_get_unit(devs[devcnt])); + + if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, 39) == 0) { + strcpy((char *)umsg->body.kvp_ip_val.adapter_id, if_name); + break; + } + } + free(devs, M_TEMP); + } + + /* Address Family , DHCP , SUBNET, Gateway, DNS */ + umsg->kvp_hdr.operation = host_ip_msg->operation; + umsg->body.kvp_ip_val.addr_family = host_ip_msg->kvp_ip_val.addr_family; + umsg->body.kvp_ip_val.dhcp_enabled = host_ip_msg->kvp_ip_val.dhcp_enabled; + utf16_to_utf8((char *)umsg->body.kvp_ip_val.sub_net, MAX_IP_ADDR_SIZE, + (uint16_t *)host_ip_msg->kvp_ip_val.sub_net, + MAX_IP_ADDR_SIZE, + UNUSED_FLAG, + &err_subnet); + + utf16_to_utf8((char *)umsg->body.kvp_ip_val.gate_way, MAX_GATEWAY_SIZE, + (uint16_t *)host_ip_msg->kvp_ip_val.gate_way, + MAX_GATEWAY_SIZE, + UNUSED_FLAG, + &err_gway); + + utf16_to_utf8((char *)umsg->body.kvp_ip_val.dns_addr, MAX_IP_ADDR_SIZE, + (uint16_t *)host_ip_msg->kvp_ip_val.dns_addr, + MAX_IP_ADDR_SIZE, + UNUSED_FLAG, + &err_dns); + + return (err_ip | err_subnet | err_gway | err_dns | err_adap); +} + + +/* + * Prepare a user kvp msg based on host kvp msg (utf16 to utf8) + * Ensure utf16_utf8 takes care of the additional string terminating char!! + */ +static void +hv_kvp_convert_hostmsg_to_usermsg(void) +{ + int utf_err = 0; + uint32_t value_type; + struct hv_kvp_ip_msg *host_ip_msg = (struct hv_kvp_ip_msg *) + kvp_globals.host_kvp_msg; + + struct hv_kvp_msg *hmsg = kvp_globals.host_kvp_msg; + struct hv_kvp_msg *umsg = &kvp_globals.daemon_kvp_msg; + + memset(umsg, 0, sizeof(struct hv_kvp_msg)); + + umsg->kvp_hdr.operation = hmsg->kvp_hdr.operation; + umsg->kvp_hdr.pool = hmsg->kvp_hdr.pool; + + switch (umsg->kvp_hdr.operation) { + case HV_KVP_OP_SET_IP_INFO: + hv_kvp_convert_utf16_ipinfo_to_utf8(host_ip_msg, umsg); + break; + + case HV_KVP_OP_GET_IP_INFO: + utf16_to_utf8((char *)umsg->body.kvp_ip_val.adapter_id, + MAX_ADAPTER_ID_SIZE, + (uint16_t *)host_ip_msg->kvp_ip_val.adapter_id, + MAX_ADAPTER_ID_SIZE, 1, &utf_err); + + umsg->body.kvp_ip_val.addr_family = + host_ip_msg->kvp_ip_val.addr_family; + break; + + case HV_KVP_OP_SET: + value_type = hmsg->body.kvp_set.data.value_type; + + switch (value_type) { + case HV_REG_SZ: + umsg->body.kvp_set.data.value_size = + utf16_to_utf8( + (char *)umsg->body.kvp_set.data.msg_value.value, + HV_KVP_EXCHANGE_MAX_VALUE_SIZE - 1, + (uint16_t *)hmsg->body.kvp_set.data.msg_value.value, + hmsg->body.kvp_set.data.value_size, + 1, &utf_err); + /* utf8 encoding */ + umsg->body.kvp_set.data.value_size = + umsg->body.kvp_set.data.value_size / 2; + break; + + case HV_REG_U32: + umsg->body.kvp_set.data.value_size = + sprintf(umsg->body.kvp_set.data.msg_value.value, "%d", + hmsg->body.kvp_set.data.msg_value.value_u32) + 1; + break; + + case HV_REG_U64: + umsg->body.kvp_set.data.value_size = + sprintf(umsg->body.kvp_set.data.msg_value.value, "%llu", + (unsigned long long) + hmsg->body.kvp_set.data.msg_value.value_u64) + 1; + break; + } + + umsg->body.kvp_set.data.key_size = + utf16_to_utf8( + umsg->body.kvp_set.data.key, + HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1, + (uint16_t *)hmsg->body.kvp_set.data.key, + hmsg->body.kvp_set.data.key_size, + 1, &utf_err); + + /* utf8 encoding */ + umsg->body.kvp_set.data.key_size = + umsg->body.kvp_set.data.key_size / 2; + break; + + case HV_KVP_OP_GET: + umsg->body.kvp_get.data.key_size = + utf16_to_utf8(umsg->body.kvp_get.data.key, + HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1, + (uint16_t *)hmsg->body.kvp_get.data.key, + hmsg->body.kvp_get.data.key_size, + 1, &utf_err); + /* utf8 encoding */ + umsg->body.kvp_get.data.key_size = + umsg->body.kvp_get.data.key_size / 2; + break; + + case HV_KVP_OP_DELETE: + umsg->body.kvp_delete.key_size = + utf16_to_utf8(umsg->body.kvp_delete.key, + HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1, + (uint16_t *)hmsg->body.kvp_delete.key, + hmsg->body.kvp_delete.key_size, + 1, &utf_err); + /* utf8 encoding */ + umsg->body.kvp_delete.key_size = + umsg->body.kvp_delete.key_size / 2; + break; + + case HV_KVP_OP_ENUMERATE: + umsg->body.kvp_enum_data.index = + hmsg->body.kvp_enum_data.index; + break; + + default: + hv_kvp_log_info("%s: daemon_kvp_msg: Invalid operation : %d\n", + __func__, umsg->kvp_hdr.operation); + } +} + + +/* + * Prepare a host kvp msg based on user kvp msg (utf8 to utf16) + */ +static int +hv_kvp_convert_usermsg_to_hostmsg(void) +{ + int hkey_len = 0, hvalue_len = 0, utf_err = 0; + struct hv_kvp_exchg_msg_value *host_exchg_data; + char *key_name, *value; + + struct hv_kvp_msg *umsg = &kvp_globals.daemon_kvp_msg; + struct hv_kvp_msg *hmsg = kvp_globals.host_kvp_msg; + struct hv_kvp_ip_msg *host_ip_msg = (struct hv_kvp_ip_msg *)hmsg; + + switch (hmsg->kvp_hdr.operation) { + case HV_KVP_OP_GET_IP_INFO: + return (hv_kvp_convert_utf8_ipinfo_to_utf16(umsg, host_ip_msg)); + + case HV_KVP_OP_SET_IP_INFO: + case HV_KVP_OP_SET: + case HV_KVP_OP_DELETE: + return (KVP_SUCCESS); + + case HV_KVP_OP_ENUMERATE: + host_exchg_data = &hmsg->body.kvp_enum_data.data; + key_name = umsg->body.kvp_enum_data.data.key; + hkey_len = utf8_to_utf16((uint16_t *)host_exchg_data->key, + ((HV_KVP_EXCHANGE_MAX_KEY_SIZE / 2) - 2), + key_name, strlen(key_name), + 1, &utf_err); + /* utf16 encoding */ + host_exchg_data->key_size = 2 * (hkey_len + 1); + value = umsg->body.kvp_enum_data.data.msg_value.value; + hvalue_len = utf8_to_utf16( + (uint16_t *)host_exchg_data->msg_value.value, + ((HV_KVP_EXCHANGE_MAX_VALUE_SIZE / 2) - 2), + value, strlen(value), + 1, &utf_err); + host_exchg_data->value_size = 2 * (hvalue_len + 1); + host_exchg_data->value_type = HV_REG_SZ; + + if ((hkey_len < 0) || (hvalue_len < 0)) + return (HV_KVP_E_FAIL); + + return (KVP_SUCCESS); + + case HV_KVP_OP_GET: + host_exchg_data = &hmsg->body.kvp_get.data; + value = umsg->body.kvp_get.data.msg_value.value; + hvalue_len = utf8_to_utf16( + (uint16_t *)host_exchg_data->msg_value.value, + ((HV_KVP_EXCHANGE_MAX_VALUE_SIZE / 2) - 2), + value, strlen(value), + 1, &utf_err); + /* Convert value size to uft16 */ + host_exchg_data->value_size = 2 * (hvalue_len + 1); + /* Use values by string */ + host_exchg_data->value_type = HV_REG_SZ; + + if ((hkey_len < 0) || (hvalue_len < 0)) + return (HV_KVP_E_FAIL); + + return (KVP_SUCCESS); + + default: + return (HV_KVP_E_FAIL); + } +} + + +/* + * Send the response back to the host. + */ +static void +hv_kvp_respond_host(int error) +{ + struct hv_vmbus_icmsg_hdr *hv_icmsg_hdrp; + + hv_icmsg_hdrp = (struct hv_vmbus_icmsg_hdr *) + &kvp_globals.rcv_buf[sizeof(struct hv_vmbus_pipe_hdr)]; + + if (error) + error = HV_KVP_E_FAIL; + + hv_icmsg_hdrp->status = error; + hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; + + error = hv_vmbus_channel_send_packet(kvp_globals.channelp, + kvp_globals.rcv_buf, + kvp_globals.host_msg_len, kvp_globals.host_msg_id, + HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + + if (error) + hv_kvp_log_info("%s: hv_kvp_respond_host: sendpacket error:%d\n", + __func__, error); +} + + +/* + * This is the main kvp kernel process that interacts with both user daemon + * and the host + */ +static void +hv_kvp_send_msg_to_daemon(void) +{ + /* Prepare kvp_msg to be sent to user */ + hv_kvp_convert_hostmsg_to_usermsg(); + + /* Send the msg to user via function deamon_read - setting sema */ + sema_post(&kvp_globals.dev_sema); +} + + +/* + * Function to read the kvp request buffer from host + * and interact with daemon + */ +static void +hv_kvp_process_request(void *context) +{ + uint8_t *kvp_buf; + hv_vmbus_channel *channel = context; + uint32_t recvlen = 0; + uint64_t requestid; + struct hv_vmbus_icmsg_hdr *icmsghdrp; + int ret = 0; + uint64_t pending_cnt = 1; + + hv_kvp_log_info("%s: entering hv_kvp_process_request\n", __func__); + kvp_buf = receive_buffer[HV_KVP]; + ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, + &recvlen, &requestid); + + /* + * We start counting only after the daemon registers + * and therefore there could be requests pending in + * the VMBus that are not reflected in pending_cnt. + * Therefore we continue reading as long as either of + * the below conditions is true. + */ + + while ((pending_cnt>0) || ((ret == 0) && (recvlen > 0))) { + + if ((ret == 0) && (recvlen>0)) { + + icmsghdrp = (struct hv_vmbus_icmsg_hdr *) + &kvp_buf[sizeof(struct hv_vmbus_pipe_hdr)]; + + hv_kvp_transaction_init(recvlen, channel, requestid, kvp_buf); + if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { + hv_kvp_negotiate_version(icmsghdrp, NULL, kvp_buf); + hv_kvp_respond_host(ret); + + /* + * It is ok to not acquire the mutex before setting + * req_in_progress here because negotiation is the + * first thing that happens and hence there is no + * chance of a race condition. + */ + + kvp_globals.req_in_progress = false; + hv_kvp_log_info("%s :version negotiated\n", __func__); + + } else { + if (!kvp_globals.daemon_busy) { + + hv_kvp_log_info("%s: issuing qury to daemon\n", __func__); + mtx_lock(&kvp_globals.pending_mutex); + kvp_globals.req_timed_out = false; + kvp_globals.daemon_busy = true; + mtx_unlock(&kvp_globals.pending_mutex); + + hv_kvp_send_msg_to_daemon(); + hv_kvp_log_info("%s: waiting for daemon\n", __func__); + } + + /* Wait 5 seconds for daemon to respond back */ + tsleep(&kvp_globals, 0, "kvpworkitem", 5 * hz); + hv_kvp_log_info("%s: came out of wait\n", __func__); + } + } + + mtx_lock(&kvp_globals.pending_mutex); + + /* Notice that once req_timed_out is set to true + * it will remain true until the next request is + * sent to the daemon. The response from daemon + * is forwarded to host only when this flag is + * false. + */ + kvp_globals.req_timed_out = true; + + /* + * Cancel request if so need be. + */ + if (hv_kvp_req_in_progress()) { + hv_kvp_log_info("%s: request was still active after wait so failing\n", __func__); + hv_kvp_respond_host(HV_KVP_E_FAIL); + kvp_globals.req_in_progress = false; + } + + /* + * Decrement pending request count and + */ + if (kvp_globals.pending_reqs>0) { + kvp_globals.pending_reqs = kvp_globals.pending_reqs - 1; + } + pending_cnt = kvp_globals.pending_reqs; + + mtx_unlock(&kvp_globals.pending_mutex); + + /* + * Try reading next buffer + */ + recvlen = 0; + ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, + &recvlen, &requestid); + hv_kvp_log_info("%s: read: context %p, pending_cnt %ju ret =%d, recvlen=%d\n", + __func__, context, pending_cnt, ret, recvlen); + } +} + + +/* + * Callback routine that gets called whenever there is a message from host + */ +void +hv_kvp_callback(void *context) +{ + uint64_t pending_cnt = 0; + + if (kvp_globals.register_done == false) { + + kvp_globals.channelp = context; + } else { + + mtx_lock(&kvp_globals.pending_mutex); + kvp_globals.pending_reqs = kvp_globals.pending_reqs + 1; + pending_cnt = kvp_globals.pending_reqs; + mtx_unlock(&kvp_globals.pending_mutex); + if (pending_cnt == 1) { + hv_kvp_log_info("%s: Queuing work item\n", __func__); + hv_queue_work_item( + service_table[HV_KVP].work_queue, + hv_kvp_process_request, + context + ); + } + } +} + + +/* + * This function is called by the hv_kvp_init - + * creates character device hv_kvp_dev + * allocates memory to hv_kvp_dev_buf + * + */ +static int +hv_kvp_dev_init(void) +{ + int error = 0; + + /* initialize semaphore */ + sema_init(&kvp_globals.dev_sema, 0, "hv_kvp device semaphore"); + /* create character device */ + error = make_dev_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, + &hv_kvp_dev, + &hv_kvp_cdevsw, + 0, + UID_ROOT, + GID_WHEEL, + 0640, + "hv_kvp_dev"); + + if (error != 0) + return (error); + + /* + * Malloc with M_WAITOK flag will never fail. + */ + hv_kvp_dev_buf = malloc(sizeof(*hv_kvp_dev_buf), M_HV_KVP_DEV_BUF, M_WAITOK | + M_ZERO); + + return (0); +} + + +/* + * This function is called by the hv_kvp_deinit - + * destroy character device + */ +static void +hv_kvp_dev_destroy(void) +{ + + if (daemon_task != NULL) { + PROC_LOCK(daemon_task); + kern_psignal(daemon_task, SIGKILL); + PROC_UNLOCK(daemon_task); + } + + destroy_dev(hv_kvp_dev); + free(hv_kvp_dev_buf, M_HV_KVP_DEV_BUF); + return; +} + + +static int +hv_kvp_dev_open(struct cdev *dev, int oflags, int devtype, + struct thread *td) +{ + + hv_kvp_log_info("%s: Opened device \"hv_kvp_device\" successfully.\n", __func__); + if (kvp_globals.dev_accessed) + return (-EBUSY); + + daemon_task = curproc; + kvp_globals.dev_accessed = true; + kvp_globals.daemon_busy = false; + return (0); +} + + +static int +hv_kvp_dev_close(struct cdev *dev __unused, int fflag __unused, int devtype __unused, + struct thread *td __unused) +{ + + hv_kvp_log_info("%s: Closing device \"hv_kvp_device\".\n", __func__); + kvp_globals.dev_accessed = false; + kvp_globals.register_done = false; + return (0); +} + + +/* + * hv_kvp_daemon read invokes this function + * acts as a send to daemon + */ +static int +hv_kvp_dev_daemon_read(struct cdev *dev __unused, struct uio *uio, int ioflag __unused) +{ + size_t amt; + int error = 0; + + /* Check hv_kvp daemon registration status*/ + if (!kvp_globals.register_done) + return (KVP_ERROR); + + sema_wait(&kvp_globals.dev_sema); + + memcpy(hv_kvp_dev_buf, &kvp_globals.daemon_kvp_msg, sizeof(struct hv_kvp_msg)); + + amt = MIN(uio->uio_resid, uio->uio_offset >= BUFFERSIZE + 1 ? 0 : + BUFFERSIZE + 1 - uio->uio_offset); + + if ((error = uiomove(hv_kvp_dev_buf, amt, uio)) != 0) + hv_kvp_log_info("%s: hv_kvp uiomove read failed!\n", __func__); + + return (error); +} + + +/* + * hv_kvp_daemon write invokes this function + * acts as a recieve from daemon + */ +static int +hv_kvp_dev_daemon_write(struct cdev *dev __unused, struct uio *uio, int ioflag __unused) +{ + size_t amt; + int error = 0; + + uio->uio_offset = 0; + + amt = MIN(uio->uio_resid, BUFFERSIZE); + error = uiomove(hv_kvp_dev_buf, amt, uio); + + if (error != 0) + return (error); + + memcpy(&kvp_globals.daemon_kvp_msg, hv_kvp_dev_buf, sizeof(struct hv_kvp_msg)); + + if (kvp_globals.register_done == false) { + if (kvp_globals.daemon_kvp_msg.kvp_hdr.operation == HV_KVP_OP_REGISTER) { + + kvp_globals.register_done = true; + if (kvp_globals.channelp) { + + hv_kvp_callback(kvp_globals.channelp); + } + } + else { + hv_kvp_log_info("%s, KVP Registration Failed\n", __func__); + return (KVP_ERROR); + } + } else { + + mtx_lock(&kvp_globals.pending_mutex); + + if(!kvp_globals.req_timed_out) { + + hv_kvp_convert_usermsg_to_hostmsg(); + hv_kvp_respond_host(KVP_SUCCESS); + wakeup(&kvp_globals); + kvp_globals.req_in_progress = false; + } + + kvp_globals.daemon_busy = false; + mtx_unlock(&kvp_globals.pending_mutex); + } + + return (error); +} + + +/* + * hv_kvp_daemon poll invokes this function to check if data is available + * for daemon to read. + */ +static int +hv_kvp_dev_daemon_poll(struct cdev *dev __unused, int events, struct thread *td __unused) +{ + int revents = 0; + + mtx_lock(&kvp_globals.pending_mutex); + /* + * We check global flag daemon_busy for the data availiability for + * userland to read. Deamon_busy is set to true before driver has data + * for daemon to read. It is set to false after daemon sends + * then response back to driver. + */ + if (kvp_globals.daemon_busy == true) + revents = POLLIN; + mtx_unlock(&kvp_globals.pending_mutex); + + return (revents); +} + + +/* + * hv_kvp initialization function + * called from hv_util service. + * + */ +int +hv_kvp_init(hv_vmbus_service *srv) +{ + int error = 0; + hv_work_queue *work_queue = NULL; + + memset(&kvp_globals, 0, sizeof(kvp_globals)); + + work_queue = hv_work_queue_create("KVP Service"); + if (work_queue == NULL) { + hv_kvp_log_info("%s: Work queue alloc failed\n", __func__); + error = ENOMEM; + hv_kvp_log_error("%s: ENOMEM\n", __func__); + goto Finish; + } + srv->work_queue = work_queue; + + error = hv_kvp_dev_init(); + mtx_init(&kvp_globals.pending_mutex, "hv-kvp pending mutex", + NULL, MTX_DEF); + kvp_globals.pending_reqs = 0; + + +Finish: + return (error); +} + + +void +hv_kvp_deinit(void) +{ + hv_kvp_dev_destroy(); + mtx_destroy(&kvp_globals.pending_mutex); + + return; +} diff --git a/sys/dev/hyperv/utilities/hv_kvp.h b/sys/dev/hyperv/utilities/hv_kvp.h index f7dccf77df29..b67373fa7aa5 100644 --- a/sys/dev/hyperv/utilities/hv_kvp.h +++ b/sys/dev/hyperv/utilities/hv_kvp.h @@ -1,7 +1,5 @@ /*- - * Copyright (c) 2009-2012 Microsoft Corp. - * Copyright (c) 2012 NetApp Inc. - * Copyright (c) 2012 Citrix Inc. + * Copyright (c) 2014 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,13 +22,15 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 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 _KVP_H #define _KVP_H /* - * An implementation of HyperV key value pair (KVP) functionality for FreeBSD + * An implementation of HyperV key value pair (KVP) functionality for FreeBSD * */ @@ -53,15 +53,15 @@ /* * bytes, including any null terminators */ -#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048) +#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048) /* * Maximum key size - the registry limit for the length of an entry name * is 256 characters, including the null terminator */ +#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512) -#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512) /* * In FreeBSD, we implement the KVP functionality in two components: @@ -111,30 +111,20 @@ * (not supported), a NULL key string is returned. */ - + /* * Registry value types. */ +#define HV_REG_SZ 1 +#define HV_REG_U32 4 +#define HV_REG_U64 8 -#define HV_REG_SZ 1 -#define HV_REG_U32 4 -#define HV_REG_U64 8 - - -/* - * Daemon code not supporting IP injection (legacy daemon). - */ - -#define HV_KVP_OP_REGISTER 4 /* * Daemon code supporting IP injection. - * The KVP opcode field is used to communicate the - * registration information; so define a namespace that - * will be distinct from the host defined KVP opcode. */ +#define HV_KVP_OP_REGISTER 4 -#define KVP_OP_REGISTER1 100 enum hv_kvp_exchg_op { HV_KVP_OP_GET = 0, @@ -155,41 +145,41 @@ enum hv_kvp_exchg_pool { HV_KVP_POOL_COUNT /* Number of pools, must be last. */ }; + /* * Some Hyper-V status codes. */ -#define HV_KVP_S_OK 0x00000000 -#define HV_KVP_E_FAIL 0x80004005 -#define HV_KVP_S_CONT 0x80070103 -#define HV_ERROR_NOT_SUPPORTED 0x80070032 -#define HV_ERROR_MACHINE_LOCKED 0x800704F7 -#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F -#define HV_INVALIDARG 0x80070057 -#define HV_KVP_GUID_NOTFOUND 0x80041002 +#define HV_KVP_S_OK 0x00000000 +#define HV_KVP_E_FAIL 0x80004005 +#define HV_KVP_S_CONT 0x80070103 +#define HV_ERROR_NOT_SUPPORTED 0x80070032 +#define HV_ERROR_MACHINE_LOCKED 0x800704F7 +#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F +#define HV_INVALIDARG 0x80070057 +#define HV_KVP_GUID_NOTFOUND 0x80041002 -#define ADDR_FAMILY_NONE 0x00 -#define ADDR_FAMILY_IPV4 0x01 -#define ADDR_FAMILY_IPV6 0x02 +#define ADDR_FAMILY_NONE 0x00 +#define ADDR_FAMILY_IPV4 0x01 +#define ADDR_FAMILY_IPV6 0x02 -#define MAX_ADAPTER_ID_SIZE 128 -#define MAX_IP_ADDR_SIZE 1024 -#define MAX_GATEWAY_SIZE 512 +#define MAX_ADAPTER_ID_SIZE 128 +#define MAX_IP_ADDR_SIZE 1024 +#define MAX_GATEWAY_SIZE 512 struct hv_kvp_ipaddr_value { - uint16_t adapter_id[MAX_ADAPTER_ID_SIZE]; - uint8_t addr_family; - uint8_t dhcp_enabled; - uint16_t ip_addr[MAX_IP_ADDR_SIZE]; - uint16_t sub_net[MAX_IP_ADDR_SIZE]; - uint16_t gate_way[MAX_GATEWAY_SIZE]; - uint16_t dns_addr[MAX_IP_ADDR_SIZE]; -} __attribute__((packed)); - + uint16_t adapter_id[MAX_ADAPTER_ID_SIZE]; + uint8_t addr_family; + uint8_t dhcp_enabled; + uint16_t ip_addr[MAX_IP_ADDR_SIZE]; + uint16_t sub_net[MAX_IP_ADDR_SIZE]; + uint16_t gate_way[MAX_GATEWAY_SIZE]; + uint16_t dns_addr[MAX_IP_ADDR_SIZE]; +}__attribute__((packed)); struct hv_kvp_hdr { - uint8_t operation; - uint8_t pool; + uint8_t operation; + uint8_t pool; uint16_t pad; } __attribute__((packed)); @@ -197,9 +187,9 @@ struct hv_kvp_exchg_msg_value { uint32_t value_type; uint32_t key_size; uint32_t value_size; - uint8_t key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; + uint8_t key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; union { - uint8_t value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; + uint8_t value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; uint32_t value_u32; uint64_t value_u64; } msg_value; @@ -229,16 +219,16 @@ struct hv_kvp_register { struct hv_kvp_msg { union { - struct hv_kvp_hdr kvp_hdr; - int error; + struct hv_kvp_hdr kvp_hdr; + uint32_t error; } hdr; union { - struct hv_kvp_msg_get kvp_get; - struct hv_kvp_msg_set kvp_set; + struct hv_kvp_msg_get kvp_get; + struct hv_kvp_msg_set kvp_set; struct hv_kvp_msg_delete kvp_delete; struct hv_kvp_msg_enumerate kvp_enum_data; - struct hv_kvp_ipaddr_value kvp_ip_val; - struct hv_kvp_register kvp_register; + struct hv_kvp_ipaddr_value kvp_ip_val; + struct hv_kvp_register kvp_register; } body; } __attribute__((packed)); @@ -248,38 +238,17 @@ struct hv_kvp_ip_msg { struct hv_kvp_ipaddr_value kvp_ip_val; } __attribute__((packed)); -#define BSD_SOC_PATH "/etc/hyperv/socket" -#define HV_SHUT_DOWN 0 -#define HV_TIME_SYNCH 1 -#define HV_HEART_BEAT 2 -#define HV_KVP 3 -#define HV_MAX_UTIL_SERVICES 4 +#define HV_SHUT_DOWN 0 +#define HV_TIME_SYNCH 1 +#define HV_HEART_BEAT 2 +#define HV_KVP 3 +#define HV_MAX_UTIL_SERVICES 4 -#define HV_WLTIMEDELTA 116444736000000000L /* in 100ns unit */ -#define HV_ICTIMESYNCFLAG_PROBE 0 -#define HV_ICTIMESYNCFLAG_SYNC 1 -#define HV_ICTIMESYNCFLAG_SAMPLE 2 -#define HV_NANO_SEC_PER_SEC 1000000000 - -typedef struct hv_vmbus_service { - hv_guid guid; /* Hyper-V GUID */ - char* name; /* name of service */ - boolean_t enabled; /* service enabled */ - hv_work_queue* work_queue; /* background work queue */ - - // - // function to initialize service - // - int (*init)(struct hv_vmbus_service *); - - // - // function to process Hyper-V messages - // - void (*callback)(void *); -} hv_vmbus_service; - -extern uint8_t* receive_buffer[]; -extern hv_vmbus_service service_table[]; +#define HV_WLTIMEDELTA 116444736000000000L /* in 100ns unit */ +#define HV_ICTIMESYNCFLAG_PROBE 0 +#define HV_ICTIMESYNCFLAG_SYNC 1 +#define HV_ICTIMESYNCFLAG_SAMPLE 2 +#define HV_NANO_SEC_PER_SEC 1000000000 #endif /* _KVP_H */ diff --git a/sys/dev/hyperv/utilities/hv_util.c b/sys/dev/hyperv/utilities/hv_util.c index e86cbd78498a..91bbc5345ad5 100644 --- a/sys/dev/hyperv/utilities/hv_util.c +++ b/sys/dev/hyperv/utilities/hv_util.c @@ -1,7 +1,5 @@ /*- - * Copyright (c) 2009-2012 Microsoft Corp. - * Copyright (c) 2012 NetApp Inc. - * Copyright (c) 2012 Citrix Inc. + * Copyright (c) 2014 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,9 +22,11 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 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$ */ -/** +/* * A common driver for all hyper-V util services. */ @@ -53,7 +53,7 @@ static void hv_timesync_cb(void *context); static int hv_timesync_init(hv_vmbus_service *serv); -/** +/* * Note: GUID codes below are predefined by the host hypervisor * (Hyper-V and Azure)interface and required for correct operation. */ @@ -80,7 +80,16 @@ hv_vmbus_service service_table[] = { 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d}, .name = "Hyper-V Heartbeat Service\n", .enabled = TRUE, - .callback = hv_heartbeat_cb, + .callback = hv_heartbeat_cb, + }, + + /* KVP (Key Value Pair) Service */ + { .guid.data = {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6}, + .name = "Hyper-V KVP Service\n", + .enabled = TRUE, + .init = hv_kvp_init, + .callback = hv_kvp_callback, }, }; @@ -90,6 +99,8 @@ hv_vmbus_service service_table[] = { */ uint8_t *receive_buffer[HV_MAX_UTIL_SERVICES]; +static boolean_t destroyed_kvp = FALSE; + struct hv_ictimesync_data { uint64_t parenttime; uint64_t childtime; @@ -143,7 +154,7 @@ hv_negotiate_version( static void hv_set_host_time(void *context) { - time_sync_data *time_msg = context; + time_sync_data* time_msg = (time_sync_data*) context; uint64_t hosttime = time_msg->data; struct timespec guest_ts, host_ts; uint64_t host_tns; @@ -253,12 +264,12 @@ hv_timesync_cb(void *context) static void hv_shutdown_cb(void *context) { - uint8_t* buf; + uint8_t* buf; hv_vmbus_channel* channel = context; - uint8_t execute_shutdown = 0; + uint8_t execute_shutdown = 0; hv_vmbus_icmsg_hdr* icmsghdrp; - uint32_t recv_len; - uint64_t request_id; + uint32_t recv_len; + uint64_t request_id; int ret; hv_vmbus_shutdown_msg_data* shutdown_msg; @@ -421,6 +432,11 @@ hv_util_detach(device_t dev) struct hv_vmbus_service* service; size_t receive_buffer_offset; + if (!destroyed_kvp) { + hv_kvp_deinit(); + destroyed_kvp = TRUE; + } + hv_dev = vmbus_get_devctx(dev); hv_vmbus_channel_close(hv_dev->channel); @@ -432,21 +448,22 @@ hv_util_detach(device_t dev) free(receive_buffer[receive_buffer_offset], M_DEVBUF); receive_buffer[receive_buffer_offset] = NULL; - return (0); } -static void hv_util_init(void) +static void +hv_util_init(void) { } -static int hv_util_modevent(module_t mod, int event, void *arg) +static int +hv_util_modevent(module_t mod, int event, void *arg) { switch (event) { case MOD_LOAD: break; case MOD_UNLOAD: - break; + break; default: break; } diff --git a/sys/dev/hyperv/utilities/unicode.h b/sys/dev/hyperv/utilities/unicode.h new file mode 100644 index 000000000000..696777cbbf26 --- /dev/null +++ b/sys/dev/hyperv/utilities/unicode.h @@ -0,0 +1,201 @@ +/* $NetBSD: unicode.h,v 1.1.1.1 2007/03/06 00:10:39 dillo Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 + +#define UNICODE_DECOMPOSE 0x01 +#define UNICODE_PRECOMPOSE 0x02 +#define UNICODE_UTF8_LATIN1_FALLBACK 0x03 + +size_t utf8_to_utf16(uint16_t *, size_t, const char *, size_t, int, int *); +size_t utf16_to_utf8(char *, size_t, const uint16_t *, size_t, int, int *); + +size_t +utf8_to_utf16(uint16_t *dst, size_t dst_len, + const char *src, size_t src_len, + int flags, int *errp) +{ + const unsigned char *s; + size_t spos, dpos; + int error; + uint16_t c; + +#define IS_CONT(c) (((c)&0xc0) == 0x80) + + error = 0; + s = (const unsigned char *)src; + spos = dpos = 0; + while (spos= src_len || !IS_CONT(s[spos+1])) + && s[spos]>=0xa0) { + /* not valid UTF-8, assume ISO 8859-1 */ + c = s[spos++]; + } + else if (s[spos] < 0xc0 || s[spos] >= 0xf5) { + /* continuation byte without lead byte + or lead byte for codepoint above 0x10ffff */ + error++; + spos++; + continue; + } + else if (s[spos] < 0xe0) { + if (spos >= src_len || !IS_CONT(s[spos+1])) { + spos++; + error++; + continue; + } + c = ((s[spos] & 0x3f) << 6) | (s[spos+1] & 0x3f); + spos += 2; + if (c < 0x80) { + /* overlong encoding */ + error++; + continue; + } + } + else if (s[spos] < 0xf0) { + if (spos >= src_len-2 + || !IS_CONT(s[spos+1]) || !IS_CONT(s[spos+2])) { + spos++; + error++; + continue; + } + c = ((s[spos] & 0x0f) << 12) | ((s[spos+1] & 0x3f) << 6) + | (s[spos+2] & 0x3f); + spos += 3; + if (c < 0x800 || (c & 0xdf00) == 0xd800 ) { + /* overlong encoding or encoded surrogate */ + error++; + continue; + } + } + else { + uint32_t cc; + /* UTF-16 surrogate pair */ + + if (spos >= src_len-3 || !IS_CONT(s[spos+1]) + || !IS_CONT(s[spos+2]) || !IS_CONT(s[spos+3])) { + spos++; + error++; + + continue; + } + cc = ((s[spos] & 0x03) << 18) | ((s[spos+1] & 0x3f) << 12) + | ((s[spos+2] & 0x3f) << 6) | (s[spos+3] & 0x3f); + spos += 4; + if (cc < 0x10000) { + /* overlong encoding */ + error++; + continue; + } + if (dst && dpos < dst_len) + dst[dpos] = (0xd800 | ((cc-0x10000)>>10)); + dpos++; + c = 0xdc00 | ((cc-0x10000) & 0x3ffff); + } + + if (dst && dpos < dst_len) + dst[dpos] = c; + dpos++; + } + + if (errp) + *errp = error; + + return dpos; + +#undef IS_CONT +} + + +size_t +utf16_to_utf8(char *dst, size_t dst_len, + const uint16_t *src, size_t src_len, + int flags, int *errp) +{ + uint16_t spos, dpos; + int error; + +#define CHECK_LENGTH(l) (dpos > dst_len-(l) ? dst=NULL : NULL) +#define ADD_BYTE(b) (dst ? dst[dpos] = (b) : 0, dpos++) + + error = 0; + dpos = 0; + for (spos=0; spos>6)); + ADD_BYTE(0x80 | (src[spos] & 0x3f)); + } + else if ((src[spos] & 0xdc00) == 0xd800) { + uint32_t c; + /* first surrogate */ + if (spos == src_len - 1 || (src[spos] & 0xdc00) != 0xdc00) { + /* no second surrogate present */ + error++; + continue; + } + spos++; + CHECK_LENGTH(4); + c = (((src[spos]&0x3ff) << 10) | (src[spos+1]&0x3ff)) + 0x10000; + ADD_BYTE(0xf0 | (c>>18)); + ADD_BYTE(0x80 | ((c>>12) & 0x3f)); + ADD_BYTE(0x80 | ((c>>6) & 0x3f)); + ADD_BYTE(0x80 | (c & 0x3f)); + } + else if ((src[spos] & 0xdc00) == 0xdc00) { + /* second surrogate without preceding first surrogate */ + error++; + } + else { + CHECK_LENGTH(3); + ADD_BYTE(0xe0 | src[spos]>>12); + ADD_BYTE(0x80 | ((src[spos]>>6) & 0x3f)); + ADD_BYTE(0x80 | (src[spos] & 0x3f)); + } + } + + if (errp) + *errp = error; + + return dpos; + +#undef ADD_BYTE +#undef CHECK_LENGTH +} diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index 82c5dfcc8106..72e2559cdb0c 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -427,13 +427,13 @@ ierint(struct ie_softc *sc) status = sc->rframes[i]->ie_fd_status; if ((status & IE_FD_COMPLETE) && (status & IE_FD_OK)) { - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); if (!--timesthru) { - sc->ifp->if_ierrors += + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, sc->scb->ie_err_crc + sc->scb->ie_err_align + sc->scb->ie_err_resource + - sc->scb->ie_err_overrun; + sc->scb->ie_err_overrun); sc->scb->ie_err_crc = 0; sc->scb->ie_err_align = 0; sc->scb->ie_err_resource = 0; @@ -477,24 +477,24 @@ ietint(struct ie_softc *sc) if (status & IE_XS_LATECOLL) { if_printf(ifp, "late collision\n"); - ifp->if_collisions++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else if (status & IE_XS_NOCARRIER) { if_printf(ifp, "no carrier\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else if (status & IE_XS_LOSTCTS) { if_printf(ifp, "lost CTS\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else if (status & IE_XS_UNDERRUN) { if_printf(ifp, "DMA underrun\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else if (status & IE_XS_EXCMAX) { if_printf(ifp, "too many collisions\n"); - ifp->if_collisions += 16; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else { - ifp->if_opackets++; - ifp->if_collisions += status & IE_XS_MAXCOLL; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, status & IE_XS_MAXCOLL); } } sc->xmit_count = 0; @@ -539,7 +539,7 @@ iernr(struct ie_softc *sc) #endif ie_ack(sc, IE_ST_WHENCE); - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); return (0); } @@ -688,16 +688,12 @@ ieget(struct ie_softc *sc, struct mbuf **mp) */ if (!check_eh(sc, &eh)) { ie_drop_packet_buffer(sc); - sc->ifp->if_ierrors--; /* just this case, it's not an - * error - */ return (-1); } MGETHDR(m, M_NOWAIT, MT_DATA); if (!m) { ie_drop_packet_buffer(sc); - /* XXXX if_ierrors++; */ return (-1); } @@ -859,7 +855,7 @@ ie_readframe(struct ie_softc *sc, int num/* frame number to read */) if (rfd.ie_fd_status & IE_FD_OK) { if (ieget(sc, &m)) { - sc->ifp->if_ierrors++; /* this counts as an + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); /* this counts as an * error */ return; } @@ -953,6 +949,8 @@ iestart_locked(struct ifnet *ifp) if (!m) break; + BPF_MTAP(ifp, m); + buffer = sc->xmit_cbuffs[sc->xmit_count]; len = 0; @@ -965,13 +963,6 @@ iestart_locked(struct ifnet *ifp) m_freem(m0); len = max(len, ETHER_MIN_LEN); - /* - * See if bpf is listening on this interface, let it see the - * packet before we commit it to the wire. - */ - BPF_TAP(sc->ifp, - (void *)sc->xmit_cbuffs[sc->xmit_count], len); - sc->xmit_buffs[sc->xmit_count]->ie_xmit_flags = IE_XMIT_LAST|len; sc->xmit_buffs[sc->xmit_count]->ie_xmit_next = 0xffff; diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c index f9ed3d08fe5b..8f235274409a 100644 --- a/sys/dev/if_ndis/if_ndis.c +++ b/sys/dev/if_ndis/if_ndis.c @@ -1431,7 +1431,7 @@ ndis_rxeof(adapter, packets, pktcnt) p->np_refcnt++; m_freem(m0); if (m == NULL) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); else m0 = m; } else @@ -1444,7 +1444,7 @@ ndis_rxeof(adapter, packets, pktcnt) p->np_oob.npo_status = NDIS_STATUS_PENDING; m_freem(m0); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } m0 = m; @@ -1554,9 +1554,9 @@ ndis_txeof(adapter, packet, status) sc->ndis_txpending++; if (status == NDIS_STATUS_SUCCESS) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->ndis_tx_timer = 0; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -1659,7 +1659,7 @@ ndis_tick(xsc) } if (sc->ndis_tx_timer && --sc->ndis_tx_timer == 0) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); device_printf(sc->ndis_dev, "watchdog timeout\n"); IoQueueWorkItem(sc->ndis_resetitem, diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index 644a12ced820..7a4e2b12e3da 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -302,8 +302,8 @@ icintr(device_t dev, int event, char *ptr) if (len <= ICHDRLEN) goto err; len -= ICHDRLEN; - sc->ic_ifp->if_ipackets++; - sc->ic_ifp->if_ibytes += len; + if_inc_counter(sc->ic_ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(sc->ic_ifp, IFCOUNTER_IBYTES, len); BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN); top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0); if (top) { @@ -316,7 +316,7 @@ icintr(device_t dev, int event, char *ptr) err: if_printf(sc->ic_ifp, "errors (%d)!\n", sc->ic_iferrs); sc->ic_iferrs = 0; /* reset error count */ - sc->ic_ifp->if_ierrors++; + if_inc_counter(sc->ic_ifp, IFCOUNTER_IERRORS, 1); break; case INTR_RECEIVE: @@ -373,7 +373,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /* already sending? */ if (sc->ic_flags & IC_SENDING) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); goto error; } @@ -386,7 +386,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, do { if (len + mm->m_len > sc->ic_ifp->if_mtu) { /* packet too large */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); goto error; } @@ -407,10 +407,10 @@ icoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf, len + ICHDRLEN, &sent)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else { - ifp->if_opackets++; - ifp->if_obytes += len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); } mtx_lock(&sc->ic_lock); diff --git a/sys/pci/intpm.c b/sys/dev/intpm/intpm.c similarity index 99% rename from sys/pci/intpm.c rename to sys/dev/intpm/intpm.c index 48ff26e6adcd..60ad17f98d53 100644 --- a/sys/pci/intpm.c +++ b/sys/dev/intpm/intpm.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "opt_intpm.h" diff --git a/sys/pci/intpmreg.h b/sys/dev/intpm/intpmreg.h similarity index 100% rename from sys/pci/intpmreg.h rename to sys/dev/intpm/intpmreg.h diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c index fe693eb78998..04c33639f59b 100644 --- a/sys/dev/ipw/if_ipw.c +++ b/sys/dev/ipw/if_ipw.c @@ -1202,7 +1202,7 @@ ipw_rx_data_intr(struct ipw_softc *sc, struct ipw_status *status, */ mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (mnew == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1223,7 +1223,7 @@ ipw_rx_data_intr(struct ipw_softc *sc, struct ipw_status *status, panic("%s: could not load old rx mbuf", device_get_name(sc->sc_dev)); } - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1378,7 +1378,7 @@ ipw_tx_intr(struct ipw_softc *sc) sbd = &sc->stbd_list[i]; if (sbd->type == IPW_SBD_TYPE_DATA) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ipw_release_sbd(sc, sbd); sc->txfree++; @@ -1768,7 +1768,7 @@ ipw_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (ipw_tx_start(ifp, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } /* start watchdog timer */ @@ -1788,7 +1788,7 @@ ipw_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); taskqueue_enqueue(taskqueue_swi, &sc->sc_init_task); } } diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index c08abf948433..e11b2b64beda 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -538,7 +538,7 @@ iscsi_callout(void *context) is->is_timeout++; if (is->is_waiting_for_iscsid) { - if (is->is_timeout > iscsid_timeout) { + if (iscsid_timeout > 0 && is->is_timeout > iscsid_timeout) { ISCSI_SESSION_WARN(is, "timed out waiting for iscsid(8) " "for %d seconds; reconnecting", is->is_timeout); @@ -548,7 +548,7 @@ iscsi_callout(void *context) } if (is->is_login_phase) { - if (is->is_timeout > login_timeout) { + if (login_timeout > 0 && is->is_timeout > login_timeout) { ISCSI_SESSION_WARN(is, "login timed out after %d seconds; " "reconnecting", is->is_timeout); reconnect_needed = true; @@ -556,6 +556,16 @@ iscsi_callout(void *context) goto out; } + if (ping_timeout <= 0) { + /* + * Pings are disabled. Don't send NOP-Out in this case. + * Reset the timeout, to avoid triggering reconnection, + * should the user decide to reenable them. + */ + is->is_timeout = 0; + goto out; + } + if (is->is_timeout >= ping_timeout) { ISCSI_SESSION_WARN(is, "no ping reply (NOP-In) after %d seconds; " "reconnecting", ping_timeout); @@ -2169,7 +2179,12 @@ iscsi_action(struct cam_sim *sim, union ccb *ccb) cpi->hba_misc = PIM_EXTLUNS; cpi->hba_eng_cnt = 0; cpi->max_target = 0; - cpi->max_lun = 0; + /* + * Note that the variable below is only relevant for targets + * that don't claim compliance with anything above SPC2, which + * means they don't support REPORT_LUNS. + */ + cpi->max_lun = 255; cpi->initiator_id = ~0; strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); strlcpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); diff --git a/sys/dev/iscsi_initiator/isc_cam.c b/sys/dev/iscsi_initiator/isc_cam.c index 8f8bd6443b2e..6089694364c6 100644 --- a/sys/dev/iscsi_initiator/isc_cam.c +++ b/sys/dev/iscsi_initiator/isc_cam.c @@ -125,7 +125,7 @@ scan_callback(struct cam_periph *periph, union ccb *ccb) debug_called(8); - free(ccb, M_TEMP); + xpt_free_ccb(ccb); if(sp->flags & ISC_SCANWAIT) { sp->flags &= ~ISC_SCANWAIT; @@ -141,30 +141,15 @@ ic_scan(isc_session_t *sp) debug_called(8); sdebug(2, "scanning sid=%d", sp->sid); - if((ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO)) == NULL) { - xdebug("scan failed (can't allocate CCB)"); - return ENOMEM; // XXX - } - sp->flags &= ~ISC_CAMDEVS; sp->flags |= ISC_SCANWAIT; - CAM_LOCK(sp); - if(xpt_create_path(&sp->cam_path, NULL, cam_sim_path(sp->cam_sim), - 0, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { - xdebug("can't create cam path"); - CAM_UNLOCK(sp); - free(ccb, M_TEMP); - return ENODEV; // XXX - } - xpt_setup_ccb(&ccb->ccb_h, sp->cam_path, 5/*priority (low)*/); - ccb->ccb_h.func_code = XPT_SCAN_BUS; + ccb = xpt_alloc_ccb(); + ccb->ccb_h.path = sp->cam_path; ccb->ccb_h.cbfcnp = scan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; ccb->ccb_h.spriv_ptr0 = sp; - xpt_action(ccb); - CAM_UNLOCK(sp); + xpt_rescan(ccb); while(sp->flags & ISC_SCANWAIT) tsleep(sp, PRIBIO, "ffp", 5*hz); // the timeout time should @@ -374,6 +359,16 @@ ic_init(isc_session_t *sp) return ENXIO; } sp->cam_sim = sim; + if(xpt_create_path(&sp->cam_path, NULL, cam_sim_path(sp->cam_sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_bus_deregister(cam_sim_path(sp->cam_sim)); + cam_sim_free(sim, /*free_devq*/TRUE); + CAM_UNLOCK(sp); +#if __FreeBSD_version >= 700000 + mtx_destroy(&sp->cam_mtx); +#endif + return ENXIO; + } CAM_UNLOCK(sp); sdebug(1, "cam subsystem initialized"); diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index 06b4d7ef42b6..979426084dda 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -132,6 +132,7 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) ISP_SET_PC(isp, chan, proc_active, 0); isp_prt(isp, ISP_LOGERR, "cannot create test target thread"); } + ISP_SPI_PC(isp, chan)->num_threads += 1; #endif } else { fcparam *fcp = FCPARAM(isp, chan); @@ -167,12 +168,14 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) cam_sim_free(fc->sim, FALSE); return (ENOMEM); } + ISP_FC_PC(isp, chan)->num_threads += 1; #ifdef ISP_INTERNAL_TARGET ISP_SET_PC(isp, chan, proc_active, 1); if (THREAD_CREATE(isp_target_thread_fc, fc, &fc->target_proc, 0, 0, "%s: isp_test_tgt%d", device_get_nameunit(isp->isp_osinfo.dev), chan)) { ISP_SET_PC(isp, chan, proc_active, 0); isp_prt(isp, ISP_LOGERR, "cannot create test target thread"); } + ISP_FC_PC(isp, chan)->num_threads += 1; #endif if (chan == 0) { struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(isp->isp_osinfo.dev); @@ -189,6 +192,47 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan) return (0); } +static void +isp_detach_internal_target(ispsoftc_t *isp, int chan) +{ +#ifdef ISP_INTERNAL_TARGET + void *wchan; + + ISP_GET_PC(isp, chan, target_proc, wchan); + ISP_SET_PC(isp, chan, proc_active, 0); + wakeup(wchan); +#endif +} + +static void +isp_detach_chan(ispsoftc_t *isp, int chan) +{ + struct cam_sim *sim; + struct cam_path *path; + struct ccb_setasync csa; + int *num_threads; + + ISP_GET_PC(isp, chan, sim, sim); + ISP_GET_PC(isp, chan, path, path); + ISP_GET_PC_ADDR(isp, chan, num_threads, num_threads); + + xpt_setup_ccb(&csa.ccb_h, path, 5); + csa.ccb_h.func_code = XPT_SASYNC_CB; + csa.event_enable = 0; + csa.callback = isp_cam_async; + csa.callback_arg = sim; + xpt_action((union ccb *)&csa); + xpt_free_path(path); + xpt_bus_deregister(cam_sim_path(sim)); + cam_sim_free(sim, FALSE); + + /* Wait for the channel's spawned threads to exit. */ + wakeup(isp->isp_osinfo.pc.ptr); + isp_detach_internal_target(isp, chan); + while (*num_threads != 0) + mtx_sleep(isp, &isp->isp_osinfo.lock, PRIBIO, "isp_reap", 100); +} + int isp_attach(ispsoftc_t *isp) { @@ -239,13 +283,9 @@ isp_attach(ispsoftc_t *isp) while (--chan >= 0) { struct cam_sim *sim; struct cam_path *path; - if (IS_FC(isp)) { - sim = ISP_FC_PC(isp, chan)->sim; - path = ISP_FC_PC(isp, chan)->path; - } else { - sim = ISP_SPI_PC(isp, chan)->sim; - path = ISP_SPI_PC(isp, chan)->path; - } + + ISP_GET_PC(isp, chan, sim, sim); + ISP_GET_PC(isp, chan, path, path); xpt_free_path(path); ISP_LOCK(isp); xpt_bus_deregister(cam_sim_path(sim)); @@ -269,49 +309,26 @@ int isp_detach(ispsoftc_t *isp) { struct cam_sim *sim; - struct cam_path *path; - struct ccb_setasync csa; int chan; ISP_LOCK(isp); for (chan = isp->isp_nchan - 1; chan >= 0; chan -= 1) { - if (IS_FC(isp)) { - sim = ISP_FC_PC(isp, chan)->sim; - path = ISP_FC_PC(isp, chan)->path; - } else { - sim = ISP_SPI_PC(isp, chan)->sim; - path = ISP_SPI_PC(isp, chan)->path; - } + ISP_GET_PC(isp, chan, sim, sim); if (sim->refcount > 2) { ISP_UNLOCK(isp); return (EBUSY); } } + /* Tell spawned threads that we're exiting. */ + isp->isp_osinfo.is_exiting = 1; if (isp->isp_osinfo.timer_active) { callout_stop(&isp->isp_osinfo.tmo); isp->isp_osinfo.timer_active = 0; } - for (chan = isp->isp_nchan - 1; chan >= 0; chan -= 1) { - if (IS_FC(isp)) { - sim = ISP_FC_PC(isp, chan)->sim; - path = ISP_FC_PC(isp, chan)->path; - } else { - sim = ISP_SPI_PC(isp, chan)->sim; - path = ISP_SPI_PC(isp, chan)->path; - } - xpt_setup_ccb(&csa.ccb_h, path, 5); - csa.ccb_h.func_code = XPT_SASYNC_CB; - csa.event_enable = 0; - csa.callback = isp_cam_async; - csa.callback_arg = sim; - ISP_LOCK(isp); - xpt_action((union ccb *)&csa); - ISP_UNLOCK(isp); - xpt_free_path(path); - xpt_bus_deregister(cam_sim_path(sim)); - cam_sim_free(sim, FALSE); - } + for (chan = isp->isp_nchan - 1; chan >= 0; chan -= 1) + isp_detach_chan(isp, chan); ISP_UNLOCK(isp); + if (isp->isp_osinfo.cdev) { destroy_dev(isp->isp_osinfo.cdev); isp->isp_osinfo.cdev = NULL; @@ -4225,7 +4242,7 @@ isp_target_thread(ispsoftc_t *isp, int chan) /* * Add resources */ - ISP_GET_PC_ADDR(isp, chan, target_proc, wchan); + ISP_GET_PC(isp, chan, target_proc, wchan); for (i = 0; i < 4; i++) { ccb = malloc(sizeof (*ccb), M_ISPTARG, M_WAITOK | M_ZERO); xpt_setup_ccb(&ccb->ccb_h, wperiph->path, 1); @@ -4313,14 +4330,24 @@ static void isp_target_thread_pi(void *arg) { struct isp_spi *pi = arg; - isp_target_thread(cam_sim_softc(pi->sim), cam_sim_bus(pi->sim)); + ispsoftc_t *isp = cam_sim_softc(pi->sim); + int chan = cam_sim_bus(pi->sim); + + isp_target_thread(isp, chan); + ISP_SPI_PC(isp, chan)->num_threads -= 1; + kthread_exit(); } static void isp_target_thread_fc(void *arg) { struct isp_fc *fc = arg; - isp_target_thread(cam_sim_softc(fc->sim), cam_sim_bus(fc->sim)); + ispsoftc_t *isp = cam_sim_softc(pi->sim); + int chan = cam_sim_bus(pi->sim); + + isp_target_thread(isp, chan); + ISP_FC_PC(isp, chan)->num_threads -= 1; + kthread_exit(); } static int @@ -4748,7 +4775,7 @@ isp_kthread(void *arg) mtx_lock(&isp->isp_osinfo.lock); - for (;;) { + while (isp->isp_osinfo.is_exiting == 0) { int lb, lim; isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "%s: Chan %d checking FC state", __func__, chan); @@ -4844,7 +4871,9 @@ isp_kthread(void *arg) mtx_lock(&isp->isp_osinfo.lock); } } + fc->num_threads -= 1; mtx_unlock(&isp->isp_osinfo.lock); + kthread_exit(); } static void diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 70061ef7b5b4..81dcd8d09193 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -268,6 +268,7 @@ struct isp_fc { unsigned int inject_lost_data_frame; #endif #endif + int num_threads; }; struct isp_spi { @@ -291,6 +292,7 @@ struct isp_spi { struct proc * target_proc; #endif #endif + int num_threads; }; struct isposinfo { @@ -365,6 +367,8 @@ struct isposinfo { struct isp_spi *spi; void *ptr; } pc; + + int is_exiting; }; #define ISP_FC_PC(isp, chan) (&(isp)->isp_osinfo.pc.fc[(chan)]) #define ISP_SPI_PC(isp, chan) (&(isp)->isp_osinfo.pc.spi[(chan)]) diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c index 412d7099a548..b6de4b69e7af 100644 --- a/sys/dev/iwi/if_iwi.c +++ b/sys/dev/iwi/if_iwi.c @@ -1235,7 +1235,7 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, int i, */ mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (mnew == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1256,7 +1256,7 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, int i, panic("%s: could not load old rx mbuf", device_get_name(sc->sc_dev)); } - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1651,7 +1651,7 @@ iwi_tx_intr(struct iwi_softc *sc, struct iwi_tx_ring *txq) DPRINTFN(15, ("tx done idx=%u\n", txq->next)); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); txq->queued--; txq->next = (txq->next + 1) % IWI_TX_RING_COUNT; @@ -1852,7 +1852,7 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni, /* h/w table is full */ m_freem(m0); ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return 0; } iwi_write_ibssnode(sc, @@ -2007,7 +2007,7 @@ iwi_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (iwi_tx_start(ifp, m, ni, ac) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } @@ -2038,7 +2038,7 @@ iwi_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_runtask(ic, &sc->sc_restarttask); } } diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 34a432109749..bf8c98d96f85 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -2966,14 +2966,14 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, if ((flags & IWN_RX_NOERROR) != IWN_RX_NOERROR) { DPRINTF(sc, IWN_DEBUG_RECV, "%s: RX flags error %x\n", __func__, flags); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } /* Discard frames that are too short. */ if (len < sizeof (*wh)) { DPRINTF(sc, IWN_DEBUG_RECV, "%s: frame too short: %d\n", __func__, len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -2981,7 +2981,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, if (m1 == NULL) { DPRINTF(sc, IWN_DEBUG_ANY, "%s: no mbuf to restock ring\n", __func__); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } bus_dmamap_unload(ring->data_dmat, data->map); @@ -3004,7 +3004,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, ring->desc[ring->cur] = htole32(paddr >> 8); bus_dmamap_sync(ring->data_dmat, ring->desc_dma.map, BUS_DMASYNC_PREWRITE); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -3125,6 +3125,7 @@ iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc, KASSERT(ni != NULL, ("no node")); KASSERT(m != NULL, ("no mbuf")); + DPRINTF(sc, IWN_DEBUG_XMIT, "%s: freeing m=%p\n", __func__, m); ieee80211_tx_complete(ni, m, 1); txq->queued--; @@ -3151,20 +3152,22 @@ iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc, return; /* - * XXX does this correctly process an almost empty bitmap? - * (since it bails out when it sees an empty bitmap, but there - * may be failed bits there..) + * Walk the bitmap and calculate how many successful and failed + * attempts are made. + * + * Yes, the rate control code doesn't know these are A-MPDU + * subframes and that it's okay to fail some of these. */ ni = tap->txa_ni; bitmap = (le64toh(ba->bitmap) >> shift) & wn->agg[tid].bitmap; for (i = 0; bitmap; i++) { if ((bitmap & 1) == 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); tx_err ++; ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); tx_ok ++; ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); @@ -3172,7 +3175,8 @@ iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc, bitmap >>= 1; } - DPRINTF(sc, IWN_DEBUG_TRACE | IWN_DEBUG_XMIT, "->%s: end; %d ok; %d err\n",__func__, tx_ok, tx_err); + DPRINTF(sc, IWN_DEBUG_TRACE | IWN_DEBUG_XMIT, + "->%s: end; %d ok; %d err\n",__func__, tx_ok, tx_err); } @@ -3423,9 +3427,12 @@ iwn4965_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, ring = &sc->txq[qid]; DPRINTF(sc, IWN_DEBUG_XMIT, "%s: " - "qid %d idx %d retries %d nkill %d rate %x duration %d status %x\n", - __func__, desc->qid, desc->idx, stat->ackfailcnt, - stat->btkillcnt, stat->rate, le16toh(stat->duration), + "qid %d idx %d RTS retries %d ACK retries %d nkill %d rate %x duration %d status %x\n", + __func__, desc->qid, desc->idx, + stat->rtsfailcnt, + stat->ackfailcnt, + stat->btkillcnt, + stat->rate, le16toh(stat->duration), le32toh(stat->status)); bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD); @@ -3450,9 +3457,12 @@ iwn5000_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, ring = &sc->txq[qid]; DPRINTF(sc, IWN_DEBUG_XMIT, "%s: " - "qid %d idx %d retries %d nkill %d rate %x duration %d status %x\n", - __func__, desc->qid, desc->idx, stat->ackfailcnt, - stat->btkillcnt, stat->rate, le16toh(stat->duration), + "qid %d idx %d RTS retries %d ACK retries %d nkill %d rate %x duration %d status %x\n", + __func__, desc->qid, desc->idx, + stat->rtsfailcnt, + stat->ackfailcnt, + stat->btkillcnt, + stat->rate, le16toh(stat->duration), le32toh(stat->status)); #ifdef notyet @@ -3499,11 +3509,11 @@ iwn_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, int ackfailcnt, * Update rate control statistics for the node. */ if (status & IWN_TX_FAIL) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); } @@ -3595,6 +3605,8 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes, uint8_t tid; int bit, i, lastidx, *res, seqno, shift, start; + /* XXX TODO: status is le16 field! Grr */ + DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); DPRINTF(sc, IWN_DEBUG_XMIT, "%s: nframes=%d, status=0x%08x\n", __func__, @@ -3606,6 +3618,18 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes, wn = (void *)tap->txa_ni; ni = tap->txa_ni; + /* + * XXX TODO: ACK and RTS failures would be nice here! + */ + + /* + * A-MPDU single frame status - if we failed to transmit it + * in A-MPDU, then it may be a permanent failure. + * + * XXX TODO: check what the Linux iwlwifi driver does here; + * there's some permanent and temporary failures that may be + * handled differently. + */ if (nframes == 1) { if ((*status & 0xff) != 1 && (*status & 0xff) != 2) { #ifdef NOT_YET @@ -3616,24 +3640,26 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes, * notification is pushed up to the rate control * layer. */ - ieee80211_ratectl_tx_complete(ni->ni_vap, ni, - IEEE80211_RATECTL_TX_FAILURE, &nframes, NULL); + ieee80211_ratectl_tx_complete(ni->ni_vap, + ni, + IEEE80211_RATECTL_TX_FAILURE, + &ackfailcnt, + NULL); + } else { + /* + * If nframes=1, then we won't be getting a BA for + * this frame. Ensure that we correctly update the + * rate control code with how many retries were + * needed to send it. + */ + ieee80211_ratectl_tx_complete(ni->ni_vap, + ni, + IEEE80211_RATECTL_TX_SUCCESS, + &ackfailcnt, + NULL); } } - /* - * We succeeded with some frames, so let's update how many - * retries were needed for this frame. - * - * XXX we can't yet pass tx_complete tx_cnt and success_cnt, - * le sigh. - */ - ieee80211_ratectl_tx_complete(ni->ni_vap, - ni, - IEEE80211_RATECTL_TX_SUCCESS, - &ackfailcnt, - NULL); - bitmap = 0; start = idx; for (i = 0; i < nframes; i++) { @@ -3671,6 +3697,7 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes, ssn = tap->txa_start & 0xfff; } + /* This is going nframes DWORDS into the descriptor? */ seqno = le32toh(*(status + nframes)) & 0xfff; for (lastidx = (seqno & 0xff); ring->read != lastidx;) { data = &ring->data[ring->read]; @@ -3684,7 +3711,7 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes, KASSERT(ni != NULL, ("no node")); KASSERT(m != NULL, ("no mbuf")); - + DPRINTF(sc, IWN_DEBUG_XMIT, "%s: freeing m=%p\n", __func__, m); ieee80211_tx_complete(ni, m, 1); ring->queued--; @@ -4179,11 +4206,11 @@ iwn_check_rate_needs_protection(struct iwn_softc *sc, return (0); /* - * If it's an 11n rate, then for now we enable - * protection. + * If it's an 11n rate - no protection. + * We'll do it via a specific 11n check. */ if (rate & IEEE80211_RATE_MCS) { - return (1); + return (0); } /* @@ -4413,6 +4440,9 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) flags |= IWN_TX_NEED_CTS; else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) flags |= IWN_TX_NEED_RTS; + } else if ((rate & IEEE80211_RATE_MCS) && + (ic->ic_htprotmode == IEEE80211_PROT_RTSCTS)) { + flags |= IWN_TX_NEED_RTS; } /* XXX HT protection? */ @@ -4795,7 +4825,7 @@ iwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, if (error != 0) { /* NB: m is reclaimed on tx failure */ ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } sc->sc_tx_timer = 5; @@ -4842,7 +4872,7 @@ iwn_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; if (iwn_tx_data(sc, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } sc->sc_tx_timer = 5; diff --git a/sys/dev/iwn/if_iwnreg.h b/sys/dev/iwn/if_iwnreg.h index 496e837e0f0e..ed65c0bf0c7a 100644 --- a/sys/dev/iwn/if_iwnreg.h +++ b/sys/dev/iwn/if_iwnreg.h @@ -1267,18 +1267,91 @@ struct iwn_ucode_info { } __packed; /* Structures for IWN_TX_DONE notification. */ -#define IWN_TX_STATUS_MSK 0xff -#define TX_STATUS_SUCCESS 0x01 -#define TX_STATUS_DIRECT_DONE 0x02 -#define IWN_TX_SUCCESS 0x00 -#define IWN_TX_FAIL 0x80 /* all failures have 0x80 set */ -#define IWN_TX_FAIL_SHORT_LIMIT 0x82 /* too many RTS retries */ -#define IWN_TX_FAIL_LONG_LIMIT 0x83 /* too many retries */ -#define IWN_TX_FAIL_FIFO_UNDERRRUN 0x84 /* tx fifo not kept running */ -#define IWN_TX_FAIL_DEST_IN_PS 0x88 /* sta found in power save */ -#define IWN_TX_FAIL_TX_LOCKED 0x90 /* waiting to see traffic */ -#define IWN_TX_FAIL_STA_INVALID 0x8b /* XXX STA invalid (???) */ +/* + * TX command response is sent after *agn* transmission attempts. + * + * both postpone and abort status are expected behavior from uCode. there is + * no special operation required from driver; except for RFKILL_FLUSH, + * which required tx flush host command to flush all the tx frames in queues + */ +#define IWN_TX_STATUS_MSK 0x000000ff +#define IWN_TX_STATUS_DELAY_MSK 0x00000040 +#define IWN_TX_STATUS_ABORT_MSK 0x00000080 +#define IWN_TX_PACKET_MODE_MSK 0x0000ff00 +#define IWN_TX_FIFO_NUMBER_MSK 0x00070000 +#define IWN_TX_RESERVED 0x00780000 +#define IWN_TX_POWER_PA_DETECT_MSK 0x7f800000 +#define IWN_TX_ABORT_REQUIRED_MSK 0x80000000 + +/* Success status */ +#define IWN_TX_STATUS_SUCCESS 0x01 +#define IWN_TX_STATUS_DIRECT_DONE 0x02 + +/* postpone TX */ +#define IWN_TX_STATUS_POSTPONE_DELAY 0x40 +#define IWN_TX_STATUS_POSTPONE_FEW_BYTES 0x41 +#define IWN_TX_STATUS_POSTPONE_BT_PRIO 0x42 +#define IWN_TX_STATUS_POSTPONE_QUIET_PERIOD 0x43 +#define IWN_TX_STATUS_POSTPONE_CALC_TTAK 0x44 + +/* Failures */ +#define IWN_TX_FAIL 0x80 /* all failures have 0x80 set */ +#define IWN_TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY 0x81 +#define IWN_TX_FAIL_SHORT_LIMIT 0x82 /* too many RTS retries */ +#define IWN_TX_FAIL_LONG_LIMIT 0x83 /* too many retries */ +#define IWN_TX_FAIL_FIFO_UNDERRRUN 0x84 /* tx fifo not kept running */ +#define IWN_TX_STATUS_FAIL_DRAIN_FLOW 0x85 +#define IWN_TX_STATUS_FAIL_RFKILL_FLUSH 0x86 +#define IWN_TX_STATUS_FAIL_LIFE_EXPIRE 0x87 +#define IWN_TX_FAIL_DEST_IN_PS 0x88 /* sta found in power save */ +#define IWN_TX_STATUS_FAIL_HOST_ABORTED 0x89 +#define IWN_TX_STATUS_FAIL_BT_RETRY 0x8a +#define IWN_TX_FAIL_STA_INVALID 0x8b /* XXX STA invalid (???) */ +#define IWN_TX_STATUS_FAIL_FRAG_DROPPED 0x8c +#define IWN_TX_STATUS_FAIL_TID_DISABLE 0x8d +#define IWN_TX_STATUS_FAIL_FIFO_FLUSHED 0x8e +#define IWN_TX_STATUS_FAIL_INSUFFICIENT_CF_POLL 0x8f +#define IWN_TX_FAIL_TX_LOCKED 0x90 /* waiting to see traffic */ +#define IWN_TX_STATUS_FAIL_NO_BEACON_ON_RADAR 0x91 + +/* + * TX command response for A-MPDU packet responses. + * + * The status response is different to the non A-MPDU responses. + * In addition, the sequence number is treated as the sequence + * number of the TX command, NOT the 802.11 sequence number! + */ +#define IWN_AGG_TX_STATE_TRANSMITTED 0x00 +#define IWN_AGG_TX_STATE_UNDERRUN_MSK 0x01 +#define IWN_AGG_TX_STATE_FEW_BYTES_MSK 0x04 +#define IWN_AGG_TX_STATE_ABORT_MSK 0x08 + +#define IWN_AGG_TX_STATE_LAST_SENT_TTL_MSK 0x10 +#define IWN_AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK 0x20 + +#define IWN_AGG_TX_STATE_SCD_QUERY_MSK 0x80 + +#define IWN_AGG_TX_STATE_TEST_BAD_CRC32_MSK 0x100 + +#define IWN_AGG_TX_STATE_RESPONSE_MSK 0x1ff +#define IWN_AGG_TX_STATE_DUMP_TX_MSK 0x200 +#define IWN_AGG_TX_STATE_DELAY_TX_MSK 0x400 + +#define IWN_AGG_TX_STATUS_MSK 0x00000fff +#define IWN_AGG_TX_TRY_MSK 0x0000f000 + +#define IWN_AGG_TX_STATE_LAST_SENT_MSK \ + (IWN_AGG_TX_STATE_LAST_SENT_TTL_MSK | \ + IWN_AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK) + +/* # tx attempts for first frame in aggregation */ +#define IWN_AGG_TX_STATE_TRY_CNT_POS 12 +#define IWN_AGG_TX_STATE_TRY_CNT_MSK 0xf000 + +/* Command ID and sequence number of Tx command for this frame */ +#define IWN_AGG_TX_STATE_SEQ_NUM_POS 16 +#define IWN_AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 struct iwn4965_tx_stat { uint8_t nframes; @@ -1405,6 +1478,12 @@ struct iwn_compressed_ba { uint64_t bitmap; uint16_t qid; uint16_t ssn; + /* extra fields starting with iwn5000 */ +#if 0 + uint8_t txed; /* number of frames sent */ + uint8_t txed_2_done; /* number of frames acked */ + uint16_t reserved1; +#endif } __packed; /* Structure for IWN_START_SCAN notification. */ diff --git a/sys/dev/ixgb/if_ixgb.c b/sys/dev/ixgb/if_ixgb.c index 9b4555dfb21d..6f25c0ae44d2 100644 --- a/sys/dev/ixgb/if_ixgb.c +++ b/sys/dev/ixgb/if_ixgb.c @@ -97,6 +97,7 @@ static void ixgb_intr(void *); static void ixgb_start(struct ifnet *); static void ixgb_start_locked(struct ifnet *); static int ixgb_ioctl(struct ifnet *, IOCTL_CMD_TYPE, caddr_t); +static uint64_t ixgb_get_counter(struct ifnet *, ift_counter); static void ixgb_watchdog(struct adapter *); static void ixgb_init(void *); static void ixgb_init_locked(struct adapter *); @@ -643,7 +644,7 @@ ixgb_watchdog(struct adapter *adapter) ixgb_init_locked(adapter); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } @@ -1355,6 +1356,7 @@ ixgb_setup_interface(device_t dev, struct adapter * adapter) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixgb_ioctl; ifp->if_start = ixgb_start; + ifp->if_get_counter = ixgb_get_counter; ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1; #if __FreeBSD_version < 500000 @@ -2326,7 +2328,6 @@ ixgb_write_pci_cfg(struct ixgb_hw * hw, static void ixgb_update_stats_counters(struct adapter * adapter) { - struct ifnet *ifp; adapter->stats.crcerrs += IXGB_READ_REG(&adapter->hw, CRCERRS); adapter->stats.gprcl += IXGB_READ_REG(&adapter->hw, GPRCL); @@ -2389,28 +2390,36 @@ ixgb_update_stats_counters(struct adapter * adapter) adapter->stats.pfrc += IXGB_READ_REG(&adapter->hw, PFRC); adapter->stats.pftc += IXGB_READ_REG(&adapter->hw, PFTC); adapter->stats.mcfrc += IXGB_READ_REG(&adapter->hw, MCFRC); - - ifp = adapter->ifp; - - /* Fill out the OS statistics structure */ - ifp->if_ipackets = adapter->stats.gprcl; - ifp->if_opackets = adapter->stats.gptcl; - ifp->if_ibytes = adapter->stats.gorcl; - ifp->if_obytes = adapter->stats.gotcl; - ifp->if_imcasts = adapter->stats.mprcl; - ifp->if_collisions = 0; - - /* Rx Errors */ - ifp->if_ierrors = - adapter->dropped_pkts + - adapter->stats.crcerrs + - adapter->stats.rnbc + - adapter->stats.mpc + - adapter->stats.rlec; - - } +static uint64_t +ixgb_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct adapter *adapter; + + adapter = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (adapter->stats.gprcl); + case IFCOUNTER_OPACKETS: + return ( adapter->stats.gptcl); + case IFCOUNTER_IBYTES: + return (adapter->stats.gorcl); + case IFCOUNTER_OBYTES: + return (adapter->stats.gotcl); + case IFCOUNTER_IMCASTS: + return ( adapter->stats.mprcl); + case IFCOUNTER_COLLISIONS: + return (0); + case IFCOUNTER_IERRORS: + return (adapter->dropped_pkts + adapter->stats.crcerrs + + adapter->stats.rnbc + adapter->stats.mpc + + adapter->stats.rlec); + default: + return (if_get_counter_default(ifp, cnt)); + } +} /********************************************************************** * diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 359279d17e79..d7371a861c33 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -120,6 +120,7 @@ static int ixgbe_ioctl(struct ifnet *, u_long, caddr_t); static void ixgbe_init(void *); static void ixgbe_init_locked(struct adapter *); static void ixgbe_stop(void *); +static uint64_t ixgbe_get_counter(struct ifnet *, ift_counter); static void ixgbe_media_status(struct ifnet *, struct ifmediareq *); static int ixgbe_media_change(struct ifnet *); static void ixgbe_identify_hardware(struct adapter *); @@ -514,7 +515,7 @@ ixgbe_attach(device_t dev) } if (((ixgbe_rxd * sizeof(union ixgbe_adv_rx_desc)) % DBA_ALIGN) != 0 || - ixgbe_rxd < MIN_TXD || ixgbe_rxd > MAX_TXD) { + ixgbe_rxd < MIN_RXD || ixgbe_rxd > MAX_RXD) { device_printf(dev, "RXD config issue, using default!\n"); adapter->num_rx_desc = DEFAULT_RXD; } else @@ -2721,6 +2722,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter) ifp->if_softc = adapter; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixgbe_ioctl; + ifp->if_get_counter = ixgbe_get_counter; #ifndef IXGBE_LEGACY_TX ifp->if_transmit = ixgbe_mq_start; ifp->if_qflush = ixgbe_qflush; @@ -4142,7 +4144,6 @@ ixgbe_setup_receive_ring(struct rx_ring *rxr) rxr->lro_enabled = FALSE; rxr->rx_copies = 0; rxr->rx_bytes = 0; - rxr->discard = FALSE; rxr->vtag_strip = FALSE; bus_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map, @@ -4523,11 +4524,6 @@ ixgbe_rx_discard(struct rx_ring *rxr, int i) rbuf = &rxr->rx_buffers[i]; - if (rbuf->fmp != NULL) {/* Partial chain ? */ - rbuf->fmp->m_flags |= M_PKTHDR; - m_freem(rbuf->fmp); - rbuf->fmp = NULL; - } /* ** With advanced descriptors the writeback @@ -4536,7 +4532,13 @@ ixgbe_rx_discard(struct rx_ring *rxr, int i) ** the normal refresh path to get new buffers ** and mapping. */ - if (rbuf->buf) { + + if (rbuf->fmp != NULL) {/* Partial chain ? */ + rbuf->fmp->m_flags |= M_PKTHDR; + m_freem(rbuf->fmp); + rbuf->fmp = NULL; + rbuf->buf = NULL; /* rbuf->buf is part of fmp's chain */ + } else if (rbuf->buf) { m_free(rbuf->buf); rbuf->buf = NULL; } @@ -4617,13 +4619,8 @@ ixgbe_rxeof(struct ix_queue *que) eop = ((staterr & IXGBE_RXD_STAT_EOP) != 0); /* Make sure bad packets are discarded */ - if (((staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) != 0) || - (rxr->discard)) { + if (eop && (staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) != 0) { rxr->rx_discarded++; - if (eop) - rxr->discard = FALSE; - else - rxr->discard = TRUE; ixgbe_rx_discard(rxr, i); goto next_desc; } @@ -5369,10 +5366,8 @@ ixgbe_reinit_fdir(void *context, int pending) static void ixgbe_update_stats_counters(struct adapter *adapter) { - struct ifnet *ifp = adapter->ifp; struct ixgbe_hw *hw = &adapter->hw; u32 missed_rx = 0, bprc, lxon, lxoff, total; - u64 total_missed_rx = 0; adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); adapter->stats.illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC); @@ -5391,8 +5386,6 @@ ixgbe_update_stats_counters(struct adapter *adapter) missed_rx += mp; /* global total per queue */ adapter->stats.mpc[i] += mp; - /* Running comprehensive total for stats display */ - total_missed_rx += adapter->stats.mpc[i]; if (hw->mac.type == ixgbe_mac_82598EB) { adapter->stats.rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); @@ -5502,19 +5495,41 @@ ixgbe_update_stats_counters(struct adapter *adapter) adapter->stats.fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC); adapter->stats.fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); } +} - /* Fill out the OS statistics structure */ - ifp->if_ipackets = adapter->stats.gprc; - ifp->if_opackets = adapter->stats.gptc; - ifp->if_ibytes = adapter->stats.gorc; - ifp->if_obytes = adapter->stats.gotc; - ifp->if_imcasts = adapter->stats.mprc; - ifp->if_omcasts = adapter->stats.mptc; - ifp->if_collisions = 0; +static uint64_t +ixgbe_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct adapter *adapter; + uint64_t rv; - /* Rx Errors */ - ifp->if_iqdrops = total_missed_rx; - ifp->if_ierrors = adapter->stats.crcerrs + adapter->stats.rlec; + adapter = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (adapter->stats.gprc); + case IFCOUNTER_OPACKETS: + return (adapter->stats.gptc); + case IFCOUNTER_IBYTES: + return (adapter->stats.gorc); + case IFCOUNTER_OBYTES: + return (adapter->stats.gotc); + case IFCOUNTER_IMCASTS: + return (adapter->stats.mprc); + case IFCOUNTER_OMCASTS: + return (adapter->stats.mptc); + case IFCOUNTER_COLLISIONS: + return (0); + case IFCOUNTER_IQDROPS: + rv = 0; + for (int i = 0; i < 8; i++) + rv += adapter->stats.mpc[i]; + return (rv); + case IFCOUNTER_IERRORS: + return (adapter->stats.crcerrs + adapter->stats.rlec); + default: + return (if_get_counter_default(ifp, cnt)); + } } /** ixgbe_sysctl_tdh_handler - Handler function diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h index 70f1f873fff6..f7e9efa7b398 100644 --- a/sys/dev/ixgbe/ixgbe.h +++ b/sys/dev/ixgbe/ixgbe.h @@ -331,7 +331,6 @@ struct rx_ring { struct lro_ctrl lro; bool lro_enabled; bool hw_rsc; - bool discard; bool vtag_strip; u16 next_to_refresh; u16 next_to_check; diff --git a/sys/dev/ixgbe/ixv.c b/sys/dev/ixgbe/ixv.c index eee1c383ac53..296138ed2469 100644 --- a/sys/dev/ixgbe/ixv.c +++ b/sys/dev/ixgbe/ixv.c @@ -347,7 +347,7 @@ ixv_attach(device_t dev) adapter->num_tx_desc = ixv_txd; if (((ixv_rxd * sizeof(union ixgbe_adv_rx_desc)) % DBA_ALIGN) != 0 || - ixv_rxd < MIN_TXD || ixv_rxd > MAX_TXD) { + ixv_rxd < MIN_RXD || ixv_rxd > MAX_RXD) { device_printf(dev, "RXD config issue, using default!\n"); adapter->num_rx_desc = DEFAULT_RXD; } else @@ -634,9 +634,9 @@ ixv_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr, struct mbuf *m) } drbr_advance(ifp, txr->br); enqueued++; - ifp->if_obytes += next->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len); if (next->m_flags & M_MCAST) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); /* Send a copy of the frame to the BPF listener */ ETHER_BPF_MTAP(ifp, next); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) @@ -2651,7 +2651,7 @@ ixv_txeof(struct tx_ring *txr) tx_desc = (struct ixgbe_legacy_tx_desc *)&txr->tx_base[first]; } - ++ifp->if_opackets; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* See if there is more work now */ last = tx_buffer->eop_index; if (last != -1) { @@ -3341,7 +3341,7 @@ ixv_rxeof(struct ix_queue *que, int count) /* Make sure all parts of a bad packet are discarded */ if (((staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) != 0) || (rxr->discard)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); rxr->rx_discarded++; if (!eop) rxr->discard = TRUE; @@ -3455,7 +3455,7 @@ ixv_rxeof(struct ix_queue *que, int count) /* Sending this frame? */ if (eop) { sendmp->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); rxr->rx_packets++; /* capture data for AIM */ rxr->bytes += sendmp->m_pkthdr.len; diff --git a/sys/dev/ixl/i40e_alloc.h b/sys/dev/ixl/i40e_alloc.h index 94673572bfb9..dc6fadd188f3 100755 --- a/sys/dev/ixl/i40e_alloc.h +++ b/sys/dev/ixl/i40e_alloc.h @@ -51,15 +51,16 @@ enum i40e_memory_type { }; /* prototype for functions used for dynamic memory allocation */ -enum i40e_status_code i40e_allocate_dma(struct i40e_hw *hw, +enum i40e_status_code i40e_allocate_dma_mem(struct i40e_hw *hw, struct i40e_dma_mem *mem, - bus_size_t size, u32 alignment); -enum i40e_status_code i40e_free_dma(struct i40e_hw *hw, + enum i40e_memory_type type, + u64 size, u32 alignment); +enum i40e_status_code i40e_free_dma_mem(struct i40e_hw *hw, struct i40e_dma_mem *mem); -enum i40e_status_code i40e_allocate_virt(struct i40e_hw *hw, +enum i40e_status_code i40e_allocate_virt_mem(struct i40e_hw *hw, struct i40e_virt_mem *mem, u32 size); -enum i40e_status_code i40e_free_virt(struct i40e_hw *hw, +enum i40e_status_code i40e_free_virt_mem(struct i40e_hw *hw, struct i40e_virt_mem *mem); #endif /* _I40E_ALLOC_H_ */ diff --git a/sys/dev/ixl/i40e_common.c b/sys/dev/ixl/i40e_common.c index 143eeb757d9e..ad1f9457c98e 100755 --- a/sys/dev/ixl/i40e_common.c +++ b/sys/dev/ixl/i40e_common.c @@ -4375,8 +4375,8 @@ enum i40e_status_code i40e_aq_alternate_write_indirect(struct i40e_hw *hw, cmd_resp->address = CPU_TO_LE32(addr); cmd_resp->length = CPU_TO_LE32(dw_count); - cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_WORD((u64)(uintptr_t)buffer)); - cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)(uintptr_t)buffer)); + cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_WORD((u64)buffer)); + cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)buffer)); status = i40e_asq_send_command(hw, &desc, buffer, I40E_LO_DWORD(4*dw_count), NULL); @@ -4458,8 +4458,8 @@ enum i40e_status_code i40e_aq_alternate_read_indirect(struct i40e_hw *hw, cmd_resp->address = CPU_TO_LE32(addr); cmd_resp->length = CPU_TO_LE32(dw_count); - cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_DWORD((u64)(uintptr_t)buffer)); - cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)(uintptr_t)buffer)); + cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_DWORD((u64)buffer)); + cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)buffer)); status = i40e_asq_send_command(hw, &desc, buffer, I40E_LO_DWORD(4*dw_count), NULL); diff --git a/sys/dev/ixl/i40e_osdep.c b/sys/dev/ixl/i40e_osdep.c index 30e2e57fcef3..214dbfc925dc 100755 --- a/sys/dev/ixl/i40e_osdep.c +++ b/sys/dev/ixl/i40e_osdep.c @@ -49,22 +49,22 @@ i40e_dmamap_cb(void *arg, bus_dma_segment_t * segs, int nseg, int error) } i40e_status -i40e_allocate_virt(struct i40e_hw *hw, struct i40e_virt_mem *m, u32 size) +i40e_allocate_virt_mem(struct i40e_hw *hw, struct i40e_virt_mem *mem, u32 size) { - m->va = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO); - return(m->va == NULL); + mem->va = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO); + return(mem->va == NULL); } i40e_status -i40e_free_virt(struct i40e_hw *hw, struct i40e_virt_mem *m) +i40e_free_virt_mem(struct i40e_hw *hw, struct i40e_virt_mem *mem) { - free(m->va, M_DEVBUF); + free(mem->va, M_DEVBUF); return(0); } i40e_status -i40e_allocate_dma(struct i40e_hw *hw, struct i40e_dma_mem *dma, - bus_size_t size, u32 alignment) +i40e_allocate_dma_mem(struct i40e_hw *hw, struct i40e_dma_mem *mem, + enum i40e_memory_type type __unused, u64 size, u32 alignment) { device_t dev = ((struct i40e_osdep *)hw->back)->dev; int err; @@ -81,25 +81,25 @@ i40e_allocate_dma(struct i40e_hw *hw, struct i40e_dma_mem *dma, BUS_DMA_ALLOCNOW, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ - &dma->tag); + &mem->tag); if (err != 0) { device_printf(dev, "i40e_allocate_dma: bus_dma_tag_create failed, " "error %u\n", err); goto fail_0; } - err = bus_dmamem_alloc(dma->tag, (void **)&dma->va, - BUS_DMA_NOWAIT | BUS_DMA_ZERO, &dma->map); + err = bus_dmamem_alloc(mem->tag, (void **)&mem->va, + BUS_DMA_NOWAIT | BUS_DMA_ZERO, &mem->map); if (err != 0) { device_printf(dev, "i40e_allocate_dma: bus_dmamem_alloc failed, " "error %u\n", err); goto fail_1; } - err = bus_dmamap_load(dma->tag, dma->map, dma->va, + err = bus_dmamap_load(mem->tag, mem->map, mem->va, size, i40e_dmamap_cb, - &dma->pa, + &mem->pa, BUS_DMA_NOWAIT); if (err != 0) { device_printf(dev, @@ -107,28 +107,28 @@ i40e_allocate_dma(struct i40e_hw *hw, struct i40e_dma_mem *dma, "error %u\n", err); goto fail_2; } - dma->size = size; - bus_dmamap_sync(dma->tag, dma->map, + mem->size = size; + bus_dmamap_sync(mem->tag, mem->map, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); return (0); fail_2: - bus_dmamem_free(dma->tag, dma->va, dma->map); + bus_dmamem_free(mem->tag, mem->va, mem->map); fail_1: - bus_dma_tag_destroy(dma->tag); + bus_dma_tag_destroy(mem->tag); fail_0: - dma->map = NULL; - dma->tag = NULL; + mem->map = NULL; + mem->tag = NULL; return (err); } i40e_status -i40e_free_dma(struct i40e_hw *hw, struct i40e_dma_mem *dma) +i40e_free_dma_mem(struct i40e_hw *hw, struct i40e_dma_mem *mem) { - bus_dmamap_sync(dma->tag, dma->map, + bus_dmamap_sync(mem->tag, mem->map, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(dma->tag, dma->map); - bus_dmamem_free(dma->tag, dma->va, dma->map); - bus_dma_tag_destroy(dma->tag); + bus_dmamap_unload(mem->tag, mem->map); + bus_dmamem_free(mem->tag, mem->va, mem->map); + bus_dma_tag_destroy(mem->tag); return (0); } diff --git a/sys/dev/ixl/i40e_osdep.h b/sys/dev/ixl/i40e_osdep.h index 3bae1672d8ee..895bf83cd686 100755 --- a/sys/dev/ixl/i40e_osdep.h +++ b/sys/dev/ixl/i40e_osdep.h @@ -152,6 +152,7 @@ struct i40e_osdep bus_space_tag_t mem_bus_space_tag; bus_space_handle_t mem_bus_space_handle; bus_size_t mem_bus_space_size; + uint32_t flush_reg; struct device *dev; }; @@ -170,9 +171,6 @@ struct i40e_hw; /* forward decl */ u16 i40e_read_pci_cfg(struct i40e_hw *, u32); void i40e_write_pci_cfg(struct i40e_hw *, u32, u16); -#define i40e_allocate_dma_mem(h, m, unused, s, a) i40e_allocate_dma(h, m, s, a) -#define i40e_free_dma_mem(h, m) i40e_free_dma(h, m) - #define i40e_debug(h, m, s, ...) i40e_debug_d(h, m, s, ##__VA_ARGS__) extern void i40e_debug_d(void *hw, u32 mask, char *fmt_str, ...); @@ -180,8 +178,6 @@ struct i40e_virt_mem { void *va; u32 size; }; -#define i40e_allocate_virt_mem(h, m, s) i40e_allocate_virt(h, m, s) -#define i40e_free_virt_mem(h, m) i40e_free_virt(h, m) /* ** This hardware supports either 16 or 32 byte rx descriptors @@ -213,6 +209,13 @@ wr32_osdep(struct i40e_osdep *osdep, uint32_t reg, uint32_t value) osdep->mem_bus_space_handle, reg, value); } +static __inline void +ixl_flush_osdep(struct i40e_osdep *osdep) +{ + + rd32_osdep(osdep, osdep->flush_reg); +} + #define rd32(a, reg) rd32_osdep((a)->back, (reg)) #define wr32(a, reg, value) wr32_osdep((a)->back, (reg), (value)) @@ -226,9 +229,6 @@ wr32_osdep(struct i40e_osdep *osdep, uint32_t reg, uint32_t value) ((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \ reg, value)) -#define ixl_flush(a) (\ - bus_space_read_4( ((struct i40e_osdep *)(a)->back)->mem_bus_space_tag, \ - ((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \ - I40E_GLGEN_STAT)) +#define ixl_flush(a) ixl_flush_osdep((a)->back) #endif /* _I40E_OSDEP_H_ */ diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c index e381f4e4f529..8d1100c55f45 100755 --- a/sys/dev/ixl/if_ixl.c +++ b/sys/dev/ixl/if_ixl.c @@ -921,8 +921,10 @@ ixl_ioctl(struct ifnet * ifp, u_long command, caddr_t data) ifp->if_flags |= IFF_UP; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) ixl_init(pf); +#ifdef INET if (!(ifp->if_flags & IFF_NOARP)) arp_ifinit(ifp, ifa); +#endif } else error = ether_ioctl(ifp, command, data); break; @@ -2175,6 +2177,7 @@ ixl_allocate_pci_resources(struct ixl_pf *pf) pf->osdep.mem_bus_space_handle = rman_get_bushandle(pf->pci_mem); pf->osdep.mem_bus_space_size = rman_get_size(pf->pci_mem); + pf->osdep.flush_reg = I40E_GLGEN_STAT; pf->hw.hw_addr = (u8 *) &pf->osdep.mem_bus_space_handle; pf->hw.back = &pf->osdep; @@ -2273,6 +2276,10 @@ ixl_setup_interface(device_t dev, struct ixl_vsi *vsi) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixl_ioctl; +#if __FreeBSD_version >= 1100000 + if_setgetcounterfn(ifp, ixl_get_counter); +#endif + ifp->if_transmit = ixl_mq_start; ifp->if_qflush = ixl_qflush; @@ -2591,7 +2598,7 @@ ixl_free_vsi(struct ixl_vsi *vsi) IXL_TX_LOCK(txr); ixl_free_que_tx(que); if (txr->base) - i40e_free_dma(&pf->hw, &txr->dma); + i40e_free_dma_mem(&pf->hw, &txr->dma); IXL_TX_UNLOCK(txr); IXL_TX_LOCK_DESTROY(txr); @@ -2600,7 +2607,7 @@ ixl_free_vsi(struct ixl_vsi *vsi) IXL_RX_LOCK(rxr); ixl_free_que_rx(que); if (rxr->base) - i40e_free_dma(&pf->hw, &rxr->dma); + i40e_free_dma_mem(&pf->hw, &rxr->dma); IXL_RX_UNLOCK(rxr); IXL_RX_LOCK_DESTROY(rxr); @@ -2668,8 +2675,8 @@ ixl_setup_stations(struct ixl_pf *pf) tsize = roundup2((que->num_desc * sizeof(struct i40e_tx_desc)) + sizeof(u32), DBA_ALIGN); - if (i40e_allocate_dma(&pf->hw, - &txr->dma, tsize, DBA_ALIGN)) { + if (i40e_allocate_dma_mem(&pf->hw, + &txr->dma, i40e_mem_reserved, tsize, DBA_ALIGN)) { device_printf(dev, "Unable to allocate TX Descriptor memory\n"); error = ENOMEM; @@ -2708,8 +2715,8 @@ ixl_setup_stations(struct ixl_pf *pf) device_get_nameunit(dev), que->me); mtx_init(&rxr->mtx, rxr->mtx_name, NULL, MTX_DEF); - if (i40e_allocate_dma(&pf->hw, - &rxr->dma, rsize, 4096)) { + if (i40e_allocate_dma_mem(&pf->hw, + &rxr->dma, i40e_mem_reserved, rsize, 4096)) { device_printf(dev, "Unable to allocate RX Descriptor memory\n"); error = ENOMEM; @@ -2735,9 +2742,9 @@ ixl_setup_stations(struct ixl_pf *pf) rxr = &que->rxr; txr = &que->txr; if (rxr->base) - i40e_free_dma(&pf->hw, &rxr->dma); + i40e_free_dma_mem(&pf->hw, &rxr->dma); if (txr->base) - i40e_free_dma(&pf->hw, &txr->dma); + i40e_free_dma_mem(&pf->hw, &txr->dma); } early: @@ -3698,7 +3705,6 @@ ixl_update_stats_counters(struct ixl_pf *pf) { struct i40e_hw *hw = &pf->hw; struct ixl_vsi *vsi = &pf->vsi; - struct ifnet *ifp = vsi->ifp; struct i40e_hw_port_stats *nsd = &pf->stats; struct i40e_hw_port_stats *osd = &pf->stats_offsets; @@ -3891,7 +3897,7 @@ ixl_update_stats_counters(struct ixl_pf *pf) /* OS statistics */ // ERJ - these are per-port, update all vsis? - ifp->if_ierrors = nsd->crc_errors + nsd->illegal_bytes; + IXL_SET_IERRORS(vsi, nsd->crc_errors + nsd->illegal_bytes); } /* @@ -4025,13 +4031,16 @@ void ixl_update_eth_stats(struct ixl_vsi *vsi) { struct ixl_pf *pf = (struct ixl_pf *)vsi->back; struct i40e_hw *hw = &pf->hw; - struct ifnet *ifp = vsi->ifp; struct i40e_eth_stats *es; struct i40e_eth_stats *oes; + int i; + uint64_t tx_discards; + struct i40e_hw_port_stats *nsd; u16 stat_idx = vsi->info.stat_counter_idx; es = &vsi->eth_stats; oes = &vsi->eth_stats_offsets; + nsd = &pf->stats; /* Gather up the stats that the hw collects */ ixl_stat_update32(hw, I40E_GLV_TEPC(stat_idx), @@ -4076,22 +4085,27 @@ void ixl_update_eth_stats(struct ixl_vsi *vsi) &oes->tx_broadcast, &es->tx_broadcast); vsi->stat_offsets_loaded = true; - /* Update ifnet stats */ - ifp->if_ipackets = es->rx_unicast + - es->rx_multicast + - es->rx_broadcast; - ifp->if_opackets = es->tx_unicast + - es->tx_multicast + - es->tx_broadcast; - ifp->if_ibytes = es->rx_bytes; - ifp->if_obytes = es->tx_bytes; - ifp->if_imcasts = es->rx_multicast; - ifp->if_omcasts = es->tx_multicast; + tx_discards = es->tx_discards + nsd->tx_dropped_link_down; + for (i = 0; i < vsi->num_queues; i++) + tx_discards += vsi->queues[i].txr.br->br_drops; - ifp->if_oerrors = es->tx_errors; - ifp->if_iqdrops = es->rx_discards; - ifp->if_noproto = es->rx_unknown_protocol; - ifp->if_collisions = 0; + /* Update ifnet stats */ + IXL_SET_IPACKETS(vsi, es->rx_unicast + + es->rx_multicast + + es->rx_broadcast); + IXL_SET_OPACKETS(vsi, es->tx_unicast + + es->tx_multicast + + es->tx_broadcast); + IXL_SET_IBYTES(vsi, es->rx_bytes); + IXL_SET_OBYTES(vsi, es->tx_bytes); + IXL_SET_IMCASTS(vsi, es->rx_multicast); + IXL_SET_OMCASTS(vsi, es->tx_multicast); + + IXL_SET_OERRORS(vsi, es->tx_errors); + IXL_SET_IQDROPS(vsi, es->rx_discards + nsd->eth.rx_discards); + IXL_SET_OQDROPS(vsi, tx_discards); + IXL_SET_NOPROTO(vsi, es->rx_unknown_protocol); + IXL_SET_COLLISIONS(vsi, 0); } /** diff --git a/sys/dev/ixl/if_ixlv.c b/sys/dev/ixl/if_ixlv.c index 2a63387c802e..bd3c202dd814 100644 --- a/sys/dev/ixl/if_ixlv.c +++ b/sys/dev/ixl/if_ixlv.c @@ -755,8 +755,10 @@ ixlv_ioctl(struct ifnet *ifp, u_long command, caddr_t data) ifp->if_flags |= IFF_UP; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) ixlv_init(sc); +#ifdef INET if (!(ifp->if_flags & IFF_NOARP)) arp_ifinit(ifp, ifa); +#endif } else error = ether_ioctl(ifp, command, data); break; @@ -1135,6 +1137,7 @@ ixlv_allocate_pci_resources(struct ixlv_sc *sc) sc->osdep.mem_bus_space_handle = rman_get_bushandle(sc->pci_mem); sc->osdep.mem_bus_space_size = rman_get_size(sc->pci_mem); + sc->osdep.flush_reg = I40E_VFGEN_RSTAT; sc->hw.hw_addr = (u8 *) &sc->osdep.mem_bus_space_handle; sc->hw.back = &sc->osdep; @@ -1353,6 +1356,10 @@ ixlv_setup_interface(device_t dev, struct ixlv_sc *sc) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ixlv_ioctl; +#if __FreeBSD_version >= 1100000 + if_setgetcounterfn(ifp, ixl_get_counter); +#endif + ifp->if_transmit = ixl_mq_start; ifp->if_qflush = ixl_qflush; @@ -1457,8 +1464,8 @@ ixlv_setup_queues(struct ixlv_sc *sc) tsize = roundup2((que->num_desc * sizeof(struct i40e_tx_desc)) + sizeof(u32), DBA_ALIGN); - if (i40e_allocate_dma(&sc->hw, - &txr->dma, tsize, DBA_ALIGN)) { + if (i40e_allocate_dma_mem(&sc->hw, + &txr->dma, i40e_mem_reserved, tsize, DBA_ALIGN)) { device_printf(dev, "Unable to allocate TX Descriptor memory\n"); error = ENOMEM; @@ -1497,8 +1504,8 @@ ixlv_setup_queues(struct ixlv_sc *sc) device_get_nameunit(dev), que->me); mtx_init(&rxr->mtx, rxr->mtx_name, NULL, MTX_DEF); - if (i40e_allocate_dma(&sc->hw, - &rxr->dma, rsize, 4096)) { //JFV - should this be DBA? + if (i40e_allocate_dma_mem(&sc->hw, + &rxr->dma, i40e_mem_reserved, rsize, 4096)) { //JFV - should this be DBA? device_printf(dev, "Unable to allocate RX Descriptor memory\n"); error = ENOMEM; @@ -1525,9 +1532,9 @@ ixlv_setup_queues(struct ixlv_sc *sc) rxr = &que->rxr; txr = &que->txr; if (rxr->base) - i40e_free_dma(&sc->hw, &rxr->dma); + i40e_free_dma_mem(&sc->hw, &rxr->dma); if (txr->base) - i40e_free_dma(&sc->hw, &txr->dma); + i40e_free_dma_mem(&sc->hw, &txr->dma); } early: @@ -2346,7 +2353,7 @@ ixlv_free_queues(struct ixl_vsi *vsi) IXL_TX_LOCK(txr); ixl_free_que_tx(que); if (txr->base) - i40e_free_dma(&sc->hw, &txr->dma); + i40e_free_dma_mem(&sc->hw, &txr->dma); IXL_TX_UNLOCK(txr); IXL_TX_LOCK_DESTROY(txr); @@ -2355,7 +2362,7 @@ ixlv_free_queues(struct ixl_vsi *vsi) IXL_RX_LOCK(rxr); ixl_free_que_rx(que); if (rxr->base) - i40e_free_dma(&sc->hw, &rxr->dma); + i40e_free_dma_mem(&sc->hw, &rxr->dma); IXL_RX_UNLOCK(rxr); IXL_RX_LOCK_DESTROY(rxr); diff --git a/sys/dev/ixl/ixl.h b/sys/dev/ixl/ixl.h index 69be0085f07b..c240b026e355 100644 --- a/sys/dev/ixl/ixl.h +++ b/sys/dev/ixl/ixl.h @@ -264,6 +264,35 @@ #define IXL_RX_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) #define IXL_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx) +#if __FreeBSD_version >= 1100000 +#define IXL_SET_IPACKETS(vsi, count) (vsi)->ipackets = (count) +#define IXL_SET_IERRORS(vsi, count) (vsi)->ierrors = (count) +#define IXL_SET_OPACKETS(vsi, count) (vsi)->opackets = (count) +#define IXL_SET_OERRORS(vsi, count) (vsi)->oerrors = (count) +#define IXL_SET_COLLISIONS(vsi, count) /* Do nothing; collisions is always 0. */ +#define IXL_SET_IBYTES(vsi, count) (vsi)->ibytes = (count) +#define IXL_SET_OBYTES(vsi, count) (vsi)->obytes = (count) +#define IXL_SET_IMCASTS(vsi, count) (vsi)->imcasts = (count) +#define IXL_SET_OMCASTS(vsi, count) (vsi)->omcasts = (count) +#define IXL_SET_IQDROPS(vsi, count) (vsi)->iqdrops = (count) +#define IXL_SET_OQDROPS(vsi, count) (vsi)->iqdrops = (count) +#define IXL_SET_NOPROTO(vsi, count) (vsi)->noproto = (count) +#else +#define IXL_SET_IPACKETS(vsi, count) (vsi)->ifp->if_ipackets = (count) +#define IXL_SET_IERRORS(vsi, count) (vsi)->ifp->if_ierrors = (count) +#define IXL_SET_OPACKETS(vsi, count) (vsi)->ifp->if_opackets = (count) +#define IXL_SET_OERRORS(vsi, count) (vsi)->ifp->if_oerrors = (count) +#define IXL_SET_COLLISIONS(vsi, count) (vsi)->ifp->if_collisions = (count) +#define IXL_SET_IBYTES(vsi, count) (vsi)->ifp->if_ibytes = (count) +#define IXL_SET_OBYTES(vsi, count) (vsi)->ifp->if_obytes = (count) +#define IXL_SET_IMCASTS(vsi, count) (vsi)->ifp->if_imcasts = (count) +#define IXL_SET_OMCASTS(vsi, count) (vsi)->ifp->if_omcasts = (count) +#define IXL_SET_IQDROPS(vsi, count) (vsi)->ifp->if_iqdrops = (count) +#define IXL_SET_OQDROPS(vsi, odrops) (vsi)->ifp->if_snd.ifq_drops = (odrops) +#define IXL_SET_NOPROTO(vsi, count) (vsi)->noproto = (count) +#endif + + /* ***************************************************************************** * vendor_info_array @@ -447,6 +476,17 @@ struct ixl_vsi { struct i40e_eth_stats eth_stats; struct i40e_eth_stats eth_stats_offsets; bool stat_offsets_loaded; + u64 ipackets; + u64 ierrors; + u64 opackets; + u64 oerrors; + u64 ibytes; + u64 obytes; + u64 imcasts; + u64 omcasts; + u64 iqdrops; + u64 oqdrops; + u64 noproto; /* Driver statistics */ u64 hw_filters_del; @@ -554,5 +594,8 @@ void ixl_free_que_rx(struct ixl_queue *); #ifdef IXL_FDIR void ixl_atr(struct ixl_queue *, struct tcphdr *, int); #endif +#if __FreeBSD_version >= 1100000 +uint64_t ixl_get_counter(if_t ifp, ift_counter cnt); +#endif #endif /* _IXL_H_ */ diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c index 12e09f776423..b804c76f9840 100755 --- a/sys/dev/ixl/ixl_txrx.c +++ b/sys/dev/ixl/ixl_txrx.c @@ -783,8 +783,6 @@ ixl_get_tx_head(struct ixl_queue *que) bool ixl_txeof(struct ixl_queue *que) { - struct ixl_vsi *vsi = que->vsi; - struct ifnet *ifp = vsi->ifp; struct tx_ring *txr = &que->txr; u32 first, last, head, done, processed; struct ixl_tx_buf *buf; @@ -857,7 +855,6 @@ ixl_txeof(struct ixl_queue *que) tx_desc = &txr->base[first]; } ++txr->packets; - ++ifp->if_opackets; /* See if there is more work now */ last = buf->eop_index; if (last != -1) { @@ -1085,10 +1082,12 @@ ixl_allocate_rx_data(struct ixl_queue *que) int ixl_init_rx_ring(struct ixl_queue *que) { + struct rx_ring *rxr = &que->rxr; +#if defined(INET6) || defined(INET) struct ixl_vsi *vsi = que->vsi; struct ifnet *ifp = vsi->ifp; - struct rx_ring *rxr = &que->rxr; struct lro_ctrl *lro = &rxr->lro; +#endif struct ixl_rx_buf *buf; bus_dma_segment_t pseg[1], hseg[1]; int rsize, nsegs, error = 0; @@ -1187,6 +1186,7 @@ ixl_init_rx_ring(struct ixl_queue *que) rxr->bytes = 0; rxr->discard = FALSE; +#if defined(INET6) || defined(INET) /* ** Now set up the LRO interface: */ @@ -1200,6 +1200,7 @@ ixl_init_rx_ring(struct ixl_queue *que) rxr->lro_enabled = TRUE; lro->ifp = vsi->ifp; } +#endif bus_dmamap_sync(rxr->dma.tag, rxr->dma.map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); @@ -1274,6 +1275,8 @@ ixl_free_que_rx(struct ixl_queue *que) static __inline void ixl_rx_input(struct rx_ring *rxr, struct ifnet *ifp, struct mbuf *m, u8 ptype) { + +#if defined(INET6) || defined(INET) /* * ATM LRO is only for IPv4/TCP packets and TCP checksum of the packet * should be computed by hardware. Also it should not have VLAN tag in @@ -1293,6 +1296,7 @@ ixl_rx_input(struct rx_ring *rxr, struct ifnet *ifp, struct mbuf *m, u8 ptype) if (tcp_lro_rx(&rxr->lro, m, 0) == 0) return; } +#endif IXL_RX_UNLOCK(rxr); (*ifp->if_input)(ifp, m); IXL_RX_LOCK(rxr); @@ -1350,8 +1354,10 @@ ixl_rxeof(struct ixl_queue *que, int count) struct ixl_vsi *vsi = que->vsi; struct rx_ring *rxr = &que->rxr; struct ifnet *ifp = vsi->ifp; +#if defined(INET6) || defined(INET) struct lro_ctrl *lro = &rxr->lro; struct lro_entry *queued; +#endif int i, nextp, processed = 0; union i40e_rx_desc *cur; struct ixl_rx_buf *rbuf, *nbuf; @@ -1411,7 +1417,6 @@ ixl_rxeof(struct ixl_queue *que, int count) ** error results. */ if (eop && (error & (1 << I40E_RX_DESC_ERROR_RXE_SHIFT))) { - ifp->if_ierrors++; rxr->discarded++; ixl_rx_discard(rxr, i); goto next_desc; @@ -1520,7 +1525,6 @@ ixl_rxeof(struct ixl_queue *que, int count) if (eop) { sendmp->m_pkthdr.rcvif = ifp; /* gather stats */ - ifp->if_ipackets++; rxr->rx_packets++; rxr->rx_bytes += sendmp->m_pkthdr.len; /* capture data for dynamic ITR adjustment */ @@ -1559,6 +1563,7 @@ ixl_rxeof(struct ixl_queue *que, int count) rxr->next_check = i; +#if defined(INET6) || defined(INET) /* * Flush any outstanding LRO work */ @@ -1566,6 +1571,7 @@ ixl_rxeof(struct ixl_queue *que, int count) SLIST_REMOVE_HEAD(&lro->lro_active, next); tcp_lro_flush(lro, queued); } +#endif IXL_RX_UNLOCK(rxr); return (FALSE); @@ -1614,3 +1620,43 @@ ixl_rx_checksum(struct mbuf * mp, u32 status, u32 error, u8 ptype) } return; } + +#if __FreeBSD_version >= 1100000 +uint64_t +ixl_get_counter(if_t ifp, ift_counter cnt) +{ + struct ixl_vsi *vsi; + + vsi = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (vsi->ipackets); + case IFCOUNTER_IERRORS: + return (vsi->ierrors); + case IFCOUNTER_OPACKETS: + return (vsi->opackets); + case IFCOUNTER_OERRORS: + return (vsi->oerrors); + case IFCOUNTER_COLLISIONS: + /* Collisions are by standard impossible in 40G/10G Ethernet */ + return (0); + case IFCOUNTER_IBYTES: + return (vsi->ibytes); + case IFCOUNTER_OBYTES: + return (vsi->obytes); + case IFCOUNTER_IMCASTS: + return (vsi->imcasts); + case IFCOUNTER_OMCASTS: + return (vsi->omcasts); + case IFCOUNTER_IQDROPS: + return (vsi->iqdrops); + case IFCOUNTER_OQDROPS: + return (vsi->oqdrops); + case IFCOUNTER_NOPROTO: + return (vsi->noproto); + default: + return (if_get_counter_default(ifp, cnt)); + } +} +#endif diff --git a/sys/dev/ixl/ixlvc.c b/sys/dev/ixl/ixlvc.c index 1f912b5db46c..ef69a82f610b 100644 --- a/sys/dev/ixl/ixlvc.c +++ b/sys/dev/ixl/ixlvc.c @@ -837,22 +837,33 @@ ixlv_request_stats(struct ixlv_sc *sc) void ixlv_update_stats_counters(struct ixlv_sc *sc, struct i40e_eth_stats *es) { - struct ifnet *ifp = sc->vsi.ifp; + struct ixl_vsi *vsi; + uint64_t tx_discards; + int i; - ifp->if_ipackets = es->rx_unicast + + vsi = &sc->vsi; + + tx_discards = es->tx_discards; + for (i = 0; i < sc->vsi.num_queues; i++) + tx_discards += sc->vsi.queues[i].txr.br->br_drops; + + /* Update ifnet stats */ + IXL_SET_IPACKETS(vsi, es->rx_unicast + es->rx_multicast + - es->rx_broadcast; - ifp->if_opackets = es->tx_unicast + + es->rx_broadcast); + IXL_SET_OPACKETS(vsi, es->tx_unicast + es->tx_multicast + - es->tx_broadcast; - ifp->if_ibytes = es->rx_bytes; - ifp->if_obytes = es->tx_bytes; - ifp->if_imcasts = es->rx_multicast; - ifp->if_omcasts = es->tx_multicast; + es->tx_broadcast); + IXL_SET_IBYTES(vsi, es->rx_bytes); + IXL_SET_OBYTES(vsi, es->tx_bytes); + IXL_SET_IMCASTS(vsi, es->rx_multicast); + IXL_SET_OMCASTS(vsi, es->tx_multicast); - ifp->if_oerrors = es->tx_errors; - ifp->if_iqdrops = es->rx_discards; - ifp->if_noproto = es->rx_unknown_protocol; + IXL_SET_OERRORS(vsi, es->tx_errors); + IXL_SET_IQDROPS(vsi, es->rx_discards); + IXL_SET_OQDROPS(vsi, tx_discards); + IXL_SET_NOPROTO(vsi, es->rx_unknown_protocol); + IXL_SET_COLLISIONS(vsi, 0); sc->vsi.eth_stats = *es; } diff --git a/sys/dev/jme/if_jme.c b/sys/dev/jme/if_jme.c index 6300df6ef290..35b25265c979 100644 --- a/sys/dev/jme/if_jme.c +++ b/sys/dev/jme/if_jme.c @@ -1947,7 +1947,7 @@ jme_watchdog(struct jme_softc *sc) ifp = sc->jme_ifp; if ((sc->jme_flags & JME_FLAG_LINK) == 0) { if_printf(sc->jme_ifp, "watchdog timeout (missed link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; jme_init_locked(sc); return; @@ -1962,7 +1962,7 @@ jme_watchdog(struct jme_softc *sc) } if_printf(sc->jme_ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; jme_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -2281,7 +2281,7 @@ jme_link_task(void *arg, int pending) m_freem(txd->tx_m); txd->tx_m = NULL; txd->tx_ndesc = 0; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } } } @@ -2449,13 +2449,13 @@ jme_txeof(struct jme_softc *sc) break; if ((status & (JME_TD_TMOUT | JME_TD_RETRY_EXP)) != 0) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if ((status & JME_TD_COLLISION) != 0) - ifp->if_collisions += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, le32toh(txd->tx_desc->buflen) & - JME_TD_BUF_LEN_MASK; + JME_TD_BUF_LEN_MASK); } /* * Only the first descriptor of multi-descriptor @@ -2526,7 +2526,7 @@ jme_rxeof(struct jme_softc *sc) nsegs = JME_RX_NSEGS(status); sc->jme_cdata.jme_rxlen = JME_RX_BYTES(status) - JME_RX_PAD_BYTES; if ((status & JME_RX_ERR_STAT) != 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); jme_discard_rxbuf(sc, sc->jme_cdata.jme_rx_cons); #ifdef JME_SHOW_ERRORS device_printf(sc->jme_dev, "%s : receive error = 0x%b\n", @@ -2543,7 +2543,7 @@ jme_rxeof(struct jme_softc *sc) mp = rxd->rx_m; /* Add a new receive buffer to the ring. */ if (jme_newbuf(sc, rxd) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* Reuse buffer. */ for (; count < nsegs; count++) { jme_discard_rxbuf(sc, cons); @@ -2626,7 +2626,7 @@ jme_rxeof(struct jme_softc *sc) m->m_flags |= M_VLANTAG; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* Pass it on. */ JME_UNLOCK(sc); (*ifp->if_input)(ifp, m); diff --git a/sys/dev/le/am7990.c b/sys/dev/le/am7990.c index d74d3b836264..a21be28a4c13 100644 --- a/sys/dev/le/am7990.c +++ b/sys/dev/le/am7990.c @@ -272,7 +272,7 @@ am7990_rint(struct lance_softc *sc) bix = 0; if (m != NULL) { - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); #ifdef LANCE_REVC_BUG /* @@ -296,7 +296,7 @@ am7990_rint(struct lance_softc *sc) (*ifp->if_input)(ifp, m); LE_LOCK(sc); } else - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } sc->sc_last_rd = bix; @@ -352,22 +352,22 @@ am7990_tint(struct lance_softc *sc) if_printf(ifp, "lost carrier\n"); } if (tmd.tmd3 & LE_T3_LCOL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (tmd.tmd3 & LE_T3_RTRY) { #ifdef LEDEBUG if_printf(ifp, "excessive collisions, tdr %d\n", tmd.tmd3 & LE_T3_TDR_MASK); #endif - ifp->if_collisions += 16; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16); } - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else { if (tmd.tmd1_bits & LE_T1_ONE) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); else if (tmd.tmd1_bits & LE_T1_MORE) /* Real number is unknown. */ - ifp->if_collisions += 2; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } if (++bix == sc->sc_ntbuf) @@ -394,7 +394,7 @@ am7990_intr(void *arg) LE_LOCK(sc); if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); lance_init_locked(sc); LE_UNLOCK(sc); return; @@ -426,19 +426,19 @@ am7990_intr(void *arg) #ifdef LEDEBUG if_printf(ifp, "babble\n"); #endif - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } #if 0 if (isr & LE_C0_CERR) { if_printf(ifp, "collision error\n"); - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } #endif if (isr & LE_C0_MISS) { #ifdef LEDEBUG if_printf(ifp, "missed packet\n"); #endif - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } if (isr & LE_C0_MERR) { if_printf(ifp, "memory error\n"); @@ -450,14 +450,14 @@ am7990_intr(void *arg) if ((isr & LE_C0_RXON) == 0) { if_printf(ifp, "receiver disabled\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); lance_init_locked(sc); LE_UNLOCK(sc); return; } if ((isr & LE_C0_TXON) == 0) { if_printf(ifp, "transmitter disabled\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lance_init_locked(sc); LE_UNLOCK(sc); return; diff --git a/sys/dev/le/am79900.c b/sys/dev/le/am79900.c index 08449e5991c9..5ea82284535c 100644 --- a/sys/dev/le/am79900.c +++ b/sys/dev/le/am79900.c @@ -313,7 +313,7 @@ am79900_rint(struct lance_softc *sc) bix = 0; if (m != NULL) { - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); #if defined(__i386__) && !defined(PC98) /* @@ -333,7 +333,7 @@ am79900_rint(struct lance_softc *sc) (*ifp->if_input)(ifp, m); LE_LOCK(sc); } else - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } sc->sc_last_rd = bix; @@ -391,21 +391,21 @@ am79900_tint(struct lance_softc *sc) if_printf(ifp, "lost carrier\n"); } if (tmd2 & LE_T2_LCOL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (tmd2 & LE_T2_RTRY) { #ifdef LEDEBUG if_printf(ifp, "excessive collisions\n"); #endif - ifp->if_collisions += 16; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16); } - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else { if (tmd1 & LE_T1_ONE) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); else if (tmd1 & LE_T1_MORE) /* Real number is unknown. */ - ifp->if_collisions += 2; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } if (++bix == sc->sc_ntbuf) @@ -432,7 +432,7 @@ am79900_intr(void *arg) LE_LOCK(sc); if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); lance_init_locked(sc); LE_UNLOCK(sc); return; @@ -464,19 +464,19 @@ am79900_intr(void *arg) #ifdef LEDEBUG if_printf(ifp, "babble\n"); #endif - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } #if 0 if (isr & LE_C0_CERR) { if_printf(ifp, "collision error\n"); - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } #endif if (isr & LE_C0_MISS) { #ifdef LEDEBUG if_printf(ifp, "missed packet\n"); #endif - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } if (isr & LE_C0_MERR) { if_printf(ifp, "memory error\n"); @@ -488,14 +488,14 @@ am79900_intr(void *arg) if ((isr & LE_C0_RXON) == 0) { if_printf(ifp, "receiver disabled\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); lance_init_locked(sc); LE_UNLOCK(sc); return; } if ((isr & LE_C0_TXON) == 0) { if_printf(ifp, "transmitter disabled\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lance_init_locked(sc); LE_UNLOCK(sc); return; diff --git a/sys/dev/le/lance.c b/sys/dev/le/lance.c index 2a2b0e0fa956..38be317aa577 100644 --- a/sys/dev/le/lance.c +++ b/sys/dev/le/lance.c @@ -446,7 +446,7 @@ lance_watchdog(void *xsc) } if_printf(ifp, "device timeout\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lance_init_locked(sc); } diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c index 94f326f8de2a..9aef1313c598 100644 --- a/sys/dev/lge/if_lge.c +++ b/sys/dev/lge/if_lge.c @@ -916,7 +916,7 @@ lge_rxeof(sc, cnt) * comes up in the ring. */ if (rxctl & LGE_RXCTL_ERRMASK) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); lge_newbuf(sc, &LGE_RXTAIL(sc), m); continue; } @@ -928,7 +928,7 @@ lge_rxeof(sc, cnt) if (m0 == NULL) { device_printf(sc->lge_dev, "no receive buffers " "available -- packet dropped!\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } m = m0; @@ -937,7 +937,7 @@ lge_rxeof(sc, cnt) m->m_pkthdr.len = m->m_len = total_len; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* Do IP checksum checking. */ if (rxsts & LGE_RXSTS_ISIP) @@ -1003,7 +1003,7 @@ lge_txeof(sc) while (idx != sc->lge_cdata.lge_tx_prod && txdone) { cur_tx = &sc->lge_ldata->lge_tx_list[idx]; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (cur_tx->lge_mbuf != NULL) { m_freem(cur_tx->lge_mbuf); cur_tx->lge_mbuf = NULL; @@ -1036,9 +1036,9 @@ lge_tick(xsc) LGE_LOCK_ASSERT(sc); CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_SINGLE_COLL_PKTS); - ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, CSR_READ_4(sc, LGE_STATSVAL)); CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_MULTI_COLL_PKTS); - ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, CSR_READ_4(sc, LGE_STATSVAL)); if (!sc->lge_link) { mii = device_get_softc(sc->lge_miibus); @@ -1504,7 +1504,7 @@ lge_watchdog(sc) LGE_LOCK_ASSERT(sc); ifp = sc->lge_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); lge_stop(sc); diff --git a/sys/dev/lmc/if_lmc.c b/sys/dev/lmc/if_lmc.c index 766fdae392ab..9e1463b0c56a 100644 --- a/sys/dev/lmc/if_lmc.c +++ b/sys/dev/lmc/if_lmc.c @@ -71,7 +71,6 @@ * * Send bug reports and improvements to . */ -#ifdef __FreeBSD__ # include /* OS version */ # define IFNET 1 # include "opt_inet.h" /* INET */ @@ -90,15 +89,9 @@ # define NETGRAPH 0 # endif # define P2P 0 /* not in FreeBSD */ -# if (__FreeBSD_version >= 500000) -# define NSPPP 1 /* No count devices in FreeBSD 5 */ -# include "opt_bpf.h" /* DEV_BPF */ -# define NBPFILTER DEV_BPF -# else /* FreeBSD-4 */ -# include "sppp.h" /* NSPPP */ -# include "bpf.h" /* NBPF */ -# define NBPFILTER NBPF -# endif +# define NSPPP 1 /* No count devices in FreeBSD 5 */ +# include "opt_bpf.h" /* DEV_BPF */ +# define NBPFILTER DEV_BPF # define GEN_HDLC 0 /* not in FreeBSD */ # # include @@ -121,16 +114,9 @@ # include # include # include -# if (__FreeBSD_version >= 700000) -# include -# endif -# if (__FreeBSD_version >= 500000) +# include # include # include -# else /* FreeBSD-4 */ -# include -# include -# endif # if NETGRAPH # include # include @@ -147,180 +133,10 @@ # endif /* and finally... */ # include -#endif /*__FreeBSD__*/ -#ifdef __NetBSD__ -# include /* OS version */ -# define IFNET 1 -# include "opt_inet.h" /* INET6, INET */ -# define NETGRAPH 0 /* not in NetBSD */ -# include "sppp.h" /* NSPPP */ -# define P2P 0 /* not in NetBSD */ -# include "opt_altq_enabled.h" /* ALTQ */ -# include "bpfilter.h" /* NBPFILTER */ -# define GEN_HDLC 0 /* not in NetBSD */ -# -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# if (__NetBSD_Version__ >= 106000000) -# include -# else -# include -# endif -# if (INET || INET6) -# include -# include -# endif -# if NSPPP -# if (__NetBSD_Version__ >= 106000000) -# include -# else -# include -# endif -# endif -# if NBPFILTER -# include -# endif -/* and finally... */ -# include "if_lmc.h" -#endif /*__NetBSD__*/ -#ifdef __OpenBSD__ -# include /* OS version */ -# define IFNET 1 -/* -DINET is passed on the compiler command line */ -/* -DINET6 is passed on the compiler command line */ -# define NETGRAPH 0 /* not in OpenBSD */ -# include "sppp.h" /* NSPPP */ -# define P2P 0 /* not in OpenBSD */ -/* -DALTQ is passed on the compiler command line */ -# include "bpfilter.h" /* NBPFILTER */ -# define GEN_HDLC 0 /* not in OpenBSD */ -# -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# if (OpenBSD >= 200206) -# include -# else -# include -# endif -# if (INET || INET6) -# include -# include -# endif -# if NSPPP -# include -# endif -# if NBPFILTER -# include -# endif -/* and finally... */ -# include "if_lmc.h" -#endif /*__OpenBSD__*/ -#ifdef __bsdi__ -# include /* OS version */ -# define IFNET 1 -/* -DINET is passed on the compiler command line */ -/* -DINET6 is passed on the compiler command line */ -# define NETGRAPH 0 /* not in BSD/OS */ -# define NSPPP 0 /* not in BSD/OS */ -/* -DPPP is passed on the compiler command line */ -/* -DCISCO_HDLC is passed on the compiler command line */ -/* -DFR is passed on the compiler command line */ -# if (PPP || CISCO_HDLC || FR) -# define P2P 1 -# else -# define P2P 0 -# endif -# define ALTQ 0 /* not in BSD/OS */ -# include "bpfilter.h" /* NBPFILTER */ -# define GEN_HDLC 0 /* not in BSD/OS */ -# -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# if (INET || INET6) -# include -# include -# endif -# if P2P -# include -# include -# endif -# if NBPFILTER -# include -# endif -/* and finally... */ -# include "if_lmc.h" -#endif /*__bsdi__*/ -#ifdef __linux__ -# include -# if (CONFIG_HDLC || CONFIG_HDLC_MODULE) -# define GEN_HDLC 1 -# else -# define GEN_HDLC 0 -# endif -# define IFNET 0 /* different in Linux */ -# define NETGRAPH 0 /* not in Linux */ -# define NSPPP 0 /* different in Linux */ -# define P2P 0 /* not in Linux */ -# define ALTQ 0 /* different in Linux */ -# define NBPFILTER 0 /* different in Linux */ -# -# include -# include -# include -# include -# if GEN_HDLC -# include -# endif -/* and finally... */ -# include "if_lmc.h" -#endif /* __linux__ */ /* The SROM is a generic 93C46 serial EEPROM (64 words by 16 bits). */ /* Data is set up before the RISING edge of CLK; CLK is parked low. */ @@ -2484,44 +2300,6 @@ struct card t1_card = /* RAWIP is raw IP packets (v4 or v6) in HDLC frames with NO HEADERS. */ /* No HDLC Address/Control fields! No line control protocol at all! */ -/* This code is BSD/ifnet-specific; Linux and Netgraph also do RAWIP. */ - -#if IFNET - -# if ((defined(__FreeBSD__) && (__FreeBSD_version < 500000)) ||\ - defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)) -static void -netisr_dispatch(int isr, struct mbuf *mbuf) - { - struct ifqueue *intrq = NULL; - int qfull = 0; - -#if INET - if (isr == NETISR_IP) intrq = &ipintrq; -#endif -#if INET6 - if (isr == NETISR_IPV6) intrq = &ip6intrq; -#endif - - if ((intrq != NULL) && ((qfull = IF_QFULL(intrq)) == 0)) - { - /* rxintr_cleanup() ENQUEUES in a hard interrupt. */ - /* networking code DEQUEUES in a soft interrupt. */ - /* Some BSD QUEUE routines are not interrupt-safe. */ - DISABLE_INTR; /* noop in FreeBSD */ - IF_ENQUEUE(intrq, mbuf); - ENABLE_INTR; - schednetisr(isr); /* schedule a soft interrupt */ - } - else - { - m_freem(mbuf); - if ((intrq != NULL) && (qfull != 0)) - IF_DROP(intrq); - } - } -# endif /* ((__FreeBSD__ && (__FreeBSD_version < 500000)) || */ - /* __NetBSD__ || __OpenBSD__ || __bsdi__) */ /* rxintr_cleanup calls this to give a newly arrived pkt to higher levels. */ static void @@ -2549,20 +2327,12 @@ lmc_raw_input(struct ifnet *ifp, struct mbuf *mbuf) } } -#endif /* IFNET */ - -/* There are TWO VERSIONS of interrupt/DMA code: Linux & BSD. - * Handling Linux and the BSDs with CPP directives would - * make the code unreadable, so there are two versions. - * Conceptually, the two versions do the same thing and - * core_interrupt() doesn't know they are different. - * +/* * We are "standing on the head of a pin" in these routines. * Tulip CSRs can be accessed, but nothing else is interrupt-safe! * Do NOT access: MII, GPIO, SROM, BIOSROM, XILINX, SYNTH, or DAC. */ -#if BSD /* BSD version of interrupt/DMA code */ /* Singly-linked tail-queues hold mbufs with active DMA. * For RX, single mbuf clusters; for TX, mbuf chains are queued. @@ -2593,7 +2363,6 @@ mbuf_dequeue(struct desc_ring *ring) return m; } -# ifdef __FreeBSD__ static void /* *** FreeBSD ONLY *** Callout from bus_dmamap_load() */ fbsd_dmamap_load(void *arg, bus_dma_segment_t *segs, int nsegs, int error) { @@ -2602,7 +2371,6 @@ fbsd_dmamap_load(void *arg, bus_dma_segment_t *segs, int nsegs, int error) ring->segs[0] = segs[0]; ring->segs[1] = segs[1]; } -# endif /* Initialize a DMA descriptor ring. */ static int /* BSD version */ @@ -2620,15 +2388,12 @@ create_ring(softc_t *sc, struct desc_ring *ring, int num_descs) return EINVAL; } -#ifdef __FreeBSD__ /* Create a DMA tag for descriptors and buffers. */ if ((error = bus_dma_tag_create(bus_get_dma_tag(sc->dev), 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, PAGE_SIZE, 2, PAGE_SIZE, BUS_DMA_ALLOCNOW, -# if (__FreeBSD_version >= 502000) NULL, NULL, -# endif &ring->tag))) { printf("%s: bus_dma_tag_create() failed: error %d\n", NAME_UNIT, error); @@ -2662,70 +2427,6 @@ create_ring(softc_t *sc, struct desc_ring *ring, int num_descs) return error; } -#elif (defined(__NetBSD__) || defined(__OpenBSD__)) - - /* Use the DMA tag passed to attach() for descriptors and buffers. */ - ring->tag = sc->pa_dmat; - - /* Allocate wired physical memory for DMA descriptor array. */ - if ((error = bus_dmamem_alloc(ring->tag, size_descs, PAGE_SIZE, 0, - ring->segs, 1, &ring->nsegs, BUS_DMA_NOWAIT))) - { - printf("%s: bus_dmamem_alloc() failed; error %d\n", NAME_UNIT, error); - return error; - } - - /* Map physical address to kernel virtual address. */ - if ((error = bus_dmamem_map(ring->tag, ring->segs, ring->nsegs, - size_descs, (caddr_t *)&ring->first, BUS_DMA_NOWAIT | BUS_DMA_COHERENT))) - { - printf("%s: bus_dmamem_map() failed; error %d\n", NAME_UNIT, error); - return error; - } - descs = ring->first; /* suppress compiler warning about aliasing */ - memset(descs, 0, size_descs); - - /* Allocate dmamap for PCI access to DMA descriptor array. */ - if ((error = bus_dmamap_create(ring->tag, size_descs, 1, - size_descs, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &ring->map))) - { - printf("%s: bus_dmamap_create() failed; error %d\n", NAME_UNIT, error); - return error; - } - - /* Map kernel virtual address to PCI address for DMA descriptor array. */ - if ((error = bus_dmamap_load(ring->tag, ring->map, descs, size_descs, - 0, BUS_DMA_NOWAIT))) - { - printf("%s: bus_dmamap_load() failed; error %d\n", NAME_UNIT, error); - return error; - } - ring->dma_addr = ring->map->dm_segs[0].ds_addr; - - /* Allocate dmamaps for each DMA descriptor. */ - for (i=0; itag, MAX_DESC_LEN, 2, - MAX_CHUNK_LEN, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &descs[i].map))) - { - printf("%s: bus_dmamap_create() failed; error %d\n", NAME_UNIT, error); - return error; - } - -#elif defined(__bsdi__) - - /* Allocate wired physical memory for DMA descriptor array. */ - if ((ring->first = malloc(size_descs, M_DEVBUF, M_NOWAIT)) == NULL) - { - printf("%s: malloc() failed for DMA descriptor array\n", NAME_UNIT); - return ENOMEM; - } - descs = ring->first; - memset(descs, 0, size_descs); - - /* Map kernel virtual address to PCI address for DMA descriptor array. */ - ring->dma_addr = vtophys(descs); /* Relax! BSD/OS only. */ - -#endif ring->read = descs; ring->write = descs; @@ -2765,7 +2466,6 @@ destroy_ring(softc_t *sc, struct desc_ring *ring) if (ring->read++ == ring->last) ring->read = ring->first; } -#ifdef __FreeBSD__ /* Free the dmamaps of all DMA descriptors. */ for (desc=ring->first; desc!=ring->last+1; desc++) @@ -2782,33 +2482,6 @@ destroy_ring(softc_t *sc, struct desc_ring *ring) if (ring->tag != NULL) bus_dma_tag_destroy(ring->tag); -#elif (defined(__NetBSD__) || defined(__OpenBSD__)) - - /* Free the dmamaps of all DMA descriptors. */ - for (desc=ring->first; desc!=ring->last+1; desc++) - if (desc->map != NULL) - bus_dmamap_destroy(ring->tag, desc->map); - - /* Unmap PCI address for DMA descriptor array. */ - if (ring->dma_addr != 0) - bus_dmamap_unload(ring->tag, ring->map); - /* Free dmamap for DMA descriptor array. */ - if (ring->map != NULL) - bus_dmamap_destroy(ring->tag, ring->map); - /* Unmap kernel address for DMA descriptor array. */ - if (ring->first != NULL) - bus_dmamem_unmap(ring->tag, (caddr_t)ring->first, ring->size_descs); - /* Free kernel memory for DMA descriptor array. */ - if (ring->segs[0].ds_addr != 0) - bus_dmamem_free(ring->tag, ring->segs, ring->nsegs); - -#elif defined(__bsdi__) - - /* Free kernel memory for DMA descriptor array. */ - if (ring->first != NULL) - free(ring->first, M_DEVBUF); - -#endif } /* Clean up after a packet has been received. */ @@ -2821,7 +2494,7 @@ rxintr_cleanup(softc_t *sc) struct mbuf *new_mbuf; int pkt_len, desc_len; -#if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) +#if defined(DEVICE_POLLING) /* Input packet flow control (livelock prevention): */ /* Give pkts to higher levels only if quota is > 0. */ if (sc->quota <= 0) return 0; @@ -2890,11 +2563,7 @@ rxintr_cleanup(softc_t *sc) { first_mbuf = new_mbuf; first_mbuf->m_pkthdr.len = pkt_len; /* total pkt length */ -#if IFNET first_mbuf->m_pkthdr.rcvif = sc->ifp; /* how it got here */ -#else - first_mbuf->m_pkthdr.rcvif = NULL; -#endif } else /* 2) link mbufs. */ { @@ -2933,11 +2602,9 @@ rxintr_cleanup(softc_t *sc) /* Include CRC and one flag byte in input byte count. */ sc->status.cntrs.ibytes += first_mbuf->m_pkthdr.len + sc->config.crc_len +1; sc->status.cntrs.ipackets++; -#if IFNET - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); LMC_BPF_MTAP(first_mbuf); -#endif -#if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) +#if defined(DEVICE_POLLING) sc->quota--; #endif @@ -2945,12 +2612,8 @@ rxintr_cleanup(softc_t *sc) #if NETGRAPH if (sc->ng_hook != NULL) /* is hook connected? */ { -# if (__FreeBSD_version >= 500000) int error; /* ignore error */ NG_SEND_DATA_ONLY(error, sc->ng_hook, first_mbuf); -# else /* FreeBSD-4 */ - ng_queue_data(sc->ng_hook, first_mbuf, NULL); -# endif return 1; /* did something */ } #endif /* NETGRAPH */ @@ -3053,13 +2716,7 @@ rxintr_setup(softc_t *sc) DMA_SYNC(desc->map, desc_len, BUS_DMASYNC_PREREAD); /* Set up the DMA descriptor. */ -#ifdef __FreeBSD__ desc->address1 = ring->segs[0].ds_addr; -#elif (defined(__NetBSD__) || defined(__OpenBSD__)) - desc->address1 = desc->map->dm_segs[0].ds_addr; -#elif defined(__bsdi__) - desc->address1 = vtophys(m->m_data); /* Relax! BSD/OS only. */ -#endif desc->length1 = desc_len>>1; desc->address2 = desc->address1 + desc->length1; desc->length2 = desc_len>>1; @@ -3108,10 +2765,8 @@ txintr_cleanup(softc_t *sc) /* Include CRC and one flag byte in output byte count. */ sc->status.cntrs.obytes += m->m_pkthdr.len + sc->config.crc_len +1; sc->status.cntrs.opackets++; -#if IFNET - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); LMC_BPF_MTAP(m); -#endif /* The only bad TX status is fifo underrun. */ if ((desc->status & TLP_DSTS_TX_UNDERRUN) != 0) sc->status.cntrs.fifo_under++; @@ -3181,15 +2836,9 @@ txintr_setup_mbuf(softc_t *sc, struct mbuf *m) /* Prevent wild fetches if mapping fails (nsegs==0). */ desc->length1 = desc->length2 = 0; desc->address1 = desc->address2 = 0; -#if (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) { -# ifdef __FreeBSD__ bus_dma_segment_t *segs = ring->segs; int nsegs = ring->nsegs; -# elif (defined(__NetBSD__) || defined(__OpenBSD__)) - bus_dma_segment_t *segs = desc->map->dm_segs; - int nsegs = desc->map->dm_nsegs; -# endif if (nsegs >= 1) { desc->address1 = segs[0].ds_addr; @@ -3201,10 +2850,6 @@ txintr_setup_mbuf(softc_t *sc, struct mbuf *m) desc->length2 = segs[1].ds_len; } } -#elif defined(__bsdi__) - desc->address1 = vtophys(data); /* Relax! BSD/OS only. */ - desc->length1 = desc_len; -#endif data += desc_len; length -= desc_len; @@ -3296,523 +2941,7 @@ txintr_setup(softc_t *sc) return 1; /* did something */ } -#endif /* BSD */ -#ifdef __linux__ -/* NOTE: this is the LINUX version of the interrupt/DMA code, */ - -/* Singly-linked tail-queues hold sk_buffs with active DMA. - * skbuffs are linked through their sk_buff.next field. - * Callers must hold sc->bottom_lock; not otherwise locked. - */ - -/* Put an skbuff on the tail of the descriptor ring queue. */ -static void /* Linux version */ -skbuff_enqueue(struct desc_ring *ring, struct sk_buff *skb) - { - skb->next = NULL; - if (ring->tail == NULL) - ring->head = skb; - else - ring->tail->next = skb; - ring->tail = skb; - } - -/* Get an skbuff from the head of the descriptor ring queue. */ -static struct sk_buff* /* Linux version */ -skbuff_dequeue(struct desc_ring *ring) - { - struct sk_buff *skb = ring->head; - if (skb != NULL) - if ((ring->head = skb->next) == NULL) - ring->tail = NULL; - return skb; - } - -/* Initialize a DMA descriptor ring. */ -static int /* Linux version */ -create_ring(softc_t *sc, struct desc_ring *ring, int num_descs) - { - struct dma_desc *descs; - int size_descs = sizeof(struct dma_desc)*num_descs; - - /* Allocate and map memory for DMA descriptor array. */ - if ((descs = pci_alloc_consistent(sc->pci_dev, size_descs, - &ring->dma_addr)) == NULL) - { - printk("%s: pci_alloc_consistent() failed\n", NAME_UNIT); - return ENOMEM; - } - memset(descs, 0, size_descs); - - ring->read = descs; - ring->write = descs; - ring->first = descs; - ring->last = descs + num_descs -1; - ring->last->control = TLP_DCTL_END_RING; - ring->num_descs = num_descs; - ring->size_descs = size_descs; - ring->head = NULL; - ring->tail = NULL; - - return 0; - } - -/* Destroy a DMA descriptor ring */ -static void /* Linux version */ -destroy_ring(softc_t *sc, struct desc_ring *ring) - { - struct sk_buff *skb; - - /* Free queued skbuffs. */ - while ((skb = skbuff_dequeue(ring)) != NULL) - dev_kfree_skb(skb); - - /* TX may have one pkt that is not on any queue. */ - if (sc->tx_skb != NULL) - { - dev_kfree_skb(sc->tx_skb); - sc->tx_skb = NULL; - } - - if (ring->first != NULL) - { - /* Unmap active DMA descriptors. */ - while (ring->read != ring->write) - { - pci_unmap_single(sc->pci_dev, ring->read->address1, - ring->read->length1 + ring->read->length2, PCI_DMA_BIDIRECTIONAL); - if (ring->read++ == ring->last) ring->read = ring->first; - } - - /* Unmap and free memory for DMA descriptor array. */ - pci_free_consistent(sc->pci_dev, ring->size_descs, ring->first, - ring->dma_addr); - } - } - -static int /* Linux version */ -rxintr_cleanup(softc_t *sc) - { - struct desc_ring *ring = &sc->rxring; - struct dma_desc *first_desc, *last_desc; - struct sk_buff *first_skb=NULL, *last_skb=NULL; - struct sk_buff *new_skb; - int pkt_len, desc_len; - - /* Input packet flow control (livelock prevention): */ - /* Give pkts to higher levels only if quota is > 0. */ - if (sc->quota <= 0) return 0; - - /* This looks complicated, but remember: packets up to 4032 */ - /* bytes long fit in one skbuff and use one DMA descriptor. */ - - first_desc = last_desc = ring->read; - - /* ASSERTION: If there is a descriptor in the ring and the hardware has */ - /* finished with it, then that descriptor will have RX_FIRST_DESC set. */ - if ((ring->read != ring->write) && /* descriptor ring not empty */ - ((ring->read->status & TLP_DSTS_OWNER) == 0) && /* hardware done */ - ((ring->read->status & TLP_DSTS_RX_FIRST_DESC) == 0)) /* should be set */ - panic("%s: rxintr_cleanup: rx-first-descriptor not set.\n", NAME_UNIT); - - /* First decide if a complete packet has arrived. */ - /* Run down DMA descriptors looking for one marked "last". */ - /* Bail out if an active descriptor is encountered. */ - /* Accumulate most significant bits of packet length. */ - pkt_len = 0; - for (;;) - { - if (last_desc == ring->write) return 0; /* no more descs */ - if (last_desc->status & TLP_DSTS_OWNER) return 0; /* still active */ - if (last_desc->status & TLP_DSTS_RX_LAST_DESC) break; /* end of packet */ - pkt_len += last_desc->length1 + last_desc->length2; /* entire desc filled */ - if (last_desc++->control & TLP_DCTL_END_RING) last_desc = ring->first; /* ring wrap */ - } - - /* A complete packet has arrived; how long is it? */ - /* H/w ref man shows RX pkt length as a 14-bit field. */ - /* An experiment found that only the 12 LSBs work. */ - if (((last_desc->status>>16)&0xFFF) == 0) pkt_len += 4096; /* carry-bit */ - pkt_len = (pkt_len & 0xF000) + ((last_desc->status>>16) & 0x0FFF); - /* Subtract the CRC length unless doing so would underflow. */ - if (pkt_len >= sc->config.crc_len) pkt_len -= sc->config.crc_len; - - /* Run down DMA descriptors again doing the following: - * 1) put pkt info in hdr of first skbuff. - * 2) put additional skbuffs on frag_list. - * 3) set skbuff lengths. - */ - first_desc = ring->read; - do - { - /* Read a DMA descriptor from the ring. */ - last_desc = ring->read; - /* Advance the ring read pointer. */ - if (ring->read++ == ring->last) ring->read = ring->first; - - /* Dequeue the corresponding skbuff. */ - new_skb = skbuff_dequeue(ring); - if (new_skb == NULL) - panic("%s: rxintr_cleanup: expected an skbuff\n", NAME_UNIT); - - desc_len = last_desc->length1 + last_desc->length2; - /* Unmap kernel virtual addresss to PCI address. */ - pci_unmap_single(sc->pci_dev, last_desc->address1, - desc_len, PCI_DMA_FROMDEVICE); - - /* Set skbuff length. */ - skb_put(new_skb, (pkt_len >= desc_len) ? desc_len : pkt_len); - pkt_len -= new_skb->len; - - /* 1) Put pkt info in hdr of first skbuff. */ - if (last_desc == first_desc) - { - first_skb = new_skb; - if (sc->config.line_pkg == PKG_RAWIP) - { - if (first_skb->data[0]>>4 == 4) - first_skb->protocol = htons(ETH_P_IP); - else if (first_skb->data[0]>>4 == 6) - first_skb->protocol = htons(ETH_P_IPV6); - } - else -#if GEN_HDLC - first_skb->protocol = hdlc_type_trans(first_skb, sc->net_dev); -#else - first_skb->protocol = htons(ETH_P_HDLC); -#endif - first_skb->mac.raw = first_skb->data; - first_skb->dev = sc->net_dev; - do_gettimeofday(&first_skb->stamp); - sc->net_dev->last_rx = jiffies; - } - else /* 2) link skbuffs. */ - { - /* Put this skbuff on the frag_list of the first skbuff. */ - new_skb->next = NULL; - if (skb_shinfo(first_skb)->frag_list == NULL) - skb_shinfo(first_skb)->frag_list = new_skb; - else - last_skb->next = new_skb; - /* 3) set skbuff lengths. */ - first_skb->len += new_skb->len; - first_skb->data_len += new_skb->len; - } - last_skb = new_skb; - } while ((last_desc->status & TLP_DSTS_RX_LAST_DESC) == 0); - - /* Decide whether to accept or to discard this packet. */ - /* RxHDLC sets MIIERR for bad CRC, abort and partial byte at pkt end. */ - if (((last_desc->status & TLP_DSTS_RX_BAD) == 0) && - (sc->status.oper_status == STATUS_UP) && - (first_skb->len > 0)) - { - /* Optimization: copy a small pkt into a small skbuff. */ - if (first_skb->len <= COPY_BREAK) - if ((new_skb = skb_copy(first_skb, GFP_ATOMIC)) != NULL) - { - dev_kfree_skb_any(first_skb); - first_skb = new_skb; - } - - /* Include CRC and one flag byte in input byte count. */ - sc->status.cntrs.ibytes += first_skb->len + sc->config.crc_len +1; - sc->status.cntrs.ipackets++; - - /* Give this good packet to the network stacks. */ - netif_receive_skb(first_skb); /* NAPI */ - sc->quota--; - } - else if (sc->status.oper_status != STATUS_UP) - { - /* If the link is down, this packet is probably noise. */ - sc->status.cntrs.idiscards++; - dev_kfree_skb_any(first_skb); - if (DRIVER_DEBUG) - printk("%s: rxintr_cleanup: rx pkt discarded: link down\n", NAME_UNIT); - } - else /* Log and discard this bad packet. */ - { - if (DRIVER_DEBUG) - printk("%s: RX bad pkt; len=%d %s%s%s%s\n", - NAME_UNIT, first_skb->len, - (last_desc->status & TLP_DSTS_RX_MII_ERR) ? " miierr" : "", - (last_desc->status & TLP_DSTS_RX_DRIBBLE) ? " dribble" : "", - (last_desc->status & TLP_DSTS_RX_DESC_ERR) ? " descerr" : "", - (last_desc->status & TLP_DSTS_RX_OVERRUN) ? " overrun" : ""); - if (last_desc->status & TLP_DSTS_RX_OVERRUN) - sc->status.cntrs.fifo_over++; - else - sc->status.cntrs.ierrors++; - dev_kfree_skb_any(first_skb); - } - - return 1; /* did something */ - } - -/* Setup (prepare) to receive a packet. */ -/* Try to keep the RX descriptor ring full of empty buffers. */ -static int /* Linux version */ -rxintr_setup(softc_t *sc) - { - struct desc_ring *ring = &sc->rxring; - struct dma_desc *desc; - struct sk_buff *skb; - u_int32_t dma_addr; - - /* Ring is full if (wrap(write+1)==read) */ - if (((ring->write == ring->last) ? ring->first : ring->write+1) == ring->read) - return 0; /* ring is full; nothing to do */ - - /* Allocate an skbuff. */ - if ((skb = dev_alloc_skb(MAX_DESC_LEN)) == NULL) - { - sc->status.cntrs.rxdma++; - if (DRIVER_DEBUG) - printk("%s: rxintr_setup: dev_alloc_skb() failed\n", NAME_UNIT); - return 0; - } - skb->dev = sc->net_dev; - - /* Queue the skbuff for later processing by rxintr_cleanup. */ - skbuff_enqueue(ring, skb); - - /* Write a DMA descriptor into the ring. */ - /* Hardware won't see it until the OWNER bit is set. */ - desc = ring->write; - /* Advance the ring write pointer. */ - if (ring->write++ == ring->last) ring->write = ring->first; - - /* Map kernel virtual addresses to PCI addresses. */ - dma_addr = pci_map_single(sc->pci_dev, skb->data, - MAX_DESC_LEN, PCI_DMA_FROMDEVICE); - /* Set up the DMA descriptor. */ - desc->address1 = dma_addr; - desc->length1 = MAX_CHUNK_LEN; - desc->address2 = desc->address1 + desc->length1; - desc->length2 = MAX_CHUNK_LEN; - - /* Before setting the OWNER bit, flush the cache (memory barrier). */ - wmb(); /* write memory barrier */ - - /* Commit the DMA descriptor to the hardware. */ - desc->status = TLP_DSTS_OWNER; - - /* Notify the receiver that there is another buffer available. */ - WRITE_CSR(TLP_RX_POLL, 1); - - return 1; /* did something */ - } - -/* Clean up after a packet has been transmitted. */ -/* Free the sk_buff and update the DMA descriptor ring. */ -static int /* Linux version */ -txintr_cleanup(softc_t *sc) - { - struct desc_ring *ring = &sc->txring; - struct dma_desc *desc; - - while ((ring->read != ring->write) && /* ring is not empty */ - ((ring->read->status & TLP_DSTS_OWNER) == 0)) - { - /* Read a DMA descriptor from the ring. */ - desc = ring->read; - /* Advance the ring read pointer. */ - if (ring->read++ == ring->last) ring->read = ring->first; - /* Unmap kernel virtual address to PCI address. */ - pci_unmap_single(sc->pci_dev, desc->address1, - desc->length1 + desc->length2, PCI_DMA_TODEVICE); - - /* If this descriptor is the last segment of a packet, */ - /* then dequeue and free the corresponding skbuff. */ - if ((desc->control & TLP_DCTL_TX_LAST_SEG) != 0) - { - struct sk_buff *skb; - if ((skb = skbuff_dequeue(ring)) == NULL) - panic("%s: txintr_cleanup: expected an sk_buff\n", NAME_UNIT); - - /* Include CRC and one flag byte in output byte count. */ - sc->status.cntrs.obytes += skb->len + sc->config.crc_len +1; - sc->status.cntrs.opackets++; - - /* The only bad TX status is fifo underrun. */ - if ((desc->status & TLP_DSTS_TX_UNDERRUN) != 0) - { - sc->status.cntrs.fifo_under++; /* also increment oerrors? */ - if (DRIVER_DEBUG) - printk("%s: txintr_cleanup: tx fifo underrun\n", NAME_UNIT); - } - - dev_kfree_skb_any(skb); - return 1; /* did something */ - } - } - - return 0; - } - -/* Build DMA descriptors for a tranmit packet fragment, */ -/* Assertion: fragment is contiguous in physical memory. */ -static int /* 0=success; 1=error */ /* linux version */ -txintr_setup_frag(softc_t *sc, char *data, int length) - { - struct desc_ring *ring = &sc->txring; - struct dma_desc *desc; - unsigned int desc_len; - u_int32_t dma_addr; - - while (length > 0) - { - /* Ring is full if (wrap(write+1)==read) */ - if (((ring->temp==ring->last) ? ring->first : ring->temp+1) == ring->read) - { /* Not enough DMA descriptors; try later. */ - for (; ring->temp!=ring->write; - ring->temp = (ring->temp==ring->first)? ring->last : ring->temp-1) - pci_unmap_single(sc->pci_dev, ring->temp->address1, - ring->temp->length1 + ring->temp->length2, PCI_DMA_FROMDEVICE); - sc->status.cntrs.txdma++; - return 1; - } - - /* Provisionally, write a DMA descriptor into the ring. */ - /* But don't change the REAL ring write pointer. */ - /* Hardware won't see it until the OWNER bit is set. */ - desc = ring->temp; - /* Advance the temporary ring write pointer. */ - if (ring->temp++ == ring->last) ring->temp = ring->first; - - /* Clear all control bits except the END_RING bit. */ - desc->control &= TLP_DCTL_END_RING; - /* Don't pad short packets up to 64 bytes */ - desc->control |= TLP_DCTL_TX_NO_PAD; - /* Use Tulip's CRC-32 generator, if appropriate. */ - if (sc->config.crc_len != CFG_CRC_32) - desc->control |= TLP_DCTL_TX_NO_CRC; - /* Set the OWNER bit, except in the first descriptor. */ - if (desc != ring->write) - desc->status = TLP_DSTS_OWNER; - - desc_len = (length >= MAX_DESC_LEN) ? MAX_DESC_LEN : length; - /* Map kernel virtual address to PCI address. */ - dma_addr = pci_map_single(sc->pci_dev, data, desc_len, PCI_DMA_TODEVICE); - /* If it will fit in one chunk, do so, otherwise split it. */ - if (desc_len <= MAX_CHUNK_LEN) - { - desc->address1 = dma_addr; - desc->length1 = desc_len; - desc->address2 = 0; - desc->length2 = 0; - } - else - { - desc->address1 = dma_addr; - desc->length1 = desc_len>>1; - desc->address2 = desc->address1 + desc->length1; - desc->length2 = desc_len>>1; - if (desc_len & 1) desc->length2++; - } - - data += desc_len; - length -= desc_len; - } /* while (length > 0) */ - - return 0; /* success */ - } - -/* NB: this procedure is recursive! */ -static int /* 0=success; 1=error */ -txintr_setup_skb(softc_t *sc, struct sk_buff *skb) - { - struct sk_buff *list; - int i; - - /* First, handle the data in the skbuff itself. */ - if (txintr_setup_frag(sc, skb->data, skb_headlen(skb))) - return 1; - - /* Next, handle the VM pages in the Scatter/Gather list. */ - if (skb_shinfo(skb)->nr_frags != 0) - for (i=0; inr_frags; i++) - { - skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - if (txintr_setup_frag(sc, page_address(frag->page) + - frag->page_offset, frag->size)) - return 1; - } - - /* Finally, handle the skbuffs in the frag_list. */ - if ((list = skb_shinfo(skb)->frag_list) != NULL) - for (; list; list=list->next) - if (txintr_setup_skb(sc, list)) /* recursive! */ - return 1; - - return 0; - } - -/* Setup (prepare) to transmit a packet. */ -/* Select a packet, build DMA descriptors and give packet to hardware. */ -/* If DMA descriptors run out, abandon the attempt and return 0. */ -static int /* Linux version */ -txintr_setup(softc_t *sc) - { - struct desc_ring *ring = &sc->txring; - struct dma_desc *first_desc, *last_desc; - - /* Protect against half-up links: Don't transmit */ - /* if the receiver can't hear the far end. */ - if (sc->status.oper_status != STATUS_UP) return 0; - - /* Pick a packet to transmit. */ - /* linux_start() puts packets in sc->tx_skb. */ - if (sc->tx_skb == NULL) - { - if (netif_queue_stopped(sc->net_dev) != 0) - netif_wake_queue(sc->net_dev); - return 0; /* no pkt to transmit */ - } - - /* Build DMA descriptors for an outgoing skbuff. */ - ring->temp = ring->write; /* temporary ring write pointer */ - if (txintr_setup_skb(sc, sc->tx_skb) != 0) return 0; - - /* Enqueue the skbuff; txintr_cleanup will free it. */ - skbuff_enqueue(ring, sc->tx_skb); - - /* The transmitter has room for another packet. */ - sc->tx_skb = NULL; - - /* Set first & last segment bits. */ - /* last_desc is the desc BEFORE the one pointed to by ring->temp. */ - first_desc = ring->write; - first_desc->control |= TLP_DCTL_TX_FIRST_SEG; - last_desc = (ring->temp==ring->first)? ring->last : ring->temp-1; - last_desc->control |= TLP_DCTL_TX_LAST_SEG; - /* Interrupt at end-of-transmission? Why bother the poor computer! */ -/* last_desc->control |= TLP_DCTL_TX_INTERRUPT; */ - - /* Make sure the OWNER bit is not set in the next descriptor. */ - /* The OWNER bit may have been set if a previous call aborted. */ - ring->temp->status = 0; - - /* Commit the DMA descriptors to the software. */ - ring->write = ring->temp; - - /* Before setting the OWNER bit, flush the cache (memory barrier). */ - wmb(); /* write memory barrier */ - - /* Commit the DMA descriptors to the hardware. */ - first_desc->status = TLP_DSTS_OWNER; - - /* Notify the transmitter that there is another packet to send. */ - WRITE_CSR(TLP_TX_POLL, 1); - - sc->net_dev->trans_start = jiffies; - - return 1; /* did something */ - } - -#endif /* __linux__ */ static void check_intr_status(softc_t *sc) @@ -3914,7 +3043,6 @@ core_interrupt(void *arg, int check_status) /* In Linux, pci_alloc_consistent() means DMA descriptors */ /* don't need explicit syncing. */ -#if BSD { struct desc_ring *ring = &sc->txring; DMA_SYNC(sc->txring.map, sc->txring.size_descs, @@ -3923,7 +3051,6 @@ core_interrupt(void *arg, int check_status) DMA_SYNC(sc->rxring.map, sc->rxring.size_descs, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); } -#endif do /* This is the main loop for interrupt processing. */ { @@ -3933,7 +3060,6 @@ core_interrupt(void *arg, int check_status) activity += rxintr_setup(sc); } while (activity); -#if BSD { struct desc_ring *ring = &sc->txring; DMA_SYNC(sc->txring.map, sc->txring.size_descs, @@ -3942,7 +3068,6 @@ core_interrupt(void *arg, int check_status) DMA_SYNC(sc->rxring.map, sc->rxring.size_descs, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } -#endif /* As the interrupt is dismissed, check for four unusual events. */ if (check_status) check_intr_status(sc); @@ -3959,9 +3084,8 @@ user_interrupt(softc_t *sc, int check_status) ENABLE_INTR; /* noop on FreeBSD-5 and Linux */ } -#if BSD -# if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) +# if defined(DEVICE_POLLING) /* Service the card from the kernel idle loop without interrupts. */ static int @@ -3969,27 +3093,13 @@ fbsd_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) { softc_t *sc = IFP2SC(ifp); -#if (__FreeBSD_version < 700000) - if ((ifp->if_capenable & IFCAP_POLLING) == 0) - { - ether_poll_deregister(ifp); - cmd = POLL_DEREGISTER; - } - - if (cmd == POLL_DEREGISTER) - { - /* Last call -- reenable card interrupts. */ - WRITE_CSR(TLP_INT_ENBL, TLP_INT_TXRX); - return 0; - } -#endif sc->quota = count; core_interrupt(sc, (cmd==POLL_AND_CHECK_STATUS)); return 0; } -# endif /* (__FreeBSD__ && DEVICE_POLLING) */ +# endif /* DEVICE_POLLING */ /* BSD kernels call this procedure when an interrupt happens. */ static intr_return_t @@ -4001,7 +3111,7 @@ bsd_interrupt(void *arg) if ((READ_CSR(TLP_STATUS) & TLP_INT_TXRX) == 0) return IRQ_NONE; -# if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) +# if defined(DEVICE_POLLING) if (sc->ifp->if_capenable & IFCAP_POLLING) return IRQ_NONE; @@ -4013,7 +3123,7 @@ bsd_interrupt(void *arg) } else sc->quota = sc->rxring.num_descs; /* input flow control */ -# endif /* (__FreeBSD__ && DEVICE_POLLING) */ +# endif /* DEVICE_POLLING */ /* Disable card interrupts. */ WRITE_CSR(TLP_INT_ENBL, TLP_INT_DISABLE); @@ -4026,7 +3136,6 @@ bsd_interrupt(void *arg) return IRQ_HANDLED; } -#endif /* BSD */ /* Administrative status of the driver (UP or DOWN) has changed. */ /* A card-specific action may be required: T1 and T3 cards: no-op. */ @@ -4081,12 +3190,8 @@ p2p_mdmctl(struct p2pcom *p2p, int flag) static void sppp_tls(struct sppp *sppp) { -# ifdef __FreeBSD__ if (!(sppp->pp_mode & IFF_LINK2) && !(sppp->pp_flags & PP_FR)) -# elif defined(__NetBSD__) || defined(__OpenBSD__) - if (!(sppp->pp_flags & PP_CISCO)) -# endif sppp->pp_up(sppp); } @@ -4094,12 +3199,8 @@ sppp_tls(struct sppp *sppp) static void sppp_tlf(struct sppp *sppp) { -# ifdef __FreeBSD__ if (!(sppp->pp_mode & IFF_LINK2) && !(sppp->pp_flags & PP_FR)) -# elif defined(__NetBSD__) || defined(__OpenBSD__) - if (!(sppp->pp_flags & PP_CISCO)) -# endif sppp->pp_down(sppp); } @@ -4193,12 +3294,8 @@ config_proto(softc_t *sc, struct config *config) (config->line_prot == PROT_PPP)) { LMC_BPF_DETACH; -# if (defined(__NetBSD__) || defined(__OpenBSD__)) - sc->sppp->pp_flags &= ~PP_CISCO; -# elif defined(__FreeBSD__) sc->ifp->if_flags &= ~IFF_LINK2; sc->sppp->pp_flags &= ~PP_FR; -# endif LMC_BPF_ATTACH(DLT_PPP, 4); sppp_ioctl(sc->ifp, SIOCSIFFLAGS, NULL); } @@ -4212,12 +3309,8 @@ config_proto(softc_t *sc, struct config *config) (config->line_prot == PROT_C_HDLC)) { LMC_BPF_DETACH; -# if (defined(__NetBSD__) || defined(__OpenBSD__)) - sc->sppp->pp_flags |= PP_CISCO; -# elif defined(__FreeBSD__) sc->ifp->if_flags |= IFF_LINK2; sc->sppp->pp_flags &= ~PP_FR; -# endif LMC_BPF_ATTACH(DLT_C_HDLC, 4); sppp_ioctl(sc->ifp, SIOCSIFFLAGS, NULL); } @@ -4227,12 +3320,8 @@ config_proto(softc_t *sc, struct config *config) (config->line_prot == PROT_FRM_RLY)) { LMC_BPF_DETACH; -# if (defined(__NetBSD__) || defined(__OpenBSD__)) - sc->sppp->pp_flags &= ~PP_CISCO; -# elif defined(__FreeBSD__) sc->ifp->if_flags &= ~IFF_LINK2; sc->sppp->pp_flags |= PP_FR; -# endif LMC_BPF_ATTACH(DLT_FRELAY, 4); sppp_ioctl(sc->ifp, SIOCSIFFLAGS, NULL); } @@ -4468,7 +3557,6 @@ core_watchdog(softc_t *sc) user_interrupt(sc, 1); } -#if IFNET /* Called from a syscall (user context; no spinlocks). */ static int @@ -4479,16 +3567,8 @@ lmc_raw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) switch (cmd) { -# if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) /* XXX necessary? */ - case SIOCSIFCAP: -# endif case SIOCAIFADDR: case SIOCSIFFLAGS: -#if 0 - case SIOCADDMULTI: - case SIOCDELMULTI: - break; -#endif case SIOCSIFADDR: ifp->if_flags |= IFF_UP; /* a Unix tradition */ break; @@ -4507,9 +3587,6 @@ static int lmc_ifnet_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { softc_t *sc = IFP2SC(ifp); -# ifdef __OpenBSD__ - struct ifreq *ifr = (struct ifreq *) data; -# endif int error = 0; switch (cmd) @@ -4523,34 +3600,6 @@ lmc_ifnet_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case LMCIOCTL: error = core_ioctl(sc, cmd, data); break; -# ifdef __OpenBSD__ - /* Catch the IOCTLs used by ifconfig. */ - case SIOCSIFMEDIA: - if ((error = CHECK_CAP)) break; - case SIOCGIFMEDIA: - error = ifmedia_ioctl(ifp, ifr, &sc->ifm, cmd); - break; - case SIOCSIFTIMESLOT: - if ((error = CHECK_CAP)) break; - if (sc->status.card_type == TLP_CSID_T1E1) - { - struct config config = sc->config; - if ((error = copyin(ifr->ifr_data, &config.time_slots, - sizeof config.time_slots))) break; - config.iohdr.cookie = NGM_LMC_COOKIE; - error = core_ioctl(sc, LMCIOCSCFG, (caddr_t)&config); - } - else - error = EINVAL; - break; - case SIOCGIFTIMESLOT: - if (sc->status.card_type == TLP_CSID_T1E1) - error = copyout(&sc->config.time_slots, ifr->ifr_data, - sizeof sc->config.time_slots); - else - error = EINVAL; - break; -# endif /* Pass the rest to the line protocol. */ default: if (sc->config.line_pkg == PKG_RAWIP) @@ -4621,11 +3670,7 @@ lmc_raw_output(struct ifnet *ifp, struct mbuf *m, /* Some BSD QUEUE routines are not interrupt-safe. */ { DISABLE_INTR; -# if (__FreeBSD_version >= 503000) IFQ_ENQUEUE(&ifp->if_snd, m, error); -# else - IFQ_ENQUEUE(&ifp->if_snd, m, NULL, error); -# endif ENABLE_INTR; } @@ -4635,6 +3680,7 @@ lmc_raw_output(struct ifnet *ifp, struct mbuf *m, { m_freem(m); sc->status.cntrs.odiscards++; + if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); if (DRIVER_DEBUG) printf("%s: lmc_raw_output: IFQ_ENQUEUE() failed; error %d\n", NAME_UNIT, error); @@ -4646,11 +3692,10 @@ lmc_raw_output(struct ifnet *ifp, struct mbuf *m, /* Called from a softirq once a second. */ static void lmc_watchdog(void *arg) - { +{ struct ifnet *ifp = arg; softc_t *sc = IFP2SC(ifp); u_int8_t old_oper_status = sc->status.oper_status; - struct event_cntrs *cntrs = &sc->status.cntrs; core_watchdog(sc); /* updates oper_status */ @@ -4703,13 +3748,9 @@ lmc_watchdog(void *arg) /* Notice change in line protocol. */ sc->status.line_pkg = PKG_SPPP; -# ifdef __FreeBSD__ if (sc->sppp->pp_flags & PP_FR) sc->status.line_prot = PROT_FRM_RLY; else if (sc->ifp->if_flags & IFF_LINK2) -# elif (defined(__NetBSD__) || defined(__OpenBSD__)) - if (sc->sppp->pp_flags & PP_CISCO) -# endif sc->status.line_prot = PROT_C_HDLC; else sc->status.line_prot = PROT_PPP; @@ -4720,98 +3761,44 @@ lmc_watchdog(void *arg) # endif } - /* Copy statistics from sc to ifp. */ ifp->if_baudrate = sc->status.tx_speed; - ifp->if_ipackets = cntrs->ipackets; - ifp->if_opackets = cntrs->opackets; - ifp->if_ibytes = cntrs->ibytes; - ifp->if_obytes = cntrs->obytes; - ifp->if_ierrors = cntrs->ierrors; - ifp->if_oerrors = cntrs->oerrors; - ifp->if_iqdrops = cntrs->idiscards; - -# if ((__FreeBSD_version >= 500000) || defined(__OpenBSD__) || defined(__NetBSD__)) if (sc->status.oper_status == STATUS_UP) ifp->if_link_state = LINK_STATE_UP; else ifp->if_link_state = LINK_STATE_DOWN; -# endif /* Call this procedure again after one second. */ callout_reset(&sc->callout, hz, lmc_watchdog, ifp); - } +} -# ifdef __OpenBSD__ +static uint64_t +lmc_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + softc_t *sc; + struct event_cntrs *cntrs; -/* Callback from ifmedia. */ -static int -ifmedia_change(struct ifnet *ifp) - { - softc_t *sc = IFP2SC(ifp); - struct config config = sc->config; - int media = sc->ifm.ifm_media; - int error; + sc = if_getsoftc(ifp); + cntrs = &sc->status.cntrs; - /* ifconfig lmc0 media t1 */ - if (sc->status.card_type == TLP_CSID_T3) - { - if ((media & IFM_TMASK) == IFM_TDM_T3) - config.format = CFG_FORMAT_T3CPAR; - else if ((media & IFM_TMASK) == IFM_TDM_T3_M13) - config.format = CFG_FORMAT_T3M13; - } - else if (sc->status.card_type == TLP_CSID_T1E1) - { - if ((media & IFM_TMASK) == IFM_TDM_T1) - config.format = CFG_FORMAT_T1ESF; - else if ((media & IFM_TMASK) == IFM_TDM_T1_AMI) - config.format = CFG_FORMAT_T1SF; - else if ((media & IFM_TMASK) == IFM_TDM_E1) - config.format = CFG_FORMAT_E1NONE; - else if ((media & IFM_TMASK) == IFM_TDM_E1_G704) - config.format = CFG_FORMAT_E1FASCRC; - } - - /* ifconfig lmc0 mediaopt loopback */ - if (media & IFM_LOOP) - config.loop_back = CFG_LOOP_TULIP; - else - config.loop_back = CFG_LOOP_NONE; - - /* ifconfig lmc0 mediaopt crc16 */ - if (media & IFM_TDM_HDLC_CRC16) - config.crc_len = CFG_CRC_16; - else - config.crc_len = CFG_CRC_32; - - /* Set ConFiGuration. */ - config.iohdr.cookie = NGM_LMC_COOKIE; - error = core_ioctl(sc, LMCIOCSCFG, (caddr_t)&config); - - return error; - } - -/* Callback from ifmedia. */ -static void -ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr) - { - softc_t *sc = IFP2SC(ifp); - - /* ifconfig wants to know if the hardware link is up. */ - ifmr->ifm_status = IFM_AVALID; - if (sc->status.oper_status == STATUS_UP) - ifmr->ifm_status |= IFM_ACTIVE; - - ifmr->ifm_active = sc->ifm.ifm_cur->ifm_media; - - if (sc->config.loop_back != CFG_LOOP_NONE) - ifmr->ifm_active |= IFM_LOOP; - - if (sc->config.crc_len == CFG_CRC_16) - ifmr->ifm_active |= IFM_TDM_HDLC_CRC16; - } - -# endif /* __OpenBSD__ */ + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (cntrs->ipackets); + case IFCOUNTER_OPACKETS: + return (cntrs->opackets); + case IFCOUNTER_IBYTES: + return (cntrs->ibytes); + case IFCOUNTER_OBYTES: + return (cntrs->obytes); + case IFCOUNTER_IERRORS: + return (cntrs->ierrors); + case IFCOUNTER_OERRORS: + return (cntrs->oerrors); + case IFCOUNTER_IQDROPS: + return (cntrs->idiscards); + default: + return (if_get_counter_default(ifp, cnt)); + } +} static void setup_ifnet(struct ifnet *ifp) @@ -4819,59 +3806,34 @@ setup_ifnet(struct ifnet *ifp) softc_t *sc = ifp->if_softc; /* Initialize the generic network interface. */ - /* Note similarity to linux's setup_netdev(). */ ifp->if_flags = IFF_POINTOPOINT; ifp->if_flags |= IFF_RUNNING; ifp->if_ioctl = lmc_ifnet_ioctl; ifp->if_start = lmc_ifnet_start; /* sppp changes this */ ifp->if_output = lmc_raw_output; /* sppp & p2p change this */ ifp->if_input = lmc_raw_input; + ifp->if_get_counter = lmc_get_counter; ifp->if_mtu = MAX_DESC_LEN; /* sppp & p2p change this */ ifp->if_type = IFT_PTPSERIAL; /* p2p changes this */ -# if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) +# if defined(DEVICE_POLLING) ifp->if_capabilities |= IFCAP_POLLING; ifp->if_capenable |= IFCAP_POLLING_NOCOUNT; -# if (__FreeBSD_version < 500000) - ifp->if_capenable |= IFCAP_POLLING; -# endif # endif - /* Every OS does it differently! */ -# if (defined(__FreeBSD__) && (__FreeBSD_version < 502000)) - (const char *)ifp->if_name = device_get_name(sc->dev); - ifp->if_unit = device_get_unit(sc->dev); -# elif (__FreeBSD_version >= 502000) if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); -# elif defined(__NetBSD__) - strcpy(ifp->if_xname, sc->dev.dv_xname); -# elif defined(__OpenBSD__) - bcopy(sc->dev.dv_xname, ifp->if_xname, IFNAMSIZ); -# elif defined(__bsdi__) - ifp->if_name = sc->dev.dv_cfdata->cf_driver->cd_name; - ifp->if_unit = sc->dev.dv_unit; -# endif } static int lmc_ifnet_attach(softc_t *sc) { -# if (__FreeBSD_version >= 600000) sc->ifp = if_alloc(NSPPP ? IFT_PPP : IFT_OTHER); if (sc->ifp == NULL) return ENOMEM; -# endif # if NSPPP -# if (__FreeBSD_version >= 600000) sc->sppp = sc->ifp->if_l2com; -# else - sc->ifp = &sc->spppcom.pp_if; - sc->sppp = &sc->spppcom; -# endif # elif P2P sc->ifp = &sc->p2pcom.p2p_if; sc->p2p = &sc->p2pcom; -# elif (__FreeBSD_version < 600000) - sc->ifp = &sc->ifnet; # endif /* Initialize the network interface struct. */ @@ -4885,40 +3847,9 @@ lmc_ifnet_attach(softc_t *sc) /* Attach to the ifnet kernel interface. */ if_attach(sc->ifp); -# if ((defined(__NetBSD__) && __NetBSD_Version__ >= 106000000) || \ - (defined(__OpenBSD__) && OpenBSD >= 200211)) - if_alloc_sadl(sc->ifp); -# endif - /* Attach Berkeley Packet Filter. */ LMC_BPF_ATTACH(DLT_RAW, 0); -# ifdef __OpenBSD__ - /* Initialize ifmedia mechanism. */ - ifmedia_init(&sc->ifm, IFM_OMASK | IFM_GMASK | IFM_IMASK, - ifmedia_change, ifmedia_status); - if (sc->status.card_type == TLP_CSID_T3) - { - ifmedia_add(&sc->ifm, IFM_TDM | IFM_TDM_T3, 0, NULL); - ifmedia_add(&sc->ifm, IFM_TDM | IFM_TDM_T3_M13, 0, NULL); - ifmedia_set(&sc->ifm, IFM_TDM | IFM_TDM_T3); - } - else if (sc->status.card_type == TLP_CSID_T1E1) - { - ifmedia_add(&sc->ifm, IFM_TDM | IFM_TDM_T1, 0, NULL); - ifmedia_add(&sc->ifm, IFM_TDM | IFM_TDM_T1_AMI, 0, NULL); - ifmedia_add(&sc->ifm, IFM_TDM | IFM_TDM_E1, 0, NULL); - ifmedia_add(&sc->ifm, IFM_TDM | IFM_TDM_E1_G704, 0, NULL); - ifmedia_set(&sc->ifm, IFM_TDM | IFM_TDM_T1); - } - else if ((sc->status.card_type == TLP_CSID_HSSI) || - (sc->status.card_type == TLP_CSID_SSI)) - { - ifmedia_add(&sc->ifm, IFM_TDM | IFM_NONE, 0, NULL); - ifmedia_set(&sc->ifm, IFM_TDM | IFM_NONE); - } -# endif /* __OpenBSD__ */ - callout_reset(&sc->callout, hz, lmc_watchdog, sc); return 0; @@ -4927,11 +3858,8 @@ lmc_ifnet_attach(softc_t *sc) static void lmc_ifnet_detach(softc_t *sc) { -# ifdef __OpenBSD__ - ifmedia_delete_instance(&sc->ifm, IFM_INST_ANY); -# endif -# if (defined(__FreeBSD__) && defined(DEVICE_POLLING)) +# if defined(DEVICE_POLLING) if (sc->ifp->if_capenable & IFCAP_POLLING) ether_poll_deregister(sc->ifp); # endif @@ -4939,28 +3867,15 @@ lmc_ifnet_detach(softc_t *sc) /* Detach Berkeley Packet Filter. */ LMC_BPF_DETACH; -# if ((defined(__NetBSD__) && __NetBSD_Version__ >= 106000000) || \ - (defined(__OpenBSD__) && OpenBSD >= 200211)) - if_free_sadl(sc->ifp); -# endif - /* Detach from the ifnet kernel interface. */ if_detach(sc->ifp); -# if (defined(__FreeBSD__) && __FreeBSD_version >= 800082) if_free(sc->ifp); -# elif (defined(__FreeBSD__) && __FreeBSD_version >= 600000) - if_free_type(sc->ifp, NSPPP ? IFT_PPP : IFT_OTHER); -# endif } -#endif /* IFNET */ #if NETGRAPH -/* Netgraph changed significantly between FreeBSD-4 and -5. */ -/* These are backward compatibility hacks for FreeBSD-4. */ -# if (__FreeBSD_version >= 500000) /* These next two macros should be added to netgraph */ # define NG_TYPE_REF(type) atomic_add_int(&(type)->refs, 1) # define NG_TYPE_UNREF(type) \ @@ -4970,39 +3885,16 @@ do { \ else \ atomic_subtract_int(&(type)->refs, 1); \ } while (0) -# else /* FreeBSD-4 */ -# define NGI_GET_MSG(item, msg) /* nothing */ -# define NG_HOOK_FORCE_QUEUE(hook) /* nothing */ -# define NG_TYPE_REF(type) atomic_add_int(&(type)->refs, 1) -# define NG_TYPE_UNREF(type) \ -do { \ - if ((type)->refs == 1) \ - LIST_REMOVE(type, types); \ - else \ - atomic_subtract_int(&(type)->refs, 1); \ - } while (0) -# endif /* It is an error to construct new copies of this Netgraph node. */ /* All instances are constructed by ng_attach and are persistent. */ -# if (__FreeBSD_version >= 500000) static int ng_constructor(node_p node) { return EINVAL; } -# else /* FreeBSD-4 */ -static int ng_constructor(node_p *node) { return EINVAL; } -# endif /* Incoming Netgraph control message. */ -# if (__FreeBSD_version >= 500000) static int ng_rcvmsg(node_p node, item_p item, hook_p lasthook) { struct ng_mesg *msg; -# else /* FreeBSD-4 */ -static int -ng_rcvmsg(node_p node, struct ng_mesg *msg, - const char *retaddr, struct ng_mesg **rptr) - { -# endif struct ng_mesg *resp = NULL; softc_t *sc = NG_NODE_PRIVATE(node); int error = 0; @@ -5072,16 +3964,8 @@ ng_rcvmsg(node_p node, struct ng_mesg *msg, error = EINVAL; /* Handle synchronous response. */ -# if (__FreeBSD_version >= 500000) NG_RESPOND_MSG(error, node, item, resp); NG_FREE_MSG(msg); -# else /* FreeBSD-4 */ - if (rptr != NULL) - *rptr = resp; - else if (resp != NULL) - free(resp, M_NETGRAPH); - free(msg, M_NETGRAPH); -# endif return error; } @@ -5090,14 +3974,9 @@ ng_rcvmsg(node_p node, struct ng_mesg *msg, static int ng_shutdown(node_p node) { -# if (__FreeBSD_version >= 500000) /* unless told to really die, bounce back to life */ if ((node->nd_flags & NG_REALLY_DIE)==0) node->nd_flags &= ~NG_INVALID; /* bounce back to life */ -# else /* FreeBSD-4 */ - ng_cutlinks(node); - node->flags &= ~NG_INVALID; /* bounce back to life */ -# endif return 0; } @@ -5134,7 +4013,6 @@ ng_connect(hook_p hook) /* Transmit an mbuf-chain on the communication link. */ /* This procedure is very similar to lmc_raw_output(). */ /* Called from a syscall (user context; no spinlocks). */ -# if (__FreeBSD_version >= 500000) static int ng_rcvdata(hook_p hook, item_p item) { @@ -5146,13 +4024,6 @@ ng_rcvdata(hook_p hook, item_p item) NGI_GET_M(item, m); NGI_GET_META(item, meta); NG_FREE_ITEM(item); -# else /* FreeBSD-4 */ -static int -ng_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) - { - softc_t *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); - int error = 0; -# endif /* This macro must not store into meta! */ NG_FREE_META(meta); @@ -5172,17 +4043,10 @@ ng_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) /* Some BSD QUEUE routines are not interrupt-safe. */ { DISABLE_INTR; -# if (__FreeBSD_version >= 503000) if (meta==NULL) IFQ_ENQUEUE(&sc->ng_sndq, m, error); else IFQ_ENQUEUE(&sc->ng_fastq, m, error); -# else - if (meta==NULL) - IFQ_ENQUEUE(&sc->ng_sndq, m, NULL, error); - else - IFQ_ENQUEUE(&sc->ng_fastq, m, NULL, error); -# endif ENABLE_INTR; } @@ -5221,38 +4085,15 @@ struct ng_type ng_type = .mod_event = NULL, .constructor = ng_constructor, .rcvmsg = ng_rcvmsg, -# if (__FreeBSD_version >=503000) .close = NULL, -# endif .shutdown = ng_shutdown, .newhook = ng_newhook, .findhook = NULL, .connect = ng_connect, .rcvdata = ng_rcvdata, -# if (defined(__FreeBSD__) && (__FreeBSD_version < 500000)) - .rcvdataq = ng_rcvdata, -# endif .disconnect = ng_disconnect, }; -# if (IFNET == 0) -/* Called from a softirq once a second. */ -static void -ng_watchdog(void *arg) - { - softc_t *sc = arg; - - /* Call the core watchdog procedure. */ - core_watchdog(sc); - - /* Set line protocol and package status. */ - sc->status.line_pkg = PKG_NG; - sc->status.line_prot = 0; - - /* Call this procedure again after one second. */ - callout_reset(&sc->callout, hz, ng_watchdog, sc); - } -# endif /* Attach to the Netgraph kernel interface (/sys/netgraph). * It is called once for each physical card during device attach. @@ -5292,11 +4133,9 @@ ng_attach(softc_t *sc) return error; } -# if (__FreeBSD_version >= 500000) /* Initialize the send queue mutexes. */ mtx_init(&sc->ng_sndq.ifq_mtx, NAME_UNIT, "sndq", MTX_DEF); mtx_init(&sc->ng_fastq.ifq_mtx, NAME_UNIT, "fastq", MTX_DEF); -# endif /* Put a backpointer to the softc in the netgraph node. */ NG_NODE_SET_PRIVATE(sc->ng_node, sc); @@ -5307,10 +4146,6 @@ ng_attach(softc_t *sc) IFQ_SET_MAXLEN(&sc->ng_sndq, SNDQ_MAXLEN); IFQ_SET_READY(&sc->ng_sndq); -# if (IFNET == 0) - /* Arrange to call ng_watchdog() once a second. */ - callout_reset(&sc->callout, hz, ng_watchdog, sc); -# endif return 0; } @@ -5319,18 +4154,11 @@ static void ng_detach(softc_t *sc) { callout_drain(&sc->callout); -# if (__FreeBSD_version >= 500000) mtx_destroy(&sc->ng_sndq.ifq_mtx); mtx_destroy(&sc->ng_fastq.ifq_mtx); ng_rmnode_self(sc->ng_node); /* free hook */ NG_NODE_UNREF(sc->ng_node); /* free node */ NG_TYPE_UNREF(&ng_type); -# else /* FreeBSD-4 */ - ng_unname(sc->ng_node); /* free name */ - ng_cutlinks(sc->ng_node); /* free hook */ - NG_NODE_UNREF(sc->ng_node); /* free node */ - NG_TYPE_UNREF(&ng_type); -# endif } #endif /* NETGRAPH */ @@ -5490,21 +4318,15 @@ attach_card(softc_t *sc, const char *intrstr) /* Start the card. */ if ((error = startup_card(sc))) return error; -# if (__FreeBSD_version >= 500000) callout_init(&sc->callout, 0); -# else /* FreeBSD-4 */ - callout_init(&sc->callout); -# endif /* Attach a kernel interface. */ #if NETGRAPH if ((error = ng_attach(sc))) return error; sc->flags |= FLAG_NETGRAPH; #endif -#if IFNET if ((error = lmc_ifnet_attach(sc))) return error; sc->flags |= FLAG_IFNET; -#endif /* Attach a line protocol stack. */ sc->config.line_pkg = PKG_RAWIP; @@ -5571,14 +4393,12 @@ detach_card(softc_t *sc) sc->flags &= ~FLAG_NETGRAPH; } #endif -#if IFNET if (sc->flags & FLAG_IFNET) { IFQ_PURGE(&sc->ifp->if_snd); lmc_ifnet_detach(sc); sc->flags &= ~FLAG_IFNET; } -#endif /* Reset the Tulip chip; stops DMA and Interrupts. */ shutdown_card(sc); @@ -5586,7 +4406,6 @@ detach_card(softc_t *sc) /* This is the I/O configuration interface for FreeBSD */ -#ifdef __FreeBSD__ static int fbsd_probe(device_t dev) @@ -5642,10 +4461,8 @@ fbsd_detach(device_t dev) sc->csr_res = NULL; } -# if (__FreeBSD_version >= 500000) mtx_destroy(&sc->top_mtx); mtx_destroy(&sc->bottom_mtx); -# endif return 0; /* no error */ } @@ -5722,11 +4539,9 @@ fbsd_attach(device_t dev) return error; } -# if (__FreeBSD_version >= 500000) /* Initialize the top-half and bottom-half locks. */ mtx_init(&sc->top_mtx, NAME_UNIT, "top half lock", MTX_DEF); mtx_init(&sc->bottom_mtx, NAME_UNIT, "bottom half lock", MTX_DEF); -# endif /* Start the card and attach a kernel interface and line protocol. */ if ((error = attach_card(sc, ""))) detach_card(sc); @@ -5747,11 +4562,7 @@ static driver_t driver = { .name = DEVICE_NAME, .methods = methods, -# if (__FreeBSD_version >= 500000) .size = sizeof(softc_t), -# else /* FreeBSD-4 */ - .softc = sizeof(softc_t), -# endif }; static devclass_t devclass; @@ -5766,1281 +4577,13 @@ MODULE_DEPEND(lmc, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION); MODULE_DEPEND(lmc, sppp, 1, 1, 1); # endif -#endif /* __FreeBSD__ */ /* This is the I/O configuration interface for NetBSD. */ -#ifdef __NetBSD__ - -static int -nbsd_match(struct device *parent, struct cfdata *match, void *aux) - { - struct pci_attach_args *pa = aux; - u_int32_t cfid = pci_conf_read(pa->pa_pc, pa->pa_tag, TLP_CFID); - u_int32_t csid = pci_conf_read(pa->pa_pc, pa->pa_tag, TLP_CSID); - - /* Looking for a DEC 21140A chip on any Lan Media Corp card. */ - if (cfid != TLP_CFID_TULIP) return 0; - switch (csid) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - case TLP_CSID_T3: - case TLP_CSID_SSI: - case TLP_CSID_T1E1: - return 100; - default: - return 0; - } - } - -static int -nbsd_detach(struct device *self, int flags) - { - softc_t *sc = (softc_t *)self; /* device is first in softc */ - - /* Stop the card and detach from the kernel. */ - detach_card(sc); - - /* Release resources. */ - if (sc->sdh_cookie != NULL) - { - shutdownhook_disestablish(sc->sdh_cookie); - sc->sdh_cookie = NULL; - } - if (sc->irq_cookie != NULL) - { - pci_intr_disestablish(sc->pa_pc, sc->irq_cookie); - sc->irq_cookie = NULL; - } - if (sc->csr_handle) - { - bus_space_unmap(sc->csr_tag, sc->csr_handle, TLP_CSR_SIZE); - sc->csr_handle = 0; - } - - return 0; /* no error */ - } - -static void -nbsd_attach(struct device *parent, struct device *self, void *aux) - { - softc_t *sc = (softc_t *)self; /* device is first in softc */ - struct pci_attach_args *pa = aux; - const char *intrstr; - bus_addr_t csr_addr; - int error; - - /* READ/WRITE_PCI_CFG need these. */ - sc->pa_pc = pa->pa_pc; - sc->pa_tag = pa->pa_tag; - /* bus_dma needs this. */ - sc->pa_dmat = pa->pa_dmat; - - /* What kind of card are we driving? */ - switch (READ_PCI_CFG(sc, TLP_CSID)) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - sc->dev_desc = HSSI_DESC; - sc->card = &hssi_card; - break; - case TLP_CSID_T3: - sc->dev_desc = T3_DESC; - sc->card = &t3_card; - break; - case TLP_CSID_SSI: - sc->dev_desc = SSI_DESC; - sc->card = &ssi_card; - break; - case TLP_CSID_T1E1: - sc->dev_desc = T1E1_DESC; - sc->card = &t1_card; - break; - default: - return; - } - printf(": %s\n", sc->dev_desc); - - /* Allocate PCI resources to access the Tulip chip CSRs. */ -# if IOREF_CSR - csr_addr = (bus_addr_t)READ_PCI_CFG(sc, TLP_CBIO) & -2; - sc->csr_tag = pa->pa_iot; /* bus_space tag for IO refs */ -# else - csr_addr = (bus_addr_t)READ_PCI_CFG(sc, TLP_CBMA); - sc->csr_tag = pa->pa_memt; /* bus_space tag for MEM refs */ -# endif - if ((error = bus_space_map(sc->csr_tag, csr_addr, - TLP_CSR_SIZE, 0, &sc->csr_handle))) - { - printf("%s: bus_space_map() failed; error %d\n", NAME_UNIT, error); - return; - } - - /* Allocate PCI interrupt resources. */ - if ((error = pci_intr_map(pa, &sc->intr_handle))) - { - printf("%s: pci_intr_map() failed; error %d\n", NAME_UNIT, error); - nbsd_detach(self, 0); - return; - } - sc->irq_cookie = pci_intr_establish(pa->pa_pc, sc->intr_handle, - IPL_NET, bsd_interrupt, sc); - if (sc->irq_cookie == NULL) - { - printf("%s: pci_intr_establish() failed\n", NAME_UNIT); - nbsd_detach(self, 0); - return; - } - intrstr = pci_intr_string(pa->pa_pc, sc->intr_handle); - - /* Install a shutdown hook. */ - sc->sdh_cookie = shutdownhook_establish(shutdown_card, sc); - if (sc->sdh_cookie == NULL) - { - printf("%s: shutdown_hook_establish() failed\n", NAME_UNIT); - nbsd_detach(self, 0); - return; - } - - /* Initialize the top-half and bottom-half locks. */ - simple_lock_init(&sc->top_lock); - simple_lock_init(&sc->bottom_lock); - - /* Start the card and attach a kernel interface and line protocol. */ - if ((error = attach_card(sc, intrstr))) detach_card(sc); - } - -# if (__NetBSD_Version__ >= 106080000) /* 1.6H */ -CFATTACH_DECL(lmc, sizeof(softc_t), - nbsd_match, nbsd_attach, nbsd_detach, NULL); -# else -struct cfattach lmc_ca = - { -/*.ca_name = DEVICE_NAME, */ - .ca_devsize = sizeof(softc_t), - .ca_match = nbsd_match, - .ca_attach = nbsd_attach, - .ca_detach = nbsd_detach, - .ca_activate = NULL, - }; -# endif - -# if (__NetBSD_Version__ >= 106080000) -CFDRIVER_DECL(lmc, DV_IFNET, NULL); -# else -static struct cfdriver lmc_cd = - { - .cd_name = DEVICE_NAME, - .cd_class = DV_IFNET, - .cd_ndevs = 0, - .cd_devs = NULL, - }; -# endif - -/* cfdata is declared static, unseen outside this module. */ -/* It is used for LKM; config builds its own in ioconf.c. */ -static struct cfdata lmc_cf = - { -# if (__NetBSD_Version__ >= 106080000) - .cf_name = DEVICE_NAME, - .cf_atname = DEVICE_NAME, -# else - .cf_driver = &lmc_cd, - .cf_attach = &lmc_ca, -# endif - .cf_unit = 0, - .cf_fstate = FSTATE_STAR, - }; - -# if (__NetBSD_Version__ >= 106080000) -MOD_MISC(DEVICE_NAME) -# else -static struct lkm_misc _module = - { - .lkm_name = DEVICE_NAME, - .lkm_type = LM_MISC, - .lkm_offset = 0, - .lkm_ver = LKM_VERSION, - }; -# endif - -/* From /sys/dev/pci/pci.c (no public prototype). */ -int pciprint(void *, const char *); - -static int lkm_nbsd_match(struct pci_attach_args *pa) - { return nbsd_match(0, 0, pa); } - -/* LKM loader finds this by appending "_lkmentry" to filename "if_lmc". */ -int if_lmc_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) - { - int i, error = 0; - - if (ver != LKM_VERSION) return EINVAL; - switch (cmd) - { - case LKM_E_LOAD: - { - struct cfdriver* pcicd; - - lkmtp->private.lkm_misc = &_module; - if ((pcicd = config_cfdriver_lookup("pci")) == NULL) - { - printf("%s: config_cfdriver_lookup(pci) failed; error %d\n", - lmc_cd.cd_name, error); - return error; - } -# if (__NetBSD_Version__ >= 106080000) - if ((error = config_cfdriver_attach(&lmc_cd))) - { - printf("%s: config_cfdriver_attach() failed; error %d\n", - lmc_cd.cd_name, error); - return error; - } - if ((error = config_cfattach_attach(lmc_cd.cd_name, &lmc_ca))) - { - printf("%s: config_cfattach_attach() failed; error %d\n", - lmc_cd.cd_name, error); - config_cfdriver_detach(&lmc_cd); - return error; - } -# endif - for (i=0; icd_ndevs; i++) - { - int dev; - /* A pointer to a device is a pointer to its softc. */ - struct pci_softc *sc = pcicd->cd_devs[i]; - if (sc == NULL) continue; - for (dev=0; devsc_maxndevs; dev++) - { - struct pci_attach_args pa; - pcitag_t tag = pci_make_tag(sc->sc_pc, sc->sc_bus, dev, 0); - if (pci_probe_device(sc, tag, lkm_nbsd_match, &pa) != 0) - config_attach(pcicd->cd_devs[i], &lmc_cf, &pa, pciprint); - /* config_attach doesn't return on failure; it calls panic. */ - } - } - break; - } - case LKM_E_UNLOAD: - { - for (i=lmc_cd.cd_ndevs-1; i>=0; i--) - { - struct device *dev = lmc_cd.cd_devs[i]; - if (dev == NULL) continue; - if ((error = config_detach(dev, 0))) - { - printf("%s: config_detach() failed; error %d\n", - dev->dv_xname, error); - return error; - } - } -# if (__NetBSD_Version__ >= 106080000) - if ((error = config_cfattach_detach(lmc_cd.cd_name, &lmc_ca))) - { - printf("%s: config_cfattach_detach() failed; error %d\n", - lmc_cd.cd_name, error); - return error; - } - if ((error = config_cfdriver_detach(&lmc_cd))) - { - printf("%s: config_cfdriver_detach() failed; error %d\n", - lmc_cd.cd_name, error); - return error; - } -# endif - break; - } - case LKM_E_STAT: - break; - } - - return error; - } - -#endif /* __NetBSD__ */ /* This is the I/O configuration interface for OpenBSD. */ -#ifdef __OpenBSD__ - -static int -obsd_match(struct device *parent, void *match, void *aux) - { - struct pci_attach_args *pa = aux; - u_int32_t cfid = pci_conf_read(pa->pa_pc, pa->pa_tag, TLP_CFID); - u_int32_t csid = pci_conf_read(pa->pa_pc, pa->pa_tag, TLP_CSID); - - /* Looking for a DEC 21140A chip on any Lan Media Corp card. */ - if (cfid != TLP_CFID_TULIP) return 0; - switch (csid) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - case TLP_CSID_T3: - case TLP_CSID_SSI: - case TLP_CSID_T1E1: - return 100; /* match better than other 21140 drivers */ - default: - return 0; - } - } - -static int -obsd_detach(struct device *self, int flags) - { - softc_t *sc = (softc_t *)self; /* device is first in softc */ - - /* Stop the card and detach from the kernel. */ - detach_card(sc); - - /* Release resources. */ - if (sc->sdh_cookie != NULL) - { - shutdownhook_disestablish(sc->sdh_cookie); - sc->sdh_cookie = NULL; - } - if (sc->irq_cookie != NULL) - { - pci_intr_disestablish(sc->pa_pc, sc->irq_cookie); - sc->irq_cookie = NULL; - } - if (sc->csr_handle) - { - bus_space_unmap(sc->csr_tag, sc->csr_handle, TLP_CSR_SIZE); - sc->csr_handle = 0; - } - - return 0; /* no error */ - } - -static void -obsd_attach(struct device *parent, struct device *self, void *aux) - { - softc_t *sc = (softc_t *)self; /* device is first in softc */ - struct pci_attach_args *pa = aux; - const char *intrstr; - bus_addr_t csr_addr; - int error; - - /* READ/WRITE_PCI_CFG need these. */ - sc->pa_pc = pa->pa_pc; - sc->pa_tag = pa->pa_tag; - /* bus_dma needs this. */ - sc->pa_dmat = pa->pa_dmat; - - /* What kind of card are we driving? */ - switch (READ_PCI_CFG(sc, TLP_CSID)) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - sc->dev_desc = HSSI_DESC; - sc->card = &hssi_card; - break; - case TLP_CSID_T3: - sc->dev_desc = T3_DESC; - sc->card = &t3_card; - break; - case TLP_CSID_SSI: - sc->dev_desc = SSI_DESC; - sc->card = &ssi_card; - break; - case TLP_CSID_T1E1: - sc->dev_desc = T1E1_DESC; - sc->card = &t1_card; - break; - default: - return; - } - printf(": %s\n", sc->dev_desc); - - /* Allocate PCI resources to access the Tulip chip CSRs. */ -# if IOREF_CSR - csr_addr = (bus_addr_t)READ_PCI_CFG(sc, TLP_CBIO) & -2; - sc->csr_tag = pa->pa_iot; /* bus_space tag for IO refs */ -# else - csr_addr = (bus_addr_t)READ_PCI_CFG(sc, TLP_CBMA); - sc->csr_tag = pa->pa_memt; /* bus_space tag for MEM refs */ -# endif - if ((error = bus_space_map(sc->csr_tag, csr_addr, - TLP_CSR_SIZE, 0, &sc->csr_handle))) - { - printf("%s: bus_space_map() failed; error %d\n", NAME_UNIT, error); - return; - } - - /* Allocate PCI interrupt resources. */ - if ((error = pci_intr_map(pa, &sc->intr_handle))) - { - printf("%s: pci_intr_map() failed; error %d\n", NAME_UNIT, error); - obsd_detach(self, 0); - return; - } - sc->irq_cookie = pci_intr_establish(pa->pa_pc, sc->intr_handle, - IPL_NET, bsd_interrupt, sc, self->dv_xname); - if (sc->irq_cookie == NULL) - { - printf("%s: pci_intr_establish() failed\n", NAME_UNIT); - obsd_detach(self, 0); - return; - } - intrstr = pci_intr_string(pa->pa_pc, sc->intr_handle); - - /* Install a shutdown hook. */ - sc->sdh_cookie = shutdownhook_establish(shutdown_card, sc); - if (sc->sdh_cookie == NULL) - { - printf("%s: shutdown_hook_establish() failed\n", NAME_UNIT); - obsd_detach(self, 0); - return; - } - - /* Initialize the top-half and bottom-half locks. */ - simple_lock_init(&sc->top_lock); - simple_lock_init(&sc->bottom_lock); - - /* Start the card and attach a kernel interface and line protocol. */ - if ((error = attach_card(sc, intrstr))) detach_card(sc); - } - -struct cfattach lmc_ca = - { - .ca_devsize = sizeof(softc_t), - .ca_match = obsd_match, - .ca_attach = obsd_attach, - .ca_detach = obsd_detach, - .ca_activate = NULL, - }; - -struct cfdriver lmc_cd = - { - .cd_name = DEVICE_NAME, - .cd_devs = NULL, - .cd_class = DV_IFNET, - .cd_indirect = 0, - .cd_ndevs = 0, - }; - -/* cfdata is declared static, unseen outside this module. */ -/* It is used for LKM; config builds its own in ioconf.c. */ -static struct cfdata lmc_cfdata = - { - .cf_attach = &lmc_ca, - .cf_driver = &lmc_cd, - .cf_unit = 0, - .cf_fstate = FSTATE_STAR, - }; - -static struct lkm_any _module = - { - .lkm_name = DEVICE_NAME, - .lkm_type = LM_MISC, - .lkm_offset = 0, - .lkm_ver = LKM_VERSION, - }; - -/* From /sys/dev/pci/pci.c (no public prototype). */ -int pciprint(void *, const char *); - -extern struct cfdriver pci_cd; - -/* LKM loader finds this by appending "_lkmentry" to filename "if_lmc". */ -int if_lmc_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) - { - int i, error = 0; - - if (ver != LKM_VERSION) return EINVAL; - switch (cmd) - { - case LKM_E_LOAD: - { /* XXX This works for ONE card on pci0 of a i386 machine! XXX */ - lkmtp->private.lkm_any = &_module; - for (i=0; idv_unit)!=0) continue; /* only bus zero */ - /* XXX For machine independence, need: pcibus_attach_args. XXX */ - /* XXX See NetBSD's sys/dev/pci/pci.c/pci_probe_device. XXX */ - /* XXX Why isn't there an LKM network interface module? XXX */ - pa.pa_pc = NULL; /* XXX */ - pa.pa_bus = 0; /* XXX */ - pa.pa_iot = X86_BUS_SPACE_IO; /* XXX */ - pa.pa_memt = X86_BUS_SPACE_MEM; /* XXX */ - pa.pa_dmat = &pci_bus_dma_tag; /* XXX */ - for (pa.pa_device=0; pa.pa_device<32; pa.pa_device++) /* XXX */ - { - int intr; - pa.pa_function = 0; /* DEC-21140A has function 0 only XXX */ - pa.pa_tag = pci_make_tag(pa.pa_pc, pa.pa_bus, pa.pa_device, 0); - pa.pa_id = pci_conf_read(pa.pa_pc, pa.pa_tag, PCI_ID_REG); - if ((pa.pa_id & 0xFFFF) == 0xFFFF) continue; - if ((pa.pa_id & 0xFFFF) == 0) continue; - /* XXX this only works for pci0 -- no swizzelling XXX */ - pa.pa_intrswiz = 0; - pa.pa_intrtag = pa.pa_tag; - intr = pci_conf_read(pa.pa_pc, pa.pa_tag, PCI_INTERRUPT_REG); - pa.pa_intrline = PCI_INTERRUPT_LINE(intr); - pa.pa_intrpin = ((PCI_INTERRUPT_PIN(intr) -1) % 4) +1; - if (obsd_match(parent, &lmc_cfdata, &pa)) - config_attach(parent, &lmc_cfdata, &pa, pciprint); - /* config_attach doesn't return on failure; it calls panic. */ - } - } - break; - } - case LKM_E_UNLOAD: - { - for (i=lmc_cd.cd_ndevs-1; i>=0; i--) - { - struct device *dev = lmc_cd.cd_devs[i]; - if (dev == NULL) continue; - if ((error = config_detach(dev, 0))) - printf("%s: config_detach() failed; error %d\n", dev->dv_xname, error); - } - break; - } - case LKM_E_STAT: - break; - } - - return error; - } - -#endif /* __OpenBSD__ */ /* This is the I/O configuration interface for BSD/OS. */ -#ifdef __bsdi__ -static int -bsdi_match(pci_devaddr_t *pa) - { - u_int32_t cfid = pci_inl(pa, TLP_CFID); - u_int32_t csid = pci_inl(pa, TLP_CSID); - - /* Looking for a DEC 21140A chip on any Lan Media Corp card. */ - if (cfid != TLP_CFID_TULIP) return 0; - switch (csid) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - case TLP_CSID_T3: - case TLP_CSID_SSI: - case TLP_CSID_T1E1: - return 1; - default: - return 0; - } - } - -static int -bsdi_probe(struct device *parent, struct cfdata *cf, void *aux) - { - struct isa_attach_args *ia = aux; - pci_devaddr_t *pa = NULL; - pci_devres_t res; - - /* This must be a PCI bus. */ - if (ia->ia_bustype != BUS_PCI) return 0; - - /* Scan PCI bus for our boards. */ - if ((pa = pci_scan(bsdi_match)) == 0) return 0; - - /* Scan config space for IO and MEM base registers and IRQ info. */ - pci_getres(pa, &res, 1, ia); - - /* Crucial: pass pci_devaddr to bsdi_attach in ia_aux. */ - ia->ia_aux = (void *)pa; - - return 1; - } - -static void -bsdi_attach(struct device *parent, struct device *self, void *aux) - { - softc_t *sc = (softc_t *)self; /* device is first in softc */ - struct isa_attach_args *ia = aux; - pci_devaddr_t *pa = ia->ia_aux; /* this is crucial! */ - int error; - - /* READ/WRITE_PCI_CFG need this. */ - sc->cfgbase = *pa; - - /* What kind of card are we driving? */ - switch (READ_PCI_CFG(sc, TLP_CSID)) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - sc->dev_desc = HSSI_DESC; - sc->card = &hssi_card; - break; - case TLP_CSID_T3: - sc->dev_desc = T3_DESC; - sc->card = &t3_card; - break; - case TLP_CSID_SSI: - sc->dev_desc = SSI_DESC; - sc->card = &ssi_card; - break; - case TLP_CSID_T1E1: - sc->dev_desc = T1E1_DESC; - sc->card = &t1_card; - break; - default: - return; - } - printf(": %s\n", sc->dev_desc); - - /* Allocate PCI memory or IO resources to access the Tulip chip CSRs. */ - sc->csr_iobase = ia->ia_iobase; - sc->csr_membase = (u_int32_t *)mapphys((vm_offset_t)ia->ia_maddr, TLP_CSR_SIZE); - - /* Attach to the PCI bus. */ - isa_establish(&sc->id, &sc->dev); - - /* Allocate PCI interrupt resources for the card. */ - sc->ih.ih_fun = bsd_interrupt; - sc->ih.ih_arg = sc; - intr_establish(ia->ia_irq, &sc->ih, DV_NET); - - /* Install a shutdown hook. */ - sc->ats.func = shutdown_card; - sc->ats.arg = sc; - atshutdown(&sc->ats, ATSH_ADD); - - /* Initialize the top-half and bottom-half locks. */ - simple_lock_init(&sc->top_lock); - simple_lock_init(&sc->bottom_lock); - - /* Start the card and attach a kernel interface and line protocol. */ - if ((error = attach_card(sc, ""))) detach_card(sc); - } - -struct cfdriver lmccd = - { - .cd_devs = NULL, - .cd_name = DEVICE_NAME, - .cd_match = bsdi_probe, - .cd_attach = bsdi_attach, - .cd_class = DV_IFNET, - .cd_devsize = sizeof(softc_t), - }; -#endif /* __bsdi__ */ - -#ifdef __linux__ - -/* The kernel calls this procedure when an interrupt happens. */ -static irqreturn_t -linux_interrupt(int irq, void *dev, struct pt_regs *regs) - { - struct net_device *net_dev = dev; - softc_t *sc = dev_to_hdlc(net_dev)->priv; - - /* Cut losses early if this is not our interrupt. */ - if ((READ_CSR(TLP_STATUS) & TLP_INT_TXRX) == 0) - return IRQ_NONE; - - /* Disable card interrupts. */ - WRITE_CSR(TLP_INT_ENBL, TLP_INT_DISABLE); - - /* Handle the card interrupt with the dev->poll method. */ - if (netif_rx_schedule_prep(net_dev)) - __netif_rx_schedule(net_dev); /* NAPI - add to poll list */ - else - printk("%s: interrupt while on poll list\n", NAME_UNIT); - - return IRQ_HANDLED; - } - -/* This net_device method services interrupts in a softirq. */ -/* With rxintr_cleanup(), it implements input flow control. */ -static int -linux_poll(struct net_device *net_dev, int *budget) - { - softc_t *sc = dev_to_hdlc(net_dev)->priv; - int received; - - /* Yes, we do NAPI. */ - /* Allow processing up to net_dev->quota incoming packets. */ - /* This is the ONLY time core_interrupt() may process rx pkts. */ - /* Otherwise (sc->quota == 0) and rxintr_cleanup() is a NOOP. */ - sc->quota = net_dev->quota; - - /* Handle the card interrupt with kernel ints enabled. */ - /* Process rx pkts (and tx pkts, too). */ - /* Card interrupts are disabled. */ - core_interrupt(sc, 0); - - /* Report number of rx packets processed. */ - received = net_dev->quota - sc->quota; - net_dev->quota -= received; - *budget -= received; - - /* if quota prevented processing all rx pkts, leave rx ints disabled */ - if (sc->quota == 0) /* this is off by one...but harmless */ - { - WRITE_CSR(TLP_INT_ENBL, TLP_INT_TX); - return 1; /* more pkts to handle -- reschedule */ - } - - sc->quota = 0; /* disable rx pkt processing by rxintr_cleanup() */ - netif_rx_complete(net_dev); /* NAPI - remove from poll list */ - - /* Enable card interrupts. */ - WRITE_CSR(TLP_INT_ENBL, TLP_INT_TXRX); - return 0; - } - -/* These next routines are similar to BSD's ifnet kernel/driver interface. */ - -/* This net_device method hands outgoing packets to the transmitter. */ -/* With txintr_setup(), it implements output flow control. */ -/* Called from a syscall (user context; no spinlocks). */ -static int -linux_start(struct sk_buff *skb, struct net_device *net_dev) - { - softc_t *sc = dev_to_hdlc(net_dev)->priv; - - if (sc->tx_skb == NULL) - { - /* Put this skb where the transmitter will see it. */ - sc->tx_skb = skb; - - /* Start the transmitter; incoming pkts are NOT processed. */ - user_interrupt(sc, 0); - - /* If the tx didn't take the skb then stop the queue. */ - /* This can happen if another CPU is in core_interrupt(). */ - if (sc->tx_skb != NULL) netif_stop_queue(net_dev); - - return 0; - } - - /* This shouldn't happen; skb is NOT consumed. */ - if (netif_queue_stopped(net_dev)) - printk("%s: dev->start() called with queue stopped\n", NAME_UNIT); - else - netif_stop_queue(net_dev); - - return 1; - } - -/* This net_device method restarts the transmitter if it hangs. */ -/* Called from a softirq. */ -static void -linux_timeout(struct net_device *net_dev) - { - softc_t *sc = dev_to_hdlc(net_dev)->priv; - - /* Start the transmitter; incoming packets are NOT processed. */ - user_interrupt(sc, 1); - } - -/* This net_device method handles IOCTL syscalls. */ -/* Called from a syscall (user context; no spinlocks; can sleep). */ -static int -linux_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) - { - softc_t *sc = dev_to_hdlc(net_dev)->priv; - int error = 0; - - if ((cmd >= SIOCDEVPRIVATE) && (cmd <= SIOCDEVPRIVATE+15)) - { - struct iohdr *iohdr = (struct iohdr *)ifr; - u_int16_t direction = iohdr->direction; - u_int16_t length = iohdr->length; - char *user_addr = (char *)iohdr->iohdr; - char *kern_addr; - - if (iohdr->cookie != NGM_LMC_COOKIE) return -EINVAL; - - /* Emulate a BSD-style IOCTL syscall. */ - kern_addr = kmalloc(length, GFP_KERNEL); - if (kern_addr == NULL) - error = -ENOMEM; - if ((error == 0) && ((direction & DIR_IOW) != 0)) - error = copy_from_user(kern_addr, user_addr, length); - if (error == 0) - error = -core_ioctl(sc, (unsigned long)cmd, kern_addr); - if ((error == 0) && ((direction & DIR_IOR) != 0)) - error = copy_to_user(user_addr, kern_addr, length); - kfree(kern_addr); - } -# if GEN_HDLC - else if (cmd == SIOCWANDEV) - { - const size_t size = sizeof(sync_serial_settings); - - switch (ifr->ifr_settings.type) - { - case IF_GET_IFACE: /* get interface config */ - { - ifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL; - if (ifr->ifr_settings.size < size) - { - ifr->ifr_settings.size = size; - error = -ENOBUFS; - } - else - { - if (sc->config.tx_clk_src == CFG_CLKMUX_ST) - sc->hdlc_settings.clock_type = CLOCK_EXT; - if (sc->config.tx_clk_src == CFG_CLKMUX_INT) - sc->hdlc_settings.clock_type = CLOCK_TXINT; - if (sc->config.tx_clk_src == CFG_CLKMUX_RT) - sc->hdlc_settings.clock_type = CLOCK_TXFROMRX; - sc->hdlc_settings.loopback = (sc->config.loop_back != CFG_LOOP_NONE) ? 1:0; - sc->hdlc_settings.clock_rate = sc->status.tx_speed; - error = copy_to_user(ifr->ifr_settings.ifs_ifsu.sync, - &sc->hdlc_settings, size); - } - break; - } - case IF_IFACE_SYNC_SERIAL: /* set interface config */ - { - if (!capable(CAP_NET_ADMIN)) - error = -EPERM; - if (error == 0) - error = copy_from_user(&sc->hdlc_settings, - ifr->ifr_settings.ifs_ifsu.sync, size); - /* hdlc_settings are currently ignored. */ - break; - } - default: /* Pass the rest to the line protocol code. */ - { - error = hdlc_ioctl(net_dev, ifr, cmd); - break; - } - } - } -# endif /* GEN_HDLC */ - else /* unknown IOCTL command */ - error = -EINVAL; - - if (DRIVER_DEBUG) - printk("%s: linux_ioctl; cmd=0x%08x error=%d\n", - NAME_UNIT, cmd, error); - - return error; - } - -/* This net_device method returns a pointer to device statistics. */ -static struct net_device_stats * -linux_stats(struct net_device *net_dev) - { -# if GEN_HDLC - return &dev_to_hdlc(net_dev)->stats; -# else - softc_t *sc = net_dev->priv; - return &sc->net_stats; -# endif - } - -/* Called from a softirq once a second. */ -static void -linux_watchdog(unsigned long softc) - { - softc_t *sc = (softc_t *)softc; - u_int8_t old_oper_status = sc->status.oper_status; - struct event_cntrs *cntrs = &sc->status.cntrs; - struct net_device_stats *stats = linux_stats(sc->net_dev); - - core_watchdog(sc); /* updates oper_status */ - - /* Notice change in link status. */ - if ((old_oper_status != STATUS_UP) && - (sc->status.oper_status == STATUS_UP)) /* link came up */ - { - hdlc_set_carrier(1, sc->net_dev); - netif_wake_queue(sc->net_dev); - } - if ((old_oper_status == STATUS_UP) && - (sc->status.oper_status != STATUS_UP)) /* link went down */ - { - hdlc_set_carrier(0, sc->net_dev); - netif_stop_queue(sc->net_dev); - } - - /* Notice change in line protocol. */ - if (sc->config.line_pkg == PKG_RAWIP) - { - sc->status.line_pkg = PKG_RAWIP; - sc->status.line_prot = PROT_IP_HDLC; - } -# if GEN_HDLC - else - { - sc->status.line_pkg = PKG_GEN_HDLC; - switch (sc->hdlc_dev->proto.id) - { - case IF_PROTO_PPP: - sc->status.line_prot = PROT_PPP; - break; - case IF_PROTO_CISCO: - sc->status.line_prot = PROT_C_HDLC; - break; - case IF_PROTO_FR: - sc->status.line_prot = PROT_FRM_RLY; - break; - case IF_PROTO_HDLC: - sc->status.line_prot = PROT_IP_HDLC; - break; - case IF_PROTO_X25: - sc->status.line_prot = PROT_X25; - break; - case IF_PROTO_HDLC_ETH: - sc->status.line_prot = PROT_ETH_HDLC; - break; - default: - sc->status.line_prot = 0; - break; - } - } -# endif /* GEN_HDLC */ - - /* Copy statistics from sc to net_dev for get_stats(). */ - stats->rx_packets = cntrs->ipackets; - stats->tx_packets = cntrs->opackets; - stats->rx_bytes = cntrs->ibytes; - stats->tx_bytes = cntrs->obytes; - stats->rx_errors = cntrs->ierrors; - stats->tx_errors = cntrs->oerrors; - stats->rx_dropped = cntrs->idiscards; - stats->tx_dropped = cntrs->odiscards; - stats->rx_fifo_errors = cntrs->fifo_over; - stats->tx_fifo_errors = cntrs->fifo_under; - stats->rx_missed_errors = cntrs->missed; - stats->rx_over_errors = cntrs->overruns; - - /* Call this procedure again after one second. */ - sc->wd_timer.expires = jiffies + HZ; /* now plus one second */ - add_timer(&sc->wd_timer); - } - -/* This is the I/O configuration interface for Linux. */ - -/* This net_device method is called when IFF_UP goes false. */ -static int -linux_stop(struct net_device *net_dev) - { - softc_t *sc = dev_to_hdlc(net_dev)->priv; - - /* Stop the card and detach from the kernel. */ - detach_card(sc); /* doesn't fail */ - - free_irq(net_dev->irq, net_dev); /* doesn't fail */ - - del_timer(&sc->wd_timer); /* return value ignored */ - - return 0; - } - -/* This net_device method is called when IFF_UP goes true. */ -static int -linux_open(struct net_device *net_dev) - { - softc_t *sc = dev_to_hdlc(net_dev)->priv; - int error; - - /* Allocate PCI interrupt resources for the card. */ - if ((error = request_irq(net_dev->irq, &linux_interrupt, SA_SHIRQ, - NAME_UNIT, net_dev))) - { - printk("%s: request_irq() failed; error %d\n", NAME_UNIT, error); - return error; - } - - /* Arrange to call linux_watchdog() once a second. */ - init_timer(&sc->wd_timer); - sc->wd_timer.expires = jiffies + HZ; /* now plus one second */ - sc->wd_timer.function = &linux_watchdog; - sc->wd_timer.data = (unsigned long) sc; - add_timer(&sc->wd_timer); - - /* Start the card and attach a kernel interface and line protocol. */ - if ((error = -attach_card(sc, ""))) - linux_stop(net_dev); - else - { - net_dev->weight = sc->rxring.num_descs; /* input flow control */ - netif_start_queue(net_dev); /* output flow control */ - } - - return error; - } - -# if GEN_HDLC -static int -hdlc_attach(struct net_device *net_dev, - unsigned short encoding, unsigned short parity) - { return 0; } -# endif - -/* This pci_driver method is called during shutdown or module-unload. */ -/* This is called from user context; can sleep; no spinlocks! */ -static void __exit -linux_remove(struct pci_dev *pci_dev) - { - struct net_device *net_dev = (struct net_device *)pci_get_drvdata(pci_dev); - softc_t *sc = dev_to_hdlc(net_dev)->priv; - - if (net_dev == NULL) return; - - /* Assume that linux_stop() has already been called. */ - if (sc->flags & FLAG_NETDEV) -# if GEN_HDLC - unregister_hdlc_device(net_dev); -# else - unregister_netdev(net_dev); -# endif - -# if (IOREF_CSR == 0) - if (sc->csr_membase != NULL) - iounmap(sc->csr_membase); -# endif - - pci_disable_device(pci_dev); - - if (sc->csr_iobase != 0) - pci_release_regions(pci_dev); - - pci_set_drvdata(pci_dev, NULL); - - kfree(sc); - free_netdev(net_dev); - } - -static void -setup_netdev(struct net_device *net_dev) - { - /* Initialize the generic network device. */ - /* Note similarity to BSD's lmc_ifnet_attach(). */ - net_dev->flags = IFF_POINTOPOINT; - net_dev->flags |= IFF_RUNNING; - net_dev->open = linux_open; - net_dev->stop = linux_stop; - net_dev->hard_start_xmit = linux_start; - net_dev->do_ioctl = linux_ioctl; - net_dev->get_stats = linux_stats; - net_dev->tx_timeout = linux_timeout; - net_dev->poll = linux_poll; - net_dev->watchdog_timeo = 1 * HZ; - net_dev->tx_queue_len = SNDQ_MAXLEN; - net_dev->mtu = MAX_DESC_LEN; - net_dev->type = ARPHRD_RAWHDLC; -/* The receiver generates frag-lists for packets >4032 bytes. */ -/* The transmitter accepts scatter/gather lists and frag-lists. */ -/* However Linux linearizes outgoing packets since our hardware */ -/* doesn't compute soft checksums. All that work for nothing! */ -/*net_dev->features |= NETIF_F_SG; */ -/*net_dev->features |= NETIF_F_FRAGLIST; */ - } - -/* This pci_driver method is called during boot or module-load. */ -/* This is called from user context; can sleep; no spinlocks! */ -static int __init -linux_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) - { - u_int32_t cfid, csid; - struct net_device *net_dev; - softc_t *sc; - int error; - - /* Looking for a DEC 21140A chip on any Lan Media Corp card. */ - pci_read_config_dword(pci_dev, TLP_CFID, &cfid); - if (cfid != TLP_CFID_TULIP) return -ENXIO; - pci_read_config_dword(pci_dev, TLP_CSID, &csid); - switch (csid) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - case TLP_CSID_T3: - case TLP_CSID_SSI: - case TLP_CSID_T1E1: - break; - default: - return -ENXIO; - } - - /* Declare that these cards use 32-bit single-address PCI cycles. */ - if ((error = pci_set_dma_mask(pci_dev, DMA_32BIT_MASK))) - { - printk("%s: pci_set_dma_mask() failed; error %d\n", DEVICE_NAME, error); - return error; - } - pci_set_consistent_dma_mask(pci_dev, DMA_32BIT_MASK); /* can't fail */ - -# if GEN_HDLC /* generic-hdlc line protocols */ - - /* device driver instance data, aka Soft Context or sc */ - if ((sc = kmalloc(sizeof(softc_t), GFP_KERNEL)) == NULL) - { - printk("%s: kmalloc() failed\n", DEVICE_NAME); - return -ENOMEM; - } - memset(sc, 0, sizeof(softc_t)); - - /* Allocate space for the HDLC network device struct. */ - if ((net_dev = alloc_hdlcdev(sc)) == NULL) - { - printk("%s: alloc_hdlcdev() failed\n", DEVICE_NAME); - kfree(sc); - return -ENOMEM; - } - - /* Initialize the network device struct. */ - setup_netdev(net_dev); - - /* Initialize the HDLC extension to the network device. */ - sc->hdlc_dev = dev_to_hdlc(net_dev); - sc->hdlc_dev->attach = hdlc_attach; /* noop for this driver */ - sc->hdlc_dev->xmit = linux_start; /* the REAL hard_start_xmit() */ - -# else /* GEN_HDLC */ /* no line protocol. */ - - /* Allocate space for the bare network device struct. */ - net_dev = alloc_netdev(sizeof(softc_t), DEVICE_NAME"%d", setup_netdev); - if (net_dev == NULL) - { - printk("%s: alloc_netdev() failed\n", DEVICE_NAME); - return -ENOMEM; - } - /* device driver instance data, aka Soft Context or sc */ - sc = net_dev->priv; - -# endif /* GEN_HDLC */ - - sc->net_dev = net_dev; /* NAME_UNIT macro needs this */ - sc->pci_dev = pci_dev; /* READ/WRITE_PCI_CFG macros need this */ - - /* Cross-link pci_dev and net_dev. */ - pci_set_drvdata(pci_dev, net_dev); /* pci_dev->driver_data = net_dev */ - SET_NETDEV_DEV(net_dev, &pci_dev->dev); /* net_dev->class_dev.dev = &pci_dev->dev */ - SET_MODULE_OWNER(net_dev); /* ??? NOOP in linux-2.6.3. ??? */ - - /* Sets cfcs.io and cfcs.mem; sets pci_dev->irq based on cfit.int */ - if ((error = pci_enable_device(pci_dev))) - { - printk("%s: pci_enable_device() failed; error %d\n", DEVICE_NAME, error); - linux_remove(pci_dev); - return error; - } - net_dev->irq = pci_dev->irq; /* linux_open/stop need this */ - - /* Allocate PCI memory and IO resources to access the Tulip chip CSRs. */ - if ((error = pci_request_regions(pci_dev, DEVICE_NAME))) - { - printk("%s: pci_request_regions() failed; error %d\n", DEVICE_NAME, error); - linux_remove(pci_dev); - return error; - } - net_dev->base_addr = pci_resource_start(pci_dev, 0); - net_dev->mem_start = pci_resource_start(pci_dev, 1); - net_dev->mem_end = pci_resource_end(pci_dev, 1); - sc->csr_iobase = net_dev->base_addr; - -# if (IOREF_CSR == 0) - sc->csr_membase = ioremap_nocache(net_dev->mem_start, TLP_CSR_SIZE); - if (sc->csr_membase == NULL) - { - printk("%s: ioremap_nocache() failed\n", DEVICE_NAME); - linux_remove(pci_dev); - return -EFAULT; - } -# endif - - /* Sets cfcs.master, enabling PCI DMA; checks latency timer value. */ - pci_set_master(pci_dev); /* Later, attach_card() does this too. */ - - /* Initialize the top-half and bottom-half locks. */ - /* Top_lock must be initialized before net_dev is registered. */ - init_MUTEX(&sc->top_lock); - spin_lock_init(&sc->bottom_lock); - -# if GEN_HDLC - if ((error = register_hdlc_device(net_dev))) - { - printk("%s: register_hdlc_device() failed; error %d\n", DEVICE_NAME, error); - linux_remove(pci_dev); - return error; - } -# else - if ((error = register_netdev(net_dev))) - { - printk("%s: register_netdev() failed; error %d\n", DEVICE_NAME, error); - linux_remove(pci_dev); - return error; - } -# endif - /* The NAME_UNIT macro now works. Use DEVICE_NAME before this. */ - sc->flags |= FLAG_NETDEV; - - /* What kind of card are we driving? */ - switch (READ_PCI_CFG(sc, TLP_CSID)) - { - case TLP_CSID_HSSI: - case TLP_CSID_HSSIc: - sc->dev_desc = HSSI_DESC; - sc->card = &hssi_card; - break; - case TLP_CSID_T3: - sc->dev_desc = T3_DESC; - sc->card = &t3_card; - break; - case TLP_CSID_SSI: - sc->dev_desc = SSI_DESC; - sc->card = &ssi_card; - break; - case TLP_CSID_T1E1: - sc->dev_desc = T1E1_DESC; - sc->card = &t1_card; - break; - default: /* shouldn't happen! */ - linux_remove(pci_dev); - return -ENXIO; - } - - /* Announce the hardware on the console. */ - printk("%s: <%s> io 0x%04lx/9 mem 0x%08lx/25 rom 0x%08lx/14 irq %d pci %s\n", - NAME_UNIT, sc->dev_desc, pci_resource_start(pci_dev, 0), - pci_resource_start(pci_dev, 1), pci_resource_start(pci_dev, 6), - pci_dev->irq, pci_name(pci_dev)); - - return 0; - } - -/* This pci driver knows how to drive these devices: */ -static __initdata struct pci_device_id pci_device_id_tbl[] = - { - /* Looking for a DEC 21140A chip on any Lan Media Corp card. */ - { 0x1011, 0x0009, 0x1376, PCI_ANY_ID, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 } - }; -MODULE_DEVICE_TABLE(pci, pci_device_id_tbl); - -static struct pci_driver pci_driver = - { - .name = DEVICE_NAME, - .id_table = pci_device_id_tbl, - .probe = linux_probe, - .remove = __devexit_p(linux_remove), - /* This driver does not suspend and resume. */ - }; - -/* This ultimately calls our pci_driver.probe() method. */ -static int __init linux_modload(void) - { return pci_module_init(&pci_driver); } -module_init(linux_modload); - -/* This ultimately calls our pci_driver.remove() method. */ -static void __exit linux_modunload(void) - { pci_unregister_driver(&pci_driver); } -module_exit(linux_modunload); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("Device driver for SBE/LMC Wide-Area Network cards"); -MODULE_AUTHOR("David Boggs "); - -#endif /* __linux__ */ diff --git a/sys/dev/lmc/if_lmc.h b/sys/dev/lmc/if_lmc.h index e89c739d46f1..fe4e7d010c57 100644 --- a/sys/dev/lmc/if_lmc.h +++ b/sys/dev/lmc/if_lmc.h @@ -620,13 +620,6 @@ # define LMCIOCREAD _IOWR('i', 243, struct ioctl) # define LMCIOCWRITE _IOW('i', 244, struct ioctl) # define LMCIOCTL _IOWR('i', 245, struct ioctl) -#elif defined(__linux__) /* sigh */ -# define LMCIOCGSTAT SIOCDEVPRIVATE+0 -# define LMCIOCGCFG SIOCDEVPRIVATE+1 -# define LMCIOCSCFG SIOCDEVPRIVATE+2 -# define LMCIOCREAD SIOCDEVPRIVATE+3 -# define LMCIOCWRITE SIOCDEVPRIVATE+4 -# define LMCIOCTL SIOCDEVPRIVATE+5 #endif struct iohdr /* all LMCIOCs begin with this */ @@ -984,12 +977,8 @@ struct dma_desc #endif u_int32_t address1; /* buffer1 bus address */ u_int32_t address2; /* buffer2 bus address */ -#if (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) bus_dmamap_t map; /* bus dmamap for this descriptor */ # define TLP_BUS_DSL_VAL (sizeof(bus_dmamap_t) & TLP_BUS_DSL) -#else -# define TLP_BUS_DSL_VAL 0 -#endif } __attribute__ ((packed)); /* Tulip DMA descriptor status bits */ @@ -1029,18 +1018,13 @@ struct desc_ring u_int32_t dma_addr; /* bus address for desc array */ int size_descs; /* bus_dmamap_sync needs this */ int num_descs; /* used to set rx quota */ -#ifdef __linux__ - struct sk_buff *head; /* tail-queue of skbuffs */ - struct sk_buff *tail; -#elif BSD +#if BSD struct mbuf *head; /* tail-queue of mbufs */ struct mbuf *tail; -# if (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) bus_dma_tag_t tag; /* bus_dma tag for desc array */ bus_dmamap_t map; /* bus_dma map for desc array */ bus_dma_segment_t segs[2]; /* bus_dmamap_load() or bus_dmamem_alloc() */ int nsegs; /* bus_dmamap_load() or bus_dmamem_alloc() */ -# endif #endif }; @@ -1085,33 +1069,7 @@ struct card /* FreeBSD wants struct ifnet first in the softc. */ struct softc { -#if (defined(__NetBSD__) || defined(__OpenBSD__)) - struct device dev; /* base device -- must be first in softc */ - pcitag_t pa_tag; /* pci_conf_read/write need this */ - pci_chipset_tag_t pa_pc; /* pci_conf_read/write need this */ - bus_dma_tag_t pa_dmat; /* bus_dma needs this */ - bus_space_tag_t csr_tag; /* bus_space needs this */ - bus_space_handle_t csr_handle;/* bus_space needs this */ - pci_intr_handle_t intr_handle;/* interrupt handle */ - void *irq_cookie; /* pci_intr_disestablish needs this */ - void *sdh_cookie; /* shutdownhook_disestablish needs this */ - struct simplelock top_lock; /* lock card->watchdog vs core_ioctl */ - struct simplelock bottom_lock;/* lock for buf queues & descriptor rings */ - struct mbuf *tx_mbuf; /* hang mbuf here while building dma descs */ -#endif /* __NetBSD__ || __OpenBSD__ */ -#ifdef __bsdi__ - struct device dev; /* base device -- must be first in softc */ - struct isadev id; /* bus resource */ - struct intrhand ih; /* interrupt vectoring */ - struct atshutdown ats; /* shutdown hook */ - pci_devaddr_t cfgbase; /* base address of PCI config regs */ - u_int16_t csr_iobase; /* io base address of Tulip CSRs */ - u_int32_t *csr_membase; /* kv mem base address of Tulip CSRs */ - struct simplelock top_lock; /* lock card->watchdog vs core_ioctl */ - struct simplelock bottom_lock;/* lock for buf queues & descriptor rings */ - struct mbuf *tx_mbuf; /* hang mbuf here while building dma descs */ -#endif /* __bsdi__ */ /* State for kernel-resident Line Protocols */ #if IFNET @@ -1130,14 +1088,6 @@ struct softc # endif #endif -#ifdef __linux__ -# if GEN_HDLC - hdlc_device *hdlc_dev; /* state for HDLC code */ - sync_serial_settings hdlc_settings; /* state set by sethdlc program */ -# else - struct net_device_stats net_stats; /* linux_stats storage */ -# endif -#endif #if NETGRAPH node_p ng_node; /* pointer to our node struct */ @@ -1151,7 +1101,6 @@ struct softc # endif #endif -#ifdef __FreeBSD__ struct callout callout; /* watchdog needs this */ struct device *dev; /* base device pointer */ bus_space_tag_t csr_tag; /* bus_space needs this */ @@ -1173,19 +1122,7 @@ struct softc int top_spl; /* lock card->watchdog vs core_ioctl */ int bottom_spl; /* lock for buf queues & descriptor rings */ # endif -#endif /* __FreeBSD__ */ -#ifdef __linux__ - struct pci_dev *pci_dev; /* READ/WRITE_PCI_CFG macros need this */ - struct net_device *net_dev; /* NAME_UNIT macro needs this */ - struct timer_list wd_timer; /* timer calls watchdog() once a second */ - u_int32_t csr_iobase; /* io base address of Tulip CSRs */ - void *csr_membase; /* kv mem base address of Tulip CSRs */ - struct sk_buff *tx_skb; /* hang skb here while building dma descs */ - int quota; /* used for incoming packet flow control */ - struct semaphore top_lock; /* lock card->watchdog vs core_ioctl */ - spinlock_t bottom_lock; /* lock for buf queues & descriptor rings */ -#endif /* __linux__ */ /* Top-half state used by all card types; lock with top_lock, */ const char *dev_desc; /* string describing type of board */ @@ -1210,7 +1147,6 @@ struct softc /* Hide the minor differences between OS versions */ -#ifdef __FreeBSD__ typedef void intr_return_t; # define READ_PCI_CFG(sc, addr) pci_read_config ((sc)->dev, addr, 4) # define WRITE_PCI_CFG(sc, addr, data) pci_write_config((sc)->dev, addr, data, 4) @@ -1264,162 +1200,10 @@ struct softc # if (__FreeBSD_version >= 600000) # define IFF_RUNNING IFF_DRV_RUNNING # endif -#endif /* __FreeBSD__ */ -#ifdef __NetBSD__ - typedef int intr_return_t; -# define READ_PCI_CFG(sc, addr) pci_conf_read ((sc)->pa_pc, (sc)->pa_tag, addr) -# define WRITE_PCI_CFG(sc, addr, data) pci_conf_write((sc)->pa_pc, (sc)->pa_tag, addr, data) -# define READ_CSR(csr) bus_space_read_4 (sc->csr_tag, sc->csr_handle, csr) -# define WRITE_CSR(csr, val) bus_space_write_4(sc->csr_tag, sc->csr_handle, csr, val) -# define NAME_UNIT sc->dev.dv_xname -# define DRIVER_DEBUG ((sc->config.debug) || (sc->ifp->if_flags & IFF_DEBUG)) -# define TOP_TRYLOCK simple_lock_try(&sc->top_lock) -# define TOP_UNLOCK simple_unlock (&sc->top_lock) -# define BOTTOM_TRYLOCK simple_lock_try(&sc->bottom_lock) -# define BOTTOM_UNLOCK simple_unlock (&sc->bottom_lock) -# define CHECK_CAP suser(curproc->p_ucred, &curproc->p_acflag) -# define DISABLE_INTR int spl = splnet() -# define ENABLE_INTR splx(spl) -# define IRQ_NONE 0 -# define IRQ_HANDLED 1 -# define IFP2SC(ifp) (ifp)->if_softc -# define COPY_BREAK MHLEN -# define SLEEP(usecs) tsleep(sc, PCATCH | PZERO, DEVICE_NAME, 1+(usecs/tick)) -# define DMA_SYNC(map, size, flags) bus_dmamap_sync(ring->tag, map, 0, size, flags) -# define DMA_LOAD(map, addr, size) bus_dmamap_load(ring->tag, map, addr, size, 0, BUS_DMA_NOWAIT) -# if (NBPFILTER != 0) -# define LMC_BPF_MTAP(mbuf) if (sc->ifp->if_bpf) bpf_mtap(sc->ifp->if_bpf, mbuf) -# define LMC_BPF_ATTACH(dlt, len) bpfattach(sc->ifp, dlt, len) -# define LMC_BPF_DETACH bpfdetach(sc->ifp) -# endif -#endif /* __NetBSD__ */ -#ifdef __OpenBSD__ - typedef int intr_return_t; -# define READ_PCI_CFG(sc, addr) pci_conf_read ((sc)->pa_pc, (sc)->pa_tag, addr) -# define WRITE_PCI_CFG(sc, addr, data) pci_conf_write((sc)->pa_pc, (sc)->pa_tag, addr, data) -# define READ_CSR(csr) bus_space_read_4 (sc->csr_tag, sc->csr_handle, csr) -# define WRITE_CSR(csr, val) bus_space_write_4(sc->csr_tag, sc->csr_handle, csr, val) -# define NAME_UNIT sc->dev.dv_xname -# define DRIVER_DEBUG ((sc->config.debug) || (sc->ifp->if_flags & IFF_DEBUG)) -# define TOP_TRYLOCK simple_lock_try(&sc->top_lock) -# define TOP_UNLOCK simple_unlock (&sc->top_lock) -# define BOTTOM_TRYLOCK simple_lock_try(&sc->bottom_lock) -# define BOTTOM_UNLOCK simple_unlock (&sc->bottom_lock) -# define CHECK_CAP suser(curproc, 0) -# define DISABLE_INTR int spl = splnet() -# define ENABLE_INTR splx(spl) -# define IRQ_NONE 0 -# define IRQ_HANDLED 1 -# define IFP2SC(ifp) (ifp)->if_softc -# define COPY_BREAK MHLEN -# define SLEEP(usecs) tsleep(sc, PCATCH | PZERO, DEVICE_NAME, 1+(usecs/tick)) -# define DMA_SYNC(map, size, flags) bus_dmamap_sync(ring->tag, map, 0, size, flags) -# define DMA_LOAD(map, addr, size) bus_dmamap_load(ring->tag, map, addr, size, 0, BUS_DMA_NOWAIT) -# if (NBPFILTER != 0) -# define LMC_BPF_MTAP(mbuf) if (sc->ifp->if_bpf) bpf_mtap(sc->ifp->if_bpf, mbuf) -# define LMC_BPF_ATTACH(dlt, len) bpfattach(&sc->ifp->if_bpf, sc->ifp, dlt, len) -# define LMC_BPF_DETACH bpfdetach(sc->ifp) -# endif -#endif /* __OpenBSD__ */ -#ifdef __bsdi__ - typedef int intr_return_t; -# define READ_PCI_CFG(sc, addr) pci_inl(&(sc)->cfgbase, addr) -# define WRITE_PCI_CFG(sc, addr, data) pci_outl(&(sc)->cfgbase, addr, data) -# if IOREF_CSR -# define READ_CSR(csr) inl(sc->csr_iobase+(csr)) -# define WRITE_CSR(csr, val) outl(sc->csr_iobase+(csr), (val)) -# else -# error Memory refs to Tulip CSRs cause page faults in BSD/OS -# define READ_CSR(csr) (0 + *(sc->csr_membase+(csr))) -# define WRITE_CSR(csr, val) ((void)(*(sc->csr_membase+(csr)) = (val))) -# endif -# define NAME_UNIT sc->dev.dv_xname -# define DRIVER_DEBUG ((sc->config.debug) || (sc->ifp->if_flags & IFF_DEBUG)) -# define TOP_TRYLOCK simple_lock_try(&sc->top_lock) -# define TOP_UNLOCK simple_unlock (&sc->top_lock) -# define BOTTOM_TRYLOCK simple_lock_try(&sc->bottom_lock) -# define BOTTOM_UNLOCK simple_unlock (&sc->bottom_lock) -# define CHECK_CAP suser(PCPU(curproc)->p_ucred, &PCPU(curproc)->p_acflag) -# define DISABLE_INTR int spl = splimp() -# define ENABLE_INTR splx(spl) -# define IRQ_NONE 1 /* XXX 0 */ -# define IRQ_HANDLED 1 -# define IFP2SC(ifp) (ifp)->if_softc -# define COPY_BREAK MHLEN -# define SLEEP(usecs) tsleep(sc, PCATCH | PZERO, DEVICE_NAME, 1+(usecs/tick)) -# define DMA_SYNC(map, size, flags) /* nothing */ -# define DMA_LOAD(map, addr, size) 0 -# define bus_dmamap_unload(tag, map) /* nothing */ -# define bus_dmamap_destroy(tag, map) /* nothing */ -# if (NBPFILTER != 0) -# define LMC_BPF_MTAP(mbuf) if (sc->ifp->if_bpf) bpf_mtap(sc->ifp->if_bpf, mbuf) -# define LMC_BPF_ATTACH(dlt, len) bpfattach(&sc->ifp->if_bpf, sc->ifp, dlt, len) -# define LMC_BPF_DETACH /* bpfdetach(sc->ifp) */ -# endif -# define memcpy(dst, src, len) bcopy(src, dst, len) -# define if_detach(ifp) /* nothing */ -/* BSD/OS-4.1 doesn't have a back pointer to softc in struct ifnet, */ -/* and it passes a unit number not a struct ifnet* to watchdog. */ -# if (_BSDI_VERSION <= 199910) - extern struct cfdriver lmccd; -# undef IFP2SC -# define UNIT2SC(unit) ((softc_t *)lmccd.cd_devs[unit]) -# define IFP2SC(ifp) (UNIT2SC((ifp)->if_unit)) -# endif -#endif /* __bsdi__ */ - -#ifdef __linux__ -static u_int32_t /* inline? so rare it doesn't matter */ -READ_PCI_CFG(softc_t *sc, u_int32_t addr) - { - u_int32_t data; - pci_read_config_dword(sc->pci_dev, addr, &data); - return data; - } -# define WRITE_PCI_CFG(sc, addr, data) pci_write_config_dword(sc->pci_dev, addr, data) -# if IOREF_CSR -# define READ_CSR(csr) inl((sc->csr_iobase+(csr))) -# define WRITE_CSR(csr, val) outl((val),(sc->csr_iobase+(csr))) -# else -# define READ_CSR(csr) readl((sc->csr_membase+(csr))) -# define WRITE_CSR(csr, val) writel((val),(sc->csr_membase+(csr))) -# endif -# define NAME_UNIT sc->net_dev->name -# define DRIVER_DEBUG ((sc->config.debug) || (sc->net_dev->flags & IFF_DEBUG)) -# define TOP_TRYLOCK ((down_trylock(&sc->top_lock)==0) ? 1:0) -# define TOP_UNLOCK up(&sc->top_lock) -# define BOTTOM_TRYLOCK spin_trylock_bh(&sc->bottom_lock) -# define BOTTOM_UNLOCK spin_unlock_bh(&sc->bottom_lock) -# define CHECK_CAP capable(CAP_NET_ADMIN)? 0 : -EPERM -# define DISABLE_INTR /* nothing */ -# define ENABLE_INTR /* nothing */ -# define COPY_BREAK 200 -# define DELAY(usecs) udelay(usecs) -# define SLEEP(usecs) do { set_current_state(TASK_INTERRUPTIBLE);\ - schedule_timeout(1+(usecs*HZ)/1000000UL); } while (0) -# define printf printk -# define copyin(u, k, len) copy_from_user(k, u, len) -# define microtime(time) do_gettimeofday(time) -# define malloc(len, t, f) kmalloc(len, GFP_KERNEL) -# define free(addr, t) kfree(addr) -# define LITTLE_ENDIAN 4321 -# define BIG_ENDIAN 1234 -# if defined(__LITTLE_ENDIAN) -# define BYTE_ORDER LITTLE_ENDIAN -# elif defined(__BIG_ENDIAN) -# define BYTE_ORDER BIG_ENDIAN -# else -# error "asm/byteorder.h is wrong" -# endif -# if (GEN_HDLC == 0) -# define dev_to_hdlc(net_dev) net_dev -# define hdlc_set_carrier(val, net_dev) /* nothing */ -# endif -#endif /* __linux__ */ #if (NBPFILTER == 0) # define LMC_BPF_MTAP(mbuf) /* nothing */ @@ -1541,9 +1325,7 @@ static void lmc_raw_input(struct ifnet *, struct mbuf *); #if BSD static void mbuf_enqueue(struct desc_ring *, struct mbuf *); static struct mbuf* mbuf_dequeue(struct desc_ring *); -# ifdef __FreeBSD__ static void fbsd_dmamap_load(void *, bus_dma_segment_t *, int, int); -# endif static int create_ring(softc_t *, struct desc_ring *, int); static void destroy_ring(softc_t *, struct desc_ring *); static int rxintr_cleanup(softc_t *); @@ -1553,18 +1335,6 @@ static int txintr_setup_mbuf(softc_t *, struct mbuf *); static int txintr_setup(softc_t *); #endif /* BSD */ -#ifdef __linux__ -static void skbuff_enqueue(struct desc_ring *, struct sk_buff *); -static struct sk_buff* skbuff_dequeue(struct desc_ring *); -static int create_ring(softc_t *, struct desc_ring *, int); -static void destroy_ring(softc_t *, struct desc_ring *); -static int rxintr_cleanup(softc_t *); -static int rxintr_setup(softc_t *); -static int txintr_cleanup(softc_t *sc); -static int txintr_setup_frag(softc_t *, char *, int); -static int txintr_setup_skb(softc_t *, struct sk_buff *); -static int txintr_setup(softc_t *); -#endif /* __linux__ */ static void check_intr_status(softc_t *); static void core_interrupt(void *, int); @@ -1596,10 +1366,6 @@ static int lmc_ifnet_ioctl(struct ifnet *, u_long, caddr_t); static void lmc_ifnet_start(struct ifnet *); static int lmc_raw_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); -# ifdef __OpenBSD__ -static int ifmedia_change(struct ifnet *); -static void ifmedia_status(struct ifnet *, struct ifmediareq *); -# endif /* __OpenBSD__ */ static void setup_ifnet(struct ifnet *); static int lmc_ifnet_attach(softc_t *); static void lmc_ifnet_detach(softc_t *); @@ -1638,52 +1404,14 @@ static void shutdown_card(void *); static int attach_card(softc_t *, const char *); static void detach_card(softc_t *); -#ifdef __FreeBSD__ static int fbsd_probe(device_t); static int fbsd_detach(device_t); static int fbsd_shutdown(device_t); static int fbsd_attach(device_t); -#endif /* __FreeBSD__ */ -#ifdef __NetBSD__ -static int nbsd_match(struct device *t, struct cfdata *, void *); -static int nbsd_detach(struct device *, int); -static void nbsd_attach(struct device *, struct device *, void *); -static int lkm_nbsd_match(struct pci_attach_args *); -int if_lmc_lkmentry(struct lkm_table *, int, int); -#endif /* __NetBSD__ */ -#ifdef __OpenBSD__ -static int obsd_match(struct device *, void *, void *); -static int obsd_detach(struct device *, int); -static void obsd_attach(struct device *, struct device *, void *); -int if_lmc_lkmentry(struct lkm_table *, int, int); -#endif /* __OpenBSD__ */ -#ifdef __bsdi__ -static int bsdi_match(pci_devaddr_t *); -static int bsdi_probe(struct device *, struct cfdata *, void *); -static void bsdi_attach(struct device *, struct device *, void *); -#endif /* __bsdi__ */ -#ifdef __linux__ -static irqreturn_t linux_interrupt(int, void *, struct pt_regs *); -static int linux_poll(struct net_device *, int *); -static int linux_start(struct sk_buff *, struct net_device *); -static void linux_timeout(struct net_device *); -static int linux_ioctl(struct net_device *, struct ifreq *, int); -static struct net_device_stats * linux_stats(struct net_device *); -static void linux_watchdog(unsigned long); -static int linux_stop(struct net_device *); -static int linux_open(struct net_device *); -# if GEN_HDLC -static int hdlc_attach(struct net_device *, - unsigned short, unsigned short); -# endif -static void __exit linux_remove(struct pci_dev *); -static void setup_netdev(struct net_device *); -static int __init linux_probe(struct pci_dev *, const struct pci_device_id *); -#endif /* __linux__ */ #endif /* KERNEL */ diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index 1e879ba9459f..b7e90e9da4ba 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -1245,7 +1245,7 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, STAILQ_INSERT_TAIL(&txq->active, bf, bf_list); MALO_TXDESC_SYNC(txq, ds, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->malo_timer = 5; MALO_TXQ_UNLOCK(txq); return 0; @@ -1283,7 +1283,7 @@ malo_start(struct ifnet *ifp) * Pass the frame to the h/w for transmission. */ if (malo_tx_start(sc, ni, bf, m)) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (bf != NULL) { bf->bf_m = NULL; bf->bf_node = NULL; @@ -1341,7 +1341,7 @@ malo_watchdog(void *arg) /* XXX no way to reset h/w. now */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->malo_stats.mst_watchdog++; } } @@ -1870,7 +1870,7 @@ malo_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, * Pass the frame to the h/w for transmission. */ if (malo_tx_start(sc, ni, bf, m) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); bf->bf_m = NULL; bf->bf_node = NULL; MALO_TXQ_LOCK(txq); @@ -2078,7 +2078,7 @@ malo_rx_proc(void *arg, int npending) #endif status = ds->status; if (status & MALO_RXD_STATUS_DECRYPT_ERR_MASK) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto rx_next; } /* @@ -2117,7 +2117,7 @@ malo_rx_proc(void *arg, int npending) /* XXX don't need mbuf, just dma buffer */ mnew = malo_getrxmbuf(sc, bf); if (mnew == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto rx_next; } /* @@ -2158,7 +2158,7 @@ malo_rx_proc(void *arg, int npending) len, ds->rate, rssi); } #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* dispatch */ ni = ieee80211_find_rxnode(ic, diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c index d479aa243722..c35dd04dcbf6 100644 --- a/sys/dev/mge/if_mge.c +++ b/sys/dev/mge/if_mge.c @@ -1161,7 +1161,7 @@ mge_intr_rx_locked(struct mge_softc *sc, int count) count -= 1; } - ifp->if_ipackets += rx_npkts; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, rx_npkts); return (rx_npkts); } @@ -1236,9 +1236,9 @@ mge_intr_tx_locked(struct mge_softc *sc) /* Update collision statistics */ if (status & MGE_ERR_SUMMARY) { if ((status & MGE_ERR_MASK) == MGE_TX_ERROR_LC) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if ((status & MGE_ERR_MASK) == MGE_TX_ERROR_RL) - ifp->if_collisions += 16; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16); } bus_dmamap_sync(sc->mge_tx_dtag, dw->buffer_dmap, @@ -1248,7 +1248,7 @@ mge_intr_tx_locked(struct mge_softc *sc) dw->buffer = (struct mbuf*)NULL; send++; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } if (send) { @@ -1516,7 +1516,7 @@ mge_watchdog(struct mge_softc *sc) return; } - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); mge_stop(sc); diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c index 2d0e60728985..381ca47452c2 100644 --- a/sys/dev/mii/rgephy.c +++ b/sys/dev/mii/rgephy.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #include "miibus_if.h" #include -#include +#include static int rgephy_probe(device_t); static int rgephy_attach(device_t); diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index b98c0403ba42..21c9a66f6cf4 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include "miidevs.h" #include -#include +#include #include "miibus_if.h" diff --git a/sys/dev/mii/rlswitch.c b/sys/dev/mii/rlswitch.c index 5082e7ccb060..d3e3c938df7e 100644 --- a/sys/dev/mii/rlswitch.c +++ b/sys/dev/mii/rlswitch.c @@ -55,7 +55,7 @@ __FBSDID("$FreeBSD$"); #include "miidevs.h" #include -#include +#include #include "miibus_if.h" diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 2ed9d6c8f171..16e7485a911f 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -2987,14 +2987,14 @@ msk_watchdog(struct msk_if_softc *sc_if) if (bootverbose) if_printf(sc_if->msk_ifp, "watchdog timeout " "(missed link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; msk_init_locked(sc_if); return; } if_printf(ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; msk_init_locked(sc_if); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -3216,7 +3216,7 @@ msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, * handle this frame. */ if (len > MSK_MAX_FRAMELEN || len < ETHER_HDR_LEN) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); msk_discard_rxbuf(sc_if, cons); break; } @@ -3225,7 +3225,7 @@ msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, ((status & GMR_FS_RX_OK) == 0) || (rxlen != len)) { /* Don't count flow-control packet as errors. */ if ((status & GMR_FS_GOOD_FC) == 0) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); msk_discard_rxbuf(sc_if, cons); break; } @@ -3237,7 +3237,7 @@ msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, #endif m = rxd->rx_m; if (msk_newbuf(sc_if, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* Reuse old buffer. */ msk_discard_rxbuf(sc_if, cons); break; @@ -3248,7 +3248,7 @@ msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) msk_fixup_rx(m); #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) msk_rxcsum(sc_if, control, m); /* Check for VLAN tagged packets. */ @@ -3290,7 +3290,7 @@ msk_jumbo_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, ((status & GMR_FS_RX_OK) == 0) || (rxlen != len)) { /* Don't count flow-control packet as errors. */ if ((status & GMR_FS_GOOD_FC) == 0) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); msk_discard_jumbo_rxbuf(sc_if, cons); break; } @@ -3302,7 +3302,7 @@ msk_jumbo_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, #endif m = jrxd->rx_m; if (msk_jumbo_newbuf(sc_if, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* Reuse old buffer. */ msk_discard_jumbo_rxbuf(sc_if, cons); break; @@ -3313,7 +3313,7 @@ msk_jumbo_rxeof(struct msk_if_softc *sc_if, uint32_t status, uint32_t control, if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) msk_fixup_rx(m); #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) msk_rxcsum(sc_if, control, m); /* Check for VLAN tagged packets. */ @@ -3368,7 +3368,7 @@ msk_txeof(struct msk_if_softc *sc_if, int idx) BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc_if->msk_cdata.msk_tx_tag, txd->tx_dmamap); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); KASSERT(txd->tx_m != NULL, ("%s: freeing NULL mbuf!", __func__)); m_freem(txd->tx_m); diff --git a/sys/dev/mvs/mvs.c b/sys/dev/mvs/mvs.c index dd5bb32cf34f..8118aa7370ca 100644 --- a/sys/dev/mvs/mvs.c +++ b/sys/dev/mvs/mvs.c @@ -122,6 +122,7 @@ mvs_ch_attach(device_t dev) ch->unit = (intptr_t)device_get_ivars(dev); ch->quirks = ctlr->quirks; mtx_init(&ch->mtx, "MVS channel lock", NULL, MTX_DEF); + ch->pm_level = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "pm_level", &ch->pm_level); if (ch->pm_level > 3) diff --git a/sys/dev/mvs/mvs_pci.c b/sys/dev/mvs/mvs_pci.c index b2b9944adfe8..bdfccfbb871b 100644 --- a/sys/dev/mvs/mvs_pci.c +++ b/sys/dev/mvs/mvs_pci.c @@ -111,6 +111,7 @@ mvs_attach(device_t dev) i++; ctlr->channels = mvs_ids[i].ports; ctlr->quirks = mvs_ids[i].quirks; + ctlr->ccc = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "ccc", &ctlr->ccc); ctlr->cccc = 8; diff --git a/sys/dev/mvs/mvs_soc.c b/sys/dev/mvs/mvs_soc.c index 14579d0c3640..c68b324e04b2 100644 --- a/sys/dev/mvs/mvs_soc.c +++ b/sys/dev/mvs/mvs_soc.c @@ -114,6 +114,7 @@ mvs_attach(device_t dev) i++; ctlr->channels = mvs_ids[i].ports; ctlr->quirks = mvs_ids[i].quirks; + ctlr->ccc = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "ccc", &ctlr->ccc); ctlr->cccc = 8; diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index 7b3308848b61..3ea24749421b 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -1434,7 +1434,7 @@ mwl_start(struct ifnet *ifp) * Pass the frame to the h/w for transmission. */ if (mwl_tx_start(sc, ni, bf, m)) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); mwl_puttxbuf_head(txq, bf); ieee80211_free_node(ni); continue; @@ -1504,7 +1504,7 @@ mwl_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, * Pass the frame to the h/w for transmission. */ if (mwl_tx_start(sc, ni, bf, m)) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); mwl_puttxbuf_head(txq, bf); ieee80211_free_node(ni); @@ -2741,7 +2741,7 @@ mwl_rx_proc(void *arg, int npending) #endif status = ds->Status; if (status & EAGLE_RXD_STATUS_DECRYPT_ERR_MASK) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); sc->sc_stats.mst_rx_crypto++; /* * NB: Check EAGLE_RXD_STATUS_GENERAL_DECRYPT_ERR @@ -2887,7 +2887,7 @@ mwl_rx_proc(void *arg, int npending) ieee80211_dump_pkt(ic, mtod(m, caddr_t), len, ds->Rate, rssi); } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* dispatch */ ni = ieee80211_find_rxnode(ic, @@ -3405,7 +3405,7 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf * STAILQ_INSERT_TAIL(&txq->active, bf, bf_list); MWL_TXDESC_SYNC(txq, ds, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->sc_tx_timer = 5; MWL_TXQ_UNLOCK(txq); @@ -4785,7 +4785,7 @@ mwl_watchdog(void *arg) mwl_reset(ifp); mwl_txq_dump(&sc->sc_txq[0]);/*XXX*/ #endif - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->sc_stats.mst_watchdog++; } } @@ -4928,8 +4928,10 @@ mwl_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCGMVSTATS: mwl_hal_gethwstats(sc->sc_mh, &sc->sc_stats.hw_stats); /* NB: embed these numbers to get a consistent view */ - sc->sc_stats.mst_tx_packets = ifp->if_opackets; - sc->sc_stats.mst_rx_packets = ifp->if_ipackets; + sc->sc_stats.mst_tx_packets = + ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS); + sc->sc_stats.mst_rx_packets = + ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS); /* * NB: Drop the softc lock in case of a page fault; * we'll accept any potential inconsisentcy in the diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c index e6cdf234407b..8de14857c517 100644 --- a/sys/dev/mxge/if_mxge.c +++ b/sys/dev/mxge/if_mxge.c @@ -211,7 +211,7 @@ mxge_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nsegs, } static int -mxge_dma_alloc(mxge_softc_t *sc, mxge_dma_t *dma, size_t bytes, +mxge_dma_alloc(mxge_softc_t *sc, mxge_dma_t *dma, size_t bytes, bus_size_t alignment) { int err; @@ -245,8 +245,8 @@ mxge_dma_alloc(mxge_softc_t *sc, mxge_dma_t *dma, size_t bytes, } /* allocate DMAable memory & map */ - err = bus_dmamem_alloc(dma->dmat, &dma->addr, - (BUS_DMA_WAITOK | BUS_DMA_COHERENT + err = bus_dmamem_alloc(dma->dmat, &dma->addr, + (BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO), &dma->map); if (err != 0) { device_printf(dev, "couldn't alloc mem (err = %d)\n", err); @@ -385,7 +385,7 @@ mxge_enable_nvidia_ecrc(mxge_softc_t *sc) /* XXXX Test below is commented because it is believed that doing config read/write beyond 0xff will access the config space - for the next larger function. Uncomment this and remove + for the next larger function. Uncomment this and remove the hacky pmap_mapdev() way of accessing config space when FreeBSD grows support for extended pcie config space access */ @@ -454,7 +454,7 @@ mxge_enable_nvidia_ecrc(mxge_softc_t *sc) } *ptr32 = val | 0x40; pmap_unmapdev((vm_offset_t)va, PAGE_SIZE); - if (mxge_verbose) + if (mxge_verbose) device_printf(sc->dev, "Enabled ECRC on upstream Nvidia bridge " "at %d:%d:%d\n", @@ -573,7 +573,7 @@ mxge_firmware_probe(mxge_softc_t *sc) } } - /* + /* * load the optimized firmware (which assumes aligned PCIe * completions) in order to see if it works on this host. */ @@ -583,12 +583,12 @@ mxge_firmware_probe(mxge_softc_t *sc) return status; } - /* + /* * Enable ECRC if possible */ mxge_enable_nvidia_ecrc(sc); - /* + /* * Run a DMA test which watches for unaligned completions and * aborts on the first one seen. Not required on Z8ES or newer. */ @@ -657,7 +657,7 @@ mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr) if (be32toh(hdr->mcp_type) != MCP_TYPE_ETH) { - device_printf(sc->dev, "Bad firmware type: 0x%x\n", + device_printf(sc->dev, "Bad firmware type: 0x%x\n", be32toh(hdr->mcp_type)); return EIO; } @@ -685,16 +685,16 @@ mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr) static void * z_alloc(void *nil, u_int items, u_int size) { - void *ptr; + void *ptr; - ptr = malloc(items * size, M_TEMP, M_NOWAIT); - return ptr; + ptr = malloc(items * size, M_TEMP, M_NOWAIT); + return ptr; } static void z_free(void *nil, void *ptr) { - free(ptr, M_TEMP); + free(ptr, M_TEMP); } @@ -732,7 +732,7 @@ mxge_load_firmware_helper(mxge_softc_t *sc, uint32_t *limit) /* the uncompressed size is stored as the firmware version, which would otherwise go unused */ - fw_len = (size_t) fw->version; + fw_len = (size_t) fw->version; inflate_buffer = malloc(fw_len, M_TEMP, M_NOWAIT); if (inflate_buffer == NULL) goto abort_with_zs; @@ -755,7 +755,7 @@ mxge_load_firmware_helper(mxge_softc_t *sc, uint32_t *limit) status = EIO; goto abort_with_buffer; } - hdr = (const void*)(inflate_buffer + hdr_offset); + hdr = (const void*)(inflate_buffer + hdr_offset); status = mxge_validate_firmware(sc, hdr); if (status != 0) @@ -832,14 +832,14 @@ mxge_dummy_rdma(mxge_softc_t *sc, int enable) i++; } if (*confirm != 0xffffffff) { - device_printf(sc->dev, "dummy rdma %s failed (%p = 0x%x)", - (enable ? "enable" : "disable"), confirm, + device_printf(sc->dev, "dummy rdma %s failed (%p = 0x%x)", + (enable ? "enable" : "disable"), confirm, *confirm); } return; } -static int +static int mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data) { mcp_cmd_t *buf; @@ -869,7 +869,7 @@ mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data) /* wait up to 20ms */ err = EAGAIN; for (sleep_total = 0; sleep_total < 20; sleep_total++) { - bus_dmamap_sync(sc->cmd_dma.dmat, + bus_dmamap_sync(sc->cmd_dma.dmat, sc->cmd_dma.map, BUS_DMASYNC_POSTREAD); wmb(); switch (be32toh(response->result)) { @@ -893,7 +893,7 @@ mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data) err = ENXIO; break; default: - device_printf(sc->dev, + device_printf(sc->dev, "mxge: command %d " "failed, result = %d\n", cmd, be32toh(response->result)); @@ -924,7 +924,7 @@ mxge_adopt_running_firmware(mxge_softc_t *sc) (sc->sram + MCP_HEADER_PTR_OFFSET)); if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > sc->sram_size) { - device_printf(sc->dev, + device_printf(sc->dev, "Running firmware has bad header offset (%d)\n", (int)hdr_offset); return EIO; @@ -943,7 +943,7 @@ mxge_adopt_running_firmware(mxge_softc_t *sc) status = mxge_validate_firmware(sc, hdr); free(hdr, M_DEVBUF); - /* + /* * check to see if adopted firmware has bug where adopting * it will cause broadcasts to be filtered unless the NIC * is kept in ALLMULTI mode @@ -1034,11 +1034,11 @@ mxge_load_firmware(mxge_softc_t *sc, int adopt) while (*confirm != 0xffffffff && i < 20) { DELAY(1000*10); i++; - bus_dmamap_sync(sc->cmd_dma.dmat, + bus_dmamap_sync(sc->cmd_dma.dmat, sc->cmd_dma.map, BUS_DMASYNC_POSTREAD); } if (*confirm != 0xffffffff) { - device_printf(sc->dev,"handoff failed (%p = 0x%x)", + device_printf(sc->dev,"handoff failed (%p = 0x%x)", confirm, *confirm); return ENXIO; @@ -1054,7 +1054,7 @@ mxge_update_mac_address(mxge_softc_t *sc) int status; - cmd.data0 = ((addr[0] << 24) | (addr[1] << 16) + cmd.data0 = ((addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3]); cmd.data1 = ((addr[4] << 8) | (addr[5])); @@ -1136,7 +1136,7 @@ mxge_set_multicast_list(mxge_softc_t *sc) err = mxge_send_cmd(sc, MXGEFW_LEAVE_ALL_MULTICAST_GROUPS, &cmd); if (err != 0) { - device_printf(sc->dev, + device_printf(sc->dev, "Failed MXGEFW_LEAVE_ALL_MULTICAST_GROUPS" ", error status: %d\n", err); return; @@ -1219,7 +1219,7 @@ mxge_reset(mxge_softc_t *sc, int interrupts_setup) cmd.data0 = sc->rx_ring_size; status = mxge_send_cmd(sc, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd); - /* + /* * Even though we already know how many slices are supported * via mxge_slice_probe(), MXGEFW_CMD_GET_MAX_RSS_QUEUES * has magic side effects, and must be called after a reset. @@ -1229,17 +1229,17 @@ mxge_reset(mxge_softc_t *sc, int interrupts_setup) * MXGEFW_CMD_SET_INTRQ_SIZE, since the intrq size is used by * the firmware to compute offsets. */ - + if (sc->num_slices > 1) { /* ask the maximum number of slices it supports */ status = mxge_send_cmd(sc, MXGEFW_CMD_GET_MAX_RSS_QUEUES, &cmd); if (status != 0) { - device_printf(sc->dev, + device_printf(sc->dev, "failed to get number of slices\n"); return status; } - /* + /* * MXGEFW_CMD_ENABLE_RSS_QUEUES must be called prior * to setting up the interrupt queue DMA */ @@ -1272,7 +1272,7 @@ mxge_reset(mxge_softc_t *sc, int interrupts_setup) } } - status |= mxge_send_cmd(sc, + status |= mxge_send_cmd(sc, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd); @@ -1282,7 +1282,7 @@ mxge_reset(mxge_softc_t *sc, int interrupts_setup) irq_claim = (volatile uint32_t *)(sc->sram + cmd.data0); - status |= mxge_send_cmd(sc, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, + status |= mxge_send_cmd(sc, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd); sc->irq_deassert = (volatile uint32_t *)(sc->sram + cmd.data0); if (status != 0) { @@ -1349,15 +1349,15 @@ mxge_change_throttle(SYSCTL_HANDLER_ARGS) sc = arg1; throttle = sc->throttle; err = sysctl_handle_int(oidp, &throttle, arg2, req); - if (err != 0) { - return err; - } + if (err != 0) { + return err; + } if (throttle == sc->throttle) return 0; - if (throttle < MXGE_MIN_THROTTLE || throttle > MXGE_MAX_THROTTLE) - return EINVAL; + if (throttle < MXGE_MIN_THROTTLE || throttle > MXGE_MAX_THROTTLE) + return EINVAL; mtx_lock(&sc->driver_mtx); cmd.data0 = throttle; @@ -1371,64 +1371,64 @@ mxge_change_throttle(SYSCTL_HANDLER_ARGS) static int mxge_change_intr_coal(SYSCTL_HANDLER_ARGS) { - mxge_softc_t *sc; - unsigned int intr_coal_delay; - int err; + mxge_softc_t *sc; + unsigned int intr_coal_delay; + int err; - sc = arg1; - intr_coal_delay = sc->intr_coal_delay; - err = sysctl_handle_int(oidp, &intr_coal_delay, arg2, req); - if (err != 0) { - return err; - } - if (intr_coal_delay == sc->intr_coal_delay) - return 0; + sc = arg1; + intr_coal_delay = sc->intr_coal_delay; + err = sysctl_handle_int(oidp, &intr_coal_delay, arg2, req); + if (err != 0) { + return err; + } + if (intr_coal_delay == sc->intr_coal_delay) + return 0; - if (intr_coal_delay == 0 || intr_coal_delay > 1000*1000) - return EINVAL; + if (intr_coal_delay == 0 || intr_coal_delay > 1000*1000) + return EINVAL; mtx_lock(&sc->driver_mtx); *sc->intr_coal_delay_ptr = htobe32(intr_coal_delay); sc->intr_coal_delay = intr_coal_delay; mtx_unlock(&sc->driver_mtx); - return err; + return err; } static int mxge_change_flow_control(SYSCTL_HANDLER_ARGS) { - mxge_softc_t *sc; - unsigned int enabled; - int err; + mxge_softc_t *sc; + unsigned int enabled; + int err; - sc = arg1; - enabled = sc->pause; - err = sysctl_handle_int(oidp, &enabled, arg2, req); - if (err != 0) { - return err; - } - if (enabled == sc->pause) - return 0; + sc = arg1; + enabled = sc->pause; + err = sysctl_handle_int(oidp, &enabled, arg2, req); + if (err != 0) { + return err; + } + if (enabled == sc->pause) + return 0; mtx_lock(&sc->driver_mtx); err = mxge_change_pause(sc, enabled); mtx_unlock(&sc->driver_mtx); - return err; + return err; } static int mxge_handle_be32(SYSCTL_HANDLER_ARGS) { - int err; + int err; - if (arg1 == NULL) - return EFAULT; - arg2 = be32toh(*(int *)arg1); - arg1 = NULL; - err = sysctl_handle_int(oidp, arg1, arg2, req); + if (arg1 == NULL) + return EFAULT; + arg2 = be32toh(*(int *)arg1); + arg1 = NULL; + err = sysctl_handle_int(oidp, arg1, arg2, req); - return err; + return err; } static void @@ -1466,156 +1466,156 @@ mxge_add_sysctls(mxge_softc_t *sc) fw = sc->ss[0].fw_stats; /* random information */ - SYSCTL_ADD_STRING(ctx, children, OID_AUTO, + SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "firmware_version", CTLFLAG_RD, &sc->fw_version, 0, "firmware version"); - SYSCTL_ADD_STRING(ctx, children, OID_AUTO, + SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "serial_number", CTLFLAG_RD, &sc->serial_number_string, 0, "serial number"); - SYSCTL_ADD_STRING(ctx, children, OID_AUTO, + SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "product_code", CTLFLAG_RD, &sc->product_code_string, 0, "product_code"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "pcie_link_width", CTLFLAG_RD, &sc->link_width, 0, "tx_boundary"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_boundary", CTLFLAG_RD, &sc->tx_boundary, 0, "tx_boundary"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "write_combine", CTLFLAG_RD, &sc->wc, 0, "write combining PIO?"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "read_dma_MBs", CTLFLAG_RD, &sc->read_dma, 0, "DMA Read speed in MB/s"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "write_dma_MBs", CTLFLAG_RD, &sc->write_dma, 0, "DMA Write speed in MB/s"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "read_write_dma_MBs", CTLFLAG_RD, &sc->read_write_dma, 0, "DMA concurrent Read/Write speed in MB/s"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "watchdog_resets", CTLFLAG_RD, &sc->watchdog_resets, 0, "Number of times NIC was reset"); /* performance related tunables */ - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_delay", CTLTYPE_INT|CTLFLAG_RW, sc, - 0, mxge_change_intr_coal, + 0, mxge_change_intr_coal, "I", "interrupt coalescing delay in usecs"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "throttle", CTLTYPE_INT|CTLFLAG_RW, sc, - 0, mxge_change_throttle, + 0, mxge_change_throttle, "I", "transmit throttling"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "flow_control_enabled", CTLTYPE_INT|CTLFLAG_RW, sc, 0, mxge_change_flow_control, "I", "interrupt coalescing delay in usecs"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "deassert_wait", CTLFLAG_RW, &mxge_deassert_wait, 0, "Wait for IRQ line to go low in ihandler"); - /* stats block from firmware is in network byte order. + /* stats block from firmware is in network byte order. Need to swap it */ - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "link_up", CTLTYPE_INT|CTLFLAG_RD, &fw->link_up, 0, mxge_handle_be32, "I", "link up"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rdma_tags_available", CTLTYPE_INT|CTLFLAG_RD, &fw->rdma_tags_available, 0, mxge_handle_be32, "I", "rdma_tags_available"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_bad_crc32", - CTLTYPE_INT|CTLFLAG_RD, + CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_bad_crc32, 0, mxge_handle_be32, "I", "dropped_bad_crc32"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_bad_phy", - CTLTYPE_INT|CTLFLAG_RD, + CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_bad_phy, 0, mxge_handle_be32, "I", "dropped_bad_phy"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_link_error_or_filtered", - CTLTYPE_INT|CTLFLAG_RD, + CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_link_error_or_filtered, 0, mxge_handle_be32, "I", "dropped_link_error_or_filtered"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_link_overflow", CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_link_overflow, 0, mxge_handle_be32, "I", "dropped_link_overflow"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_multicast_filtered", - CTLTYPE_INT|CTLFLAG_RD, + CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_multicast_filtered, 0, mxge_handle_be32, "I", "dropped_multicast_filtered"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_no_big_buffer", CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_no_big_buffer, 0, mxge_handle_be32, "I", "dropped_no_big_buffer"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_no_small_buffer", - CTLTYPE_INT|CTLFLAG_RD, + CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_no_small_buffer, 0, mxge_handle_be32, "I", "dropped_no_small_buffer"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_overrun", CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_overrun, 0, mxge_handle_be32, "I", "dropped_overrun"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_pause", - CTLTYPE_INT|CTLFLAG_RD, + CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_pause, 0, mxge_handle_be32, "I", "dropped_pause"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_runt", CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_runt, 0, mxge_handle_be32, "I", "dropped_runt"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dropped_unicast_filtered", CTLTYPE_INT|CTLFLAG_RD, &fw->dropped_unicast_filtered, 0, mxge_handle_be32, "I", "dropped_unicast_filtered"); /* verbose printing? */ - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "verbose", CTLFLAG_RW, &mxge_verbose, 0, "verbose printing"); /* add counters exported for debugging from all slices */ sysctl_ctx_init(&sc->slice_sysctl_ctx); - sc->slice_sysctl_tree = + sc->slice_sysctl_tree = SYSCTL_ADD_NODE(&sc->slice_sysctl_ctx, children, OID_AUTO, "slice", CTLFLAG_RD, 0, ""); @@ -1625,15 +1625,15 @@ mxge_add_sysctls(mxge_softc_t *sc) ctx = &ss->sysctl_ctx; children = SYSCTL_CHILDREN(sc->slice_sysctl_tree); sprintf(slice_num, "%d", slice); - ss->sysctl_tree = + ss->sysctl_tree = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, slice_num, CTLFLAG_RD, 0, ""); children = SYSCTL_CHILDREN(ss->sysctl_tree); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "rx_small_cnt", CTLFLAG_RD, &ss->rx_small.cnt, 0, "rx_small_cnt"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "rx_big_cnt", CTLFLAG_RD, &ss->rx_big.cnt, 0, "rx_small_cnt"); @@ -1655,118 +1655,118 @@ mxge_add_sysctls(mxge_softc_t *sc) if (slice > 0) continue; #endif - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_req", CTLFLAG_RD, &ss->tx.req, 0, "tx_req"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_done", CTLFLAG_RD, &ss->tx.done, 0, "tx_done"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_pkt_done", CTLFLAG_RD, &ss->tx.pkt_done, 0, "tx_done"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_stall", CTLFLAG_RD, &ss->tx.stall, 0, "tx_stall"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_wake", CTLFLAG_RD, &ss->tx.wake, 0, "tx_wake"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_defrag", CTLFLAG_RD, &ss->tx.defrag, 0, "tx_defrag"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_queue_active", CTLFLAG_RD, &ss->tx.queue_active, 0, "tx_queue_active"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_activate", CTLFLAG_RD, &ss->tx.activate, 0, "tx_activate"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_deactivate", CTLFLAG_RD, &ss->tx.deactivate, 0, "tx_deactivate"); } } -/* copy an array of mcp_kreq_ether_send_t's to the mcp. Copy +/* copy an array of mcp_kreq_ether_send_t's to the mcp. Copy backwards one at a time and handle ring wraps */ -static inline void -mxge_submit_req_backwards(mxge_tx_ring_t *tx, +static inline void +mxge_submit_req_backwards(mxge_tx_ring_t *tx, mcp_kreq_ether_send_t *src, int cnt) { - int idx, starting_slot; - starting_slot = tx->req; - while (cnt > 1) { - cnt--; - idx = (starting_slot + cnt) & tx->mask; - mxge_pio_copy(&tx->lanai[idx], + int idx, starting_slot; + starting_slot = tx->req; + while (cnt > 1) { + cnt--; + idx = (starting_slot + cnt) & tx->mask; + mxge_pio_copy(&tx->lanai[idx], &src[cnt], sizeof(*src)); - wmb(); - } + wmb(); + } } /* * copy an array of mcp_kreq_ether_send_t's to the mcp. Copy * at most 32 bytes at a time, so as to avoid involving the software * pio handler in the nic. We re-write the first segment's flags - * to mark them valid only after writing the entire chain + * to mark them valid only after writing the entire chain */ -static inline void -mxge_submit_req(mxge_tx_ring_t *tx, mcp_kreq_ether_send_t *src, - int cnt) +static inline void +mxge_submit_req(mxge_tx_ring_t *tx, mcp_kreq_ether_send_t *src, + int cnt) { - int idx, i; - uint32_t *src_ints; + int idx, i; + uint32_t *src_ints; volatile uint32_t *dst_ints; - mcp_kreq_ether_send_t *srcp; + mcp_kreq_ether_send_t *srcp; volatile mcp_kreq_ether_send_t *dstp, *dst; uint8_t last_flags; - - idx = tx->req & tx->mask; + + idx = tx->req & tx->mask; last_flags = src->flags; src->flags = 0; - wmb(); - dst = dstp = &tx->lanai[idx]; - srcp = src; + wmb(); + dst = dstp = &tx->lanai[idx]; + srcp = src; - if ((idx + cnt) < tx->mask) { - for (i = 0; i < (cnt - 1); i += 2) { - mxge_pio_copy(dstp, srcp, 2 * sizeof(*src)); - wmb(); /* force write every 32 bytes */ - srcp += 2; - dstp += 2; - } - } else { - /* submit all but the first request, and ensure - that it is submitted below */ - mxge_submit_req_backwards(tx, src, cnt); - i = 0; - } - if (i < cnt) { - /* submit the first request */ - mxge_pio_copy(dstp, srcp, sizeof(*src)); - wmb(); /* barrier before setting valid flag */ - } + if ((idx + cnt) < tx->mask) { + for (i = 0; i < (cnt - 1); i += 2) { + mxge_pio_copy(dstp, srcp, 2 * sizeof(*src)); + wmb(); /* force write every 32 bytes */ + srcp += 2; + dstp += 2; + } + } else { + /* submit all but the first request, and ensure + that it is submitted below */ + mxge_submit_req_backwards(tx, src, cnt); + i = 0; + } + if (i < cnt) { + /* submit the first request */ + mxge_pio_copy(dstp, srcp, sizeof(*src)); + wmb(); /* barrier before setting valid flag */ + } - /* re-write the last 32-bits with the valid flags */ - src->flags = last_flags; - src_ints = (uint32_t *)src; - src_ints+=3; - dst_ints = (volatile uint32_t *)dst; - dst_ints+=3; - *dst_ints = *src_ints; - tx->req += cnt; - wmb(); + /* re-write the last 32-bits with the valid flags */ + src->flags = last_flags; + src_ints = (uint32_t *)src; + src_ints+=3; + dst_ints = (volatile uint32_t *)dst; + dst_ints+=3; + *dst_ints = *src_ints; + tx->req += cnt; + wmb(); } static int @@ -1969,7 +1969,7 @@ mxge_encap_tso(struct mxge_slice_state *ss, struct mbuf *m, seglen = -cum_len; small = (mss <= MXGEFW_SEND_SMALL_SIZE); flags_next = MXGEFW_FLAGS_TSO_PLD | - MXGEFW_FLAGS_FIRST | + MXGEFW_FLAGS_FIRST | (small * MXGEFW_FLAGS_SMALL); } @@ -2038,7 +2038,7 @@ mxge_encap_tso(struct mxge_slice_state *ss, struct mbuf *m, #endif /* IFCAP_TSO4 */ #ifdef MXGE_NEW_VLAN_API -/* +/* * We reproduce the software vlan tag insertion from * net/if_vlan.c:vlan_start() here so that we can advertise "hardware" * vlan tag insertion. We need to advertise this in order to have the @@ -2083,7 +2083,7 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m) mxge_tx_ring_t *tx; int cnt, cum_len, err, i, idx, odd_flag; uint16_t pseudo_hdr_offset; - uint8_t flags, cksum_offset; + uint8_t flags, cksum_offset; sc = ss->sc; @@ -2106,7 +2106,7 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m) /* (try to) map the frame for DMA */ idx = tx->req & tx->mask; err = bus_dmamap_load_mbuf_sg(tx->dmat, tx->info[idx].map, - m, tx->seg_list, &cnt, + m, tx->seg_list, &cnt, BUS_DMA_NOWAIT); if (__predict_false(err == EFBIG)) { /* Too many segments in the chain. Try @@ -2117,9 +2117,9 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m) } ss->tx.defrag++; m = m_tmp; - err = bus_dmamap_load_mbuf_sg(tx->dmat, + err = bus_dmamap_load_mbuf_sg(tx->dmat, tx->info[idx].map, - m, tx->seg_list, &cnt, + m, tx->seg_list, &cnt, BUS_DMA_NOWAIT); } if (__predict_false(err != 0)) { @@ -2166,9 +2166,9 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m) seg = tx->seg_list; req->flags = MXGEFW_FLAGS_FIRST; for (i = 0; i < cnt; i++) { - req->addr_low = + req->addr_low = htobe32(MXGE_LOWPART_TO_U32(seg->ds_addr)); - req->addr_high = + req->addr_high = htobe32(MXGE_HIGHPART_TO_U32(seg->ds_addr)); req->length = htobe16(seg->ds_len); req->cksum_offset = cksum_offset; @@ -2189,9 +2189,9 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m) /* pad runts to 60 bytes */ if (cum_len < 60) { req++; - req->addr_low = + req->addr_low = htobe32(MXGE_LOWPART_TO_U32(sc->zeropad_dma.bus_addr)); - req->addr_high = + req->addr_high = htobe32(MXGE_HIGHPART_TO_U32(sc->zeropad_dma.bus_addr)); req->length = htobe16(60 - cum_len); req->cksum_offset = 0; @@ -2427,16 +2427,16 @@ mxge_get_buf_small(struct mxge_slice_state *ss, bus_dmamap_t map, int idx) goto done; } m->m_len = MHLEN; - err = bus_dmamap_load_mbuf_sg(rx->dmat, map, m, + err = bus_dmamap_load_mbuf_sg(rx->dmat, map, m, &seg, &cnt, BUS_DMA_NOWAIT); if (err != 0) { m_free(m); goto done; } rx->info[idx].m = m; - rx->shadow[idx].addr_low = + rx->shadow[idx].addr_low = htobe32(MXGE_LOWPART_TO_U32(seg.ds_addr)); - rx->shadow[idx].addr_high = + rx->shadow[idx].addr_high = htobe32(MXGE_HIGHPART_TO_U32(seg.ds_addr)); done: @@ -2460,23 +2460,23 @@ mxge_get_buf_big(struct mxge_slice_state *ss, bus_dmamap_t map, int idx) goto done; } m->m_len = rx->mlen; - err = bus_dmamap_load_mbuf_sg(rx->dmat, map, m, + err = bus_dmamap_load_mbuf_sg(rx->dmat, map, m, seg, &cnt, BUS_DMA_NOWAIT); if (err != 0) { m_free(m); goto done; } rx->info[idx].m = m; - rx->shadow[idx].addr_low = + rx->shadow[idx].addr_low = htobe32(MXGE_LOWPART_TO_U32(seg->ds_addr)); - rx->shadow[idx].addr_high = + rx->shadow[idx].addr_high = htobe32(MXGE_HIGHPART_TO_U32(seg->ds_addr)); #if MXGE_VIRT_JUMBOS for (i = 1; i < cnt; i++) { - rx->shadow[idx + i].addr_low = + rx->shadow[idx + i].addr_low = htobe32(MXGE_LOWPART_TO_U32(seg[i].ds_addr)); - rx->shadow[idx + i].addr_high = + rx->shadow[idx + i].addr_high = htobe32(MXGE_HIGHPART_TO_U32(seg[i].ds_addr)); } #endif @@ -2548,7 +2548,7 @@ mxge_rx_csum6(void *p, struct mbuf *m, uint32_t csum) return (c); } #endif /* INET6 */ -/* +/* * Myri10GE hardware checksums are not valid if the sender * padded the frame with non-zero padding. This is because * the firmware just does a simple 16-bit 1s complement @@ -2616,14 +2616,14 @@ mxge_vlan_tag_remove(struct mbuf *m, uint32_t *csum) */ /* put checksum into host byte order */ - *csum = ntohs(*csum); + *csum = ntohs(*csum); partial = ntohl(*(uint32_t *)(mtod(m, char *) + ETHER_HDR_LEN)); (*csum) += ~partial; (*csum) += ((*csum) < ~partial); (*csum) = ((*csum) >> 16) + ((*csum) & 0xFFFF); (*csum) = ((*csum) >> 16) + ((*csum) & 0xFFFF); - /* restore checksum to network byte order; + /* restore checksum to network byte order; later consumers expect this */ *csum = htons(*csum); @@ -2678,7 +2678,7 @@ mxge_rx_done_big(struct mxge_slice_state *ss, uint32_t len, /* try to replace the received mbuf */ if (mxge_get_buf_big(ss, rx->extra_map, idx)) { /* drop the frame -- the old mbuf is re-cycled */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -2747,7 +2747,7 @@ mxge_rx_done_small(struct mxge_slice_state *ss, uint32_t len, /* try to replace the received mbuf */ if (mxge_get_buf_small(ss, rx->extra_map, idx)) { /* drop the frame -- the old mbuf is re-cycled */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -2863,7 +2863,7 @@ mxge_tx_done(struct mxge_slice_state *ss, uint32_t mcp_idx) } /* If we have space, clear IFF_OACTIVE to tell the stack that - its OK to send packets */ + its OK to send packets */ #ifdef IFNET_BUF_RING flags = &ss->if_drv_flags; #else @@ -2919,7 +2919,7 @@ mxge_media_set(mxge_softc_t *sc, int media_type) { - ifmedia_add(&sc->media, IFM_ETHER | IFM_FDX | media_type, + ifmedia_add(&sc->media, IFM_ETHER | IFM_FDX | media_type, 0, NULL); ifmedia_set(&sc->media, IFM_ETHER | IFM_FDX | media_type); sc->current_media = media_type; @@ -2935,7 +2935,7 @@ mxge_media_init(mxge_softc_t *sc) ifmedia_removeall(&sc->media); mxge_media_set(sc, IFM_AUTO); - /* + /* * parse the product code to deterimine the interface type * (CX4, XFP, Quad Ribbon Fiber) by looking at the character * after the 3rd dash in the driver's cached copy of the @@ -2980,7 +2980,7 @@ mxge_media_init(mxge_softc_t *sc) * themselves only when their link is up, so this is initiated via a * link up interrupt. However, this can potentially take up to * several milliseconds, so it is run via the watchdog routine, rather - * than in the interrupt handler itself. + * than in the interrupt handler itself. */ static void mxge_media_probe(mxge_softc_t *sc) @@ -2997,7 +2997,7 @@ mxge_media_probe(mxge_softc_t *sc) if (sc->connector == MXGE_XFP) { /* -R is XFP */ mxge_media_types = mxge_xfp_media_types; - mxge_media_type_entries = + mxge_media_type_entries = sizeof (mxge_xfp_media_types) / sizeof (mxge_xfp_media_types[0]); byte = MXGE_XFP_COMPLIANCE_BYTE; @@ -3005,7 +3005,7 @@ mxge_media_probe(mxge_softc_t *sc) } else if (sc->connector == MXGE_SFP) { /* -S or -2S is SFP+ */ mxge_media_types = mxge_sfp_media_types; - mxge_media_type_entries = + mxge_media_type_entries = sizeof (mxge_sfp_media_types) / sizeof (mxge_sfp_media_types[0]); cage_type = "SFP+"; @@ -3151,7 +3151,7 @@ mxge_intr(void *arg) } if (sc->rdma_tags_available != be32toh(stats->rdma_tags_available)) { - sc->rdma_tags_available = + sc->rdma_tags_available = be32toh(stats->rdma_tags_available); device_printf(sc->dev, "RDMA timed out! %d tags " "left\n", sc->rdma_tags_available); @@ -3384,7 +3384,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, return err; } for (i = 0; i <= ss->rx_small.mask; i++) { - err = bus_dmamap_create(ss->rx_small.dmat, 0, + err = bus_dmamap_create(ss->rx_small.dmat, 0, &ss->rx_small.info[i].map); if (err != 0) { device_printf(sc->dev, "Err %d rx_small dmamap\n", @@ -3392,7 +3392,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, return err; } } - err = bus_dmamap_create(ss->rx_small.dmat, 0, + err = bus_dmamap_create(ss->rx_small.dmat, 0, &ss->rx_small.extra_map); if (err != 0) { device_printf(sc->dev, "Err %d extra rx_small dmamap\n", @@ -3401,7 +3401,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, } for (i = 0; i <= ss->rx_big.mask; i++) { - err = bus_dmamap_create(ss->rx_big.dmat, 0, + err = bus_dmamap_create(ss->rx_big.dmat, 0, &ss->rx_big.info[i].map); if (err != 0) { device_printf(sc->dev, "Err %d rx_big dmamap\n", @@ -3409,7 +3409,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, return err; } } - err = bus_dmamap_create(ss->rx_big.dmat, 0, + err = bus_dmamap_create(ss->rx_big.dmat, 0, &ss->rx_big.extra_map); if (err != 0) { device_printf(sc->dev, "Err %d extra rx_big dmamap\n", @@ -3430,7 +3430,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, /* allocate the tx request copy block */ - bytes = 8 + + bytes = 8 + sizeof (*ss->tx.req_list) * (ss->tx.max_desc + 4); ss->tx.req_bytes = malloc(bytes, M_DEVBUF, M_WAITOK); /* ensure req_list entries are aligned to 8 bytes */ @@ -3439,7 +3439,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, /* allocate the tx busdma segment list */ bytes = sizeof (*ss->tx.seg_list) * ss->tx.max_desc; - ss->tx.seg_list = (bus_dma_segment_t *) + ss->tx.seg_list = (bus_dma_segment_t *) malloc(bytes, M_DEVBUF, M_WAITOK); /* allocate the tx host info ring */ @@ -3469,7 +3469,7 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries, /* now use these tags to setup dmamaps for each slot in the ring */ for (i = 0; i <= ss->tx.mask; i++) { - err = bus_dmamap_create(ss->tx.dmat, 0, + err = bus_dmamap_create(ss->tx.dmat, 0, &ss->tx.info[i].map); if (err != 0) { device_printf(sc->dev, "Err %d tx dmamap\n", @@ -3580,7 +3580,7 @@ mxge_slice_open(struct mxge_slice_state *ss, int nbufs, int cl_size) #endif cmd.data0 = slice; err = mxge_send_cmd(sc, MXGEFW_CMD_GET_SEND_OFFSET, &cmd); - ss->tx.lanai = + ss->tx.lanai = (volatile mcp_kreq_ether_send_t *)(sc->sram + cmd.data0); ss->tx.send_go = (volatile uint32_t *) (sc->sram + MXGEFW_ETH_SEND_GO + 64 * slice); @@ -3590,17 +3590,17 @@ mxge_slice_open(struct mxge_slice_state *ss, int nbufs, int cl_size) } #endif cmd.data0 = slice; - err |= mxge_send_cmd(sc, + err |= mxge_send_cmd(sc, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd); - ss->rx_small.lanai = + ss->rx_small.lanai = (volatile mcp_kreq_ether_recv_t *)(sc->sram + cmd.data0); cmd.data0 = slice; err |= mxge_send_cmd(sc, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd); - ss->rx_big.lanai = + ss->rx_big.lanai = (volatile mcp_kreq_ether_recv_t *)(sc->sram + cmd.data0); if (err != 0) { - device_printf(sc->dev, + device_printf(sc->dev, "failed to get ring sizes or locations\n"); return EIO; } @@ -3635,7 +3635,7 @@ mxge_slice_open(struct mxge_slice_state *ss, int nbufs, int cl_size) return 0; } -static int +static int mxge_open(mxge_softc_t *sc) { mxge_cmd_t cmd; @@ -3687,7 +3687,7 @@ mxge_open(mxge_softc_t *sc) cmd.data0 = nbufs; err = mxge_send_cmd(sc, MXGEFW_CMD_ALWAYS_USE_N_BIG_BUFFERS, &cmd); - /* error is only meaningful if we're trying to set + /* error is only meaningful if we're trying to set MXGEFW_CMD_ALWAYS_USE_N_BIG_BUFFERS > 1 */ if (err && nbufs > 1) { device_printf(sc->dev, @@ -3712,7 +3712,7 @@ mxge_open(mxge_softc_t *sc) } /* Now give him the pointer to the stats block */ - for (slice = 0; + for (slice = 0; #ifdef IFNET_BUF_RING slice < sc->num_slices; #else @@ -3880,7 +3880,7 @@ mxge_watchdog_reset(mxge_softc_t *sc) device_printf(sc->dev, "Watchdog reset!\n"); - /* + /* * check to see if the NIC rebooted. If it did, then all of * PCI config space has been reset, and things like the * busmaster bit will be zero. If this is the case, then we @@ -3889,10 +3889,10 @@ mxge_watchdog_reset(mxge_softc_t *sc) */ cmd = pci_read_config(sc->dev, PCIR_COMMAND, 2); if (cmd == 0xffff) { - /* + /* * maybe the watchdog caught the NIC rebooting; wait * up to 100ms for it to finish. If it does not come - * back, then give up + * back, then give up */ DELAY(1000*100); cmd = pci_read_config(sc->dev, PCIR_COMMAND, 2); @@ -3908,7 +3908,7 @@ mxge_watchdog_reset(mxge_softc_t *sc) running = sc->ifp->if_drv_flags & IFF_DRV_RUNNING; if (running) { - /* + /* * quiesce NIC so that TX routines will not try to * xmit after restoration of BAR */ @@ -4004,7 +4004,7 @@ mxge_watchdog(mxge_softc_t *sc) /* see if we have outstanding transmits, which have been pending for more than mxge_ticks */ - for (i = 0; + for (i = 0; #ifdef IFNET_BUF_RING (i < sc->num_slices) && (err == 0); #else @@ -4036,43 +4036,45 @@ mxge_watchdog(mxge_softc_t *sc) return (err); } -static u_long -mxge_update_stats(mxge_softc_t *sc) +static uint64_t +mxge_get_counter(struct ifnet *ifp, ift_counter cnt) { - struct mxge_slice_state *ss; - u_long pkts = 0; - u_long ipackets = 0; - u_long opackets = 0; -#ifdef IFNET_BUF_RING - u_long obytes = 0; - u_long omcasts = 0; - u_long odrops = 0; -#endif - u_long oerrors = 0; - int slice; + struct mxge_softc *sc; + uint64_t rv; - for (slice = 0; slice < sc->num_slices; slice++) { - ss = &sc->ss[slice]; - ipackets += ss->ipackets; - opackets += ss->opackets; + sc = if_getsoftc(ifp); + rv = 0; + + switch (cnt) { + case IFCOUNTER_IPACKETS: + for (int s = 0; s < sc->num_slices; s++) + rv += sc->ss[s].ipackets; + return (rv); + case IFCOUNTER_OPACKETS: + for (int s = 0; s < sc->num_slices; s++) + rv += sc->ss[s].opackets; + return (rv); + case IFCOUNTER_OERRORS: + for (int s = 0; s < sc->num_slices; s++) + rv += sc->ss[s].oerrors; + return (rv); #ifdef IFNET_BUF_RING - obytes += ss->obytes; - omcasts += ss->omcasts; - odrops += ss->tx.br->br_drops; + case IFCOUNTER_OBYTES: + for (int s = 0; s < sc->num_slices; s++) + rv += sc->ss[s].obytes; + return (rv); + case IFCOUNTER_OMCASTS: + for (int s = 0; s < sc->num_slices; s++) + rv += sc->ss[s].omcasts; + return (rv); + case IFCOUNTER_OQDROPS: + for (int s = 0; s < sc->num_slices; s++) + rv += sc->ss[s].tx.br->br_drops; + return (rv); #endif - oerrors += ss->oerrors; + default: + return (if_get_counter_default(ifp, cnt)); } - pkts = (ipackets - sc->ifp->if_ipackets); - pkts += (opackets - sc->ifp->if_opackets); - sc->ifp->if_ipackets = ipackets; - sc->ifp->if_opackets = opackets; -#ifdef IFNET_BUF_RING - sc->ifp->if_obytes = obytes; - sc->ifp->if_omcasts = omcasts; - sc->ifp->if_snd.ifq_drops = odrops; -#endif - sc->ifp->if_oerrors = oerrors; - return pkts; } static void @@ -4087,8 +4089,6 @@ mxge_tick(void *arg) ticks = mxge_ticks; running = sc->ifp->if_drv_flags & IFF_DRV_RUNNING; if (running) { - /* aggregate stats from different slices */ - pkts = mxge_update_stats(sc); if (!sc->watchdog_countdown) { err = mxge_watchdog(sc); sc->watchdog_countdown = 4; @@ -4189,7 +4189,7 @@ mxge_ioctl(struct ifnet *ifp, u_long command, caddr_t data) } else { /* take care of promis can allmulti flag chages */ - mxge_change_promisc(sc, + mxge_change_promisc(sc, ifp->if_flags & IFF_PROMISC); mxge_set_multicast_list(sc); } @@ -4291,13 +4291,13 @@ mxge_ioctl(struct ifnet *ifp, u_long command, caddr_t data) mtx_lock(&sc->driver_mtx); mxge_media_probe(sc); mtx_unlock(&sc->driver_mtx); - err = ifmedia_ioctl(ifp, (struct ifreq *)data, + err = ifmedia_ioctl(ifp, (struct ifreq *)data, &sc->media, command); - break; + break; default: err = ENOTTY; - } + } return err; } @@ -4306,17 +4306,17 @@ mxge_fetch_tunables(mxge_softc_t *sc) { TUNABLE_INT_FETCH("hw.mxge.max_slices", &mxge_max_slices); - TUNABLE_INT_FETCH("hw.mxge.flow_control_enabled", + TUNABLE_INT_FETCH("hw.mxge.flow_control_enabled", &mxge_flow_control); - TUNABLE_INT_FETCH("hw.mxge.intr_coal_delay", + TUNABLE_INT_FETCH("hw.mxge.intr_coal_delay", &mxge_intr_coal_delay); - TUNABLE_INT_FETCH("hw.mxge.nvidia_ecrc_enable", + TUNABLE_INT_FETCH("hw.mxge.nvidia_ecrc_enable", &mxge_nvidia_ecrc_enable); - TUNABLE_INT_FETCH("hw.mxge.force_firmware", + TUNABLE_INT_FETCH("hw.mxge.force_firmware", &mxge_force_firmware); - TUNABLE_INT_FETCH("hw.mxge.deassert_wait", + TUNABLE_INT_FETCH("hw.mxge.deassert_wait", &mxge_deassert_wait); - TUNABLE_INT_FETCH("hw.mxge.verbose", + TUNABLE_INT_FETCH("hw.mxge.verbose", &mxge_verbose); TUNABLE_INT_FETCH("hw.mxge.ticks", &mxge_ticks); TUNABLE_INT_FETCH("hw.mxge.always_promisc", &mxge_always_promisc); @@ -4332,7 +4332,7 @@ mxge_fetch_tunables(mxge_softc_t *sc) if (mxge_ticks == 0) mxge_ticks = hz / 2; sc->pause = mxge_flow_control; - if (mxge_rss_hash_type < MXGEFW_RSS_HASH_TYPE_IPV4 + if (mxge_rss_hash_type < MXGEFW_RSS_HASH_TYPE_IPV4 || mxge_rss_hash_type > MXGEFW_RSS_HASH_TYPE_MAX) { mxge_rss_hash_type = MXGEFW_RSS_HASH_TYPE_SRC_DST_PORT; } @@ -4414,7 +4414,7 @@ mxge_alloc_slices(mxge_softc_t *sc) ss->rx_done.entry = ss->rx_done.dma.addr; bzero(ss->rx_done.entry, bytes); - /* + /* * allocate the per-slice firmware stats; stats * (including tx) are used used only on the first * slice for now @@ -4425,7 +4425,7 @@ mxge_alloc_slices(mxge_softc_t *sc) #endif bytes = sizeof (*ss->fw_stats); - err = mxge_dma_alloc(sc, &ss->fw_stats_dma, + err = mxge_dma_alloc(sc, &ss->fw_stats_dma, sizeof (*ss->fw_stats), 64); if (err != 0) goto abort; @@ -4454,9 +4454,9 @@ mxge_slice_probe(mxge_softc_t *sc) int msix_cnt, status, max_intr_slots; sc->num_slices = 1; - /* + /* * don't enable multiple slices if they are not enabled, - * or if this is not an SMP system + * or if this is not an SMP system */ if (mxge_max_slices == 0 || mxge_max_slices == 1 || mp_ncpus < 2) @@ -4593,7 +4593,7 @@ mxge_add_msix_irqs(mxge_softc_t *sc) sc->msix_ih = malloc(bytes, M_DEVBUF, M_NOWAIT|M_ZERO); for (i = 0; i < sc->num_slices; i++) { - err = bus_setup_intr(sc->dev, sc->msix_irq_res[i], + err = bus_setup_intr(sc->dev, sc->msix_irq_res[i], INTR_TYPE_NET | INTR_MPSAFE, #if __FreeBSD_version > 700030 NULL, @@ -4671,7 +4671,7 @@ mxge_add_single_irq(mxge_softc_t *sc) device_printf(sc->dev, "using %s irq %ld\n", sc->legacy_irq ? "INTx" : "MSI", rman_get_start(sc->irq_res)); - err = bus_setup_intr(sc->dev, sc->irq_res, + err = bus_setup_intr(sc->dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, #if __FreeBSD_version > 700030 NULL, @@ -4753,7 +4753,7 @@ mxge_add_irq(mxge_softc_t *sc) } -static int +static int mxge_attach(device_t dev) { mxge_cmd_t cmd; @@ -4835,7 +4835,7 @@ mxge_attach(device_t dev) bus_space_read_region_1(rman_get_bustag(sc->mem_res), rman_get_bushandle(sc->mem_res), sc->sram_size - MXGE_EEPROM_STRINGS_SIZE, - sc->eeprom_strings, + sc->eeprom_strings, MXGE_EEPROM_STRINGS_SIZE - 2); err = mxge_parse_strings(sc); if (err != 0) @@ -4845,13 +4845,13 @@ mxge_attach(device_t dev) mxge_enable_wc(sc); /* Allocate the out of band dma memory */ - err = mxge_dma_alloc(sc, &sc->cmd_dma, + err = mxge_dma_alloc(sc, &sc->cmd_dma, sizeof (mxge_cmd_t), 64); - if (err != 0) + if (err != 0) goto abort_with_mem_res; sc->cmd = (mcp_cmd_response_t *) sc->cmd_dma.addr; err = mxge_dma_alloc(sc, &sc->zeropad_dma, 64, 64); - if (err != 0) + if (err != 0) goto abort_with_cmd_dma; err = mxge_dma_alloc(sc, &sc->dmabench_dma, 4096, 4096); @@ -4920,13 +4920,14 @@ mxge_attach(device_t dev) ifp->if_capenable = ifp->if_capabilities; if (sc->lro_cnt == 0) ifp->if_capenable &= ~IFCAP_LRO; - ifp->if_init = mxge_init; - ifp->if_softc = sc; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = mxge_ioctl; - ifp->if_start = mxge_start; + ifp->if_init = mxge_init; + ifp->if_softc = sc; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_ioctl = mxge_ioctl; + ifp->if_start = mxge_start; + ifp->if_get_counter = mxge_get_counter; /* Initialise the ifmedia structure */ - ifmedia_init(&sc->media, 0, mxge_media_change, + ifmedia_init(&sc->media, 0, mxge_media_change, mxge_media_status); mxge_media_init(sc); mxge_media_probe(sc); diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c index f8df05998d24..e94e9aba300c 100644 --- a/sys/dev/my/if_my.c +++ b/sys/dev/my/if_my.c @@ -1121,7 +1121,7 @@ my_rxeof(struct my_softc * sc) sc->my_cdata.my_rx_head = cur_rx->my_nextdesc; if (rxstat & MY_ES) { /* error summary: give up this rx pkt */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->my_ptr->my_status = MY_OWNByNIC; continue; } @@ -1134,7 +1134,7 @@ my_rxeof(struct my_softc * sc) total_len, 0, ifp, NULL); cur_rx->my_ptr->my_status = MY_OWNByNIC; if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } } else { @@ -1147,14 +1147,14 @@ my_rxeof(struct my_softc * sc) * little else we can do in this situation. */ if (my_newbuf(sc, cur_rx) == ENOBUFS) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->my_ptr->my_status = MY_OWNByNIC; continue; } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = total_len; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); eh = mtod(m, struct ether_header *); #if NBPFILTER > 0 /* @@ -1212,16 +1212,16 @@ my_txeof(struct my_softc * sc) break; if (!(CSR_READ_4(sc, MY_TCRRCR) & MY_Enhanced)) { if (txstat & MY_TXERR) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (txstat & MY_EC) /* excessive collision */ - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (txstat & MY_LC) /* late collision */ - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } - ifp->if_collisions += (txstat & MY_NCRMASK) >> - MY_NCRShift; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + (txstat & MY_NCRMASK) >> MY_NCRShift); } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(cur_tx->my_mbuf); cur_tx->my_mbuf = NULL; if (sc->my_cdata.my_tx_head == sc->my_cdata.my_tx_tail) { @@ -1232,7 +1232,7 @@ my_txeof(struct my_softc * sc) sc->my_cdata.my_tx_head = cur_tx->my_nextdesc; } if (CSR_READ_4(sc, MY_TCRRCR) & MY_Enhanced) { - ifp->if_collisions += (CSR_READ_4(sc, MY_TSR) & MY_NCRMask); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (CSR_READ_4(sc, MY_TSR) & MY_NCRMask)); } return; } @@ -1293,7 +1293,7 @@ my_intr(void *arg) if ((status & MY_RBU) || (status & MY_RxErr)) { /* rx buffer unavailable or rx error */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); #ifdef foo my_stop(sc); my_reset(sc); @@ -1701,7 +1701,7 @@ my_watchdog(void *arg) return; ifp = sc->my_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); if (!(my_phy_readreg(sc, PHY_BMSR) & PHY_BMSR_LINKSTAT)) if_printf(ifp, "no carrier - transceiver cable problem?\n"); diff --git a/sys/pci/locate.pl b/sys/dev/ncr/locate.pl similarity index 100% rename from sys/pci/locate.pl rename to sys/dev/ncr/locate.pl diff --git a/sys/pci/ncr.c b/sys/dev/ncr/ncr.c similarity index 97% rename from sys/pci/ncr.c rename to sys/dev/ncr/ncr.c index d13769cc6313..6c941e1fcd7d 100644 --- a/sys/pci/ncr.c +++ b/sys/dev/ncr/ncr.c @@ -43,11 +43,6 @@ __FBSDID("$FreeBSD$"); -#define NCR_DATE "pl30 98/1/1" - -#define NCR_VERSION (2) -#define MAX_UNITS (16) - #define NCR_GETCC_WITHMSG #if defined (__FreeBSD__) && defined(_KERNEL) @@ -197,7 +192,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include @@ -274,25 +269,22 @@ __FBSDID("$FreeBSD$"); **========================================================== */ -#define INB(r) bus_space_read_1(np->bst, np->bsh, offsetof(struct ncr_reg, r)) -#define INW(r) bus_space_read_2(np->bst, np->bsh, offsetof(struct ncr_reg, r)) -#define INL(r) bus_space_read_4(np->bst, np->bsh, offsetof(struct ncr_reg, r)) +#define INB(r) bus_read_1(np->reg_res, offsetof(struct ncr_reg, r)) +#define INW(r) bus_read_2(np->reg_res, offsetof(struct ncr_reg, r)) +#define INL(r) bus_read_4(np->reg_res, offsetof(struct ncr_reg, r)) -#define OUTB(r, val) bus_space_write_1(np->bst, np->bsh, \ - offsetof(struct ncr_reg, r), val) -#define OUTW(r, val) bus_space_write_2(np->bst, np->bsh, \ - offsetof(struct ncr_reg, r), val) -#define OUTL(r, val) bus_space_write_4(np->bst, np->bsh, \ - offsetof(struct ncr_reg, r), val) -#define OUTL_OFF(o, val) bus_space_write_4(np->bst, np->bsh, o, val) +#define OUTB(r, val) bus_write_1(np->reg_res, offsetof(struct ncr_reg, r), val) +#define OUTW(r, val) bus_write_2(np->reg_res, offsetof(struct ncr_reg, r), val) +#define OUTL(r, val) bus_write_4(np->reg_res, offsetof(struct ncr_reg, r), val) +#define OUTL_OFF(o, val) bus_write_4(np->reg_res, o, val) -#define INB_OFF(o) bus_space_read_1(np->bst, np->bsh, o) -#define INW_OFF(o) bus_space_read_2(np->bst, np->bsh, o) -#define INL_OFF(o) bus_space_read_4(np->bst, np->bsh, o) +#define INB_OFF(o) bus_read_1(np->reg_res, o) +#define INW_OFF(o) bus_read_2(np->reg_res, o) +#define INL_OFF(o) bus_read_4(np->reg_res, o) #define READSCRIPT_OFF(base, off) \ (base ? *((volatile u_int32_t *)((volatile char *)base + (off))) : \ - bus_space_read_4(np->bst2, np->bsh2, off)) + bus_read_4(np->sram_res, off)) #define WRITESCRIPT_OFF(base, off, val) \ do { \ @@ -300,7 +292,7 @@ __FBSDID("$FreeBSD$"); *((volatile u_int32_t *) \ ((volatile char *)base + (off))) = (val); \ else \ - bus_space_write_4(np->bst2, np->bsh2, off, val); \ + bus_write_4(np->sram_res, off, val); \ } while (0) #define READSCRIPT(r) \ @@ -974,7 +966,7 @@ struct ncb { */ struct head header; - int unit; + device_t dev; /*----------------------------------------------- ** Scripts .. @@ -999,13 +991,9 @@ struct ncb { */ int reg_rid; struct resource *reg_res; - bus_space_tag_t bst; - bus_space_handle_t bsh; int sram_rid; struct resource *sram_res; - bus_space_tag_t bst2; - bus_space_handle_t bsh2; struct resource *irq_res; void *irq_handle; @@ -1086,7 +1074,7 @@ struct ncb { u_short ticks; u_short latetime; time_t lasttime; - struct callout_handle timeout_ch; + struct callout timer; /*----------------------------------------------- ** Debug and profiling @@ -1129,6 +1117,7 @@ struct ncb { */ u_char maxwide; + struct mtx lock; #ifdef NCR_IOMAPPED /* ** address of the ncr control registers in io space @@ -1261,6 +1250,7 @@ static u_int32_t ncr_info(int unit); #endif static void ncr_init(ncb_p np, char * msg, u_long code); static void ncr_intr(void *vnp); +static void ncr_intr_locked(ncb_p np); static void ncr_int_ma(ncb_p np, u_char dstat); static void ncr_int_sir(ncb_p np); static void ncr_int_sto(ncb_p np); @@ -1299,12 +1289,6 @@ static int ncr_attach(device_t dev); **========================================================== */ -static const u_long ncr_version = NCR_VERSION * 11 - + (u_long) sizeof (struct ncb) * 7 - + (u_long) sizeof (struct nccb) * 5 - + (u_long) sizeof (struct lcb) * 3 - + (u_long) sizeof (struct tcb) * 2; - #ifdef _KERNEL static int ncr_debug = SCSI_NCR_DEBUG; @@ -1335,13 +1319,6 @@ static int ncr_cache; /* to be aligned _NOT_ static */ #define NCR_1510D_ID (0x000a1000ul) -static char *ncr_name (ncb_p np) -{ - static char name[10]; - snprintf(name, sizeof(name), "ncr%d", np->unit); - return (name); -} - /*========================================================== ** ** @@ -3017,8 +2994,8 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le */ if (opcode == 0) { - printf ("%s: ERROR0 IN SCRIPT at %d.\n", - ncr_name(np), (int) (src-start-1)); + device_printf(np->dev, "ERROR0 IN SCRIPT at %d.\n", + (int)(src - start - 1)); DELAY (1000000); }; @@ -3043,8 +3020,9 @@ static void ncr_script_copy_and_bind (ncb_p np, ncrcmd *src, ncrcmd *dst, int le if ((tmp2 & RELOC_MASK) == RELOC_KVAR) tmp2 = 0; if ((tmp1 ^ tmp2) & 3) { - printf ("%s: ERROR1 IN SCRIPT at %d.\n", - ncr_name(np), (int) (src-start-1)); + device_printf(np->dev, + "ERROR1 IN SCRIPT at %d.\n", + (int)(src - start - 1)); DELAY (1000000); } /* @@ -3368,14 +3346,16 @@ ncr_attach (device_t dev) ** allocate and initialize structures. */ - np->unit = device_get_unit(dev); + np->dev = dev; + mtx_init(&np->lock, "ncr", NULL, MTX_DEF); + callout_init_mtx(&np->timer, &np->lock, 0); /* ** Try to map the controller chip to ** virtual and physical memory. */ - np->reg_rid = 0x14; + np->reg_rid = PCIR_BAR(1); np->reg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &np->reg_rid, RF_ACTIVE); if (!np->reg_res) { @@ -3384,15 +3364,10 @@ ncr_attach (device_t dev) } /* - ** Make the controller's registers available. ** Now the INB INW INL OUTB OUTW OUTL macros ** can be used safely. */ - np->bst = rman_get_bustag(np->reg_res); - np->bsh = rman_get_bushandle(np->reg_res); - - #ifdef NCR_IOMAPPED /* ** Try to map the controller chip into iospace. @@ -3463,8 +3438,7 @@ ncr_attach (device_t dev) #ifdef NCR_TEKRAM_EEPROM if (bootverbose) { - printf ("%s: Tekram EEPROM read %s\n", - ncr_name(np), + device_printf(dev, "Tekram EEPROM read %s\n", read_tekram_eeprom (np, NULL) ? "succeeded" : "failed"); } @@ -3572,7 +3546,7 @@ ncr_attach (device_t dev) ** Get on-chip SRAM address, if supported */ if ((np->features & FE_RAM) && sizeof(struct script) <= 4096) { - np->sram_rid = 0x18; + np->sram_rid = PCIR_BAR(2); np->sram_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &np->sram_rid, RF_ACTIVE); @@ -3584,8 +3558,6 @@ ncr_attach (device_t dev) if (np->sram_res != NULL) { np->script = NULL; np->p_script = rman_get_start(np->sram_res); - np->bst2 = rman_get_bustag(np->sram_res); - np->bsh2 = rman_get_bushandle(np->sram_res); } else if (sizeof (struct script) > PAGE_SIZE) { np->script = (struct script*) contigmalloc (round_page(sizeof (struct script)), M_DEVBUF, M_WAITOK, @@ -3617,15 +3589,16 @@ ncr_attach (device_t dev) if (!cachelnsz) { cachelnsz = 8; - printf("%s: setting PCI cache line size register to %d.\n", - ncr_name(np), (int)cachelnsz); + device_printf(dev, + "setting PCI cache line size register to %d.\n", + (int)cachelnsz); pci_write_config(dev, PCIR_CACHELNSZ, cachelnsz, 1); } if (!(command & PCIM_CMD_MWRICEN)) { command |= PCIM_CMD_MWRICEN; - printf("%s: setting PCI command write and invalidate.\n", - ncr_name(np)); + device_printf(dev, + "setting PCI command write and invalidate.\n"); pci_write_config(dev, PCIR_COMMAND, command, 2); } } @@ -3662,8 +3635,9 @@ ncr_attach (device_t dev) ** Bells and whistles ;-) */ if (bootverbose) - printf("%s: minsync=%d, maxsync=%d, maxoffs=%d, %d dwords burst, %s dma fifo\n", - ncr_name(np), np->minsync, np->maxsync, np->maxoffs, + device_printf(dev, + "minsync=%d, maxsync=%d, maxoffs=%d, %d dwords burst, %s dma fifo\n", + np->minsync, np->maxsync, np->maxoffs, burst_length(np->maxburst), (np->rv_ctest5 & DFS) ? "large" : "normal"); @@ -3671,8 +3645,7 @@ ncr_attach (device_t dev) ** Print some complementary information that can be helpfull. */ if (bootverbose) - printf("%s: %s, %s IRQ driver%s\n", - ncr_name(np), + device_printf(dev, "%s, %s IRQ driver%s\n", np->rv_stest2 & 0x20 ? "differential" : "single-ended", np->rv_dcntl & IRQM ? "totem pole" : "open drain", np->sram_res ? ", using on-chip SRAM" : ""); @@ -3759,8 +3732,8 @@ ncr_attach (device_t dev) device_printf(dev, "interruptless mode: reduced performance.\n"); } else { - bus_setup_intr(dev, np->irq_res, INTR_TYPE_CAM | INTR_ENTROPY, - NULL, ncr_intr, np, &np->irq_handle); + bus_setup_intr(dev, np->irq_res, INTR_TYPE_CAM | INTR_ENTROPY | + INTR_MPSAFE, NULL, ncr_intr, np, &np->irq_handle); } /* @@ -3776,16 +3749,17 @@ ncr_attach (device_t dev) ** Now tell the generic SCSI layer ** about our bus. */ - np->sim = cam_sim_alloc(ncr_action, ncr_poll, "ncr", np, np->unit, - &Giant, 1, MAX_TAGS, devq); + np->sim = cam_sim_alloc(ncr_action, ncr_poll, "ncr", np, + device_get_unit(dev), &np->lock, 1, MAX_TAGS, devq); if (np->sim == NULL) { cam_simq_free(devq); return ENOMEM; } - + mtx_lock(&np->lock); if (xpt_bus_register(np->sim, dev, 0) != CAM_SUCCESS) { cam_sim_free(np->sim, /*free_devq*/ TRUE); + mtx_unlock(&np->lock); return ENOMEM; } @@ -3794,6 +3768,7 @@ ncr_attach (device_t dev) CAM_LUN_WILDCARD) != CAM_REQ_CMP) { xpt_bus_deregister(cam_sim_path(np->sim)); cam_sim_free(np->sim, /*free_devq*/TRUE); + mtx_unlock(&np->lock); return ENOMEM; } @@ -3802,6 +3777,7 @@ ncr_attach (device_t dev) */ ncr_timeout (np); np->lasttime=0; + mtx_unlock(&np->lock); return 0; } @@ -3820,7 +3796,15 @@ ncr_intr(vnp) void *vnp; { ncb_p np = vnp; - int oldspl = splcam(); + + mtx_lock(&np->lock); + ncr_intr_locked(np); + mtx_unlock(&np->lock); +} + +static void +ncr_intr_locked(ncb_p np) +{ if (DEBUG_FLAGS & DEBUG_TINY) printf ("["); @@ -3836,8 +3820,6 @@ ncr_intr(vnp) }; if (DEBUG_FLAGS & DEBUG_TINY) printf ("]\n"); - - splx (oldspl); } /*========================================================== @@ -3856,6 +3838,7 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) ncb_p np; np = (ncb_p) cam_sim_softc(sim); + mtx_assert(&np->lock, MA_OWNED); switch (ccb->ccb_h.func_code) { /* Common cases first */ @@ -3864,7 +3847,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) nccb_p cp; lcb_p lp; tcb_p tp; - int oldspl; struct ccb_scsiio *csio; u_int8_t *msgptr; u_int msglen; @@ -3877,15 +3859,12 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) tp = &np->target[ccb->ccb_h.target_id]; csio = &ccb->csio; - oldspl = splcam(); - /* * Last time we need to check if this CCB needs to * be aborted. */ if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { xpt_done(ccb); - splx(oldspl); return; } ccb->ccb_h.status |= CAM_SIM_QUEUED; @@ -4040,7 +4019,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) if (segments < 0) { ccb->ccb_h.status = CAM_REQ_TOO_BIG; ncr_free_nccb(np, cp); - splx(oldspl); xpt_done(ccb); return; } @@ -4153,8 +4131,8 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) np->squeueput = qidx; if(DEBUG_FLAGS & DEBUG_QUEUE) - printf("%s: queuepos=%d tryoffset=%d.\n", - ncr_name (np), np->squeueput, + device_printf(np->dev, "queuepos=%d tryoffset=%d.\n", + np->squeueput, (unsigned)(READSCRIPT(startpos[0]) - (NCB_SCRIPTH_PHYS (np, tryloop)))); @@ -4163,11 +4141,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) ** Wake it up. */ OUTB (nc_istat, SIGP); - - /* - ** and reenable interrupts - */ - splx (oldspl); break; } case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */ @@ -4185,7 +4158,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) struct ccb_trans_settings *cts = &ccb->cts; tcb_p tp; u_int update_type; - int s; struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; struct ccb_trans_settings_spi *spi = @@ -4197,7 +4169,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) if (cts->type == CTS_TYPE_USER_SETTINGS) update_type |= NCR_TRANS_USER; - s = splcam(); tp = &np->target[ccb->ccb_h.target_id]; /* Tag and disc enables */ if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { @@ -4271,7 +4242,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) tp->tinfo.goal.width = spi->bus_width; } - splx(s); ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; @@ -4282,7 +4252,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) struct ccb_trans_settings *cts = &ccb->cts; struct ncr_transinfo *tinfo; tcb_p tp = &np->target[ccb->ccb_h.target_id]; - int s; struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; struct ccb_trans_settings_spi *spi = @@ -4293,7 +4262,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) cts->transport = XPORT_SPI; cts->transport_version = 2; - s = splcam(); if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { tinfo = &tp->tinfo.current; if (tp->tinfo.disc_tag & NCR_CUR_DISCENB) @@ -4322,7 +4290,6 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) spi->sync_offset = tinfo->offset; spi->bus_width = tinfo->width; - splx(s); spi->valid = CTS_SPI_VALID_SYNC_RATE | CTS_SPI_VALID_SYNC_OFFSET | CTS_SPI_VALID_BUS_WIDTH @@ -4718,7 +4685,8 @@ ncr_init(ncb_p np, char * msg, u_long code) ** Message. */ - if (msg) printf ("%s: restart (%s).\n", ncr_name (np), msg); + if (msg) + device_printf(np->dev, "restart (%s).\n", msg); /* ** Clear Start Queue @@ -4813,7 +4781,7 @@ ncr_init(ncb_p np, char * msg, u_long code) static void ncr_poll(struct cam_sim *sim) { - ncr_intr(cam_sim_softc(sim)); + ncr_intr_locked(cam_sim_softc(sim)); } @@ -5089,11 +5057,8 @@ ncr_timeout (void *arg) long signed t; nccb_p cp; + mtx_assert(&np->lock, MA_OWNED); if (np->lasttime != thistime) { - /* - ** block ncr interrupts - */ - int oldspl = splcam(); np->lasttime = thistime; /*---------------------------------------------------- @@ -5143,8 +5108,8 @@ ncr_timeout (void *arg) cp->jump_nccb.l_cmd = (SCR_JUMP); if (cp->phys.header.launch.l_paddr == NCB_SCRIPT_PHYS (np, select)) { - printf ("%s: timeout nccb=%p (skip)\n", - ncr_name (np), cp); + device_printf(np->dev, + "timeout nccb=%p (skip)\n", cp); cp->phys.header.launch.l_paddr = NCB_SCRIPT_PHYS (np, skip); }; @@ -5164,11 +5129,9 @@ ncr_timeout (void *arg) */ ncr_complete (np, cp); }; - splx (oldspl); } - np->timeout_ch = - timeout (ncr_timeout, (caddr_t) np, step ? step : 1); + callout_reset(&np->timer, step ? step : 1, ncr_timeout, np); if (INB(nc_istat) & (INTF|SIP|DIP)) { @@ -5176,11 +5139,9 @@ ncr_timeout (void *arg) ** Process pending interrupts. */ - int oldspl = splcam(); if (DEBUG_FLAGS & DEBUG_TINY) printf ("{"); ncr_exception (np); if (DEBUG_FLAGS & DEBUG_TINY) printf ("}"); - splx (oldspl); }; } @@ -5245,19 +5206,20 @@ static void ncr_log_hard_error(ncb_p np, u_short sist, u_char dstat) script_name = "mem"; } - printf ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", - ncr_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist, + device_printf(np->dev, + "%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", + (unsigned)INB (nc_sdid)&0x0f, dstat, sist, (unsigned)INB (nc_socl), (unsigned)INB (nc_sbcl), (unsigned)INB (nc_sbdl), (unsigned)INB (nc_sxfer),(unsigned)INB (nc_scntl3), script_name, script_ofs, (unsigned)INL (nc_dbc)); if (((script_ofs & 3) == 0) && (unsigned)script_ofs < script_size) { - printf ("%s: script cmd = %08x\n", ncr_name(np), + device_printf(np->dev, "script cmd = %08x\n", (int)READSCRIPT_OFF(script_base, script_ofs)); } - printf ("%s: regdump:", ncr_name(np)); + device_printf(np->dev, "regdump:"); for (i=0; i<16;i++) printf (" %02x", (unsigned)INB_OFF(i)); printf (".\n"); @@ -5411,7 +5373,7 @@ static void ncr_exception (ncb_p np) (INB(nc_sstat1) & (FF3210) ) || (INB(nc_sstat2) & (ILF1|ORF1|OLF1)) || /* wide .. */ !(dstat & DFE)) { - printf ("%s: have to clear fifos.\n", ncr_name (np)); + device_printf(np->dev, "have to clear fifos.\n"); OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */ OUTB (nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */ @@ -5423,7 +5385,7 @@ static void ncr_exception (ncb_p np) */ if (sist & HTH) { - printf ("%s: handshake timeout\n", ncr_name(np)); + device_printf(np->dev, "handshake timeout\n"); OUTB (nc_scntl1, CRST); DELAY (1000); OUTB (nc_scntl1, 0x00); @@ -5466,12 +5428,11 @@ static void ncr_exception (ncb_p np) /* ** info message */ - printf ("%s: INFO: LDSC while IID.\n", - ncr_name (np)); + device_printf(np->dev, "INFO: LDSC while IID.\n"); return; }; - printf ("%s: target %d doesn't release the bus.\n", - ncr_name (np), INB (nc_sdid)&0x0f); + device_printf(np->dev, "target %d doesn't release the bus.\n", + INB (nc_sdid)&0x0f); /* ** return without restarting the NCR. ** timeout will do the real work. @@ -5515,8 +5476,7 @@ static void ncr_exception (ncb_p np) switch (i%16) { case 0: - printf ("%s: reg[%d0]: ", - ncr_name(np),i/16); + device_printf(np->dev, "reg[%d0]: ", i / 16); break; case 4: case 8: @@ -5524,14 +5484,14 @@ static void ncr_exception (ncb_p np) printf (" "); break; }; - val = bus_space_read_1(np->bst, np->bsh, i); + val = bus_read_1(np->reg_res, i); printf (" %x%x", val/16, val%16); if (i%16==15) printf (".\n"); }; - untimeout (ncr_timeout, (caddr_t) np, np->timeout_ch); + callout_stop(&np->timer); - printf ("%s: halted!\n", ncr_name(np)); + device_printf(np->dev, "halted!\n"); /* ** don't restart controller ... */ @@ -5678,14 +5638,16 @@ static void ncr_int_ma (ncb_p np, u_char dstat) cp = cp->link_nccb; if (!cp) { - printf ("%s: SCSI phase error fixup: CCB already dequeued (%p)\n", - ncr_name (np), (void *) np->header.cp); - return; + device_printf(np->dev, + "SCSI phase error fixup: CCB already dequeued (%p)\n", + (void *)np->header.cp); + return; } if (cp != np->header.cp) { - printf ("%s: SCSI phase error fixup: CCB address mismatch " + device_printf(np->dev, + "SCSI phase error fixup: CCB address mismatch " "(%p != %p) np->nccb = %p\n", - ncr_name (np), (void *)cp, (void *)np->header.cp, + (void *)cp, (void *)np->header.cp, (void *)np->link_nccb); /* return;*/ } @@ -5889,7 +5851,7 @@ static void ncr_int_sir (ncb_p np) */ if (DEBUG_FLAGS & DEBUG_RESTART) - printf ("%s: int#%d",ncr_name (np),num); + device_printf(np->dev, "int#%d", num); cp = (nccb_p) 0; for (i=0; idev, "queue empty.\n"); WRITESCRIPT(start1[0], SCR_INT ^ IFFALSE (0)); break; }; @@ -6424,7 +6386,7 @@ static nccb_p ncr_get_nccb if (cp != NULL) { if (cp->magic) { - printf("%s: Bogus free cp found\n", ncr_name(np)); + device_printf(np->dev, "Bogus free cp found\n"); return (NULL); } cp->magic = 1; @@ -6913,7 +6875,7 @@ static void ncr_selectclock(ncb_p np, u_char scntl3) } if (bootverbose >= 2) - printf ("%s: enabling clock multiplier\n", ncr_name(np)); + device_printf(np->dev, "enabling clock multiplier\n"); OUTB(nc_stest1, DBLEN); /* Enable clock multiplier */ if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */ @@ -6921,7 +6883,8 @@ static void ncr_selectclock(ncb_p np, u_char scntl3) while (!(INB(nc_stest4) & LCKFRQ) && --i > 0) DELAY(20); if (!i) - printf("%s: the chip cannot lock the frequency\n", ncr_name(np)); + device_printf(np->dev, + "the chip cannot lock the frequency\n"); } else /* Wait 20 micro-seconds for doubler */ DELAY(20); OUTB(nc_stest3, HSC); /* Halt the scsi clock */ diff --git a/sys/pci/ncrreg.h b/sys/dev/ncr/ncrreg.h similarity index 100% rename from sys/pci/ncrreg.h rename to sys/dev/ncr/ncrreg.h diff --git a/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c b/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c index e8e877788687..2f864ab2e2c8 100644 --- a/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c +++ b/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c @@ -414,7 +414,7 @@ nf10bmac_rx_locked(struct nf10bmac_softc *sc) * packet on the floor and count the error. */ nf10bmac_eat_packet_munch_munch(sc); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return (0); } else if ((len - l) <= sizeof(val)) { @@ -445,14 +445,14 @@ nf10bmac_rx_locked(struct nf10bmac_softc *sc) if ((md & NF10BMAC_DATA_LAST) == 0 || (md & NF10BMAC_DATA_STRB) == 0) { device_printf(sc->nf10bmac_dev, "Unexpected rx loop end state: " "md=0x%08jx len=%d l=%d\n", (uintmax_t)md, len, l); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return (0); } m->m_pkthdr.len = m->m_len = len; m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); NF10BMAC_UNLOCK(sc); (*ifp->if_input)(ifp, m); @@ -584,7 +584,7 @@ nf10bmac_watchdog(struct nf10bmac_softc *sc) return; device_printf(sc->nf10bmac_dev, "watchdog timeout\n"); - sc->nf10bmac_ifp->if_oerrors++; + sc->nf10if_inc_counter(bmac_ifp, IFCOUNTER_OERRORS, 1); sc->nf10bmac_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; nf10bmac_init_locked(sc); diff --git a/sys/dev/netmap/if_lem_netmap.h b/sys/dev/netmap/if_lem_netmap.h index 272f02c7b9d0..50eb1f719929 100644 --- a/sys/dev/netmap/if_lem_netmap.h +++ b/sys/dev/netmap/if_lem_netmap.h @@ -410,7 +410,7 @@ lem_netmap_rxsync(struct netmap_kring *kring, int flags) netmap_idx_n2k(kring, adapter->next_rx_desc_to_check), kring->nr_hwtail); adapter->next_rx_desc_to_check = nic_i; - // ifp->if_ipackets += n; + // if_inc_counter(ifp, IFCOUNTER_IPACKETS, n); kring->nr_hwtail = nm_i; } kring->nr_kflags &= ~NKR_PENDINTR; diff --git a/sys/dev/netmap/if_re_netmap.h b/sys/dev/netmap/if_re_netmap.h index 98f61432ad7c..354f14df1c58 100644 --- a/sys/dev/netmap/if_re_netmap.h +++ b/sys/dev/netmap/if_re_netmap.h @@ -222,7 +222,7 @@ re_netmap_rxsync(struct netmap_kring *kring, int flags) /* sync was in re_newbuf() */ bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, rxd[nic_i].rx_dmamap, BUS_DMASYNC_POSTREAD); - // sc->rl_ifp->if_ipackets++; + // if_inc_counter(sc->rl_ifp, IFCOUNTER_IPACKETS, 1); nm_i = nm_next(nm_i, lim); nic_i = nm_next(nic_i, lim); } diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c index 0fd362fe086f..f37bf9e81c45 100644 --- a/sys/dev/netmap/netmap.c +++ b/sys/dev/netmap/netmap.c @@ -2222,23 +2222,18 @@ netmap_ioctl(struct cdev *dev, u_long cmd, caddr_t data, default: /* allow device-specific ioctls */ { - struct socket so; - struct ifnet *ifp; + struct ifnet *ifp = ifunit_ref(nmr->nr_name); + if (ifp == NULL) { + error = ENXIO; + } else { + struct socket so; - bzero(&so, sizeof(so)); - NMG_LOCK(); - error = netmap_get_na(nmr, &na, 0 /* don't create */); /* keep reference */ - if (error) { - netmap_adapter_put(na); - NMG_UNLOCK(); - break; + bzero(&so, sizeof(so)); + so.so_vnet = ifp->if_vnet; + // so->so_proto not null. + error = ifioctl(&so, cmd, data, td); + if_rele(ifp); } - ifp = na->ifp; - so.so_vnet = ifp->if_vnet; - // so->so_proto not null. - error = ifioctl(&so, cmd, data, td); - netmap_adapter_put(na); - NMG_UNLOCK(); break; } diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h index e97d5b570db6..76d893588e34 100644 --- a/sys/dev/netmap/netmap_kern.h +++ b/sys/dev/netmap/netmap_kern.h @@ -63,6 +63,12 @@ #define NM_ATOMIC_TEST_AND_SET(p) (!atomic_cmpset_acq_int((p), 0, 1)) #define NM_ATOMIC_CLEAR(p) atomic_store_rel_int((p), 0) +#if __FreeBSD_version >= 1100030 +#define WNA(_ifp) (_ifp)->if_netmap +#else /* older FreeBSD */ +#define WNA(_ifp) (_ifp)->if_pspare[0] +#endif /* older FreeBSD */ + #if __FreeBSD_version >= 1100005 struct netmap_adapter *netmap_getna(if_t ifp); #endif @@ -1186,9 +1192,6 @@ extern int netmap_generic_rings; * 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_netmap -#endif #define NA(_ifp) ((struct netmap_adapter *)WNA(_ifp)) /* diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index 0c0ae5cf60f4..1675f032bddc 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -1630,7 +1630,7 @@ nfe_free_tx_ring(struct nfe_softc *sc, struct nfe_tx_ring *ring) } #ifdef DEVICE_POLLING -static poll_handler_drv_t nfe_poll; +static poll_handler_t nfe_poll; static int @@ -1782,7 +1782,7 @@ nfe_ioctl(if_t ifp, u_long cmd, caddr_t data) #ifdef DEVICE_POLLING if ((mask & IFCAP_POLLING) != 0) { if ((ifr->ifr_reqcap & IFCAP_POLLING) != 0) { - error = ether_poll_register_drv(nfe_poll, ifp); + error = ether_poll_register(nfe_poll, ifp); if (error) break; NFE_LOCK(sc); @@ -2149,7 +2149,7 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp) prog++; if ((sc->nfe_flags & (NFE_JUMBO_SUP | NFE_40BIT_ADDR)) == 0) { if (!(flags & NFE_RX_VALID_V1)) { - if_incierrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); nfe_discard_rxbuf(sc, sc->rxq.cur); continue; } @@ -2159,7 +2159,7 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp) } } else { if (!(flags & NFE_RX_VALID_V2)) { - if_incierrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); nfe_discard_rxbuf(sc, sc->rxq.cur); continue; } @@ -2171,14 +2171,14 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp) } if (flags & NFE_RX_ERROR) { - if_incierrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); nfe_discard_rxbuf(sc, sc->rxq.cur); continue; } m = data->m; if (nfe_newbuf(sc, sc->rxq.cur) != 0) { - if_inciqdrops(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); nfe_discard_rxbuf(sc, sc->rxq.cur); continue; } @@ -2205,7 +2205,7 @@ nfe_rxeof(struct nfe_softc *sc, int count, int *rx_npktsp) } } - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); NFE_UNLOCK(sc); if_input(ifp, m); @@ -2265,7 +2265,7 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp) prog++; if ((sc->nfe_flags & (NFE_JUMBO_SUP | NFE_40BIT_ADDR)) == 0) { if (!(flags & NFE_RX_VALID_V1)) { - if_incierrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); nfe_discard_jrxbuf(sc, sc->jrxq.jcur); continue; } @@ -2275,7 +2275,7 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp) } } else { if (!(flags & NFE_RX_VALID_V2)) { - if_incierrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); nfe_discard_jrxbuf(sc, sc->jrxq.jcur); continue; } @@ -2287,14 +2287,14 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp) } if (flags & NFE_RX_ERROR) { - if_incierrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); nfe_discard_jrxbuf(sc, sc->jrxq.jcur); continue; } m = data->m; if (nfe_jnewbuf(sc, sc->jrxq.jcur) != 0) { - if_inciqdrops(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); nfe_discard_jrxbuf(sc, sc->jrxq.jcur); continue; } @@ -2321,7 +2321,7 @@ nfe_jrxeof(struct nfe_softc *sc, int count, int *rx_npktsp) } } - if_incipackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); NFE_UNLOCK(sc); if_input(ifp, m); @@ -2379,18 +2379,18 @@ nfe_txeof(struct nfe_softc *sc) device_printf(sc->nfe_dev, "tx v1 error 0x%4b\n", flags, NFE_V1_TXERR); - if_incoerrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else - if_incopackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } else { if ((flags & NFE_TX_LASTFRAG_V2) == 0) continue; if ((flags & NFE_TX_ERROR_V2) != 0) { device_printf(sc->nfe_dev, "tx v2 error 0x%4b\n", flags, NFE_V2_TXERR); - if_incoerrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else - if_incopackets(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } /* last fragment of the mbuf chain transmitted */ @@ -2723,7 +2723,7 @@ nfe_watchdog(if_t ifp) if_printf(ifp, "watchdog timeout\n"); if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); - if_incoerrors(ifp, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); nfe_init_locked(sc); } diff --git a/sys/pci/nfsmb.c b/sys/dev/nfsmb/nfsmb.c similarity index 100% rename from sys/pci/nfsmb.c rename to sys/dev/nfsmb/nfsmb.c diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index 2d28883cba73..007a1139ec89 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -1476,7 +1476,7 @@ nge_rxeof(struct nge_softc *sc) if ((cmdsts & NGE_CMDSTS_MORE) != 0) { if (nge_newbuf(sc, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (sc->nge_head != NULL) { m_freem(sc->nge_head); sc->nge_head = sc->nge_tail = NULL; @@ -1526,7 +1526,7 @@ nge_rxeof(struct nge_softc *sc) /* Try conjure up a replacement mbuf. */ if (nge_newbuf(sc, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (sc->nge_head != NULL) { m_freem(sc->nge_head); sc->nge_head = sc->nge_tail = NULL; @@ -1563,7 +1563,7 @@ nge_rxeof(struct nge_softc *sc) nge_fixup_rx(m); #endif m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { /* Do IP checksum checking. */ @@ -1650,15 +1650,15 @@ nge_txeof(struct nge_softc *sc) BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->nge_cdata.nge_tx_tag, txd->tx_dmamap); if ((cmdsts & NGE_CMDSTS_PKT_OK) == 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if ((cmdsts & NGE_TXSTAT_EXCESSCOLLS) != 0) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if ((cmdsts & NGE_TXSTAT_OUTOFWINCOLL) != 0) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - ifp->if_collisions += (cmdsts & NGE_TXSTAT_COLLCNT) >> 16; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (cmdsts & NGE_TXSTAT_COLLCNT) >> 16); KASSERT(txd->tx_m != NULL, ("%s: freeing NULL mbuf!\n", __func__)); m_freem(txd->tx_m); @@ -1730,8 +1730,9 @@ nge_stats_update(struct nge_softc *sc) /* * Since we've accept errored frames exclude Rx length errors. */ - ifp->if_ierrors += stats->rx_pkts_errs + stats->rx_crc_errs + - stats->rx_fifo_oflows + stats->rx_sym_errs; + if_inc_counter(ifp, IFCOUNTER_IERRORS, + stats->rx_pkts_errs + stats->rx_crc_errs + + stats->rx_fifo_oflows + stats->rx_sym_errs); nstats = &sc->nge_stats; nstats->rx_pkts_errs += stats->rx_pkts_errs; @@ -2435,7 +2436,7 @@ nge_watchdog(struct nge_softc *sc) return; ifp = sc->nge_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c index 04a0b160c127..dbe24cb5191b 100644 --- a/sys/dev/nmdm/nmdm.c +++ b/sys/dev/nmdm/nmdm.c @@ -157,21 +157,21 @@ nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen, { struct nmdmsoftc *ns; struct tty *tp; - unsigned long unit; char *end; int error; + char endc; if (*dev != NULL) return; if (strncmp(name, "nmdm", 4) != 0) return; - - /* Device name must be "nmdm%lu%c", where %c is 'A' or 'B'. */ - name += 4; - unit = strtoul(name, &end, 10); - if (unit == ULONG_MAX || name == end) + if (strlen(name) <= strlen("nmdmX")) return; - if ((end[0] != 'A' && end[0] != 'B') || end[1] != '\0') + + /* Device name must be "nmdm%s%c", where %c is 'A' or 'B'. */ + end = name + strlen(name) - 1; + endc = *end; + if (endc != 'A' && endc != 'B') return; ns = malloc(sizeof(*ns), M_NMDM, M_WAITOK | M_ZERO); @@ -191,9 +191,11 @@ nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen, /* Create device nodes. */ tp = ns->ns_part1.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part1, &ns->ns_mtx); - error = tty_makedevf(tp, NULL, end[0] == 'A' ? TTYMK_CLONING : 0, - "nmdm%luA", unit); + *end = 'A'; + error = tty_makedevf(tp, NULL, endc == 'A' ? TTYMK_CLONING : 0, + "%s", name); if (error) { + *end = endc; mtx_destroy(&ns->ns_mtx); free(ns, M_NMDM); return; @@ -201,9 +203,11 @@ nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen, tp = ns->ns_part2.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part2, &ns->ns_mtx); - error = tty_makedevf(tp, NULL, end[0] == 'B' ? TTYMK_CLONING : 0, - "nmdm%luB", unit); + *end = 'B'; + error = tty_makedevf(tp, NULL, endc == 'B' ? TTYMK_CLONING : 0, + "%s", name); if (error) { + *end = endc; mtx_lock(&ns->ns_mtx); /* see nmdm_free() */ ns->ns_part1.np_other = NULL; @@ -212,11 +216,12 @@ nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen, return; } - if (end[0] == 'A') + if (endc == 'A') *dev = ns->ns_part1.np_tty->t_dev; else *dev = ns->ns_part2.np_tty->t_dev; + *end = endc; atomic_add_int(&nmdm_count, 1); } diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c index af57491e1fa2..fe48007e8973 100644 --- a/sys/dev/oce/oce_if.c +++ b/sys/dev/oce/oce_if.c @@ -989,7 +989,7 @@ oce_tx(POCE_SOFTC sc, struct mbuf **mpp, int wq_index) pd->nsegs++; } - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); wq->tx_stats.tx_reqs++; wq->tx_stats.tx_wrbs += num_wqes; wq->tx_stats.tx_bytes += m->m_pkthdr.len; @@ -1275,9 +1275,9 @@ oce_multiq_transmit(struct ifnet *ifp, struct mbuf *m, struct oce_wq *wq) break; } drbr_advance(ifp, br); - ifp->if_obytes += next->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len); if (next->m_flags & M_MCAST) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); ETHER_BPF_MTAP(ifp, next); } @@ -1394,7 +1394,7 @@ oce_rx(struct oce_rq *rq, uint32_t rqe_idx, struct oce_nic_rx_cqe *cqe) } } - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); #if defined(INET6) || defined(INET) /* Try to queue to LRO */ if (IF_LRO_ENABLED(sc) && @@ -1637,7 +1637,7 @@ oce_rq_handler(void *arg) oce_rx(rq, cqe->u0.s.frag_index, cqe); } else { rq->rx_stats.rxcp_err++; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); /* Post L3/L4 errors to stack.*/ oce_rx(rq, cqe->u0.s.frag_index, cqe); } @@ -1731,7 +1731,9 @@ oce_attach_ifp(POCE_SOFTC sc) sc->ifp->if_baudrate = IF_Gbps(10); #if __FreeBSD_version >= 1000000 - sc->ifp->if_hw_tsomax = OCE_MAX_TSO_SIZE; + sc->ifp->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + sc->ifp->if_hw_tsomaxsegcount = OCE_MAX_TX_ELEMENTS; + sc->ifp->if_hw_tsomaxsegsize = 4096; #endif ether_ifattach(sc->ifp, sc->macaddr.mac_addr); diff --git a/sys/dev/oce/oce_if.h b/sys/dev/oce/oce_if.h index b6db402e7766..bb788413faa0 100644 --- a/sys/dev/oce/oce_if.h +++ b/sys/dev/oce/oce_if.h @@ -152,7 +152,6 @@ extern int mp_ncpus; /* system's total active cpu cores */ #define OCE_MAX_TX_ELEMENTS 29 #define OCE_MAX_TX_DESC 1024 #define OCE_MAX_TX_SIZE 65535 -#define OCE_MAX_TSO_SIZE (65535 - ETHER_HDR_LEN) #define OCE_MAX_RX_SIZE 4096 #define OCE_MAX_RQ_POSTS 255 #define OCE_DEFAULT_PROMISCUOUS 0 diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c index 7ddb5e6ab9d1..cd1169365d68 100644 --- a/sys/dev/ofw/ofw_bus_subr.c +++ b/sys/dev/ofw/ofw_bus_subr.c @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -367,3 +369,64 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz, return (0); } +int +ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl) +{ + phandle_t iparent; + uint32_t icells, *intr; + int err, i, irqnum, nintr, rid; + boolean_t extended; + + nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), + (void **)&intr); + if (nintr > 0) { + if (OF_searchencprop(node, "interrupt-parent", &iparent, + sizeof(iparent)) == -1) { + device_printf(dev, "No interrupt-parent found, " + "assuming direct parent\n"); + iparent = OF_parent(node); + } + if (OF_searchencprop(OF_node_from_xref(iparent), + "#interrupt-cells", &icells, sizeof(icells)) == -1) { + device_printf(dev, "Missing #interrupt-cells " + "property, assuming <1>\n"); + icells = 1; + } + if (icells < 1 || icells > nintr) { + device_printf(dev, "Invalid #interrupt-cells property " + "value <%d>, assuming <1>\n", icells); + icells = 1; + } + extended = false; + } else { + nintr = OF_getencprop_alloc(node, "interrupts-extended", + sizeof(*intr), (void **)&intr); + if (nintr <= 0) + return (0); + extended = true; + } + err = 0; + rid = 0; + for (i = 0; i < nintr; i += icells) { + if (extended) { + iparent = intr[i++]; + if (OF_searchencprop(OF_node_from_xref(iparent), + "#interrupt-cells", &icells, sizeof(icells)) == -1) { + device_printf(dev, "Missing #interrupt-cells " + "property\n"); + err = ENOENT; + break; + } + if (icells < 1 || (i + icells) > nintr) { + device_printf(dev, "Invalid #interrupt-cells " + "property value <%d>\n", icells); + err = ERANGE; + break; + } + } + irqnum = ofw_bus_map_intr(dev, iparent, icells, &intr[i]); + resource_list_add(rl, SYS_RES_IRQ, rid++, irqnum, irqnum, 1); + } + free(intr, M_OFWPROP); + return (err); +} diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h index a4d8b920291f..59f83fca3c3c 100644 --- a/sys/dev/ofw/ofw_bus_subr.h +++ b/sys/dev/ofw/ofw_bus_subr.h @@ -72,6 +72,9 @@ int ofw_bus_lookup_imap(phandle_t, struct ofw_bus_iinfo *, void *, int, int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *, void *, void *, int, phandle_t *); +/* Routines for parsing device-tree data into resource lists. */ +int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *); + /* Helper to get device status property */ const char *ofw_bus_get_status(device_t dev); int ofw_bus_status_okay(device_t dev); diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c index 11a6a645ab48..2b975ac1aa11 100644 --- a/sys/dev/ofw/ofwbus.c +++ b/sys/dev/ofw/ofwbus.c @@ -436,11 +436,9 @@ ofwbus_setup_dinfo(device_t dev, phandle_t node) struct ofwbus_softc *sc; struct ofwbus_devinfo *ndi; const char *nodename; - uint32_t *reg, *intr, icells; + uint32_t *reg; uint64_t phys, size; - phandle_t iparent; int i, j, rid; - int nintr; int nreg; sc = device_get_softc(dev); @@ -485,35 +483,7 @@ ofwbus_setup_dinfo(device_t dev, phandle_t node) } free(reg, M_OFWPROP); - nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - if (OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)) == -1) { - device_printf(dev, "No interrupt-parent found, " - "assuming nexus on <%s>\n", nodename); - iparent = 0xffffffff; - } - if (OF_searchencprop(OF_node_from_xref(iparent), - "#interrupt-cells", &icells, sizeof(icells)) == -1) { - device_printf(dev, "Missing #interrupt-cells property, " - "assuming <1> on <%s>\n", nodename); - icells = 1; - } - if (icells < 1 || icells > nintr) { - device_printf(dev, "Invalid #interrupt-cells property " - "value <%d>, assuming <1> on <%s>\n", icells, - nodename); - icells = 1; - } - for (i = 0, rid = 0; i < nintr; i += icells, rid++) { - intr[i] = ofw_bus_map_intr(dev, iparent, icells, - &intr[i]); - resource_list_add(&ndi->ndi_rl, SYS_RES_IRQ, rid, intr[i], - intr[i], 1); - } - free(intr, M_OFWPROP); - } + ofw_bus_intr_to_rl(dev, node, &ndi->ndi_rl); return (ndi); } diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c index cc997d90f210..5bcf3d1a69d2 100644 --- a/sys/dev/ofw/openfirm.c +++ b/sys/dev/ofw/openfirm.c @@ -62,7 +62,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include +#include #include #include @@ -92,6 +95,7 @@ struct xrefinfo { }; static SLIST_HEAD(, xrefinfo) xreflist = SLIST_HEAD_INITIALIZER(xreflist); +static struct mtx xreflist_lock; static boolean_t xref_init_done; #define FIND_BY_XREF 0 @@ -138,6 +142,12 @@ static void xrefinfo_init(void *unsed) { + /* + * There is no locking during this init because it runs much earlier + * than any of the clients/consumers of the xref list data, but we do + * initialize the mutex that will be used for access later. + */ + mtx_init(&xreflist_lock, "OF xreflist lock", NULL, MTX_DEF); xrefinfo_create(OF_peer(0)); xref_init_done = true; } @@ -146,17 +156,35 @@ SYSINIT(xrefinfo, SI_SUB_KMEM, SI_ORDER_ANY, xrefinfo_init, NULL); static struct xrefinfo * xrefinfo_find(phandle_t phandle, int find_by) { - struct xrefinfo * xi; + struct xrefinfo *rv, *xi; + rv = NULL; + mtx_lock(&xreflist_lock); SLIST_FOREACH(xi, &xreflist, next_entry) { - if (find_by == FIND_BY_XREF && phandle == xi->xref) - return (xi); - else if (find_by == FIND_BY_NODE && phandle == xi->node) - return (xi); - else if (find_by == FIND_BY_DEV && phandle == (uintptr_t)xi->dev) - return (xi); + if ((find_by == FIND_BY_XREF && phandle == xi->xref) || + (find_by == FIND_BY_NODE && phandle == xi->node) || + (find_by == FIND_BY_DEV && phandle == (uintptr_t)xi->dev)) { + rv = xi; + break; + } } - return (NULL); + mtx_unlock(&xreflist_lock); + return (rv); +} + +static struct xrefinfo * +xrefinfo_add(phandle_t node, phandle_t xref, device_t dev) +{ + struct xrefinfo *xi; + + xi = malloc(sizeof(*xi), M_OFWPROP, M_WAITOK); + xi->node = node; + xi->xref = xref; + xi->dev = dev; + mtx_lock(&xreflist_lock); + SLIST_INSERT_HEAD(&xreflist, xi, next_entry); + mtx_unlock(&xreflist_lock); + return (xi); } /* @@ -605,10 +633,17 @@ OF_device_register_xref(phandle_t xref, device_t dev) { struct xrefinfo *xi; + /* + * If the given xref handle doesn't already exist in the list then we + * add a list entry. In theory this can only happen on a system where + * nodes don't contain phandle properties and xref and node handles are + * synonymous, so the xref handle is added as the node handle as well. + */ if (xref_init_done) { if ((xi = xrefinfo_find(xref, FIND_BY_XREF)) == NULL) - return (ENXIO); - xi->dev = dev; + xrefinfo_add(xref, xref, dev); + else + xi->dev = dev; return (0); } panic("Attempt to register device before xreflist_init"); diff --git a/sys/dev/patm/if_patm_rx.c b/sys/dev/patm/if_patm_rx.c index 06a58c34b1c8..3df4d6a29b8d 100644 --- a/sys/dev/patm/if_patm_rx.c +++ b/sys/dev/patm/if_patm_rx.c @@ -254,7 +254,7 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) } else if (vcc->vcc.aal == ATMIO_AAL_5) { if (stat & IDT_RSQE_CRC) { - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); if (vcc->chain != NULL) { m_freem(vcc->chain); vcc->chain = vcc->last = NULL; @@ -312,9 +312,9 @@ patm_rx(struct patm_softc *sc, struct idt_rsqe *rsqe) } #endif - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); /* this is in if_atmsubr.c */ - /* sc->ifp->if_ibytes += m->m_pkthdr.len; */ + /* if_inc_counter(sc->ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); */ vcc->ibytes += m->m_pkthdr.len; vcc->ipackets++; @@ -511,9 +511,9 @@ patm_rx_raw(struct patm_softc *sc, u_char *cell) break; } - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); /* this is in if_atmsubr.c */ - /* sc->ifp->if_ibytes += m->m_pkthdr.len; */ + /* if_inc_counter(sc->ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); */ vcc->ibytes += m->m_pkthdr.len; vcc->ipackets++; diff --git a/sys/dev/patm/if_patm_tx.c b/sys/dev/patm/if_patm_tx.c index 1b4384496b9e..d38d07895d0d 100644 --- a/sys/dev/patm/if_patm_tx.c +++ b/sys/dev/patm/if_patm_tx.c @@ -304,7 +304,7 @@ patm_start(struct ifnet *ifp) /* split of pseudo header */ if (m->m_len < sizeof(*aph) && (m = m_pullup(m, sizeof(*aph))) == NULL) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } @@ -316,21 +316,21 @@ patm_start(struct ifnet *ifp) /* reject empty packets */ if (m->m_pkthdr.len == 0) { m_freem(m); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } /* check whether this is a legal vcc */ if (!LEGAL_VPI(sc, vpi) || !LEGAL_VCI(sc, vci) || vci == 0) { m_freem(m); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } cid = PATM_CID(sc, vpi, vci); vcc = sc->vccs[cid]; if (vcc == NULL) { m_freem(m); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } @@ -340,7 +340,7 @@ patm_start(struct ifnet *ifp) /* XXX AAL3/4 format? */ if (m->m_pkthdr.len % 48 != 0 && (m = patm_tx_pad(sc, m)) == NULL) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } } else if (vcc->vcc.aal == ATMIO_AAL_RAW) { @@ -349,7 +349,7 @@ patm_start(struct ifnet *ifp) default: case PATM_RAW_CELL: if (m->m_pkthdr.len != 53) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); m_freem(m); continue; } @@ -357,7 +357,7 @@ patm_start(struct ifnet *ifp) case PATM_RAW_NOHEC: if (m->m_pkthdr.len != 52) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); m_freem(m); continue; } @@ -365,7 +365,7 @@ patm_start(struct ifnet *ifp) case PATM_RAW_CS: if (m->m_pkthdr.len != 64) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); m_freem(m); continue; } @@ -378,7 +378,7 @@ patm_start(struct ifnet *ifp) /* try to put it on the channels queue */ if (_IF_QFULL(&vcc->scd->q)) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); sc->stats.tx_qfull++; m_freem(m); continue; @@ -416,7 +416,7 @@ patm_tx_pad(struct patm_softc *sc, struct mbuf *m0) m0->m_pkthdr.len = plen; if (plen == 0) { m_freem(m0); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); return (NULL); } if (plen % 48 == 0) @@ -442,7 +442,7 @@ patm_tx_pad(struct patm_softc *sc, struct mbuf *m0) MGET(m, M_NOWAIT, MT_DATA); if (m == 0) { m_freem(m0); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); return (NULL); } bzero(mtod(m, u_char *), pad); @@ -534,7 +534,7 @@ patm_launch(struct patm_softc *sc, struct patm_scd *scd) patm_load_txbuf, &a, BUS_DMA_NOWAIT); if (error == EFBIG) { if ((m = m_defrag(m, M_NOWAIT)) == NULL) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); continue; } error = bus_dmamap_load_mbuf(sc->tx_tag, map->map, m, @@ -542,13 +542,13 @@ patm_launch(struct patm_softc *sc, struct patm_scd *scd) } if (error != 0) { sc->stats.tx_load_err++; - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); SLIST_INSERT_HEAD(&sc->tx_maps_free, map, link); m_freem(m); continue; } - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); } } diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 0526e8d08c8f..1bb31724c126 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -131,7 +131,7 @@ static device_method_t pci_methods[] = { DEVMETHOD(device_detach, bus_generic_detach), #endif DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, pci_suspend), + DEVMETHOD(device_suspend, bus_generic_suspend), DEVMETHOD(device_resume, pci_resume), /* Bus interface */ @@ -157,6 +157,8 @@ static device_method_t pci_methods[] = { DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method), DEVMETHOD(bus_child_location_str, pci_child_location_str_method), DEVMETHOD(bus_remap_intr, pci_remap_intr_method), + DEVMETHOD(bus_suspend_child, pci_suspend_child), + DEVMETHOD(bus_resume_child, pci_resume_child), /* PCI interface */ DEVMETHOD(pci_read_config, pci_read_config_method), @@ -3622,12 +3624,11 @@ pci_detach(device_t dev) #endif static void -pci_set_power_children(device_t dev, device_t *devlist, int numdevs, - int state) +pci_set_power_child(device_t dev, device_t child, int state) { - device_t child, pcib; struct pci_devinfo *dinfo; - int dstate, i; + device_t pcib; + int dstate; /* * Set the device to the given state. If the firmware suggests @@ -3637,45 +3638,54 @@ pci_set_power_children(device_t dev, device_t *devlist, int numdevs, * are handled separately. */ pcib = device_get_parent(dev); - for (i = 0; i < numdevs; i++) { - child = devlist[i]; - dinfo = device_get_ivars(child); - dstate = state; - if (device_is_attached(child) && - PCIB_POWER_FOR_SLEEP(pcib, dev, &dstate) == 0) - pci_set_powerstate(child, dstate); - } + dinfo = device_get_ivars(child); + dstate = state; + if (device_is_attached(child) && + PCIB_POWER_FOR_SLEEP(pcib, dev, &dstate) == 0) + pci_set_powerstate(child, dstate); } int -pci_suspend(device_t dev) +pci_suspend_child(device_t dev, device_t child) { - device_t child, *devlist; struct pci_devinfo *dinfo; - int error, i, numdevs; + int error; + + dinfo = device_get_ivars(child); /* - * Save the PCI configuration space for each child and set the + * Save the PCI configuration space for the child and set the * device in the appropriate power state for this sleep state. */ - if ((error = device_get_children(dev, &devlist, &numdevs)) != 0) - return (error); - for (i = 0; i < numdevs; i++) { - child = devlist[i]; - dinfo = device_get_ivars(child); - pci_cfg_save(child, dinfo, 0); - } + pci_cfg_save(child, dinfo, 0); /* Suspend devices before potentially powering them down. */ - error = bus_generic_suspend(dev); - if (error) { - free(devlist, M_TEMP); + error = bus_generic_suspend_child(dev, child); + + if (error) return (error); - } + if (pci_do_power_suspend) - pci_set_power_children(dev, devlist, numdevs, - PCI_POWERSTATE_D3); - free(devlist, M_TEMP); + pci_set_power_child(dev, child, PCI_POWERSTATE_D3); + + return (0); +} + +int +pci_resume_child(device_t dev, device_t child) +{ + struct pci_devinfo *dinfo; + + if (pci_do_power_resume) + pci_set_power_child(dev, child, PCI_POWERSTATE_D0); + + dinfo = device_get_ivars(child); + pci_cfg_restore(child, dinfo); + if (!device_is_attached(child)) + pci_cfg_save(child, dinfo, 1); + + bus_generic_resume_child(dev, child); + return (0); } @@ -3683,27 +3693,10 @@ int pci_resume(device_t dev) { device_t child, *devlist; - struct pci_devinfo *dinfo; int error, i, numdevs; - /* - * Set each child to D0 and restore its PCI configuration space. - */ if ((error = device_get_children(dev, &devlist, &numdevs)) != 0) return (error); - if (pci_do_power_resume) - pci_set_power_children(dev, devlist, numdevs, - PCI_POWERSTATE_D0); - - /* Now the device is powered up, restore its config space. */ - for (i = 0; i < numdevs; i++) { - child = devlist[i]; - dinfo = device_get_ivars(child); - - pci_cfg_restore(child, dinfo); - if (!device_is_attached(child)) - pci_cfg_save(child, dinfo, 1); - } /* * Resume critical devices first, then everything else later. @@ -3715,7 +3708,7 @@ pci_resume(device_t dev) case PCIC_MEMORY: case PCIC_BRIDGE: case PCIC_BASEPERIPH: - DEVICE_RESUME(child); + BUS_RESUME_CHILD(dev, child); break; } } @@ -3728,7 +3721,7 @@ pci_resume(device_t dev) case PCIC_BASEPERIPH: break; default: - DEVICE_RESUME(child); + BUS_RESUME_CHILD(dev, child); } } free(devlist, M_TEMP); diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h index 5a90ce98d8ba..c10701d2afca 100644 --- a/sys/dev/pci/pci_private.h +++ b/sys/dev/pci/pci_private.h @@ -123,7 +123,8 @@ int pci_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, size_t buflen); int pci_assign_interrupt_method(device_t dev, device_t child); int pci_resume(device_t dev); -int pci_suspend(device_t dev); +int pci_resume_child(device_t dev, device_t child); +int pci_suspend_child(device_t dev, device_t child); bus_dma_tag_t pci_get_dma_tag(device_t bus, device_t dev); void pci_child_added_method(device_t dev, device_t child); diff --git a/sys/dev/pcn/if_pcn.c b/sys/dev/pcn/if_pcn.c index cd04b38899d3..d3121a13ea3d 100644 --- a/sys/dev/pcn/if_pcn.c +++ b/sys/dev/pcn/if_pcn.c @@ -856,7 +856,7 @@ pcn_rxeof(sc) * comes up in the ring. */ if (cur_rx->pcn_rxstat & PCN_RXSTAT_ERR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); pcn_newbuf(sc, i, m); PCN_INC(i, PCN_RX_LIST_CNT); continue; @@ -865,7 +865,7 @@ pcn_rxeof(sc) if (pcn_newbuf(sc, i, NULL)) { /* Ran out of mbufs; recycle this one. */ pcn_newbuf(sc, i, m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); PCN_INC(i, PCN_RX_LIST_CNT); continue; } @@ -873,7 +873,7 @@ pcn_rxeof(sc) PCN_INC(i, PCN_RX_LIST_CNT); /* No errors; receive the packet. */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_len = m->m_pkthdr.len = cur_rx->pcn_rxlen - ETHER_CRC_LEN; m->m_pkthdr.rcvif = ifp; @@ -921,17 +921,17 @@ pcn_txeof(sc) } if (cur_tx->pcn_txctl & PCN_TXCTL_ERR) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (cur_tx->pcn_txstat & PCN_TXSTAT_EXDEF) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (cur_tx->pcn_txstat & PCN_TXSTAT_RTRY) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } - ifp->if_collisions += - cur_tx->pcn_txstat & PCN_TXSTAT_TRC; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + cur_tx->pcn_txstat & PCN_TXSTAT_TRC); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (sc->pcn_cdata.pcn_tx_chain[idx] != NULL) { m_freem(sc->pcn_cdata.pcn_tx_chain[idx]); sc->pcn_cdata.pcn_tx_chain[idx] = NULL; @@ -1436,7 +1436,7 @@ pcn_watchdog(struct pcn_softc *sc) PCN_LOCK_ASSERT(sc); ifp = sc->pcn_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); pcn_stop(sc); diff --git a/sys/dev/pdq/pdq_ifsubr.c b/sys/dev/pdq/pdq_ifsubr.c index b359b5253456..50619cbe0242 100644 --- a/sys/dev/pdq/pdq_ifsubr.c +++ b/sys/dev/pdq/pdq_ifsubr.c @@ -229,7 +229,7 @@ pdq_os_receive_pdu( struct ifnet *ifp = PDQ_IFNET(sc); struct fddi_header *fh; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); #if defined(PDQ_BUS_DMA) { /* @@ -251,8 +251,8 @@ pdq_os_receive_pdu( m->m_pkthdr.len = pktlen; fh = mtod(m, struct fddi_header *); if (drop || (fh->fddi_fc & (FDDIFC_L|FDDIFC_F)) != FDDIFC_LLC_ASYNC) { - ifp->if_iqdrops++; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); PDQ_OS_DATABUF_FREE(pdq, m); return; } @@ -289,7 +289,7 @@ pdq_os_transmit_done( PDQ_BPF_MTAP(sc, m); #endif PDQ_OS_DATABUF_FREE(pdq, m); - PDQ_IFNET(sc)->if_opackets++; + if_inc_counter(PDQ_IFNET(sc), IFCOUNTER_OPACKETS, 1); } void diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index dbc5183fe894..93a0da17307a 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -576,8 +576,8 @@ lp_intr(void *arg) sc->sc_iferrs = 0; len -= CLPIPHDRLEN; - sc->sc_ifp->if_ipackets++; - sc->sc_ifp->if_ibytes += len; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, len); top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp, 0); if (top) { @@ -630,8 +630,8 @@ lp_intr(void *arg) sc->sc_iferrs = 0; len -= LPIPHDRLEN; - sc->sc_ifp->if_ipackets++; - sc->sc_ifp->if_ibytes += len; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, len); top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp, 0); if (top) { @@ -651,7 +651,7 @@ lp_intr(void *arg) err: ppb_wdtr(ppbus, 0); lprintf("R"); - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); sc->sc_iferrs++; /* @@ -768,11 +768,11 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, nend: ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (err) { /* if we didn't timeout... */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lprintf("X"); } else { - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); if (bpf_peers_present(ifp->if_bpf)) lptap(ifp, m); } @@ -814,11 +814,11 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (err) { /* if we didn't timeout... */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); lprintf("X"); } else { - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); if (bpf_peers_present(ifp->if_bpf)) lptap(ifp, m); } diff --git a/sys/dev/qlxgbe/ql_hw.c b/sys/dev/qlxgbe/ql_hw.c index 1d1e3f145b32..f28215999a12 100644 --- a/sys/dev/qlxgbe/ql_hw.c +++ b/sys/dev/qlxgbe/ql_hw.c @@ -2566,7 +2566,7 @@ qla_hw_tx_done_locked(qla_host_t *ha, uint32_t txr_idx) comp_count++; if (txb->m_head) { - ha->ifp->if_opackets++; + if_inc_counter(ha->ifp, IFCOUNTER_OPACKETS, 1); bus_dmamap_sync(ha->tx_tag, txb->map, BUS_DMASYNC_POSTWRITE); diff --git a/sys/dev/qlxgbe/ql_isr.c b/sys/dev/qlxgbe/ql_isr.c index c11e9866626f..db0029822927 100644 --- a/sys/dev/qlxgbe/ql_isr.c +++ b/sys/dev/qlxgbe/ql_isr.c @@ -156,7 +156,7 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx) mpf->m_pkthdr.csum_flags = 0; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); mpf->m_pkthdr.flowid = sgc->rss_hash; mpf->m_flags |= M_FLOWID; @@ -326,7 +326,7 @@ qla_lro_intr(qla_host_t *ha, qla_sgl_lro_t *sgc, uint32_t sds_idx) mpf->m_pkthdr.flowid = sgc->rss_hash; mpf->m_flags |= M_FLOWID; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, mpf); diff --git a/sys/dev/qlxge/qls_isr.c b/sys/dev/qlxge/qls_isr.c index 26e431e628db..14b4839be913 100644 --- a/sys/dev/qlxge/qls_isr.c +++ b/sys/dev/qlxge/qls_isr.c @@ -57,7 +57,7 @@ qls_tx_comp(qla_host_t *ha, uint32_t txr_idx, q81_tx_mac_comp_t *tx_comp) txb = &ha->tx_ring[txr_idx].tx_buf[tx_idx]; if (txb->m_head) { - ha->ifp->if_opackets++; + if_inc_counter(ha->ifp, IFCOUNTER_OPACKETS, 1); bus_dmamap_sync(ha->tx_tag, txb->map, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(ha->tx_tag, txb->map); @@ -201,7 +201,7 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e) CSUM_PSEUDO_HDR; mp->m_pkthdr.csum_data = 0xFFFF; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if (lro->lro_cnt && (tcp_lro_rx(lro, mp, 0) == 0)) { /* LRO packet has been successfuly queued */ diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c index 475544d23d6d..02c93103245b 100644 --- a/sys/dev/ral/rt2560.c +++ b/sys/dev/ral/rt2560.c @@ -959,7 +959,7 @@ rt2560_tx_intr(struct rt2560_softc *sc) ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); break; case RT2560_TX_SUCCESS_RETRY: @@ -971,7 +971,7 @@ rt2560_tx_intr(struct rt2560_softc *sc) ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); break; case RT2560_TX_FAIL_RETRY: @@ -983,7 +983,7 @@ rt2560_tx_intr(struct rt2560_softc *sc) ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; case RT2560_TX_FAIL_INVALID: @@ -991,7 +991,7 @@ rt2560_tx_intr(struct rt2560_softc *sc) default: device_printf(sc->sc_dev, "sending data frame failed " "0x%08x\n", flags); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } bus_dmamap_sync(sc->txq.data_dmat, data->map, @@ -1144,13 +1144,13 @@ rt2560_decryption_intr(struct rt2560_softc *sc) break; if (data->drop) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } if ((le32toh(desc->flags) & RT2560_RX_CIPHER_MASK) != 0 && (le32toh(desc->flags) & RT2560_RX_ICV_ERROR)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1163,7 +1163,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc) */ mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (mnew == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1186,7 +1186,7 @@ rt2560_decryption_intr(struct rt2560_softc *sc) panic("%s: could not load old rx mbuf", device_get_name(sc->sc_dev)); } - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1936,7 +1936,7 @@ rt2560_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (rt2560_tx_data(sc, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } @@ -1973,7 +1973,7 @@ rt2560_watchdog(void *arg) if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); rt2560_init_locked(sc); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* NB: callout is reset in rt2560_init() */ return; } @@ -2796,7 +2796,7 @@ rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return ENOBUFS; /* XXX */ } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (params == NULL) { /* @@ -2819,7 +2819,7 @@ rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return 0; bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_free_node(ni); RAL_UNLOCK(sc); return EIO; /* XXX */ diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c index 7b621d7e7ae4..448ba5746bd2 100644 --- a/sys/dev/ral/rt2661.c +++ b/sys/dev/ral/rt2661.c @@ -909,7 +909,7 @@ rt2661_tx_intr(struct rt2661_softc *sc) ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); break; case RT2661_TX_RETRY_FAIL: @@ -921,14 +921,14 @@ rt2661_tx_intr(struct rt2661_softc *sc) ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; default: /* other failure */ device_printf(sc->sc_dev, "sending data frame failed 0x%08x\n", val); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } DPRINTFN(sc, 15, "tx done q=%d idx=%u\n", qid, txq->stat); @@ -1015,12 +1015,12 @@ rt2661_rx_intr(struct rt2661_softc *sc) */ DPRINTFN(sc, 5, "PHY or CRC error flags 0x%08x\n", le32toh(desc->flags)); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } if ((le32toh(desc->flags) & RT2661_RX_CIPHER_MASK) != 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1033,7 +1033,7 @@ rt2661_rx_intr(struct rt2661_softc *sc) */ mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (mnew == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1056,7 +1056,7 @@ rt2661_rx_intr(struct rt2661_softc *sc) panic("%s: could not load old rx mbuf", device_get_name(sc->sc_dev)); } - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1631,7 +1631,7 @@ rt2661_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (rt2661_tx_data(sc, m, ni, ac) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } @@ -1674,7 +1674,7 @@ rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return ENOBUFS; /* XXX */ } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * Legacy path; interpret frame contents to decide @@ -1689,7 +1689,7 @@ rt2661_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return 0; bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_free_node(ni); RAL_UNLOCK(sc); return EIO; /* XXX */ @@ -1711,7 +1711,7 @@ rt2661_watchdog(void *arg) if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); rt2661_init_locked(sc); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* NB: callout is reset in rt2661_init() */ return; } diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c index e37f820d27f3..2e68c2e505ad 100644 --- a/sys/dev/ral/rt2860.c +++ b/sys/dev/ral/rt2860.c @@ -1127,7 +1127,7 @@ rt2860_drain_stats_fifo(struct rt2860_softc *sc) } else { ieee80211_ratectl_tx_complete(ni->ni_vap, ni, IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } } } @@ -1161,7 +1161,7 @@ rt2860_tx_intr(struct rt2860_softc *sc, int qid) SLIST_INSERT_HEAD(&sc->data_pool, data, next); ring->data[ring->next] = NULL; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } ring->queued--; ring->next = (ring->next + 1) % RT2860_TX_RING_COUNT; @@ -1224,7 +1224,7 @@ rt2860_rx_intr(struct rt2860_softc *sc) if (__predict_false(rxd->flags & htole32(RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1233,14 +1233,14 @@ rt2860_rx_intr(struct rt2860_softc *sc) /* report MIC failures to net80211 for TKIP */ ic->ic_stats.is_rx_locmicfail++; ieee80211_michael_mic_failure(ic, 0/* XXX */); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } #endif m1 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (__predict_false(m1 == NULL)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1264,7 +1264,7 @@ rt2860_rx_intr(struct rt2860_softc *sc) } /* physical address may have changed */ rxd->sdp0 = htole32(physaddr); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1744,7 +1744,7 @@ rt2860_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, if (error != 0) { /* NB: m is reclaimed on tx failure */ ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } sc->sc_tx_timer = 5; RAL_UNLOCK(sc); @@ -1997,7 +1997,7 @@ rt2860_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; if (rt2860_tx(sc, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } sc->sc_tx_timer = 5; @@ -2021,7 +2021,7 @@ rt2860_watchdog(void *arg) if_printf(ifp, "device timeout\n"); rt2860_stop_locked(sc); rt2860_init_locked(sc); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } callout_reset(&sc->watchdog_ch, hz, rt2860_watchdog, sc); diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index e7f1361b4967..bb4e6727c9c5 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -148,7 +148,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include MODULE_DEPEND(re, pci, 1, 1, 1); MODULE_DEPEND(re, ether, 1, 1, 1); @@ -2241,7 +2241,7 @@ re_rxeof(struct rl_softc *sc, int *rx_npktsp) (rxstat & RL_RDESC_STAT_ERRS) == RL_RDESC_STAT_GIANT) rxerr = 0; if (rxerr != 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); /* * If this is part of a multi-fragment packet, * discard all the pieces. @@ -2264,7 +2264,7 @@ re_rxeof(struct rl_softc *sc, int *rx_npktsp) else rxerr = re_newbuf(sc, i); if (rxerr != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (sc->rl_head != NULL) { m_freem(sc->rl_head); sc->rl_head = sc->rl_tail = NULL; @@ -2306,7 +2306,7 @@ re_rxeof(struct rl_softc *sc, int *rx_npktsp) #ifdef RE_FIXUP_RX re_fixup_rx(m); #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; /* Do RX checksumming if enabled */ @@ -2425,11 +2425,11 @@ re_txeof(struct rl_softc *sc) txd->tx_m = NULL; if (txstat & (RL_TDESC_STAT_EXCESSCOL| RL_TDESC_STAT_COLCNT)) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (txstat & RL_TDESC_STAT_TXERRSUM) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } sc->rl_ldata.rl_tx_free++; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -3539,7 +3539,7 @@ re_watchdog(struct rl_softc *sc) } if_printf(ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); re_rxeof(sc, NULL); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/pci/if_rl.c b/sys/dev/rl/if_rl.c similarity index 99% rename from sys/pci/if_rl.c rename to sys/dev/rl/if_rl.c index f69866353f2b..9d0d7aa31d94 100644 --- a/sys/pci/if_rl.c +++ b/sys/dev/rl/if_rl.c @@ -127,7 +127,7 @@ MODULE_DEPEND(rl, miibus, 1, 1, 1); /* "device miibus" required. See GENERIC if you get errors here. */ #include "miibus_if.h" -#include +#include /* * Various supported device vendors/types and their names. @@ -1166,7 +1166,7 @@ rl_rxeof(struct rl_softc *sc) if (!(rxstat & RL_RXSTAT_RXOK) || total_len < ETHER_MIN_LEN || total_len > ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; rl_init_locked(sc); return (rx_npkts); @@ -1215,11 +1215,11 @@ rl_rxeof(struct rl_softc *sc) CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16); if (m == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); RL_UNLOCK(sc); (*ifp->if_input)(ifp, m); RL_LOCK(sc); @@ -1254,7 +1254,7 @@ rl_txeof(struct rl_softc *sc) RL_TXSTAT_TX_UNDERRUN|RL_TXSTAT_TXABRT))) break; - ifp->if_collisions += (txstat & RL_TXSTAT_COLLCNT) >> 24; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (txstat & RL_TXSTAT_COLLCNT) >> 24); bus_dmamap_sync(sc->rl_cdata.rl_tx_tag, RL_LAST_DMAMAP(sc), BUS_DMASYNC_POSTWRITE); @@ -1270,10 +1270,10 @@ rl_txeof(struct rl_softc *sc) (sc->rl_txthresh < 2016)) sc->rl_txthresh += 32; if (txstat & RL_TXSTAT_TX_OK) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); else { int oldthresh; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if ((txstat & RL_TXSTAT_TXABRT) || (txstat & RL_TXSTAT_OUTOFWIN)) CSR_WRITE_4(sc, RL_TXCFG, RL_TXCFG_CONFIG); @@ -1897,7 +1897,7 @@ rl_watchdog(struct rl_softc *sc) return; device_printf(sc->rl_dev, "watchdog timeout\n"); - sc->rl_ifp->if_oerrors++; + if_inc_counter(sc->rl_ifp, IFCOUNTER_OERRORS, 1); rl_txeof(sc); rl_rxeof(sc); diff --git a/sys/pci/if_rlreg.h b/sys/dev/rl/if_rlreg.h similarity index 100% rename from sys/pci/if_rlreg.h rename to sys/dev/rl/if_rlreg.h diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c index 3d936b58240f..910276fdc719 100644 --- a/sys/dev/rt/if_rt.c +++ b/sys/dev/rt/if_rt.c @@ -1025,7 +1025,7 @@ rt_start(struct ifnet *ifp) m_freem(m); ifp->if_drv_flags |= IFF_DRV_OACTIVE; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->tx_data_queue_full[qid]++; @@ -1035,7 +1035,7 @@ rt_start(struct ifnet *ifp) if (rt_tx_data(sc, m, qid) != 0) { RT_SOFTC_TX_RING_UNLOCK(&sc->tx_ring[qid]); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } @@ -1152,7 +1152,7 @@ rt_tx_watchdog(void *arg) rt_stop_locked(sc); rt_init_locked(sc); #endif - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->tx_watchdog_timeouts++; } callout_reset(&sc->tx_watchdog_ch, hz, rt_tx_watchdog, sc); @@ -1637,7 +1637,7 @@ rt_rx_eof(struct rt_softc *sc, int limit) MJUMPAGESIZE); if (mnew == NULL) { sc->rx_mbuf_alloc_errors++; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1654,7 +1654,7 @@ rt_rx_eof(struct rt_softc *sc, int limit) m_freem(mnew); sc->rx_mbuf_dmamap_errors++; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto skip; } @@ -1700,7 +1700,7 @@ rt_rx_eof(struct rt_softc *sc, int limit) RT_DPRINTF(sc, RT_DEBUG_RX, "rxdesc: crc error\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (!(ifp->if_flags & IFF_PROMISC)) { m_freem(m); @@ -1785,7 +1785,7 @@ rt_tx_eof(struct rt_softc *sc, struct rt_softc_tx_ring *ring) data->m = NULL; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); RT_SOFTC_TX_RING_LOCK(ring); ring->data_queued--; diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c index 8a4ce2ea55ef..c459dedcc7ce 100644 --- a/sys/dev/sbni/if_sbni.c +++ b/sys/dev/sbni/if_sbni.c @@ -612,7 +612,7 @@ upload_data(struct sbni_softc *sc, u_int framelen, u_int frameno, } else if ((frame_ok = skip_tail(sc, framelen, crc)) != 0) { sc->wait_frameno = 0; sc->inppos = 0; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); /* now skip all frames until is_first != 0 */ } } else @@ -624,7 +624,7 @@ upload_data(struct sbni_softc *sc, u_int framelen, u_int frameno, * is_first already... Drop entire packet. */ sc->wait_frameno = 0; - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } return (frame_ok); @@ -638,7 +638,7 @@ send_complete(struct sbni_softc *sc) { m_freem(sc->tx_buf_p); sc->tx_buf_p = NULL; - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); } @@ -689,7 +689,7 @@ append_frame_to_pkt(struct sbni_softc *sc, u_int framelen, u_int32_t crc) sc->inppos += framelen - 4; if (--sc->wait_frameno == 0) { /* last frame received */ indicate_pkt(sc); - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); } return (1); @@ -755,7 +755,7 @@ drop_xmit_queue(struct sbni_softc *sc) if (sc->tx_buf_p) { m_freem(sc->tx_buf_p); sc->tx_buf_p = NULL; - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); } for (;;) { @@ -763,7 +763,7 @@ drop_xmit_queue(struct sbni_softc *sc) if (m == NULL) break; m_freem(m); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); } sc->tx_frameno = 0; diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index 304813a59db1..d2c43945233b 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -1566,7 +1566,7 @@ sf_rxeof(struct sf_softc *sc) m = rxd->rx_m; /* - * Note, if_ipackets and if_ierrors counters + * Note, IFCOUNTER_IPACKETS and IFCOUNTER_IERRORS * are handled in sf_stats_update(). */ if ((status & SF_RXSTAT1_OK) == 0) { @@ -1575,7 +1575,7 @@ sf_rxeof(struct sf_softc *sc) } if (sf_newbuf(sc, eidx) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); cur_cmp->sf_rx_status1 = 0; continue; } @@ -1720,8 +1720,9 @@ sf_txeof(struct sf_softc *sc) /* * We don't need to check Tx status here. * SF_ISR_TX_LOFIFO intr would handle this. - * Note, if_opackets, if_collisions and if_oerrors - * counters are handled in sf_stats_update(). + * Note, IFCOUNTER_OPACKETS, IFCOUNTER_COLLISIONS + * and IFCOUNTER_OERROR are handled in + * sf_stats_update(). */ txd = &sc->sf_cdata.sf_txdesc[idx]; if (txd->tx_m != NULL) { @@ -2479,23 +2480,26 @@ sf_stats_update(struct sf_softc *sc) for (i = SF_STATS_BASE; i < (SF_STATS_END + 1); i += sizeof(uint32_t)) csr_write_4(sc, i, 0); - ifp->if_opackets += (u_long)stats->sf_tx_frames; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, (u_long)stats->sf_tx_frames); - ifp->if_collisions += (u_long)stats->sf_tx_single_colls + - (u_long)stats->sf_tx_multi_colls; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + (u_long)stats->sf_tx_single_colls + + (u_long)stats->sf_tx_multi_colls); - ifp->if_oerrors += (u_long)stats->sf_tx_excess_colls + + if_inc_counter(ifp, IFCOUNTER_OERRORS, + (u_long)stats->sf_tx_excess_colls + (u_long)stats->sf_tx_excess_defer + - (u_long)stats->sf_tx_frames_lost; + (u_long)stats->sf_tx_frames_lost); - ifp->if_ipackets += (u_long)stats->sf_rx_frames; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, (u_long)stats->sf_rx_frames); - ifp->if_ierrors += (u_long)stats->sf_rx_crcerrs + + if_inc_counter(ifp, IFCOUNTER_IERRORS, + (u_long)stats->sf_rx_crcerrs + (u_long)stats->sf_rx_alignerrs + (u_long)stats->sf_rx_giants + (u_long)stats->sf_rx_runts + (u_long)stats->sf_rx_jabbererrs + - (u_long)stats->sf_rx_frames_lost; + (u_long)stats->sf_rx_frames_lost); nstats = &sc->sf_statistics; @@ -2546,7 +2550,7 @@ sf_watchdog(struct sf_softc *sc) ifp = sc->sf_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (sc->sf_link == 0) { if (bootverbose) if_printf(sc->sf_ifp, "watchdog timeout " diff --git a/sys/dev/sfxge/common/efsys.h b/sys/dev/sfxge/common/efsys.h index 8fd126735b9e..433c40bf91eb 100644 --- a/sys/dev/sfxge/common/efsys.h +++ b/sys/dev/sfxge/common/efsys.h @@ -53,44 +53,44 @@ extern "C" { #define EFSYS_HAS_UINT64 1 #define EFSYS_USE_UINT64 0 #if _BYTE_ORDER == _BIG_ENDIAN -#define EFSYS_IS_BIG_ENDIAN 1 -#define EFSYS_IS_LITTLE_ENDIAN 0 +#define EFSYS_IS_BIG_ENDIAN 1 +#define EFSYS_IS_LITTLE_ENDIAN 0 #elif _BYTE_ORDER == _LITTLE_ENDIAN -#define EFSYS_IS_BIG_ENDIAN 0 -#define EFSYS_IS_LITTLE_ENDIAN 1 +#define EFSYS_IS_BIG_ENDIAN 0 +#define EFSYS_IS_LITTLE_ENDIAN 1 #endif #include "efx_types.h" /* Common code requires this */ #if __FreeBSD_version < 800068 -#define memmove(d, s, l) bcopy(s, d, l) +#define memmove(d, s, l) bcopy(s, d, l) #endif - + /* FreeBSD equivalents of Solaris things */ #ifndef _NOTE -#define _NOTE(s) +#define _NOTE(s) #endif #ifndef B_FALSE -#define B_FALSE FALSE +#define B_FALSE FALSE #endif #ifndef B_TRUE -#define B_TRUE TRUE +#define B_TRUE TRUE #endif #ifndef IS_P2ALIGNED -#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) +#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) #endif #ifndef P2ROUNDUP -#define P2ROUNDUP(x, align) (-(-(x) & -(align))) +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) #endif #ifndef IS2P -#define ISP2(x) (((x) & ((x) - 1)) == 0) +#define ISP2(x) (((x) & ((x) - 1)) == 0) #endif -#define ENOTACTIVE EINVAL +#define ENOTACTIVE EINVAL /* Memory type to use on FreeBSD */ MALLOC_DECLARE(M_SFXGE); @@ -242,7 +242,7 @@ sfxge_map_mbuf_fast(bus_dma_tag_t tag, bus_dmamap_t map, #define EFSYS_OPT_PHY_PROPS 0 #define EFSYS_OPT_PHY_BIST 1 #define EFSYS_OPT_PHY_LED_CONTROL 1 -#define EFSYS_OPT_PHY_FLAGS 0 +#define EFSYS_OPT_PHY_FLAGS 0 #define EFSYS_OPT_VPD 1 #define EFSYS_OPT_NVRAM 1 @@ -256,8 +256,8 @@ sfxge_map_mbuf_fast(bus_dma_tag_t tag, bus_dmamap_t map, #define EFSYS_OPT_WOL 1 #define EFSYS_OPT_RX_SCALE 1 #define EFSYS_OPT_QSTATS 1 -#define EFSYS_OPT_FILTER 0 -#define EFSYS_OPT_RX_SCATTER 0 +#define EFSYS_OPT_FILTER 0 +#define EFSYS_OPT_RX_SCATTER 0 #define EFSYS_OPT_RX_HDR_SPLIT 0 #define EFSYS_OPT_EV_PREFETCH 0 @@ -272,7 +272,7 @@ typedef struct __efsys_identifier_s efsys_identifier_t; #ifndef DTRACE_PROBE -#define EFSYS_PROBE(_name) +#define EFSYS_PROBE(_name) #define EFSYS_PROBE1(_name, _type1, _arg1) @@ -815,16 +815,16 @@ extern void sfxge_err(efsys_identifier_t *, unsigned int, panic(#_exp); \ } while (0) -#define EFSYS_ASSERT3(_x, _op, _y, _t) do { \ +#define EFSYS_ASSERT3(_x, _op, _y, _t) do { \ const _t __x = (_t)(_x); \ const _t __y = (_t)(_y); \ if (!(__x _op __y)) \ - panic("assertion failed at %s:%u", __FILE__, __LINE__); \ + panic("assertion failed at %s:%u", __FILE__, __LINE__); \ } while(0) -#define EFSYS_ASSERT3U(_x, _op, _y) EFSYS_ASSERT3(_x, _op, _y, uint64_t) -#define EFSYS_ASSERT3S(_x, _op, _y) EFSYS_ASSERT3(_x, _op, _y, int64_t) -#define EFSYS_ASSERT3P(_x, _op, _y) EFSYS_ASSERT3(_x, _op, _y, uintptr_t) +#define EFSYS_ASSERT3U(_x, _op, _y) EFSYS_ASSERT3(_x, _op, _y, uint64_t) +#define EFSYS_ASSERT3S(_x, _op, _y) EFSYS_ASSERT3(_x, _op, _y, int64_t) +#define EFSYS_ASSERT3P(_x, _op, _y) EFSYS_ASSERT3(_x, _op, _y, uintptr_t) #ifdef __cplusplus } diff --git a/sys/dev/sfxge/sfxge.c b/sys/dev/sfxge/sfxge.c index 8f2c7bbc299a..c0850ec40f23 100644 --- a/sys/dev/sfxge/sfxge.c +++ b/sys/dev/sfxge/sfxge.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -57,16 +58,35 @@ __FBSDID("$FreeBSD$"); #include "sfxge.h" #include "sfxge_rx.h" -#define SFXGE_CAP (IFCAP_VLAN_MTU | \ +#define SFXGE_CAP (IFCAP_VLAN_MTU | \ IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | IFCAP_TSO | \ IFCAP_JUMBO_MTU | IFCAP_LRO | \ IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE) -#define SFXGE_CAP_ENABLE SFXGE_CAP -#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \ +#define SFXGE_CAP_ENABLE SFXGE_CAP +#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \ IFCAP_JUMBO_MTU | IFCAP_LINKSTATE) MALLOC_DEFINE(M_SFXGE, "sfxge", "Solarflare 10GigE driver"); + +SYSCTL_NODE(_hw, OID_AUTO, sfxge, CTLFLAG_RD, 0, + "SFXGE driver parameters"); + +#define SFXGE_PARAM_RX_RING SFXGE_PARAM(rx_ring) +static int sfxge_rx_ring_entries = SFXGE_NDESCS; +TUNABLE_INT(SFXGE_PARAM_RX_RING, &sfxge_rx_ring_entries); +SYSCTL_INT(_hw_sfxge, OID_AUTO, rx_ring, CTLFLAG_RDTUN, + &sfxge_rx_ring_entries, 0, + "Maximum number of descriptors in a receive ring"); + +#define SFXGE_PARAM_TX_RING SFXGE_PARAM(tx_ring) +static int sfxge_tx_ring_entries = SFXGE_NDESCS; +TUNABLE_INT(SFXGE_PARAM_TX_RING, &sfxge_tx_ring_entries); +SYSCTL_INT(_hw_sfxge, OID_AUTO, tx_ring, CTLFLAG_RDTUN, + &sfxge_tx_ring_entries, 0, + "Maximum number of descriptors in a transmit ring"); + + static void sfxge_reset(void *arg, int npending); @@ -78,7 +98,7 @@ sfxge_start(struct sfxge_softc *sc) sx_assert(&sc->softc_lock, LA_XLOCKED); if (sc->init_state == SFXGE_STARTED) - return 0; + return (0); if (sc->init_state != SFXGE_REGISTERED) { rc = EINVAL; @@ -223,7 +243,7 @@ sfxge_if_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data) ifp->if_mtu = ifr->ifr_mtu; error = sfxge_start(sc); sx_xunlock(&sc->softc_lock); - if (error) { + if (error != 0) { ifp->if_flags &= ~IFF_UP; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; if_down(ifp); @@ -287,7 +307,7 @@ sfxge_ifnet_fini(struct ifnet *ifp) if_free(ifp); } -static int +static int sfxge_ifnet_init(struct ifnet *ifp, struct sfxge_softc *sc) { const efx_nic_cfg_t *encp = efx_nic_cfg_get(sc->enp); @@ -314,8 +334,8 @@ sfxge_ifnet_init(struct ifnet *ifp, struct sfxge_softc *sc) ifp->if_qflush = sfxge_if_qflush; #else ifp->if_start = sfxge_if_start; - IFQ_SET_MAXLEN(&ifp->if_snd, SFXGE_NDESCS - 1); - ifp->if_snd.ifq_drv_maxlen = SFXGE_NDESCS - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, sc->txq_entries - 1); + ifp->if_snd.ifq_drv_maxlen = sc->txq_entries - 1; IFQ_SET_READY(&ifp->if_snd); mtx_init(&sc->tx_lock, "txq", NULL, MTX_DEF); @@ -324,11 +344,11 @@ sfxge_ifnet_init(struct ifnet *ifp, struct sfxge_softc *sc) if ((rc = sfxge_port_ifmedia_init(sc)) != 0) goto fail; - return 0; + return (0); fail: ether_ifdetach(sc->ifnet); - return rc; + return (rc); } void @@ -347,7 +367,7 @@ sfxge_bar_init(struct sfxge_softc *sc) { efsys_bar_t *esbp = &sc->bar; - esbp->esb_rid = PCIR_BAR(EFX_MEM_BAR); + esbp->esb_rid = PCIR_BAR(EFX_MEM_BAR); if ((esbp->esb_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, &esbp->esb_rid, RF_ACTIVE)) == NULL) { device_printf(sc->dev, "Cannot allocate BAR region %d\n", @@ -386,7 +406,7 @@ sfxge_create(struct sfxge_softc *sc) device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "stats", CTLFLAG_RD, NULL, "Statistics"); - if (!sc->stats_node) { + if (sc->stats_node == NULL) { error = ENOMEM; goto fail; } @@ -414,6 +434,26 @@ sfxge_create(struct sfxge_softc *sc) goto fail3; sc->enp = enp; + if (!ISP2(sfxge_rx_ring_entries) || + !(sfxge_rx_ring_entries & EFX_RXQ_NDESCS_MASK)) { + log(LOG_ERR, "%s=%d must be power of 2 from %u to %u", + SFXGE_PARAM_RX_RING, sfxge_rx_ring_entries, + EFX_RXQ_MINNDESCS, EFX_RXQ_MAXNDESCS); + error = EINVAL; + goto fail_rx_ring_entries; + } + sc->rxq_entries = sfxge_rx_ring_entries; + + if (!ISP2(sfxge_tx_ring_entries) || + !(sfxge_tx_ring_entries & EFX_TXQ_NDESCS_MASK)) { + log(LOG_ERR, "%s=%d must be power of 2 from %u to %u", + SFXGE_PARAM_TX_RING, sfxge_tx_ring_entries, + EFX_TXQ_MINNDESCS, EFX_TXQ_MAXNDESCS); + error = EINVAL; + goto fail_tx_ring_entries; + } + sc->txq_entries = sfxge_tx_ring_entries; + /* Initialize MCDI to talk to the microcontroller. */ if ((error = sfxge_mcdi_init(sc)) != 0) goto fail4; @@ -486,6 +526,8 @@ sfxge_create(struct sfxge_softc *sc) sfxge_mcdi_fini(sc); fail4: +fail_tx_ring_entries: +fail_rx_ring_entries: sc->enp = NULL; efx_nic_destroy(enp); mtx_destroy(&sc->enp_lock); @@ -554,14 +596,14 @@ sfxge_vpd_handler(SYSCTL_HANDLER_ARGS) struct sfxge_softc *sc = arg1; efx_vpd_value_t value; int rc; - + value.evv_tag = arg2 >> 16; value.evv_keyword = arg2 & 0xffff; if ((rc = efx_vpd_get(sc->enp, sc->vpd_data, sc->vpd_size, &value)) != 0) - return rc; + return (rc); - return SYSCTL_OUT(req, value.evv_value, value.evv_length); + return (SYSCTL_OUT(req, value.evv_value, value.evv_length)); } static void @@ -623,12 +665,12 @@ sfxge_vpd_init(struct sfxge_softc *sc) for (keyword[1] = 'A'; keyword[1] <= 'Z'; keyword[1]++) sfxge_vpd_try_add(sc, vpd_list, EFX_VPD_RO, keyword); - return 0; - + return (0); + fail2: free(sc->vpd_data, M_SFXGE); fail: - return rc; + return (rc); } static void @@ -745,12 +787,12 @@ sfxge_probe(device_t dev) pci_device_id = pci_get_device(dev); rc = efx_family(pci_vendor_id, pci_device_id, &family); - if (rc) - return ENXIO; + if (rc != 0) + return (ENXIO); KASSERT(family == EFX_FAMILY_SIENA, ("impossible controller family")); device_set_desc(dev, "Solarflare SFC9000 family"); - return 0; + return (0); } static device_method_t sfxge_methods[] = { diff --git a/sys/dev/sfxge/sfxge.h b/sys/dev/sfxge/sfxge.h index d73d15019bf8..69b062ab817d 100644 --- a/sys/dev/sfxge/sfxge.h +++ b/sys/dev/sfxge/sfxge.h @@ -30,7 +30,7 @@ */ #ifndef _SFXGE_H -#define _SFXGE_H +#define _SFXGE_H #include #include @@ -53,43 +53,45 @@ /* This should be right on most machines the driver will be used on, and * we needn't care too much about wasting a few KB per interface. */ -#define CACHE_LINE_SIZE 128 +#define CACHE_LINE_SIZE 128 #endif #ifndef IFCAP_LINKSTATE -#define IFCAP_LINKSTATE 0 +#define IFCAP_LINKSTATE 0 #endif #ifndef IFCAP_VLAN_HWTSO -#define IFCAP_VLAN_HWTSO 0 +#define IFCAP_VLAN_HWTSO 0 #endif #ifndef IFM_10G_T -#define IFM_10G_T IFM_UNKNOWN +#define IFM_10G_T IFM_UNKNOWN #endif #ifndef IFM_10G_KX4 -#define IFM_10G_KX4 IFM_10G_CX4 +#define IFM_10G_KX4 IFM_10G_CX4 #endif #if __FreeBSD_version >= 800054 /* Networking core is multiqueue aware. We can manage our own TX * queues and use m_pkthdr.flowid. */ -#define SFXGE_HAVE_MQ +#define SFXGE_HAVE_MQ #endif #if (__FreeBSD_version >= 800501 && __FreeBSD_version < 900000) || \ __FreeBSD_version >= 900003 -#define SFXGE_HAVE_DESCRIBE_INTR +#define SFXGE_HAVE_DESCRIBE_INTR #endif #ifdef IFM_ETH_RXPAUSE -#define SFXGE_HAVE_PAUSE_MEDIAOPTS +#define SFXGE_HAVE_PAUSE_MEDIAOPTS #endif #ifndef CTLTYPE_U64 -#define CTLTYPE_U64 CTLTYPE_QUAD +#define CTLTYPE_U64 CTLTYPE_QUAD #endif #include "sfxge_rx.h" #include "sfxge_tx.h" -#define SFXGE_IP_ALIGN 2 +#define ROUNDUP_POW_OF_TWO(_n) (1ULL << flsl((_n) - 1)) -#define SFXGE_ETHERTYPE_LOOPBACK 0x9000 /* Xerox loopback */ +#define SFXGE_IP_ALIGN 2 + +#define SFXGE_ETHERTYPE_LOOPBACK 0x9000 /* Xerox loopback */ enum sfxge_evq_state { SFXGE_EVQ_UNINITIALIZED = 0, @@ -106,6 +108,7 @@ struct sfxge_evq { enum sfxge_evq_state init_state; unsigned int index; + unsigned int entries; efsys_mem_t mem; unsigned int buf_base_id; @@ -121,7 +124,6 @@ struct sfxge_evq { struct sfxge_txq **txqs; }; -#define SFXGE_NEVS 4096 #define SFXGE_NDESCS 1024 #define SFXGE_MODERATION 30 @@ -133,9 +135,9 @@ enum sfxge_intr_state { }; struct sfxge_intr_hdl { - int eih_rid; - void *eih_tag; - struct resource *eih_res; + int eih_rid; + void *eih_tag; + struct resource *eih_res; }; struct sfxge_intr { @@ -197,9 +199,10 @@ struct sfxge_softc { device_t dev; struct sx softc_lock; enum sfxge_softc_state init_state; - struct ifnet *ifnet; + struct ifnet *ifnet; unsigned int if_flags; struct sysctl_oid *stats_node; + struct sysctl_oid *txqs_node; struct task task_reset; @@ -209,7 +212,10 @@ struct sfxge_softc { efx_nic_t *enp; struct mtx enp_lock; - bus_dma_tag_t parent_dma_tag; + unsigned int rxq_entries; + unsigned int txq_entries; + + bus_dma_tag_t parent_dma_tag; efsys_bar_t bar; struct sfxge_intr intr; @@ -243,8 +249,12 @@ struct sfxge_softc { #endif }; -#define SFXGE_LINK_UP(sc) ((sc)->port.link_mode != EFX_LINK_DOWN) -#define SFXGE_RUNNING(sc) ((sc)->ifnet->if_drv_flags & IFF_DRV_RUNNING) +#define SFXGE_LINK_UP(sc) ((sc)->port.link_mode != EFX_LINK_DOWN) +#define SFXGE_RUNNING(sc) ((sc)->ifnet->if_drv_flags & IFF_DRV_RUNNING) + +#define SFXGE_PARAM(_name) "hw.sfxge." #_name + +SYSCTL_DECL(_hw_sfxge); /* * From sfxge.c. @@ -299,6 +309,6 @@ extern void sfxge_mac_link_update(struct sfxge_softc *sc, extern int sfxge_mac_filter_set(struct sfxge_softc *sc); extern int sfxge_port_ifmedia_init(struct sfxge_softc *sc); -#define SFXGE_MAX_MTU (9 * 1024) +#define SFXGE_MAX_MTU (9 * 1024) #endif /* _SFXGE_H */ diff --git a/sys/dev/sfxge/sfxge_dma.c b/sys/dev/sfxge/sfxge_dma.c index 48d02d56192e..e2bf171e35d8 100644 --- a/sys/dev/sfxge/sfxge_dma.c +++ b/sys/dev/sfxge/sfxge_dma.c @@ -50,7 +50,7 @@ sfxge_dma_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) addr = arg; - if (error) { + if (error != 0) { *addr = 0; return; } @@ -82,7 +82,7 @@ sfxge_dma_map_sg_collapse(bus_dma_tag_t tag, bus_dmamap_t map, return (0); } #if defined(__i386__) || defined(__amd64__) - while (m && seg_count < maxsegs) { + while (m != NULL && seg_count < maxsegs) { /* * firmware doesn't like empty segments */ @@ -164,11 +164,14 @@ sfxge_dma_alloc(struct sfxge_softc *sc, bus_size_t len, efsys_mem_t *esmp) /* * The callback gets error information about the mapping - * and will have set our vaddr to NULL if something went + * and will have set esm_addr to 0 if something went * wrong. */ - if (vaddr == NULL) + if (esmp->esm_addr == 0) { + bus_dmamem_free(esmp->esm_tag, esmp->esm_base, esmp->esm_map); + bus_dma_tag_destroy(esmp->esm_tag); return (ENOMEM); + } esmp->esm_base = vaddr; @@ -197,7 +200,7 @@ sfxge_dma_init(struct sfxge_softc *sc) BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ NULL, NULL, /* lock, lockarg */ - &sc->parent_dma_tag)) { + &sc->parent_dma_tag) != 0) { device_printf(sc->dev, "Cannot allocate parent DMA tag\n"); return (ENOMEM); } diff --git a/sys/dev/sfxge/sfxge_ev.c b/sys/dev/sfxge/sfxge_ev.c index 77f0a7460c5b..7c0aa7fdf61d 100644 --- a/sys/dev/sfxge/sfxge_ev.c +++ b/sys/dev/sfxge/sfxge_ev.c @@ -102,7 +102,7 @@ sfxge_ev_rx(void *arg, uint32_t label, uint32_t id, uint32_t size, if (rxq->init_state != SFXGE_RXQ_STARTED) goto done; - expected = rxq->pending++ & (SFXGE_NDESCS - 1); + expected = rxq->pending++ & rxq->ptr_mask; if (id != expected) { evq->exception = B_TRUE; @@ -226,7 +226,7 @@ sfxge_get_txq_by_label(struct sfxge_evq *evq, enum sfxge_txq_type label) KASSERT((evq->index == 0 && label < SFXGE_TXQ_NTYPES) || (label == SFXGE_TXQ_IP_TCP_UDP_CKSUM), ("unexpected txq label")); index = (evq->index == 0) ? label : (evq->index - 1 + SFXGE_TXQ_NTYPES); - return evq->sc->txq[index]; + return (evq->sc->txq[index]); } static boolean_t @@ -247,10 +247,10 @@ sfxge_ev_tx(void *arg, uint32_t label, uint32_t id) if (txq->init_state != SFXGE_TXQ_STARTED) goto done; - stop = (id + 1) & (SFXGE_NDESCS - 1); - id = txq->pending & (SFXGE_NDESCS - 1); + stop = (id + 1) & txq->ptr_mask; + id = txq->pending & txq->ptr_mask; - delta = (stop >= id) ? (stop - id) : (SFXGE_NDESCS - id + stop); + delta = (stop >= id) ? (stop - id) : (txq->entries - id + stop); txq->pending += delta; evq->tx_done++; @@ -443,7 +443,7 @@ sfxge_ev_stat_handler(SYSCTL_HANDLER_ARGS) sfxge_ev_stat_update(sc); - return SYSCTL_OUT(req, &sc->ev_stats[id], sizeof(sc->ev_stats[id])); + return (SYSCTL_OUT(req, &sc->ev_stats[id], sizeof(sc->ev_stats[id]))); } static void @@ -493,7 +493,7 @@ sfxge_int_mod_handler(SYSCTL_HANDLER_ARGS) sx_xlock(&sc->softc_lock); - if (req->newptr) { + if (req->newptr != NULL) { if ((error = SYSCTL_IN(req, &moderation, sizeof(moderation))) != 0) goto out; @@ -520,14 +520,14 @@ sfxge_int_mod_handler(SYSCTL_HANDLER_ARGS) out: sx_xunlock(&sc->softc_lock); - return error; + return (error); } static boolean_t sfxge_ev_initialized(void *arg) { struct sfxge_evq *evq; - + evq = (struct sfxge_evq *)arg; KASSERT(evq->init_state == SFXGE_EVQ_STARTING, @@ -635,7 +635,7 @@ sfxge_ev_qstop(struct sfxge_softc *sc, unsigned int index) efx_ev_qdestroy(evq->common); efx_sram_buf_tbl_clear(sc->enp, evq->buf_base_id, - EFX_EVQ_NBUFS(SFXGE_NEVS)); + EFX_EVQ_NBUFS(evq->entries)); mtx_unlock(&evq->lock); } @@ -654,15 +654,15 @@ sfxge_ev_qstart(struct sfxge_softc *sc, unsigned int index) ("evq->init_state != SFXGE_EVQ_INITIALIZED")); /* Clear all events. */ - (void)memset(esmp->esm_base, 0xff, EFX_EVQ_SIZE(SFXGE_NEVS)); + (void)memset(esmp->esm_base, 0xff, EFX_EVQ_SIZE(evq->entries)); /* Program the buffer table. */ if ((rc = efx_sram_buf_tbl_set(sc->enp, evq->buf_base_id, esmp, - EFX_EVQ_NBUFS(SFXGE_NEVS))) != 0) - return rc; + EFX_EVQ_NBUFS(evq->entries))) != 0) + return (rc); /* Create the common code event queue. */ - if ((rc = efx_ev_qcreate(sc->enp, index, esmp, SFXGE_NEVS, + if ((rc = efx_ev_qcreate(sc->enp, index, esmp, evq->entries, evq->buf_base_id, &evq->common)) != 0) goto fail; @@ -705,7 +705,7 @@ sfxge_ev_qstart(struct sfxge_softc *sc, unsigned int index) efx_ev_qdestroy(evq->common); fail: efx_sram_buf_tbl_clear(sc->enp, evq->buf_base_id, - EFX_EVQ_NBUFS(SFXGE_NEVS)); + EFX_EVQ_NBUFS(evq->entries)); return (rc); } @@ -746,7 +746,7 @@ sfxge_ev_start(struct sfxge_softc *sc) /* Initialize the event module */ if ((rc = efx_ev_init(sc->enp)) != 0) - return rc; + return (rc); /* Start the event queues */ for (index = 0; index < intr->n_alloc; index++) { @@ -802,15 +802,31 @@ sfxge_ev_qinit(struct sfxge_softc *sc, unsigned int index) sc->evq[index] = evq; esmp = &evq->mem; + /* Build an event queue with room for one event per tx and rx buffer, + * plus some extra for link state events and MCDI completions. + * There are three tx queues in the first event queue and one in + * other. + */ + if (index == 0) + evq->entries = + ROUNDUP_POW_OF_TWO(sc->rxq_entries + + 3 * sc->txq_entries + + 128); + else + evq->entries = + ROUNDUP_POW_OF_TWO(sc->rxq_entries + + sc->txq_entries + + 128); + /* Initialise TX completion list */ evq->txqs = &evq->txq; /* Allocate DMA space. */ - if ((rc = sfxge_dma_alloc(sc, EFX_EVQ_SIZE(SFXGE_NEVS), esmp)) != 0) + if ((rc = sfxge_dma_alloc(sc, EFX_EVQ_SIZE(evq->entries), esmp)) != 0) return (rc); /* Allocate buffer table entries. */ - sfxge_sram_buf_tbl_alloc(sc, EFX_EVQ_NBUFS(SFXGE_NEVS), + sfxge_sram_buf_tbl_alloc(sc, EFX_EVQ_NBUFS(evq->entries), &evq->buf_base_id); mtx_init(&evq->lock, "evq", NULL, MTX_DEF); diff --git a/sys/dev/sfxge/sfxge_intr.c b/sys/dev/sfxge/sfxge_intr.c index 17f5fcd47dbf..2f40603b1d0e 100644 --- a/sys/dev/sfxge/sfxge_intr.c +++ b/sys/dev/sfxge/sfxge_intr.c @@ -70,19 +70,19 @@ sfxge_intr_line_filter(void *arg) ("intr->type != EFX_INTR_LINE")); if (intr->state != SFXGE_INTR_STARTED) - return FILTER_STRAY; + return (FILTER_STRAY); (void)efx_intr_status_line(enp, &fatal, &qmask); if (fatal) { (void) efx_intr_disable(enp); (void) efx_intr_fatal(enp); - return FILTER_HANDLED; + return (FILTER_HANDLED); } if (qmask != 0) { intr->zero_count = 0; - return FILTER_SCHEDULE_THREAD; + return (FILTER_SCHEDULE_THREAD); } /* SF bug 15783: If the function is not asserting its IRQ and @@ -97,13 +97,13 @@ sfxge_intr_line_filter(void *arg) if (intr->zero_count++ == 0) { if (evq->init_state == SFXGE_EVQ_STARTED) { if (efx_ev_qpending(evq->common, evq->read_ptr)) - return FILTER_SCHEDULE_THREAD; + return (FILTER_SCHEDULE_THREAD); efx_ev_qprime(evq->common, evq->read_ptr); - return FILTER_HANDLED; + return (FILTER_HANDLED); } } - return FILTER_STRAY; + return (FILTER_STRAY); } static void @@ -175,7 +175,7 @@ sfxge_intr_bus_enable(struct sfxge_softc *sc) default: KASSERT(0, ("Invalid interrupt type")); - return EINVAL; + return (EINVAL); } /* Try to add the handlers */ @@ -254,7 +254,7 @@ sfxge_intr_alloc(struct sfxge_softc *sc, int count) table[i].eih_res = res; } - if (error) { + if (error != 0) { count = i - 1; for (i = 0; i < count; i++) bus_release_resource(dev, SYS_RES_IRQ, @@ -349,7 +349,7 @@ sfxge_intr_setup_msi(struct sfxge_softc *sc) if (count == 0) return (EINVAL); - if ((error = pci_alloc_msi(dev, &count)) != 0) + if ((error = pci_alloc_msi(dev, &count)) != 0) return (ENOMEM); /* Allocate interrupt handler. */ @@ -424,7 +424,7 @@ void sfxge_intr_stop(struct sfxge_softc *sc) { struct sfxge_intr *intr; - + intr = &sc->intr; KASSERT(intr->state == SFXGE_INTR_STARTED, diff --git a/sys/dev/sfxge/sfxge_port.c b/sys/dev/sfxge/sfxge_port.c index abd2924f2cd4..6e28d7cac13c 100644 --- a/sys/dev/sfxge/sfxge_port.c +++ b/sys/dev/sfxge/sfxge_port.c @@ -74,7 +74,7 @@ sfxge_mac_stat_update(struct sfxge_softc *sc) /* Try to update the cached counters */ if ((rc = efx_mac_stats_update(sc->enp, esmp, - port->mac_stats.decode_buf, NULL)) != EAGAIN) + port->mac_stats.decode_buf, NULL)) != EAGAIN) goto out; DELAY(100); @@ -83,7 +83,7 @@ sfxge_mac_stat_update(struct sfxge_softc *sc) rc = ETIMEDOUT; out: mtx_unlock(&port->lock); - return rc; + return (rc); } static int @@ -94,11 +94,11 @@ sfxge_mac_stat_handler(SYSCTL_HANDLER_ARGS) int rc; if ((rc = sfxge_mac_stat_update(sc)) != 0) - return rc; + return (rc); - return SYSCTL_OUT(req, + return (SYSCTL_OUT(req, (uint64_t *)sc->port.mac_stats.decode_buf + id, - sizeof(uint64_t)); + sizeof(uint64_t))); } static void @@ -130,9 +130,9 @@ sfxge_port_wanted_fc(struct sfxge_softc *sc) struct ifmedia_entry *ifm = sc->media.ifm_cur; if (ifm->ifm_media == (IFM_ETHER | IFM_AUTO)) - return EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE; - return ((ifm->ifm_media & IFM_ETH_RXPAUSE) ? EFX_FCNTL_RESPOND : 0) | - ((ifm->ifm_media & IFM_ETH_TXPAUSE) ? EFX_FCNTL_GENERATE : 0); + return (EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE); + return (((ifm->ifm_media & IFM_ETH_RXPAUSE) ? EFX_FCNTL_RESPOND : 0) | + ((ifm->ifm_media & IFM_ETH_TXPAUSE) ? EFX_FCNTL_GENERATE : 0)); } static unsigned int @@ -150,13 +150,13 @@ sfxge_port_link_fc_ifm(struct sfxge_softc *sc) static unsigned int sfxge_port_wanted_fc(struct sfxge_softc *sc) { - return sc->port.wanted_fc; + return (sc->port.wanted_fc); } static unsigned int sfxge_port_link_fc_ifm(struct sfxge_softc *sc) { - return 0; + return (0); } static int @@ -172,7 +172,7 @@ sfxge_port_wanted_fc_handler(SYSCTL_HANDLER_ARGS) mtx_lock(&port->lock); - if (req->newptr) { + if (req->newptr != NULL) { if ((error = SYSCTL_IN(req, &fcntl, sizeof(fcntl))) != 0) goto out; @@ -220,14 +220,14 @@ sfxge_port_link_fc_handler(SYSCTL_HANDLER_ARGS) #endif /* SFXGE_HAVE_PAUSE_MEDIAOPTS */ -static const u_long sfxge_link_baudrate[EFX_LINK_NMODES] = { +static const uint64_t sfxge_link_baudrate[EFX_LINK_NMODES] = { [EFX_LINK_10HDX] = IF_Mbps(10), [EFX_LINK_10FDX] = IF_Mbps(10), [EFX_LINK_100HDX] = IF_Mbps(100), [EFX_LINK_100FDX] = IF_Mbps(100), [EFX_LINK_1000HDX] = IF_Gbps(1), [EFX_LINK_1000FDX] = IF_Gbps(1), - [EFX_LINK_10000FDX] = MIN(IF_Gbps(10ULL), ULONG_MAX), + [EFX_LINK_10000FDX] = IF_Gbps(10), }; void @@ -235,7 +235,7 @@ sfxge_mac_link_update(struct sfxge_softc *sc, efx_link_mode_t mode) { struct sfxge_port *port; int link_state; - + port = &sc->port; if (port->link_mode == mode) @@ -289,7 +289,7 @@ sfxge_mac_filter_set_locked(struct sfxge_softc *sc) /* Set promisc-unicast and broadcast filter bits */ if ((rc = efx_mac_filter_set(enp, !!(ifp->if_flags & IFF_PROMISC), B_TRUE)) != 0) - return rc; + return (rc); /* Set multicast hash filter */ if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) { @@ -311,7 +311,7 @@ sfxge_mac_filter_set_locked(struct sfxge_softc *sc) } if_maddr_runlock(ifp); } - return efx_mac_hash_set(enp, bucket); + return (efx_mac_hash_set(enp, bucket)); } int @@ -336,7 +336,7 @@ sfxge_mac_filter_set(struct sfxge_softc *sc) else rc = 0; mtx_unlock(&port->lock); - return rc; + return (rc); } void @@ -413,7 +413,7 @@ sfxge_port_start(struct sfxge_softc *sc) /* Update MAC stats by DMA every second */ if ((rc = efx_mac_stats_periodic(enp, &port->mac_stats.dma_buf, - 1000, B_FALSE)) != 0) + 1000, B_FALSE)) != 0) goto fail2; if ((rc = efx_mac_drain(enp, B_FALSE)) != 0) @@ -435,7 +435,7 @@ sfxge_port_start(struct sfxge_softc *sc) (void)efx_mac_drain(enp, B_TRUE); fail3: (void)efx_mac_stats_periodic(enp, &port->mac_stats.dma_buf, - 0, B_FALSE); + 0, B_FALSE); fail2: efx_port_fini(sc->enp); fail: @@ -488,7 +488,7 @@ sfxge_phy_stat_update(struct sfxge_softc *sc) rc = ETIMEDOUT; out: mtx_unlock(&port->lock); - return rc; + return (rc); } static int @@ -499,11 +499,11 @@ sfxge_phy_stat_handler(SYSCTL_HANDLER_ARGS) int rc; if ((rc = sfxge_phy_stat_update(sc)) != 0) - return rc; + return (rc); - return SYSCTL_OUT(req, + return (SYSCTL_OUT(req, (uint32_t *)sc->port.phy_stats.decode_buf + id, - sizeof(uint32_t)); + sizeof(uint32_t))); } static void @@ -619,7 +619,7 @@ sfxge_port_init(struct sfxge_softc *sc) free(port->phy_stats.decode_buf, M_SFXGE); (void)mtx_destroy(&port->lock); port->sc = NULL; - return rc; + return (rc); } static int sfxge_link_mode[EFX_PHY_MEDIA_NTYPES][EFX_LINK_NMODES] = { @@ -697,9 +697,9 @@ sfxge_media_change(struct ifnet *ifp) rc = efx_phy_adv_cap_set(sc->enp, ifm->ifm_data); out: - sx_xunlock(&sc->softc_lock); + sx_xunlock(&sc->softc_lock); - return rc; + return (rc); } int sfxge_port_ifmedia_init(struct sfxge_softc *sc) @@ -788,7 +788,7 @@ int sfxge_port_ifmedia_init(struct sfxge_softc *sc) best_mode_ifm = mode_ifm; } - if (best_mode_ifm) + if (best_mode_ifm != 0) ifmedia_set(&sc->media, best_mode_ifm); /* Now discard port state until interface is started. */ @@ -796,5 +796,5 @@ int sfxge_port_ifmedia_init(struct sfxge_softc *sc) out2: efx_nic_fini(sc->enp); out: - return rc; + return (rc); } diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c index 7209c382edea..66083d832857 100644 --- a/sys/dev/sfxge/sfxge_rx.c +++ b/sys/dev/sfxge/sfxge_rx.c @@ -54,8 +54,7 @@ __FBSDID("$FreeBSD$"); #include "sfxge.h" #include "sfxge_rx.h" -#define RX_REFILL_THRESHOLD (EFX_RXQ_LIMIT(SFXGE_NDESCS) * 9 / 10) -#define RX_REFILL_THRESHOLD_2 (RX_REFILL_THRESHOLD / 2) +#define RX_REFILL_THRESHOLD(_entries) (EFX_RXQ_LIMIT(_entries) * 9 / 10) /* Size of the LRO hash table. Must be a power of 2. A larger table * means we can accelerate a larger number of streams. @@ -87,10 +86,10 @@ static int lro_slow_start_packets = 2000; static int lro_loss_packets = 20; /* Flags for sfxge_lro_conn::l2_id; must not collide with EVL_VLID_MASK */ -#define SFXGE_LRO_L2_ID_VLAN 0x4000 -#define SFXGE_LRO_L2_ID_IPV6 0x8000 -#define SFXGE_LRO_CONN_IS_VLAN_ENCAP(c) ((c)->l2_id & SFXGE_LRO_L2_ID_VLAN) -#define SFXGE_LRO_CONN_IS_TCPIPV4(c) (!((c)->l2_id & SFXGE_LRO_L2_ID_IPV6)) +#define SFXGE_LRO_L2_ID_VLAN 0x4000 +#define SFXGE_LRO_L2_ID_IPV6 0x8000 +#define SFXGE_LRO_CONN_IS_VLAN_ENCAP(c) ((c)->l2_id & SFXGE_LRO_L2_ID_VLAN) +#define SFXGE_LRO_CONN_IS_TCPIPV4(c) (!((c)->l2_id & SFXGE_LRO_L2_ID_IPV6)) /* Compare IPv6 addresses, avoiding conditional branches */ static __inline unsigned long ipv6_addr_cmp(const struct in6_addr *left, @@ -179,12 +178,12 @@ static inline struct mbuf *sfxge_rx_alloc_mbuf(struct sfxge_softc *sc) m = (struct mbuf *)uma_zalloc_arg(zone_mbuf, &args, M_NOWAIT); /* Allocate (and attach) packet buffer */ - if (m && !uma_zalloc_arg(sc->rx_buffer_zone, m, M_NOWAIT)) { + if (m != NULL && !uma_zalloc_arg(sc->rx_buffer_zone, m, M_NOWAIT)) { uma_zfree(zone_mbuf, m); m = NULL; } - return m; + return (m); } #define SFXGE_REFILL_BATCH 64 @@ -214,11 +213,11 @@ sfxge_rx_qfill(struct sfxge_rxq *rxq, unsigned int target, boolean_t retrying) return; rxfill = rxq->added - rxq->completed; - KASSERT(rxfill <= EFX_RXQ_LIMIT(SFXGE_NDESCS), - ("rxfill > EFX_RXQ_LIMIT(SFXGE_NDESCS)")); - ntodo = min(EFX_RXQ_LIMIT(SFXGE_NDESCS) - rxfill, target); - KASSERT(ntodo <= EFX_RXQ_LIMIT(SFXGE_NDESCS), - ("ntodo > EFX_RQX_LIMIT(SFXGE_NDESCS)")); + KASSERT(rxfill <= EFX_RXQ_LIMIT(rxq->entries), + ("rxfill > EFX_RXQ_LIMIT(rxq->entries)")); + ntodo = min(EFX_RXQ_LIMIT(rxq->entries) - rxfill, target); + KASSERT(ntodo <= EFX_RXQ_LIMIT(rxq->entries), + ("ntodo > EFX_RQX_LIMIT(rxq->entries)")); if (ntodo == 0) return; @@ -231,7 +230,7 @@ sfxge_rx_qfill(struct sfxge_rxq *rxq, unsigned int target, boolean_t retrying) bus_dma_segment_t seg; struct mbuf *m; - id = (rxq->added + batch) & (SFXGE_NDESCS - 1); + id = (rxq->added + batch) & rxq->ptr_mask; rx_desc = &rxq->queue[id]; KASSERT(rx_desc->mbuf == NULL, ("rx_desc->mbuf != NULL")); @@ -274,7 +273,7 @@ sfxge_rx_qrefill(struct sfxge_rxq *rxq) return; /* Make sure the queue is full */ - sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(SFXGE_NDESCS), B_TRUE); + sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(rxq->entries), B_TRUE); } static void __sfxge_rx_deliver(struct sfxge_softc *sc, struct mbuf *m) @@ -370,7 +369,7 @@ static void sfxge_lro_drop(struct sfxge_rxq *rxq, struct sfxge_lro_conn *c) KASSERT(!c->mbuf, ("found orphaned mbuf")); - if (c->next_buf.mbuf) { + if (c->next_buf.mbuf != NULL) { sfxge_rx_deliver(rxq->sc, &c->next_buf); LIST_REMOVE(c, active_link); } @@ -510,7 +509,7 @@ sfxge_lro_try_merge(struct sfxge_rxq *rxq, struct sfxge_lro_conn *c) if (__predict_false(th_seq != c->next_seq)) { /* Out-of-order, so start counting again. */ - if (c->mbuf) + if (c->mbuf != NULL) sfxge_lro_deliver(&rxq->lro, c); c->n_in_order_pkts -= lro_loss_packets; c->next_seq = th_seq + data_length; @@ -522,10 +521,10 @@ sfxge_lro_try_merge(struct sfxge_rxq *rxq, struct sfxge_lro_conn *c) now = ticks; if (now - c->last_pkt_ticks > lro_idle_ticks) { ++rxq->lro.n_drop_idle; - if (c->mbuf) + if (c->mbuf != NULL) sfxge_lro_deliver(&rxq->lro, c); sfxge_lro_drop(rxq, c); - return 0; + return (0); } c->last_pkt_ticks = ticks; @@ -537,12 +536,12 @@ sfxge_lro_try_merge(struct sfxge_rxq *rxq, struct sfxge_lro_conn *c) } if (__predict_false(dont_merge)) { - if (c->mbuf) + if (c->mbuf != NULL) sfxge_lro_deliver(&rxq->lro, c); if (th->th_flags & (TH_FIN | TH_RST)) { ++rxq->lro.n_drop_closed; sfxge_lro_drop(rxq, c); - return 0; + return (0); } goto deliver_buf_out; } @@ -563,11 +562,11 @@ sfxge_lro_try_merge(struct sfxge_rxq *rxq, struct sfxge_lro_conn *c) } rx_buf->mbuf = NULL; - return 1; + return (1); deliver_buf_out: sfxge_rx_deliver(rxq->sc, rx_buf); - return 1; + return (1); } static void sfxge_lro_new_conn(struct sfxge_lro_state *st, uint32_t conn_hash, @@ -621,7 +620,7 @@ sfxge_lro(struct sfxge_rxq *rxq, struct sfxge_rx_sw_desc *rx_buf) struct sfxge_lro_conn *c; uint16_t l2_id; uint16_t l3_proto; - void *nh; + void *nh; struct tcphdr *th; uint32_t conn_hash; unsigned bucket; @@ -671,7 +670,7 @@ sfxge_lro(struct sfxge_rxq *rxq, struct sfxge_rx_sw_desc *rx_buf) continue; if ((c->source - th->th_sport) | (c->dest - th->th_dport)) continue; - if (c->mbuf) { + if (c->mbuf != NULL) { if (SFXGE_LRO_CONN_IS_TCPIPV4(c)) { struct ip *c_iph, *iph = nh; c_iph = c->nh; @@ -691,7 +690,7 @@ sfxge_lro(struct sfxge_rxq *rxq, struct sfxge_rx_sw_desc *rx_buf) TAILQ_REMOVE(&rxq->lro.conns[bucket], c, link); TAILQ_INSERT_HEAD(&rxq->lro.conns[bucket], c, link); - if (c->next_buf.mbuf) { + if (c->next_buf.mbuf != NULL) { if (!sfxge_lro_try_merge(rxq, c)) goto deliver_now; } else { @@ -720,10 +719,10 @@ static void sfxge_lro_end_of_burst(struct sfxge_rxq *rxq) while (!LIST_EMPTY(&st->active_conns)) { c = LIST_FIRST(&st->active_conns); - if (!c->delivered && c->mbuf) + if (!c->delivered && c->mbuf != NULL) sfxge_lro_deliver(st, c); if (sfxge_lro_try_merge(rxq, c)) { - if (c->mbuf) + if (c->mbuf != NULL) sfxge_lro_deliver(st, c); LIST_REMOVE(c, active_link); } @@ -757,7 +756,7 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop) unsigned int id; struct sfxge_rx_sw_desc *rx_desc; - id = completed++ & (SFXGE_NDESCS - 1); + id = completed++ & rxq->ptr_mask; rx_desc = &rxq->queue[id]; m = rx_desc->mbuf; @@ -821,8 +820,8 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop) sfxge_lro_end_of_burst(rxq); /* Top up the queue if necessary */ - if (level < RX_REFILL_THRESHOLD) - sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(SFXGE_NDESCS), B_FALSE); + if (level < rxq->refill_threshold) + sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(rxq->entries), B_FALSE); } static void @@ -836,7 +835,7 @@ sfxge_rx_qstop(struct sfxge_softc *sc, unsigned int index) evq = sc->evq[index]; mtx_lock(&evq->lock); - + KASSERT(rxq->init_state == SFXGE_RXQ_STARTED, ("rxq not started")); @@ -881,10 +880,10 @@ sfxge_rx_qstop(struct sfxge_softc *sc, unsigned int index) rxq->loopback = 0; /* Destroy the common code receive queue. */ - efx_rx_qdestroy(rxq->common); + efx_rx_qdestroy(rxq->common); efx_sram_buf_tbl_clear(sc->enp, rxq->buf_base_id, - EFX_RXQ_NBUFS(SFXGE_NDESCS)); + EFX_RXQ_NBUFS(sc->rxq_entries)); mtx_unlock(&evq->lock); } @@ -908,12 +907,12 @@ sfxge_rx_qstart(struct sfxge_softc *sc, unsigned int index) /* Program the buffer table. */ if ((rc = efx_sram_buf_tbl_set(sc->enp, rxq->buf_base_id, esmp, - EFX_RXQ_NBUFS(SFXGE_NDESCS))) != 0) - return rc; + EFX_RXQ_NBUFS(sc->rxq_entries))) != 0) + return (rc); /* Create the common code receive queue. */ if ((rc = efx_rx_qcreate(sc->enp, index, index, EFX_RXQ_TYPE_DEFAULT, - esmp, SFXGE_NDESCS, rxq->buf_base_id, evq->common, + esmp, sc->rxq_entries, rxq->buf_base_id, evq->common, &rxq->common)) != 0) goto fail; @@ -925,7 +924,7 @@ sfxge_rx_qstart(struct sfxge_softc *sc, unsigned int index) rxq->init_state = SFXGE_RXQ_STARTED; /* Try to fill the queue from the pool. */ - sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(SFXGE_NDESCS), B_FALSE); + sfxge_rx_qfill(rxq, EFX_RXQ_LIMIT(sc->rxq_entries), B_FALSE); mtx_unlock(&evq->lock); @@ -933,8 +932,8 @@ sfxge_rx_qstart(struct sfxge_softc *sc, unsigned int index) fail: efx_sram_buf_tbl_clear(sc->enp, rxq->buf_base_id, - EFX_RXQ_NBUFS(SFXGE_NDESCS)); - return rc; + EFX_RXQ_NBUFS(sc->rxq_entries)); + return (rc); } void @@ -1105,6 +1104,9 @@ sfxge_rx_qinit(struct sfxge_softc *sc, unsigned int index) rxq = malloc(sizeof(struct sfxge_rxq), M_SFXGE, M_ZERO | M_WAITOK); rxq->sc = sc; rxq->index = index; + rxq->entries = sc->rxq_entries; + rxq->ptr_mask = rxq->entries - 1; + rxq->refill_threshold = RX_REFILL_THRESHOLD(rxq->entries); sc->rxq[index] = rxq; esmp = &rxq->mem; @@ -1112,16 +1114,16 @@ sfxge_rx_qinit(struct sfxge_softc *sc, unsigned int index) evq = sc->evq[index]; /* Allocate and zero DMA space. */ - if ((rc = sfxge_dma_alloc(sc, EFX_RXQ_SIZE(SFXGE_NDESCS), esmp)) != 0) + if ((rc = sfxge_dma_alloc(sc, EFX_RXQ_SIZE(sc->rxq_entries), esmp)) != 0) return (rc); - (void)memset(esmp->esm_base, 0, EFX_RXQ_SIZE(SFXGE_NDESCS)); + (void)memset(esmp->esm_base, 0, EFX_RXQ_SIZE(sc->rxq_entries)); /* Allocate buffer table entries. */ - sfxge_sram_buf_tbl_alloc(sc, EFX_RXQ_NBUFS(SFXGE_NDESCS), + sfxge_sram_buf_tbl_alloc(sc, EFX_RXQ_NBUFS(sc->rxq_entries), &rxq->buf_base_id); /* Allocate the context array and the flow table. */ - rxq->queue = malloc(sizeof(struct sfxge_rx_sw_desc) * SFXGE_NDESCS, + rxq->queue = malloc(sizeof(struct sfxge_rx_sw_desc) * sc->rxq_entries, M_SFXGE, M_WAITOK | M_ZERO); sfxge_lro_init(rxq); @@ -1136,7 +1138,7 @@ static const struct { const char *name; size_t offset; } sfxge_rx_stats[] = { -#define SFXGE_RX_STAT(name, member) \ +#define SFXGE_RX_STAT(name, member) \ { #name, offsetof(struct sfxge_rxq, member) } SFXGE_RX_STAT(lro_merges, lro.n_merges), SFXGE_RX_STAT(lro_bursts, lro.n_bursts), @@ -1161,7 +1163,7 @@ sfxge_rx_stat_handler(SYSCTL_HANDLER_ARGS) sum += *(unsigned int *)((caddr_t)sc->rxq[index] + sfxge_rx_stats[id].offset); - return SYSCTL_OUT(req, &sum, sizeof(sum)); + return (SYSCTL_OUT(req, &sum, sizeof(sum))); } static void diff --git a/sys/dev/sfxge/sfxge_rx.h b/sys/dev/sfxge/sfxge_rx.h index 5a80fdbc054c..4b3e73a97d20 100644 --- a/sys/dev/sfxge/sfxge_rx.h +++ b/sys/dev/sfxge/sfxge_rx.h @@ -30,25 +30,25 @@ */ #ifndef _SFXGE_RX_H -#define _SFXGE_RX_H +#define _SFXGE_RX_H -#define SFXGE_MAGIC_RESERVED 0x8000 +#define SFXGE_MAGIC_RESERVED 0x8000 -#define SFXGE_MAGIC_DMAQ_LABEL_WIDTH 6 -#define SFXGE_MAGIC_DMAQ_LABEL_MASK \ - ((1 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH) - 1) +#define SFXGE_MAGIC_DMAQ_LABEL_WIDTH 6 +#define SFXGE_MAGIC_DMAQ_LABEL_MASK \ + ((1 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH) - 1) -#define SFXGE_MAGIC_RX_QFLUSH_DONE \ - (SFXGE_MAGIC_RESERVED | (1 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) +#define SFXGE_MAGIC_RX_QFLUSH_DONE \ + (SFXGE_MAGIC_RESERVED | (1 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) -#define SFXGE_MAGIC_RX_QFLUSH_FAILED \ - (SFXGE_MAGIC_RESERVED | (2 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) +#define SFXGE_MAGIC_RX_QFLUSH_FAILED \ + (SFXGE_MAGIC_RESERVED | (2 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) -#define SFXGE_MAGIC_RX_QREFILL \ - (SFXGE_MAGIC_RESERVED | (3 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) +#define SFXGE_MAGIC_RX_QREFILL \ + (SFXGE_MAGIC_RESERVED | (3 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) -#define SFXGE_MAGIC_TX_QFLUSH_DONE \ - (SFXGE_MAGIC_RESERVED | (4 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) +#define SFXGE_MAGIC_TX_QFLUSH_DONE \ + (SFXGE_MAGIC_RESERVED | (4 << SFXGE_MAGIC_DMAQ_LABEL_WIDTH)) #define SFXGE_RX_SCALE_MAX EFX_MAXRSS @@ -159,6 +159,8 @@ struct sfxge_rxq { efsys_mem_t mem; unsigned int buf_base_id; enum sfxge_rxq_state init_state; + unsigned int entries; + unsigned int ptr_mask; struct sfxge_rx_sw_desc *queue __aligned(CACHE_LINE_SIZE); unsigned int added; @@ -166,6 +168,7 @@ struct sfxge_rxq { unsigned int completed; unsigned int loopback; struct sfxge_lro_state lro; + unsigned int refill_threshold; struct callout refill_callout; unsigned int refill_delay; diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c index 20f6f87dc28b..a12c74756ea5 100644 --- a/sys/dev/sfxge/sfxge_tx.c +++ b/sys/dev/sfxge/sfxge_tx.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -74,8 +75,27 @@ __FBSDID("$FreeBSD$"); * the output at a packet boundary. Allow for a reasonable * minimum MSS of 512. */ -#define SFXGE_TSO_MAX_DESC ((65535 / 512) * 2 + SFXGE_TX_MAPPING_MAX_SEG - 1) -#define SFXGE_TXQ_BLOCK_LEVEL (SFXGE_NDESCS - SFXGE_TSO_MAX_DESC) +#define SFXGE_TSO_MAX_DESC ((65535 / 512) * 2 + SFXGE_TX_MAPPING_MAX_SEG - 1) +#define SFXGE_TXQ_BLOCK_LEVEL(_entries) ((_entries) - SFXGE_TSO_MAX_DESC) + +#ifdef SFXGE_HAVE_MQ + +#define SFXGE_PARAM_TX_DPL_GET_MAX SFXGE_PARAM(tx_dpl_get_max) +static int sfxge_tx_dpl_get_max = SFXGE_TX_DPL_GET_PKT_LIMIT_DEFAULT; +TUNABLE_INT(SFXGE_PARAM_TX_DPL_GET_MAX, &sfxge_tx_dpl_get_max); +SYSCTL_INT(_hw_sfxge, OID_AUTO, tx_dpl_get_max, CTLFLAG_RDTUN, + &sfxge_tx_dpl_get_max, 0, + "Maximum number of packets in deferred packet get-list"); + +#define SFXGE_PARAM_TX_DPL_PUT_MAX SFXGE_PARAM(tx_dpl_put_max) +static int sfxge_tx_dpl_put_max = SFXGE_TX_DPL_PUT_PKT_LIMIT_DEFAULT; +TUNABLE_INT(SFXGE_PARAM_TX_DPL_PUT_MAX, &sfxge_tx_dpl_put_max); +SYSCTL_INT(_hw_sfxge, OID_AUTO, tx_dpl_put_max, CTLFLAG_RDTUN, + &sfxge_tx_dpl_put_max, 0, + "Maximum number of packets in deferred packet put-list"); + +#endif + /* Forward declarations. */ static inline void sfxge_tx_qdpl_service(struct sfxge_txq *txq); @@ -101,7 +121,7 @@ sfxge_tx_qcomplete(struct sfxge_txq *txq) struct sfxge_tx_mapping *stmp; unsigned int id; - id = completed++ & (SFXGE_NDESCS - 1); + id = completed++ & txq->ptr_mask; stmp = &txq->stmp[id]; if (stmp->flags & TX_BUF_UNMAP) { @@ -125,7 +145,7 @@ sfxge_tx_qcomplete(struct sfxge_txq *txq) unsigned int level; level = txq->added - txq->completed; - if (level <= SFXGE_TXQ_UNBLOCK_LEVEL) + if (level <= SFXGE_TXQ_UNBLOCK_LEVEL(txq->entries)) sfxge_tx_qunblock(txq); } } @@ -176,7 +196,7 @@ sfxge_tx_qdpl_swizzle(struct sfxge_txq *txq) KASSERT(*get_tailp == NULL, ("*get_tailp != NULL")); *stdp->std_getp = get_next; stdp->std_getp = get_tailp; - stdp->std_count += count; + stdp->std_get_count += count; } #endif /* SFXGE_HAVE_MQ */ @@ -218,19 +238,19 @@ sfxge_tx_qlist_post(struct sfxge_txq *txq) ("efx_tx_qpost() refragmented descriptors")); level = txq->added - txq->reaped; - KASSERT(level <= SFXGE_NDESCS, ("overfilled TX queue")); + KASSERT(level <= txq->entries, ("overfilled TX queue")); /* Clear the fragment list. */ txq->n_pend_desc = 0; /* Have we reached the block level? */ - if (level < SFXGE_TXQ_BLOCK_LEVEL) + if (level < SFXGE_TXQ_BLOCK_LEVEL(txq->entries)) return; /* Reap, and check again */ sfxge_tx_qreap(txq); level = txq->added - txq->reaped; - if (level < SFXGE_TXQ_BLOCK_LEVEL) + if (level < SFXGE_TXQ_BLOCK_LEVEL(txq->entries)) return; txq->blocked = 1; @@ -242,7 +262,7 @@ sfxge_tx_qlist_post(struct sfxge_txq *txq) mb(); sfxge_tx_qreap(txq); level = txq->added - txq->reaped; - if (level < SFXGE_TXQ_BLOCK_LEVEL) { + if (level < SFXGE_TXQ_BLOCK_LEVEL(txq->entries)) { mb(); txq->blocked = 0; } @@ -271,7 +291,7 @@ static int sfxge_tx_queue_mbuf(struct sfxge_txq *txq, struct mbuf *mbuf) } /* Load the packet for DMA. */ - id = txq->added & (SFXGE_NDESCS - 1); + id = txq->added & txq->ptr_mask; stmp = &txq->stmp[id]; rc = bus_dmamap_load_mbuf_sg(txq->packet_dma_tag, stmp->map, mbuf, dma_seg, &n_dma_seg, 0); @@ -318,7 +338,7 @@ static int sfxge_tx_queue_mbuf(struct sfxge_txq *txq, struct mbuf *mbuf) stmp->flags = 0; if (__predict_false(stmp == - &txq->stmp[SFXGE_NDESCS - 1])) + &txq->stmp[txq->ptr_mask])) stmp = &txq->stmp[0]; else stmp++; @@ -343,7 +363,7 @@ static int sfxge_tx_queue_mbuf(struct sfxge_txq *txq, struct mbuf *mbuf) /* Post the fragment list. */ sfxge_tx_qlist_post(txq); - return 0; + return (0); reject_mapped: bus_dmamap_unload(txq->packet_dma_tag, *used_map); @@ -352,7 +372,7 @@ static int sfxge_tx_queue_mbuf(struct sfxge_txq *txq, struct mbuf *mbuf) m_freem(mbuf); ++txq->drops; - return rc; + return (rc); } #ifdef SFXGE_HAVE_MQ @@ -380,7 +400,7 @@ sfxge_tx_qdpl_drain(struct sfxge_txq *txq) prefetch_read_many(txq->common); mbuf = stdp->std_get; - count = stdp->std_count; + count = stdp->std_get_count; while (count != 0) { KASSERT(mbuf != NULL, ("mbuf == NULL")); @@ -412,22 +432,22 @@ sfxge_tx_qdpl_drain(struct sfxge_txq *txq) if (count == 0) { KASSERT(mbuf == NULL, ("mbuf != NULL")); stdp->std_get = NULL; - stdp->std_count = 0; + stdp->std_get_count = 0; stdp->std_getp = &stdp->std_get; } else { stdp->std_get = mbuf; - stdp->std_count = count; + stdp->std_get_count = count; } if (txq->added != pushed) efx_tx_qpush(txq->common, txq->added); - KASSERT(txq->blocked || stdp->std_count == 0, + KASSERT(txq->blocked || stdp->std_get_count == 0, ("queue unblocked but count is non-zero")); } -#define SFXGE_TX_QDPL_PENDING(_txq) \ - ((_txq)->dpl.std_put != 0) +#define SFXGE_TX_QDPL_PENDING(_txq) \ + ((_txq)->dpl.std_put != 0) /* * Service the deferred packet list. @@ -476,12 +496,12 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked) sfxge_tx_qdpl_swizzle(txq); - if (stdp->std_count >= SFXGE_TX_DPL_GET_PKT_LIMIT_DEFAULT) + if (stdp->std_get_count >= stdp->std_get_max) return (ENOBUFS); *(stdp->std_getp) = mbuf; stdp->std_getp = &mbuf->m_nextpkt; - stdp->std_count++; + stdp->std_get_count++; } else { volatile uintptr_t *putp; uintptr_t old; @@ -493,12 +513,12 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked) do { old = *putp; - if (old) { + if (old != 0) { struct mbuf *mp = (struct mbuf *)old; old_len = mp->m_pkthdr.csum_data; } else old_len = 0; - if (old_len >= SFXGE_TX_DPL_PUT_PKT_LIMIT_DEFAULT) + if (old_len >= stdp->std_put_max) return (ENOBUFS); mbuf->m_pkthdr.csum_data = old_len + 1; mbuf->m_nextpkt = (void *)old; @@ -559,7 +579,6 @@ sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m) m_freem(m); atomic_add_long(&txq->early_drops, 1); return (rc); - } static void @@ -576,8 +595,8 @@ sfxge_tx_qdpl_flush(struct sfxge_txq *txq) m_freem(mbuf); } stdp->std_get = NULL; - stdp->std_count = 0; - stdp->std_getp = &stdp->std_get; + stdp->std_get_count = 0; + stdp->std_getp = &stdp->std_get; mtx_unlock(&txq->lock); } @@ -599,7 +618,7 @@ sfxge_if_qflush(struct ifnet *ifp) */ int sfxge_if_transmit(struct ifnet *ifp, struct mbuf *m) -{ +{ struct sfxge_softc *sc; struct sfxge_txq *txq; int rc; @@ -652,7 +671,7 @@ static void sfxge_if_start_locked(struct ifnet *ifp) } while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { - IFQ_DRV_DEQUEUE(&ifp->if_snd, mbuf); + IFQ_DRV_DEQUEUE(&ifp->if_snd, mbuf); if (mbuf == NULL) break; @@ -757,47 +776,49 @@ static inline const struct tcphdr *tso_tcph(const struct sfxge_tso_state *tso) /* Size of preallocated TSO header buffers. Larger blocks must be * allocated from the heap. */ -#define TSOH_STD_SIZE 128 +#define TSOH_STD_SIZE 128 /* At most half the descriptors in the queue at any time will refer to * a TSO header buffer, since they must always be followed by a * payload descriptor referring to an mbuf. */ -#define TSOH_COUNT (SFXGE_NDESCS / 2u) -#define TSOH_PER_PAGE (PAGE_SIZE / TSOH_STD_SIZE) -#define TSOH_PAGE_COUNT ((TSOH_COUNT + TSOH_PER_PAGE - 1) / TSOH_PER_PAGE) +#define TSOH_COUNT(_txq_entries) ((_txq_entries) / 2u) +#define TSOH_PER_PAGE (PAGE_SIZE / TSOH_STD_SIZE) +#define TSOH_PAGE_COUNT(_txq_entries) \ + ((TSOH_COUNT(_txq_entries) + TSOH_PER_PAGE - 1) / TSOH_PER_PAGE) static int tso_init(struct sfxge_txq *txq) { struct sfxge_softc *sc = txq->sc; + unsigned int tsoh_page_count = TSOH_PAGE_COUNT(sc->txq_entries); int i, rc; /* Allocate TSO header buffers */ - txq->tsoh_buffer = malloc(TSOH_PAGE_COUNT * sizeof(txq->tsoh_buffer[0]), + txq->tsoh_buffer = malloc(tsoh_page_count * sizeof(txq->tsoh_buffer[0]), M_SFXGE, M_WAITOK); - for (i = 0; i < TSOH_PAGE_COUNT; i++) { + for (i = 0; i < tsoh_page_count; i++) { rc = sfxge_dma_alloc(sc, PAGE_SIZE, &txq->tsoh_buffer[i]); - if (rc) + if (rc != 0) goto fail; } - return 0; + return (0); fail: while (i-- > 0) sfxge_dma_free(&txq->tsoh_buffer[i]); free(txq->tsoh_buffer, M_SFXGE); txq->tsoh_buffer = NULL; - return rc; + return (rc); } static void tso_fini(struct sfxge_txq *txq) { int i; - if (txq->tsoh_buffer) { - for (i = 0; i < TSOH_PAGE_COUNT; i++) + if (txq->tsoh_buffer != NULL) { + for (i = 0; i < TSOH_PAGE_COUNT(txq->sc->txq_entries); i++) sfxge_dma_free(&txq->tsoh_buffer[i]); free(txq->tsoh_buffer, M_SFXGE); } @@ -925,7 +946,7 @@ static int tso_start_new_packet(struct sfxge_txq *txq, /* We cannot use bus_dmamem_alloc() as that may sleep */ header = malloc(tso->header_len, M_SFXGE, M_NOWAIT); if (__predict_false(!header)) - return ENOMEM; + return (ENOMEM); rc = bus_dmamap_load(txq->packet_dma_tag, stmp->map, header, tso->header_len, tso_map_long_header, &dma_addr, @@ -938,7 +959,7 @@ static int tso_start_new_packet(struct sfxge_txq *txq, rc = EINVAL; } free(header, M_SFXGE); - return rc; + return (rc); } map = stmp->map; @@ -987,7 +1008,7 @@ static int tso_start_new_packet(struct sfxge_txq *txq, desc->eb_size = tso->header_len; desc->eb_eop = 0; - return 0; + return (0); } static int @@ -1011,12 +1032,12 @@ sfxge_tx_queue_tso(struct sfxge_txq *txq, struct mbuf *mbuf, tso.dma_addr = dma_seg->ds_addr + tso.header_len; } - id = txq->added & (SFXGE_NDESCS - 1); + id = txq->added & txq->ptr_mask; if (__predict_false(tso_start_new_packet(txq, &tso, id))) - return -1; + return (-1); while (1) { - id = (id + 1) & (SFXGE_NDESCS - 1); + id = (id + 1) & txq->ptr_mask; tso_fill_packet_with_fragment(txq, &tso); /* Move onto the next fragment? */ @@ -1039,7 +1060,7 @@ sfxge_tx_queue_tso(struct sfxge_txq *txq, struct mbuf *mbuf, if (txq->n_pend_desc > SFXGE_TSO_MAX_DESC - (1 + SFXGE_TX_MAPPING_MAX_SEG)) break; - next_id = (id + 1) & (SFXGE_NDESCS - 1); + next_id = (id + 1) & txq->ptr_mask; if (__predict_false(tso_start_new_packet(txq, &tso, next_id))) break; @@ -1048,7 +1069,7 @@ sfxge_tx_queue_tso(struct sfxge_txq *txq, struct mbuf *mbuf, } txq->tso_bursts++; - return id; + return (id); } static void @@ -1071,7 +1092,7 @@ sfxge_tx_qunblock(struct sfxge_txq *txq) unsigned int level; level = txq->added - txq->completed; - if (level <= SFXGE_TXQ_UNBLOCK_LEVEL) + if (level <= SFXGE_TXQ_UNBLOCK_LEVEL(txq->entries)) txq->blocked = 0; } @@ -1147,7 +1168,7 @@ sfxge_tx_qstop(struct sfxge_softc *sc, unsigned int index) txq->common = NULL; efx_sram_buf_tbl_clear(sc->enp, txq->buf_base_id, - EFX_TXQ_NBUFS(SFXGE_NDESCS)); + EFX_TXQ_NBUFS(sc->txq_entries)); mtx_unlock(&evq->lock); mtx_unlock(SFXGE_TXQ_LOCK(txq)); @@ -1173,8 +1194,8 @@ sfxge_tx_qstart(struct sfxge_softc *sc, unsigned int index) /* Program the buffer table. */ if ((rc = efx_sram_buf_tbl_set(sc->enp, txq->buf_base_id, esmp, - EFX_TXQ_NBUFS(SFXGE_NDESCS))) != 0) - return rc; + EFX_TXQ_NBUFS(sc->txq_entries))) != 0) + return (rc); /* Determine the kind of queue we are creating. */ switch (txq->type) { @@ -1195,12 +1216,12 @@ sfxge_tx_qstart(struct sfxge_softc *sc, unsigned int index) /* Create the common code transmit queue. */ if ((rc = efx_tx_qcreate(sc->enp, index, txq->type, esmp, - SFXGE_NDESCS, txq->buf_base_id, flags, evq->common, + sc->txq_entries, txq->buf_base_id, flags, evq->common, &txq->common)) != 0) goto fail; mtx_lock(SFXGE_TXQ_LOCK(txq)); - + /* Enable the transmit queue. */ efx_tx_qenable(txq->common); @@ -1212,8 +1233,8 @@ sfxge_tx_qstart(struct sfxge_softc *sc, unsigned int index) fail: efx_sram_buf_tbl_clear(sc->enp, txq->buf_base_id, - EFX_TXQ_NBUFS(SFXGE_NDESCS)); - return rc; + EFX_TXQ_NBUFS(sc->txq_entries)); + return (rc); } void @@ -1229,7 +1250,7 @@ sfxge_tx_stop(struct sfxge_softc *sc) sfxge_tx_qstop(sc, SFXGE_TXQ_IP_CKSUM); encp = efx_nic_cfg_get(sc->enp); - sfxge_tx_qstop(sc, SFXGE_TXQ_NON_CKSUM); + sfxge_tx_qstop(sc, SFXGE_TXQ_NON_CKSUM); /* Tear down the transmit module */ efx_tx_fini(sc->enp); @@ -1266,7 +1287,7 @@ sfxge_tx_start(struct sfxge_softc *sc) sfxge_tx_qstop(sc, SFXGE_TXQ_IP_CKSUM); fail2: - sfxge_tx_qstop(sc, SFXGE_TXQ_NON_CKSUM); + sfxge_tx_qstop(sc, SFXGE_TXQ_NON_CKSUM); fail: efx_tx_fini(sc->enp); @@ -1281,7 +1302,7 @@ static void sfxge_tx_qfini(struct sfxge_softc *sc, unsigned int index) { struct sfxge_txq *txq; - unsigned int nmaps = SFXGE_NDESCS; + unsigned int nmaps; txq = sc->txq[index]; @@ -1293,7 +1314,8 @@ sfxge_tx_qfini(struct sfxge_softc *sc, unsigned int index) /* Free the context arrays. */ free(txq->pend_desc, M_SFXGE); - while (nmaps--) + nmaps = sc->txq_entries; + while (nmaps-- != 0) bus_dmamap_destroy(txq->packet_dma_tag, txq->stmp[nmaps].map); free(txq->stmp, M_SFXGE); @@ -1313,6 +1335,8 @@ static int sfxge_tx_qinit(struct sfxge_softc *sc, unsigned int txq_index, enum sfxge_txq_type type, unsigned int evq_index) { + char name[16]; + struct sysctl_oid *txq_node; struct sfxge_txq *txq; struct sfxge_evq *evq; #ifdef SFXGE_HAVE_MQ @@ -1324,6 +1348,8 @@ sfxge_tx_qinit(struct sfxge_softc *sc, unsigned int txq_index, txq = malloc(sizeof(struct sfxge_txq), M_SFXGE, M_ZERO | M_WAITOK); txq->sc = sc; + txq->entries = sc->txq_entries; + txq->ptr_mask = txq->entries - 1; sc->txq[txq_index] = txq; esmp = &txq->mem; @@ -1331,12 +1357,12 @@ sfxge_tx_qinit(struct sfxge_softc *sc, unsigned int txq_index, evq = sc->evq[evq_index]; /* Allocate and zero DMA space for the descriptor ring. */ - if ((rc = sfxge_dma_alloc(sc, EFX_TXQ_SIZE(SFXGE_NDESCS), esmp)) != 0) + if ((rc = sfxge_dma_alloc(sc, EFX_TXQ_SIZE(sc->txq_entries), esmp)) != 0) return (rc); - (void)memset(esmp->esm_base, 0, EFX_TXQ_SIZE(SFXGE_NDESCS)); + (void)memset(esmp->esm_base, 0, EFX_TXQ_SIZE(sc->txq_entries)); /* Allocate buffer table entries. */ - sfxge_sram_buf_tbl_alloc(sc, EFX_TXQ_NBUFS(SFXGE_NDESCS), + sfxge_sram_buf_tbl_alloc(sc, EFX_TXQ_NBUFS(sc->txq_entries), &txq->buf_base_id); /* Create a DMA tag for packet mappings. */ @@ -1350,29 +1376,59 @@ sfxge_tx_qinit(struct sfxge_softc *sc, unsigned int txq_index, } /* Allocate pending descriptor array for batching writes. */ - txq->pend_desc = malloc(sizeof(efx_buffer_t) * SFXGE_NDESCS, + txq->pend_desc = malloc(sizeof(efx_buffer_t) * sc->txq_entries, M_SFXGE, M_ZERO | M_WAITOK); /* Allocate and initialise mbuf DMA mapping array. */ - txq->stmp = malloc(sizeof(struct sfxge_tx_mapping) * SFXGE_NDESCS, + txq->stmp = malloc(sizeof(struct sfxge_tx_mapping) * sc->txq_entries, M_SFXGE, M_ZERO | M_WAITOK); - for (nmaps = 0; nmaps < SFXGE_NDESCS; nmaps++) { + for (nmaps = 0; nmaps < sc->txq_entries; nmaps++) { rc = bus_dmamap_create(txq->packet_dma_tag, 0, &txq->stmp[nmaps].map); if (rc != 0) goto fail2; } + snprintf(name, sizeof(name), "%u", txq_index); + txq_node = SYSCTL_ADD_NODE( + device_get_sysctl_ctx(sc->dev), + SYSCTL_CHILDREN(sc->txqs_node), + OID_AUTO, name, CTLFLAG_RD, NULL, ""); + if (txq_node == NULL) { + rc = ENOMEM; + goto fail_txq_node; + } + if (type == SFXGE_TXQ_IP_TCP_UDP_CKSUM && (rc = tso_init(txq)) != 0) goto fail3; #ifdef SFXGE_HAVE_MQ + if (sfxge_tx_dpl_get_max <= 0) { + log(LOG_ERR, "%s=%d must be greater than 0", + SFXGE_PARAM_TX_DPL_GET_MAX, sfxge_tx_dpl_get_max); + rc = EINVAL; + goto fail_tx_dpl_get_max; + } + if (sfxge_tx_dpl_put_max < 0) { + log(LOG_ERR, "%s=%d must be greater or equal to 0", + SFXGE_PARAM_TX_DPL_PUT_MAX, sfxge_tx_dpl_put_max); + rc = EINVAL; + goto fail_tx_dpl_put_max; + } + /* Initialize the deferred packet list. */ stdp = &txq->dpl; + stdp->std_put_max = sfxge_tx_dpl_put_max; + stdp->std_get_max = sfxge_tx_dpl_get_max; stdp->std_getp = &stdp->std_get; mtx_init(&txq->lock, "txq", NULL, MTX_DEF); + + SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc->dev), + SYSCTL_CHILDREN(txq_node), OID_AUTO, + "dpl_get_count", CTLFLAG_RD | CTLFLAG_STATS, + &stdp->std_get_count, 0, ""); #endif txq->type = type; @@ -1382,10 +1438,13 @@ sfxge_tx_qinit(struct sfxge_softc *sc, unsigned int txq_index, return (0); +fail_tx_dpl_put_max: +fail_tx_dpl_get_max: fail3: +fail_txq_node: free(txq->pend_desc, M_SFXGE); fail2: - while (nmaps--) + while (nmaps-- != 0) bus_dmamap_destroy(txq->packet_dma_tag, txq->stmp[nmaps].map); free(txq->stmp, M_SFXGE); bus_dma_tag_destroy(txq->packet_dma_tag); @@ -1400,7 +1459,7 @@ static const struct { const char *name; size_t offset; } sfxge_tx_stats[] = { -#define SFXGE_TX_STAT(name, member) \ +#define SFXGE_TX_STAT(name, member) \ { #name, offsetof(struct sfxge_txq, member) } SFXGE_TX_STAT(tso_bursts, tso_bursts), SFXGE_TX_STAT(tso_packets, tso_packets), @@ -1426,7 +1485,7 @@ sfxge_tx_stat_handler(SYSCTL_HANDLER_ARGS) sum += *(unsigned long *)((caddr_t)sc->txq[index] + sfxge_tx_stats[id].offset); - return SYSCTL_OUT(req, &sum, sizeof(sum)); + return (SYSCTL_OUT(req, &sum, sizeof(sum))); } static void @@ -1460,7 +1519,7 @@ sfxge_tx_fini(struct sfxge_softc *sc) sfxge_tx_qfini(sc, SFXGE_TXQ_IP_TCP_UDP_CKSUM + index); sfxge_tx_qfini(sc, SFXGE_TXQ_IP_CKSUM); - sfxge_tx_qfini(sc, SFXGE_TXQ_NON_CKSUM); + sfxge_tx_qfini(sc, SFXGE_TXQ_NON_CKSUM); } @@ -1476,6 +1535,15 @@ sfxge_tx_init(struct sfxge_softc *sc) KASSERT(intr->state == SFXGE_INTR_INITIALIZED, ("intr->state != SFXGE_INTR_INITIALIZED")); + sc->txqs_node = SYSCTL_ADD_NODE( + device_get_sysctl_ctx(sc->dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), + OID_AUTO, "txq", CTLFLAG_RD, NULL, "Tx queues"); + if (sc->txqs_node == NULL) { + rc = ENOMEM; + goto fail_txq_node; + } + /* Initialize the transmit queues */ if ((rc = sfxge_tx_qinit(sc, SFXGE_TXQ_NON_CKSUM, SFXGE_TXQ_NON_CKSUM, 0)) != 0) @@ -1505,5 +1573,6 @@ sfxge_tx_init(struct sfxge_softc *sc) sfxge_tx_qfini(sc, SFXGE_TXQ_NON_CKSUM); fail: +fail_txq_node: return (rc); } diff --git a/sys/dev/sfxge/sfxge_tx.h b/sys/dev/sfxge/sfxge_tx.h index 33ce8b9126f9..67dea0c74d5f 100644 --- a/sys/dev/sfxge/sfxge_tx.h +++ b/sys/dev/sfxge/sfxge_tx.h @@ -30,7 +30,7 @@ */ #ifndef _SFXGE_TX_H -#define _SFXGE_TX_H +#define _SFXGE_TX_H #include #include @@ -47,7 +47,7 @@ * could overlap all mbufs in the chain and also require an extra * segment for a TSO header. */ -#define SFXGE_TX_PACKET_MAX_SEG (SFXGE_TX_MAPPING_MAX_SEG + 1) +#define SFXGE_TX_PACKET_MAX_SEG (SFXGE_TX_MAPPING_MAX_SEG + 1) /* * Buffer mapping flags. @@ -75,17 +75,21 @@ struct sfxge_tx_mapping { enum sfxge_tx_buf_flags flags; }; -#define SFXGE_TX_DPL_GET_PKT_LIMIT_DEFAULT 64 +#define SFXGE_TX_DPL_GET_PKT_LIMIT_DEFAULT 1024 #define SFXGE_TX_DPL_PUT_PKT_LIMIT_DEFAULT 64 /* * Deferred packet list. */ struct sfxge_tx_dpl { - uintptr_t std_put; /* Head of put list. */ - struct mbuf *std_get; /* Head of get list. */ - struct mbuf **std_getp; /* Tail of get list. */ - unsigned int std_count; /* Count of packets. */ + unsigned int std_get_max; /* Maximum number of packets + * in get list */ + unsigned int std_put_max; /* Maximum number of packets + * in put list */ + uintptr_t std_put; /* Head of put list. */ + struct mbuf *std_get; /* Head of get list. */ + struct mbuf **std_getp; /* Tail of get list. */ + unsigned int std_get_count; /* Packets in get list. */ }; @@ -106,16 +110,16 @@ enum sfxge_txq_type { SFXGE_TXQ_NTYPES }; -#define SFXGE_TXQ_UNBLOCK_LEVEL (EFX_TXQ_LIMIT(SFXGE_NDESCS) / 4) +#define SFXGE_TXQ_UNBLOCK_LEVEL(_entries) (EFX_TXQ_LIMIT(_entries) / 4) #define SFXGE_TX_BATCH 64 #ifdef SFXGE_HAVE_MQ -#define SFXGE_TXQ_LOCK(txq) (&(txq)->lock) -#define SFXGE_TX_SCALE(sc) ((sc)->intr.n_alloc) +#define SFXGE_TXQ_LOCK(txq) (&(txq)->lock) +#define SFXGE_TX_SCALE(sc) ((sc)->intr.n_alloc) #else -#define SFXGE_TXQ_LOCK(txq) (&(txq)->sc->tx_lock) -#define SFXGE_TX_SCALE(sc) 1 +#define SFXGE_TXQ_LOCK(txq) (&(txq)->sc->tx_lock) +#define SFXGE_TX_SCALE(sc) 1 #endif struct sfxge_txq { @@ -128,6 +132,8 @@ struct sfxge_txq { unsigned int evq_index; efsys_mem_t mem; unsigned int buf_base_id; + unsigned int entries; + unsigned int ptr_mask; struct sfxge_tx_mapping *stmp; /* Packets in flight. */ bus_dma_tag_t packet_dma_tag; diff --git a/sys/dev/sge/if_sge.c b/sys/dev/sge/if_sge.c index 32773fd786b6..f0ef07fcb52c 100644 --- a/sys/dev/sge/if_sge.c +++ b/sys/dev/sge/if_sge.c @@ -1171,13 +1171,13 @@ sge_rxeof(struct sge_softc *sc) RX_ERR_BITS); #endif sge_discard_rxbuf(sc, cons); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } m = cd->sge_rxdesc[cons].rx_m; if (sge_newbuf(sc, cons) != 0) { sge_discard_rxbuf(sc, cons); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { @@ -1210,7 +1210,7 @@ sge_rxeof(struct sge_softc *sc) m->m_pkthdr.len = m->m_len = SGE_RX_BYTES(rxstat) - SGE_RX_PAD_BYTES; m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); SGE_UNLOCK(sc); (*ifp->if_input)(ifp, m); SGE_LOCK(sc); @@ -1265,12 +1265,12 @@ sge_txeof(struct sge_softc *sc) device_printf(sc->sge_dev, "Tx error : 0x%b\n", txstat, TX_ERR_BITS); #endif - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else { #ifdef notyet - ifp->if_collisions += (txstat & 0xFFFF) - 1; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (txstat & 0xFFFF) - 1); #endif - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } txd = &cd->sge_txdesc[cons]; for (nsegs = 0; nsegs < txd->tx_ndesc; nsegs++) { @@ -1856,13 +1856,13 @@ sge_watchdog(struct sge_softc *sc) if (1 || bootverbose) device_printf(sc->sge_dev, "watchdog timeout (lost link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sge_init_locked(sc); return; } device_printf(sc->sge_dev, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sge_init_locked(sc); diff --git a/sys/dev/siis/siis.c b/sys/dev/siis/siis.c index dd2bd70a656c..b617689918fc 100644 --- a/sys/dev/siis/siis.c +++ b/sys/dev/siis/siis.c @@ -465,6 +465,7 @@ siis_ch_attach(device_t dev) ch->dev = dev; ch->unit = (intptr_t)device_get_ivars(dev); ch->quirks = ctlr->quirks; + ch->pm_level = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "pm_level", &ch->pm_level); resource_int_value(device_get_name(dev), diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c index c32aa14a416f..f7e6f3ba4442 100644 --- a/sys/dev/sis/if_sis.c +++ b/sys/dev/sis/if_sis.c @@ -1509,9 +1509,9 @@ sis_rxeof(struct sis_softc *sc) ETHER_CRC_LEN)) rxstat &= ~SIS_RXSTAT_GIANT; if (SIS_RXSTAT_ERROR(rxstat) != 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (rxstat & SIS_RXSTAT_COLL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); sis_discard_rxbuf(rxd); continue; } @@ -1519,7 +1519,7 @@ sis_rxeof(struct sis_softc *sc) /* Add a new receive buffer to the ring. */ m = rxd->rx_m; if (sis_newbuf(sc, rxd) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); sis_discard_rxbuf(rxd); continue; } @@ -1535,7 +1535,7 @@ sis_rxeof(struct sis_softc *sc) */ sis_fixup_rx(m); #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; SIS_UNLOCK(sc); @@ -1593,15 +1593,15 @@ sis_txeof(struct sis_softc *sc) m_freem(txd->tx_m); txd->tx_m = NULL; if ((txstat & SIS_CMDSTS_PKT_OK) != 0) { - ifp->if_opackets++; - ifp->if_collisions += - (txstat & SIS_TXSTAT_COLLCNT) >> 16; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + (txstat & SIS_TXSTAT_COLLCNT) >> 16); } else { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (txstat & SIS_TXSTAT_EXCESSCOLLS) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (txstat & SIS_TXSTAT_OUTOFWINCOLL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } } sc->sis_tx_cnt--; @@ -1664,7 +1664,7 @@ sis_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) status = CSR_READ_4(sc, SIS_ISR); if (status & (SIS_ISR_RX_ERR|SIS_ISR_RX_OFLOW)) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (status & (SIS_ISR_RX_IDLE)) SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE); @@ -1722,7 +1722,7 @@ sis_intr(void *arg) sis_rxeof(sc); if (status & SIS_ISR_RX_OFLOW) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (status & (SIS_ISR_RX_IDLE)) SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE); @@ -2197,7 +2197,7 @@ sis_watchdog(struct sis_softc *sc) return; device_printf(sc->sis_dev, "watchdog timeout\n"); - sc->sis_ifp->if_oerrors++; + if_inc_counter(sc->sis_ifp, IFCOUNTER_OERRORS, 1); sc->sis_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sis_initl(sc); diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index c4eb2d6c57ac..9898370ad62d 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -2556,7 +2556,7 @@ sk_watchdog(arg) sk_txeof(sc_if); if (sc_if->sk_cdata.sk_tx_cnt != 0) { if_printf(sc_if->sk_ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sk_init_locked(sc_if); } @@ -2771,7 +2771,7 @@ sk_rxeof(sc_if) SK_RXBYTES(sk_ctl) < SK_MIN_FRAMELEN || SK_RXBYTES(sk_ctl) > SK_MAX_FRAMELEN || sk_rxvalid(sc, rxstat, SK_RXBYTES(sk_ctl)) == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); sk_discard_rxbuf(sc_if, cons); continue; } @@ -2779,14 +2779,14 @@ sk_rxeof(sc_if) m = rxd->rx_m; csum = le32toh(cur_rx->sk_csum); if (sk_newbuf(sc_if, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* reuse old buffer */ sk_discard_rxbuf(sc_if, cons); continue; } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = SK_RXBYTES(sk_ctl); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) sk_rxcksum(ifp, m, csum); SK_IF_UNLOCK(sc_if); @@ -2839,7 +2839,7 @@ sk_jumbo_rxeof(sc_if) SK_RXBYTES(sk_ctl) < SK_MIN_FRAMELEN || SK_RXBYTES(sk_ctl) > SK_JUMBO_FRAMELEN || sk_rxvalid(sc, rxstat, SK_RXBYTES(sk_ctl)) == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); sk_discard_jumbo_rxbuf(sc_if, cons); continue; } @@ -2847,14 +2847,14 @@ sk_jumbo_rxeof(sc_if) m = jrxd->rx_m; csum = le32toh(cur_rx->sk_csum); if (sk_jumbo_newbuf(sc_if, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* reuse old buffer */ sk_discard_jumbo_rxbuf(sc_if, cons); continue; } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = SK_RXBYTES(sk_ctl); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) sk_rxcksum(ifp, m, csum); SK_IF_UNLOCK(sc_if); @@ -2905,7 +2905,7 @@ sk_txeof(sc_if) BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc_if->sk_cdata.sk_tx_tag, txd->tx_dmamap); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(txd->tx_m); txd->tx_m = NULL; STAILQ_REMOVE_HEAD(&sc_if->sk_cdata.sk_txbusyq, tx_q); diff --git a/sys/dev/smc/if_smc.c b/sys/dev/smc/if_smc.c index 0ce595f67a60..8ba7210d5796 100644 --- a/sys/dev/smc/if_smc.c +++ b/sys/dev/smc/if_smc.c @@ -512,7 +512,7 @@ smc_start_locked(struct ifnet *ifp) len += (len & 1); if (len > ETHER_MAX_LEN - ETHER_CRC_LEN) { if_printf(ifp, "large packet discarded\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); return; /* XXX readcheck? */ } @@ -598,7 +598,7 @@ smc_task_tx(void *context, int pending) */ if (packet & ARR_FAILED) { IFQ_DRV_PREPEND(&ifp->if_snd, m); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; smc_start_locked(ifp); SMC_UNLOCK(sc); @@ -655,7 +655,7 @@ smc_task_tx(void *context, int pending) /* * Finish up. */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; SMC_UNLOCK(sc); BPF_MTAP(ifp, m0); @@ -721,7 +721,7 @@ smc_task_rx(void *context, int pending) if (status & (RX_TOOSHORT | RX_TOOLNG | RX_BADCRC | RX_ALGNERR)) { smc_mmu_wait(sc); smc_write_2(sc, MMUCR, MMUCR_CMD_RELEASE); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); break; } @@ -777,7 +777,7 @@ smc_task_rx(void *context, int pending) m = mhead; mhead = mhead->m_next; m->m_next = NULL; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, m); } } @@ -892,7 +892,7 @@ smc_task_intr(void *context, int pending) */ if (status & RX_OVRN_INT) { smc_write_1(sc, ACK, RX_OVRN_INT); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } /* @@ -909,10 +909,9 @@ smc_task_intr(void *context, int pending) smc_select_bank(sc, 0); counter = smc_read_2(sc, ECR); smc_select_bank(sc, 2); - ifp->if_collisions += - (counter & ECR_SNGLCOL_MASK) >> ECR_SNGLCOL_SHIFT; - ifp->if_collisions += - (counter & ECR_MULCOL_MASK) >> ECR_MULCOL_SHIFT; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + ((counter & ECR_SNGLCOL_MASK) >> ECR_SNGLCOL_SHIFT) + + ((counter & ECR_MULCOL_MASK) >> ECR_MULCOL_SHIFT)); /* * See if there are any packets to transmit. diff --git a/sys/arm/versatile/if_smc_fdt.c b/sys/dev/smc/if_smc_fdt.c similarity index 100% rename from sys/arm/versatile/if_smc_fdt.c rename to sys/dev/smc/if_smc_fdt.c diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c index 7cc856439c73..7350537935e0 100644 --- a/sys/dev/sn/if_sn.c +++ b/sys/dev/sn/if_sn.c @@ -409,7 +409,7 @@ snstart_locked(struct ifnet *ifp) */ if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) { if_printf(ifp, "large packet discarded (A)\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); IFQ_DRV_DEQUEUE(&ifp->if_snd, m); m_freem(m); goto readcheck; @@ -556,7 +556,7 @@ snstart_locked(struct ifnet *ifp) BPF_MTAP(ifp, top); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(top); @@ -625,7 +625,7 @@ snresume(struct ifnet *ifp) */ if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) { if_printf(ifp, "large packet discarded (B)\n"); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); IFQ_DRV_DEQUEUE(&ifp->if_snd, m); m_freem(m); return; @@ -750,7 +750,7 @@ snresume(struct ifnet *ifp) BPF_MTAP(ifp, top); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(top); try_start: @@ -830,7 +830,7 @@ snintr_locked(struct sn_softc *sc) SMC_SELECT_BANK(sc, 2); CSR_WRITE_1(sc, INTR_ACK_REG_B, IM_RX_OVRN_INT); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } /* * Got a packet. @@ -896,11 +896,11 @@ snintr_locked(struct sn_softc *sc) device_printf(sc->dev, "Successful packet caused interrupt\n"); } else { - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } if (tx_status & EPHSR_LATCOL) - ++ifp->if_collisions; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); /* * Some of these errors will have disabled transmit. @@ -951,12 +951,12 @@ snintr_locked(struct sn_softc *sc) /* * Single collisions */ - ifp->if_collisions += card_stats & ECR_COLN_MASK; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, card_stats & ECR_COLN_MASK); /* * Multiple collisions */ - ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (card_stats & ECR_MCOLN_MASK) >> 4); SMC_SELECT_BANK(sc, 2); @@ -1041,7 +1041,7 @@ snread(struct ifnet *ifp) * Account for receive errors and discard. */ if (status & RS_ERRORS) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto out; } /* @@ -1074,7 +1074,7 @@ snread(struct ifnet *ifp) */ if ((m->m_flags & M_EXT) == 0) { m_freem(m); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); printf("sn: snread() kernel memory allocation problem\n"); goto out; } @@ -1089,7 +1089,7 @@ snread(struct ifnet *ifp) data += packet_length & ~1; *data = CSR_READ_1(sc, DATA_REG_B); } - ++ifp->if_ipackets; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* * Remove link layer addresses and whatnot. diff --git a/sys/dev/snc/dp83932.c b/sys/dev/snc/dp83932.c index 617897780ccd..d4e062ac1f2f 100644 --- a/sys/dev/snc/dp83932.c +++ b/sys/dev/snc/dp83932.c @@ -369,7 +369,7 @@ sncstart_locked(struct ifnet *ifp) sc->mtd_prev = sc->mtd_free; sc->mtd_free = mtd_next; - ifp->if_opackets++; /* # of pkts */ + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* # of pkts */ /* Jump back for possibly more punishment. */ goto outloop; @@ -935,11 +935,12 @@ sonictxint(struct snc_softc *sc) txp_status = SRO(sc, txp, TXP_STATUS); - ifp->if_collisions += (txp_status & TCR_EXC) ? 16 : - ((txp_status & TCR_NC) >> 12); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + (txp_status & TCR_EXC) ? 16 : + ((txp_status & TCR_NC) >> 12)); if ((txp_status & TCR_PTX) == 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); device_printf(sc->sc_dev, "Tx packet status=0x%x\n", txp_status); @@ -989,11 +990,11 @@ sonicrxint(struct snc_softc *sc) u_int32_t pkt = sc->rbuf[orra & RBAMASK] + (rxpkt_ptr & PAGE_MASK); if (sonic_read(sc, pkt, len)) - sc->sc_ifp->if_ipackets++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); else - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); } else - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); /* * give receive buffer area back to chip. diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 9d98a78bccb5..3d48abca05c6 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -232,7 +232,7 @@ struct uaudio_chan { #define UAUDIO_SYNC_LESS 2 }; -#define UMIDI_CABLES_MAX 16 /* units */ +#define UMIDI_EMB_JACK_MAX 16 /* units */ #define UMIDI_TX_FRAMES 256 /* units */ #define UMIDI_TX_BUFFER (UMIDI_TX_FRAMES * 4) /* bytes */ @@ -263,7 +263,7 @@ struct umidi_sub_chan { struct umidi_chan { - struct umidi_sub_chan sub[UMIDI_CABLES_MAX]; + struct umidi_sub_chan sub[UMIDI_EMB_JACK_MAX]; struct mtx mtx; struct usb_xfer *xfer[UMIDI_N_TRANSFER]; @@ -275,7 +275,7 @@ struct umidi_chan { uint8_t write_open_refcount; uint8_t curr_cable; - uint8_t max_cable; + uint8_t max_emb_jack; uint8_t valid; uint8_t single_command; }; @@ -1481,6 +1481,7 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev, union uaudio_asid asid = { NULL }; union uaudio_asf1d asf1d = { NULL }; union uaudio_sed sed = { NULL }; + struct usb_midi_streaming_endpoint_descriptor *msid = NULL; usb_endpoint_descriptor_audio_t *ed1 = NULL; const struct usb_audio_control_descriptor *acdp = NULL; struct usb_config_descriptor *cd = usbd_get_config_descriptor(udev); @@ -1498,6 +1499,7 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev, uint8_t bChannels; uint8_t bBitResolution; uint8_t audio_if = 0; + uint8_t midi_if = 0; uint8_t uma_if_class; while ((desc = usb_desc_foreach(cd, desc))) { @@ -1533,7 +1535,8 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev, ((id->bInterfaceClass == UICLASS_VENDOR) && (sc->sc_uq_au_vendor_class != 0))); - if ((uma_if_class != 0) && (id->bInterfaceSubClass == UISUBCLASS_AUDIOSTREAM)) { + if ((uma_if_class != 0) && + (id->bInterfaceSubClass == UISUBCLASS_AUDIOSTREAM)) { audio_if = 1; } else { audio_if = 0; @@ -1545,13 +1548,16 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev, /* * XXX could allow multiple MIDI interfaces */ + midi_if = 1; if ((sc->sc_midi_chan.valid == 0) && - usbd_get_iface(udev, curidx)) { + (usbd_get_iface(udev, curidx) != NULL)) { sc->sc_midi_chan.iface_index = curidx; sc->sc_midi_chan.iface_alt_index = alt_index; sc->sc_midi_chan.valid = 1; } + } else { + midi_if = 0; } asid.v1 = NULL; asf1d.v1 = NULL; @@ -1560,14 +1566,25 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev, } if (audio_if == 0) { - if ((acdp == NULL) && - (desc->bDescriptorType == UDESC_CS_INTERFACE) && - (desc->bDescriptorSubtype == UDESCSUB_AC_HEADER) && - (desc->bLength >= sizeof(*acdp))) { - acdp = (void *)desc; - audio_rev = UGETW(acdp->bcdADC); - } + if (midi_if == 0) { + if ((acdp == NULL) && + (desc->bDescriptorType == UDESC_CS_INTERFACE) && + (desc->bDescriptorSubtype == UDESCSUB_AC_HEADER) && + (desc->bLength >= sizeof(*acdp))) { + acdp = (void *)desc; + audio_rev = UGETW(acdp->bcdADC); + } + } else { + msid = (void *)desc; + /* get the maximum number of embedded jacks in use, if any */ + if (msid->bLength >= sizeof(*msid) && + msid->bDescriptorType == UDESC_CS_ENDPOINT && + msid->bDescriptorSubtype == MS_GENERAL && + msid->bNumEmbMIDIJack > sc->sc_midi_chan.max_emb_jack) { + sc->sc_midi_chan.max_emb_jack = msid->bNumEmbMIDIJack; + } + } /* * Don't collect any USB audio descriptors if * this is not an USB audio stream interface. @@ -2724,14 +2741,14 @@ uaudio_mixer_controls_create_ftu(struct uaudio_softc *sc) uaudio_mixer_add_ctl(sc, &MIX(sc)); - MIX(sc).wValue[0] = MAKE_WORD(9, chy + 1); + MIX(sc).wValue[0] = MAKE_WORD(9, chy + 1 + 8); MIX(sc).type = MIX_SIGNED_16; MIX(sc).ctl = SOUND_MIXER_NRDEVICES; MIX(sc).name = "effect_send"; MIX(sc).nchan = 1; MIX(sc).update[0] = 1; snprintf(MIX(sc).desc, sizeof(MIX(sc).desc), - "Effect Send DIn%d Volume", chy + 1 + 8); + "Effect Send DIn%d Volume", chy + 1); uaudio_mixer_add_ctl(sc, &MIX(sc)); } @@ -5219,8 +5236,7 @@ umidi_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) */ sub = &chan->sub[cn]; - if ((cmd_len != 0) && - (cn < chan->max_cable) && + if ((cmd_len != 0) && (cn < chan->max_emb_jack) && (sub->read_open != 0)) { /* Send data to the application */ @@ -5456,7 +5472,7 @@ umidi_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) } chan->curr_cable++; - if (chan->curr_cable >= chan->max_cable) + if (chan->curr_cable >= chan->max_emb_jack) chan->curr_cable = 0; if (chan->curr_cable == start_cable) { @@ -5493,7 +5509,7 @@ umidi_sub_by_fifo(struct usb_fifo *fifo) struct umidi_sub_chan *sub; uint32_t n; - for (n = 0; n < UMIDI_CABLES_MAX; n++) { + for (n = 0; n < UMIDI_EMB_JACK_MAX; n++) { sub = &chan->sub[n]; if ((sub->fifo.fp[USB_FIFO_RX] == fifo) || (sub->fifo.fp[USB_FIFO_TX] == fifo)) { @@ -5676,12 +5692,12 @@ umidi_probe(device_t dev) if (chan->single_command != 0) device_printf(dev, "Single command MIDI quirk enabled\n"); - if ((chan->max_cable > UMIDI_CABLES_MAX) || - (chan->max_cable == 0)) { - chan->max_cable = UMIDI_CABLES_MAX; + if ((chan->max_emb_jack == 0) || + (chan->max_emb_jack > UMIDI_EMB_JACK_MAX)) { + chan->max_emb_jack = UMIDI_EMB_JACK_MAX; } - for (n = 0; n < chan->max_cable; n++) { + for (n = 0; n < chan->max_emb_jack; n++) { sub = &chan->sub[n]; @@ -5719,9 +5735,8 @@ umidi_detach(device_t dev) struct umidi_chan *chan = &sc->sc_midi_chan; uint32_t n; - for (n = 0; n < UMIDI_CABLES_MAX; n++) { + for (n = 0; n < UMIDI_EMB_JACK_MAX; n++) usb_fifo_detach(&chan->sub[n].fifo); - } mtx_lock(&chan->mtx); diff --git a/sys/dev/sound/usb/uaudioreg.h b/sys/dev/sound/usb/uaudioreg.h index c2c1ad4b077f..637b5b1c0f23 100644 --- a/sys/dev/sound/usb/uaudioreg.h +++ b/sys/dev/sound/usb/uaudioreg.h @@ -119,6 +119,13 @@ struct usb_audio_streaming_endpoint_descriptor { uWord wLockDelay; } __packed; +struct usb_midi_streaming_endpoint_descriptor { + uByte bLength; + uByte bDescriptorType; + uByte bDescriptorSubtype; + uByte bNumEmbMIDIJack; +} __packed; + struct usb_audio_streaming_type1_descriptor { uByte bLength; uByte bDescriptorType; @@ -378,6 +385,7 @@ struct usb_audio_extension_unit_1 { #define MASTER_CHAN 0 +#define MS_GENERAL 1 #define AS_GENERAL 1 #define FORMAT_TYPE 2 #define FORMAT_SPECIFIC 3 diff --git a/sys/dev/ste/if_ste.c b/sys/dev/ste/if_ste.c index edc173b96fea..e6cffb3d23b2 100644 --- a/sys/dev/ste/if_ste.c +++ b/sys/dev/ste/if_ste.c @@ -622,7 +622,7 @@ ste_rxeof(struct ste_softc *sc, int count) * comes up in the ring. */ if (rxstat & STE_RXSTAT_FRAME_ERR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->ste_ptr->ste_status = 0; continue; } @@ -639,7 +639,7 @@ ste_rxeof(struct ste_softc *sc, int count) * can do in this situation. */ if (ste_newbuf(sc, cur_rx) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); cur_rx->ste_ptr->ste_status = 0; continue; } @@ -647,7 +647,7 @@ ste_rxeof(struct ste_softc *sc, int count) m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = total_len; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); STE_UNLOCK(sc); (*ifp->if_input)(ifp, m); STE_LOCK(sc); @@ -690,7 +690,7 @@ ste_txeoc(struct ste_softc *sc) if ((txstat & (STE_TXSTATUS_UNDERRUN | STE_TXSTATUS_EXCESSCOLLS | STE_TXSTATUS_RECLAIMERR | STE_TXSTATUS_STATSOFLOW)) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); #ifdef STE_SHOW_TXERRORS device_printf(sc->ste_dev, "TX error : 0x%b\n", txstat & 0xFF, STE_ERR_BITS); @@ -791,7 +791,7 @@ ste_txeof(struct ste_softc *sc) m_freem(cur_tx->ste_mbuf); cur_tx->ste_mbuf = NULL; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->ste_cdata.ste_tx_cnt--; STE_INC(idx, STE_TX_LIST_CNT); } @@ -860,13 +860,13 @@ ste_stats_update(struct ste_softc *sc) stats->tx_carrsense_errs += CSR_READ_1(sc, STE_STAT_CARRIER_ERR); val = CSR_READ_1(sc, STE_STAT_SINGLE_COLLS); stats->tx_single_colls += val; - ifp->if_collisions += val; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, val); val = CSR_READ_1(sc, STE_STAT_MULTI_COLLS); stats->tx_multi_colls += val; - ifp->if_collisions += val; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, val); val += CSR_READ_1(sc, STE_STAT_LATE_COLLS); stats->tx_late_colls += val; - ifp->if_collisions += val; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, val); stats->tx_frames_defered += CSR_READ_1(sc, STE_STAT_TX_DEFER); stats->tx_excess_defers += CSR_READ_1(sc, STE_STAT_TX_EXDEFER); stats->tx_abort += CSR_READ_1(sc, STE_STAT_TX_ABORT); @@ -1960,7 +1960,7 @@ ste_watchdog(struct ste_softc *sc) if (sc->ste_timer == 0 || --sc->ste_timer) return; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); ste_txeof(sc); diff --git a/sys/dev/stge/if_stge.c b/sys/dev/stge/if_stge.c index 16eccf5846c7..a93dda7b0e8b 100644 --- a/sys/dev/stge/if_stge.c +++ b/sys/dev/stge/if_stge.c @@ -1236,7 +1236,7 @@ stge_watchdog(struct stge_softc *sc) ifp = sc->sc_ifp; if_printf(sc->sc_ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; stge_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -1684,7 +1684,7 @@ stge_rxeof(struct stge_softc *sc) * Add a new receive buffer to the ring. */ if (stge_newbuf(sc, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); stge_discard_rxbuf(sc, cons); if (sc->sc_cdata.stge_rxhead != NULL) { m_freem(sc->sc_cdata.stge_rxhead); @@ -1874,22 +1874,22 @@ stge_stats_update(struct stge_softc *sc) CSR_READ_4(sc,STGE_OctetRcvOk); - ifp->if_ipackets += CSR_READ_4(sc, STGE_FramesRcvdOk); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, CSR_READ_4(sc, STGE_FramesRcvdOk)); - ifp->if_ierrors += CSR_READ_2(sc, STGE_FramesLostRxErrors); + if_inc_counter(ifp, IFCOUNTER_IERRORS, CSR_READ_2(sc, STGE_FramesLostRxErrors)); CSR_READ_4(sc, STGE_OctetXmtdOk); - ifp->if_opackets += CSR_READ_4(sc, STGE_FramesXmtdOk); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, CSR_READ_4(sc, STGE_FramesXmtdOk)); - ifp->if_collisions += + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, CSR_READ_4(sc, STGE_LateCollisions) + CSR_READ_4(sc, STGE_MultiColFrames) + - CSR_READ_4(sc, STGE_SingleColFrames); + CSR_READ_4(sc, STGE_SingleColFrames)); - ifp->if_oerrors += + if_inc_counter(ifp, IFCOUNTER_OERRORS, CSR_READ_2(sc, STGE_FramesAbortXSColls) + - CSR_READ_2(sc, STGE_FramesWEXDeferal); + CSR_READ_2(sc, STGE_FramesWEXDeferal)); } /* diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index fa63aa9543bb..7d0fc9d318f5 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -184,13 +184,13 @@ static int ti_detach(device_t); static void ti_txeof(struct ti_softc *); static void ti_rxeof(struct ti_softc *); -static void ti_stats_update(struct ti_softc *); static int ti_encap(struct ti_softc *, struct mbuf **); static void ti_intr(void *); static void ti_start(struct ifnet *); static void ti_start_locked(struct ifnet *); static int ti_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t ti_get_counter(struct ifnet *, ift_counter); static void ti_init(void *); static void ti_init_locked(void *); static void ti_init2(struct ti_softc *); @@ -959,8 +959,6 @@ ti_handle_events(struct ti_softc *sc) ti_init2(sc); break; case TI_EV_STATS_UPDATED: - ti_stats_update(sc); - break; case TI_EV_RESET_JUMBO_RING: case TI_EV_MCAST_UPDATED: /* Who cares. */ @@ -2505,6 +2503,7 @@ ti_attach(device_t dev) ifp->if_ioctl = ti_ioctl; ifp->if_start = ti_start; ifp->if_init = ti_init; + ifp->if_get_counter = ti_get_counter; ifp->if_baudrate = IF_Gbps(1UL); ifp->if_snd.ifq_drv_maxlen = TI_TX_RING_CNT - 1; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); @@ -2803,12 +2802,12 @@ ti_rxeof(struct ti_softc *sc) m = sc->ti_cdata.ti_rx_jumbo_chain[rxidx]; #ifndef TI_SF_BUF_JUMBO if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ti_discard_jumbo(sc, rxidx); continue; } if (ti_newbuf_jumbo(sc, rxidx, NULL) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); ti_discard_jumbo(sc, rxidx); continue; } @@ -2820,12 +2819,12 @@ ti_rxeof(struct ti_softc *sc) BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->ti_cdata.ti_rx_jumbo_tag, map); if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ti_newbuf_jumbo(sc, sc->ti_jumbo, m); continue; } if (ti_newbuf_jumbo(sc, sc->ti_jumbo, NULL) == ENOBUFS) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); ti_newbuf_jumbo(sc, sc->ti_jumbo, m); continue; } @@ -2842,12 +2841,12 @@ ti_rxeof(struct ti_softc *sc) TI_INC(sc->ti_mini, TI_MINI_RX_RING_CNT); m = sc->ti_cdata.ti_rx_mini_chain[rxidx]; if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ti_discard_mini(sc, rxidx); continue; } if (ti_newbuf_mini(sc, rxidx) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); ti_discard_mini(sc, rxidx); continue; } @@ -2857,12 +2856,12 @@ ti_rxeof(struct ti_softc *sc) TI_INC(sc->ti_std, TI_STD_RX_RING_CNT); m = sc->ti_cdata.ti_rx_std_chain[rxidx]; if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ti_discard_std(sc, rxidx); continue; } if (ti_newbuf_std(sc, rxidx) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); ti_discard_std(sc, rxidx); continue; } @@ -2870,7 +2869,7 @@ ti_rxeof(struct ti_softc *sc) } m->m_pkthdr.len = ti_len; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; if (ifp->if_capenable & IFCAP_RXCSUM) { @@ -2961,7 +2960,7 @@ ti_txeof(struct ti_softc *sc) BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(txd->tx_m); txd->tx_m = NULL; STAILQ_REMOVE_HEAD(&sc->ti_cdata.ti_txbusyq, tx_q); @@ -3016,27 +3015,35 @@ ti_intr(void *xsc) TI_UNLOCK(sc); } -static void -ti_stats_update(struct ti_softc *sc) +static uint64_t +ti_get_counter(struct ifnet *ifp, ift_counter cnt) { - struct ifnet *ifp; - struct ti_stats *s; - ifp = sc->ti_ifp; + switch (cnt) { + case IFCOUNTER_COLLISIONS: + { + struct ti_softc *sc; + struct ti_stats *s; + uint64_t rv; - if (sc->ti_stat_ticks == 0) - return; - bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, sc->ti_cdata.ti_gib_map, - BUS_DMASYNC_POSTREAD); + sc = if_getsoftc(ifp); + s = &sc->ti_rdata.ti_info->ti_stats; - s = &sc->ti_rdata.ti_info->ti_stats; - ifp->if_collisions += (s->dot3StatsSingleCollisionFrames + - s->dot3StatsMultipleCollisionFrames + - s->dot3StatsExcessiveCollisions + s->dot3StatsLateCollisions) - - ifp->if_collisions; - - bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, sc->ti_cdata.ti_gib_map, - BUS_DMASYNC_PREREAD); + TI_LOCK(sc); + bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, + sc->ti_cdata.ti_gib_map, BUS_DMASYNC_POSTREAD); + rv = s->dot3StatsSingleCollisionFrames + + s->dot3StatsMultipleCollisionFrames + + s->dot3StatsExcessiveCollisions + + s->dot3StatsLateCollisions; + bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, + sc->ti_cdata.ti_gib_map, BUS_DMASYNC_PREREAD); + TI_UNLOCK(sc); + return (rv); + } + default: + return (if_get_counter_default(ifp, cnt)); + } } /* @@ -3662,6 +3669,8 @@ ti_ioctl2(struct cdev *dev, u_long cmd, caddr_t addr, int flag, sc->ti_cdata.ti_gib_map, BUS_DMASYNC_POSTREAD); bcopy(&sc->ti_rdata.ti_info->ti_stats, outstats, sizeof(struct ti_stats)); + bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, + sc->ti_cdata.ti_gib_map, BUS_DMASYNC_PREREAD); TI_UNLOCK(sc); break; } @@ -3917,7 +3926,7 @@ ti_watchdog(void *arg) ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ti_init_locked(sc); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* diff --git a/sys/dev/tl/if_tl.c b/sys/dev/tl/if_tl.c index 754c9455a820..8535b046565f 100644 --- a/sys/dev/tl/if_tl.c +++ b/sys/dev/tl/if_tl.c @@ -1430,7 +1430,7 @@ tl_intvec_rxeof(xsc, type) total_len = cur_rx->tl_ptr->tlist_frsize; if (tl_newbuf(sc, cur_rx) == ENOBUFS) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->tl_ptr->tlist_frsize = MCLBYTES; cur_rx->tl_ptr->tlist_cstat = TL_CSTAT_READY; cur_rx->tl_ptr->tl_frag.tlist_dcnt = MCLBYTES; @@ -1726,13 +1726,13 @@ tl_stats_update(xsc) *p++ = CSR_READ_4(sc, TL_DIO_DATA); *p++ = CSR_READ_4(sc, TL_DIO_DATA); - ifp->if_opackets += tl_tx_goodframes(tl_stats); - ifp->if_collisions += tl_stats.tl_tx_single_collision + - tl_stats.tl_tx_multi_collision; - ifp->if_ipackets += tl_rx_goodframes(tl_stats); - ifp->if_ierrors += tl_stats.tl_crc_errors + tl_stats.tl_code_errors + - tl_rx_overrun(tl_stats); - ifp->if_oerrors += tl_tx_underrun(tl_stats); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, tl_tx_goodframes(tl_stats)); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + tl_stats.tl_tx_single_collision + tl_stats.tl_tx_multi_collision); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, tl_rx_goodframes(tl_stats)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, tl_stats.tl_crc_errors + + tl_stats.tl_code_errors + tl_rx_overrun(tl_stats)); + if_inc_counter(ifp, IFCOUNTER_OERRORS, tl_tx_underrun(tl_stats)); if (tl_tx_underrun(tl_stats)) { u_int8_t tx_thresh; @@ -2186,7 +2186,7 @@ tl_watchdog(sc) if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); tl_softreset(sc, 1); tl_init_locked(sc); diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index c6e57e954426..7ec2f986ef65 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -687,7 +687,7 @@ tsec_watchdog(struct tsec_softc *sc) return; ifp = sc->tsec_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); tsec_stop(sc); @@ -1349,7 +1349,7 @@ tsec_receive_intr_locked(struct tsec_softc *sc, int count) if (tsec_new_rxbuf(sc->tsec_rx_mtag, rx_data[i].map, &rx_data[i].mbuf, &rx_data[i].paddr)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); /* * We ran out of mbufs; didn't consume current * descriptor and have to return it to the queue. @@ -1430,7 +1430,7 @@ tsec_transmit_intr_locked(struct tsec_softc *sc) ifp = sc->tsec_ifp; /* Update collision statistics */ - ifp->if_collisions += TSEC_READ(sc, TSEC_REG_MON_TNCL); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, TSEC_READ(sc, TSEC_REG_MON_TNCL)); /* Reset collision counters in hardware */ TSEC_WRITE(sc, TSEC_REG_MON_TSCL, 0); @@ -1465,7 +1465,7 @@ tsec_transmit_intr_locked(struct tsec_softc *sc) TSEC_FREE_TX_MAP(sc, mapp); m_freem(m0); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); send = 1; } bus_dmamap_sync(sc->tsec_tx_dtag, sc->tsec_tx_dmap, @@ -1522,18 +1522,18 @@ tsec_error_intr_locked(struct tsec_softc *sc, int count) /* Check transmitter errors */ if (eflags & TSEC_IEVENT_TXE) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (eflags & TSEC_IEVENT_LC) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); TSEC_WRITE(sc, TSEC_REG_TSTAT, TSEC_TSTAT_THLT); } /* Check receiver errors */ if (eflags & TSEC_IEVENT_BSY) { - ifp->if_ierrors++; - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); /* Get data from RX buffers */ tsec_receive_intr_locked(sc, count); @@ -1550,10 +1550,10 @@ tsec_error_intr_locked(struct tsec_softc *sc, int count) } if (eflags & TSEC_IEVENT_BABT) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (eflags & TSEC_IEVENT_BABR) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } void diff --git a/sys/dev/tws/tws.c b/sys/dev/tws/tws.c index 11013cbc2b55..a94ac25e948a 100644 --- a/sys/dev/tws/tws.c +++ b/sys/dev/tws/tws.c @@ -198,6 +198,7 @@ tws_attach(device_t dev) mtx_init( &sc->sim_lock, "tws_sim_lock", NULL, MTX_DEF); mtx_init( &sc->gen_lock, "tws_gen_lock", NULL, MTX_DEF); mtx_init( &sc->io_lock, "tws_io_lock", NULL, MTX_DEF | MTX_RECURSE); + callout_init(&sc->stats_timer, CALLOUT_MPSAFE); if ( tws_init_trace_q(sc) == FAILURE ) printf("trace init failure\n"); @@ -408,11 +409,20 @@ tws_detach(device_t dev) TWS_TRACE(sc, "bus release mem resource", 0, sc->reg_res_id); } + for ( i=0; i< tws_queue_depth; i++) { + if (sc->reqs[i].dma_map) + bus_dmamap_destroy(sc->data_tag, sc->reqs[i].dma_map); + callout_drain(&sc->reqs[i].timeout); + } + + callout_drain(&sc->stats_timer); free(sc->reqs, M_TWS); free(sc->sense_bufs, M_TWS); free(sc->scan_ccb, M_TWS); if (sc->ioctl_data_mem) bus_dmamem_free(sc->data_tag, sc->ioctl_data_mem, sc->ioctl_data_map); + if (sc->data_tag) + bus_dma_tag_destroy(sc->data_tag); free(sc->aen_q.q, M_TWS); free(sc->trace_q.q, M_TWS); mtx_destroy(&sc->q_lock); @@ -709,7 +719,7 @@ tws_init_reqs(struct tws_softc *sc, u_int32_t dma_mem_size) sc->reqs[i].cmd_pkt->hdr.header_desc.size_header = 128; - callout_handle_init(&sc->reqs[i].thandle); + callout_init(&sc->reqs[i].timeout, CALLOUT_MPSAFE); sc->reqs[i].state = TWS_REQ_STATE_FREE; if ( i >= TWS_RESERVED_REQS ) tws_q_insert_tail(sc, &sc->reqs[i], TWS_FREE_Q); @@ -859,7 +869,7 @@ tws_get_request(struct tws_softc *sc, u_int16_t type) r->error_code = TWS_REQ_RET_INVALID; r->cb = NULL; r->ccb_ptr = NULL; - r->thandle.callout = NULL; + callout_stop(&r->timeout); r->next = r->prev = NULL; r->state = ((type == TWS_REQ_TYPE_SCSI_IO) ? TWS_REQ_STATE_TRAN : TWS_REQ_STATE_BUSY); diff --git a/sys/dev/tws/tws.h b/sys/dev/tws/tws.h index 11017300acc0..8cb9791c0ad8 100644 --- a/sys/dev/tws/tws.h +++ b/sys/dev/tws/tws.h @@ -268,4 +268,5 @@ struct tws_softc { union ccb *scan_ccb; /* pointer to a ccb */ struct tws_request *q_head[TWS_MAX_QS]; /* head pointers to q's */ struct tws_request *q_tail[TWS_MAX_QS]; /* tail pointers to q's */ + struct callout stats_timer; }; diff --git a/sys/dev/tws/tws_cam.c b/sys/dev/tws/tws_cam.c index cb94fee5f246..9b429d2542ed 100644 --- a/sys/dev/tws/tws_cam.c +++ b/sys/dev/tws/tws_cam.c @@ -341,7 +341,7 @@ tws_scsi_complete(struct tws_request *req) tws_q_remove_request(sc, req, TWS_BUSY_Q); mtx_unlock(&sc->q_lock); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(req->sc, req); @@ -362,7 +362,7 @@ tws_getset_param_complete(struct tws_request *req) TWS_TRACE_DEBUG(sc, "getset complete", req, req->request_id); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(sc, req); free(req->data, M_TWS); @@ -380,7 +380,7 @@ tws_aen_complete(struct tws_request *req) TWS_TRACE_DEBUG(sc, "aen complete", 0, req->request_id); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(sc, req); sense = (struct tws_command_header *)req->data; @@ -454,7 +454,7 @@ tws_cmd_complete(struct tws_request *req) { struct tws_softc *sc = req->sc; - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(sc, req); } @@ -561,7 +561,7 @@ tws_scsi_err_complete(struct tws_request *req, struct tws_command_header *hdr) xpt_done(ccb); mtx_unlock(&sc->sim_lock); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(req->sc, req); mtx_lock(&sc->q_lock); tws_q_remove_request(sc, req, TWS_BUSY_Q); @@ -591,7 +591,7 @@ tws_drain_busy_queue(struct tws_softc *sc) mtx_unlock(&sc->q_lock); while ( req ) { TWS_TRACE_DEBUG(sc, "moved to TWS_COMPLETE_Q", 0, req->request_id); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); req->error_code = TWS_REQ_RET_RESET; ccb = (union ccb *)(req->ccb_ptr); @@ -622,7 +622,7 @@ tws_drain_reserved_reqs(struct tws_softc *sc) r = &sc->reqs[TWS_REQ_TYPE_AEN_FETCH]; if ( r->state != TWS_REQ_STATE_FREE ) { TWS_TRACE_DEBUG(sc, "reset aen req", 0, 0); - untimeout(tws_timeout, r, r->thandle); + callout_stop(&r->timeout); tws_unmap_request(sc, r); free(r->data, M_TWS); r->state = TWS_REQ_STATE_FREE; @@ -638,7 +638,7 @@ tws_drain_reserved_reqs(struct tws_softc *sc) r = &sc->reqs[TWS_REQ_TYPE_GETSET_PARAM]; if ( r->state != TWS_REQ_STATE_FREE ) { TWS_TRACE_DEBUG(sc, "reset setparam req", 0, 0); - untimeout(tws_timeout, r, r->thandle); + callout_stop(&r->timeout); tws_unmap_request(sc, r); free(r->data, M_TWS); r->state = TWS_REQ_STATE_FREE; @@ -747,7 +747,7 @@ tws_execute_scsi(struct tws_softc *sc, union ccb *ccb) * and submit the I/O. */ sc->stats.scsi_ios++; - req->thandle = timeout(tws_timeout, req, (ccb_h->timeout * hz)/1000); + callout_reset(&req->timeout, (ccb_h->timeout * hz) / 1000, tws_timeout, req); error = tws_map_request(sc, req); return(error); } @@ -785,7 +785,7 @@ tws_send_scsi_cmd(struct tws_softc *sc, int cmd) bzero(req->data, TWS_SECTOR_SIZE); req->flags = TWS_DIR_IN; - req->thandle = timeout(tws_timeout, req, (TWS_IO_TIMEOUT * hz)); + callout_reset(&req->timeout, (TWS_IO_TIMEOUT * hz), tws_timeout, req); error = tws_map_request(sc, req); return(error); @@ -832,7 +832,7 @@ tws_set_param(struct tws_softc *sc, u_int32_t table_id, u_int32_t param_id, param->parameter_size_bytes = (u_int16_t)param_size; memcpy(param->data, data, param_size); - req->thandle = timeout(tws_timeout, req, (TWS_IOCTL_TIMEOUT * hz)); + callout_reset(&req->timeout, (TWS_IOCTL_TIMEOUT * hz), tws_timeout, req); error = tws_map_request(sc, req); return(error); @@ -1168,7 +1168,6 @@ tws_timeout(void *arg) return; } - tws_teardown_intr(sc); xpt_freeze_simq(sc->sim, 1); tws_send_event(sc, TWS_RESET_START); @@ -1191,7 +1190,6 @@ tws_timeout(void *arg) mtx_unlock(&sc->gen_lock); xpt_release_simq(sc->sim, 1); - tws_setup_intr(sc, sc->irqs); } void @@ -1205,7 +1203,6 @@ tws_reset(void *arg) return; } - tws_teardown_intr(sc); xpt_freeze_simq(sc->sim, 1); tws_send_event(sc, TWS_RESET_START); @@ -1222,7 +1219,6 @@ tws_reset(void *arg) mtx_unlock(&sc->gen_lock); xpt_release_simq(sc->sim, 1); - tws_setup_intr(sc, sc->irqs); } static void diff --git a/sys/dev/tws/tws_hdm.c b/sys/dev/tws/tws_hdm.c index f5bb3f16a636..2e568c8653fc 100644 --- a/sys/dev/tws/tws_hdm.c +++ b/sys/dev/tws/tws_hdm.c @@ -161,7 +161,7 @@ tws_init_connect(struct tws_softc *sc, u_int16_t mcreadits ) req->error_code = TWS_REQ_RET_INVALID; req->cb = NULL; req->ccb_ptr = NULL; - req->thandle.callout = NULL; + callout_stop(&req->timeout); req->next = req->prev = NULL; req->state = TWS_REQ_STATE_BUSY; #endif // 0 diff --git a/sys/dev/tws/tws_hdm.h b/sys/dev/tws/tws_hdm.h index 58feeeecf5bb..5cacf19b9326 100644 --- a/sys/dev/tws/tws_hdm.h +++ b/sys/dev/tws/tws_hdm.h @@ -410,7 +410,7 @@ struct tws_request { void (*cb)(struct tws_request *); /* callback func */ bus_dmamap_t dma_map; /* dma map */ union ccb *ccb_ptr; /* pointer to ccb */ - struct callout_handle thandle; /* handle to req timeout */ + struct callout timeout; /* request timeout timer */ struct tws_softc *sc; /* pointer back to ctlr softc */ struct tws_request *next; /* pointer to next request */ diff --git a/sys/dev/tws/tws_services.c b/sys/dev/tws/tws_services.c index d2a52cd5ff3f..243585b6b223 100644 --- a/sys/dev/tws/tws_services.c +++ b/sys/dev/tws/tws_services.c @@ -395,7 +395,6 @@ tws_print_stats(void *arg) , sc->stats.num_intrs); TWS_TRACE(sc, "reqs(ioctls, scsi)", sc->stats.ioctls , sc->stats.scsi_ios); - timeout(tws_print_stats, sc, 300*hz); - + callout_reset(&sc->stats_timer, 300 * hz, tws_print_stats, sc); } /* --------------------- misc service end --------------------- */ diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index 7a965588d908..7a12aee288d1 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -671,7 +671,7 @@ epic_ifstart_locked(struct ifnet * ifp) if (error && error != EFBIG) { m_freem(m0); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } @@ -683,7 +683,7 @@ epic_ifstart_locked(struct ifnet * ifp) m = m_defrag(m0, M_NOWAIT); if (m == NULL) { m_freem(m0); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } m_freem(m0); @@ -693,7 +693,7 @@ epic_ifstart_locked(struct ifnet * ifp) epic_dma_map_txbuf, flist, 0); if (error) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -748,7 +748,7 @@ epic_rx_done(epic_softc_t *sc) * RXE interrupt usually. */ if ((desc->status & 1) == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); desc->status = 0x8000; continue; } @@ -763,7 +763,7 @@ epic_rx_done(epic_softc_t *sc) if (buf->mbuf == NULL) { buf->mbuf = m; desc->status = 0x8000; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES; @@ -775,7 +775,7 @@ epic_rx_done(epic_softc_t *sc) if (error) { buf->mbuf = m; desc->status = 0x8000; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); continue; } @@ -796,7 +796,7 @@ epic_rx_done(epic_softc_t *sc) EPIC_LOCK(sc); /* Successfuly received frame */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } bus_dmamap_sync(sc->rtag, sc->rmap, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); @@ -838,10 +838,10 @@ epic_tx_done(epic_softc_t *sc) /* Check for errors and collisions. */ if (status & 0x0001) - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); else - sc->ifp->if_oerrors++; - sc->ifp->if_collisions += (status >> 8) & 0x1F; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, (status >> 8) & 0x1F); #ifdef EPIC_DIAG if ((status & 0x1001) == 0x1001) device_printf(sc->dev, @@ -881,7 +881,7 @@ epic_intr(void *arg) #endif if ((CSR_READ_4(sc, COMMAND) & COMMAND_RXQUEUED) == 0) CSR_WRITE_4(sc, COMMAND, COMMAND_RXQUEUED); - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } } @@ -911,12 +911,12 @@ epic_intr(void *arg) #ifdef EPIC_DIAG device_printf(sc->dev, "CRC/Alignment error\n"); #endif - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } if (status & INTSTAT_TXU) { epic_tx_underrun(sc); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); } } } @@ -981,7 +981,7 @@ epic_timer(void *arg) /* If not successful. */ if (sc->pending_txs > 0) { - ifp->if_oerrors += sc->pending_txs; + if_inc_counter(ifp, IFCOUNTER_OERRORS, sc->pending_txs); /* Reinitialize board. */ device_printf(sc->dev, "reinitialization\n"); diff --git a/sys/dev/txp/if_txp.c b/sys/dev/txp/if_txp.c index d000db43a895..8e0b91cf915a 100644 --- a/sys/dev/txp/if_txp.c +++ b/sys/dev/txp/if_txp.c @@ -149,6 +149,7 @@ static int txp_intr(void *); static void txp_int_task(void *, int); static void txp_tick(void *); static int txp_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t txp_get_counter(struct ifnet *, ift_counter); static void txp_start(struct ifnet *); static void txp_start_locked(struct ifnet *); static int txp_encap(struct txp_softc *, struct txp_tx_ring *, struct mbuf **); @@ -413,6 +414,7 @@ txp_attach(device_t dev) ifp->if_ioctl = txp_ioctl; ifp->if_start = txp_start; ifp->if_init = txp_init; + ifp->if_get_counter = txp_get_counter; ifp->if_snd.ifq_drv_maxlen = TX_ENTRIES - 1; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); IFQ_SET_READY(&ifp->if_snd); @@ -2540,7 +2542,7 @@ txp_watchdog(struct txp_softc *sc) ifp = sc->sc_ifp; if_printf(ifp, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); txp_stop(sc); txp_init_locked(sc); } @@ -2816,13 +2818,11 @@ txp_stats_save(struct txp_softc *sc) static void txp_stats_update(struct txp_softc *sc, struct txp_rsp_desc *rsp) { - struct ifnet *ifp; struct txp_hw_stats *ostats, *stats; struct txp_ext_desc *ext; TXP_LOCK_ASSERT(sc); - ifp = sc->sc_ifp; ext = (struct txp_ext_desc *)(rsp + 1); ostats = &sc->sc_ostats; stats = &sc->sc_stats; @@ -2856,15 +2856,34 @@ txp_stats_update(struct txp_softc *sc, struct txp_rsp_desc *rsp) le32toh(ext[4].ext_3); stats->rx_oflows = ostats->rx_oflows + le32toh(ext[4].ext_4); stats->rx_filtered = ostats->rx_filtered + le32toh(ext[5].ext_1); +} - ifp->if_ierrors = stats->rx_fifo_oflows + stats->rx_badssd + - stats->rx_crcerrs + stats->rx_lenerrs + stats->rx_oflows; - ifp->if_oerrors = stats->tx_deferred + stats->tx_carrier_lost + - stats->tx_fifo_underruns + stats->tx_mcast_oflows; - ifp->if_collisions = stats->tx_late_colls + stats->tx_multi_colls + - stats->tx_excess_colls; - ifp->if_opackets = stats->tx_frames; - ifp->if_ipackets = stats->rx_frames; +static uint64_t +txp_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct txp_softc *sc; + struct txp_hw_stats *stats; + + sc = if_getsoftc(ifp); + stats = &sc->sc_stats; + + switch (cnt) { + case IFCOUNTER_IERRORS: + return (stats->rx_fifo_oflows + stats->rx_badssd + + stats->rx_crcerrs + stats->rx_lenerrs + stats->rx_oflows); + case IFCOUNTER_OERRORS: + return (stats->tx_deferred + stats->tx_carrier_lost + + stats->tx_fifo_underruns + stats->tx_mcast_oflows); + case IFCOUNTER_COLLISIONS: + return (stats->tx_late_colls + stats->tx_multi_colls + + stats->tx_excess_colls); + case IFCOUNTER_OPACKETS: + return (stats->tx_frames); + case IFCOUNTER_IPACKETS: + return (stats->rx_frames); + default: + return (if_get_counter_default(ifp, cnt)); + } } #define TXP_SYSCTL_STAT_ADD32(c, h, n, p, d) \ diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h index 0bceddeabe35..8ab50224a7c9 100644 --- a/sys/dev/uart/uart.h +++ b/sys/dev/uart/uart.h @@ -65,6 +65,7 @@ struct uart_bas { struct uart_class; extern struct uart_class uart_imx_class __attribute__((weak)); +extern struct uart_class uart_msm_class __attribute__((weak)); extern struct uart_class uart_ns8250_class __attribute__((weak)); extern struct uart_class uart_quicc_class __attribute__((weak)); extern struct uart_class uart_s3c2410_class __attribute__((weak)); diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c index 92e155b34a7a..f52fec1e5936 100644 --- a/sys/dev/uart/uart_bus_fdt.c +++ b/sys/dev/uart/uart_bus_fdt.c @@ -84,6 +84,7 @@ static struct ofw_compat_data compat_data[] = { {"fsl,imx21-uart", (uintptr_t)&uart_imx_class}, {"fsl,mvf600-uart", (uintptr_t)&uart_vybrid_class}, {"lpc,uart", (uintptr_t)&uart_lpc_class}, + {"qcom,uart-dm", (uintptr_t)&uart_msm_class}, {"ti,ns16550", (uintptr_t)&uart_ti8250_class}, {"ns16550", (uintptr_t)&uart_ns8250_class}, {NULL, (uintptr_t)NULL}, diff --git a/sys/dev/uart/uart_dev_imx.c b/sys/dev/uart/uart_dev_imx.c index 43338febb6c6..2def18cbdbd1 100644 --- a/sys/dev/uart/uart_dev_imx.c +++ b/sys/dev/uart/uart_dev_imx.c @@ -90,6 +90,45 @@ imx_uart_probe(struct uart_bas *bas) return (0); } +static u_int +imx_uart_getbaud(struct uart_bas *bas) +{ + uint32_t rate, ubir, ubmr; + u_int baud, blo, bhi, i; + static const u_int predivs[] = {6, 5, 4, 3, 2, 1, 7, 1}; + static const u_int std_rates[] = { + 9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600 + }; + + /* + * Get the baud rate the hardware is programmed for, then search the + * table of standard baud rates for a number that's within 3% of the + * actual rate the hardware is programmed for. It's more comforting to + * see that your console is running at 115200 than 114942. Note that + * here we cannot make a simplifying assumption that the predivider and + * numerator are 1 (like we do when setting the baud rate), because we + * don't know what u-boot might have set up. + */ + i = (GETREG(bas, REG(UFCR)) & IMXUART_UFCR_RFDIV_MASK) >> + IMXUART_UFCR_RFDIV_SHIFT; + rate = imx_ccm_uart_hz() / predivs[i]; + ubir = GETREG(bas, REG(UBIR)) + 1; + ubmr = GETREG(bas, REG(UBMR)) + 1; + baud = ((rate / 16 ) * ubir) / ubmr; + + blo = (baud * 100) / 103; + bhi = (baud * 100) / 97; + for (i = 0; i < nitems(std_rates); i++) { + rate = std_rates[i]; + if (rate >= blo && rate <= bhi) { + baud = rate; + break; + } + } + + return (baud); +} + static void imx_uart_init(struct uart_bas *bas, int baudrate, int databits, int stopbits, int parity) @@ -348,8 +387,7 @@ imx_uart_bus_ioctl(struct uart_softc *sc, int request, intptr_t data) /* TODO */ break; case UART_IOCTL_BAUD: - /* TODO */ - *(int*)data = 115200; + *(u_int*)data = imx_uart_getbaud(bas); break; default: error = EINVAL; diff --git a/sys/dev/uart/uart_dev_msm.c b/sys/dev/uart/uart_dev_msm.c new file mode 100644 index 000000000000..12dc8a7b63cd --- /dev/null +++ b/sys/dev/uart/uart_dev_msm.c @@ -0,0 +1,568 @@ +/*- + * Copyright (c) 2014 Ganbold Tsagaankhuu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 ``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. + */ + +/* Qualcomm MSM7K/8K uart driver */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ddb.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "uart_if.h" + +#define DEF_CLK 7372800 + +#define GETREG(bas, reg) \ + bus_space_read_4((bas)->bst, (bas)->bsh, (reg)) +#define SETREG(bas, reg, value) \ + bus_space_write_4((bas)->bst, (bas)->bsh, (reg), (value)) + +static int msm_uart_param(struct uart_bas *, int, int, int, int); + +/* + * Low-level UART interface. + */ +static int msm_probe(struct uart_bas *bas); +static void msm_init(struct uart_bas *bas, int, int, int, int); +static void msm_term(struct uart_bas *bas); +static void msm_putc(struct uart_bas *bas, int); +static int msm_rxready(struct uart_bas *bas); +static int msm_getc(struct uart_bas *bas, struct mtx *mtx); + +extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; + +static int +msm_uart_param(struct uart_bas *bas, int baudrate, int databits, + int stopbits, int parity) +{ + int ulcon; + + ulcon = 0; + + switch (databits) { + case 5: + ulcon |= (UART_DM_5_BPS << 4); + break; + case 6: + ulcon |= (UART_DM_6_BPS << 4); + break; + case 7: + ulcon |= (UART_DM_7_BPS << 4); + break; + case 8: + ulcon |= (UART_DM_8_BPS << 4); + break; + default: + return (EINVAL); + } + + switch (parity) { + case UART_PARITY_NONE: + ulcon |= UART_DM_NO_PARITY; + break; + case UART_PARITY_ODD: + ulcon |= UART_DM_ODD_PARITY; + break; + case UART_PARITY_EVEN: + ulcon |= UART_DM_EVEN_PARITY; + break; + case UART_PARITY_SPACE: + ulcon |= UART_DM_SPACE_PARITY; + break; + case UART_PARITY_MARK: + default: + return (EINVAL); + } + + switch (stopbits) { + case 1: + ulcon |= (UART_DM_SBL_1 << 2); + break; + case 2: + ulcon |= (UART_DM_SBL_2 << 2); + break; + default: + return (EINVAL); + } + uart_setreg(bas, UART_DM_MR2, ulcon); + + /* Set 115200 for both TX and RX. */; + uart_setreg(bas, UART_DM_CSR, UART_DM_CSR_115200); + uart_barrier(bas); + + return (0); +} + +struct uart_ops uart_msm_ops = { + .probe = msm_probe, + .init = msm_init, + .term = msm_term, + .putc = msm_putc, + .rxready = msm_rxready, + .getc = msm_getc, +}; + +static int +msm_probe(struct uart_bas *bas) +{ + + return (0); +} + +static void +msm_init(struct uart_bas *bas, int baudrate, int databits, int stopbits, + int parity) +{ + + if (bas->rclk == 0) + bas->rclk = DEF_CLK; + + KASSERT(bas->rclk != 0, ("msm_init: Invalid rclk")); + + /* Set default parameters */ + msm_uart_param(bas, baudrate, databits, stopbits, parity); + + /* + * Configure UART mode registers MR1 and MR2. + * Hardware flow control isn't supported. + */ + uart_setreg(bas, UART_DM_MR1, 0x0); + + /* Reset interrupt mask register. */ + uart_setreg(bas, UART_DM_IMR, 0); + + /* + * Configure Tx and Rx watermarks configuration registers. + * TX watermark value is set to 0 - interrupt is generated when + * FIFO level is less than or equal to 0. + */ + uart_setreg(bas, UART_DM_TFWR, UART_DM_TFW_VALUE); + + /* Set RX watermark value */ + uart_setreg(bas, UART_DM_RFWR, UART_DM_RFW_VALUE); + + /* + * Configure Interrupt Programming Register. + * Set initial Stale timeout value. + */ + uart_setreg(bas, UART_DM_IPR, UART_DM_STALE_TIMEOUT_LSB); + + /* Disable IRDA mode */ + uart_setreg(bas, UART_DM_IRDA, 0x0); + + /* + * Configure and enable sim interface if required. + * Configure hunt character value in HCR register. + * Keep it in reset state. + */ + uart_setreg(bas, UART_DM_HCR, 0x0); + + /* Issue soft reset command */ + SETREG(bas, UART_DM_CR, UART_DM_RESET_TX); + SETREG(bas, UART_DM_CR, UART_DM_RESET_RX); + SETREG(bas, UART_DM_CR, UART_DM_RESET_ERROR_STATUS); + SETREG(bas, UART_DM_CR, UART_DM_RESET_BREAK_INT); + SETREG(bas, UART_DM_CR, UART_DM_RESET_STALE_INT); + + /* Enable/Disable Rx/Tx DM interfaces */ + /* Disable Data Mover for now. */ + uart_setreg(bas, UART_DM_DMEN, 0x0); + + /* Enable transmitter and receiver */ + uart_setreg(bas, UART_DM_CR, UART_DM_CR_RX_ENABLE); + uart_setreg(bas, UART_DM_CR, UART_DM_CR_TX_ENABLE); + + uart_barrier(bas); +} + +static void +msm_term(struct uart_bas *bas) +{ + + /* XXX */ +} + +static void +msm_putc(struct uart_bas *bas, int c) +{ + int limit; + + /* + * Write to NO_CHARS_FOR_TX register the number of characters + * to be transmitted. However, before writing TX_FIFO must + * be empty as indicated by TX_READY interrupt in IMR register + */ + + /* + * Check if transmit FIFO is empty. + * If not wait for TX_READY interrupt. + */ + limit = 1000; + if (!(uart_getreg(bas, UART_DM_SR) & UART_DM_SR_TXEMT)) { + while ((uart_getreg(bas, UART_DM_ISR) & UART_DM_TX_READY) == 0 + && --limit) + DELAY(4); + } + /* FIFO is ready, write number of characters to be written */ + uart_setreg(bas, UART_DM_NO_CHARS_FOR_TX, 1); + + /* Wait till TX FIFO has space */ + while ((uart_getreg(bas, UART_DM_SR) & UART_DM_SR_TXRDY) == 0) + DELAY(4); + + /* TX FIFO has space. Write char */ + SETREG(bas, UART_DM_TF(0), (c & 0xff)); +} + +static int +msm_rxready(struct uart_bas *bas) +{ + + /* Wait for a character to come ready */ + return ((uart_getreg(bas, UART_DM_SR) & UART_DM_SR_RXRDY) == + UART_DM_SR_RXRDY); +} + +static int +msm_getc(struct uart_bas *bas, struct mtx *mtx) +{ + int c; + + uart_lock(mtx); + + /* Wait for a character to come ready */ + while ((uart_getreg(bas, UART_DM_SR) & UART_DM_SR_RXRDY) != + UART_DM_SR_RXRDY) + DELAY(4); + + /* Check for Overrun error. If so reset Error Status */ + if (uart_getreg(bas, UART_DM_SR) & UART_DM_SR_UART_OVERRUN) + uart_setreg(bas, UART_DM_CR, UART_DM_RESET_ERROR_STATUS); + + /* Read char */ + c = uart_getreg(bas, UART_DM_RF(0)); + + uart_unlock(mtx); + + return (c); +} + +/* + * High-level UART interface. + */ +struct msm_uart_softc { + struct uart_softc base; + uint32_t ier; +}; + +static int msm_bus_probe(struct uart_softc *sc); +static int msm_bus_attach(struct uart_softc *sc); +static int msm_bus_flush(struct uart_softc *, int); +static int msm_bus_getsig(struct uart_softc *); +static int msm_bus_ioctl(struct uart_softc *, int, intptr_t); +static int msm_bus_ipend(struct uart_softc *); +static int msm_bus_param(struct uart_softc *, int, int, int, int); +static int msm_bus_receive(struct uart_softc *); +static int msm_bus_setsig(struct uart_softc *, int); +static int msm_bus_transmit(struct uart_softc *); +static void msm_bus_grab(struct uart_softc *); +static void msm_bus_ungrab(struct uart_softc *); + +static kobj_method_t msm_methods[] = { + KOBJMETHOD(uart_probe, msm_bus_probe), + KOBJMETHOD(uart_attach, msm_bus_attach), + KOBJMETHOD(uart_flush, msm_bus_flush), + KOBJMETHOD(uart_getsig, msm_bus_getsig), + KOBJMETHOD(uart_ioctl, msm_bus_ioctl), + KOBJMETHOD(uart_ipend, msm_bus_ipend), + KOBJMETHOD(uart_param, msm_bus_param), + KOBJMETHOD(uart_receive, msm_bus_receive), + KOBJMETHOD(uart_setsig, msm_bus_setsig), + KOBJMETHOD(uart_transmit, msm_bus_transmit), + KOBJMETHOD(uart_grab, msm_bus_grab), + KOBJMETHOD(uart_ungrab, msm_bus_ungrab), + {0, 0 } +}; + +int +msm_bus_probe(struct uart_softc *sc) +{ + + sc->sc_txfifosz = 64; + sc->sc_rxfifosz = 64; + + device_set_desc(sc->sc_dev, "Qualcomm HSUART"); + + return (0); +} + +static int +msm_bus_attach(struct uart_softc *sc) +{ + struct msm_uart_softc *u = (struct msm_uart_softc *)sc; + struct uart_bas *bas = &sc->sc_bas; + + sc->sc_hwiflow = 0; + sc->sc_hwoflow = 0; + + /* Set TX_READY, TXLEV, RXLEV, RXSTALE */ + u->ier = UART_DM_IMR_ENABLED; + + /* Configure Interrupt Mask register IMR */ + uart_setreg(bas, UART_DM_IMR, u->ier); + + return (0); +} + +/* + * Write the current transmit buffer to the TX FIFO. + */ +static int +msm_bus_transmit(struct uart_softc *sc) +{ + struct msm_uart_softc *u = (struct msm_uart_softc *)sc; + struct uart_bas *bas = &sc->sc_bas; + int i; + + uart_lock(sc->sc_hwmtx); + + /* Write some data */ + for (i = 0; i < sc->sc_txdatasz; i++) { + /* Write TX data */ + msm_putc(bas, sc->sc_txbuf[i]); + uart_barrier(bas); + } + + /* TX FIFO is empty now, enable TX_READY interrupt */ + u->ier |= UART_DM_TX_READY; + SETREG(bas, UART_DM_IMR, u->ier); + uart_barrier(bas); + + /* + * Inform upper layer that it is transmitting data to hardware, + * this will be cleared when TXIDLE interrupt occurs. + */ + sc->sc_txbusy = 1; + uart_unlock(sc->sc_hwmtx); + + return (0); +} + +static int +msm_bus_setsig(struct uart_softc *sc, int sig) +{ + + return (0); +} + +static int +msm_bus_receive(struct uart_softc *sc) +{ + struct msm_uart_softc *u = (struct msm_uart_softc *)sc; + struct uart_bas *bas; + int c; + + bas = &sc->sc_bas; + uart_lock(sc->sc_hwmtx); + + /* Initialize Receive Path and interrupt */ + SETREG(bas, UART_DM_CR, UART_DM_RESET_STALE_INT); + SETREG(bas, UART_DM_CR, UART_DM_STALE_EVENT_ENABLE); + u->ier |= UART_DM_RXLEV; + SETREG(bas, UART_DM_IMR, u->ier); + + /* Loop over until we are full, or no data is available */ + while (uart_getreg(bas, UART_DM_SR) & UART_DM_SR_RXRDY) { + if (uart_rx_full(sc)) { + /* No space left in input buffer */ + sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN; + break; + } + + /* Read RX FIFO */ + c = uart_getreg(bas, UART_DM_RF(0)); + uart_barrier(bas); + + uart_rx_put(sc, c); + } + + uart_unlock(sc->sc_hwmtx); + + return (0); +} + +static int +msm_bus_param(struct uart_softc *sc, int baudrate, int databits, + int stopbits, int parity) +{ + int error; + + if (sc->sc_bas.rclk == 0) + sc->sc_bas.rclk = DEF_CLK; + + KASSERT(sc->sc_bas.rclk != 0, ("msm_init: Invalid rclk")); + + uart_lock(sc->sc_hwmtx); + error = msm_uart_param(&sc->sc_bas, baudrate, databits, stopbits, + parity); + uart_unlock(sc->sc_hwmtx); + + return (error); +} + +static int +msm_bus_ipend(struct uart_softc *sc) +{ + struct msm_uart_softc *u = (struct msm_uart_softc *)sc; + struct uart_bas *bas = &sc->sc_bas; + uint32_t isr; + int ipend; + + uart_lock(sc->sc_hwmtx); + + /* Get ISR status */ + isr = GETREG(bas, UART_DM_MISR); + + ipend = 0; + + /* Uart RX starting, notify upper layer */ + if (isr & UART_DM_RXLEV) { + u->ier &= ~UART_DM_RXLEV; + SETREG(bas, UART_DM_IMR, u->ier); + uart_barrier(bas); + ipend |= SER_INT_RXREADY; + } + + /* Stale RX interrupt */ + if (isr & UART_DM_RXSTALE) { + /* Disable and reset it */ + SETREG(bas, UART_DM_CR, UART_DM_STALE_EVENT_DISABLE); + SETREG(bas, UART_DM_CR, UART_DM_RESET_STALE_INT); + uart_barrier(bas); + ipend |= SER_INT_RXREADY; + } + + /* TX READY interrupt */ + if (isr & UART_DM_TX_READY) { + /* Clear TX Ready */ + SETREG(bas, UART_DM_CR, UART_DM_CLEAR_TX_READY); + + /* Disable TX_READY */ + u->ier &= ~UART_DM_TX_READY; + SETREG(bas, UART_DM_IMR, u->ier); + uart_barrier(bas); + + if (sc->sc_txbusy != 0) + ipend |= SER_INT_TXIDLE; + } + + if (isr & UART_DM_TXLEV) { + /* TX FIFO is empty */ + u->ier &= ~UART_DM_TXLEV; + SETREG(bas, UART_DM_IMR, u->ier); + uart_barrier(bas); + + if (sc->sc_txbusy != 0) + ipend |= SER_INT_TXIDLE; + } + + uart_unlock(sc->sc_hwmtx); + return (ipend); +} + +static int +msm_bus_flush(struct uart_softc *sc, int what) +{ + + return (0); +} + +static int +msm_bus_getsig(struct uart_softc *sc) +{ + + return (0); +} + +static int +msm_bus_ioctl(struct uart_softc *sc, int request, intptr_t data) +{ + + return (EINVAL); +} + +static void +msm_bus_grab(struct uart_softc *sc) +{ + struct uart_bas *bas = &sc->sc_bas; + + /* + * XXX: Turn off all interrupts to enter polling mode. Leave the + * saved mask alone. We'll restore whatever it was in ungrab. + */ + uart_lock(sc->sc_hwmtx); + SETREG(bas, UART_DM_CR, UART_DM_RESET_STALE_INT); + SETREG(bas, UART_DM_IMR, 0); + uart_barrier(bas); + uart_unlock(sc->sc_hwmtx); +} + +static void +msm_bus_ungrab(struct uart_softc *sc) +{ + struct msm_uart_softc *u = (struct msm_uart_softc *)sc; + struct uart_bas *bas = &sc->sc_bas; + + /* + * Restore previous interrupt mask + */ + uart_lock(sc->sc_hwmtx); + SETREG(bas, UART_DM_IMR, u->ier); + uart_barrier(bas); + uart_unlock(sc->sc_hwmtx); +} + +struct uart_class uart_msm_class = { + "msm", + msm_methods, + sizeof(struct msm_uart_softc), + .uc_ops = &uart_msm_ops, + .uc_range = 8, + .uc_rclk = DEF_CLK, +}; diff --git a/sys/dev/uart/uart_dev_msm.h b/sys/dev/uart/uart_dev_msm.h new file mode 100644 index 000000000000..89a7f191b245 --- /dev/null +++ b/sys/dev/uart/uart_dev_msm.h @@ -0,0 +1,229 @@ +/*- + * Copyright (c) 2014 Ganbold Tsagaankhuu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 _UART_DM_H_ +#define _UART_DM_H_ + +#define UART_DM_EXTR_BITS(value, start_pos, end_pos) \ + ((value << (32 - end_pos)) >> (32 - (end_pos - start_pos))) + +/* UART Parity Mode */ +enum UART_DM_PARITY_MODE { + UART_DM_NO_PARITY, + UART_DM_ODD_PARITY, + UART_DM_EVEN_PARITY, + UART_DM_SPACE_PARITY +}; + +/* UART Stop Bit Length */ +enum UART_DM_STOP_BIT_LEN { + UART_DM_SBL_9_16, + UART_DM_SBL_1, + UART_DM_SBL_1_9_16, + UART_DM_SBL_2 +}; + +/* UART Bits per Char */ +enum UART_DM_BITS_PER_CHAR { + UART_DM_5_BPS, + UART_DM_6_BPS, + UART_DM_7_BPS, + UART_DM_8_BPS +}; + +/* 8-N-1 Configuration */ +#define UART_DM_8_N_1_MODE (UART_DM_NO_PARITY | \ + (UART_DM_SBL_1 << 2) | \ + (UART_DM_8_BPS << 4)) + +/* UART_DM Registers */ + +/* UART Operational Mode Registers (HSUART) */ +#define UART_DM_MR1 0x00 +#define UART_DM_MR1_AUTO_RFR_LEVEL1_BMSK 0xffffff00 +#define UART_DM_MR1_AUTO_RFR_LEVEL0_BMSK 0x3f +#define UART_DM_MR1_CTS_CTL_BMSK 0x40 +#define UART_DM_MR1_RX_RDY_CTL_BMSK 0x80 + +#define UART_DM_MR2 0x04 +#define UART_DM_MR2_ERROR_MODE_BMSK 0x40 +#define UART_DM_MR2_BITS_PER_CHAR_BMSK 0x30 +#define UART_DM_MR2_STOP_BIT_LEN_BMSK 0x0c +#define UART_DM_MR2_PARITY_MODE_BMSK 0x03 +#define UART_DM_RXBRK_ZERO_CHAR_OFF (1 << 8) +#define UART_DM_LOOPBACK (1 << 7) + +/* UART Clock Selection Register, write only */ +#define UART_DM_CSR 0x08 +#define UART_DM_CSR_115200 0xff +#define UART_DM_CSR_57600 0xee +#define UART_DM_CSR_38400 0xdd +#define UART_DM_CSR_28800 0xcc +#define UART_DM_CSR_19200 0xbb +#define UART_DM_CSR_14400 0xaa +#define UART_DM_CSR_9600 0x99 +#define UART_DM_CSR_7200 0x88 +#define UART_DM_CSR_4800 0x77 +#define UART_DM_CSR_3600 0x66 +#define UART_DM_CSR_2400 0x55 +#define UART_DM_CSR_1200 0x44 +#define UART_DM_CSR_600 0x33 +#define UART_DM_CSR_300 0x22 +#define UART_DM_CSR_150 0x11 +#define UART_DM_CSR_75 0x00 + +/* UART DM TX FIFO Registers - 4, write only */ +#define UART_DM_TF(x) (0x70 + (4 * (x))) + +/* UART Command Register, write only */ +#define UART_DM_CR 0x10 +#define UART_DM_CR_RX_ENABLE (1 << 0) +#define UART_DM_CR_RX_DISABLE (1 << 1) +#define UART_DM_CR_TX_ENABLE (1 << 2) +#define UART_DM_CR_TX_DISABLE (1 << 3) + +/* UART_DM_CR channel command bit value (register field is bits 8:4) */ +#define UART_DM_RESET_RX 0x10 +#define UART_DM_RESET_TX 0x20 +#define UART_DM_RESET_ERROR_STATUS 0x30 +#define UART_DM_RESET_BREAK_INT 0x40 +#define UART_DM_START_BREAK 0x50 +#define UART_DM_STOP_BREAK 0x60 +#define UART_DM_RESET_CTS 0x70 +#define UART_DM_RESET_STALE_INT 0x80 +#define UART_DM_RFR_LOW 0xD0 +#define UART_DM_RFR_HIGH 0xE0 +#define UART_DM_CR_PROTECTION_EN 0x100 +#define UART_DM_STALE_EVENT_ENABLE 0x500 +#define UART_DM_STALE_EVENT_DISABLE 0x600 +#define UART_DM_FORCE_STALE_EVENT 0x400 +#define UART_DM_CLEAR_TX_READY 0x300 +#define UART_DM_RESET_TX_ERROR 0x800 +#define UART_DM_RESET_TX_DONE 0x810 + +/* UART Interrupt Mask Register */ +#define UART_DM_IMR 0x14 +/* these can be used for both ISR and IMR registers */ +#define UART_DM_TXLEV (1 << 0) +#define UART_DM_RXHUNT (1 << 1) +#define UART_DM_RXBRK_CHNG (1 << 2) +#define UART_DM_RXSTALE (1 << 3) +#define UART_DM_RXLEV (1 << 4) +#define UART_DM_DELTA_CTS (1 << 5) +#define UART_DM_CURRENT_CTS (1 << 6) +#define UART_DM_TX_READY (1 << 7) +#define UART_DM_TX_ERROR (1 << 8) +#define UART_DM_TX_DONE (1 << 9) +#define UART_DM_RXBREAK_START (1 << 10) +#define UART_DM_RXBREAK_END (1 << 11) +#define UART_DM_PAR_FRAME_ERR_IRQ (1 << 12) + +#define UART_DM_IMR_ENABLED (UART_DM_TX_READY | \ + UART_DM_TXLEV | \ + UART_DM_RXLEV | \ + UART_DM_RXSTALE) + +/* UART Interrupt Programming Register */ +#define UART_DM_IPR 0x18 +#define UART_DM_STALE_TIMEOUT_LSB 0x0f +#define UART_DM_STALE_TIMEOUT_MSB 0x00 +#define UART_DM_IPR_STALE_TIMEOUT_MSB_BMSK 0xffffff80 +#define UART_DM_IPR_STALE_LSB_BMSK 0x1f + +/* UART Transmit/Receive FIFO Watermark Register */ +#define UART_DM_TFWR 0x1c +/* Interrupt is generated when FIFO level is less than or equal to this value */ +#define UART_DM_TFW_VALUE 0 + +#define UART_DM_RFWR 0x20 +/* Interrupt generated when no of words in RX FIFO is greater than this value */ +#define UART_DM_RFW_VALUE 0 + +/* UART Hunt Character Register */ +#define UART_DM_HCR 0x24 + +/* Used for RX transfer initialization */ +#define UART_DM_DMRX 0x34 +/* Default DMRX value - any value bigger than FIFO size would be fine */ +#define UART_DM_DMRX_DEF_VALUE 0x220 + +/* Register to enable IRDA function */ +#define UART_DM_IRDA 0x38 + +/* UART Data Mover Enable Register */ +#define UART_DM_DMEN 0x3c + +/* Number of characters for Transmission */ +#define UART_DM_NO_CHARS_FOR_TX 0x40 + +/* UART RX FIFO Base Address */ +#define UART_DM_BADR 0x44 + +#define UART_DM_SIM_CFG_ADDR 0x80 + +/* Read only registers */ +/* UART Status Register */ +#define UART_DM_SR 0x08 +/* register field mask mapping */ +#define UART_DM_SR_RXRDY (1 << 0) +#define UART_DM_SR_RXFULL (1 << 1) +#define UART_DM_SR_TXRDY (1 << 2) +#define UART_DM_SR_TXEMT (1 << 3) +#define UART_DM_SR_UART_OVERRUN (1 << 4) +#define UART_DM_SR_PAR_FRAME_ERR (1 << 5) +#define UART_DM_RX_BREAK (1 << 6) +#define UART_DM_HUNT_CHAR (1 << 7) +#define UART_DM_RX_BRK_START_LAST (1 << 8) + +/* UART Receive FIFO Registers - 4 in numbers */ +#define UART_DM_RF(x) (0x70 + (4 * (x))) + +/* UART Masked Interrupt Status Register */ +#define UART_DM_MISR 0x10 + +/* UART Interrupt Status Register */ +#define UART_DM_ISR 0x14 + +/* Number of characters received since the end of last RX transfer */ +#define UART_DM_RX_TOTAL_SNAP 0x38 + +/* UART TX FIFO Status Register */ +#define UART_DM_TXFS 0x4c +#define UART_DM_TXFS_STATE_LSB(x) UART_DM_EXTR_BITS(x,0,6) +#define UART_DM_TXFS_STATE_MSB(x) UART_DM_EXTR_BITS(x,14,31) +#define UART_DM_TXFS_BUF_STATE(x) UART_DM_EXTR_BITS(x,7,9) +#define UART_DM_TXFS_ASYNC_STATE(x) UART_DM_EXTR_BITS(x,10,13) + +/* UART RX FIFO Status Register */ +#define UART_DM_RXFS 0x50 +#define UART_DM_RXFS_STATE_LSB(x) UART_DM_EXTR_BITS(x,0,6) +#define UART_DM_RXFS_STATE_MSB(x) UART_DM_EXTR_BITS(x,14,31) +#define UART_DM_RXFS_BUF_STATE(x) UART_DM_EXTR_BITS(x,7,9) +#define UART_DM_RXFS_ASYNC_STATE(x) UART_DM_EXTR_BITS(x,10,13) + +#endif /* _UART_DM_H_ */ diff --git a/sys/dev/usb/controller/ohci_s3c24x0.c b/sys/dev/usb/controller/ohci_s3c24x0.c index 225a2d201e33..08624d23f35d 100644 --- a/sys/dev/usb/controller/ohci_s3c24x0.c +++ b/sys/dev/usb/controller/ohci_s3c24x0.c @@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include static device_probe_t ohci_s3c24x0_probe; static device_attach_t ohci_s3c24x0_attach; diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 5e9029c5abe9..8676c0f73d54 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -614,6 +614,10 @@ xhci_init(struct xhci_softc *sc, device_t self) sc->sc_bus.devices = sc->sc_devices; sc->sc_bus.devices_max = XHCI_MAX_DEVICES; + /* set default cycle state in case of early interrupts */ + sc->sc_event_ccs = 1; + sc->sc_command_ccs = 1; + /* setup command queue mutex and condition varible */ cv_init(&sc->sc_cmd_cv, "CMDQ"); sx_init(&sc->sc_cmd_sx, "CMDQ lock"); @@ -2248,7 +2252,14 @@ xhci_configure_mask(struct usb_device *udev, uint32_t mask, uint8_t drop) xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, mask); xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx1, 0); } else { - xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, 0); + /* + * Some hardware requires that we drop the endpoint + * context before adding it again: + */ + xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, + mask & XHCI_INCTX_NON_CTRL_MASK); + + /* Add new endpoint context */ xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx1, mask); /* find most significant set bit */ @@ -2260,14 +2271,17 @@ xhci_configure_mask(struct usb_device *udev, uint32_t mask, uint8_t drop) /* adjust */ x--; - /* figure out maximum */ - if (x > sc->sc_hw.devs[index].context_num) { + /* figure out the maximum number of contexts */ + if (x > sc->sc_hw.devs[index].context_num) sc->sc_hw.devs[index].context_num = x; - temp = xhci_ctx_get_le32(sc, &pinp->ctx_slot.dwSctx0); - temp &= ~XHCI_SCTX_0_CTX_NUM_SET(31); - temp |= XHCI_SCTX_0_CTX_NUM_SET(x + 1); - xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); - } + else + x = sc->sc_hw.devs[index].context_num; + + /* update number of contexts */ + temp = xhci_ctx_get_le32(sc, &pinp->ctx_slot.dwSctx0); + temp &= ~XHCI_SCTX_0_CTX_NUM_SET(31); + temp |= XHCI_SCTX_0_CTX_NUM_SET(x + 1); + xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); } return (0); } diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index 408b429dff0a..7352e9c84ea7 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -493,7 +493,8 @@ struct xhci_softc { uint8_t sc_noscratch; /* root HUB device configuration */ uint8_t sc_conf; - uint8_t sc_hub_idata[2]; + /* root HUB port event bitmap, max 256 ports */ + uint8_t sc_hub_idata[32]; /* size of context */ uint8_t sc_ctx_is_64_byte; diff --git a/sys/dev/usb/misc/uled.c b/sys/dev/usb/misc/uled.c index 9053067806e8..efe6d9cd7c3d 100644 --- a/sys/dev/usb/misc/uled.c +++ b/sys/dev/usb/misc/uled.c @@ -231,7 +231,7 @@ uled_close(struct usb_fifo *fifo, int fflags) sc->sc_state &= ~ULED_ENABLED; } } - + static int uled_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags) { diff --git a/sys/dev/usb/net/if_aue.c b/sys/dev/usb/net/if_aue.c index dbd7b9b3f1fd..d07392728202 100644 --- a/sys/dev/usb/net/if_aue.c +++ b/sys/dev/usb/net/if_aue.c @@ -748,10 +748,10 @@ aue_intr_callback(struct usb_xfer *xfer, usb_error_t error) usbd_copy_out(pc, 0, &pkt, sizeof(pkt)); if (pkt.aue_txstat0) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (pkt.aue_txstat0 & (AUE_TXSTAT0_LATECOLL | AUE_TXSTAT0_EXCESSCOLL)) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } /* FALLTHROUGH */ case USB_ST_SETUP: @@ -790,13 +790,13 @@ aue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) if (sc->sc_flags & AUE_FLAG_VER_2) { if (actlen == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } } else { if (actlen <= (int)(sizeof(stat) + ETHER_CRC_LEN)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } usbd_copy_out(pc, actlen - sizeof(stat), &stat, @@ -808,7 +808,7 @@ aue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) */ stat.aue_rxstat &= AUE_RXSTAT_MASK; if (stat.aue_rxstat) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } /* No errors; receive the packet. */ @@ -853,7 +853,7 @@ aue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer of %d bytes complete\n", actlen); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -910,7 +910,7 @@ aue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ diff --git a/sys/dev/usb/net/if_axe.c b/sys/dev/usb/net/if_axe.c index e4f3153c82fb..52bd5f53c190 100644 --- a/sys/dev/usb/net/if_axe.c +++ b/sys/dev/usb/net/if_axe.c @@ -1097,7 +1097,7 @@ axe_rx_frame(struct usb_ether *ue, struct usb_page_cache *pc, int actlen) axe_rxeof(ue, pc, 0, actlen, NULL); if (error != 0) - ue->ue_ifp->if_ierrors++; + if_inc_counter(ue->ue_ifp, IFCOUNTER_IERRORS, 1); return (error); } @@ -1109,13 +1109,13 @@ axe_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset, struct mbuf *m; if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (EINVAL); } m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (ENOMEM); } m->m_len = m->m_pkthdr.len = MCLBYTES; @@ -1123,7 +1123,7 @@ axe_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, unsigned int offset, usbd_copy_out(pc, offset, mtod(m, uint8_t *), len); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; @@ -1229,7 +1229,7 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) * multiple writes into single one if there is * room in TX buffer of controller. */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * if there's a BPF listener, bounce a copy @@ -1253,7 +1253,7 @@ axe_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (error != USB_ERR_CANCELLED) { diff --git a/sys/dev/usb/net/if_axge.c b/sys/dev/usb/net/if_axge.c index 17fd4d81a4bc..e262a5dc378d 100644 --- a/sys/dev/usb/net/if_axge.c +++ b/sys/dev/usb/net/if_axge.c @@ -681,7 +681,7 @@ axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) * multiple writes into single one if there is * room in TX buffer of controller. */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * if there's a BPF listener, bounce a copy @@ -702,7 +702,7 @@ axge_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) return; /* NOTREACHED */ default: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (error != USB_ERR_CANCELLED) { @@ -962,7 +962,7 @@ axge_rx_frame(struct usb_ether *ue, struct usb_page_cache *pc, int actlen) pktlen = (pkt_hdr >> 16) & 0x1fff; if (pkt_hdr & (AXGE_RXHDR_CRC_ERR | AXGE_RXHDR_DROP_ERR)) { DPRINTF("Dropped a packet\n"); - ue->ue_ifp->if_ierrors++; + if_inc_counter(ue->ue_ifp, IFCOUNTER_IERRORS, 1); } if (pktlen >= 6 && (int)(pos + pktlen) <= actlen) { axge_rxeof(ue, pc, pos + 2, pktlen - 6, pkt_hdr); @@ -984,13 +984,13 @@ axge_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, ifp = ue->ue_ifp; if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return; } m->m_pkthdr.rcvif = ifp; @@ -999,7 +999,7 @@ axge_rxeof(struct usb_ether *ue, struct usb_page_cache *pc, usbd_copy_out(pc, offset, mtod(m, uint8_t *), len); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if ((pkt_hdr & (AXGE_RXHDR_L4CSUM_ERR | AXGE_RXHDR_L3CSUM_ERR)) == 0) { if ((pkt_hdr & AXGE_RXHDR_L4_TYPE_MASK) == diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c index 4f475ec8338d..b03bf6383703 100644 --- a/sys/dev/usb/net/if_cdce.c +++ b/sys/dev/usb/net/if_cdce.c @@ -788,7 +788,7 @@ cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer complete: %u bytes in %u frames\n", actlen, aframes); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* free all previous TX buffers */ cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX); @@ -814,7 +814,7 @@ cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) if (!m_append(m, 4, (void *)&crc)) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -822,7 +822,7 @@ cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) mt = m_defrag(m, M_NOWAIT); if (mt == NULL) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } m = mt; @@ -854,7 +854,7 @@ cdce_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX); /* count output errors */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ @@ -1169,7 +1169,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index) /* The frame won't fit in our buffer */ DPRINTFN(1, "Frame too big to be transmitted!\n"); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); n--; continue; } @@ -1207,7 +1207,7 @@ cdce_ncm_fill_tx_frames(struct usb_xfer *xfer, uint8_t index) /* Pre-increment interface counter */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } if (n == 0) @@ -1310,7 +1310,7 @@ cdce_ncm_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) usbd_errstr(error)); /* update error counter */ - ifp->if_oerrors += 1; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ @@ -1454,7 +1454,7 @@ cdce_ncm_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) sumdata += temp; } else { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } } diff --git a/sys/dev/usb/net/if_cue.c b/sys/dev/usb/net/if_cue.c index 5b06bc4c2a5d..850ad0e7d6db 100644 --- a/sys/dev/usb/net/if_cue.c +++ b/sys/dev/usb/net/if_cue.c @@ -462,7 +462,7 @@ cue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: if (actlen <= (int)(2 + sizeof(struct ether_header))) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } pc = usbd_xfer_get_frame(xfer, 0); @@ -506,7 +506,7 @@ cue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete\n"); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -544,7 +544,7 @@ cue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ @@ -563,12 +563,12 @@ cue_tick(struct usb_ether *ue) CUE_LOCK_ASSERT(sc, MA_OWNED); - ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_SINGLECOLL); - ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_MULTICOLL); - ifp->if_collisions += cue_csr_read_2(sc, CUE_TX_EXCESSCOLL); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cue_csr_read_2(sc, CUE_TX_SINGLECOLL)); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cue_csr_read_2(sc, CUE_TX_MULTICOLL)); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, cue_csr_read_2(sc, CUE_TX_EXCESSCOLL)); if (cue_csr_read_2(sc, CUE_RX_FRAMEERR)) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } static void diff --git a/sys/dev/usb/net/if_ipheth.c b/sys/dev/usb/net/if_ipheth.c index 056d364dccde..5bbf11b190d4 100644 --- a/sys/dev/usb/net/if_ipheth.c +++ b/sys/dev/usb/net/if_ipheth.c @@ -400,7 +400,7 @@ ipheth_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer complete: %u bytes in %u frames\n", actlen, aframes); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* free all previous TX buffers */ ipheth_free_queue(sc->sc_tx_buf, IPHETH_TX_FRAMES_MAX); @@ -455,7 +455,7 @@ ipheth_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) ipheth_free_queue(sc->sc_tx_buf, IPHETH_TX_FRAMES_MAX); /* count output errors */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ diff --git a/sys/dev/usb/net/if_kue.c b/sys/dev/usb/net/if_kue.c index 7410dbea76e4..ea88ed9bcc15 100644 --- a/sys/dev/usb/net/if_kue.c +++ b/sys/dev/usb/net/if_kue.c @@ -550,7 +550,7 @@ kue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: if (actlen <= (int)(2 + sizeof(struct ether_header))) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } pc = usbd_xfer_get_frame(xfer, 0); @@ -596,7 +596,7 @@ kue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete\n"); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -638,7 +638,7 @@ kue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ diff --git a/sys/dev/usb/net/if_mos.c b/sys/dev/usb/net/if_mos.c index b3e541370a80..8d0642a6921c 100644 --- a/sys/dev/usb/net/if_mos.c +++ b/sys/dev/usb/net/if_mos.c @@ -792,7 +792,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: MOS_DPRINTFN("actlen : %d", actlen); if (actlen <= 1) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } /* evaluate status byte at the end */ @@ -811,7 +811,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) MOS_DPRINTFN("CRC error"); if (rxstat & MOS_RXSTS_ALIGN_ERROR) MOS_DPRINTFN("alignment error"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } /* Remember the last byte was used for the status fields */ @@ -820,7 +820,7 @@ mos_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) MOS_DPRINTFN("error: pktlen %d is smaller " "than ether_header %zd", pktlen, sizeof(struct ether_header)); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } uether_rxbuf(ue, pc, 0, actlen); @@ -859,7 +859,7 @@ mos_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: MOS_DPRINTFN("transfer of complete"); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: @@ -886,11 +886,11 @@ mos_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) usbd_transfer_submit(xfer); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); return; default: MOS_DPRINTFN("usb error on tx: %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); goto tr_setup; @@ -981,7 +981,7 @@ mos_intr_callback(struct usb_xfer *xfer, usb_error_t error) uint32_t pkt; int actlen; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); MOS_DPRINTFN("actlen %i", actlen); diff --git a/sys/dev/usb/net/if_rue.c b/sys/dev/usb/net/if_rue.c index f37ae1c6a028..d4e71479f3e8 100644 --- a/sys/dev/usb/net/if_rue.c +++ b/sys/dev/usb/net/if_rue.c @@ -648,9 +648,9 @@ rue_intr_callback(struct usb_xfer *xfer, usb_error_t error) pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, &pkt, sizeof(pkt)); - ifp->if_ierrors += pkt.rue_rxlost_cnt; - ifp->if_ierrors += pkt.rue_crcerr_cnt; - ifp->if_collisions += pkt.rue_col_cnt; + if_inc_counter(ifp, IFCOUNTER_IERRORS, pkt.rue_rxlost_cnt); + if_inc_counter(ifp, IFCOUNTER_IERRORS, pkt.rue_crcerr_cnt); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, pkt.rue_col_cnt); } /* FALLTHROUGH */ case USB_ST_SETUP: @@ -685,7 +685,7 @@ rue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: if (actlen < 4) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } pc = usbd_xfer_get_frame(xfer, 0); @@ -695,7 +695,7 @@ rue_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) /* check recieve packet was valid or not */ status = le16toh(status); if ((status & RUE_RXSTAT_VALID) == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } uether_rxbuf(ue, pc, 0, actlen); @@ -732,7 +732,7 @@ rue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete\n"); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -782,7 +782,7 @@ rue_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c index 55d3560759b1..bd2e75141e1e 100644 --- a/sys/dev/usb/net/if_smsc.c +++ b/sys/dev/usb/net/if_smsc.c @@ -123,7 +123,24 @@ SYSCTL_INT(_hw_usb_smsc, OID_AUTO, debug, CTLFLAG_RW, &smsc_debug, 0, */ static const struct usb_device_id smsc_devs[] = { #define SMSC_DEV(p,i) { USB_VPI(USB_VENDOR_SMC2, USB_PRODUCT_SMC2_##p, i) } + SMSC_DEV(LAN89530_ETH, 0), + SMSC_DEV(LAN9500_ETH, 0), + SMSC_DEV(LAN9500_ETH_2, 0), + SMSC_DEV(LAN9500A_ETH, 0), + SMSC_DEV(LAN9500A_ETH_2, 0), + SMSC_DEV(LAN9505_ETH, 0), + SMSC_DEV(LAN9505A_ETH, 0), SMSC_DEV(LAN9514_ETH, 0), + SMSC_DEV(LAN9514_ETH_2, 0), + SMSC_DEV(LAN9530_ETH, 0), + SMSC_DEV(LAN9730_ETH, 0), + SMSC_DEV(LAN9500_SAL10, 0), + SMSC_DEV(LAN9505_SAL10, 0), + SMSC_DEV(LAN9500A_SAL10, 0), + SMSC_DEV(LAN9505A_SAL10, 0), + SMSC_DEV(LAN9514_SAL10, 0), + SMSC_DEV(LAN9500A_HAL, 0), + SMSC_DEV(LAN9505A_HAL, 0), #undef SMSC_DEV }; @@ -989,9 +1006,9 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) if (rxhdr & SMSC_RX_STAT_ERROR) { smsc_dbg_printf(sc, "rx error (hdr 0x%08x)\n", rxhdr); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (rxhdr & SMSC_RX_STAT_COLLISION) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } else { /* Check if the ethernet frame is too big or too small */ @@ -1002,7 +1019,7 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) m = uether_newbuf(); if (m == NULL) { smsc_warn_printf(sc, "failed to create new mbuf\n"); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); goto tr_setup; } @@ -1158,7 +1175,7 @@ smsc_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) usbd_m_copy_in(pc, frm_len, m, 0, m->m_pkthdr.len); frm_len += m->m_pkthdr.len; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* If there's a BPF listener, bounce a copy of this frame to him */ BPF_MTAP(ifp, m); @@ -1176,7 +1193,7 @@ smsc_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) return; default: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (error != USB_ERR_CANCELLED) { diff --git a/sys/dev/usb/net/if_udav.c b/sys/dev/usb/net/if_udav.c index 418776030daa..66d684453a40 100644 --- a/sys/dev/usb/net/if_udav.c +++ b/sys/dev/usb/net/if_udav.c @@ -582,7 +582,7 @@ udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete\n"); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -638,7 +638,7 @@ udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ @@ -666,7 +666,7 @@ udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: if (actlen < (int)(sizeof(stat) + ETHER_CRC_LEN)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } pc = usbd_xfer_get_frame(xfer, 0); @@ -676,11 +676,11 @@ udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) len -= ETHER_CRC_LEN; if (stat.rxstat & UDAV_RSR_LCS) { - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); goto tr_setup; } if (stat.rxstat & UDAV_RSR_ERR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } uether_rxbuf(ue, pc, sizeof(stat), len); diff --git a/sys/dev/usb/net/if_urndis.c b/sys/dev/usb/net/if_urndis.c index 5b4f8ac046b1..5d45395d46c6 100644 --- a/sys/dev/usb/net/if_urndis.c +++ b/sys/dev/usb/net/if_urndis.c @@ -844,12 +844,12 @@ urndis_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) rm_dataoffset), actlen); goto tr_setup; } else if (msg.rm_datalen < (uint32_t)sizeof(struct ether_header)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF("invalid ethernet size " "%u < %u\n", msg.rm_datalen, (unsigned)sizeof(struct ether_header)); goto tr_setup; } else if (msg.rm_datalen > (uint32_t)MCLBYTES) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF("invalid ethernet size " "%u > %u\n", msg.rm_datalen, (unsigned)MCLBYTES); @@ -871,7 +871,7 @@ urndis_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) /* enqueue */ uether_rxmbuf(&sc->sc_ue, m, msg.rm_datalen); } else { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } offset += msg.rm_len; actlen -= msg.rm_len; @@ -917,7 +917,7 @@ urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: DPRINTFN(11, "%u bytes in %u frames\n", actlen, aframes); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -937,7 +937,7 @@ urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) if ((m->m_pkthdr.len + sizeof(msg)) > RNDIS_TX_MAXLEN) { DPRINTF("Too big packet\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* Free buffer */ m_freem(m); @@ -973,7 +973,7 @@ urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); /* count output errors */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ diff --git a/sys/dev/usb/net/if_usie.c b/sys/dev/usb/net/if_usie.c index 19093184c68c..b71b8256f221 100644 --- a/sys/dev/usb/net/if_usie.c +++ b/sys/dev/usb/net/if_usie.c @@ -806,7 +806,7 @@ usie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (sc->sc_rxm == NULL) { DPRINTF("could not allocate Rx mbuf\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); usbd_xfer_set_stall(xfer); usbd_xfer_set_frames(xfer, 0); } else { @@ -828,7 +828,7 @@ usie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error) if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } if (sc->sc_rxm != NULL) { @@ -917,8 +917,8 @@ usie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error) mtx_lock(&sc->sc_mtx); - ifp->if_ierrors += err; - ifp->if_ipackets += pkt; + if_inc_counter(ifp, IFCOUNTER_IERRORS, err); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, pkt); } static void @@ -934,7 +934,7 @@ usie_if_tx_callback(struct usb_xfer *xfer, usb_error_t error) case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete\n"); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* fall though */ case USB_ST_SETUP: @@ -974,11 +974,11 @@ usie_if_tx_callback(struct usb_xfer *xfer, usb_error_t error) default: /* Error */ DPRINTF("USB transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } break; @@ -1214,10 +1214,10 @@ usie_if_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, err = (ifp->if_transmit)(ifp, m); if (err) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); return (0); } @@ -1395,7 +1395,7 @@ usie_cns_req(struct usie_softc *sc, uint32_t id, uint16_t obj) m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (__predict_false(m == NULL)) { DPRINTF("could not allocate mbuf\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } /* to align usie_hip{} on 32 bit */ diff --git a/sys/dev/usb/net/uhso.c b/sys/dev/usb/net/uhso.c index ba6236c6b263..e39f0937176c 100644 --- a/sys/dev/usb/net/uhso.c +++ b/sys/dev/usb/net/uhso.c @@ -1694,7 +1694,7 @@ uhso_if_rxflush(void *arg) m = m_pullup(m0, sizeof(struct ip)); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); UHSO_DPRINTF(0, "m_pullup failed\n"); mtx_lock(&sc->sc_mtx); continue; @@ -1724,7 +1724,7 @@ uhso_if_rxflush(void *arg) else { UHSO_DPRINTF(0, "got unexpected ip version %d, " "m=%p, len=%d\n", (*cp & 0xf0) >> 4, m, m->m_len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); UHSO_HEXDUMP(cp, 4); m_freem(m); m = NULL; @@ -1734,7 +1734,7 @@ uhso_if_rxflush(void *arg) if (iplen == 0) { UHSO_DPRINTF(0, "Zero IP length\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); m = NULL; mtx_lock(&sc->sc_mtx); @@ -1775,7 +1775,7 @@ uhso_if_rxflush(void *arg) continue; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; /* Dispatch to IP layer */ @@ -1803,7 +1803,7 @@ uhso_ifnet_write_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; case USB_ST_SETUP: tr_setup: @@ -1898,10 +1898,10 @@ uhso_if_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, error = (ifp->if_transmit)(ifp, m0); if (error) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); return (0); } diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c index d2b7f20ab50d..58b83ff94a03 100644 --- a/sys/dev/usb/net/usb_ethernet.c +++ b/sys/dev/usb/net/usb_ethernet.c @@ -580,7 +580,7 @@ uether_rxmbuf(struct usb_ether *ue, struct mbuf *m, UE_LOCK_ASSERT(ue, MA_OWNED); /* finalize mbuf */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; @@ -603,14 +603,14 @@ uether_rxbuf(struct usb_ether *ue, struct usb_page_cache *pc, m = uether_newbuf(); if (m == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (ENOMEM); } usbd_copy_out(pc, offset, mtod(m, uint8_t *), len); /* finalize mbuf */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c index bbf535126442..b39607c2533b 100644 --- a/sys/dev/usb/serial/u3g.c +++ b/sys/dev/usb/serial/u3g.c @@ -75,6 +75,8 @@ SYSCTL_INT(_hw_usb_u3g, OID_AUTO, debug, CTLFLAG_RW, #define U3G_MAXPORTS 12 #define U3G_CONFIG_INDEX 0 #define U3G_BSIZE 2048 +#define U3G_TXSIZE (U3G_BSIZE / U3G_TXFRAMES) +#define U3G_TXFRAMES 4 /* Eject methods; See also usb_quirks.h:UQ_MSC_EJECT_* */ #define U3GINIT_HUAWEI 1 /* Requires Huawei init command */ @@ -145,6 +147,7 @@ static const struct usb_config u3g_config[U3G_N_TRANSFER] = { .endpoint = UE_ADDR_ANY, .direction = UE_DIR_OUT, .bufsize = U3G_BSIZE,/* bytes */ + .frames = U3G_TXFRAMES, .flags = {.pipe_bof = 1,.force_short_xfer = 1,}, .callback = &u3g_write_callback, }, @@ -239,6 +242,8 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = { U3G_DEV(DLINK3, DWM652, 0), U3G_DEV(HP, EV2200, 0), U3G_DEV(HP, HS2300, 0), + U3G_DEV(HP, UN2420_QDL, 0), + U3G_DEV(HP, UN2420, 0), U3G_DEV(HUAWEI, E1401, U3GINIT_HUAWEI), U3G_DEV(HUAWEI, E1402, U3GINIT_HUAWEI), U3G_DEV(HUAWEI, E1403, U3GINIT_HUAWEI), @@ -1011,14 +1016,22 @@ u3g_write_callback(struct usb_xfer *xfer, usb_error_t error) struct ucom_softc *ucom = usbd_xfer_softc(xfer); struct usb_page_cache *pc; uint32_t actlen; + uint32_t frame; switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: case USB_ST_SETUP: tr_setup: - pc = usbd_xfer_get_frame(xfer, 0); - if (ucom_get_data(ucom, pc, 0, U3G_BSIZE, &actlen)) { - usbd_xfer_set_frame_len(xfer, 0, actlen); + for (frame = 0; frame != U3G_TXFRAMES; frame++) { + usbd_xfer_set_frame_offset(xfer, frame * U3G_TXSIZE, frame); + + pc = usbd_xfer_get_frame(xfer, frame); + if (ucom_get_data(ucom, pc, 0, U3G_TXSIZE, &actlen) == 0) + break; + usbd_xfer_set_frame_len(xfer, frame, actlen); + } + if (frame != 0) { + usbd_xfer_set_frames(xfer, frame); usbd_transfer_submit(xfer); } break; diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index 396067309ac4..2dad2bdf455c 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -298,6 +298,10 @@ usb_ref_device(struct usb_cdev_privdata *cpd, } mtx_unlock(&usb_ref_lock); DPRINTFN(2, "fail\n"); + + /* clear all refs */ + memset(crd, 0, sizeof(*crd)); + return (USB_ERR_INVAL); } @@ -1093,8 +1097,8 @@ usb_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int fflag, struct thread* goto done; if (usb_usb_ref_device(cpd, &refs)) { - err = ENXIO; - goto done; + /* we lost the reference */ + return (ENXIO); } err = (f->methods->f_ioctl_post) (f, cmd, addr, fflags); @@ -1117,9 +1121,8 @@ usb_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int fflag, struct thread* while (usb_ref_device(cpd, &refs, 1 /* need uref */)) { if (usb_ref_device(cpd, &refs, 0)) { - /* device no longer exits */ - err = ENXIO; - goto done; + /* device no longer exists */ + return (ENXIO); } usb_unref_device(cpd, &refs); usb_pause_mtx(NULL, hz / 128); @@ -1411,9 +1414,9 @@ usb_read(struct cdev *dev, struct uio *uio, int ioflag) return (err); err = usb_ref_device(cpd, &refs, 0 /* no uref */ ); - if (err) { + if (err) return (ENXIO); - } + fflags = cpd->fflags; f = refs.rxfifo; @@ -1537,9 +1540,9 @@ usb_write(struct cdev *dev, struct uio *uio, int ioflag) return (err); err = usb_ref_device(cpd, &refs, 0 /* no uref */ ); - if (err) { + if (err) return (ENXIO); - } + fflags = cpd->fflags; f = refs.txfifo; diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index a64093ea9b20..17a880637e0c 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -2229,6 +2229,8 @@ product HP 3300C 0x0205 ScanJet 3300C product HP CDW8200 0x0207 CD-Writer Plus 8200e product HP MMKEYB 0x020c Multimedia keyboard product HP 1220C 0x0212 DeskJet 1220C +product HP UN2420_QDL 0x241d UN2420 QDL Firmware Loader +product HP UN2420 0x251d UN2420 WWAN/GPS Module product HP 810C 0x0304 DeskJet 810C/812C product HP 4300C 0x0305 Scanjet 4300C product HP CDW4E 0x0307 CD-Writer+ CD-4e @@ -3715,6 +3717,7 @@ product REALTEK RTL8191CU 0x8177 RTL8191CU product REALTEK RTL8192CU 0x8178 RTL8192CU product REALTEK RTL8192CE 0x817c RTL8192CE product REALTEK RTL8188RU_1 0x817d RTL8188RU +product REALTEK RTL8188RU_3 0x817f RTL8188RU product REALTEK RTL8712 0x8712 RTL8712 product REALTEK RTL8713 0x8712 RTL8713 product REALTEK RTL8188RU_2 0x317f RTL8188RU @@ -4133,6 +4136,23 @@ product SMC 2862WG 0xee13 EZ Connect Wireless Adapter product SMC2 2020HUB 0x2020 USB Hub product SMC2 2514HUB 0x2514 USB Hub product SMC3 2662WUSB 0xa002 2662W-AR Wireless +product SMC2 LAN9500_ETH 0x9500 USB/Ethernet +product SMC2 LAN9505_ETH 0x9505 USB/Ethernet +product SMC2 LAN9530_ETH 0x9530 USB/Ethernet +product SMC2 LAN9730_ETH 0x9730 USB/Ethernet +product SMC2 LAN9500_SAL10 0x9900 USB/Ethernet +product SMC2 LAN9505_SAL10 0x9901 USB/Ethernet +product SMC2 LAN9500A_SAL10 0x9902 USB/Ethernet +product SMC2 LAN9505A_SAL10 0x9903 USB/Ethernet +product SMC2 LAN9514_SAL10 0x9904 USB/Ethernet +product SMC2 LAN9500A_HAL 0x9905 USB/Ethernet +product SMC2 LAN9505A_HAL 0x9906 USB/Ethernet +product SMC2 LAN9500_ETH_2 0x9907 USB/Ethernet +product SMC2 LAN9500A_ETH_2 0x9908 USB/Ethernet +product SMC2 LAN9514_ETH_2 0x9909 USB/Ethernet +product SMC2 LAN9500A_ETH 0x9e00 USB/Ethernet +product SMC2 LAN9505A_ETH 0x9e01 USB/Ethernet +product SMC2 LAN89530_ETH 0x9e08 USB/Ethernet product SMC2 LAN9514_ETH 0xec00 USB/Ethernet /* SOHOware products */ diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index 7fcd429017e1..4808c0f9f290 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -1352,11 +1352,11 @@ rsu_rx_frame(struct rsu_softc *sc, uint8_t *buf, int pktlen, int *rssi) rxdw3 = le32toh(stat->rxdw3); if (__predict_false(rxdw0 & R92S_RXDW0_CRCERR)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } if (__predict_false(pktlen < sizeof(*wh) || pktlen > MCLBYTES)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } @@ -1374,7 +1374,7 @@ rsu_rx_frame(struct rsu_softc *sc, uint8_t *buf, int pktlen, int *rssi) m = m_get2(pktlen, M_NOWAIT, MT_DATA, M_PKTHDR); if (__predict_false(m == NULL)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } /* Finalize mbuf. */ @@ -1483,7 +1483,7 @@ rsu_rxeof(struct usb_xfer *xfer, struct rsu_data *data, int *rssi) if (__predict_false(len < sizeof(*stat))) { DPRINTF("xfer too short %d\n", len); - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); return (NULL); } /* Determine if it is a firmware C2H event or an 802.11 frame. */ @@ -1561,7 +1561,7 @@ rsu_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } break; @@ -1596,7 +1596,7 @@ rsu_txeof(struct usb_xfer *xfer, struct rsu_data *data) ieee80211_free_node(data->ni); data->ni = NULL; } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } @@ -1640,7 +1640,7 @@ rsu_bulk_tx_callback_sub(struct usb_xfer *xfer, usb_error_t error, rsu_txeof(xfer, data); STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, data, next); } - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); @@ -1801,11 +1801,11 @@ rsu_start_locked(struct ifnet *ifp) bf = rsu_getbuf(sc); if (bf == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); m_freem(m); ieee80211_free_node(ni); } else if (rsu_tx_start(sc, ni, m, bf) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); ieee80211_free_node(ni); } @@ -2311,10 +2311,10 @@ rsu_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, RSU_UNLOCK(sc); return (ENOBUFS); } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (rsu_tx_start(sc, ni, m, bf) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); RSU_UNLOCK(sc); return (EIO); diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c index 700f72afac53..6efea79ba098 100644 --- a/sys/dev/usb/wlan/if_rum.c +++ b/sys/dev/usb/wlan/if_rum.c @@ -797,7 +797,7 @@ rum_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) rum_tx_free(data, 0); usbd_xfer_set_priv(xfer, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; /* FALLTHROUGH */ @@ -851,7 +851,7 @@ rum_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); data = usbd_xfer_get_priv(xfer); if (data != NULL) { rum_tx_free(data, error); @@ -897,7 +897,7 @@ rum_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) if (len < (int)(RT2573_RX_DESC_SIZE + IEEE80211_MIN_LEN)) { DPRINTF("%s: xfer too short %d\n", device_get_nameunit(sc->sc_dev), len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } @@ -914,14 +914,14 @@ rum_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) * filled RUM_TXRX_CSR2: */ DPRINTFN(5, "PHY or CRC error\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) { DPRINTF("could not allocate mbuf\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } usbd_copy_out(pc, RT2573_RX_DESC_SIZE, @@ -1321,7 +1321,7 @@ rum_start(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (rum_tx_data(sc, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } } @@ -2205,7 +2205,7 @@ rum_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return EIO; } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (params == NULL) { /* @@ -2226,7 +2226,7 @@ rum_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return 0; bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); RUM_UNLOCK(sc); ieee80211_free_node(ni); return EIO; @@ -2281,7 +2281,7 @@ rum_ratectl_task(void *arg, int pending) (void) ieee80211_ratectl_rate(ni, NULL, 0); ieee80211_free_node(ni); - ifp->if_oerrors += fail; /* count TX retry-fail as Tx errors */ + if_inc_counter(ifp, IFCOUNTER_OERRORS, fail); /* count TX retry-fail as Tx errors */ usb_callout_reset(&rvp->ratectl_ch, hz, rum_ratectl_timeout, rvp); RUM_UNLOCK(sc); diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index 8f46d1b91741..1451225353b1 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -2574,7 +2574,7 @@ run_drain_fifo(void *arg) if (stat & RT2860_TXQ_OK) (*wstat)[RUN_SUCCESS]++; else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* * Check if there were retries, ie if the Tx success rate is * different from the requested rate. Note that it works only @@ -2620,7 +2620,7 @@ run_iter_func(void *arg, struct ieee80211_node *ni) goto fail; /* count failed TX as errors */ - ifp->if_oerrors += le16toh(sta[0].error.fail); + if_inc_counter(ifp, IFCOUNTER_OERRORS, le16toh(sta[0].error.fail)); retrycnt = le16toh(sta[1].tx.retry); success = le16toh(sta[1].tx.success); @@ -2786,7 +2786,7 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen) rxwisize += sizeof(uint32_t); if (__predict_false(len > dmalen)) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF("bad RXWI length %u > %u\n", len, dmalen); return; } @@ -2796,7 +2796,7 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen) if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF("%s error.\n", (flags & RT2860_RX_CRCERR)?"CRC":"ICV"); return; } @@ -2825,7 +2825,7 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen) ieee80211_notify_michael_failure(ni->ni_vap, wh, rxwi->keyidx); m_freem(m); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF("MIC error. Someone is lying.\n"); return; } @@ -2925,7 +2925,7 @@ run_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (sc->rx_m == NULL) { DPRINTF("could not allocate mbuf - idle with stall\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); usbd_xfer_set_stall(xfer); usbd_xfer_set_frames(xfer, 0); } else { @@ -2949,7 +2949,7 @@ run_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) if (error == USB_ERR_TIMEOUT) device_printf(sc->sc_dev, "device timeout\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } @@ -2998,7 +2998,7 @@ run_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (__predict_false(m0 == NULL)) { DPRINTF("could not allocate mbuf\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } m_copydata(m, 4 /* skip 32-bit DMA-len header */, @@ -3070,7 +3070,7 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index) usbd_xfer_set_priv(xfer, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* FALLTHROUGH */ case USB_ST_SETUP: @@ -3089,7 +3089,7 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index) DPRINTF("data overflow, %u bytes\n", m->m_pkthdr.len); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); run_tx_free(pq, data, 1); @@ -3144,7 +3144,7 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index) data = usbd_xfer_get_priv(xfer); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (data != NULL) { if(data->ni != NULL) @@ -3567,7 +3567,7 @@ run_sendprot(struct run_softc *sc, mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur); } if (mprot == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); DPRINTF("could not allocate mbuf\n"); return (ENOBUFS); } @@ -3703,20 +3703,20 @@ run_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, if (params == NULL) { /* tx mgt packet */ if ((error = run_tx_mgt(sc, m, ni)) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); DPRINTF("mgt tx failed\n"); goto done; } } else { /* tx raw packet with param */ if ((error = run_tx_param(sc, m, ni, params)) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); DPRINTF("tx with param failed\n"); goto done; } } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); done: RUN_UNLOCK(sc); diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index b8e886388f72..0796fbe76316 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -1333,7 +1333,7 @@ uath_watchdog(void *arg) if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "device timeout\n"); /*uath_init(ifp); XXX needs a process context! */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } callout_reset(&sc->watchdog_ch, hz, uath_watchdog, sc); @@ -1814,7 +1814,7 @@ uath_start(struct ifnet *ifp) next = m->m_nextpkt; if (uath_tx_start(sc, m, ni, bf) != 0) { bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); reclaim: STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); UATH_STAT_INC(sc, st_tx_inactive); @@ -1878,7 +1878,7 @@ uath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, sc->sc_seqnum = 0; if (uath_tx_start(sc, m, ni, bf) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); UATH_STAT_INC(sc, st_tx_inactive); UATH_UNLOCK(sc); @@ -2553,14 +2553,14 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data, if (actlen < (int)UATH_MIN_RXBUFSZ) { DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL, "%s: wrong xfer size (len=%d)\n", __func__, actlen); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } chunk = (struct uath_chunk *)data->buf; if (chunk->seqnum == 0 && chunk->flags == 0 && chunk->length == 0) { device_printf(sc->sc_dev, "%s: strange response\n", __func__); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); UATH_RESET_INTRX(sc); return (NULL); } @@ -2593,7 +2593,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data, if ((sc->sc_intrx_len + sizeof(struct uath_rx_desc) + chunklen) > UATH_MAX_INTRX_SIZE) { UATH_STAT_INC(sc, st_invalidlen); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (sc->sc_intrx_head != NULL) m_freem(sc->sc_intrx_head); UATH_RESET_INTRX(sc); @@ -2618,7 +2618,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data, if (mnew == NULL) { DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL, "%s: can't get new mbuf, drop frame\n", __func__); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); if (sc->sc_intrx_head != NULL) m_freem(sc->sc_intrx_head); UATH_RESET_INTRX(sc); @@ -2659,7 +2659,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data, DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL, "%s: bad descriptor (len=%d)\n", __func__, be32toh(desc->len)); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); UATH_STAT_INC(sc, st_toobigrxpkt); if (sc->sc_intrx_head != NULL) m_freem(sc->sc_intrx_head); @@ -2703,7 +2703,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data, tap->wr_antnoise = -95; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); UATH_RESET_INTRX(sc); return (m); @@ -2790,7 +2790,7 @@ uath_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto setup; } break; @@ -2826,7 +2826,7 @@ uath_data_txeof(struct usb_xfer *xfer, struct uath_data *data) data->ni = NULL; } sc->sc_tx_timer = 0; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } @@ -2878,7 +2878,7 @@ uath_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error) if ((sc->sc_flags & UATH_FLAG_INVALID) == 0) ieee80211_free_node(data->ni); data->ni = NULL; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index a84644d6e921..6b24524b10a5 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -416,7 +416,7 @@ upgt_txeof(struct usb_xfer *xfer, struct upgt_data *data) ieee80211_free_node(data->ni); data->ni = NULL; } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } static void @@ -854,7 +854,7 @@ upgt_start(struct ifnet *ifp) STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, data_tx, next); UPGT_STAT_INC(sc, st_tx_inactive); ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); continue; } sc->sc_tx_timer = 5; @@ -891,7 +891,7 @@ upgt_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, data_tx, next); UPGT_STAT_INC(sc, st_tx_inactive); ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); UPGT_UNLOCK(sc); return (EIO); } @@ -911,7 +911,7 @@ upgt_watchdog(void *arg) if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "watchdog timeout\n"); /* upgt_init(ifp); XXX needs a process context ? */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } callout_reset(&sc->sc_watchdog_ch, hz, upgt_watchdog, sc); @@ -1552,7 +1552,7 @@ upgt_rx(struct upgt_softc *sc, uint8_t *data, int pkglen, int *rssi) tap->wr_rate = upgt_rx_rate(sc, rxdesc->rate); tap->wr_antsignal = rxdesc->rssi; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); DPRINTF(sc, UPGT_DEBUG_RX_PROC, "%s: RX done\n", __func__); *rssi = rxdesc->rssi; @@ -2293,7 +2293,8 @@ upgt_tx_start(struct upgt_softc *sc, struct mbuf *m, struct ieee80211_node *ni, * will stall. It's strange, but it works, so we keep reading * the statistics here. *shrug* */ - if (!(ifp->if_opackets % UPGT_TX_STAT_INTERVAL)) + if (!(ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS) % + UPGT_TX_STAT_INTERVAL)) upgt_get_stats(sc); return (error); @@ -2366,7 +2367,7 @@ upgt_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto setup; } break; @@ -2418,7 +2419,7 @@ upgt_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error) if (data->ni != NULL) { ieee80211_free_node(data->ni); data->ni = NULL; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 6145ff86c26d..959bec5e43e5 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -805,7 +805,7 @@ ural_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) ural_tx_free(data, 0); usbd_xfer_set_priv(xfer, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; /* FALLTHROUGH */ @@ -859,7 +859,7 @@ ural_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); data = usbd_xfer_get_priv(xfer); if (data != NULL) { ural_tx_free(data, error); @@ -900,7 +900,7 @@ ural_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) if (len < (int)(RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN)) { DPRINTF("%s: xfer too short %d\n", device_get_nameunit(sc->sc_dev), len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } @@ -919,14 +919,14 @@ ural_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) * filled RAL_TXRX_CSR2: */ DPRINTFN(5, "PHY or CRC error\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) { DPRINTF("could not allocate mbuf\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } usbd_copy_out(pc, 0, mtod(m, uint8_t *), len); @@ -1370,7 +1370,7 @@ ural_start(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (ural_tx_data(sc, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } } @@ -2210,7 +2210,7 @@ ural_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return EIO; } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (params == NULL) { /* @@ -2230,7 +2230,7 @@ ural_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, RAL_UNLOCK(sc); return 0; bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); RAL_UNLOCK(sc); ieee80211_free_node(ni); return EIO; /* XXX */ @@ -2284,7 +2284,7 @@ ural_ratectl_task(void *arg, int pending) ieee80211_ratectl_tx_update(vap, ni, &sum, &ok, &retrycnt); (void) ieee80211_ratectl_rate(ni, NULL, 0); - ifp->if_oerrors += fail; /* count TX retry-fail as Tx errors */ + if_inc_counter(ifp, IFCOUNTER_OERRORS, fail); /* count TX retry-fail as Tx errors */ usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); RAL_UNLOCK(sc); diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index d2837324b63f..d2c6ef975a9f 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -1472,7 +1472,7 @@ urtw_start(struct ifnet *ifp) m->m_pkthdr.rcvif = NULL; if (urtw_tx_start(sc, ni, m, bf, URTW_PRIORITY_NORMAL) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); ieee80211_free_node(ni); break; @@ -1582,10 +1582,10 @@ urtw_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return (ENOBUFS); /* XXX */ } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (urtw_tx_start(sc, ni, m, bf, URTW_PRIORITY_LOW) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); URTW_UNLOCK(sc); return (EIO); @@ -1918,7 +1918,7 @@ urtw_watchdog(void *arg) if (sc->sc_txtimer > 0) { if (--sc->sc_txtimer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); @@ -3993,7 +3993,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p, usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); if (actlen < (int)URTW_MIN_RXBUFSZ) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } @@ -4004,7 +4004,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p, (actlen - (sizeof(struct urtw_8187b_rxhdr)))); flen = le32toh(rx->flag) & 0xfff; if (flen > actlen) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } rate = (le32toh(rx->flag) >> URTW_RX_FLAG_RXRATE_SHIFT) & 0xf; @@ -4018,7 +4018,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p, (actlen - (sizeof(struct urtw_8187l_rxhdr)))); flen = le32toh(rx->flag) & 0xfff; if (flen > actlen) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } @@ -4030,7 +4030,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p, mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); if (mnew == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } @@ -4127,7 +4127,7 @@ urtw_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto setup; } break; @@ -4156,7 +4156,7 @@ urtw_txstatus_eof(struct usb_xfer *xfer) pktretry = val & 0xff; seq = (val >> 16) & 0xff; if (pktretry == URTW_TX_MAXRETRY) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); DPRINTF(sc, URTW_DEBUG_TXSTATUS, "pktretry %d seq %#x\n", pktretry, seq); } @@ -4184,7 +4184,7 @@ urtw_bulk_tx_status_callback(struct usb_xfer *xfer, usb_error_t error) default: if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto setup; } break; @@ -4218,7 +4218,7 @@ urtw_txeof(struct usb_xfer *xfer, struct urtw_data *data) data->ni = NULL; } sc->sc_txtimer = 0; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } @@ -4265,7 +4265,7 @@ urtw_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error) if (data->ni != NULL) { ieee80211_free_node(data->ni); data->ni = NULL; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 1f1446cdfcd7..1f728d40c85d 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -141,6 +141,7 @@ static const STRUCT_USB_HOST_ID urtwn_devs[] = { URTWN_DEV(REALTEK, RTL8188CUS), URTWN_DEV(REALTEK, RTL8188RU_1), URTWN_DEV(REALTEK, RTL8188RU_2), + URTWN_DEV(REALTEK, RTL8188RU_3), URTWN_DEV(REALTEK, RTL8191CU), URTWN_DEV(REALTEK, RTL8192CE), URTWN_DEV(REALTEK, RTL8192CU), @@ -657,7 +658,11 @@ urtwn_rx_frame(struct urtwn_softc *sc, uint8_t *buf, int pktlen, int *rssi_p) * This should not happen since we setup our Rx filter * to not receive these frames. */ - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + return (NULL); + } + if (pktlen < sizeof(*wh) || pktlen > MCLBYTES) { + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } @@ -742,7 +747,7 @@ urtwn_rxeof(struct usb_xfer *xfer, struct urtwn_data *data, int *rssi, usbd_xfer_status(xfer, &len, NULL, NULL, NULL); if (len < sizeof(*stat)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (NULL); } @@ -857,7 +862,7 @@ urtwn_bulk_rx_callback(struct usb_xfer *xfer, usb_error_t error) } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto tr_setup; } break; @@ -891,7 +896,7 @@ urtwn_txeof(struct usb_xfer *xfer, struct urtwn_data *data) data->ni = NULL; } sc->sc_txtimer = 0; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } @@ -933,7 +938,7 @@ urtwn_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error) if (data->ni != NULL) { ieee80211_free_node(data->ni); data->ni = NULL; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } if (error != USB_ERR_CANCELLED) { usbd_xfer_set_stall(xfer); @@ -1664,7 +1669,7 @@ urtwn_watchdog(void *arg) if (sc->sc_txtimer > 0) { if (--sc->sc_txtimer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } callout_reset(&sc->sc_watchdog_ch, hz, urtwn_watchdog, sc); @@ -1968,7 +1973,7 @@ urtwn_start_locked(struct ifnet *ifp, struct urtwn_softc *sc) m->m_pkthdr.rcvif = NULL; if (urtwn_tx_start(sc, ni, m, bf) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); ieee80211_free_node(ni); break; @@ -3524,10 +3529,10 @@ urtwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return (ENOBUFS); } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (urtwn_tx_start(sc, ni, m, bf) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); URTWN_UNLOCK(sc); return (EIO); diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index 1e06d1512d18..2db22f531cde 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -679,7 +679,7 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error) ieee80211_free_node(ni); } if (le16toh(retry->count) & 0x100) - ifp->if_oerrors++; /* too many retries */ + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* too many retries */ break; } case ZYD_NOTIF_IORD: @@ -2188,7 +2188,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len) if (len < ZYD_MIN_FRAGSZ) { DPRINTF(sc, ZYD_DEBUG_RECV, "%s: frame too short (length=%d)\n", device_get_nameunit(sc->sc_dev), len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } pc = usbd_xfer_get_frame(xfer, 0); @@ -2199,7 +2199,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len) DPRINTF(sc, ZYD_DEBUG_RECV, "%s: RX status indicated error (%x)\n", device_get_nameunit(sc->sc_dev), stat.flags); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -2211,7 +2211,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len) if (rlen > (int)MCLBYTES) { DPRINTF(sc, ZYD_DEBUG_RECV, "%s: frame too long (length=%d)\n", device_get_nameunit(sc->sc_dev), rlen); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } else if (rlen > (int)MHLEN) m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); @@ -2220,7 +2220,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len) if (m == NULL) { DPRINTF(sc, ZYD_DEBUG_RECV, "%s: could not allocate rx mbuf\n", device_get_nameunit(sc->sc_dev)); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } m->m_pkthdr.rcvif = ifp; @@ -2403,7 +2403,7 @@ zyd_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) zyd_tx_free(data, 0); usbd_xfer_set_priv(xfer, NULL); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; /* FALLTHROUGH */ @@ -2447,7 +2447,7 @@ zyd_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) DPRINTF(sc, ZYD_DEBUG_ANY, "transfer error, %s\n", usbd_errstr(error)); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); data = usbd_xfer_get_priv(xfer); usbd_xfer_set_priv(xfer, NULL); if (data != NULL) @@ -2608,7 +2608,7 @@ zyd_start(struct ifnet *ifp) ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; if (zyd_tx_start(sc, m, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } } @@ -2646,7 +2646,7 @@ zyd_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, */ if (zyd_tx_start(sc, m, ni) != 0) { ZYD_UNLOCK(sc); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_free_node(ni); return (EIO); } diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c index 13276d95bfa6..315f273eef9d 100644 --- a/sys/dev/vge/if_vge.c +++ b/sys/dev/vge/if_vge.c @@ -1400,7 +1400,7 @@ vge_freebufs(struct vge_softc *sc) txd->tx_dmamap); m_freem(txd->tx_m); txd->tx_m = NULL; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } } } @@ -1467,7 +1467,7 @@ vge_rxeof(struct vge_softc *sc, int count) */ if ((rxstat & VGE_RXPKT_SOF) != 0) { if (vge_newbuf(sc, prod) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); VGE_CHAIN_RESET(sc); vge_discard_rxbuf(sc, prod); continue; @@ -1498,7 +1498,7 @@ vge_rxeof(struct vge_softc *sc, int count) if ((rxstat & VGE_RDSTS_RXOK) == 0 && (rxstat & (VGE_RDSTS_VIDM | VGE_RDSTS_RLERR | VGE_RDSTS_CSUMERR)) == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); /* * If this is part of a multi-fragment packet, * discard all the pieces. @@ -1509,7 +1509,7 @@ vge_rxeof(struct vge_softc *sc, int count) } if (vge_newbuf(sc, prod) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); VGE_CHAIN_RESET(sc); vge_discard_rxbuf(sc, prod); continue; @@ -2380,7 +2380,7 @@ vge_watchdog(void *arg) ifp = sc->vge_ifp; if_printf(ifp, "watchdog timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); vge_txeof(sc); vge_rxeof(sc, VGE_RX_DESC_CNT); @@ -2706,24 +2706,25 @@ vge_stats_update(struct vge_softc *sc) stats->tx_latecolls += mib[VGE_MIB_TX_LATECOLLS]; /* Update counters in ifnet. */ - ifp->if_opackets += mib[VGE_MIB_TX_GOOD_FRAMES]; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, mib[VGE_MIB_TX_GOOD_FRAMES]); - ifp->if_collisions += mib[VGE_MIB_TX_COLLS] + - mib[VGE_MIB_TX_LATECOLLS]; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + mib[VGE_MIB_TX_COLLS] + mib[VGE_MIB_TX_LATECOLLS]); - ifp->if_oerrors += mib[VGE_MIB_TX_COLLS] + - mib[VGE_MIB_TX_LATECOLLS]; + if_inc_counter(ifp, IFCOUNTER_OERRORS, + mib[VGE_MIB_TX_COLLS] + mib[VGE_MIB_TX_LATECOLLS]); - ifp->if_ipackets += mib[VGE_MIB_RX_GOOD_FRAMES]; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, mib[VGE_MIB_RX_GOOD_FRAMES]); - ifp->if_ierrors += mib[VGE_MIB_RX_FIFO_OVERRUNS] + + if_inc_counter(ifp, IFCOUNTER_IERRORS, + mib[VGE_MIB_RX_FIFO_OVERRUNS] + mib[VGE_MIB_RX_RUNTS] + mib[VGE_MIB_RX_RUNTS_ERRS] + mib[VGE_MIB_RX_CRCERRS] + mib[VGE_MIB_RX_ALIGNERRS] + mib[VGE_MIB_RX_NOBUFS] + mib[VGE_MIB_RX_SYMERRS] + - mib[VGE_MIB_RX_LENERRS]; + mib[VGE_MIB_RX_LENERRS]); } static void diff --git a/sys/pci/viapm.c b/sys/dev/viapm/viapm.c similarity index 100% rename from sys/pci/viapm.c rename to sys/dev/viapm/viapm.c diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 38de48e37bef..1310f30bc239 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -107,6 +107,7 @@ static int vtnet_alloc_virtqueues(struct vtnet_softc *); static int vtnet_setup_interface(struct vtnet_softc *); static int vtnet_change_mtu(struct vtnet_softc *, int); static int vtnet_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t vtnet_get_counter(struct ifnet *, ift_counter); static int vtnet_rxq_populate(struct vtnet_rxq *); static void vtnet_rxq_free_mbufs(struct vtnet_rxq *); @@ -160,11 +161,8 @@ static void vtnet_qflush(struct ifnet *); #endif static int vtnet_watchdog(struct vtnet_txq *); -static void vtnet_rxq_accum_stats(struct vtnet_rxq *, - struct vtnet_rxq_stats *); -static void vtnet_txq_accum_stats(struct vtnet_txq *, - struct vtnet_txq_stats *); -static void vtnet_accumulate_stats(struct vtnet_softc *); +static void vtnet_accum_stats(struct vtnet_softc *, + struct vtnet_rxq_stats *, struct vtnet_txq_stats *); static void vtnet_tick(void *); static void vtnet_start_taskqueues(struct vtnet_softc *); @@ -921,7 +919,7 @@ vtnet_setup_interface(struct vtnet_softc *sc) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = vtnet_init; ifp->if_ioctl = vtnet_ioctl; - + ifp->if_get_counter = vtnet_get_counter; #ifndef VTNET_LEGACY_TX ifp->if_transmit = vtnet_txq_mq_start; ifp->if_qflush = vtnet_qflush; @@ -2573,74 +2571,62 @@ vtnet_watchdog(struct vtnet_txq *txq) } static void -vtnet_rxq_accum_stats(struct vtnet_rxq *rxq, struct vtnet_rxq_stats *accum) +vtnet_accum_stats(struct vtnet_softc *sc, struct vtnet_rxq_stats *rxacc, + struct vtnet_txq_stats *txacc) { - struct vtnet_rxq_stats *st; - st = &rxq->vtnrx_stats; + bzero(rxacc, sizeof(struct vtnet_rxq_stats)); + bzero(txacc, sizeof(struct vtnet_txq_stats)); - accum->vrxs_ipackets += st->vrxs_ipackets; - accum->vrxs_ibytes += st->vrxs_ibytes; - accum->vrxs_iqdrops += st->vrxs_iqdrops; - accum->vrxs_csum += st->vrxs_csum; - accum->vrxs_csum_failed += st->vrxs_csum_failed; - accum->vrxs_rescheduled += st->vrxs_rescheduled; + for (int i = 0; i < sc->vtnet_max_vq_pairs; i++) { + struct vtnet_rxq_stats *rxst; + struct vtnet_txq_stats *txst; + + rxst = &sc->vtnet_rxqs[i].vtnrx_stats; + rxacc->vrxs_ipackets += rxst->vrxs_ipackets; + rxacc->vrxs_ibytes += rxst->vrxs_ibytes; + rxacc->vrxs_iqdrops += rxst->vrxs_iqdrops; + rxacc->vrxs_csum += rxst->vrxs_csum; + rxacc->vrxs_csum_failed += rxst->vrxs_csum_failed; + rxacc->vrxs_rescheduled += rxst->vrxs_rescheduled; + + txst = &sc->vtnet_txqs[i].vtntx_stats; + txacc->vtxs_opackets += txst->vtxs_opackets; + txacc->vtxs_obytes += txst->vtxs_obytes; + txacc->vtxs_csum += txst->vtxs_csum; + txacc->vtxs_tso += txst->vtxs_tso; + txacc->vtxs_rescheduled += txst->vtxs_rescheduled; + } } -static void -vtnet_txq_accum_stats(struct vtnet_txq *txq, struct vtnet_txq_stats *accum) +static uint64_t +vtnet_get_counter(if_t ifp, ift_counter cnt) { - struct vtnet_txq_stats *st; - - st = &txq->vtntx_stats; - - accum->vtxs_opackets += st->vtxs_opackets; - accum->vtxs_obytes += st->vtxs_obytes; - accum->vtxs_csum += st->vtxs_csum; - accum->vtxs_tso += st->vtxs_tso; - accum->vtxs_rescheduled += st->vtxs_rescheduled; -} - -static void -vtnet_accumulate_stats(struct vtnet_softc *sc) -{ - struct ifnet *ifp; - struct vtnet_statistics *st; + struct vtnet_softc *sc; struct vtnet_rxq_stats rxaccum; struct vtnet_txq_stats txaccum; - int i; - ifp = sc->vtnet_ifp; - st = &sc->vtnet_stats; - bzero(&rxaccum, sizeof(struct vtnet_rxq_stats)); - bzero(&txaccum, sizeof(struct vtnet_txq_stats)); + sc = if_getsoftc(ifp); + vtnet_accum_stats(sc, &rxaccum, &txaccum); - for (i = 0; i < sc->vtnet_max_vq_pairs; i++) { - vtnet_rxq_accum_stats(&sc->vtnet_rxqs[i], &rxaccum); - vtnet_txq_accum_stats(&sc->vtnet_txqs[i], &txaccum); - } - - st->rx_csum_offloaded = rxaccum.vrxs_csum; - st->rx_csum_failed = rxaccum.vrxs_csum_failed; - st->rx_task_rescheduled = rxaccum.vrxs_rescheduled; - st->tx_csum_offloaded = txaccum.vtxs_csum; - st->tx_tso_offloaded = txaccum.vtxs_tso; - st->tx_task_rescheduled = txaccum.vtxs_rescheduled; - - /* - * With the exception of if_ierrors, these ifnet statistics are - * only updated in the driver, so just set them to our accumulated - * values. if_ierrors is updated in ether_input() for malformed - * frames that we should have already discarded. - */ - ifp->if_ipackets = rxaccum.vrxs_ipackets; - ifp->if_iqdrops = rxaccum.vrxs_iqdrops; - ifp->if_ierrors = rxaccum.vrxs_ierrors; - ifp->if_opackets = txaccum.vtxs_opackets; + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (rxaccum.vrxs_ipackets); + case IFCOUNTER_IQDROPS: + return (rxaccum.vrxs_iqdrops); + case IFCOUNTER_IERRORS: + return (rxaccum.vrxs_ierrors); + case IFCOUNTER_OPACKETS: + return (txaccum.vtxs_opackets); #ifndef VTNET_LEGACY_TX - ifp->if_obytes = txaccum.vtxs_obytes; - ifp->if_omcasts = txaccum.vtxs_omcasts; + case IFCOUNTER_OBYTES: + return (txaccum.vtxs_obytes); + case IFCOUNTER_OMCASTS: + return (txaccum.vtxs_omcasts); #endif + default: + return (if_get_counter_default(ifp, cnt)); + } } static void @@ -2655,7 +2641,6 @@ vtnet_tick(void *xsc) timedout = 0; VTNET_CORE_LOCK_ASSERT(sc); - vtnet_accumulate_stats(sc); for (i = 0; i < sc->vtnet_act_vq_pairs; i++) timedout |= vtnet_watchdog(&sc->vtnet_txqs[i]); @@ -3762,8 +3747,18 @@ vtnet_setup_stat_sysctl(struct sysctl_ctx_list *ctx, struct sysctl_oid_list *child, struct vtnet_softc *sc) { struct vtnet_statistics *stats; + struct vtnet_rxq_stats rxaccum; + struct vtnet_txq_stats txaccum; + + vtnet_accum_stats(sc, &rxaccum, &txaccum); stats = &sc->vtnet_stats; + stats->rx_csum_offloaded = rxaccum.vrxs_csum; + stats->rx_csum_failed = rxaccum.vrxs_csum_failed; + stats->rx_task_rescheduled = rxaccum.vrxs_rescheduled; + stats->tx_csum_offloaded = txaccum.vtxs_csum; + stats->tx_tso_offloaded = txaccum.vtxs_tso; + stats->tx_task_rescheduled = txaccum.vtxs_rescheduled; SYSCTL_ADD_UQUAD(ctx, child, OID_AUTO, "mbuf_alloc_failed", CTLFLAG_RD, &stats->mbuf_alloc_failed, diff --git a/sys/dev/vmware/vmxnet3/if_vmx.c b/sys/dev/vmware/vmxnet3/if_vmx.c index f3fde92e3f7a..1d8c12e2fc9b 100644 --- a/sys/dev/vmware/vmxnet3/if_vmx.c +++ b/sys/dev/vmware/vmxnet3/if_vmx.c @@ -187,6 +187,7 @@ static void vmxnet3_unregister_vlan(void *, struct ifnet *, uint16_t); static void vmxnet3_set_rxfilter(struct vmxnet3_softc *); static int vmxnet3_change_mtu(struct vmxnet3_softc *, int); static int vmxnet3_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t vmxnet3_get_counter(struct ifnet *, ift_counter); #ifndef VMXNET3_LEGACY_TX static void vmxnet3_qflush(struct ifnet *); @@ -194,10 +195,6 @@ static void vmxnet3_qflush(struct ifnet *); static int vmxnet3_watchdog(struct vmxnet3_txqueue *); static void vmxnet3_refresh_host_stats(struct vmxnet3_softc *); -static void vmxnet3_txq_accum_stats(struct vmxnet3_txqueue *, - struct vmxnet3_txq_stats *); -static void vmxnet3_rxq_accum_stats(struct vmxnet3_rxqueue *, - struct vmxnet3_rxq_stats *); static void vmxnet3_tick(void *); static void vmxnet3_link_status(struct vmxnet3_softc *); static void vmxnet3_media_status(struct ifnet *, struct ifmediareq *); @@ -1722,7 +1719,10 @@ vmxnet3_setup_interface(struct vmxnet3_softc *sc) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = vmxnet3_init; ifp->if_ioctl = vmxnet3_ioctl; - ifp->if_hw_tsomax = VMXNET3_TSO_MAXSIZE; + ifp->if_get_counter = vmxnet3_get_counter; + ifp->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + ifp->if_hw_tsomaxsegcount = VMXNET3_TX_MAXSEGS; + ifp->if_hw_tsomaxsegsize = VMXNET3_TX_MAXSEGSIZE; #ifdef VMXNET3_LEGACY_TX ifp->if_start = vmxnet3_start; @@ -3342,56 +3342,14 @@ vmxnet3_refresh_host_stats(struct vmxnet3_softc *sc) vmxnet3_write_cmd(sc, VMXNET3_CMD_GET_STATS); } -static void -vmxnet3_txq_accum_stats(struct vmxnet3_txqueue *txq, - struct vmxnet3_txq_stats *accum) +static uint64_t +vmxnet3_get_counter(struct ifnet *ifp, ift_counter cnt) { - struct vmxnet3_txq_stats *st; + struct vmxnet3_softc *sc; + uint64_t rv; - st = &txq->vxtxq_stats; - - accum->vmtxs_opackets += st->vmtxs_opackets; - accum->vmtxs_obytes += st->vmtxs_obytes; - accum->vmtxs_omcasts += st->vmtxs_omcasts; - accum->vmtxs_csum += st->vmtxs_csum; - accum->vmtxs_tso += st->vmtxs_tso; - accum->vmtxs_full += st->vmtxs_full; - accum->vmtxs_offload_failed += st->vmtxs_offload_failed; -} - -static void -vmxnet3_rxq_accum_stats(struct vmxnet3_rxqueue *rxq, - struct vmxnet3_rxq_stats *accum) -{ - struct vmxnet3_rxq_stats *st; - - st = &rxq->vxrxq_stats; - - accum->vmrxs_ipackets += st->vmrxs_ipackets; - accum->vmrxs_ibytes += st->vmrxs_ibytes; - accum->vmrxs_iqdrops += st->vmrxs_iqdrops; - accum->vmrxs_ierrors += st->vmrxs_ierrors; -} - -static void -vmxnet3_accumulate_stats(struct vmxnet3_softc *sc) -{ - struct ifnet *ifp; - struct vmxnet3_statistics *st; - struct vmxnet3_txq_stats txaccum; - struct vmxnet3_rxq_stats rxaccum; - int i; - - ifp = sc->vmx_ifp; - st = &sc->vmx_stats; - - bzero(&txaccum, sizeof(struct vmxnet3_txq_stats)); - bzero(&rxaccum, sizeof(struct vmxnet3_rxq_stats)); - - for (i = 0; i < sc->vmx_ntxqueues; i++) - vmxnet3_txq_accum_stats(&sc->vmx_txq[i], &txaccum); - for (i = 0; i < sc->vmx_nrxqueues; i++) - vmxnet3_rxq_accum_stats(&sc->vmx_rxq[i], &rxaccum); + sc = if_getsoftc(ifp); + rv = 0; /* * With the exception of if_ierrors, these ifnet statistics are @@ -3399,14 +3357,36 @@ vmxnet3_accumulate_stats(struct vmxnet3_softc *sc) * values. if_ierrors is updated in ether_input() for malformed * frames that we should have already discarded. */ - ifp->if_ipackets = rxaccum.vmrxs_ipackets; - ifp->if_iqdrops = rxaccum.vmrxs_iqdrops; - ifp->if_ierrors = rxaccum.vmrxs_ierrors; - ifp->if_opackets = txaccum.vmtxs_opackets; + switch (cnt) { + case IFCOUNTER_IPACKETS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets; + return (rv); + case IFCOUNTER_IQDROPS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops; + return (rv); + case IFCOUNTER_IERRORS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors; + return (rv); + case IFCOUNTER_OPACKETS: + for (int i = 0; i < sc->vmx_ntxqueues; i++) + rv += sc->vmx_txq[i].vxtxq_stats.vmtxs_opackets; + return (rv); #ifndef VMXNET3_LEGACY_TX - ifp->if_obytes = txaccum.vmtxs_obytes; - ifp->if_omcasts = txaccum.vmtxs_omcasts; + case IFCOUNTER_OBYTES: + for (int i = 0; i < sc->vmx_ntxqueues; i++) + rv += sc->vmx_txq[i].vxtxq_stats.vmtxs_obytes; + return (rv); + case IFCOUNTER_OMCASTS: + for (int i = 0; i < sc->vmx_ntxqueues; i++) + rv += sc->vmx_txq[i].vxtxq_stats.vmtxs_omcasts; + return (rv); #endif + default: + return (if_get_counter_default(ifp, cnt)); + } } static void @@ -3422,7 +3402,6 @@ vmxnet3_tick(void *xsc) VMXNET3_CORE_LOCK_ASSERT(sc); - vmxnet3_accumulate_stats(sc); vmxnet3_refresh_host_stats(sc); for (i = 0; i < sc->vmx_ntxqueues; i++) diff --git a/sys/dev/vmware/vmxnet3/if_vmxvar.h b/sys/dev/vmware/vmxnet3/if_vmxvar.h index 6c797214b2ee..861351603e2b 100644 --- a/sys/dev/vmware/vmxnet3/if_vmxvar.h +++ b/sys/dev/vmware/vmxnet3/if_vmxvar.h @@ -277,8 +277,6 @@ struct vmxnet3_softc { */ #define VMXNET3_TX_MAXSEGS 32 #define VMXNET3_TX_MAXSIZE (VMXNET3_TX_MAXSEGS * MCLBYTES) -#define VMXNET3_TSO_MAXSIZE \ - (VMXNET3_TX_MAXSIZE - sizeof(struct ether_vlan_header)) /* * Maximum support Tx segments size. The length field in the diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 104687231533..fdf82a588f17 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -1325,7 +1325,7 @@ vr_rxeof(struct vr_softc *sc) if ((rxstat & VR_RXSTAT_RX_OK) == 0 || (rxstat & (VR_RXSTAT_FIRSTFRAG | VR_RXSTAT_LASTFRAG)) != (VR_RXSTAT_FIRSTFRAG | VR_RXSTAT_LASTFRAG)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); sc->vr_stat.rx_errors++; if (rxstat & VR_RXSTAT_CRCERR) sc->vr_stat.rx_crc_errors++; @@ -1348,7 +1348,7 @@ vr_rxeof(struct vr_softc *sc) } if (vr_newbuf(sc, cons) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); sc->vr_stat.rx_errors++; sc->vr_stat.rx_no_mbufs++; vr_discard_rxbuf(rxd); @@ -1376,7 +1376,7 @@ vr_rxeof(struct vr_softc *sc) vr_fixup_rx(m); #endif m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); sc->vr_stat.rx_ok++; if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 && (rxstat & VR_RXSTAT_FRAG) == 0 && @@ -1466,7 +1466,7 @@ vr_txeof(struct vr_softc *sc) __func__)); if ((txstat & VR_TXSTAT_ERRSUM) != 0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); sc->vr_stat.tx_errors++; if ((txstat & VR_TXSTAT_ABRT) != 0) { /* Give up and restart Tx. */ @@ -1504,28 +1504,28 @@ vr_txeof(struct vr_softc *sc) return; } if ((txstat & VR_TXSTAT_DEFER) != 0) { - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); sc->vr_stat.tx_collisions++; } if ((txstat & VR_TXSTAT_LATECOLL) != 0) { - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); sc->vr_stat.tx_late_collisions++; } } else { sc->vr_stat.tx_ok++; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } bus_dmamap_sync(sc->vr_cdata.vr_tx_tag, txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->vr_cdata.vr_tx_tag, txd->tx_dmamap); if (sc->vr_revid < REV_ID_VT3071_A) { - ifp->if_collisions += - (txstat & VR_TXSTAT_COLLCNT) >> 3; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + (txstat & VR_TXSTAT_COLLCNT) >> 3); sc->vr_stat.tx_collisions += (txstat & VR_TXSTAT_COLLCNT) >> 3; } else { - ifp->if_collisions += (txstat & 0x0f); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (txstat & 0x0f)); sc->vr_stat.tx_collisions += (txstat & 0x0f); } m_freem(txd->tx_m); @@ -2318,13 +2318,13 @@ vr_watchdog(struct vr_softc *sc) if (bootverbose) if_printf(sc->vr_ifp, "watchdog timeout " "(missed link)\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; vr_init_locked(sc); return; } - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/dev/vt/hw/efifb/efifb.c b/sys/dev/vt/hw/efifb/efifb.c index ff95391a6ce7..05b2d795228a 100644 --- a/sys/dev/vt/hw/efifb/efifb.c +++ b/sys/dev/vt/hw/efifb/efifb.c @@ -62,6 +62,8 @@ static struct vt_driver vt_efifb_driver = { .vd_blank = vt_fb_blank, .vd_bitblt_text = vt_fb_bitblt_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_drawrect = vt_fb_drawrect, + .vd_setpixel = vt_fb_setpixel, .vd_fb_ioctl = vt_fb_ioctl, .vd_fb_mmap = vt_fb_mmap, /* Better than VGA, but still generic driver. */ diff --git a/sys/dev/vt/hw/fb/vt_early_fb.c b/sys/dev/vt/hw/fb/vt_early_fb.c index ff50a9ccda55..187f7f72dd93 100644 --- a/sys/dev/vt/hw/fb/vt_early_fb.c +++ b/sys/dev/vt/hw/fb/vt_early_fb.c @@ -61,6 +61,8 @@ static struct vt_driver vt_fb_early_driver = { .vd_blank = vt_fb_blank, .vd_bitblt_text = vt_fb_bitblt_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_drawrect = vt_fb_drawrect, + .vd_setpixel = vt_fb_setpixel, .vd_priority = VD_PRIORITY_GENERIC, }; diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c index ddec76d1cc69..422bb034bf16 100644 --- a/sys/dev/vt/hw/fb/vt_fb.c +++ b/sys/dev/vt/hw/fb/vt_fb.c @@ -41,9 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include -static vd_drawrect_t vt_fb_drawrect; -static vd_setpixel_t vt_fb_setpixel; - static struct vt_driver vt_fb_driver = { .vd_name = "fb", .vd_init = vt_fb_init, @@ -146,7 +143,7 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr, return (EINVAL); } -static void +void vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color) { struct fb_info *info; @@ -181,7 +178,7 @@ vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color) } -static void +void vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, term_color_t color) { diff --git a/sys/dev/vt/hw/fb/vt_fb.h b/sys/dev/vt/hw/fb/vt_fb.h index 9a0da6ebbc3b..43ce2b7b4c64 100644 --- a/sys/dev/vt/hw/fb/vt_fb.h +++ b/sys/dev/vt/hw/fb/vt_fb.h @@ -40,6 +40,8 @@ vd_init_t vt_fb_init; vd_blank_t vt_fb_blank; vd_bitblt_text_t vt_fb_bitblt_text; vd_bitblt_bmp_t vt_fb_bitblt_bitmap; +vd_drawrect_t vt_fb_drawrect; +vd_setpixel_t vt_fb_setpixel; vd_postswitch_t vt_fb_postswitch; vd_fb_ioctl_t vt_fb_ioctl; vd_fb_mmap_t vt_fb_mmap; diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c index 75d42b583d89..ad5b664a9d71 100644 --- a/sys/dev/vt/hw/ofwfb/ofwfb.c +++ b/sys/dev/vt/hw/ofwfb/ofwfb.c @@ -53,7 +53,7 @@ struct ofwfb_softc { phandle_t sc_node; ihandle_t sc_handle; - bus_space_tag_t sc_memt; + bus_space_tag_t sc_memt; }; static vd_probe_t ofwfb_probe; diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c index 487ed4fb633b..abddbf50ce10 100644 --- a/sys/dev/vt/hw/vga/vt_vga.c +++ b/sys/dev/vt/hw/vga/vt_vga.c @@ -352,6 +352,9 @@ static void vga_setpixel(struct vt_device *vd, int x, int y, term_color_t color) { + if (vd->vd_flags & VDF_TEXTMODE) + return; + vga_bitblt_put(vd, (y * VT_VGA_WIDTH / 8) + (x / 8), color, 0x80 >> (x % 8)); } @@ -362,6 +365,9 @@ vga_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill, { int x, y; + if (vd->vd_flags & VDF_TEXTMODE) + return; + for (y = y1; y <= y2; y++) { if (fill || (y == y1) || (y == y2)) { for (x = x1; x <= x2; x++) diff --git a/sys/dev/vt/logo/logo_freebsd.c b/sys/dev/vt/logo/logo_freebsd.c index fc70570876ae..beb3f0c4990b 100644 --- a/sys/dev/vt/logo/logo_freebsd.c +++ b/sys/dev/vt/logo/logo_freebsd.c @@ -637,5 +637,5 @@ unsigned char vt_logo_image[] = { 0x1f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, }; diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index b9303bae3274..578f1a8ff09e 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -87,12 +87,6 @@ static int vt_##_name = _default; \ SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\ _descr); -/* Allow to disable some special keys by users. */ -#define VT_DEBUG_KEY_ENABLED (1 << 0) -#define VT_REBOOT_KEY_ENABLED (1 << 1) -#define VT_HALT_KEY_ENABLED (1 << 2) -#define VT_POWEROFF_KEY_ENABLED (1 << 3) - struct vt_driver; void vt_allocate(struct vt_driver *, void *); @@ -119,11 +113,17 @@ typedef unsigned int vt_axis_t; struct vt_mouse_cursor; #endif +struct vt_pastebuf { + term_char_t *vpb_buf; /* Copy-paste buffer. */ + unsigned int vpb_bufsz; /* Buffer size. */ + unsigned int vpb_len; /* Length of a last selection. */ +}; + struct vt_device { struct vt_window *vd_windows[VT_MAXWINDOWS]; /* (c) Windows. */ struct vt_window *vd_curwindow; /* (d) Current window. */ struct vt_window *vd_savedwindow;/* (?) Saved for suspend. */ - struct vt_window *vd_markedwin; /* (?) Copy/paste buf owner. */ + struct vt_pastebuf vd_pastebuf; /* (?) Copy/paste buf. */ const struct vt_driver *vd_driver; /* (c) Graphics driver. */ void *vd_softc; /* (u) Driver data. */ #ifndef SC_NO_CUTPASTE @@ -157,6 +157,10 @@ struct vt_device { unsigned int vd_unit; /* (c) Device unit. */ }; +#define VD_PASTEBUF(vd) ((vd)->vd_pastebuf.vpb_buf) +#define VD_PASTEBUFSZ(vd) ((vd)->vd_pastebuf.vpb_bufsz) +#define VD_PASTEBUFLEN(vd) ((vd)->vd_pastebuf.vpb_len) + /* * Per-window terminal screen buffer. * @@ -168,11 +172,6 @@ struct vt_device { * been modified. */ -struct vt_bufmask { - uint64_t vbm_row, vbm_col; -#define VBM_DIRTY UINT64_MAX -}; - struct vt_buf { struct mtx vb_lock; /* Buffer lock. */ term_pos_t vb_scr_size; /* (b) Screen dimensions. */ @@ -191,7 +190,6 @@ struct vt_buf { term_pos_t vb_mark_end; /* (b) Copy region end. */ int vb_mark_last; /* Last mouse event. */ term_rect_t vb_dirtyrect; /* (b) Dirty rectangle. */ - struct vt_bufmask vb_dirtymask; /* (b) Dirty bitmasks. */ term_char_t *vb_buffer; /* (u) Data buffer. */ term_char_t **vb_rows; /* (u) Array of rows */ }; @@ -205,7 +203,7 @@ void vtbuf_putchar(struct vt_buf *, const term_pos_t *, term_char_t); void vtbuf_cursor_position(struct vt_buf *, const term_pos_t *); void vtbuf_scroll_mode(struct vt_buf *vb, int yes); void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area); -void vtbuf_undirty(struct vt_buf *, term_rect_t *, struct vt_bufmask *); +void vtbuf_undirty(struct vt_buf *, term_rect_t *); void vtbuf_sethistory_size(struct vt_buf *, int); int vtbuf_iscursor(const struct vt_buf *vb, int row, int col); void vtbuf_cursor_visibility(struct vt_buf *, int); @@ -262,6 +260,7 @@ struct vt_window { unsigned int vw_number; /* (c) Window number. */ int vw_kbdmode; /* (?) Keyboard mode. */ int vw_prev_kbdmode;/* (?) Previous mode. */ + int vw_kbdstate; /* (?) Keyboard state. */ int vw_grabbed; /* (?) Grab count. */ char *vw_kbdsq; /* Escape sequence queue*/ unsigned int vw_flags; /* (d) Per-window flags. */ diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index d468173605e6..cc23b3b6c99b 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -76,44 +76,47 @@ vthistory_seek(struct vt_buf *vb, int offset, int whence) } return (0); /* No changes */ } - top = (vb->vb_flags & VBF_HISTORY_FULL)? - (vb->vb_curroffset + vb->vb_scr_size.tp_row):vb->vb_history_size; - bottom = vb->vb_curroffset + vb->vb_history_size; - /* - * Operate on copy of offset value, since it temporary can be bigger - * than amount of rows in buffer. - */ - roffset = vb->vb_roffset + vb->vb_history_size; + /* "top" may be a negative integer. */ + bottom = vb->vb_curroffset; + top = (vb->vb_flags & VBF_HISTORY_FULL) ? + bottom + vb->vb_scr_size.tp_row - vb->vb_history_size : + 0; + + roffset = 0; /* Make gcc happy. */ switch (whence) { case VHS_SET: - roffset = offset + vb->vb_history_size; + if (offset < 0) + offset = 0; + roffset = top + offset; break; case VHS_CUR: + /* + * Operate on copy of offset value, since it temporary + * can be bigger than amount of rows in buffer. + */ + roffset = vb->vb_roffset; + if (roffset >= bottom + vb->vb_scr_size.tp_row) + roffset -= vb->vb_history_size; + roffset += offset; + roffset = MAX(roffset, top); + roffset = MIN(roffset, bottom); + + if (roffset < 0) + roffset = vb->vb_history_size + roffset; + break; case VHS_END: /* Go to current offset. */ - roffset = vb->vb_curroffset + vb->vb_history_size; + roffset = vb->vb_curroffset; break; } - roffset = (roffset < top)?top:roffset; - roffset = (roffset > bottom)?bottom:roffset; + diff = vb->vb_roffset != roffset; + vb->vb_roffset = roffset; - roffset %= vb->vb_history_size; - - if (vb->vb_roffset != roffset) { - diff = vb->vb_roffset - roffset; - vb->vb_roffset = roffset; - /* - * Offset changed, please update Nth lines on sceen. - * +N - Nth lines at top; - * -N - Nth lines at bottom. - */ - return (diff); - } - return (0); /* No changes */ + return (diff); } void @@ -123,6 +126,8 @@ vthistory_addlines(struct vt_buf *vb, int offset) vb->vb_curroffset += offset; if (vb->vb_curroffset < 0) vb->vb_curroffset = 0; + if (vb->vb_curroffset + vb->vb_scr_size.tp_row >= vb->vb_history_size) + vb->vb_flags |= VBF_HISTORY_FULL; vb->vb_curroffset %= vb->vb_history_size; if ((vb->vb_flags & VBF_SCROLL) == 0) { vb->vb_roffset = vb->vb_curroffset; @@ -195,39 +200,6 @@ vtbuf_iscursor(const struct vt_buf *vb, int row, int col) return (0); } -static inline uint64_t -vtbuf_dirty_axis(unsigned int begin, unsigned int end) -{ - uint64_t left, right, mask; - - /* - * Mark all bits between begin % 64 and end % 64 dirty. - * This code is functionally equivalent to: - * - * for (i = begin; i < end; i++) - * mask |= (uint64_t)1 << (i % 64); - */ - - /* Obvious case. Mark everything dirty. */ - if (end - begin >= 64) - return (VBM_DIRTY); - - /* 1....0; used bits on the left. */ - left = VBM_DIRTY << begin % 64; - /* 0....1; used bits on the right. */ - right = VBM_DIRTY >> -end % 64; - - /* - * Only take the intersection. If the result of that is 0, it - * means that the selection crossed a 64 bit boundary along the - * way, which means we have to take the complement. - */ - mask = left & right; - if (mask == 0) - mask = left | right; - return (mask); -} - static inline void vtbuf_dirty_locked(struct vt_buf *vb, const term_rect_t *area) { @@ -240,10 +212,6 @@ vtbuf_dirty_locked(struct vt_buf *vb, const term_rect_t *area) vb->vb_dirtyrect.tr_end.tp_row = area->tr_end.tp_row; if (vb->vb_dirtyrect.tr_end.tp_col < area->tr_end.tp_col) vb->vb_dirtyrect.tr_end.tp_col = area->tr_end.tp_col; - vb->vb_dirtymask.vbm_row |= - vtbuf_dirty_axis(area->tr_begin.tp_row, area->tr_end.tp_row); - vb->vb_dirtymask.vbm_col |= - vtbuf_dirty_axis(area->tr_begin.tp_col, area->tr_end.tp_col); } void @@ -272,16 +240,14 @@ vtbuf_make_undirty(struct vt_buf *vb) vb->vb_dirtyrect.tr_begin = vb->vb_scr_size; vb->vb_dirtyrect.tr_end.tp_row = vb->vb_dirtyrect.tr_end.tp_col = 0; - vb->vb_dirtymask.vbm_row = vb->vb_dirtymask.vbm_col = 0; } void -vtbuf_undirty(struct vt_buf *vb, term_rect_t *r, struct vt_bufmask *m) +vtbuf_undirty(struct vt_buf *vb, term_rect_t *r) { VTBUF_LOCK(vb); *r = vb->vb_dirtyrect; - *m = vb->vb_dirtymask; vtbuf_make_undirty(vb); VTBUF_UNLOCK(vb); } @@ -321,7 +287,7 @@ vtbuf_copy(struct vt_buf *vb, const term_rect_t *r, const term_pos_t *p2) if (r->tr_begin.tp_row > p2->tp_row && r->tr_begin.tp_col == 0 && r->tr_end.tp_col == vb->vb_scr_size.tp_col && /* Full row. */ (rows + rdiff) == vb->vb_scr_size.tp_row && /* Whole screen. */ - rdiff > 0) { /* Only forward dirrection. Do not eat history. */ + rdiff > 0) { /* Only forward direction. Do not eat history. */ vthistory_addlines(vb, rdiff); } else if (p2->tp_row < p1->tp_row) { /* Handle overlapping copies of line segments. */ @@ -453,71 +419,155 @@ vtbuf_sethistory_size(struct vt_buf *vb, int size) void vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, unsigned int history_size) { - term_char_t *old, *new, **rows, **oldrows, **copyrows, *row; - int bufsize, rowssize, w, h, c, r; + term_char_t *old, *new, **rows, **oldrows, **copyrows, *row, *oldrow; + int bufsize, rowssize, w, h, c, r, history_was_full; + unsigned int old_history_size; term_rect_t rect; history_size = MAX(history_size, p->tp_row); - /* If new screen/history size bigger or buffer is VBF_STATIC. */ - if ((history_size > vb->vb_history_size) || (p->tp_col > - vb->vb_scr_size.tp_col) || (vb->vb_flags & VBF_STATIC)) { - /* Allocate new buffer. */ - bufsize = history_size * p->tp_col * sizeof(term_char_t); - new = malloc(bufsize, M_VTBUF, M_WAITOK | M_ZERO); - rowssize = history_size * sizeof(term_pos_t *); - rows = malloc(rowssize, M_VTBUF, M_WAITOK | M_ZERO); + /* Allocate new buffer. */ + bufsize = history_size * p->tp_col * sizeof(term_char_t); + new = malloc(bufsize, M_VTBUF, M_WAITOK | M_ZERO); + rowssize = history_size * sizeof(term_pos_t *); + rows = malloc(rowssize, M_VTBUF, M_WAITOK | M_ZERO); - /* Toggle it. */ - VTBUF_LOCK(vb); - old = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_buffer; - oldrows = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_rows; - copyrows = vb->vb_rows; - w = vb->vb_scr_size.tp_col; - h = vb->vb_history_size; + /* Toggle it. */ + VTBUF_LOCK(vb); + old = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_buffer; + oldrows = vb->vb_flags & VBF_STATIC ? NULL : vb->vb_rows; + copyrows = vb->vb_rows; - vb->vb_history_size = history_size; - vb->vb_buffer = new; - vb->vb_rows = rows; - vb->vb_flags &= ~VBF_STATIC; - vb->vb_scr_size = *p; - vtbuf_init_rows(vb); + w = vb->vb_scr_size.tp_col; + h = vb->vb_scr_size.tp_row; + old_history_size = vb->vb_history_size; + history_was_full = vb->vb_flags & VBF_HISTORY_FULL; + + vb->vb_history_size = history_size; + vb->vb_buffer = new; + vb->vb_rows = rows; + vb->vb_flags &= ~VBF_STATIC; + vb->vb_scr_size = *p; + vtbuf_init_rows(vb); + + /* Copy history and fill extra space if needed. */ + if (history_size > old_history_size) { + /* + * Copy rows to the new buffer. The first row in the history + * is back to index 0, ie. the new buffer doesn't cycle. + * + * The rest of the new buffer is initialized with blank + * content. + */ + for (r = 0; r < old_history_size; r ++) { + row = rows[r]; + + /* Compute the corresponding row in the old buffer. */ + if (history_was_full) + /* + * The buffer is full, the "top" row is + * the one just after the viewable area + * (curroffset + viewable height) in the + * cycling buffer. The corresponding row + * is computed from this top row. + */ + oldrow = copyrows[ + (vb->vb_curroffset + h + r) % + old_history_size]; + else + /* + * The buffer is not full, therefore, + * we didn't cycle already. The + * corresponding rows are the same in + * both buffers. + */ + oldrow = copyrows[r]; + + memmove(row, oldrow, + MIN(p->tp_col, w) * sizeof(term_char_t)); - /* Copy history and fill extra space. */ - for (r = 0; r < history_size; r ++) { /* * XXX VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR) will * extended lines of kernel text using the wrong * background color. */ - row = rows[r]; - if (r < h) { /* Copy. */ - memmove(rows[r], copyrows[r], - MIN(p->tp_col, w) * sizeof(term_char_t)); - for (c = MIN(p->tp_col, w); c < p->tp_col; - c++) { - row[c] = VTBUF_SPACE_CHAR( - TERMINAL_NORM_ATTR); - } - } else { /* Just fill. */ - rect.tr_begin.tp_col = 0; - rect.tr_begin.tp_row = r; - rect.tr_end.tp_col = p->tp_col; - rect.tr_end.tp_row = p->tp_row; - vtbuf_fill(vb, &rect, - VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR)); - break; + for (c = MIN(p->tp_col, w); c < p->tp_col; c++) { + row[c] = VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR); } } - vtbuf_make_undirty(vb); - VTBUF_UNLOCK(vb); - /* Deallocate old buffer. */ - free(old, M_VTBUF); - free(oldrows, M_VTBUF); + + /* Fill remaining rows. */ + rect.tr_begin.tp_col = 0; + rect.tr_begin.tp_row = old_history_size; + rect.tr_end.tp_col = p->tp_col; + rect.tr_end.tp_row = p->tp_row; + vtbuf_fill(vb, &rect, VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR)); + + vb->vb_flags &= ~VBF_HISTORY_FULL; } else { - /* Just update the size. */ - vb->vb_scr_size = *p; + /* + * Copy rows to the new buffer. The first row in the history + * is back to index 0, ie. the new buffer doesn't cycle. + * + * (old_history_size - history_size) lines of history are + * dropped. + */ + for (r = 0; r < history_size; r ++) { + row = rows[r]; + + /* + * Compute the corresponding row in the old buffer. + * + * See the equivalent if{} block above for an + * explanation. + */ + if (history_was_full) + oldrow = copyrows[ + (vb->vb_curroffset + h + r + + (old_history_size - history_size)) % + old_history_size]; + else + oldrow = copyrows[ + (r + (old_history_size - history_size)) % + old_history_size]; + + memmove(row, oldrow, + MIN(p->tp_col, w) * sizeof(term_char_t)); + + /* + * XXX VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR) will + * extended lines of kernel text using the wrong + * background color. + */ + for (c = MIN(p->tp_col, w); c < p->tp_col; c++) { + row[c] = VTBUF_SPACE_CHAR(TERMINAL_NORM_ATTR); + } + } + + if (!history_was_full && + (vb->vb_curroffset + h) >= history_size) + vb->vb_flags |= VBF_HISTORY_FULL; } + + /* + * If the screen is already filled (there are non-visible lines + * above the current viewable area), adjust curroffset to the + * new viewable area. + */ + if (!history_was_full && vb->vb_curroffset > 0) { + vb->vb_curroffset = vb->vb_curroffset + h - p->tp_row; + if (vb->vb_curroffset < 0) + vb->vb_curroffset += vb->vb_history_size; + vb->vb_curroffset %= vb->vb_history_size; + vb->vb_roffset = vb->vb_curroffset; + } + + vtbuf_make_undirty(vb); + VTBUF_UNLOCK(vb); + + /* Deallocate old buffer. */ + free(old, M_VTBUF); + free(oldrows, M_VTBUF); } void @@ -603,7 +653,7 @@ vtbuf_get_marked_len(struct vt_buf *vb) ei = e.tp_row * vb->vb_scr_size.tp_col + e.tp_col; /* Number symbols and number of rows to inject \n */ - sz = ei - si + ((e.tp_row - s.tp_row) * 2) + 1; + sz = ei - si + ((e.tp_row - s.tp_row) * 2); return (sz * sizeof(term_char_t)); } diff --git a/sys/dev/vt/vt_consolectl.c b/sys/dev/vt/vt_consolectl.c index 32e3ba6a9ce5..a7042fd14706 100644 --- a/sys/dev/vt/vt_consolectl.c +++ b/sys/dev/vt/vt_consolectl.c @@ -51,7 +51,7 @@ consolectl_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, { switch (cmd) { - case CONS_GETVERS: + case CONS_GETVERS: *(int*)data = 0x200; return 0; case CONS_MOUSECTL: { diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 2f5e9c99cb22..2dd7e3f134bd 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -122,9 +123,18 @@ VT_SYSCTL_INT(enable_altgr, 1, "Enable AltGr key (Do not assume R.Alt as Alt)"); VT_SYSCTL_INT(debug, 0, "vt(9) debug level"); VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode"); VT_SYSCTL_INT(suspendswitch, 1, "Switch to VT0 before suspend"); -VT_SYSCTL_INT(spclkeys, (VT_DEBUG_KEY_ENABLED|VT_REBOOT_KEY_ENABLED| - VT_HALT_KEY_ENABLED|VT_POWEROFF_KEY_ENABLED), "Enabled special keys " - "handled by vt(4)"); + +/* Allow to disable some keyboard combinations. */ +VT_SYSCTL_INT(kbd_halt, 1, "Enable halt keyboard combination. " + "See kbdmap(5) to configure."); +VT_SYSCTL_INT(kbd_poweroff, 1, "Enable Power Off keyboard combination. " + "See kbdmap(5) to configure."); +VT_SYSCTL_INT(kbd_reboot, 1, "Enable reboot keyboard combination. " + "See kbdmap(5) to configure (typically Ctrl-Alt-Delete)."); +VT_SYSCTL_INT(kbd_debug, 1, "Enable key combination to enter debugger. " + "See kbdmap(5) to configure (typically Ctrl-Alt-Esc)."); +VT_SYSCTL_INT(kbd_panic, 0, "Enable request to panic. " + "See kbdmap(5) to configure."); static struct vt_device vt_consdev; static unsigned int vt_unit = 0; @@ -152,6 +162,9 @@ static int vt_late_window_switch(struct vt_window *); static int vt_proc_alive(struct vt_window *); static void vt_resize(struct vt_device *); static void vt_update_static(void *); +#ifndef SC_NO_CUTPASTE +static void vt_mouse_paste(void); +#endif SET_DECLARE(vt_drv_set, struct vt_driver); @@ -166,10 +179,14 @@ static struct vt_device vt_consdev = { .vd_flags = VDF_INVALID, .vd_windows = { [VT_CONSWINDOW] = &vt_conswindow, }, .vd_curwindow = &vt_conswindow, - .vd_markedwin = NULL, .vd_kbstate = 0, #ifndef SC_NO_CUTPASTE + .vd_pastebuf = { + .vpb_buf = NULL, + .vpb_bufsz = 0, + .vpb_len = 0 + }, .vd_mcursor = &vt_default_mouse_pointer, .vd_mcursor_fg = TC_WHITE, .vd_mcursor_bg = TC_BLACK, @@ -280,6 +297,97 @@ vt_switch_timer(void *arg) vt_late_window_switch((struct vt_window *)arg); } +static int +vt_save_kbd_mode(struct vt_window *vw, keyboard_t *kbd) +{ + int mode, ret; + + mode = 0; + ret = kbdd_ioctl(kbd, KDGKBMODE, (caddr_t)&mode); + if (ret == ENOIOCTL) + ret = ENODEV; + if (ret != 0) + return (ret); + + vw->vw_kbdmode = mode; + + return (0); +} + +static int +vt_update_kbd_mode(struct vt_window *vw, keyboard_t *kbd) +{ + int ret; + + ret = kbdd_ioctl(kbd, KDSKBMODE, (caddr_t)&vw->vw_kbdmode); + if (ret == ENOIOCTL) + ret = ENODEV; + + return (ret); +} + +static int +vt_save_kbd_state(struct vt_window *vw, keyboard_t *kbd) +{ + int state, ret; + + state = 0; + ret = kbdd_ioctl(kbd, KDGKBSTATE, (caddr_t)&state); + if (ret == ENOIOCTL) + ret = ENODEV; + if (ret != 0) + return (ret); + + vw->vw_kbdstate &= ~LOCK_MASK; + vw->vw_kbdstate |= state & LOCK_MASK; + + return (0); +} + +static int +vt_update_kbd_state(struct vt_window *vw, keyboard_t *kbd) +{ + int state, ret; + + state = vw->vw_kbdstate & LOCK_MASK; + ret = kbdd_ioctl(kbd, KDSKBSTATE, (caddr_t)&state); + if (ret == ENOIOCTL) + ret = ENODEV; + + return (ret); +} + +static int +vt_save_kbd_leds(struct vt_window *vw, keyboard_t *kbd) +{ + int leds, ret; + + leds = 0; + ret = kbdd_ioctl(kbd, KDGETLED, (caddr_t)&leds); + if (ret == ENOIOCTL) + ret = ENODEV; + if (ret != 0) + return (ret); + + vw->vw_kbdstate &= ~LED_MASK; + vw->vw_kbdstate |= leds & LED_MASK; + + return (0); +} + +static int +vt_update_kbd_leds(struct vt_window *vw, keyboard_t *kbd) +{ + int leds, ret; + + leds = vw->vw_kbdstate & LED_MASK; + ret = kbdd_ioctl(kbd, KDSETLED, (caddr_t)&leds); + if (ret == ENOIOCTL) + ret = ENODEV; + + return (ret); +} + static int vt_window_preswitch(struct vt_window *vw, struct vt_window *curvw) { @@ -337,7 +445,7 @@ vt_proc_window_switch(struct vt_window *vw) if (curvw->vw_flags & VWF_VTYLOCK) return (EBUSY); - /* Ask current process permitions to switch away. */ + /* Ask current process permission to switch away. */ if (curvw->vw_smode.mode == VT_PROCESS) { DPRINTF(30, "%s: VT_PROCESS ", __func__); if (vt_proc_alive(curvw) == FALSE) { @@ -392,7 +500,11 @@ vt_window_switch(struct vt_window *vw) mtx_lock(&Giant); kbd = kbd_get_keyboard(vd->vd_keyboard); if (kbd != NULL) { - kbdd_ioctl(kbd, KDSKBMODE, (void *)&vw->vw_kbdmode); + if (curvw->vw_kbdmode == K_XLATE) + vt_save_kbd_state(curvw, kbd); + + vt_update_kbd_mode(vw, kbd); + vt_update_kbd_state(vw, kbd); } mtx_unlock(&Giant); DPRINTF(10, "%s(ttyv%d) done\n", __func__, vw->vw_number); @@ -430,10 +542,16 @@ vt_compute_drawable_area(struct vt_window *vw) struct vt_device *vd; struct vt_font *vf; - if (vw->vw_font == NULL) - return; - vd = vw->vw_device; + + if (vw->vw_font == NULL) { + vw->vw_draw_area.tr_begin.tp_col = 0; + vw->vw_draw_area.tr_begin.tp_row = 0; + vw->vw_draw_area.tr_end.tp_col = vd->vd_width; + vw->vw_draw_area.tr_end.tp_row = vd->vd_height; + return; + } + vf = vw->vw_font; /* @@ -461,18 +579,8 @@ vt_scroll(struct vt_window *vw, int offset, int whence) vt_termsize(vw->vw_device, vw->vw_font, &size); diff = vthistory_seek(&vw->vw_buf, offset, whence); - /* - * Offset changed, please update Nth lines on screen. - * +N - Nth lines at top; - * -N - Nth lines at bottom. - */ - - if (diff < -size.tp_row || diff > size.tp_row) { + if (diff) vw->vw_device->vd_flags |= VDF_INVALID; - vt_resume_flush_timer(vw->vw_device, 0); - return; - } - vw->vw_device->vd_flags |= VDF_INVALID; /*XXX*/ vt_resume_flush_timer(vw->vw_device, 0); } @@ -481,23 +589,48 @@ vt_machine_kbdevent(int c) { switch (c) { - case SPCLKEY | DBG: - if (vt_spclkeys & VT_DEBUG_KEY_ENABLED) + case SPCLKEY | DBG: /* kbdmap(5) keyword `debug`. */ + if (vt_kbd_debug) kdb_enter(KDB_WHY_BREAK, "manual escape to debugger"); return (1); - case SPCLKEY | RBT: - if (vt_spclkeys & VT_REBOOT_KEY_ENABLED) - /* XXX: Make this configurable! */ - shutdown_nice(0); - return (1); - case SPCLKEY | HALT: - if (vt_spclkeys & VT_HALT_KEY_ENABLED) + case SPCLKEY | HALT: /* kbdmap(5) keyword `halt`. */ + if (vt_kbd_halt) shutdown_nice(RB_HALT); return (1); - case SPCLKEY | PDWN: - if (vt_spclkeys & VT_POWEROFF_KEY_ENABLED) + case SPCLKEY | PASTE: /* kbdmap(5) keyword `paste`. */ +#ifndef SC_NO_CUTPASTE + /* Insert text from cut-paste buffer. */ + vt_mouse_paste(); +#endif + break; + case SPCLKEY | PDWN: /* kbdmap(5) keyword `pdwn`. */ + if (vt_kbd_poweroff) shutdown_nice(RB_HALT|RB_POWEROFF); return (1); + case SPCLKEY | PNC: /* kbdmap(5) keyword `panic`. */ + /* + * Request to immediate panic if sysctl + * kern.vt.enable_panic_key allow it. + */ + if (vt_kbd_panic) + panic("Forced by the panic key"); + return (1); + case SPCLKEY | RBT: /* kbdmap(5) keyword `boot`. */ + if (vt_kbd_reboot) + shutdown_nice(RB_AUTOBOOT); + return (1); + case SPCLKEY | SPSC: /* kbdmap(5) keyword `spsc`. */ + /* Force activatation/deactivation of the screen saver. */ + /* TODO */ + return (1); + case SPCLKEY | STBY: /* XXX Not present in kbdcontrol parser. */ + /* Put machine into Stand-By mode. */ + power_pm_suspend(POWER_SLEEP_STATE_STANDBY); + return (1); + case SPCLKEY | SUSP: /* kbdmap(5) keyword `susp`. */ + /* Suspend machine. */ + power_pm_suspend(POWER_SLEEP_STATE_SUSPEND); + return (1); }; return (0); @@ -564,7 +697,6 @@ static int vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c) { struct vt_window *vw = vd->vd_curwindow; - int state = 0; #if VT_ALT_TO_ESC_HACK if (c & RELKEY) { @@ -612,11 +744,24 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c) } switch (c) { + case NEXT: + /* Switch to next VT. */ + c = (vw->vw_number + 1) % VT_MAXWINDOWS; + vw = vd->vd_windows[c]; + if (vw != NULL) + vt_proc_window_switch(vw); + return (0); + case PREV: + /* Switch to previous VT. */ + c = (vw->vw_number - 1) % VT_MAXWINDOWS; + vw = vd->vd_windows[c]; + if (vw != NULL) + vt_proc_window_switch(vw); + return (0); case SLK: { - - kbdd_ioctl(kbd, KDGKBSTATE, (caddr_t)&state); + vt_save_kbd_state(vw, kbd); VT_LOCK(vd); - if (state & SLKED) { + if (vw->vw_kbdstate & SLKED) { /* Turn scrolling on. */ vw->vw_flags |= VWF_SCROLL; VTBUF_SLCK_ENABLE(&vw->vw_buf); @@ -734,7 +879,8 @@ vt_allocate_keyboard(struct vt_device *vd) continue; bzero(&ki, sizeof(ki)); - strcpy(ki.kb_name, k->kb_name); + strncpy(ki.kb_name, k->kb_name, sizeof(ki.kb_name)); + ki.kb_name[sizeof(ki.kb_name) - 1] = '\0'; ki.kb_unit = k->kb_unit; kbdd_ioctl(k0, KBADDKBD, (caddr_t) &ki); @@ -929,7 +1075,6 @@ vt_flush(struct vt_device *vd) { struct vt_window *vw; struct vt_font *vf; - struct vt_bufmask tmask; term_rect_t tarea; term_pos_t size; #ifndef SC_NO_CUTPASTE @@ -985,14 +1130,13 @@ vt_flush(struct vt_device *vd) vt_mark_mouse_position_as_dirty(vd); #endif - vtbuf_undirty(&vw->vw_buf, &tarea, &tmask); + vtbuf_undirty(&vw->vw_buf, &tarea); vt_termsize(vd, vf, &size); /* Force a full redraw when the screen contents are invalid. */ if (vd->vd_flags & VDF_INVALID) { tarea.tr_begin.tp_row = tarea.tr_begin.tp_col = 0; tarea.tr_end = size; - tmask.vbm_row = tmask.vbm_col = VBM_DIRTY; vd->vd_flags &= ~VDF_INVALID; } @@ -1120,6 +1264,13 @@ vtterm_cnprobe(struct terminal *tm, struct consdev *cp) vt_compute_drawable_area(vw); } + /* + * The original screen size was faked (_VTDEFW x _VTDEFH). Now + * that we have the real viewable size, fix it in the static + * buffer. + */ + vt_termsize(vd, vw->vw_font, &vw->vw_buf.vb_scr_size); + vtbuf_init_early(&vw->vw_buf); vt_winsize(vd, vw->vw_font, &wsz); c = (boothowto & RB_MUTE) == 0 ? TERMINAL_KERN_ATTR : @@ -1143,13 +1294,11 @@ vtterm_cngetc(struct terminal *tm) struct vt_window *vw = tm->tm_softc; struct vt_device *vd = vw->vw_device; keyboard_t *kbd; - int state; u_int c; if (vw->vw_kbdsq && *vw->vw_kbdsq) return (*vw->vw_kbdsq++); - state = 0; /* Make sure the splash screen is not there. */ if (vd->vd_flags & VDF_SPLASH) { /* Remove splash */ @@ -1165,8 +1314,8 @@ vtterm_cngetc(struct terminal *tm) return (-1); /* Force keyboard input mode to K_XLATE */ - c = K_XLATE; - kbdd_ioctl(kbd, KDSKBMODE, (void *)&c); + vw->vw_kbdmode = K_XLATE; + vt_update_kbd_mode(vw, kbd); /* Switch the keyboard to polling to make it work here. */ kbdd_poll(kbd, TRUE); @@ -1185,8 +1334,8 @@ vtterm_cngetc(struct terminal *tm) if (c & SPCLKEY) { switch (c) { case SPCLKEY | SLK: - kbdd_ioctl(kbd, KDGKBSTATE, (caddr_t)&state); - if (state & SLKED) { + vt_save_kbd_state(vw, kbd); + if (vw->vw_kbdstate & SLKED) { /* Turn scrolling on. */ vw->vw_flags |= VWF_SCROLL; VTBUF_SLCK_ENABLE(&vw->vw_buf); @@ -1253,7 +1402,7 @@ vtterm_cngrab(struct terminal *tm) /* We shall always use the keyboard in the XLATE mode here. */ vw->vw_prev_kbdmode = vw->vw_kbdmode; vw->vw_kbdmode = K_XLATE; - (void)kbdd_ioctl(kbd, KDSKBMODE, (caddr_t)&vw->vw_kbdmode); + vt_update_kbd_mode(vw, kbd); kbdd_poll(kbd, TRUE); } @@ -1278,7 +1427,7 @@ vtterm_cnungrab(struct terminal *tm) kbdd_poll(kbd, FALSE); vw->vw_kbdmode = vw->vw_prev_kbdmode; - (void)kbdd_ioctl(kbd, KDSKBMODE, (caddr_t)&vw->vw_kbdmode); + vt_update_kbd_mode(vw, kbd); kbdd_disable(kbd); } @@ -1300,30 +1449,40 @@ vtterm_opened(struct terminal *tm, int opened) } static int -vt_set_border(struct vt_window *vw, struct vt_font *vf, term_color_t c) +vt_set_border(struct vt_window *vw, term_color_t c) { struct vt_device *vd = vw->vw_device; - int x, y, off_x, off_y; if (vd->vd_driver->vd_drawrect == NULL) return (ENOTSUP); - x = vd->vd_width - 1; - y = vd->vd_height - 1; - off_x = vw->vw_draw_area.tr_begin.tp_col; - off_y = vw->vw_draw_area.tr_begin.tp_row; - /* Top bar. */ - if (off_y > 0) - vd->vd_driver->vd_drawrect(vd, 0, 0, x, off_y - 1, 1, c); - /* Left bar. */ - if (off_x > 0) - vd->vd_driver->vd_drawrect(vd, 0, off_y, off_x - 1, y - off_y, + if (vw->vw_draw_area.tr_begin.tp_row > 0) + vd->vd_driver->vd_drawrect(vd, + 0, 0, + vd->vd_width - 1, vw->vw_draw_area.tr_begin.tp_row - 1, + 1, c); + + /* Left bar. */ + if (vw->vw_draw_area.tr_begin.tp_col > 0) + vd->vd_driver->vd_drawrect(vd, + 0, 0, + vw->vw_draw_area.tr_begin.tp_col - 1, vd->vd_height - 1, + 1, c); + + /* Right bar. */ + if (vw->vw_draw_area.tr_end.tp_col < vd->vd_width) + vd->vd_driver->vd_drawrect(vd, + vw->vw_draw_area.tr_end.tp_col - 1, 0, + vd->vd_width - 1, vd->vd_height - 1, + 1, c); + + /* Bottom bar. */ + if (vw->vw_draw_area.tr_end.tp_row < vd->vd_height) + vd->vd_driver->vd_drawrect(vd, + 0, vw->vw_draw_area.tr_end.tp_row - 1, + vd->vd_width - 1, vd->vd_height - 1, 1, c); - /* Right bar. May be 1 pixel wider than necessary due to rounding. */ - vd->vd_driver->vd_drawrect(vd, x - off_x, off_y, x, y - off_y, 1, c); - /* Bottom bar. May be 1 mixel taller than necessary due to rounding. */ - vd->vd_driver->vd_drawrect(vd, 0, y - off_y, x, y, 1, c); return (0); } @@ -1355,11 +1514,6 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf) VT_UNLOCK(vd); return (EBUSY); } - if (vd->vd_flags & VDF_TEXTMODE) { - /* Our device doesn't need fonts. */ - VT_UNLOCK(vd); - return (ENOTTY); - } vw->vw_flags |= VWF_BUSY; VT_UNLOCK(vd); @@ -1374,7 +1528,7 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf) /* Actually apply the font to the current window. */ VT_LOCK(vd); - if (vw->vw_font != vf) { + if (vw->vw_font != vf && vw->vw_font != NULL && vf != NULL) { /* * In case vt_change_font called to update size we don't need * to update font link. @@ -1397,7 +1551,7 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf) /* Force a full redraw the next timer tick. */ if (vd->vd_curwindow == vw) { - vt_set_border(vw, vf, TC_BLACK); + vt_set_border(vw, TC_BLACK); vd->vd_flags |= VDF_INVALID; vt_resume_flush_timer(vw->vw_device, 0); } @@ -1516,7 +1670,7 @@ vt_mouse_terminput_button(struct vt_device *vd, int button) mouseb[4] = '!' + x; mouseb[5] = '!' + y; - for (i = 0; i < sizeof(mouseb); i++ ) + for (i = 0; i < sizeof(mouseb); i++) terminal_input_char(vw->vw_terminal, mouseb[i]); } @@ -1554,6 +1708,23 @@ vt_mouse_terminput(struct vt_device *vd, int type, int x, int y, int event, } } +static void +vt_mouse_paste() +{ + term_char_t *buf; + int i, len; + + len = VD_PASTEBUFLEN(main_vd); + buf = VD_PASTEBUF(main_vd); + len /= sizeof(term_char_t); + for (i = 0; i < len; i++) { + if (buf[i] == '\0') + continue; + terminal_input_char(main_vd->vd_curwindow->vw_terminal, + buf[i]); + } +} + void vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) { @@ -1561,8 +1732,7 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) struct vt_window *vw; struct vt_font *vf; term_pos_t size; - term_char_t *buf; - int i, len, mark; + int len, mark; vd = main_vd; vw = vd->vd_curwindow; @@ -1605,17 +1775,10 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) vd->vd_mx = x; vd->vd_my = y; - if ((vd->vd_mstate & MOUSE_BUTTON1DOWN) && - (vtbuf_set_mark(&vw->vw_buf, VTB_MARK_MOVE, - vd->vd_mx / vf->vf_width, - vd->vd_my / vf->vf_height) == 1)) { - - /* - * We have something marked to copy, so update pointer - * to window with selection. - */ - vd->vd_markedwin = vw; - } + if (vd->vd_mstate & MOUSE_BUTTON1DOWN) + vtbuf_set_mark(&vw->vw_buf, VTB_MARK_MOVE, + vd->vd_mx / vf->vf_width, + vd->vd_my / vf->vf_height); vt_resume_flush_timer(vw->vw_device, 0); return; /* Done */ @@ -1648,27 +1811,7 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) case 0: /* up */ break; default: - if (vd->vd_markedwin == NULL) - return; - /* Get current selecton size in bytes. */ - len = vtbuf_get_marked_len(&vd->vd_markedwin->vw_buf); - if (len <= 0) - return; - - buf = malloc(len, M_VT, M_WAITOK | M_ZERO); - /* Request cupy/paste buffer data, no more than `len' */ - vtbuf_extract_marked(&vd->vd_markedwin->vw_buf, buf, - len); - - len /= sizeof(term_char_t); - for (i = 0; i < len; i++ ) { - if (buf[i] == '\0') - continue; - terminal_input_char(vw->vw_terminal, buf[i]); - } - - /* Done, so cleanup. */ - free(buf, M_VT); + vt_mouse_paste(); break; } return; /* Done */ @@ -1701,8 +1844,38 @@ vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) * We have something marked to copy, so update pointer to * window with selection. */ - vd->vd_markedwin = vw; vt_resume_flush_timer(vw->vw_device, 0); + + switch (mark) { + case VTB_MARK_END: + case VTB_MARK_WORD: + case VTB_MARK_ROW: + case VTB_MARK_EXTEND: + break; + default: + /* Other types of mark do not require to copy data. */ + return; + } + + /* Get current selection size in bytes. */ + len = vtbuf_get_marked_len(&vw->vw_buf); + if (len <= 0) + return; + + /* Reallocate buffer only if old one is too small. */ + if (len > VD_PASTEBUFSZ(vd)) { + VD_PASTEBUF(vd) = realloc(VD_PASTEBUF(vd), len, M_VT, + M_WAITOK | M_ZERO); + /* Update buffer size. */ + VD_PASTEBUFSZ(vd) = len; + } + /* Request copy/paste buffer data, no more than `len' */ + vtbuf_extract_marked(&vw->vw_buf, VD_PASTEBUF(vd), + VD_PASTEBUFSZ(vd)); + + VD_PASTEBUFLEN(vd) = len; + + /* XXX VD_PASTEBUF(vd) have to be freed on shutdown/unload. */ } } @@ -1808,12 +1981,8 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, case SETFKEY: case KDGKBINFO: case KDGKBTYPE: - case KDSKBSTATE: /* set keyboard state (locks) */ - case KDGKBSTATE: /* get keyboard state (locks) */ case KDGETREPEAT: /* get keyboard repeat & delay rates */ case KDSETREPEAT: /* set keyboard repeat & delay rates (new) */ - case KDSETLED: /* set keyboard LED status */ - case KDGETLED: /* get keyboard LED status */ case KBADDKBD: /* add/remove keyboard to/from mux */ case KBRELKBD: { error = 0; @@ -1833,18 +2002,101 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, } return (error); } - case KDGKBMODE: { - int mode = -1; + case KDGKBSTATE: { /* get keyboard state (locks) */ + error = 0; - mtx_lock(&Giant); - kbd = kbd_get_keyboard(vd->vd_keyboard); - if (kbd != NULL) { - kbdd_ioctl(kbd, KDGKBMODE, (void *)&mode); + if (vw == vd->vd_curwindow) { + mtx_lock(&Giant); + kbd = kbd_get_keyboard(vd->vd_keyboard); + if (kbd != NULL) + error = vt_save_kbd_state(vw, kbd); + mtx_unlock(&Giant); + + if (error != 0) + return (error); } - mtx_unlock(&Giant); - DPRINTF(20, "mode %d, vw_kbdmode %d\n", mode, vw->vw_kbdmode); - *(int *)data = mode; - return (0); + + *(int *)data = vw->vw_kbdstate & LOCK_MASK; + + return (error); + } + case KDSKBSTATE: { /* set keyboard state (locks) */ + int state; + + state = *(int *)data; + if (state & ~LOCK_MASK) + return (EINVAL); + + vw->vw_kbdstate &= ~LOCK_MASK; + vw->vw_kbdstate |= state; + + error = 0; + if (vw == vd->vd_curwindow) { + mtx_lock(&Giant); + kbd = kbd_get_keyboard(vd->vd_keyboard); + if (kbd != NULL) + error = vt_update_kbd_state(vw, kbd); + mtx_unlock(&Giant); + } + + return (error); + } + case KDGETLED: { /* get keyboard LED status */ + error = 0; + + if (vw == vd->vd_curwindow) { + mtx_lock(&Giant); + kbd = kbd_get_keyboard(vd->vd_keyboard); + if (kbd != NULL) + error = vt_save_kbd_leds(vw, kbd); + mtx_unlock(&Giant); + + if (error != 0) + return (error); + } + + *(int *)data = vw->vw_kbdstate & LED_MASK; + + return (error); + } + case KDSETLED: { /* set keyboard LED status */ + int leds; + + leds = *(int *)data; + if (leds & ~LED_MASK) + return (EINVAL); + + vw->vw_kbdstate &= ~LED_MASK; + vw->vw_kbdstate |= leds; + + error = 0; + if (vw == vd->vd_curwindow) { + mtx_lock(&Giant); + kbd = kbd_get_keyboard(vd->vd_keyboard); + if (kbd != NULL) + error = vt_update_kbd_leds(vw, kbd); + mtx_unlock(&Giant); + } + + return (error); + } + case KDGKBMODE: { + error = 0; + + if (vw == vd->vd_curwindow) { + mtx_lock(&Giant); + kbd = kbd_get_keyboard(vd->vd_keyboard); + if (kbd != NULL) + error = vt_save_kbd_mode(vw, kbd); + mtx_unlock(&Giant); + + if (error != 0) + return (error); + } + + *(int *)data = vw->vw_kbdmode; + + return (error); } case KDSKBMODE: { int mode; @@ -1855,19 +2107,17 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, case K_RAW: case K_CODE: vw->vw_kbdmode = mode; - if (vw == vd->vd_curwindow) { - keyboard_t *kbd; - error = 0; + error = 0; + if (vw == vd->vd_curwindow) { mtx_lock(&Giant); kbd = kbd_get_keyboard(vd->vd_keyboard); - if (kbd != NULL) { - error = kbdd_ioctl(kbd, KDSKBMODE, - (void *)&mode); - } + if (kbd != NULL) + error = vt_update_kbd_mode(vw, kbd); mtx_unlock(&Giant); } - return (0); + + return (error); default: return (EINVAL); } @@ -1895,8 +2145,17 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, return (0); case CONS_GETINFO: { vid_info_t *vi = (vid_info_t *)data; + if (vi->size != sizeof(struct vid_info)) + return (EINVAL); + + if (vw == vd->vd_curwindow) { + kbd = kbd_get_keyboard(vd->vd_keyboard); + if (kbd != NULL) + vt_save_kbd_state(vw, kbd); + } vi->m_num = vd->vd_curwindow->vw_number + 1; + vi->mk_keylock = vw->vw_kbdstate & LOCK_MASK; /* XXX: other fields! */ return (0); } @@ -2011,13 +2270,14 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, (void *)vd, vt_kbdevent, vd); if (i >= 0) { if (vd->vd_keyboard != -1) { + vt_save_kbd_state(vd->vd_curwindow, kbd); kbd_release(kbd, (void *)vd); } kbd = kbd_get_keyboard(i); vd->vd_keyboard = i; - (void)kbdd_ioctl(kbd, KDSKBMODE, - (caddr_t)&vd->vd_curwindow->vw_kbdmode); + vt_update_kbd_mode(vd->vd_curwindow, kbd); + vt_update_kbd_state(vd->vd_curwindow, kbd); } else { error = EPERM; /* XXX */ } @@ -2033,6 +2293,7 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, mtx_unlock(&Giant); return (EINVAL); } + vt_save_kbd_state(vd->vd_curwindow, kbd); error = kbd_release(kbd, (void *)vd); if (error == 0) { vd->vd_keyboard = -1; @@ -2045,7 +2306,7 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, win = *(int *)data - 1; DPRINTF(5, "%s%d: VT_ACTIVATE ttyv%d ", SC_DRIVER_NAME, VT_UNIT(vw), win); - if ((win > VT_MAXWINDOWS) || (win < 0)) + if ((win >= VT_MAXWINDOWS) || (win < 0)) return (EINVAL); return (vt_proc_window_switch(vd->vd_windows[win])); } @@ -2319,7 +2580,6 @@ vt_allocate(struct vt_driver *drv, void *softc) main_vd->vd_driver->vd_name, drv->vd_name); } vd = main_vd; - VT_LOCK(vd); if (vd->vd_flags & VDF_ASYNC) { /* Stop vt_flush periodic task. */ @@ -2335,6 +2595,7 @@ vt_allocate(struct vt_driver *drv, void *softc) * Reset VDF_TEXTMODE flag, driver who require that flag (vt_vga) will * set it. */ + VT_LOCK(vd); vd->vd_flags &= ~VDF_TEXTMODE; vd->vd_driver = drv; diff --git a/sys/dev/vte/if_vte.c b/sys/dev/vte/if_vte.c index 79dd1fb360d1..e10b98829144 100644 --- a/sys/dev/vte/if_vte.c +++ b/sys/dev/vte/if_vte.c @@ -109,6 +109,7 @@ static int vte_init_rx_ring(struct vte_softc *); static int vte_init_tx_ring(struct vte_softc *); static void vte_intr(void *); static int vte_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_t vte_get_counter(struct ifnet *, ift_counter); static void vte_mac_config(struct vte_softc *); static int vte_miibus_readreg(device_t, int, int); static void vte_miibus_statchg(device_t); @@ -449,6 +450,7 @@ vte_attach(device_t dev) ifp->if_ioctl = vte_ioctl; ifp->if_start = vte_start; ifp->if_init = vte_init; + ifp->if_get_counter = vte_get_counter; ifp->if_snd.ifq_drv_maxlen = VTE_TX_RING_CNT - 1; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); IFQ_SET_READY(&ifp->if_snd); @@ -1171,7 +1173,7 @@ vte_watchdog(struct vte_softc *sc) ifp = sc->vte_ifp; if_printf(sc->vte_ifp, "watchdog timeout -- resetting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; vte_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) @@ -1272,12 +1274,10 @@ static void vte_stats_update(struct vte_softc *sc) { struct vte_hw_stats *stat; - struct ifnet *ifp; uint16_t value; VTE_LOCK_ASSERT(sc); - ifp = sc->vte_ifp; stat = &sc->vte_stats; CSR_READ_2(sc, VTE_MECISR); @@ -1304,14 +1304,32 @@ vte_stats_update(struct vte_softc *sc) value = CSR_READ_2(sc, VTE_CNT_PAUSE); stat->tx_pause_frames += (value >> 8); stat->rx_pause_frames += (value & 0xFF); +} - /* Update ifp counters. */ - ifp->if_opackets = stat->tx_frames; - ifp->if_collisions = stat->tx_late_colls; - ifp->if_oerrors = stat->tx_late_colls + stat->tx_underruns; - ifp->if_ipackets = stat->rx_frames; - ifp->if_ierrors = stat->rx_crcerrs + stat->rx_runts + - stat->rx_long_frames + stat->rx_fifo_full; +static uint64_t +vte_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct vte_softc *sc; + struct vte_hw_stats *stat; + + sc = if_getsoftc(ifp); + stat = &sc->vte_stats; + + switch (cnt) { + case IFCOUNTER_OPACKETS: + return (stat->tx_frames); + case IFCOUNTER_COLLISIONS: + return (stat->tx_late_colls); + case IFCOUNTER_OERRORS: + return (stat->tx_late_colls + stat->tx_underruns); + case IFCOUNTER_IPACKETS: + return (stat->rx_frames); + case IFCOUNTER_IERRORS: + return (stat->rx_crcerrs + stat->rx_runts + + stat->rx_long_frames + stat->rx_fifo_full); + default: + return (if_get_counter_default(ifp, cnt)); + } } static void @@ -1503,7 +1521,7 @@ vte_rxeof(struct vte_softc *sc) continue; } if (vte_newbuf(sc, rxd) != 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); rxd->rx_desc->drlen = htole16(MCLBYTES - sizeof(uint32_t)); rxd->rx_desc->drst = htole16(VTE_DRST_RX_OWN); diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index afbaee781837..7d852e9a839f 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -463,7 +463,7 @@ vx_start_locked(struct ifnet *ifp) */ if (len + pad > ETHER_MAX_LEN) { /* packet is obviously too large: toss it */ - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); IF_DEQUEUE(&ifp->if_snd, m); m_freem(m); goto readcheck; @@ -513,7 +513,7 @@ vx_start_locked(struct ifnet *ifp) while (pad--) CSR_WRITE_1(sc, VX_W1_TX_PIO_WR_1, 0); /* Padding */ - ++ifp->if_opackets; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->vx_timer = 1; readcheck: @@ -610,12 +610,12 @@ vx_txstat(struct vx_softc *sc) CSR_WRITE_1(sc, VX_W1_TX_STATUS, 0x0); if (i & TXS_JABBER) { - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (ifp->if_flags & IFF_DEBUG) if_printf(ifp, "jabber (%x)\n", i); vx_reset(sc); } else if (i & TXS_UNDERRUN) { - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (ifp->if_flags & IFF_DEBUG) if_printf(ifp, "fifo underrun (%x) @%d\n", i, sc->vx_tx_start_thresh); @@ -626,7 +626,7 @@ vx_txstat(struct vx_softc *sc) sc->vx_tx_succ_ok = 0; vx_reset(sc); } else if (i & TXS_MAX_COLLISION) { - ++ifp->if_collisions; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } else @@ -722,7 +722,7 @@ vx_read(struct vx_softc *sc) return; if (len & ERR_RX) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto abort; } len &= RX_BYTES_MASK; /* Lower 11 bits = RX bytes. */ @@ -730,10 +730,10 @@ vx_read(struct vx_softc *sc) /* Pull packet off interface. */ m = vx_get(sc, len); if (m == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto abort; } - ++ifp->if_ipackets; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); { struct mbuf *m0; @@ -741,7 +741,7 @@ vx_read(struct vx_softc *sc) m0 = m_devget(mtod(m, char *), m->m_pkthdr.len, ETHER_ALIGN, ifp, NULL); if (m0 == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto abort; } m_freem(m); diff --git a/sys/dev/vxge/vxge.c b/sys/dev/vxge/vxge.c index 037b481a0fb0..e23e701567aa 100644 --- a/sys/dev/vxge/vxge.c +++ b/sys/dev/vxge/vxge.c @@ -709,9 +709,9 @@ vxge_mq_send_locked(ifnet_t ifp, vxge_vpath_t *vpath, mbuf_t m_head) VXGE_DRV_STATS(vpath, tx_again); break; } - ifp->if_obytes += next->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len); if (next->m_flags & M_MCAST) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); /* Send a copy of the frame to the BPF listener */ ETHER_BPF_MTAP(ifp, next); @@ -904,11 +904,11 @@ vxge_tx_compl(vxge_hal_vpath_h vpath_handle, vxge_hal_txdl_h txdlh, device_printf(vdev->ndev, "tx transfer code %d\n", t_code); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); VXGE_DRV_STATS(vpath, tx_tcode); vxge_hal_fifo_handle_tcode(vpath_handle, txdlh, t_code); } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); txdl_priv = (vxge_txdl_priv_t *) dtr_priv; bus_dmamap_unload(vpath->dma_tag_tx, txdl_priv->dma_map); @@ -1024,7 +1024,7 @@ vxge_rx_compl(vxge_hal_vpath_h vpath_handle, vxge_hal_rxd_h rxdh, mbuf_up = rxd_priv->mbuf_pkt; if (t_code != VXGE_HAL_RING_RXD_T_CODE_OK) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); VXGE_DRV_STATS(vpath, rx_tcode); status = vxge_hal_ring_handle_tcode(vpath_handle, rxdh, t_code); diff --git a/sys/dev/wb/if_wb.c b/sys/dev/wb/if_wb.c index dd087a9d5eac..01090aacde66 100644 --- a/sys/dev/wb/if_wb.c +++ b/sys/dev/wb/if_wb.c @@ -895,7 +895,7 @@ wb_rxeof(sc) (WB_RXBYTES(cur_rx->wb_ptr->wb_status) > 1536) || !(rxstat & WB_RXSTAT_LASTFRAG) || !(rxstat & WB_RXSTAT_RXCMP)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); wb_newbuf(sc, cur_rx, m); device_printf(sc->wb_dev, "receiver babbling: possible chip bug," @@ -907,7 +907,7 @@ wb_rxeof(sc) } if (rxstat & WB_RXSTAT_RXERR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); wb_newbuf(sc, cur_rx, m); break; } @@ -928,12 +928,12 @@ wb_rxeof(sc) NULL); wb_newbuf(sc, cur_rx, m); if (m0 == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } m = m0; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); WB_UNLOCK(sc); (*ifp->if_input)(ifp, m); WB_LOCK(sc); @@ -986,16 +986,16 @@ wb_txeof(sc) break; if (txstat & WB_TXSTAT_TXERR) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (txstat & WB_TXSTAT_ABORT) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); if (txstat & WB_TXSTAT_LATECOLL) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } - ifp->if_collisions += (txstat & WB_TXSTAT_COLLCNT) >> 3; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (txstat & WB_TXSTAT_COLLCNT) >> 3); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); m_freem(cur_tx->wb_mbuf); cur_tx->wb_mbuf = NULL; @@ -1064,7 +1064,7 @@ wb_intr(arg) break; if ((status & WB_ISR_RX_NOBUF) || (status & WB_ISR_RX_ERR)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); wb_reset(sc); if (status & WB_ISR_RX_ERR) wb_fixmedia(sc); @@ -1093,7 +1093,7 @@ wb_intr(arg) } if (status & WB_ISR_TX_UNDERRUN) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); wb_txeof(sc); WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_TX_ON); /* Jack up TX threshold */ @@ -1553,7 +1553,7 @@ wb_watchdog(sc) WB_LOCK_ASSERT(sc); ifp = sc->wb_ifp; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if_printf(ifp, "watchdog timeout\n"); #ifdef foo if (!(wb_phy_readreg(sc, PHY_BMSR) & PHY_BMSR_LINKSTAT)) diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index d713c97eb6a7..68018239d736 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -132,6 +132,7 @@ static int wi_reset(struct wi_softc *); static void wi_watchdog(void *); static int wi_ioctl(struct ifnet *, u_long, caddr_t); static void wi_media_status(struct ifnet *, struct ifmediareq *); +static uint64_t wi_get_counter(struct ifnet *, ift_counter); static void wi_rx_intr(struct wi_softc *); static void wi_tx_intr(struct wi_softc *); @@ -337,6 +338,7 @@ wi_attach(device_t dev) ifp->if_ioctl = wi_ioctl; ifp->if_start = wi_start; ifp->if_init = wi_init; + ifp->if_get_counter = wi_get_counter; IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; IFQ_SET_READY(&ifp->if_snd); @@ -1028,7 +1030,7 @@ wi_start_locked(struct ifnet *ifp) continue; sc->sc_txnext = cur = (cur + 1) % sc->sc_ntxbuf; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } } @@ -1055,7 +1057,7 @@ wi_start_tx(struct ifnet *ifp, struct wi_frame *frmhdr, struct mbuf *m0) || wi_mwrite_bap(sc, fid, off, m0, m0->m_pkthdr.len) != 0; m_freem(m0); if (error) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return -1; } sc->sc_txd[cur].d_len = off; @@ -1182,7 +1184,7 @@ wi_watchdog(void *arg) if (sc->sc_tx_timer && --sc->sc_tx_timer == 0) { if_printf(ifp, "device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); wi_init_locked(ifp->if_softc); return; } @@ -1327,7 +1329,7 @@ wi_rx_intr(struct wi_softc *sc) /* First read in the frame header */ if (wi_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr))) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: read fid %x failed\n", fid)); return; } @@ -1338,7 +1340,7 @@ wi_rx_intr(struct wi_softc *sc) status = le16toh(frmhdr.wi_status); if (status & WI_STAT_ERRSTAT) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: fid %x error status %x\n", fid, status)); return; } @@ -1353,7 +1355,7 @@ wi_rx_intr(struct wi_softc *sc) if (off + len > MCLBYTES) { if (ic->ic_opmode != IEEE80211_M_MONITOR) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: oversized packet\n")); return; } else @@ -1366,7 +1368,7 @@ wi_rx_intr(struct wi_softc *sc) m = m_gethdr(M_NOWAIT, MT_DATA); if (m == NULL) { CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); DPRINTF(("wi_rx_intr: MGET failed\n")); return; } @@ -1450,11 +1452,9 @@ wi_tx_ex_intr(struct wi_softc *sc) printf(", status=0x%x", status); printf("\n"); } - ifp->if_oerrors++; - } else { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + } else DPRINTF(("port disconnected\n")); - ifp->if_collisions++; /* XXX */ - } } else DPRINTF(("wi_tx_ex_intr: read fid %x failed\n", fid)); CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX_EXC); @@ -1497,8 +1497,7 @@ wi_tx_intr(struct wi_softc *sc) static __noinline void wi_info_intr(struct wi_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = sc->sc_ifp->if_l2com; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); int i, fid, len, off; u_int16_t ltbuf[2]; @@ -1562,9 +1561,6 @@ wi_info_intr(struct wi_softc *sc) #endif *ptr += stat; } - ifp->if_collisions = sc->sc_stats.wi_tx_single_retries + - sc->sc_stats.wi_tx_multi_retries + - sc->sc_stats.wi_tx_retry_limit; break; default: DPRINTF(("wi_info_intr: got fid %x type %x len %d\n", fid, @@ -1575,6 +1571,23 @@ wi_info_intr(struct wi_softc *sc) CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO); } +static uint64_t +wi_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct wi_softc *sc; + + sc = if_getsoftc(ifp); + + switch (cnt) { + case IFCOUNTER_COLLISIONS: + return (sc->sc_stats.wi_tx_single_retries + + sc->sc_stats.wi_tx_multi_retries + + sc->sc_stats.wi_tx_retry_limit); + default: + return (if_get_counter_default(ifp, cnt)); + } +} + static int wi_write_multi(struct wi_softc *sc) { diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c index 303e57fb4846..978000710573 100644 --- a/sys/dev/wl/if_wl.c +++ b/sys/dev/wl/if_wl.c @@ -1022,7 +1022,7 @@ wlstart(struct ifnet *ifp) /* try 10 ticks, not very long */ sc->watchdog_ch = timeout(wlwatchdog, sc, 10); sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE; - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); wlxmt(sc, m); } else { sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -1478,7 +1478,7 @@ wlwatchdog(void *vsc) log(LOG_ERR, "wl%d: wavelan device timeout on xmit\n", unit); WL_LOCK(sc); - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); wlinit(sc); WL_UNLOCK(sc); } @@ -1542,14 +1542,14 @@ wlintr(void *arg) * incoming packet */ if (int_type & SCB_SW_FR) { - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); wlrcv(sc); } /* * receiver not ready */ if (int_type & SCB_SW_RNR) { - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); #ifdef WLDEBUG if (sc->ifp->if_flags & IFF_DEBUG) printf("wl%d intr(): receiver overrun! begin_fd = %x\n", @@ -1610,13 +1610,13 @@ wlintr(void *arg) /* if the transmit actually failed, or returned some status */ if ((!(ac_status & AC_SW_OK)) || (ac_status & 0xfff)) { if (ac_status & (TC_COLLISION | TC_CLS | TC_DMA)) { - sc->ifp->if_oerrors++; + if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1); } /* count collisions */ - sc->ifp->if_collisions += (ac_status & 0xf); + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, (ac_status & 0xf)); /* if TC_COLLISION set and collision count zero, 16 collisions */ if ((ac_status & 0x20) == 0x20) { - sc->ifp->if_collisions += 0x10; + if_inc_counter(sc->ifp, IFCOUNTER_COLLISIONS, 0x10); } } sc->tbusy = 0; @@ -1671,13 +1671,13 @@ wlrcv(struct wl_softc *sc) if (sc->ifp->if_flags & IFF_DEBUG) printf("wl%d RCV: RSC %x\n", sc->unit, status); #endif - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } else if (!(status & RFD_OK)) { printf("wl%d RCV: !OK %x\n", sc->unit, status); - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } else if (status & 0xfff) { /* can't happen */ printf("wl%d RCV: ERRs %x\n", sc->unit, status); - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); } else if (!wlread(sc, fd_p)) return; diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index 6e4428bef516..e94fa7404243 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -1460,7 +1460,7 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, if (stat->len > WPI_STAT_MAXLEN) { device_printf(sc->sc_dev, "invalid rx statistic header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1477,13 +1477,13 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, if ((le32toh(tail->flags) & WPI_RX_NOERROR) != WPI_RX_NOERROR) { DPRINTFN(WPI_DEBUG_RX, ("%s: rx flags error %x\n", __func__, le32toh(tail->flags))); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } if (le16toh(head->len) < sizeof (struct ieee80211_frame)) { DPRINTFN(WPI_DEBUG_RX, ("%s: frame too short: %d\n", __func__, le16toh(head->len))); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } @@ -1492,7 +1492,7 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, if (mnew == NULL) { DPRINTFN(WPI_DEBUG_RX, ("%s: no mbuf to restock ring\n", __func__)); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } bus_dmamap_unload(ring->data_dmat, data->map); @@ -1504,7 +1504,7 @@ wpi_rx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc, device_printf(sc->sc_dev, "%s: bus_dmamap_load failed, error %d\n", __func__, error); m_freem(mnew); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); @@ -1596,9 +1596,9 @@ wpi_tx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc) /* XXX oerrors should only count errors !maxtries */ if ((le32toh(stat->status) & 0xff) != 1) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); bus_dmamap_sync(ring->data_dmat, txdata->map, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(ring->data_dmat, txdata->map); @@ -2059,7 +2059,7 @@ wpi_start_locked(struct ifnet *ifp) ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; if (wpi_tx_data(sc, m, ni, ac) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); break; } sc->sc_tx_timer = 5; @@ -2091,7 +2091,7 @@ wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return ENOBUFS; /* XXX */ } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (wpi_tx_data(sc, m, ni, 0) != 0) goto bad; sc->sc_tx_timer = 5; @@ -2100,7 +2100,7 @@ wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, WPI_UNLOCK(sc); return 0; bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); WPI_UNLOCK(sc); ieee80211_free_node(ni); return EIO; /* XXX */ @@ -3667,7 +3667,7 @@ wpi_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev,"device timeout\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_runtask(ic, &sc->sc_restarttask); } } diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c index 6bc8e6b6f28e..3c6408543364 100644 --- a/sys/dev/wtap/if_wtap.c +++ b/sys/dev/wtap/if_wtap.c @@ -421,13 +421,13 @@ wtap_start(struct ifnet *ifp) #endif if ((m->m_flags & M_FRAG)){ printf("dont support frags\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if(wtap_raw_xmit(ni, m, NULL) < 0){ printf("error raw_xmiting\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } } @@ -594,7 +594,7 @@ wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m) if_printf(ifp, "%s: no mbuf!\n", __func__); } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0); @@ -649,7 +649,7 @@ wtap_rx_proc(void *arg, int npending) return; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); #if 0 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0); #endif diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c index 5399d28c07ac..bcde27f31ee6 100644 --- a/sys/dev/xe/if_xe.c +++ b/sys/dev/xe/if_xe.c @@ -614,8 +614,8 @@ xe_txintr(struct xe_softc *scp, uint8_t txst1) coll = txst1 & XE_TXST1_RETRY_COUNT; scp->tx_tpr = tpr; scp->tx_queued -= sent; - ifp->if_opackets += sent; - ifp->if_collisions += coll; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, sent); + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, coll); /* * According to the Xircom manual, Dingo will @@ -656,14 +656,14 @@ xe_macintr(struct xe_softc *scp, uint8_t rst0, uint8_t txst0, uint8_t txst1) if (txst0 & XE_TXST0_NO_CARRIER || !(txst1 & XE_TXST1_LINK_STATUS)) { /* XXX - Need to update media status here */ device_printf(scp->dev, "no carrier\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); scp->mibdata.dot3StatsCarrierSenseErrors++; } #endif /* Excessive collisions -- try sending again */ if (txst0 & XE_TXST0_16_COLLISIONS) { - ifp->if_collisions += 16; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); scp->mibdata.dot3StatsExcessiveCollisions++; scp->mibdata.dot3StatsMultipleCollisionFrames++; scp->mibdata.dot3StatsCollFrequencies[15]++; @@ -683,35 +683,35 @@ xe_macintr(struct xe_softc *scp, uint8_t rst0, uint8_t txst0, uint8_t txst1) XE_SELECT_PAGE(0x0); } DPRINTF(1, ("\n")); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); scp->mibdata.dot3StatsInternalMacTransmitErrors++; } /* Late collision -- just complain about it */ if (txst0 & XE_TXST0_LATE_COLLISION) { device_printf(scp->dev, "late collision\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); scp->mibdata.dot3StatsLateCollisions++; } /* SQE test failure -- just complain about it */ if (txst0 & XE_TXST0_SQE_FAIL) { device_printf(scp->dev, "SQE test failure\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); scp->mibdata.dot3StatsSQETestErrors++; } /* Packet too long -- what happens to these */ if (rst0 & XE_RST0_LONG_PACKET) { device_printf(scp->dev, "received giant packet\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); scp->mibdata.dot3StatsFrameTooLongs++; } /* CRC error -- packet dropped */ if (rst0 & XE_RST0_CRC_ERROR) { device_printf(scp->dev, "CRC error\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); scp->mibdata.dot3StatsFCSErrors++; } } @@ -743,7 +743,7 @@ xe_rxintr(struct xe_softc *scp, uint8_t rst0) len)); if (len == 0) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } @@ -760,7 +760,7 @@ xe_rxintr(struct xe_softc *scp, uint8_t rst0) */ MGETHDR(mbp, M_NOWAIT, MT_DATA); if (mbp == NULL) { - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } @@ -768,7 +768,7 @@ xe_rxintr(struct xe_softc *scp, uint8_t rst0) MCLGET(mbp, M_NOWAIT); if ((mbp->m_flags & M_EXT) == 0) { m_freem(mbp); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } } @@ -826,13 +826,13 @@ xe_rxintr(struct xe_softc *scp, uint8_t rst0) XE_UNLOCK(scp); (*ifp->if_input)(ifp, mbp); XE_LOCK(scp); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } else if (rsr & XE_RSR_ALIGN_ERROR) { /* Packet alignment error -- drop packet */ device_printf(scp->dev, "alignment error\n"); scp->mibdata.dot3StatsAlignmentErrors++; - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } /* Skip to next packet, if there is one */ @@ -842,7 +842,7 @@ xe_rxintr(struct xe_softc *scp, uint8_t rst0) /* Clear receiver overruns now we have some free buffer space */ if (rst0 & XE_RST0_RX_OVERRUN) { DEVPRINTF(1, (scp->dev, "receive overrun\n")); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); scp->mibdata.dot3StatsInternalMacReceiveErrors++; XE_OUTB(XE_CR, XE_CR_CLEAR_OVERRUN); } @@ -923,7 +923,7 @@ xe_watchdog(void *arg) if (scp->tx_timeout && --scp->tx_timeout == 0) { device_printf(scp->dev, "watchdog timeout: resetting card\n"); scp->tx_timeouts++; - scp->ifp->if_oerrors += scp->tx_queued; + if_inc_counter(scp->ifp, IFCOUNTER_OERRORS, scp->tx_queued); xe_stop(scp); xe_reset(scp); xe_init_locked(scp); diff --git a/sys/dev/xen/balloon/balloon.c b/sys/dev/xen/balloon/balloon.c index 6503a0060fa7..e113e2ce9256 100644 --- a/sys/dev/xen/balloon/balloon.c +++ b/sys/dev/xen/balloon/balloon.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -348,25 +349,50 @@ watch_target(struct xs_watch *watch, set_new_target(new_target >> KB_TO_PAGE_SHIFT); } -static void -balloon_init_watcher(void *arg) +/*------------------ Private Device Attachment Functions --------------------*/ +/** + * \brief Identify instances of this device type in the system. + * + * \param driver The driver performing this identify action. + * \param parent The NewBus parent device for any devices this method adds. + */ +static void +xenballoon_identify(driver_t *driver __unused, device_t parent) +{ + /* + * A single device instance for our driver is always present + * in a system operating under Xen. + */ + BUS_ADD_CHILD(parent, 0, driver->name, 0); +} + +/** + * \brief Probe for the existance of the Xen Balloon device + * + * \param dev NewBus device_t for this Xen control instance. + * + * \return Always returns 0 indicating success. + */ +static int +xenballoon_probe(device_t dev) +{ + + device_set_desc(dev, "Xen Balloon Device"); + return (0); +} + +/** + * \brief Attach the Xen Balloon device. + * + * \param dev NewBus device_t for this Xen control instance. + * + * \return On success, 0. Otherwise an errno value indicating the + * type of failure. + */ +static int +xenballoon_attach(device_t dev) { int err; - - if (!is_running_on_xen()) - return; - - err = xs_register_watch(&target_watch); - if (err) - printf("Failed to set balloon watcher\n"); - -} -SYSINIT(balloon_init_watcher, SI_SUB_PSEUDO, SI_ORDER_ANY, - balloon_init_watcher, NULL); - -static void -balloon_init(void *arg) -{ #ifndef XENHVM vm_page_t page; unsigned long pfn; @@ -374,15 +400,13 @@ balloon_init(void *arg) #define max_pfn HYPERVISOR_shared_info->arch.max_pfn #endif - if (!is_running_on_xen()) - return; - mtx_init(&balloon_mutex, "balloon_mutex", NULL, MTX_DEF); #ifndef XENHVM bs.current_pages = min(xen_start_info->nr_pages, max_pfn); #else - bs.current_pages = realmem; + bs.current_pages = xen_pv_domain() ? + HYPERVISOR_start_info->nr_pages : realmem; #endif bs.target_pages = bs.current_pages; bs.balloon_low = 0; @@ -403,17 +427,27 @@ balloon_init(void *arg) #endif target_watch.callback = watch_target; - - return; -} -SYSINIT(balloon_init, SI_SUB_PSEUDO, SI_ORDER_ANY, balloon_init, NULL); -void balloon_update_driver_allowance(long delta); + err = xs_register_watch(&target_watch); + if (err) + device_printf(dev, + "xenballon: failed to set balloon watcher\n"); -void -balloon_update_driver_allowance(long delta) -{ - mtx_lock(&balloon_mutex); - bs.driver_pages += delta; - mtx_unlock(&balloon_mutex); + return (err); } + +/*-------------------- Private Device Attachment Data -----------------------*/ +static device_method_t xenballoon_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, xenballoon_identify), + DEVMETHOD(device_probe, xenballoon_probe), + DEVMETHOD(device_attach, xenballoon_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(xenballoon, xenballoon_driver, xenballoon_methods, 0); +devclass_t xenballoon_devclass; + +DRIVER_MODULE(xenballoon, xenstore, xenballoon_driver, xenballoon_devclass, + NULL, NULL); diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 654f307cbb6d..1273961a3ca8 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2011 Spectra Logic Corporation + * Copyright (c) 2009-2012 Spectra Logic Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -784,6 +784,12 @@ struct xbb_softc { /** Number of requests we have completed*/ uint64_t reqs_completed; + /** Number of requests we queued but not pushed*/ + uint64_t reqs_queued_for_completion; + + /** Number of requests we completed with an error status*/ + uint64_t reqs_completed_with_error; + /** How many forced dispatches (i.e. without coalescing) have happend */ uint64_t forced_dispatch; @@ -1143,7 +1149,7 @@ xbb_release_reqlist(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist, int wakeup) { - mtx_lock(&xbb->lock); + mtx_assert(&xbb->lock, MA_OWNED); if (wakeup) { wakeup = xbb->flags & XBBF_RESOURCE_SHORTAGE; @@ -1167,8 +1173,6 @@ xbb_release_reqlist(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist, xbb_shutdown(xbb); } - mtx_unlock(&xbb->lock); - if (wakeup != 0) taskqueue_enqueue(xbb->io_taskqueue, &xbb->io_task); } @@ -1261,16 +1265,16 @@ xbb_get_resources(struct xbb_softc *xbb, struct xbb_xen_reqlist **reqlist, if (nreq != NULL) xbb_release_req(xbb, nreq); - mtx_unlock(&xbb->lock); - if (nreqlist != NULL) xbb_release_reqlist(xbb, nreqlist, /*wakeup*/ 0); + mtx_unlock(&xbb->lock); + return (1); } /** - * Create and transmit a response to a blkif request. + * Create and queue a response to a blkif request. * * \param xbb Per-instance xbb configuration structure. * \param req The request structure to which to respond. @@ -1278,20 +1282,28 @@ xbb_get_resources(struct xbb_softc *xbb, struct xbb_xen_reqlist **reqlist, * in sys/xen/interface/io/blkif.h. */ static void -xbb_send_response(struct xbb_softc *xbb, struct xbb_xen_req *req, int status) +xbb_queue_response(struct xbb_softc *xbb, struct xbb_xen_req *req, int status) { blkif_response_t *resp; - int more_to_do; - int notify; - more_to_do = 0; + /* + * The mutex is required here, and should be held across this call + * until after the subsequent call to xbb_push_responses(). This + * is to guarantee that another context won't queue responses and + * push them while we're active. + * + * That could lead to the other end being notified of responses + * before the resources have been freed on this end. The other end + * would then be able to queue additional I/O, and we may run out + * of resources because we haven't freed them all yet. + */ + mtx_assert(&xbb->lock, MA_OWNED); /* * Place on the response ring for the relevant domain. * For now, only the spacing between entries is different * in the different ABIs, not the response entry layout. */ - mtx_lock(&xbb->lock); switch (xbb->abi) { case BLKIF_PROTOCOL_NATIVE: resp = RING_GET_RESPONSE(&xbb->rings.native, @@ -1315,8 +1327,38 @@ xbb_send_response(struct xbb_softc *xbb, struct xbb_xen_req *req, int status) resp->operation = req->operation; resp->status = status; + if (status != BLKIF_RSP_OKAY) + xbb->reqs_completed_with_error++; + xbb->rings.common.rsp_prod_pvt += BLKIF_SEGS_TO_BLOCKS(req->nr_pages); - RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&xbb->rings.common, notify); + + xbb->reqs_queued_for_completion++; + +} + +/** + * Send queued responses to blkif requests. + * + * \param xbb Per-instance xbb configuration structure. + * \param run_taskqueue Flag that is set to 1 if the taskqueue + * should be run, 0 if it does not need to be run. + * \param notify Flag that is set to 1 if the other end should be + * notified via irq, 0 if the other end should not be + * notified. + */ +static void +xbb_push_responses(struct xbb_softc *xbb, int *run_taskqueue, int *notify) +{ + int more_to_do; + + /* + * The mutex is required here. + */ + mtx_assert(&xbb->lock, MA_OWNED); + + more_to_do = 0; + + RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&xbb->rings.common, *notify); if (xbb->rings.common.rsp_prod_pvt == xbb->rings.common.req_cons) { @@ -1331,15 +1373,10 @@ xbb_send_response(struct xbb_softc *xbb, struct xbb_xen_req *req, int status) more_to_do = 1; } - xbb->reqs_completed++; + xbb->reqs_completed += xbb->reqs_queued_for_completion; + xbb->reqs_queued_for_completion = 0; - mtx_unlock(&xbb->lock); - - if (more_to_do) - taskqueue_enqueue(xbb->io_taskqueue, &xbb->io_task); - - if (notify) - xen_intr_signal(xbb->xen_intr_handle); + *run_taskqueue = more_to_do; } /** @@ -1353,23 +1390,29 @@ xbb_complete_reqlist(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist) { struct xbb_xen_req *nreq; off_t sectors_sent; + int notify, run_taskqueue; sectors_sent = 0; if (reqlist->flags & XBB_REQLIST_MAPPED) xbb_unmap_reqlist(reqlist); + mtx_lock(&xbb->lock); + /* - * All I/O is done, send the response. A lock should not be - * necessary here because the request list is complete, and - * therefore this is the only context accessing this request - * right now. The functions we call do their own locking if - * necessary. + * All I/O is done, send the response. A lock is not necessary + * to protect the request list, because all requests have + * completed. Therefore this is the only context accessing this + * reqlist right now. However, in order to make sure that no one + * else queues responses onto the queue or pushes them to the other + * side while we're active, we need to hold the lock across the + * calls to xbb_queue_response() and xbb_push_responses(). */ STAILQ_FOREACH(nreq, &reqlist->contig_req_list, links) { off_t cur_sectors_sent; - xbb_send_response(xbb, nreq, reqlist->status); + /* Put this response on the ring, but don't push yet */ + xbb_queue_response(xbb, nreq, reqlist->status); /* We don't report bytes sent if there is an error. */ if (reqlist->status == BLKIF_RSP_OKAY) @@ -1404,6 +1447,16 @@ xbb_complete_reqlist(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist) /*then*/&reqlist->ds_t0); xbb_release_reqlist(xbb, reqlist, /*wakeup*/ 1); + + xbb_push_responses(xbb, &run_taskqueue, ¬ify); + + mtx_unlock(&xbb->lock); + + if (run_taskqueue) + taskqueue_enqueue(xbb->io_taskqueue, &xbb->io_task); + + if (notify) + xen_intr_signal(xbb->xen_intr_handle); } /** @@ -3588,6 +3641,16 @@ xbb_setup_sysctl(struct xbb_softc *xbb) "reqs_completed", CTLFLAG_RW, &xbb->reqs_completed, "how many I/O requests have been completed"); + SYSCTL_ADD_UQUAD(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, + "reqs_queued_for_completion", CTLFLAG_RW, + &xbb->reqs_queued_for_completion, + "how many I/O requests queued but not yet pushed"); + + SYSCTL_ADD_UQUAD(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, + "reqs_completed_with_error", CTLFLAG_RW, + &xbb->reqs_completed_with_error, + "how many I/O requests completed with error status"); + SYSCTL_ADD_UQUAD(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "forced_dispatch", CTLFLAG_RW, &xbb->forced_dispatch, "how many I/O dispatches were forced"); diff --git a/sys/dev/xen/netback/netback.c b/sys/dev/xen/netback/netback.c index b0f206ed57cb..e9d3dc1286f4 100644 --- a/sys/dev/xen/netback/netback.c +++ b/sys/dev/xen/netback/netback.c @@ -1829,7 +1829,7 @@ xnb_recv(netif_tx_back_ring_t *txb, domid_t otherend, struct mbuf **mbufc, return 0; /* Nothing to receive */ /* update statistics independent of errors */ - ifnet->if_ipackets++; + if_inc_counter(ifnet, IFCOUNTER_IPACKETS, 1); /* * if we got here, then 1 or more requests was consumed, but the packet @@ -1841,7 +1841,7 @@ xnb_recv(netif_tx_back_ring_t *txb, domid_t otherend, struct mbuf **mbufc, txb->req_cons += num_consumed; DPRINTF("xnb_intr: garbage packet, num_consumed=%d\n", num_consumed); - ifnet->if_ierrors++; + if_inc_counter(ifnet, IFCOUNTER_IERRORS, 1); return EINVAL; } @@ -1855,7 +1855,7 @@ xnb_recv(netif_tx_back_ring_t *txb, domid_t otherend, struct mbuf **mbufc, xnb_txpkt2rsp(&pkt, txb, 1); DPRINTF("xnb_intr: Couldn't allocate mbufs, num_consumed=%d\n", num_consumed); - ifnet->if_iqdrops++; + if_inc_counter(ifnet, IFCOUNTER_IQDROPS, 1); return ENOMEM; } @@ -2364,12 +2364,12 @@ xnb_start_locked(struct ifnet *ifp) case EINVAL: /* OS gave a corrupt packet. Drop it.*/ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* FALLTHROUGH */ default: /* Send succeeded, or packet had error. * Free the packet */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (mbufc) m_freem(mbufc); break; diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c index 9ff872cdc745..a652c75f0174 100644 --- a/sys/dev/xen/netfront/netfront.c +++ b/sys/dev/xen/netfront/netfront.c @@ -134,7 +134,6 @@ static const int MODPARM_rx_flip = 0; * to mirror the Linux MAX_SKB_FRAGS constant. */ #define MAX_TX_REQ_FRAGS (65536 / PAGE_SIZE + 2) -#define NF_TSO_MAXBURST ((IP_MAXPACKET / PAGE_SIZE) * MCLBYTES) #define RX_COPY_THRESHOLD 256 @@ -1056,7 +1055,7 @@ xn_rxeof(struct netfront_info *np) * Break the mbuf chain first though. */ while ((m = mbufq_dequeue(&rxq)) != NULL) { - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* * Do we really need to drop the rx lock? @@ -1147,7 +1146,7 @@ xn_txeof(struct netfront_info *np) * mbuf of the chain. */ if (!m->m_next) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (__predict_false(gnttab_query_foreign_access( np->grant_tx_ref[id]) != 0)) { panic("%s: grant id %u still in use by the " @@ -2102,7 +2101,9 @@ create_netdev(device_t dev) ifp->if_hwassist = XN_CSUM_FEATURES; ifp->if_capabilities = IFCAP_HWCSUM; - ifp->if_hw_tsomax = NF_TSO_MAXBURST; + ifp->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + ifp->if_hw_tsomaxsegcount = MAX_TX_REQ_FRAGS; + ifp->if_hw_tsomaxsegsize = PAGE_SIZE; ether_ifattach(ifp, np->mac); callout_init(&np->xn_stat_ch, CALLOUT_MPSAFE); diff --git a/sys/xen/xenstore/xenstore.c b/sys/dev/xen/xenstore/xenstore.c similarity index 95% rename from sys/xen/xenstore/xenstore.c rename to sys/dev/xen/xenstore/xenstore.c index f7425da7b98f..4cf985a04430 100644 --- a/sys/xen/xenstore/xenstore.c +++ b/sys/dev/xen/xenstore/xenstore.c @@ -48,6 +48,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include @@ -249,6 +251,20 @@ struct xs_softc { * with the XenStore service) are available. */ struct intr_config_hook xs_attachcb; + + /** + * Xenstore is a user-space process that usually runs in Dom0, + * so if this domain is booting as Dom0, xenstore wont we accessible, + * and we have to defer the initialization of xenstore related + * devices to later (when xenstore is started). + */ + bool initialized; + + /** + * Task to run when xenstore is initialized (Dom0 only), will + * take care of attaching xenstore related devices. + */ + struct task xs_late_init; }; /*-------------------------------- Global Data ------------------------------*/ @@ -352,6 +368,16 @@ static void xs_intr(void * arg __unused /*__attribute__((unused))*/) { + /* If xenstore has not been initialized, initialize it now */ + if (!xs.initialized) { + xs.initialized = true; + /* + * Since this task is probing and attaching devices we + * have to hold the Giant lock. + */ + taskqueue_enqueue(taskqueue_swi_giant, &xs.xs_late_init); + } + /* * Hold ring lock across wakeup so that clients * cannot miss a wakeup. @@ -1104,7 +1130,6 @@ xs_probe(device_t dev) static void xs_attach_deferred(void *arg) { - xs_dev_init(); bus_generic_probe(xs.xs_dev); bus_generic_attach(xs.xs_dev); @@ -1112,6 +1137,15 @@ xs_attach_deferred(void *arg) config_intrhook_disestablish(&xs.xs_attachcb); } +static void +xs_attach_late(void *arg, int pending) +{ + + KASSERT((pending == 1), ("xs late attach queued several times")); + bus_generic_probe(xs.xs_dev); + bus_generic_attach(xs.xs_dev); +} + /** * Attach to the XenStore. * @@ -1130,12 +1164,37 @@ xs_attach(device_t dev) /* Initialize the interface to xenstore. */ struct proc *p; + xs.initialized = false; if (xen_hvm_domain()) { xs.evtchn = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN); xs.gpfn = hvm_get_parameter(HVM_PARAM_STORE_PFN); xen_store = pmap_mapdev(xs.gpfn * PAGE_SIZE, PAGE_SIZE); + xs.initialized = true; } else if (xen_pv_domain()) { - xs.evtchn = HYPERVISOR_start_info->store_evtchn; + if (HYPERVISOR_start_info->store_evtchn == 0) { + struct evtchn_alloc_unbound alloc_unbound; + + /* Allocate a local event channel for xenstore */ + alloc_unbound.dom = DOMID_SELF; + alloc_unbound.remote_dom = DOMID_SELF; + error = HYPERVISOR_event_channel_op( + EVTCHNOP_alloc_unbound, &alloc_unbound); + if (error != 0) + panic( + "unable to alloc event channel for Dom0: %d", + error); + + HYPERVISOR_start_info->store_evtchn = + alloc_unbound.port; + xs.evtchn = alloc_unbound.port; + + /* Allocate memory for the xs shared ring */ + xen_store = malloc(PAGE_SIZE, M_XENSTORE, + M_WAITOK | M_ZERO); + } else { + xs.evtchn = HYPERVISOR_start_info->store_evtchn; + xs.initialized = true; + } } else { panic("Unknown domain type, cannot initialize xenstore."); } @@ -1167,7 +1226,11 @@ xs_attach(device_t dev) xs.xs_attachcb.ich_func = xs_attach_deferred; xs.xs_attachcb.ich_arg = NULL; - config_intrhook_establish(&xs.xs_attachcb); + if (xs.initialized) { + config_intrhook_establish(&xs.xs_attachcb); + } else { + TASK_INIT(&xs.xs_late_init, 0, xs_attach_late, NULL); + } return (error); } diff --git a/sys/xen/xenstore/xenstore_dev.c b/sys/dev/xen/xenstore/xenstore_dev.c similarity index 76% rename from sys/xen/xenstore/xenstore_dev.c rename to sys/dev/xen/xenstore/xenstore_dev.c index e1b4091447ab..54b5e82f75fb 100644 --- a/sys/xen/xenstore/xenstore_dev.c +++ b/sys/dev/xen/xenstore/xenstore_dev.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -216,9 +217,71 @@ static struct cdevsw xs_dev_cdevsw = { .d_name = "xs_dev", }; -void -xs_dev_init() +/*------------------ Private Device Attachment Functions --------------------*/ +/** + * \brief Identify instances of this device type in the system. + * + * \param driver The driver performing this identify action. + * \param parent The NewBus parent device for any devices this method adds. + */ +static void +xs_dev_identify(driver_t *driver __unused, device_t parent) { - make_dev(&xs_dev_cdevsw, 0, UID_ROOT, GID_WHEEL, 0400, - "xen/xenstore"); + /* + * A single device instance for our driver is always present + * in a system operating under Xen. + */ + BUS_ADD_CHILD(parent, 0, driver->name, 0); } + +/** + * \brief Probe for the existance of the Xenstore device + * + * \param dev NewBus device_t for this instance. + * + * \return Always returns 0 indicating success. + */ +static int +xs_dev_probe(device_t dev) +{ + + device_set_desc(dev, "Xenstore user-space device"); + return (0); +} + +/** + * \brief Attach the Xenstore device. + * + * \param dev NewBus device_t for this instance. + * + * \return On success, 0. Otherwise an errno value indicating the + * type of failure. + */ +static int +xs_dev_attach(device_t dev) +{ + struct cdev *xs_cdev; + + xs_cdev = make_dev(&xs_dev_cdevsw, 0, UID_ROOT, GID_WHEEL, 0400, + "xen/xenstore"); + if (xs_cdev == NULL) + return (EINVAL); + + return (0); +} + +/*-------------------- Private Device Attachment Data -----------------------*/ +static device_method_t xs_dev_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, xs_dev_identify), + DEVMETHOD(device_probe, xs_dev_probe), + DEVMETHOD(device_attach, xs_dev_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(xs_dev, xs_dev_driver, xs_dev_methods, 0); +devclass_t xs_dev_devclass; + +DRIVER_MODULE(xs_dev, xenstore, xs_dev_driver, xs_dev_devclass, + NULL, NULL); diff --git a/sys/dev/xen/xenstore/xenstored_dev.c b/sys/dev/xen/xenstore/xenstored_dev.c new file mode 100644 index 000000000000..ae24085dc809 --- /dev/null +++ b/sys/dev/xen/xenstore/xenstored_dev.c @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2014 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 + +#define XSD_READ_SIZE 20 + +static int xsd_dev_read(struct cdev *dev, struct uio *uio, int ioflag); +static int xsd_dev_mmap(struct cdev *dev, vm_ooffset_t offset, + vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr); + + +static struct cdevsw xsd_dev_cdevsw = { + .d_version = D_VERSION, + .d_read = xsd_dev_read, + .d_mmap = xsd_dev_mmap, + .d_name = "xsd_dev", +}; + +static int +xsd_dev_read(struct cdev *dev, struct uio *uio, int ioflag) +{ + char evtchn[XSD_READ_SIZE]; + int error, len; + + len = snprintf(evtchn, sizeof(evtchn), "%u", + HYPERVISOR_start_info->store_evtchn); + if (len < 0 || len > uio->uio_resid) + return (EINVAL); + + error = uiomove(evtchn, len, uio); + if (error) + return (error); + + return (0); +} + +static int +xsd_dev_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, + int nprot, vm_memattr_t *memattr) +{ + + if (offset != 0) + return (EINVAL); + + *paddr = pmap_kextract((vm_offset_t)xen_store); + + return (0); +} + +/*------------------ Private Device Attachment Functions --------------------*/ +/** + * \brief Identify instances of this device type in the system. + * + * \param driver The driver performing this identify action. + * \param parent The NewBus parent device for any devices this method adds. + */ +static void +xsd_dev_identify(driver_t *driver __unused, device_t parent) +{ + + if (!xen_pv_domain()) + return; + if (HYPERVISOR_start_info->store_mfn != 0) + return; + + /* + * Only attach if xenstore is not available, because we are the + * domain that's supposed to run it. + */ + BUS_ADD_CHILD(parent, 0, driver->name, 0); +} + +/** + * \brief Probe for the existence of the Xenstored device + * + * \param dev NewBus device_t for this instance. + * + * \return Always returns 0 indicating success. + */ +static int +xsd_dev_probe(device_t dev) +{ + + device_set_desc(dev, "Xenstored user-space device"); + return (BUS_PROBE_NOWILDCARD); +} + +/** + * \brief Attach the Xenstored device. + * + * \param dev NewBus device_t for this instance. + * + * \return On success, 0. Otherwise an errno value indicating the + * type of failure. + */ +static int +xsd_dev_attach(device_t dev) +{ + struct cdev *xsd_cdev; + + xsd_cdev = make_dev(&xsd_dev_cdevsw, 0, UID_ROOT, GID_WHEEL, 0400, + "xen/xenstored"); + if (xsd_cdev == NULL) + return (EINVAL); + + return (0); +} + +/*-------------------- Private Device Attachment Data -----------------------*/ +static device_method_t xsd_dev_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, xsd_dev_identify), + DEVMETHOD(device_probe, xsd_dev_probe), + DEVMETHOD(device_attach, xsd_dev_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(xsd_dev, xsd_dev_driver, xsd_dev_methods, 0); +devclass_t xsd_dev_devclass; + +DRIVER_MODULE(xsd_dev, xenpv, xsd_dev_driver, xsd_dev_devclass, + NULL, NULL); diff --git a/sys/dev/xl/if_xl.c b/sys/dev/xl/if_xl.c index 8c3846091a39..f7bd599a04ed 100644 --- a/sys/dev/xl/if_xl.c +++ b/sys/dev/xl/if_xl.c @@ -1866,7 +1866,7 @@ xl_rxeof(struct xl_softc *sc) * comes up in the ring. */ if (rxstat & XL_RXSTAT_UP_ERROR) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->xl_ptr->xl_status = 0; bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); @@ -1881,7 +1881,7 @@ xl_rxeof(struct xl_softc *sc) if (!(rxstat & XL_RXSTAT_UP_CMPLT)) { device_printf(sc->xl_dev, "bad receive status -- packet dropped\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->xl_ptr->xl_status = 0; bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); @@ -1901,7 +1901,7 @@ xl_rxeof(struct xl_softc *sc) * can do in this situation. */ if (xl_newbuf(sc, cur_rx)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); cur_rx->xl_ptr->xl_status = 0; bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); @@ -1910,7 +1910,7 @@ xl_rxeof(struct xl_softc *sc) bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = total_len; @@ -2014,7 +2014,7 @@ xl_txeof(struct xl_softc *sc) bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); m_freem(cur_tx->xl_mbuf); cur_tx->xl_mbuf = NULL; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; cur_tx->xl_next = sc->xl_cdata.xl_tx_free; @@ -2061,7 +2061,7 @@ xl_txeof_90xB(struct xl_softc *sc) cur_tx->xl_mbuf = NULL; } - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->xl_cdata.xl_tx_cnt--; XL_INC(idx, XL_TX_LIST_CNT); @@ -2185,7 +2185,7 @@ xl_intr(void *arg) } if (status & XL_STAT_TX_COMPLETE) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); xl_txeoc(sc); } @@ -2255,7 +2255,7 @@ xl_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count) XL_CMD_INTR_ACK|(status & XL_INTRS)); if (status & XL_STAT_TX_COMPLETE) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); xl_txeoc(sc); } @@ -2312,10 +2312,12 @@ xl_stats_update(struct xl_softc *sc) for (i = 0; i < 16; i++) *p++ = CSR_READ_1(sc, XL_W6_CARRIER_LOST + i); - ifp->if_ierrors += xl_stats.xl_rx_overrun; + if_inc_counter(ifp, IFCOUNTER_IERRORS, xl_stats.xl_rx_overrun); - ifp->if_collisions += xl_stats.xl_tx_multi_collision + - xl_stats.xl_tx_single_collision + xl_stats.xl_tx_late_collision; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + xl_stats.xl_tx_multi_collision + + xl_stats.xl_tx_single_collision + + xl_stats.xl_tx_late_collision); /* * Boomerang and cyclone chips have an extra stats counter @@ -3121,7 +3123,7 @@ xl_watchdog(struct xl_softc *sc) return (0); } - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); XL_SEL_WIN(4); status = CSR_READ_2(sc, XL_W4_MEDIA_STATUS); device_printf(sc->xl_dev, "watchdog timeout\n"); diff --git a/sys/fs/autofs/autofs.c b/sys/fs/autofs/autofs.c index eeaf705f5b92..719a2c57dc62 100644 --- a/sys/fs/autofs/autofs.c +++ b/sys/fs/autofs/autofs.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -260,7 +261,7 @@ autofs_path(struct autofs_node *anp) } static void -autofs_callout(void *context) +autofs_task(void *context, int pending) { struct autofs_request *ar; @@ -296,9 +297,9 @@ autofs_cached(struct autofs_node *anp, const char *component, int componentlen) * is necessary for wildcard indirect map keys to work. */ if (anp->an_parent == NULL && componentlen != 0) { - AUTOFS_LOCK(amp); + AUTOFS_SLOCK(amp); error = autofs_node_find(anp, component, componentlen, NULL); - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); if (error != 0) return (false); } @@ -414,9 +415,14 @@ autofs_trigger_one(struct autofs_node *anp, strlcpy(ar->ar_options, amp->am_options, sizeof(ar->ar_options)); - callout_init(&ar->ar_callout, 1); - callout_reset(&ar->ar_callout, - autofs_timeout * hz, autofs_callout, ar); + TIMEOUT_TASK_INIT(taskqueue_thread, &ar->ar_task, 0, + autofs_task, ar); + error = taskqueue_enqueue_timeout(taskqueue_thread, + &ar->ar_task, autofs_timeout * hz); + if (error != 0) { + AUTOFS_WARN("taskqueue_enqueue_timeout() failed " + "with error %d", error); + } refcount_init(&ar->ar_refcount, 1); TAILQ_INSERT_TAIL(&autofs_softc->sc_requests, ar, ar_next); } @@ -429,11 +435,6 @@ autofs_trigger_one(struct autofs_node *anp, &autofs_softc->sc_lock); autofs_restore_sigmask(&oldset); if (error != 0) { - /* - * XXX: For some reson this returns -1 - * instead of EINTR, wtf?! - */ - error = EINTR; AUTOFS_WARN("cv_wait_sig for %s failed " "with error %d", ar->ar_path, error); break; @@ -453,12 +454,13 @@ autofs_trigger_one(struct autofs_node *anp, if (last) { TAILQ_REMOVE(&autofs_softc->sc_requests, ar, ar_next); /* - * XXX: Is it safe? + * Unlock the sc_lock, so that autofs_task() can complete. */ sx_xunlock(&autofs_softc->sc_lock); - callout_drain(&ar->ar_callout); - sx_xlock(&autofs_softc->sc_lock); + taskqueue_cancel_timeout(taskqueue_thread, &ar->ar_task, NULL); + taskqueue_drain_timeout(taskqueue_thread, &ar->ar_task); uma_zfree(autofs_request_zone, ar); + sx_xlock(&autofs_softc->sc_lock); } /* @@ -495,7 +497,7 @@ autofs_trigger(struct autofs_node *anp, anp->an_retries = 0; return (0); } - if (error == EINTR) { + if (error == EINTR || error == ERESTART) { AUTOFS_DEBUG("trigger interrupted by signal, " "not retrying"); anp->an_retries = 0; @@ -541,11 +543,6 @@ autofs_ioctl_request(struct autofs_daemon_request *adr) error = cv_wait_sig(&autofs_softc->sc_cv, &autofs_softc->sc_lock); if (error != 0) { - /* - * XXX: For some reson this returns -1 instead - * of EINTR, wtf?! - */ - error = EINTR; sx_xunlock(&autofs_softc->sc_lock); AUTOFS_DEBUG("failed with error %d", error); return (error); diff --git a/sys/fs/autofs/autofs.h b/sys/fs/autofs/autofs.h index 2c72645792b3..dc33eeff54e6 100644 --- a/sys/fs/autofs/autofs.h +++ b/sys/fs/autofs/autofs.h @@ -42,20 +42,26 @@ extern uma_zone_t autofs_node_zone; extern int autofs_debug; extern int autofs_mount_on_stat; -#define AUTOFS_DEBUG(X, ...) \ - if (autofs_debug > 1) { \ - printf("%s: " X "\n", __func__, ## __VA_ARGS__);\ +#define AUTOFS_DEBUG(X, ...) \ + do { \ + if (autofs_debug > 1) \ + printf("%s: " X "\n", __func__, ## __VA_ARGS__);\ } while (0) -#define AUTOFS_WARN(X, ...) \ - if (autofs_debug > 0) { \ - printf("WARNING: %s: " X "\n", \ - __func__, ## __VA_ARGS__); \ +#define AUTOFS_WARN(X, ...) \ + do { \ + if (autofs_debug > 0) { \ + printf("WARNING: %s: " X "\n", \ + __func__, ## __VA_ARGS__); \ + } \ } while (0) -#define AUTOFS_LOCK(X) sx_xlock(&X->am_lock) -#define AUTOFS_UNLOCK(X) sx_xunlock(&X->am_lock) -#define AUTOFS_ASSERT_LOCKED(X) sx_assert(&X->am_lock, SA_XLOCKED) +#define AUTOFS_SLOCK(X) sx_slock(&X->am_lock) +#define AUTOFS_XLOCK(X) sx_xlock(&X->am_lock) +#define AUTOFS_SUNLOCK(X) sx_sunlock(&X->am_lock) +#define AUTOFS_XUNLOCK(X) sx_xunlock(&X->am_lock) +#define AUTOFS_ASSERT_LOCKED(X) sx_assert(&X->am_lock, SA_LOCKED) +#define AUTOFS_ASSERT_XLOCKED(X) sx_assert(&X->am_lock, SA_XLOCKED) #define AUTOFS_ASSERT_UNLOCKED(X) sx_assert(&X->am_lock, SA_UNLOCKED) struct autofs_node { @@ -97,7 +103,7 @@ struct autofs_request { char ar_prefix[MAXPATHLEN]; char ar_key[MAXPATHLEN]; char ar_options[MAXPATHLEN]; - struct callout ar_callout; + struct timeout_task ar_task; volatile u_int ar_refcount; }; @@ -132,6 +138,6 @@ int autofs_node_find(struct autofs_node *parent, const char *name, int namelen, struct autofs_node **anpp); void autofs_node_delete(struct autofs_node *anp); int autofs_node_vn(struct autofs_node *anp, struct mount *mp, - struct vnode **vpp); + int flags, struct vnode **vpp); #endif /* !AUTOFS_H */ diff --git a/sys/fs/autofs/autofs_vfsops.c b/sys/fs/autofs/autofs_vfsops.c index b289cadd4bac..13a5a89b81c7 100644 --- a/sys/fs/autofs/autofs_vfsops.c +++ b/sys/fs/autofs/autofs_vfsops.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -87,14 +88,18 @@ autofs_mount(struct mount *mp) vfs_getnewfsid(mp); - AUTOFS_LOCK(amp); + MNT_ILOCK(mp); + mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED; + MNT_IUNLOCK(mp); + + AUTOFS_XLOCK(amp); error = autofs_node_new(NULL, amp, ".", -1, &->am_root); if (error != 0) { - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); free(amp, M_AUTOFS); return (error); } - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); vfs_mountedfrom(mp, from); @@ -145,7 +150,7 @@ autofs_unmount(struct mount *mp, int mntflags) pause("autofs_umount", 1); } - AUTOFS_LOCK(amp); + AUTOFS_XLOCK(amp); /* * Not terribly efficient, but at least not recursive. @@ -159,7 +164,7 @@ autofs_unmount(struct mount *mp, int mntflags) autofs_node_delete(amp->am_root); mp->mnt_data = NULL; - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); sx_destroy(&->am_lock); @@ -176,7 +181,7 @@ autofs_root(struct mount *mp, int flags, struct vnode **vpp) amp = VFSTOAUTOFS(mp); - error = autofs_node_vn(amp->am_root, mp, vpp); + error = autofs_node_vn(amp->am_root, mp, flags, vpp); return (error); } diff --git a/sys/fs/autofs/autofs_vnops.c b/sys/fs/autofs/autofs_vnops.c index e0a75fa62ad6..72d6bfff842c 100644 --- a/sys/fs/autofs/autofs_vnops.c +++ b/sys/fs/autofs/autofs_vnops.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -197,12 +198,12 @@ autofs_trigger_vn(struct vnode *vp, const char *path, int pathlen, } static int -autofs_vget_callback(struct mount *mp, void *arg, int lkflags __unused, +autofs_vget_callback(struct mount *mp, void *arg, int flags, struct vnode **vpp) { - return (autofs_node_vn(arg, mp, vpp)); + return (autofs_node_vn(arg, mp, flags, vpp)); } static int @@ -232,7 +233,7 @@ autofs_lookup(struct vop_lookup_args *ap) * use vn_vget_ino_gen() which takes care of all that. */ error = vn_vget_ino_gen(dvp, autofs_vget_callback, - anp->an_parent, 0, vpp); + anp->an_parent, cnp->cn_lkflags, vpp); if (error != 0) { AUTOFS_WARN("vn_vget_ino_gen() failed with error %d", error); @@ -276,24 +277,24 @@ autofs_lookup(struct vop_lookup_args *ap) } } - AUTOFS_LOCK(amp); + AUTOFS_SLOCK(amp); error = autofs_node_find(anp, cnp->cn_nameptr, cnp->cn_namelen, &child); if (error != 0) { if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == CREATE) { - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (EJUSTRETURN); } - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (ENOENT); } /* * XXX: Dropping the node here is ok, because we never remove nodes. */ - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); - error = autofs_node_vn(child, mp, vpp); + error = autofs_node_vn(child, mp, cnp->cn_lkflags, vpp); if (error != 0) { if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == CREATE) return (EJUSTRETURN); @@ -324,16 +325,16 @@ autofs_mkdir(struct vop_mkdir_args *ap) if (autofs_ignore_thread(curthread) == false) return (EPERM); - AUTOFS_LOCK(amp); + AUTOFS_XLOCK(amp); error = autofs_node_new(anp, amp, ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen, &child); if (error != 0) { - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); return (error); } - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); - error = autofs_node_vn(child, vp->v_mount, ap->a_vpp); + error = autofs_node_vn(child, vp->v_mount, LK_EXCLUSIVE, ap->a_vpp); return (error); } @@ -426,7 +427,7 @@ autofs_readdir(struct vop_readdir_args *ap) } i = 2; /* Account for "." and "..". */ - AUTOFS_LOCK(amp); + AUTOFS_SLOCK(amp); TAILQ_FOREACH(child, &anp->an_children, an_next) { if (resid < AUTOFS_DELEN) { if (ap->a_eofflag != NULL) @@ -444,14 +445,14 @@ autofs_readdir(struct vop_readdir_args *ap) error = autofs_readdir_one(uio, child->an_name, child->an_fileno); if (error != 0) { - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (error); } offset += AUTOFS_DELEN; resid -= AUTOFS_DELEN; } - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (0); } @@ -504,7 +505,7 @@ autofs_node_new(struct autofs_node *parent, struct autofs_mount *amp, struct autofs_node *anp; if (parent != NULL) - AUTOFS_ASSERT_LOCKED(parent->an_mount); + AUTOFS_ASSERT_XLOCKED(parent->an_mount); anp = uma_zalloc(autofs_node_zone, M_WAITOK | M_ZERO); if (namelen >= 0) @@ -544,6 +545,8 @@ autofs_node_find(struct autofs_node *parent, const char *name, TAILQ_FOREACH(anp, &parent->an_children, an_next) { if (namelen >= 0) { + if (strlen(anp->an_name) != namelen) + continue; if (strncmp(anp->an_name, name, namelen) != 0) continue; } else { @@ -564,7 +567,7 @@ autofs_node_delete(struct autofs_node *anp) { struct autofs_node *parent; - AUTOFS_ASSERT_LOCKED(anp->an_mount); + AUTOFS_ASSERT_XLOCKED(anp->an_mount); KASSERT(TAILQ_EMPTY(&anp->an_children), ("have children")); callout_drain(&anp->an_callout); @@ -578,7 +581,8 @@ autofs_node_delete(struct autofs_node *anp) } int -autofs_node_vn(struct autofs_node *anp, struct mount *mp, struct vnode **vpp) +autofs_node_vn(struct autofs_node *anp, struct mount *mp, int flags, + struct vnode **vpp) { struct vnode *vp; int error; @@ -589,7 +593,7 @@ autofs_node_vn(struct autofs_node *anp, struct mount *mp, struct vnode **vpp) vp = anp->an_vnode; if (vp != NULL) { - error = vget(vp, LK_EXCLUSIVE | LK_RETRY, curthread); + error = vget(vp, flags | LK_RETRY, curthread); if (error != 0) { AUTOFS_WARN("vget failed with error %d", error); sx_xunlock(&anp->an_vnode_lock); @@ -629,6 +633,8 @@ autofs_node_vn(struct autofs_node *anp, struct mount *mp, struct vnode **vpp) vp->v_vflag |= VV_ROOT; vp->v_data = anp; + VN_LOCK_ASHARE(vp); + error = insmntque(vp, mp); if (error != 0) { AUTOFS_WARN("insmntque() failed with error %d", error); diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 1e3f5e844864..d0aabefe80a9 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -1700,6 +1700,7 @@ static struct fileops devfs_ops_f = { .fo_chown = vn_chown, .fo_sendfile = vn_sendfile, .fo_seek = vn_seek, + .fo_fill_kinfo = vn_fill_kinfo, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE }; diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 2046e33a5d39..0972ec7400d6 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -65,9 +66,11 @@ #include #include -#include -#include +#include #include +#include +#include +#include #include #include "opt_directio.h" @@ -124,6 +127,7 @@ struct vop_vector ext2_vnodeops = { .vop_close = ext2_close, .vop_create = ext2_create, .vop_fsync = ext2_fsync, + .vop_getpages = vnode_pager_local_getpages, .vop_getattr = ext2_getattr, .vop_inactive = ext2_inactive, .vop_ioctl = ext2_ioctl, diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index 690d8d09d92e..54f659fe70c8 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -1721,7 +1721,6 @@ fuse_vnop_write(struct vop_write_args *ap) vm_page_t *a_m; int a_count; int a_reqpage; - vm_ooffset_t a_offset; }; */ static int diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index b94091c62e45..d9f843611b31 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -820,7 +820,6 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, struct dqblk dqb; uid_t savuid; #endif - if (compare) { retnotsup = 0; error = nfsrv_getattrbits(nd, &attrbits, NULL, &retnotsup); @@ -902,6 +901,12 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, goto nfsmout; if (compare && !(*retcmpp)) { NFSSETSUPP_ATTRBIT(&checkattrbits); + + /* Some filesystem do not support NFSv4ACL */ + if (nfsrv_useacl == 0 || nfs_supportsnfsv4acls(vp) == 0) { + NFSCLRBIT_ATTRBIT(&checkattrbits, NFSATTRBIT_ACL); + NFSCLRBIT_ATTRBIT(&checkattrbits, NFSATTRBIT_ACLSUPPORT); + } if (!NFSEQUAL_ATTRBIT(&retattrbits, &checkattrbits) || retnotsup) *retcmpp = NFSERR_NOTSAME; @@ -1052,7 +1057,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, case NFSATTRBIT_ACL: if (compare) { if (!(*retcmpp)) { - if (nfsrv_useacl) { + if (nfsrv_useacl && nfs_supportsnfsv4acls(vp)) { NFSACL_T *naclp; naclp = acl_alloc(M_WAITOK); @@ -1073,21 +1078,22 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, } } } else { - if (vp != NULL && aclp != NULL) - error = nfsrv_dissectacl(nd, aclp, &aceerr, - &cnt, p); - else - error = nfsrv_dissectacl(nd, NULL, &aceerr, - &cnt, p); - if (error) - goto nfsmout; + if (vp != NULL && aclp != NULL) + error = nfsrv_dissectacl(nd, aclp, &aceerr, + &cnt, p); + else + error = nfsrv_dissectacl(nd, NULL, &aceerr, + &cnt, p); + if (error) + goto nfsmout; } + attrsum += cnt; break; case NFSATTRBIT_ACLSUPPORT: NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); if (compare && !(*retcmpp)) { - if (nfsrv_useacl) { + if (nfsrv_useacl && nfs_supportsnfsv4acls(vp)) { if (fxdr_unsigned(u_int32_t, *tl) != NFSV4ACE_SUPTYPES) *retcmpp = NFSERR_NOTSAME; @@ -2090,6 +2096,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp, } } } + /* * Put out the attribute bitmap for the ones being filled in * and get the field for the number of attributes returned. diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 2abd7e4dc880..ef15a1d686f2 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -644,9 +644,9 @@ int nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct ucred *, int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *, struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t); -int nfsrv_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *, +int nfsrv_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *, NFSACL_T *, NFSPROC_T *); -int nfsv4_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *, +int nfsv4_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *, NFSACL_T *, NFSPROC_T *); int nfsvno_checkexp(mount_t, NFSSOCKADDR_T, struct nfsexstuff *, struct ucred **); diff --git a/sys/fs/nfs/nfsm_subs.h b/sys/fs/nfs/nfsm_subs.h index ebdfbc7b834c..0c31f56a32c3 100644 --- a/sys/fs/nfs/nfsm_subs.h +++ b/sys/fs/nfs/nfsm_subs.h @@ -47,13 +47,6 @@ * First define what the actual subs. return */ #define M_HASCL(m) ((m)->m_flags & M_EXT) -#define NFSMINOFF(m) \ - if (M_HASCL(m)) \ - (m)->m_data = (m)->m_ext.ext_buf; \ - else if ((m)->m_flags & M_PKTHDR) \ - (m)->m_data = (m)->m_pktdat; \ - else \ - (m)->m_data = (m)->m_dat #define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \ (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN)) #define NFSM_DATAP(m, s) (m)->m_data += (s) diff --git a/sys/fs/nfs/nfsproto.h b/sys/fs/nfs/nfsproto.h index 731be0777c15..768dfcbbc9af 100644 --- a/sys/fs/nfs/nfsproto.h +++ b/sys/fs/nfs/nfsproto.h @@ -996,7 +996,11 @@ struct nfsv3_sattr { NFSATTRBM_TIMEDELTA | \ NFSATTRBM_TIMEMETADATA | \ NFSATTRBM_TIMEMODIFY | \ - NFSATTRBM_MOUNTEDONFILEID) + NFSATTRBM_MOUNTEDONFILEID | \ + NFSATTRBM_QUOTAHARD | \ + NFSATTRBM_QUOTASOFT | \ + NFSATTRBM_QUOTAUSED) + #ifdef QUOTA /* diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index dc106ee53707..4c8c2dc62322 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -128,24 +128,21 @@ ncl_getpages(struct vop_getpages_args *ap) npages = btoc(count); + /* + * Since the caller has busied the requested page, that page's valid + * field will not be changed by other threads. + */ + vm_page_assert_xbusied(pages[ap->a_reqpage]); + /* * If the requested page is partially valid, just return it and * allow the pager to zero-out the blanks. Partially valid pages * can only occur at the file EOF. */ - VM_OBJECT_WLOCK(object); if (pages[ap->a_reqpage]->valid != 0) { - for (i = 0; i < npages; ++i) { - if (i != ap->a_reqpage) { - vm_page_lock(pages[i]); - vm_page_free(pages[i]); - vm_page_unlock(pages[i]); - } - } - VM_OBJECT_WUNLOCK(object); - return (0); + vm_pager_free_nonreq(object, pages, ap->a_reqpage, npages); + return (VM_PAGER_OK); } - VM_OBJECT_WUNLOCK(object); /* * We use only the kva address for the buffer, but this is extremely @@ -175,15 +172,7 @@ ncl_getpages(struct vop_getpages_args *ap) if (error && (uio.uio_resid == count)) { ncl_printf("nfs_getpages: error %d\n", error); - VM_OBJECT_WLOCK(object); - for (i = 0; i < npages; ++i) { - if (i != ap->a_reqpage) { - vm_page_lock(pages[i]); - vm_page_free(pages[i]); - vm_page_unlock(pages[i]); - } - } - VM_OBJECT_WUNLOCK(object); + vm_pager_free_nonreq(object, pages, ap->a_reqpage, npages); return (VM_PAGER_ERROR); } diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 1973c14f41b4..5bd4538f073c 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1008,7 +1008,7 @@ nfsvno_getsymlink(struct nfsrv_descript *nd, struct nfsvattr *nvap, *pathcpp = NULL; *lenp = 0; if ((nd->nd_flag & ND_NFSV3) && - (error = nfsrv_sattr(nd, nvap, NULL, NULL, p))) + (error = nfsrv_sattr(nd, NULL, nvap, NULL, NULL, p))) goto nfsmout; NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); len = fxdr_unsigned(int, *tl); @@ -2298,7 +2298,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram, * (Return 0 or EBADRPC) */ int -nfsrv_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, +nfsrv_sattr(struct nfsrv_descript *nd, vnode_t vp, struct nfsvattr *nvap, nfsattrbit_t *attrbitp, NFSACL_T *aclp, struct thread *p) { u_int32_t *tl; @@ -2380,7 +2380,7 @@ nfsrv_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, }; break; case ND_NFSV4: - error = nfsv4_sattr(nd, nvap, attrbitp, aclp, p); + error = nfsv4_sattr(nd, vp, nvap, attrbitp, aclp, p); }; nfsmout: NFSEXITCODE2(error, nd); @@ -2392,7 +2392,7 @@ nfsrv_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, * Returns NFSERR_BADXDR if it can't be parsed, 0 otherwise. */ int -nfsv4_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, +nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, struct nfsvattr *nvap, nfsattrbit_t *attrbitp, NFSACL_T *aclp, struct thread *p) { u_int32_t *tl; @@ -2429,6 +2429,11 @@ nfsv4_sattr(struct nfsrv_descript *nd, struct nfsvattr *nvap, switch (bitpos) { case NFSATTRBIT_SIZE: NFSM_DISSECT(tl, u_int32_t *, NFSX_HYPER); + if (vp != NULL && vp->v_type != VREG) { + error = (vp->v_type == VDIR) ? NFSERR_ISDIR : + NFSERR_INVAL; + goto nfsmout; + } nvap->na_size = fxdr_hyper(tl); attrsum += NFSX_HYPER; break; diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 0d3ff7658ec6..9bf43c37b10a 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -210,6 +210,17 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram, if (nd->nd_repstat == 0) { accmode = 0; NFSSET_ATTRBIT(&tmpbits, &attrbits); + + /* + * GETATTR with write-only attr time_access_set and time_modify_set + * should return NFS4ERR_INVAL. + */ + if (NFSISSET_ATTRBIT(&tmpbits, NFSATTRBIT_TIMEACCESSSET) || + NFSISSET_ATTRBIT(&tmpbits, NFSATTRBIT_TIMEMODIFYSET)){ + error = NFSERR_INVAL; + vput(vp); + goto out; + } if (NFSISSET_ATTRBIT(&tmpbits, NFSATTRBIT_ACL)) { NFSCLRBIT_ATTRBIT(&tmpbits, NFSATTRBIT_ACL); accmode |= VREAD_ACL; @@ -315,7 +326,7 @@ nfsrvd_setattr(struct nfsrv_descript *nd, __unused int isdgram, stateid.seqid = fxdr_unsigned(u_int32_t, *tl++); NFSBCOPY((caddr_t)tl,(caddr_t)stateid.other,NFSX_STATEIDOTHER); } - error = nfsrv_sattr(nd, &nva, &attrbits, aclp, p); + error = nfsrv_sattr(nd, vp, &nva, &attrbits, aclp, p); if (error) goto nfsmout; preat_ret = nfsvno_getattr(vp, &nva2, nd->nd_cred, p, 1); @@ -1019,7 +1030,7 @@ nfsrvd_create(struct nfsrv_descript *nd, __unused int isdgram, switch (how) { case NFSCREATE_GUARDED: case NFSCREATE_UNCHECKED: - error = nfsrv_sattr(nd, &nva, NULL, NULL, p); + error = nfsrv_sattr(nd, NULL, &nva, NULL, NULL, p); if (error) goto nfsmout; break; @@ -1204,7 +1215,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); vtyp = nfsv34tov_type(*tl); } - error = nfsrv_sattr(nd, &nva, &attrbits, aclp, p); + error = nfsrv_sattr(nd, NULL, &nva, &attrbits, aclp, p); if (error) goto nfsmout; nva.na_type = vtyp; @@ -1850,7 +1861,7 @@ nfsrvd_mkdir(struct nfsrv_descript *nd, __unused int isdgram, if (!nd->nd_repstat) { NFSVNO_ATTRINIT(&nva); if (nd->nd_flag & ND_NFSV3) { - error = nfsrv_sattr(nd, &nva, NULL, NULL, p); + error = nfsrv_sattr(nd, NULL, &nva, NULL, NULL, p); if (error) goto nfsmout; } else { @@ -1967,11 +1978,21 @@ nfsrvd_commit(struct nfsrv_descript *nd, __unused int isdgram, int error = 0, for_ret = 1, aft_ret = 1, cnt; u_int64_t off; - if (nd->nd_repstat) { + if (nd->nd_repstat) { nfsrv_wcc(nd, for_ret, &bfor, aft_ret, &aft); goto out; } + + /* Return NFSERR_ISDIR in NFSv4 when commit on a directory. */ + if (vp->v_type != VREG) { + if (nd->nd_flag & ND_NFSV3) + error = NFSERR_NOTSUPP; + else + error = (vp->v_type == VDIR) ? NFSERR_ISDIR : NFSERR_INVAL; + goto nfsmout; + } NFSM_DISSECT(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + /* * XXX At this time VOP_FSYNC() does not accept offset and byte * count parameters, so these arguments are useless (someday maybe). @@ -2683,7 +2704,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, switch (how) { case NFSCREATE_UNCHECKED: case NFSCREATE_GUARDED: - error = nfsv4_sattr(nd, &nva, &attrbits, aclp, p); + error = nfsv4_sattr(nd, NULL, &nva, &attrbits, aclp, p); if (error) goto nfsmout; /* @@ -2707,7 +2728,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, NFSM_DISSECT(tl, u_int32_t *, NFSX_VERF); cverf[0] = *tl++; cverf[1] = *tl; - error = nfsv4_sattr(nd, &nva, &attrbits, aclp, p); + error = nfsv4_sattr(nd, vp, &nva, &attrbits, aclp, p); if (error != 0) goto nfsmout; if (NFSISSET_ATTRBIT(&attrbits, @@ -2858,7 +2879,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, * The IETF working group decided that this is the correct * error return for all non-regular files. */ - nd->nd_repstat = NFSERR_SYMLINK; + nd->nd_repstat = (vp->v_type == VDIR) ? NFSERR_ISDIR : NFSERR_SYMLINK; } if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_WRITEACCESS)) nd->nd_repstat = nfsvno_accchk(vp, VWRITE, nd->nd_cred, @@ -3197,6 +3218,11 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unused int isdgram, nfsv4stateid_t stateid; nfsquad_t clientid; + /* opendowngrade can only work on a file object.*/ + if (vp->v_type != VREG) { + error = NFSERR_INVAL; + goto nfsmout; + } NFSM_DISSECT(tl, u_int32_t *, NFSX_STATEID + 3 * NFSX_UNSIGNED); stp->ls_ownerlen = 0; stp->ls_op = nd->nd_rp; diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 2faf064d7567..97f8fffd622b 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -1628,9 +1628,17 @@ nfsrv_lockctrl(vnode_t vp, struct nfsstate **new_stpp, */ if (error == 0 && (stp->ls_flags & NFSLCK_OPEN) && ((stp->ls_openowner->ls_flags & NFSLCK_NEEDSCONFIRM) || - (getlckret == 0 && stp->ls_lfp != lfp))) - error = NFSERR_BADSTATEID; - if (error == 0 && + (getlckret == 0 && stp->ls_lfp != lfp))){ + /* + * NFSLCK_SETATTR should return OK rather than NFSERR_BADSTATEID + * The only exception is using SETATTR with SIZE. + * */ + if ((new_stp->ls_flags & + (NFSLCK_SETATTR | NFSLCK_CHECK)) != NFSLCK_SETATTR) + error = NFSERR_BADSTATEID; + } + + if (error == 0 && (stp->ls_flags & (NFSLCK_DELEGREAD | NFSLCK_DELEGWRITE)) && getlckret == 0 && stp->ls_lfp != lfp) error = NFSERR_BADSTATEID; @@ -4909,12 +4917,17 @@ nfsrv_checkremove(vnode_t vp, int remove, NFSPROC_T *p) * Now, look for a conflicting open share. */ if (remove) { - LIST_FOREACH(stp, &lfp->lf_open, ls_file) { - if (stp->ls_flags & NFSLCK_WRITEDENY) { - error = NFSERR_FILEOPEN; - break; + /* + * If the entry in the directory was the last reference to the + * corresponding filesystem object, the object can be destroyed + * */ + if(lfp->lf_usecount>1) + LIST_FOREACH(stp, &lfp->lf_open, ls_file) { + if (stp->ls_flags & NFSLCK_WRITEDENY) { + error = NFSERR_FILEOPEN; + break; + } } - } } NFSUNLOCKSTATE(); diff --git a/sys/fs/smbfs/smbfs_io.c b/sys/fs/smbfs/smbfs_io.c index 0ffb50391c95..a567ce6bf19c 100644 --- a/sys/fs/smbfs/smbfs_io.c +++ b/sys/fs/smbfs/smbfs_io.c @@ -419,7 +419,6 @@ smbfs_getpages(ap) vm_page_t *a_m; int a_count; int a_reqpage; - vm_ooffset_t a_offset; } */ *ap; { #ifdef SMBFS_RWGENERIC @@ -568,7 +567,6 @@ smbfs_putpages(ap) int a_count; int a_sync; int *a_rtvals; - vm_ooffset_t a_offset; } */ *ap; { int error; diff --git a/sys/gdb/gdb_int.h b/sys/gdb/gdb_int.h index d06943a2a002..aa8940257a69 100644 --- a/sys/gdb/gdb_int.h +++ b/sys/gdb/gdb_int.h @@ -60,6 +60,9 @@ void gdb_tx_begin(char); int gdb_tx_end(void); int gdb_tx_mem(const unsigned char *, size_t); void gdb_tx_reg(int); +int gdb_rx_bindata(unsigned char *data, size_t datalen, size_t *amt); +int gdb_search_mem(const unsigned char *addr, size_t size, + const unsigned char *pat, size_t patlen, const unsigned char **found); static __inline void gdb_tx_char(char c) diff --git a/sys/gdb/gdb_main.c b/sys/gdb/gdb_main.c index 4ed3272108e5..f8f3836f66eb 100644 --- a/sys/gdb/gdb_main.c +++ b/sys/gdb/gdb_main.c @@ -53,6 +53,8 @@ SET_DECLARE(gdb_dbgport_set, struct gdb_dbgport); struct gdb_dbgport *gdb_cur = NULL; int gdb_listening = 0; +static unsigned char gdb_bindata[64]; + static int gdb_init(void) { @@ -254,6 +256,28 @@ gdb_trap(int type, int code) gdb_tx_begin('l'); gdb_tx_end(); } + } else if (gdb_rx_equal("Search:memory:")) { + size_t patlen; + intmax_t addr, size; + const unsigned char *found; + if (gdb_rx_varhex(&addr) || gdb_rx_char() != ';' || + gdb_rx_varhex(&size) || gdb_rx_char() != ';' || + gdb_rx_bindata(gdb_bindata, sizeof(gdb_bindata), &patlen)) { + gdb_tx_err(EINVAL); + break; + } + if (gdb_search_mem((char *)(uintptr_t)addr, size, gdb_bindata, patlen, &found)) { + if (found == 0ULL) + gdb_tx_begin('0'); + else { + gdb_tx_begin('1'); + gdb_tx_char(','); + gdb_tx_hex((intmax_t)(uintptr_t)found, 8); + } + gdb_tx_end(); + } else + gdb_tx_err(EIO); + break; } else if (!gdb_cpu_query()) gdb_tx_empty(); break; diff --git a/sys/gdb/gdb_packet.c b/sys/gdb/gdb_packet.c index a62cc8d16b36..73ee74f34bd0 100644 --- a/sys/gdb/gdb_packet.c +++ b/sys/gdb/gdb_packet.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -320,3 +321,46 @@ gdb_tx_reg(int regnum) } else gdb_tx_mem(regp, regsz); } + +/* Read binary data up until the end of the packet or until we have datalen decoded bytes */ +int +gdb_rx_bindata(unsigned char *data, size_t datalen, size_t *amt) +{ + int c; + + *amt = 0; + + while (*amt < datalen) { + c = gdb_rx_char(); + /* End of packet? */ + if (c == -1) + break; + /* Escaped character up next */ + if (c == '}') { + /* Truncated packet? Bail out */ + if ((c = gdb_rx_char()) == -1) + return (1); + c ^= 0x20; + } + *(data++) = c & 0xff; + (*amt)++; + } + + return (0); +} + +int +gdb_search_mem(const unsigned char *addr, size_t size, const unsigned char *pat, size_t patlen, const unsigned char **found) +{ + void *prev; + jmp_buf jb; + int ret; + + prev = kdb_jmpbuf(jb); + ret = setjmp(jb); + if (ret == 0) + *found = memmem(addr, size, pat, patlen); + + (void)kdb_jmpbuf(prev); + return ((ret == 0) ? 1 : 0); +} diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 2c4dc2c41ae5..f545b75bfd0e 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -82,6 +82,24 @@ u_int g_eli_batch = 0; SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RWTUN, &g_eli_batch, 0, "Use crypto operations batching"); +/* + * Passphrase cached during boot, in order to be more user-friendly if + * there are multiple providers using the same passphrase. + */ +static char cached_passphrase[256]; +static u_int g_eli_boot_passcache = 1; +TUNABLE_INT("kern.geom.eli.boot_passcache", &g_eli_boot_passcache); +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, boot_passcache, CTLFLAG_RD, + &g_eli_boot_passcache, 0, + "Passphrases are cached during boot process for possible reuse"); +static void +zero_boot_passcache(void * dummy) +{ + + memset(cached_passphrase, 0, sizeof(cached_passphrase)); +} +EVENTHANDLER_DEFINE(mountroot, zero_boot_passcache, NULL, 0); + static eventhandler_tag g_eli_pre_sync = NULL; static int g_eli_destroy_geom(struct gctl_req *req, struct g_class *mp, @@ -1059,7 +1077,7 @@ g_eli_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) tries = g_eli_tries; } - for (i = 0; i < tries; i++) { + for (i = 0; i <= tries; i++) { g_eli_crypto_hmac_init(&ctx, NULL, 0); /* @@ -1083,9 +1101,19 @@ g_eli_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) /* Ask for the passphrase if defined. */ if (md.md_iterations >= 0) { - printf("Enter passphrase for %s: ", pp->name); - cngets(passphrase, sizeof(passphrase), - g_eli_visible_passphrase); + /* Try first with cached passphrase. */ + if (i == 0) { + if (!g_eli_boot_passcache) + continue; + memcpy(passphrase, cached_passphrase, + sizeof(passphrase)); + } else { + printf("Enter passphrase for %s: ", pp->name); + cngets(passphrase, sizeof(passphrase), + g_eli_visible_passphrase); + memcpy(cached_passphrase, passphrase, + sizeof(passphrase)); + } } /* @@ -1115,15 +1143,18 @@ g_eli_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) error = g_eli_mkey_decrypt(&md, key, mkey, &nkey); bzero(key, sizeof(key)); if (error == -1) { - if (i == tries - 1) { + if (i == tries) { G_ELI_DEBUG(0, "Wrong key for %s. No tries left.", pp->name); g_eli_keyfiles_clear(pp->name); return (NULL); } - G_ELI_DEBUG(0, "Wrong key for %s. Tries left: %u.", - pp->name, tries - i - 1); + if (i > 0) { + G_ELI_DEBUG(0, + "Wrong key for %s. Tries left: %u.", + pp->name, tries - i); + } /* Try again. */ continue; } else if (error > 0) { diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index a2034d379c8c..c7104d85375e 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -281,7 +281,7 @@ g_dev_open(struct cdev *dev, int flags, int fmt, struct thread *td) cp = dev->si_drv2; if (cp == NULL) - return(ENXIO); /* g_dev_taste() not done yet */ + return (ENXIO); /* g_dev_taste() not done yet */ g_trace(G_T_ACCESS, "g_dev_open(%s, %d, %d, %p)", cp->geom->name, flags, fmt, td); @@ -312,7 +312,7 @@ g_dev_open(struct cdev *dev, int flags, int fmt, struct thread *td) sc->sc_open += r + w + e; mtx_unlock(&sc->sc_mtx); } - return(error); + return (error); } static int @@ -324,10 +324,10 @@ g_dev_close(struct cdev *dev, int flags, int fmt, struct thread *td) cp = dev->si_drv2; if (cp == NULL) - return(ENXIO); + return (ENXIO); g_trace(G_T_ACCESS, "g_dev_close(%s, %d, %d, %p)", cp->geom->name, flags, fmt, td); - + r = flags & FREAD ? -1 : 0; w = flags & FWRITE ? -1 : 0; #ifdef notyet @@ -361,7 +361,6 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread struct g_kerneldump kd; off_t offset, length, chunk; int i, error; - u_int u; cp = dev->si_drv2; pp = cp->provider; @@ -396,19 +395,17 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread error = g_io_getattr("GEOM::frontstuff", cp, &i, data); break; case DIOCSKERNELDUMP: - u = *((u_int *)data); - if (!u) { - set_dumper(NULL, NULL); - error = 0; + if (*(u_int *)data == 0) { + error = set_dumper(NULL, NULL); break; } kd.offset = 0; kd.length = OFF_MAX; i = sizeof kd; error = g_io_getattr("GEOM::kerneldump", cp, &i, &kd); - if (!error) { + if (error == 0) { error = set_dumper(&kd.di, devtoname(dev)); - if (!error) + if (error == 0) dev->si_flags |= SI_DUMPDEV; } break; @@ -425,7 +422,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread error = EINVAL; break; } - while (length > 0) { + while (length > 0) { chunk = length; if (g_dev_del_max_sectors != 0 && chunk > g_dev_del_max_sectors * cp->provider->sectorsize) { @@ -618,7 +615,7 @@ g_dev_orphan(struct g_consumer *cp) /* Reset any dump-area set on this device */ if (dev->si_flags & SI_DUMPDEV) - set_dumper(NULL, NULL); + (void)set_dumper(NULL, NULL); /* Destroy the struct cdev *so we get no more requests */ destroy_dev_sched_cb(dev, g_dev_callback, cp); diff --git a/sys/geom/geom_map.c b/sys/geom/geom_map.c index afc26b66633c..a5db2a55b3df 100644 --- a/sys/geom/geom_map.c +++ b/sys/geom/geom_map.c @@ -153,8 +153,8 @@ find_marker(struct g_consumer *cp, const char *line, off_t *offset) return (1); if (bootverbose) { - printf("MAP: search key \"%s\" from 0x%jx, step 0x%jx\n", - search_key, (intmax_t)search_start, (intmax_t)search_step); + printf("MAP: search %s for key \"%s\" from 0x%jx, step 0x%jx\n", + cp->geom->name, search_key, (intmax_t)search_start, (intmax_t)search_step); } /* error if search_key is empty */ @@ -321,9 +321,9 @@ g_map_parse_part(struct g_class *mp, struct g_provider *pp, } if (bootverbose) { - printf("MAP: %jxx%jx, data=%jxx%jx " + printf("MAP: %s: %jxx%jx, data=%jxx%jx " "\"/dev/map/%s\"\n", - (intmax_t)start, (intmax_t)size, (intmax_t)offset, + cp->geom->name, (intmax_t)start, (intmax_t)size, (intmax_t)offset, (intmax_t)dsize, name); } diff --git a/sys/gnu/fs/reiserfs/reiserfs_fs_i.h b/sys/gnu/fs/reiserfs/reiserfs_fs_i.h index d9e358ec8370..e269d9210925 100644 --- a/sys/gnu/fs/reiserfs/reiserfs_fs_i.h +++ b/sys/gnu/fs/reiserfs/reiserfs_fs_i.h @@ -59,7 +59,7 @@ struct reiserfs_node { flags read from sd_attrs. */ uint16_t i_mode; /* IFMT, permissions. */ - uint16_t i_nlink; /* File link count. */ + int16_t i_nlink; /* File link count. */ uint64_t i_size; /* File byte count. */ uint32_t i_bytes; uid_t i_uid; /* File owner. */ diff --git a/sys/i386/i386/initcpu.c b/sys/i386/i386/initcpu.c index f93ea13cb546..6872aecf47a9 100644 --- a/sys/i386/i386/initcpu.c +++ b/sys/i386/i386/initcpu.c @@ -59,6 +59,12 @@ static void init_i486_on_386(void); static void init_6x86(void); #endif /* I486_CPU */ +#if defined(I586_CPU) && defined(CPU_WT_ALLOC) +static void enable_K5_wt_alloc(void); +static void enable_K6_wt_alloc(void); +static void enable_K6_2_wt_alloc(void); +#endif + #ifdef I686_CPU static void init_6x86MX(void); static void init_ppro(void); @@ -451,7 +457,7 @@ init_winchip(void) fcr &= ~(1ULL << 11); /* - * Additioanlly, set EBRPRED, E2MMX and EAMD3D for WinChip 2 and 3. + * Additionally, set EBRPRED, E2MMX and EAMD3D for WinChip 2 and 3. */ if (CPUID_TO_MODEL(cpu_id) >= 8) fcr |= (1 << 12) | (1 << 19) | (1 << 20); @@ -527,6 +533,8 @@ init_6x86MX(void) intr_restore(saveintr); } +static int ppro_apic_used = -1; + static void init_ppro(void) { @@ -535,9 +543,29 @@ init_ppro(void) /* * Local APIC should be disabled if it is not going to be used. */ - apicbase = rdmsr(MSR_APICBASE); - apicbase &= ~APICBASE_ENABLED; - wrmsr(MSR_APICBASE, apicbase); + if (ppro_apic_used != 1) { + apicbase = rdmsr(MSR_APICBASE); + apicbase &= ~APICBASE_ENABLED; + wrmsr(MSR_APICBASE, apicbase); + ppro_apic_used = 0; + } +} + +/* + * If the local APIC is going to be used after being disabled above, + * re-enable it and don't disable it in the future. + */ +void +ppro_reenable_apic(void) +{ + u_int64_t apicbase; + + if (ppro_apic_used == 0) { + apicbase = rdmsr(MSR_APICBASE); + apicbase |= APICBASE_ENABLED; + wrmsr(MSR_APICBASE, apicbase); + ppro_apic_used = 1; + } } /* @@ -646,20 +674,6 @@ init_transmeta(void) } #endif -/* - * Initialize CR4 (Control register 4) to enable SSE instructions. - */ -void -enable_sse(void) -{ -#if defined(CPU_ENABLE_SSE) - if ((cpu_feature & CPUID_XMM) && (cpu_feature & CPUID_FXSR)) { - load_cr4(rcr4() | CR4_FXSR | CR4_XMM); - cpu_fxsr = hw_instruction_sse = 1; - } -#endif -} - extern int elf32_nxstack; void @@ -692,6 +706,27 @@ initializecpu(void) #ifdef I586_CPU case CPU_586: switch (cpu_vendor_id) { + case CPU_VENDOR_AMD: +#ifdef CPU_WT_ALLOC + if (((cpu_id & 0x0f0) > 0) && + ((cpu_id & 0x0f0) < 0x60) && + ((cpu_id & 0x00f) > 3)) + enable_K5_wt_alloc(); + else if (((cpu_id & 0x0f0) > 0x80) || + (((cpu_id & 0x0f0) == 0x80) && + (cpu_id & 0x00f) > 0x07)) + enable_K6_2_wt_alloc(); + else if ((cpu_id & 0x0f0) > 0x50) + enable_K6_wt_alloc(); +#endif + if ((cpu_id & 0xf0) == 0xa0) + /* + * Make sure the TSC runs through + * suspension, otherwise we can't use + * it as timecounter + */ + wrmsr(0x1900, rdmsr(0x1900) | 0x20ULL); + break; case CPU_VENDOR_CENTAUR: init_winchip(); break; @@ -762,7 +797,17 @@ initializecpu(void) default: break; } - enable_sse(); +#if defined(CPU_ENABLE_SSE) + if ((cpu_feature & CPUID_XMM) && (cpu_feature & CPUID_FXSR)) { + load_cr4(rcr4() | CR4_FXSR | CR4_XMM); + cpu_fxsr = hw_instruction_sse = 1; + } +#endif +} + +void +initializecpucache(void) +{ /* * CPUID with %eax = 1, %ebx returns @@ -839,7 +884,7 @@ initializecpu(void) * Enable write allocate feature of AMD processors. * Following two functions require the Maxmem variable being set. */ -void +static void enable_K5_wt_alloc(void) { u_int64_t msr; @@ -885,7 +930,7 @@ enable_K5_wt_alloc(void) } } -void +static void enable_K6_wt_alloc(void) { quad_t size; @@ -945,7 +990,7 @@ enable_K6_wt_alloc(void) intr_restore(saveintr); } -void +static void enable_K6_2_wt_alloc(void) { quad_t size; diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index ed7b072c7839..34b147dcc5fd 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -109,7 +109,11 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef PC98 +#include +#else #include +#endif #include @@ -197,10 +201,6 @@ static void fill_fpregs_xmm(struct savexmm *, struct save87 *); #endif /* CPU_ENABLE_SSE */ SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif - /* Intel ICH registers */ #define ICH_PMBASE 0x400 #define ICH_SMI_EN ICH_PMBASE + 0x30 @@ -208,6 +208,14 @@ extern vm_offset_t ksym_start, ksym_end; int _udatasel, _ucodesel; u_int basemem; +#ifdef PC98 +int need_pre_dma_flush; /* If 1, use wbinvd befor DMA transfer. */ +int need_post_dma_flush; /* If 1, use invd after DMA transfer. */ + +static int ispc98 = 1; +SYSCTL_INT(_machdep, OID_AUTO, ispc98, CTLFLAG_RD, &ispc98, 0, ""); +#endif + int cold = 1; #ifdef COMPAT_43 @@ -252,6 +260,9 @@ struct mem_range_softc mem_range_softc; struct init_ops init_ops = { .early_clock_source_init = i8254_init, .early_delay = i8254_delay, +#ifdef DEV_APIC + .msi_init = msi_init, +#endif }; static void @@ -260,7 +271,8 @@ cpu_startup(dummy) { uintmax_t memsize; char *sysenv; - + +#ifndef PC98 /* * On MacBooks, we need to disallow the legacy USB circuit to * generate an SMI# because this can cause several problems, @@ -286,6 +298,7 @@ cpu_startup(dummy) } freeenv(sysenv); } +#endif /* !PC98 */ /* * Good {morning,afternoon,evening,night}. @@ -1236,6 +1249,7 @@ SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, #define STATE_MWAIT 0x1 #define STATE_SLEEPING 0x2 +#ifndef PC98 static void cpu_idle_acpi(sbintime_t sbt) { @@ -1254,6 +1268,7 @@ cpu_idle_acpi(sbintime_t sbt) __asm __volatile("sti; hlt"); *state = STATE_RUNNING; } +#endif /* !PC98 */ #ifndef XEN static void @@ -1371,7 +1386,7 @@ cpu_probe_amdc1e(void) } } -#ifdef XEN +#if defined(PC98) || defined(XEN) void (*cpu_idle_fn)(sbintime_t) = cpu_idle_hlt; #else void (*cpu_idle_fn)(sbintime_t) = cpu_idle_acpi; @@ -1459,7 +1474,9 @@ struct { { cpu_idle_spin, "spin" }, { cpu_idle_mwait, "mwait" }, { cpu_idle_hlt, "hlt" }, +#ifndef PC98 { cpu_idle_acpi, "acpi" }, +#endif { NULL, NULL } }; @@ -1476,9 +1493,11 @@ idle_sysctl_available(SYSCTL_HANDLER_ARGS) if (strstr(idle_tbl[i].id_name, "mwait") && (cpu_feature2 & CPUID2_MON) == 0) continue; +#ifndef PC98 if (strcmp(idle_tbl[i].id_name, "acpi") == 0 && cpu_idle_hook == NULL) continue; +#endif p += sprintf(p, "%s%s", p != avail ? ", " : "", idle_tbl[i].id_name); } @@ -1513,9 +1532,11 @@ idle_sysctl(SYSCTL_HANDLER_ARGS) if (strstr(idle_tbl[i].id_name, "mwait") && (cpu_feature2 & CPUID2_MON) == 0) continue; +#ifndef PC98 if (strcmp(idle_tbl[i].id_name, "acpi") == 0 && cpu_idle_hook == NULL) continue; +#endif if (strcmp(idle_tbl[i].id_name, buf)) continue; cpu_idle_fn = idle_tbl[i].id_fn; @@ -2001,7 +2022,7 @@ sdtossd(sd, ssd) ssd->ssd_gran = sd->sd_gran; } -#ifndef XEN +#if !defined(PC98) && !defined(XEN) static int add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap, int *physmap_idxp) @@ -2108,7 +2129,9 @@ add_smap_entries(struct bios_smap *smapbase, vm_paddr_t *physmap, if (!add_smap_entry(smap, physmap, physmap_idxp)) break; } +#endif /* !PC98 && !XEN */ +#ifndef XEN static void basemem_setup(void) { @@ -2156,7 +2179,7 @@ basemem_setup(void) for (i = basemem / 4; i < 160; i++) pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U; } -#endif +#endif /* !XEN */ /* * Populate the (physmap) array with base/bound pairs describing the @@ -2171,6 +2194,271 @@ basemem_setup(void) * * XXX first should be vm_paddr_t. */ +#ifdef PC98 +static void +getmemsize(int first) +{ + int off, physmap_idx, pa_indx, da_indx; + u_long physmem_tunable, memtest; + vm_paddr_t physmap[PHYSMAP_SIZE]; + pt_entry_t *pte; + quad_t dcons_addr, dcons_size; + int i; + int pg_n; + u_int extmem; + u_int under16; + vm_paddr_t pa; + + bzero(physmap, sizeof(physmap)); + + /* XXX - some of EPSON machines can't use PG_N */ + pg_n = PG_N; + if (pc98_machine_type & M_EPSON_PC98) { + switch (epson_machine_id) { +#ifdef WB_CACHE + default: +#endif + case EPSON_PC486_HX: + case EPSON_PC486_HG: + case EPSON_PC486_HA: + pg_n = 0; + break; + } + } + + under16 = pc98_getmemsize(&basemem, &extmem); + basemem_setup(); + + physmap[0] = 0; + physmap[1] = basemem * 1024; + physmap_idx = 2; + physmap[physmap_idx] = 0x100000; + physmap[physmap_idx + 1] = physmap[physmap_idx] + extmem * 1024; + + /* + * Now, physmap contains a map of physical memory. + */ + +#ifdef SMP + /* make hole for AP bootstrap code */ + physmap[1] = mp_bootaddress(physmap[1]); +#endif + + /* + * Maxmem isn't the "maximum memory", it's one larger than the + * highest page of the physical address space. It should be + * called something like "Maxphyspage". We may adjust this + * based on ``hw.physmem'' and the results of the memory test. + */ + Maxmem = atop(physmap[physmap_idx + 1]); + +#ifdef MAXMEM + Maxmem = MAXMEM / 4; +#endif + + if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable)) + Maxmem = atop(physmem_tunable); + + /* + * By default keep the memtest enabled. Use a general name so that + * one could eventually do more with the code than just disable it. + */ + memtest = 1; + TUNABLE_ULONG_FETCH("hw.memtest.tests", &memtest); + + if (atop(physmap[physmap_idx + 1]) != Maxmem && + (boothowto & RB_VERBOSE)) + printf("Physical memory use set to %ldK\n", Maxmem * 4); + + /* + * If Maxmem has been increased beyond what the system has detected, + * extend the last memory segment to the new limit. + */ + if (atop(physmap[physmap_idx + 1]) < Maxmem) + physmap[physmap_idx + 1] = ptoa((vm_paddr_t)Maxmem); + + /* + * We need to divide chunk if Maxmem is larger than 16MB and + * under 16MB area is not full of memory. + * (1) system area (15-16MB region) is cut off + * (2) extended memory is only over 16MB area (ex. Melco "HYPERMEMORY") + */ + if ((under16 != 16 * 1024) && (extmem > 15 * 1024)) { + /* 15M - 16M region is cut off, so need to divide chunk */ + physmap[physmap_idx + 1] = under16 * 1024; + physmap_idx += 2; + physmap[physmap_idx] = 0x1000000; + physmap[physmap_idx + 1] = physmap[2] + extmem * 1024; + } + + /* call pmap initialization to make new kernel address space */ + pmap_bootstrap(first); + + /* + * Size up each available chunk of physical memory. + */ + physmap[0] = PAGE_SIZE; /* mask off page 0 */ + pa_indx = 0; + da_indx = 1; + phys_avail[pa_indx++] = physmap[0]; + phys_avail[pa_indx] = physmap[0]; + dump_avail[da_indx] = physmap[0]; + pte = CMAP3; + + /* + * Get dcons buffer address + */ + if (getenv_quad("dcons.addr", &dcons_addr) == 0 || + getenv_quad("dcons.size", &dcons_size) == 0) + dcons_addr = 0; + + /* + * physmap is in bytes, so when converting to page boundaries, + * round up the start address and round down the end address. + */ + for (i = 0; i <= physmap_idx; i += 2) { + vm_paddr_t end; + + end = ptoa((vm_paddr_t)Maxmem); + if (physmap[i + 1] < end) + end = trunc_page(physmap[i + 1]); + for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) { + int tmp, page_bad, full; + int *ptr = (int *)CADDR3; + + full = FALSE; + /* + * block out kernel memory as not available. + */ + if (pa >= KERNLOAD && pa < first) + goto do_dump_avail; + + /* + * block out dcons buffer + */ + if (dcons_addr > 0 + && pa >= trunc_page(dcons_addr) + && pa < dcons_addr + dcons_size) + goto do_dump_avail; + + page_bad = FALSE; + if (memtest == 0) + goto skip_memtest; + + /* + * map page into kernel: valid, read/write,non-cacheable + */ + *pte = pa | PG_V | PG_RW | pg_n; + invltlb(); + + tmp = *(int *)ptr; + /* + * Test for alternating 1's and 0's + */ + *(volatile int *)ptr = 0xaaaaaaaa; + if (*(volatile int *)ptr != 0xaaaaaaaa) + page_bad = TRUE; + /* + * Test for alternating 0's and 1's + */ + *(volatile int *)ptr = 0x55555555; + if (*(volatile int *)ptr != 0x55555555) + page_bad = TRUE; + /* + * Test for all 1's + */ + *(volatile int *)ptr = 0xffffffff; + if (*(volatile int *)ptr != 0xffffffff) + page_bad = TRUE; + /* + * Test for all 0's + */ + *(volatile int *)ptr = 0x0; + if (*(volatile int *)ptr != 0x0) + page_bad = TRUE; + /* + * Restore original value. + */ + *(int *)ptr = tmp; + +skip_memtest: + /* + * Adjust array of valid/good pages. + */ + if (page_bad == TRUE) + continue; + /* + * If this good page is a continuation of the + * previous set of good pages, then just increase + * the end pointer. Otherwise start a new chunk. + * Note that "end" points one higher than end, + * making the range >= start and < end. + * If we're also doing a speculative memory + * test and we at or past the end, bump up Maxmem + * so that we keep going. The first bad page + * will terminate the loop. + */ + if (phys_avail[pa_indx] == pa) { + phys_avail[pa_indx] += PAGE_SIZE; + } else { + pa_indx++; + if (pa_indx == PHYS_AVAIL_ARRAY_END) { + printf( + "Too many holes in the physical address space, giving up\n"); + pa_indx--; + full = TRUE; + goto do_dump_avail; + } + phys_avail[pa_indx++] = pa; /* start */ + phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */ + } + physmem++; +do_dump_avail: + if (dump_avail[da_indx] == pa) { + dump_avail[da_indx] += PAGE_SIZE; + } else { + da_indx++; + if (da_indx == DUMP_AVAIL_ARRAY_END) { + da_indx--; + goto do_next; + } + dump_avail[da_indx++] = pa; /* start */ + dump_avail[da_indx] = pa + PAGE_SIZE; /* end */ + } +do_next: + if (full) + break; + } + } + *pte = 0; + invltlb(); + + /* + * XXX + * The last chunk must contain at least one page plus the message + * buffer to avoid complicating other code (message buffer address + * calculation, etc.). + */ + while (phys_avail[pa_indx - 1] + PAGE_SIZE + + round_page(msgbufsize) >= phys_avail[pa_indx]) { + physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]); + phys_avail[pa_indx--] = 0; + phys_avail[pa_indx--] = 0; + } + + Maxmem = atop(phys_avail[pa_indx]); + + /* Trim off space for the message buffer. */ + phys_avail[pa_indx] -= round_page(msgbufsize); + + /* Map the message buffer. */ + for (off = 0; off < round_page(msgbufsize); off += PAGE_SIZE) + pmap_kenter((vm_offset_t)msgbufp + off, phys_avail[pa_indx] + + off); + + PT_UPDATES_FLUSH(); +} +#else /* PC98 */ static void getmemsize(int first) { @@ -2568,6 +2856,7 @@ getmemsize(int first) PT_UPDATES_FLUSH(); } +#endif /* PC98 */ #ifdef XEN #define MTOPSIZE (1<<(14 + PAGE_SHIFT)) @@ -2736,8 +3025,7 @@ init386(first) #endif #ifdef DDB - ksym_start = bootinfo.bi_symtab; - ksym_end = bootinfo.bi_esymtab; + db_fetch_ksymtab(bootinfo.bi_symtab, bootinfo.bi_esymtab); #endif kdb_init(); @@ -2753,6 +3041,7 @@ init386(first) setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); initializecpu(); /* Initialize CPU registers */ + initializecpucache(); /* make an initial tss so cpu can get interrupt stack on syscall! */ /* Note: -16 is so we can grow the trapframe if we came from vm86 */ @@ -2831,6 +3120,13 @@ init386(first) */ proc_linkup0(&proc0, &thread0); +#ifdef PC98 + /* + * Initialize DMAC + */ + pc98_init_dmac(); +#endif + metadata_missing = 0; if (bootinfo.bi_modulep) { preload_metadata = (caddr_t)bootinfo.bi_modulep + KERNBASE; @@ -2994,7 +3290,9 @@ init386(first) #ifdef DEV_ISA #ifdef DEV_ATPIC +#ifndef PC98 elcr_probe(); +#endif atpic_startup(); #else /* Reset and mask the atpics and leave them shut down. */ @@ -3012,8 +3310,7 @@ init386(first) #endif #ifdef DDB - ksym_start = bootinfo.bi_symtab; - ksym_end = bootinfo.bi_esymtab; + db_fetch_ksymtab(bootinfo.bi_symtab, bootinfo.bi_esymtab); #endif kdb_init(); @@ -3029,6 +3326,9 @@ init386(first) setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); initializecpu(); /* Initialize CPU registers */ +#ifdef PC98 + initializecpucache(); +#endif /* make an initial tss so cpu can get interrupt stack on syscall! */ /* Note: -16 is so we can grow the trapframe if we came from vm86 */ @@ -3116,6 +3416,7 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) pcpu->pc_acpi_id = 0xffffffff; } +#ifndef PC98 static int smap_sysctl_handler(SYSCTL_HANDLER_ARGS) { @@ -3151,6 +3452,7 @@ smap_sysctl_handler(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_machdep, OID_AUTO, smap, CTLTYPE_OPAQUE|CTLFLAG_RD, NULL, 0, smap_sysctl_handler, "S,bios_smap_xattr", "Raw BIOS SMAP data"); +#endif /* !PC98 */ void spinlock_enter(void) diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 1ea8f9572d6a..3b112aa168db 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -147,7 +147,7 @@ void *bootstacks[MAXCPU]; static void *dpcpu; struct pcb stoppcbs[MAXCPU]; -struct pcb **susppcbs = NULL; +struct susppcb **susppcbs; /* Variables needed for SMP tlb shootdown. */ vm_offset_t smp_tlb_addr1; @@ -745,25 +745,15 @@ init_secondary(void) /* set up CPU registers and state */ cpu_setregs(); + /* set up SSE/NX */ + initializecpu(); + /* set up FPU state on the AP */ npxinit(); - /* set up SSE registers */ - enable_sse(); - if (cpu_ops.cpu_init) cpu_ops.cpu_init(); -#ifdef PAE - /* Enable the PTE no-execute bit. */ - if ((amd_feature & AMDID_NX) != 0) { - uint64_t msr; - - msr = rdmsr(MSR_EFER) | EFER_NXE; - wrmsr(MSR_EFER, msr); - } -#endif - /* A quick check from sanity claus */ cpuid = PCPU_GET(cpuid); if (PCPU_GET(apic_id) != lapic_id()) { @@ -1521,13 +1511,14 @@ cpususpend_handler(void) mtx_assert(&smp_ipi_mtx, MA_NOTOWNED); cpu = PCPU_GET(cpuid); - if (savectx(susppcbs[cpu])) { - npxsuspend(&susppcbs[cpu]->pcb_fpususpend); + if (savectx(&susppcbs[cpu]->sp_pcb)) { + npxsuspend(&susppcbs[cpu]->sp_fpususpend); wbinvd(); CPU_SET_ATOMIC(cpu, &suspended_cpus); } else { - npxresume(&susppcbs[cpu]->pcb_fpususpend); + npxresume(&susppcbs[cpu]->sp_fpususpend); pmap_init_pat(); + initializecpu(); PCPU_SET(switchtime, 0); PCPU_SET(switchticks, ticks); diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 2859b84b4582..37e14e9d62cf 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -3161,7 +3161,8 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) pt_entry_t *pte; boolean_t anychanged, pv_lists_locked; - if ((prot & VM_PROT_READ) == VM_PROT_NONE) { + KASSERT((prot & ~VM_PROT_ALL) == 0, ("invalid prot %x", prot)); + if (prot == VM_PROT_NONE) { pmap_remove(pmap, sva, eva); return; } diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index c2c8c6c64ac0..950fa1f0556c 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -99,14 +99,9 @@ void doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault)); void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); void finishidentcpu(void); -#if defined(I586_CPU) && defined(CPU_WT_ALLOC) -void enable_K5_wt_alloc(void); -void enable_K6_wt_alloc(void); -void enable_K6_2_wt_alloc(void); -#endif -void enable_sse(void); void fillw(int /*u_short*/ pat, void *base, size_t cnt); void initializecpu(void); +void initializecpucache(void); void i686_pagezero(void *addr); void sse2_pagezero(void *addr); void init_AMD_Elan_sc520(void); @@ -114,6 +109,7 @@ int is_physical_memory(vm_paddr_t addr); int isa_nmi(int cd); vm_paddr_t kvtop(void *addr); void panicifcpuunsupported(void); +void ppro_reenable_apic(void); void printcpuinfo(void); void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec); int user_dbreg_trap(void); diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index a654ad3e6c39..01ace723e501 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -90,8 +90,11 @@ struct pcb { struct region_descriptor pcb_idt; uint16_t pcb_ldt; uint16_t pcb_tr; +}; - union savefpu pcb_fpususpend; +struct susppcb { + struct pcb sp_pcb; + union savefpu sp_fpususpend; }; #ifdef _KERNEL diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index 87d419f76dcc..27eff3255c15 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -54,6 +54,11 @@ MALLOC_DECLARE(M_LINUX); #define PTRIN(v) (void *)(v) #define PTROUT(v) (l_uintptr_t)(v) +#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0) +#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0) +#define PTRIN_CP(src,dst,fld) \ + do { (dst).fld = PTRIN((src).fld); } while (0) + /* * Provide a separate set of types for the Linux types. */ diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index 5d6972906336..d9c28d9483da 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -980,37 +980,6 @@ linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args return (0); } -/* copied from kern/kern_time.c */ -int -linux_timer_create(struct thread *td, struct linux_timer_create_args *args) -{ - return sys_ktimer_create(td, (struct ktimer_create_args *) args); -} - -int -linux_timer_settime(struct thread *td, struct linux_timer_settime_args *args) -{ - return sys_ktimer_settime(td, (struct ktimer_settime_args *) args); -} - -int -linux_timer_gettime(struct thread *td, struct linux_timer_gettime_args *args) -{ - return sys_ktimer_gettime(td, (struct ktimer_gettime_args *) args); -} - -int -linux_timer_getoverrun(struct thread *td, struct linux_timer_getoverrun_args *args) -{ - return sys_ktimer_getoverrun(td, (struct ktimer_getoverrun_args *) args); -} - -int -linux_timer_delete(struct thread *td, struct linux_timer_delete_args *args) -{ - return sys_ktimer_delete(td, (struct ktimer_delete_args *) args); -} - /* XXX: this wont work with module - convert it */ int linux_mq_open(struct thread *td, struct linux_mq_open_args *args) diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index 912c60dfb941..1f75c5f340e0 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/i386/linux/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/i386/linux/syscalls.master 271743 2014-09-18 08:36:45Z bz */ #ifndef _LINUX_SYSPROTO_H_ @@ -787,6 +787,7 @@ struct linux_timer_create_args { }; struct linux_timer_settime_args { char timerid_l_[PADL_(l_timer_t)]; l_timer_t timerid; char timerid_r_[PADR_(l_timer_t)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; char new_l_[PADL_(const struct itimerspec *)]; const struct itimerspec * new; char new_r_[PADR_(const struct itimerspec *)]; char old_l_[PADL_(struct itimerspec *)]; struct itimerspec * old; char old_r_[PADR_(struct itimerspec *)]; }; diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h index bb76143f1c58..7c2362c073c1 100644 --- a/sys/i386/linux/linux_syscall.h +++ b/sys/i386/linux/linux_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/i386/linux/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/i386/linux/syscalls.master 271743 2014-09-18 08:36:45Z bz */ #define LINUX_SYS_exit 1 diff --git a/sys/i386/linux/linux_syscalls.c b/sys/i386/linux/linux_syscalls.c index 38642f4ddb01..87601d8ac197 100644 --- a/sys/i386/linux/linux_syscalls.c +++ b/sys/i386/linux/linux_syscalls.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/i386/linux/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/i386/linux/syscalls.master 271743 2014-09-18 08:36:45Z bz */ const char *linux_syscallnames[] = { diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index 0d9168aad061..640c531f90c7 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/i386/linux/syscalls.master 255675 2013-09-18 18:48:33Z rdivacky + * created from FreeBSD: head/sys/i386/linux/syscalls.master 271743 2014-09-18 08:36:45Z bz */ #include diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c index dfdd43085f86..20bf94a03abf 100644 --- a/sys/i386/linux/linux_systrace_args.c +++ b/sys/i386/linux/linux_systrace_args.c @@ -1781,9 +1781,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 260: { struct linux_timer_settime_args *p = params; iarg[0] = p->timerid; /* l_timer_t */ - uarg[1] = (intptr_t) p->new; /* const struct itimerspec * */ - uarg[2] = (intptr_t) p->old; /* struct itimerspec * */ - *n_args = 3; + iarg[1] = p->flags; /* l_int */ + uarg[2] = (intptr_t) p->new; /* const struct itimerspec * */ + uarg[3] = (intptr_t) p->old; /* struct itimerspec * */ + *n_args = 4; break; } /* linux_timer_gettime */ @@ -5012,9 +5013,12 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) p = "l_timer_t"; break; case 1: - p = "const struct itimerspec *"; + p = "l_int"; break; case 2: + p = "const struct itimerspec *"; + break; + case 3: p = "struct itimerspec *"; break; default: diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index bb1716638639..0b119bf5620b 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -439,7 +439,7 @@ 258 AUE_NULL STD { int linux_set_tid_address(int *tidptr); } 259 AUE_NULL STD { int linux_timer_create(clockid_t clock_id, \ struct sigevent *evp, l_timer_t *timerid); } -260 AUE_NULL STD { int linux_timer_settime(l_timer_t timerid, \ +260 AUE_NULL STD { int linux_timer_settime(l_timer_t timerid, l_int flags, \ const struct itimerspec *new, struct itimerspec *old); } 261 AUE_NULL STD { int linux_timer_gettime(l_timer_t timerid, struct itimerspec *setting); } 262 AUE_NULL STD { int linux_timer_getoverrun(l_timer_t timerid); } diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 165b319bd6ae..3502151e3239 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -598,22 +598,13 @@ init_secondary(void) for (addr = 0; addr < NKPT * NBPDR - 1; addr += PAGE_SIZE) invlpg(addr); +#if 0 + /* set up SSE/NX */ + initializecpu(); +#endif + /* set up FPU state on the AP */ npxinit(); -#if 0 - - /* set up SSE registers */ - enable_sse(); -#endif -#if 0 && defined(PAE) - /* Enable the PTE no-execute bit. */ - if ((amd_feature & AMDID_NX) != 0) { - uint64_t msr; - - msr = rdmsr(MSR_EFER) | EFER_NXE; - wrmsr(MSR_EFER, msr); - } -#endif #if 0 /* A quick check from sanity claus */ if (PCPU_GET(apic_id) != lapic_id()) { diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index b0ad6110c6f7..ccc854c0f2d9 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -670,3 +670,25 @@ METHOD int remap_intr { device_t _child; u_int _irq; } DEFAULT null_remap_intr; + +/** + * @brief Suspend a given child + * + * @param _dev the parent device of @p _child + * @param _child the device to suspend + */ +METHOD int suspend_child { + device_t _dev; + device_t _child; +} DEFAULT bus_generic_suspend_child; + +/** + * @brief Resume a given child + * + * @param _dev the parent device of @p _child + * @param _child the device to resume + */ +METHOD int resume_child { + device_t _dev; + device_t _child; +} DEFAULT bus_generic_resume_child; diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index da157ecccfa9..a6ccf626803d 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -607,6 +607,7 @@ SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, cn_drvinit, NULL); #ifdef HAS_TIMER_SPKR static int beeping; +static struct callout beeping_timer; static void sysbeepstop(void *chan) @@ -629,11 +630,18 @@ sysbeep(int pitch, int period) timer_spkr_setfreq(pitch); if (!beeping) { beeping = period; - timeout(sysbeepstop, (void *)NULL, period); + callout_reset(&beeping_timer, period, sysbeepstop, NULL); } return (0); } +static void +sysbeep_init(void *unused) +{ + + callout_init(&beeping_timer, CALLOUT_MPSAFE); +} +SYSINIT(sysbeep, SI_SUB_SOFTINTR, SI_ORDER_ANY, sysbeep_init, NULL); #else /* diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index aca26efc50b5..341f998f9292 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -719,7 +719,7 @@ cpuset_setthread(lwpid_t id, cpuset_t *mask) * Apply new cpumask to the ithread. */ int -cpuset_setithread(lwpid_t id, u_char cpu) +cpuset_setithread(lwpid_t id, int cpu) { struct cpuset *nset, *rset; struct cpuset *parent, *old_set; @@ -731,6 +731,7 @@ cpuset_setithread(lwpid_t id, u_char cpu) nset = uma_zalloc(cpuset_zone, M_WAITOK); rset = uma_zalloc(cpuset_zone, M_WAITOK); + cs_id = CPUSET_INVALID; CPU_ZERO(&mask); if (cpu == NOCPU) @@ -739,13 +740,14 @@ cpuset_setithread(lwpid_t id, u_char cpu) CPU_SET(cpu, &mask); error = cpuset_which(CPU_WHICH_TID, id, &p, &td, &old_set); - if (((cs_id = alloc_unr(cpuset_unr)) == CPUSET_INVALID) || error != 0) + if (error != 0 || ((cs_id = alloc_unr(cpuset_unr)) == CPUSET_INVALID)) goto out; - thread_lock(td); + /* cpuset_which() returns with PROC_LOCK held. */ old_set = td->td_cpuset; if (cpu == NOCPU) { + /* * roll back to default set. We're not using cpuset_shadow() * here because we can fail CPU_SUBSET() check. This can happen @@ -759,7 +761,14 @@ cpuset_setithread(lwpid_t id, u_char cpu) if (old_set->cs_id == 1 || (old_set->cs_id == CPUSET_INVALID && old_set->cs_parent->cs_id == 1)) { - /* Default mask, we need to use new root set */ + + /* + * Current set is either default (1) or + * shadowed version of default set. + * + * Allocate new root set to be able to shadow it + * with any mask. + */ error = _cpuset_create(rset, cpuset_zero, &cpuset_zero->cs_mask, cs_id); if (error != 0) { @@ -772,18 +781,20 @@ cpuset_setithread(lwpid_t id, u_char cpu) cs_id = CPUSET_INVALID; } else { /* Assume existing set was already allocated by previous call */ - parent = td->td_cpuset; + parent = old_set; old_set = NULL; } error = cpuset_shadow(parent, nset, &mask); applyset: if (error == 0) { + thread_lock(td); td->td_cpuset = nset; sched_affinity(td); + thread_unlock(td); nset = NULL; - } - thread_unlock(td); + } else + old_set = NULL; PROC_UNLOCK(p); if (old_set != NULL) cpuset_rel(old_set); diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index ec750a09f1d7..5f6aa6fc0696 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -47,27 +47,21 @@ __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 @@ -79,10 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include -#include #include #include #ifdef KTRACE @@ -91,9 +82,6 @@ __FBSDID("$FreeBSD$"); #include -#include -#include - #include #include @@ -111,26 +99,23 @@ MALLOC_DECLARE(M_FADVISE); static uma_zone_t file_zone; -void (*ksem_info)(struct ksem *ks, char *path, size_t size, uint32_t *value); - static int closefp(struct filedesc *fdp, int fd, struct file *fp, struct thread *td, int holdleaders); +static int do_dup(struct thread *td, int flags, int old, int new, + register_t *retval); static int fd_first_free(struct filedesc *fdp, int low, int size); static int fd_last_used(struct filedesc *fdp, int size); static void fdgrowtable(struct filedesc *fdp, int nfd); static void fdgrowtable_exp(struct filedesc *fdp, int nfd); static void fdunused(struct filedesc *fdp, int fd); static void fdused(struct filedesc *fdp, int fd); -static int fill_pipe_info(struct pipe *pi, struct kinfo_file *kif); -static int fill_procdesc_info(struct procdesc *pdp, - struct kinfo_file *kif); -static int fill_pts_info(struct tty *tp, struct kinfo_file *kif); -static int fill_sem_info(struct file *fp, struct kinfo_file *kif); -static int fill_shm_info(struct file *fp, struct kinfo_file *kif); -static int fill_socket_info(struct socket *so, struct kinfo_file *kif); -static int fill_vnode_info(struct vnode *vp, struct kinfo_file *kif); static int getmaxfd(struct proc *p); +/* Flags for do_dup() */ +#define DUP_FIXED 0x1 /* Force fixed allocation. */ +#define DUP_FCNTL 0x2 /* fcntl()-style errors. */ +#define DUP_CLOEXEC 0x4 /* Atomically set FD_CLOEXEC. */ + /* * Each process has: * @@ -303,11 +288,18 @@ _fdfree(struct filedesc *fdp, int fd, int last) struct filedescent *fde; fde = &fdp->fd_ofiles[fd]; +#ifdef CAPABILITIES + if (!last) + seq_write_begin(&fde->fde_seq); +#endif filecaps_free(&fde->fde_caps); if (last) return; - bzero(fde, sizeof(*fde)); + bzero(fde_change(fde), fde_change_size); fdunused(fdp, fd); +#ifdef CAPABILITIES + seq_write_end(&fde->fde_seq); +#endif } static inline void @@ -399,23 +391,28 @@ struct fcntl_args { /* ARGSUSED */ int sys_fcntl(struct thread *td, struct fcntl_args *uap) +{ + + return (kern_fcntl_freebsd(td, uap->fd, uap->cmd, uap->arg)); +} + +int +kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg) { struct flock fl; struct __oflock ofl; - intptr_t arg; + intptr_t arg1; int error; - int cmd; error = 0; - cmd = uap->cmd; - switch (uap->cmd) { + switch (cmd) { case F_OGETLK: case F_OSETLK: case F_OSETLKW: /* * Convert old flock structure to new. */ - error = copyin((void *)(intptr_t)uap->arg, &ofl, sizeof(ofl)); + error = copyin((void *)(intptr_t)arg, &ofl, sizeof(ofl)); fl.l_start = ofl.l_start; fl.l_len = ofl.l_len; fl.l_pid = ofl.l_pid; @@ -423,7 +420,7 @@ sys_fcntl(struct thread *td, struct fcntl_args *uap) fl.l_whence = ofl.l_whence; fl.l_sysid = 0; - switch (uap->cmd) { + switch (cmd) { case F_OGETLK: cmd = F_GETLK; break; @@ -434,33 +431,33 @@ sys_fcntl(struct thread *td, struct fcntl_args *uap) cmd = F_SETLKW; break; } - arg = (intptr_t)&fl; + arg1 = (intptr_t)&fl; break; case F_GETLK: case F_SETLK: case F_SETLKW: case F_SETLK_REMOTE: - error = copyin((void *)(intptr_t)uap->arg, &fl, sizeof(fl)); - arg = (intptr_t)&fl; + error = copyin((void *)(intptr_t)arg, &fl, sizeof(fl)); + arg1 = (intptr_t)&fl; break; default: - arg = uap->arg; + arg1 = arg; break; } if (error) return (error); - error = kern_fcntl(td, uap->fd, cmd, arg); + error = kern_fcntl(td, fd, cmd, arg1); if (error) return (error); - if (uap->cmd == F_OGETLK) { + if (cmd == F_OGETLK) { ofl.l_start = fl.l_start; ofl.l_len = fl.l_len; ofl.l_pid = fl.l_pid; ofl.l_type = fl.l_type; ofl.l_whence = fl.l_whence; - error = copyout(&ofl, (void *)(intptr_t)uap->arg, sizeof(ofl)); - } else if (uap->cmd == F_GETLK) { - error = copyout(&fl, (void *)(intptr_t)uap->arg, sizeof(fl)); + error = copyout(&ofl, (void *)(intptr_t)arg, sizeof(ofl)); + } else if (cmd == F_GETLK) { + error = copyout(&fl, (void *)(intptr_t)arg, sizeof(fl)); } return (error); } @@ -509,7 +506,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) case F_GETFD: FILEDESC_SLOCK(fdp); - if ((fp = fget_locked(fdp, fd)) == NULL) { + if (fget_locked(fdp, fd) == NULL) { FILEDESC_SUNLOCK(fdp); error = EBADF; break; @@ -522,7 +519,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) case F_SETFD: FILEDESC_XLOCK(fdp); - if ((fp = fget_locked(fdp, fd)) == NULL) { + if (fget_locked(fdp, fd) == NULL) { FILEDESC_XUNLOCK(fdp); error = EBADF; break; @@ -802,7 +799,7 @@ getmaxfd(struct proc *p) /* * Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD). */ -int +static int do_dup(struct thread *td, int flags, int old, int new, register_t *retval) { @@ -893,13 +890,19 @@ do_dup(struct thread *td, int flags, int old, int new, /* * Duplicate the source descriptor. */ +#ifdef CAPABILITIES + seq_write_begin(&newfde->fde_seq); +#endif filecaps_free(&newfde->fde_caps); - *newfde = *oldfde; + memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size); filecaps_copy(&oldfde->fde_caps, &newfde->fde_caps); if ((flags & DUP_CLOEXEC) != 0) newfde->fde_flags = oldfde->fde_flags | UF_EXCLOSE; else newfde->fde_flags = oldfde->fde_flags & ~UF_EXCLOSE; +#ifdef CAPABILITIES + seq_write_end(&newfde->fde_seq); +#endif *retval = new; if (delfp != NULL) { @@ -1766,6 +1769,9 @@ finstall(struct thread *td, struct file *fp, int *fd, int flags, } fhold(fp); fde = &fdp->fd_ofiles[*fd]; +#ifdef CAPABILITIES + seq_write_begin(&fde->fde_seq); +#endif fde->fde_file = fp; if ((flags & O_CLOEXEC) != 0) fde->fde_flags |= UF_EXCLOSE; @@ -1773,6 +1779,9 @@ finstall(struct thread *td, struct file *fp, int *fd, int flags, filecaps_move(fcaps, &fde->fde_caps); else filecaps_fill(&fde->fde_caps); +#ifdef CAPABILITIES + seq_write_end(&fde->fde_seq); +#endif FILEDESC_XUNLOCK(fdp); return (0); } @@ -2304,6 +2313,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, struct file *fp; u_int count; #ifdef CAPABILITIES + seq_t seq; cap_rights_t haverights; int error; #endif @@ -2324,7 +2334,12 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, */ for (;;) { #ifdef CAPABILITIES + seq = seq_read(fd_seq(fdp, fd)); fde = fdp->fd_ofiles[fd]; + if (!seq_consistent(fd_seq(fdp, fd), seq)) { + cpu_spinwait(); + continue; + } fp = fde.fde_file; #else fp = fdp->fd_ofiles[fd].fde_file; @@ -2353,7 +2368,11 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, */ if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1) continue; +#ifdef CAPABILITIES + if (seq_consistent_nomb(fd_seq(fdp, fd), seq)) +#else if (fp == fdp->fd_ofiles[fd].fde_file) +#endif break; fdrop(fp, curthread); } @@ -2710,6 +2729,7 @@ int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, int openerror, int *indxp) { + struct filedescent *newfde, *oldfde; struct file *fp; int error, indx; @@ -2753,17 +2773,32 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, return (EACCES); } fhold(fp); - fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd]; - filecaps_copy(&fdp->fd_ofiles[dfd].fde_caps, - &fdp->fd_ofiles[indx].fde_caps); + newfde = &fdp->fd_ofiles[indx]; + oldfde = &fdp->fd_ofiles[dfd]; +#ifdef CAPABILITIES + seq_write_begin(&newfde->fde_seq); +#endif + memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size); + filecaps_copy(&oldfde->fde_caps, &newfde->fde_caps); +#ifdef CAPABILITIES + seq_write_end(&newfde->fde_seq); +#endif break; case ENXIO: /* * Steal away the file pointer from dfd and stuff it into indx. */ - fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd]; - bzero(&fdp->fd_ofiles[dfd], sizeof(fdp->fd_ofiles[dfd])); + newfde = &fdp->fd_ofiles[indx]; + oldfde = &fdp->fd_ofiles[dfd]; +#ifdef CAPABILITIES + seq_write_begin(&newfde->fde_seq); +#endif + memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size); + bzero(fde_change(oldfde), fde_change_size); fdunused(fdp, dfd); +#ifdef CAPABILITIES + seq_write_end(&newfde->fde_seq); +#endif break; } FILEDESC_XUNLOCK(fdp); @@ -2945,280 +2980,14 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_file, "S,xfile", "Entire file table"); -#ifdef KINFO_OFILE_SIZE -CTASSERT(sizeof(struct kinfo_ofile) == KINFO_OFILE_SIZE); -#endif - -#ifdef COMPAT_FREEBSD7 -static int -export_vnode_for_osysctl(struct vnode *vp, int type, - struct kinfo_ofile *kif, struct filedesc *fdp, struct sysctl_req *req) -{ - int error; - char *fullpath, *freepath; - - bzero(kif, sizeof(*kif)); - kif->kf_structsize = sizeof(*kif); - - vref(vp); - kif->kf_fd = type; - kif->kf_type = KF_TYPE_VNODE; - /* This function only handles directories. */ - if (vp->v_type != VDIR) { - vrele(vp); - return (ENOTDIR); - } - kif->kf_vnode_type = KF_VTYPE_VDIR; - - /* - * This is not a true file descriptor, so we set a bogus refcount - * and offset to indicate these fields should be ignored. - */ - kif->kf_ref_count = -1; - kif->kf_offset = -1; - - freepath = NULL; - fullpath = "-"; - FILEDESC_SUNLOCK(fdp); - vn_fullpath(curthread, vp, &fullpath, &freepath); - vrele(vp); - strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path)); - if (freepath != NULL) - free(freepath, M_TEMP); - error = SYSCTL_OUT(req, kif, sizeof(*kif)); - FILEDESC_SLOCK(fdp); - return (error); -} - -/* - * Get per-process file descriptors for use by procstat(1), et al. - */ -static int -sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) -{ - char *fullpath, *freepath; - struct kinfo_ofile *kif; - struct filedesc *fdp; - int error, i, *name; - struct shmfd *shmfd; - struct socket *so; - struct vnode *vp; - struct ksem *ks; - struct file *fp; - struct proc *p; - struct tty *tp; - - name = (int *)arg1; - error = pget((pid_t)name[0], PGET_CANDEBUG | PGET_NOTWEXIT, &p); - if (error != 0) - return (error); - fdp = fdhold(p); - PROC_UNLOCK(p); - if (fdp == NULL) - return (ENOENT); - kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK); - FILEDESC_SLOCK(fdp); - if (fdp->fd_cdir != NULL) - export_vnode_for_osysctl(fdp->fd_cdir, KF_FD_TYPE_CWD, kif, - fdp, req); - if (fdp->fd_rdir != NULL) - export_vnode_for_osysctl(fdp->fd_rdir, KF_FD_TYPE_ROOT, kif, - fdp, req); - if (fdp->fd_jdir != NULL) - export_vnode_for_osysctl(fdp->fd_jdir, KF_FD_TYPE_JAIL, kif, - fdp, req); - for (i = 0; fdp->fd_refcnt > 0 && i <= fdp->fd_lastfile; i++) { - if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) - continue; - bzero(kif, sizeof(*kif)); - kif->kf_structsize = sizeof(*kif); - ks = NULL; - vp = NULL; - so = NULL; - tp = NULL; - shmfd = NULL; - kif->kf_fd = i; - - switch (fp->f_type) { - case DTYPE_VNODE: - kif->kf_type = KF_TYPE_VNODE; - vp = fp->f_vnode; - break; - - case DTYPE_SOCKET: - kif->kf_type = KF_TYPE_SOCKET; - so = fp->f_data; - break; - - case DTYPE_PIPE: - kif->kf_type = KF_TYPE_PIPE; - break; - - case DTYPE_FIFO: - kif->kf_type = KF_TYPE_FIFO; - vp = fp->f_vnode; - break; - - case DTYPE_KQUEUE: - kif->kf_type = KF_TYPE_KQUEUE; - break; - - case DTYPE_CRYPTO: - kif->kf_type = KF_TYPE_CRYPTO; - break; - - case DTYPE_MQUEUE: - kif->kf_type = KF_TYPE_MQUEUE; - break; - - case DTYPE_SHM: - kif->kf_type = KF_TYPE_SHM; - shmfd = fp->f_data; - break; - - case DTYPE_SEM: - kif->kf_type = KF_TYPE_SEM; - ks = fp->f_data; - break; - - case DTYPE_PTS: - kif->kf_type = KF_TYPE_PTS; - tp = fp->f_data; - break; - - case DTYPE_PROCDESC: - kif->kf_type = KF_TYPE_PROCDESC; - break; - - default: - kif->kf_type = KF_TYPE_UNKNOWN; - break; - } - kif->kf_ref_count = fp->f_count; - if (fp->f_flag & FREAD) - kif->kf_flags |= KF_FLAG_READ; - if (fp->f_flag & FWRITE) - kif->kf_flags |= KF_FLAG_WRITE; - if (fp->f_flag & FAPPEND) - kif->kf_flags |= KF_FLAG_APPEND; - if (fp->f_flag & FASYNC) - kif->kf_flags |= KF_FLAG_ASYNC; - if (fp->f_flag & FFSYNC) - kif->kf_flags |= KF_FLAG_FSYNC; - if (fp->f_flag & FNONBLOCK) - kif->kf_flags |= KF_FLAG_NONBLOCK; - if (fp->f_flag & O_DIRECT) - kif->kf_flags |= KF_FLAG_DIRECT; - if (fp->f_flag & FHASLOCK) - kif->kf_flags |= KF_FLAG_HASLOCK; - kif->kf_offset = foffset_get(fp); - if (vp != NULL) { - vref(vp); - switch (vp->v_type) { - case VNON: - kif->kf_vnode_type = KF_VTYPE_VNON; - break; - case VREG: - kif->kf_vnode_type = KF_VTYPE_VREG; - break; - case VDIR: - kif->kf_vnode_type = KF_VTYPE_VDIR; - break; - case VBLK: - kif->kf_vnode_type = KF_VTYPE_VBLK; - break; - case VCHR: - kif->kf_vnode_type = KF_VTYPE_VCHR; - break; - case VLNK: - kif->kf_vnode_type = KF_VTYPE_VLNK; - break; - case VSOCK: - kif->kf_vnode_type = KF_VTYPE_VSOCK; - break; - case VFIFO: - kif->kf_vnode_type = KF_VTYPE_VFIFO; - break; - case VBAD: - kif->kf_vnode_type = KF_VTYPE_VBAD; - break; - default: - kif->kf_vnode_type = KF_VTYPE_UNKNOWN; - break; - } - /* - * It is OK to drop the filedesc lock here as we will - * re-validate and re-evaluate its properties when - * the loop continues. - */ - freepath = NULL; - fullpath = "-"; - FILEDESC_SUNLOCK(fdp); - vn_fullpath(curthread, vp, &fullpath, &freepath); - vrele(vp); - strlcpy(kif->kf_path, fullpath, - sizeof(kif->kf_path)); - if (freepath != NULL) - free(freepath, M_TEMP); - FILEDESC_SLOCK(fdp); - } - if (so != NULL) { - struct sockaddr *sa; - - if (so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa) - == 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) { - bcopy(sa, &kif->kf_sa_local, sa->sa_len); - free(sa, M_SONAME); - } - if (so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa) - == 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) { - bcopy(sa, &kif->kf_sa_peer, sa->sa_len); - free(sa, M_SONAME); - } - kif->kf_sock_domain = - so->so_proto->pr_domain->dom_family; - kif->kf_sock_type = so->so_type; - kif->kf_sock_protocol = so->so_proto->pr_protocol; - } - if (tp != NULL) { - strlcpy(kif->kf_path, tty_devname(tp), - sizeof(kif->kf_path)); - } - if (shmfd != NULL) - shm_path(shmfd, kif->kf_path, sizeof(kif->kf_path)); - if (ks != NULL && ksem_info != NULL) - ksem_info(ks, kif->kf_path, sizeof(kif->kf_path), NULL); - error = SYSCTL_OUT(req, kif, sizeof(*kif)); - if (error) - break; - } - FILEDESC_SUNLOCK(fdp); - fddrop(fdp); - free(kif, M_TEMP); - return (0); -} - -static SYSCTL_NODE(_kern_proc, KERN_PROC_OFILEDESC, ofiledesc, - CTLFLAG_RD||CTLFLAG_MPSAFE, sysctl_kern_proc_ofiledesc, - "Process ofiledesc entries"); -#endif /* COMPAT_FREEBSD7 */ - #ifdef KINFO_FILE_SIZE CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE); #endif -struct export_fd_buf { - struct filedesc *fdp; - struct sbuf *sb; - ssize_t remainder; - struct kinfo_file kif; -}; - static int -export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt, - int64_t offset, cap_rights_t *rightsp, struct export_fd_buf *efbuf) +xlate_fflags(int fflags) { - struct { + static const struct { int fflag; int kf_fflag; } fflags_table[] = { @@ -3238,83 +3007,126 @@ export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt, { O_SHLOCK, KF_FLAG_SHLOCK }, { O_TRUNC, KF_FLAG_TRUNC } }; -#define NFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table)) - struct kinfo_file *kif; - struct vnode *vp; - int error, locked; unsigned int i; + int kflags; - if (efbuf->remainder == 0) - return (0); - kif = &efbuf->kif; - bzero(kif, sizeof(*kif)); - locked = efbuf->fdp != NULL; - switch (type) { - case KF_TYPE_FIFO: - case KF_TYPE_VNODE: - if (locked) { - FILEDESC_SUNLOCK(efbuf->fdp); - locked = 0; - } - vp = (struct vnode *)data; - error = fill_vnode_info(vp, kif); - vrele(vp); - break; - case KF_TYPE_SOCKET: - error = fill_socket_info((struct socket *)data, kif); - break; - case KF_TYPE_PIPE: - error = fill_pipe_info((struct pipe *)data, kif); - break; - case KF_TYPE_PTS: - error = fill_pts_info((struct tty *)data, kif); - break; - case KF_TYPE_PROCDESC: - error = fill_procdesc_info((struct procdesc *)data, kif); - break; - case KF_TYPE_SEM: - error = fill_sem_info((struct file *)data, kif); - break; - case KF_TYPE_SHM: - error = fill_shm_info((struct file *)data, kif); - break; - default: - error = 0; - } - if (error == 0) - kif->kf_status |= KF_ATTR_VALID; - - /* - * Translate file access flags. - */ - for (i = 0; i < NFFLAGS; i++) + kflags = 0; + for (i = 0; i < nitems(fflags_table); i++) if (fflags & fflags_table[i].fflag) - kif->kf_flags |= fflags_table[i].kf_fflag; + kflags |= fflags_table[i].kf_fflag; + return (kflags); +} + +/* Trim unused data from kf_path by truncating the structure size. */ +static void +pack_kinfo(struct kinfo_file *kif) +{ + + kif->kf_structsize = offsetof(struct kinfo_file, kf_path) + + strlen(kif->kf_path) + 1; + kif->kf_structsize = roundup(kif->kf_structsize, sizeof(uint64_t)); +} + +static void +export_file_to_kinfo(struct file *fp, int fd, cap_rights_t *rightsp, + struct kinfo_file *kif, struct filedesc *fdp) +{ + int error; + + bzero(kif, sizeof(*kif)); + + /* Set a default type to allow for empty fill_kinfo() methods. */ + kif->kf_type = KF_TYPE_UNKNOWN; + kif->kf_flags = xlate_fflags(fp->f_flag); if (rightsp != NULL) kif->kf_cap_rights = *rightsp; else cap_rights_init(&kif->kf_cap_rights); kif->kf_fd = fd; - kif->kf_type = type; - kif->kf_ref_count = refcnt; - kif->kf_offset = offset; - /* Pack record size down */ - kif->kf_structsize = offsetof(struct kinfo_file, kf_path) + - strlen(kif->kf_path) + 1; - kif->kf_structsize = roundup(kif->kf_structsize, sizeof(uint64_t)); + kif->kf_ref_count = fp->f_count; + kif->kf_offset = foffset_get(fp); + + /* + * This may drop the filedesc lock, so the 'fp' cannot be + * accessed after this call. + */ + error = fo_fill_kinfo(fp, kif, fdp); + if (error == 0) + kif->kf_status |= KF_ATTR_VALID; + pack_kinfo(kif); +} + +static void +export_vnode_to_kinfo(struct vnode *vp, int fd, int fflags, + struct kinfo_file *kif) +{ + int error; + + bzero(kif, sizeof(*kif)); + + kif->kf_type = KF_TYPE_VNODE; + error = vn_fill_kinfo_vnode(vp, kif); + if (error == 0) + kif->kf_status |= KF_ATTR_VALID; + kif->kf_flags = xlate_fflags(fflags); + kif->kf_fd = fd; + kif->kf_ref_count = -1; + kif->kf_offset = -1; + pack_kinfo(kif); + vrele(vp); +} + +struct export_fd_buf { + struct filedesc *fdp; + struct sbuf *sb; + ssize_t remainder; + struct kinfo_file kif; +}; + +static int +export_kinfo_to_sb(struct export_fd_buf *efbuf) +{ + struct kinfo_file *kif; + + kif = &efbuf->kif; if (efbuf->remainder != -1) { if (efbuf->remainder < kif->kf_structsize) { /* Terminate export. */ efbuf->remainder = 0; - if (efbuf->fdp != NULL && !locked) - FILEDESC_SLOCK(efbuf->fdp); return (0); } efbuf->remainder -= kif->kf_structsize; } - if (locked) + return (sbuf_bcat(efbuf->sb, kif, kif->kf_structsize)); +} + +static int +export_file_to_sb(struct file *fp, int fd, cap_rights_t *rightsp, + struct export_fd_buf *efbuf) +{ + int error; + + if (efbuf->remainder == 0) + return (0); + export_file_to_kinfo(fp, fd, rightsp, &efbuf->kif, efbuf->fdp); + FILEDESC_SUNLOCK(efbuf->fdp); + error = export_kinfo_to_sb(efbuf); + FILEDESC_SLOCK(efbuf->fdp); + return (error); +} + +static int +export_vnode_to_sb(struct vnode *vp, int fd, int fflags, + struct export_fd_buf *efbuf) +{ + int error; + + if (efbuf->remainder == 0) + return (0); + if (efbuf->fdp != NULL) FILEDESC_SUNLOCK(efbuf->fdp); - error = sbuf_bcat(efbuf->sb, kif, kif->kf_structsize); + export_vnode_to_kinfo(vp, fd, fflags, &efbuf->kif); + error = export_kinfo_to_sb(efbuf); if (efbuf->fdp != NULL) FILEDESC_SLOCK(efbuf->fdp); return (error); @@ -3328,16 +3140,15 @@ export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt, int kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen) { + struct thread *td; struct file *fp; struct filedesc *fdp; struct export_fd_buf *efbuf; struct vnode *cttyvp, *textvp, *tracevp; - int64_t offset; - void *data; int error, i; - int type, refcnt, fflags; cap_rights_t rights; + td = curthread; PROC_LOCK_ASSERT(p, MA_OWNED); /* ktrace vnode */ @@ -3362,14 +3173,13 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen) efbuf->sb = sb; efbuf->remainder = maxlen; if (tracevp != NULL) - export_fd_to_sb(tracevp, KF_TYPE_VNODE, KF_FD_TYPE_TRACE, - FREAD | FWRITE, -1, -1, NULL, efbuf); + export_vnode_to_sb(tracevp, KF_FD_TYPE_TRACE, FREAD | FWRITE, + efbuf); if (textvp != NULL) - export_fd_to_sb(textvp, KF_TYPE_VNODE, KF_FD_TYPE_TEXT, - FREAD, -1, -1, NULL, efbuf); + export_vnode_to_sb(textvp, KF_FD_TYPE_TEXT, FREAD, efbuf); if (cttyvp != NULL) - export_fd_to_sb(cttyvp, KF_TYPE_VNODE, KF_FD_TYPE_CTTY, - FREAD | FWRITE, -1, -1, NULL, efbuf); + export_vnode_to_sb(cttyvp, KF_FD_TYPE_CTTY, FREAD | FWRITE, + efbuf); error = 0; if (fdp == NULL) goto fail; @@ -3378,105 +3188,34 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen) /* working directory */ if (fdp->fd_cdir != NULL) { vref(fdp->fd_cdir); - data = fdp->fd_cdir; - export_fd_to_sb(data, KF_TYPE_VNODE, KF_FD_TYPE_CWD, - FREAD, -1, -1, NULL, efbuf); + export_vnode_to_sb(fdp->fd_cdir, KF_FD_TYPE_CWD, FREAD, efbuf); } /* root directory */ if (fdp->fd_rdir != NULL) { vref(fdp->fd_rdir); - data = fdp->fd_rdir; - export_fd_to_sb(data, KF_TYPE_VNODE, KF_FD_TYPE_ROOT, - FREAD, -1, -1, NULL, efbuf); + export_vnode_to_sb(fdp->fd_rdir, KF_FD_TYPE_ROOT, FREAD, efbuf); } /* jail directory */ if (fdp->fd_jdir != NULL) { vref(fdp->fd_jdir); - data = fdp->fd_jdir; - export_fd_to_sb(data, KF_TYPE_VNODE, KF_FD_TYPE_JAIL, - FREAD, -1, -1, NULL, efbuf); + export_vnode_to_sb(fdp->fd_jdir, KF_FD_TYPE_JAIL, FREAD, efbuf); } for (i = 0; fdp->fd_refcnt > 0 && i <= fdp->fd_lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; - data = NULL; #ifdef CAPABILITIES rights = *cap_rights(fdp, i); #else /* !CAPABILITIES */ cap_rights_init(&rights); #endif - switch (fp->f_type) { - case DTYPE_VNODE: - type = KF_TYPE_VNODE; - vref(fp->f_vnode); - data = fp->f_vnode; - break; - - case DTYPE_SOCKET: - type = KF_TYPE_SOCKET; - data = fp->f_data; - break; - - case DTYPE_PIPE: - type = KF_TYPE_PIPE; - data = fp->f_data; - break; - - case DTYPE_FIFO: - type = KF_TYPE_FIFO; - vref(fp->f_vnode); - data = fp->f_vnode; - break; - - case DTYPE_KQUEUE: - type = KF_TYPE_KQUEUE; - break; - - case DTYPE_CRYPTO: - type = KF_TYPE_CRYPTO; - break; - - case DTYPE_MQUEUE: - type = KF_TYPE_MQUEUE; - break; - - case DTYPE_SHM: - type = KF_TYPE_SHM; - data = fp; - break; - - case DTYPE_SEM: - type = KF_TYPE_SEM; - data = fp; - break; - - case DTYPE_PTS: - type = KF_TYPE_PTS; - data = fp->f_data; - break; - - case DTYPE_PROCDESC: - type = KF_TYPE_PROCDESC; - data = fp->f_data; - break; - - default: - type = KF_TYPE_UNKNOWN; - break; - } - refcnt = fp->f_count; - fflags = fp->f_flag; - offset = foffset_get(fp); - /* - * Create sysctl entry. - * It is OK to drop the filedesc lock here as we will - * re-validate and re-evaluate its properties when - * the loop continues. + * Create sysctl entry. It is OK to drop the filedesc + * lock inside of export_file_to_sb() as we will + * re-validate and re-evaluate its properties when the + * loop continues. */ - error = export_fd_to_sb(data, type, i, fflags, refcnt, - offset, &rights, efbuf); - if (error != 0) + error = export_file_to_sb(fp, i, &rights, efbuf); + if (error != 0 || efbuf->remainder == 0) break; } FILEDESC_SUNLOCK(fdp); @@ -3514,6 +3253,105 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER_ARGS) return (error != 0 ? error : error2); } +#ifdef KINFO_OFILE_SIZE +CTASSERT(sizeof(struct kinfo_ofile) == KINFO_OFILE_SIZE); +#endif + +#ifdef COMPAT_FREEBSD7 +static void +kinfo_to_okinfo(struct kinfo_file *kif, struct kinfo_ofile *okif) +{ + + okif->kf_structsize = sizeof(*okif); + okif->kf_type = kif->kf_type; + okif->kf_fd = kif->kf_fd; + okif->kf_ref_count = kif->kf_ref_count; + okif->kf_flags = kif->kf_flags & (KF_FLAG_READ | KF_FLAG_WRITE | + KF_FLAG_APPEND | KF_FLAG_ASYNC | KF_FLAG_FSYNC | KF_FLAG_NONBLOCK | + KF_FLAG_DIRECT | KF_FLAG_HASLOCK); + okif->kf_offset = kif->kf_offset; + okif->kf_vnode_type = kif->kf_vnode_type; + okif->kf_sock_domain = kif->kf_sock_domain; + okif->kf_sock_type = kif->kf_sock_type; + okif->kf_sock_protocol = kif->kf_sock_protocol; + strlcpy(okif->kf_path, kif->kf_path, sizeof(okif->kf_path)); + okif->kf_sa_local = kif->kf_sa_local; + okif->kf_sa_peer = kif->kf_sa_peer; +} + +static int +export_vnode_for_osysctl(struct vnode *vp, int type, struct kinfo_file *kif, + struct kinfo_ofile *okif, struct filedesc *fdp, struct sysctl_req *req) +{ + int error; + + vref(vp); + FILEDESC_SUNLOCK(fdp); + export_vnode_to_kinfo(vp, type, 0, kif); + kinfo_to_okinfo(kif, okif); + error = SYSCTL_OUT(req, okif, sizeof(*okif)); + FILEDESC_SLOCK(fdp); + return (error); +} + +/* + * Get per-process file descriptors for use by procstat(1), et al. + */ +static int +sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) +{ + struct kinfo_ofile *okif; + struct kinfo_file *kif; + struct filedesc *fdp; + struct thread *td; + int error, i, *name; + struct file *fp; + struct proc *p; + + td = curthread; + name = (int *)arg1; + error = pget((pid_t)name[0], PGET_CANDEBUG | PGET_NOTWEXIT, &p); + if (error != 0) + return (error); + fdp = fdhold(p); + PROC_UNLOCK(p); + if (fdp == NULL) + return (ENOENT); + kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK); + okif = malloc(sizeof(*okif), M_TEMP, M_WAITOK); + FILEDESC_SLOCK(fdp); + if (fdp->fd_cdir != NULL) + export_vnode_for_osysctl(fdp->fd_cdir, KF_FD_TYPE_CWD, kif, + okif, fdp, req); + if (fdp->fd_rdir != NULL) + export_vnode_for_osysctl(fdp->fd_rdir, KF_FD_TYPE_ROOT, kif, + okif, fdp, req); + if (fdp->fd_jdir != NULL) + export_vnode_for_osysctl(fdp->fd_jdir, KF_FD_TYPE_JAIL, kif, + okif, fdp, req); + for (i = 0; fdp->fd_refcnt > 0 && i <= fdp->fd_lastfile; i++) { + if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) + continue; + export_file_to_kinfo(fp, i, NULL, kif, fdp); + FILEDESC_SUNLOCK(fdp); + kinfo_to_okinfo(kif, okif); + error = SYSCTL_OUT(req, okif, sizeof(*okif)); + FILEDESC_SLOCK(fdp); + if (error) + break; + } + FILEDESC_SUNLOCK(fdp); + fddrop(fdp); + free(kif, M_TEMP); + free(okif, M_TEMP); + return (0); +} + +static SYSCTL_NODE(_kern_proc, KERN_PROC_OFILEDESC, ofiledesc, + CTLFLAG_RD||CTLFLAG_MPSAFE, sysctl_kern_proc_ofiledesc, + "Process ofiledesc entries"); +#endif /* COMPAT_FREEBSD7 */ + int vntype_to_kinfo(int vtype) { @@ -3531,185 +3369,18 @@ vntype_to_kinfo(int vtype) { VREG, KF_VTYPE_VREG }, { VSOCK, KF_VTYPE_VSOCK } }; -#define NVTYPES (sizeof(vtypes_table) / sizeof(*vtypes_table)) unsigned int i; /* * Perform vtype translation. */ - for (i = 0; i < NVTYPES; i++) + for (i = 0; i < nitems(vtypes_table); i++) if (vtypes_table[i].vtype == vtype) - break; - if (i < NVTYPES) - return (vtypes_table[i].kf_vtype); + return (vtypes_table[i].kf_vtype); return (KF_VTYPE_UNKNOWN); } -static int -fill_vnode_info(struct vnode *vp, struct kinfo_file *kif) -{ - struct vattr va; - char *fullpath, *freepath; - int error; - - if (vp == NULL) - return (1); - kif->kf_vnode_type = vntype_to_kinfo(vp->v_type); - freepath = NULL; - fullpath = "-"; - error = vn_fullpath(curthread, vp, &fullpath, &freepath); - if (error == 0) { - strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path)); - } - if (freepath != NULL) - free(freepath, M_TEMP); - - /* - * Retrieve vnode attributes. - */ - va.va_fsid = VNOVAL; - va.va_rdev = NODEV; - vn_lock(vp, LK_SHARED | LK_RETRY); - error = VOP_GETATTR(vp, &va, curthread->td_ucred); - VOP_UNLOCK(vp, 0); - if (error != 0) - return (error); - if (va.va_fsid != VNOVAL) - kif->kf_un.kf_file.kf_file_fsid = va.va_fsid; - else - kif->kf_un.kf_file.kf_file_fsid = - vp->v_mount->mnt_stat.f_fsid.val[0]; - kif->kf_un.kf_file.kf_file_fileid = va.va_fileid; - kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode); - kif->kf_un.kf_file.kf_file_size = va.va_size; - kif->kf_un.kf_file.kf_file_rdev = va.va_rdev; - return (0); -} - -static int -fill_socket_info(struct socket *so, struct kinfo_file *kif) -{ - struct sockaddr *sa; - struct inpcb *inpcb; - struct unpcb *unpcb; - int error; - - if (so == NULL) - return (1); - kif->kf_sock_domain = so->so_proto->pr_domain->dom_family; - kif->kf_sock_type = so->so_type; - kif->kf_sock_protocol = so->so_proto->pr_protocol; - kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; - switch(kif->kf_sock_domain) { - case AF_INET: - case AF_INET6: - if (kif->kf_sock_protocol == IPPROTO_TCP) { - if (so->so_pcb != NULL) { - inpcb = (struct inpcb *)(so->so_pcb); - kif->kf_un.kf_sock.kf_sock_inpcb = - (uintptr_t)inpcb->inp_ppcb; - } - } - break; - case AF_UNIX: - if (so->so_pcb != NULL) { - unpcb = (struct unpcb *)(so->so_pcb); - if (unpcb->unp_conn) { - kif->kf_un.kf_sock.kf_sock_unpconn = - (uintptr_t)unpcb->unp_conn; - kif->kf_un.kf_sock.kf_sock_rcv_sb_state = - so->so_rcv.sb_state; - kif->kf_un.kf_sock.kf_sock_snd_sb_state = - so->so_snd.sb_state; - } - } - break; - } - error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); - if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) { - bcopy(sa, &kif->kf_sa_local, sa->sa_len); - free(sa, M_SONAME); - } - error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); - if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) { - bcopy(sa, &kif->kf_sa_peer, sa->sa_len); - free(sa, M_SONAME); - } - strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, - sizeof(kif->kf_path)); - return (0); -} - -static int -fill_pts_info(struct tty *tp, struct kinfo_file *kif) -{ - - if (tp == NULL) - return (1); - kif->kf_un.kf_pts.kf_pts_dev = tty_udev(tp); - strlcpy(kif->kf_path, tty_devname(tp), sizeof(kif->kf_path)); - return (0); -} - -static int -fill_pipe_info(struct pipe *pi, struct kinfo_file *kif) -{ - - if (pi == NULL) - return (1); - kif->kf_un.kf_pipe.kf_pipe_addr = (uintptr_t)pi; - kif->kf_un.kf_pipe.kf_pipe_peer = (uintptr_t)pi->pipe_peer; - kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt; - return (0); -} - -static int -fill_procdesc_info(struct procdesc *pdp, struct kinfo_file *kif) -{ - - if (pdp == NULL) - return (1); - kif->kf_un.kf_proc.kf_pid = pdp->pd_pid; - return (0); -} - -static int -fill_sem_info(struct file *fp, struct kinfo_file *kif) -{ - struct thread *td; - struct stat sb; - - td = curthread; - if (fp->f_data == NULL) - return (1); - if (fo_stat(fp, &sb, td->td_ucred, td) != 0) - return (1); - if (ksem_info == NULL) - return (1); - ksem_info(fp->f_data, kif->kf_path, sizeof(kif->kf_path), - &kif->kf_un.kf_sem.kf_sem_value); - kif->kf_un.kf_sem.kf_sem_mode = sb.st_mode; - return (0); -} - -static int -fill_shm_info(struct file *fp, struct kinfo_file *kif) -{ - struct thread *td; - struct stat sb; - - td = curthread; - if (fp->f_data == NULL) - return (1); - if (fo_stat(fp, &sb, td->td_ucred, td) != 0) - return (1); - shm_path(fp->f_data, kif->kf_path, sizeof(kif->kf_path)); - kif->kf_un.kf_file.kf_file_mode = sb.st_mode; - kif->kf_un.kf_file.kf_file_size = sb.st_size; - return (0); -} - static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_filedesc, "Process filedesc entries"); @@ -3929,6 +3600,13 @@ badfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, return (EBADF); } +static int +badfo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + + return (0); +} + struct fileops badfileops = { .fo_read = badfo_readwrite, .fo_write = badfo_readwrite, @@ -3941,8 +3619,17 @@ struct fileops badfileops = { .fo_chmod = badfo_chmod, .fo_chown = badfo_chown, .fo_sendfile = badfo_sendfile, + .fo_fill_kinfo = badfo_fill_kinfo, }; +int +invfo_rdwr(struct file *fp, struct uio *uio, struct ucred *active_cred, + int flags, struct thread *td) +{ + + return (EOPNOTSUPP); +} + int invfo_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td) @@ -3951,6 +3638,29 @@ invfo_truncate(struct file *fp, off_t length, struct ucred *active_cred, return (EINVAL); } +int +invfo_ioctl(struct file *fp, u_long com, void *data, + struct ucred *active_cred, struct thread *td) +{ + + return (ENOTTY); +} + +int +invfo_poll(struct file *fp, int events, struct ucred *active_cred, + struct thread *td) +{ + + return (poll_no_poll(events)); +} + +int +invfo_kqfilter(struct file *fp, struct knote *kn) +{ + + return (EINVAL); +} + int invfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index fc256f120525..7488652c20de 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef KTRACE #include #endif @@ -109,19 +110,17 @@ static void kqueue_wakeup(struct kqueue *kq); static struct filterops *kqueue_fo_find(int filt); static void kqueue_fo_release(int filt); -static fo_rdwr_t kqueue_read; -static fo_rdwr_t kqueue_write; -static fo_truncate_t kqueue_truncate; static fo_ioctl_t kqueue_ioctl; static fo_poll_t kqueue_poll; static fo_kqfilter_t kqueue_kqfilter; static fo_stat_t kqueue_stat; static fo_close_t kqueue_close; +static fo_fill_kinfo_t kqueue_fill_kinfo; static struct fileops kqueueops = { - .fo_read = kqueue_read, - .fo_write = kqueue_write, - .fo_truncate = kqueue_truncate, + .fo_read = invfo_rdwr, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, .fo_ioctl = kqueue_ioctl, .fo_poll = kqueue_poll, .fo_kqfilter = kqueue_kqfilter, @@ -130,6 +129,7 @@ static struct fileops kqueueops = { .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = kqueue_fill_kinfo, }; static int knote_attach(struct knote *kn, struct kqueue *kq); @@ -1602,35 +1602,6 @@ kqueue_scan(struct kqueue *kq, int maxevents, struct kevent_copyops *k_ops, return (error); } -/* - * XXX - * This could be expanded to call kqueue_scan, if desired. - */ -/*ARGSUSED*/ -static int -kqueue_read(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - return (ENXIO); -} - -/*ARGSUSED*/ -static int -kqueue_write(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - return (ENXIO); -} - -/*ARGSUSED*/ -static int -kqueue_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td) -{ - - return (EINVAL); -} - /*ARGSUSED*/ static int kqueue_ioctl(struct file *fp, u_long cmd, void *data, @@ -1834,6 +1805,14 @@ kqueue_close(struct file *fp, struct thread *td) return (0); } +static int +kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + + kif->kf_type = KF_TYPE_KQUEUE; + return (0); +} + static void kqueue_wakeup(struct kqueue *kq) { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 8ef082162d95..fd1e21483e41 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -379,29 +379,10 @@ do_execve(td, args, mac_p) /* * Initialize part of the common data */ + bzero(imgp, sizeof(*imgp)); imgp->proc = p; - imgp->execlabel = NULL; imgp->attr = &attr; - imgp->entry_addr = 0; - imgp->reloc_base = 0; - imgp->vmspace_destroyed = 0; - imgp->interpreted = 0; - imgp->opened = 0; - imgp->interpreter_name = NULL; - imgp->auxargs = NULL; - imgp->vp = NULL; - imgp->object = NULL; - imgp->firstpage = NULL; - imgp->ps_strings = 0; - imgp->auxarg_size = 0; imgp->args = args; - imgp->execpath = imgp->freepath = NULL; - imgp->execpathp = 0; - imgp->canary = 0; - imgp->canarylen = 0; - imgp->pagesizes = 0; - imgp->pagesizeslen = 0; - imgp->stack_prot = 0; #ifdef MAC error = mac_execve_enter(imgp, mac_p); @@ -409,8 +390,6 @@ do_execve(td, args, mac_p) goto exec_fail; #endif - imgp->image_header = NULL; - /* * Translate the file name. namei() returns a vnode pointer * in ni_vp amoung other things. diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 25032f278c1d..6e9a4e8e48d2 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -249,7 +249,7 @@ intr_event_update(struct intr_event *ie) int intr_event_create(struct intr_event **event, void *source, int flags, int irq, void (*pre_ithread)(void *), void (*post_ithread)(void *), - void (*post_filter)(void *), int (*assign_cpu)(void *, u_char), + void (*post_filter)(void *), int (*assign_cpu)(void *, int), const char *fmt, ...) { struct intr_event *ie; @@ -292,7 +292,7 @@ intr_event_create(struct intr_event **event, void *source, int flags, int irq, * the interrupt event. */ int -intr_event_bind(struct intr_event *ie, u_char cpu) +intr_event_bind(struct intr_event *ie, int cpu) { lwpid_t id; int error; @@ -1078,7 +1078,7 @@ intr_event_schedule_thread(struct intr_event *ie, struct intr_thread *it) * a PIC. */ static int -swi_assign_cpu(void *arg, u_char cpu) +swi_assign_cpu(void *arg, int cpu) { return (0); diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 47cd5687c653..f8ae0e6bfb00 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1812,9 +1812,11 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) #ifdef RACCT if (!created) { - sx_sunlock(&allprison_lock); + if (!(flags & JAIL_ATTACH)) + sx_sunlock(&allprison_lock); prison_racct_modify(pr); - sx_slock(&allprison_lock); + if (!(flags & JAIL_ATTACH)) + sx_slock(&allprison_lock); } #endif diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index c39f14359bf9..9e29030fb6f0 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -717,6 +717,8 @@ kmeminit(void) * a given architecture. */ mem_size = vm_cnt.v_page_count; + if (mem_size <= 32768) /* delphij XXX 128MB */ + kmem_zmax = PAGE_SIZE; if (vm_kmem_size_scale < 1) vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 00cc93298f30..7ab650949c8b 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -447,9 +447,9 @@ mb_dtor_mbuf(void *mem, int size, void *arg) m = (struct mbuf *)mem; flags = (unsigned long)arg; + KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__)); if ((m->m_flags & M_PKTHDR) && !SLIST_EMPTY(&m->m_pkthdr.tags)) m_tag_delete_chain(m, NULL); - KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__)); #ifdef INVARIANTS trash_dtor(mem, size, arg); #endif diff --git a/sys/kern/kern_poll.c b/sys/kern/kern_poll.c index f8bc8009c32d..04b4e7936a1e 100644 --- a/sys/kern/kern_poll.c +++ b/sys/kern/kern_poll.c @@ -451,19 +451,6 @@ netisr_poll(void) mtx_unlock(&poll_mtx); } -/* The following should be temporary, till all drivers use the driver API */ -int -ether_poll_register_drv(poll_handler_drv_t *h, if_t ifh) -{ - return (ether_poll_register((poll_handler_t *)h, (struct ifnet *)ifh)); -} - -int -ether_poll_deregister_drv(if_t ifh) -{ - return (ether_poll_deregister((struct ifnet *)ifh)); -} - /* * Try to register routine for polling. Returns 0 if successful * (and polling should be enabled), error code otherwise. @@ -472,7 +459,7 @@ ether_poll_deregister_drv(if_t ifh) * This is called from within the *_ioctl() functions. */ int -ether_poll_register(poll_handler_t *h, struct ifnet *ifp) +ether_poll_register(poll_handler_t *h, if_t ifp) { int i; @@ -519,7 +506,7 @@ ether_poll_register(poll_handler_t *h, struct ifnet *ifp) * Remove interface from the polling list. Called from *_ioctl(), too. */ int -ether_poll_deregister(struct ifnet *ifp) +ether_poll_deregister(if_t ifp) { int i; diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 37c538b64b73..02a8cf911e44 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -362,7 +362,7 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) if (sbt == 0) sbt = tick_sbt; - if (cold) { + if (cold || kdb_active) { /* * We delay one second at a time to avoid overflowing the * system specific DELAY() function(s): diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 0a63c01d8188..473e334e64a9 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -1037,6 +1037,14 @@ tdq_notify(struct tdq *tdq, struct thread *td) ctd = pcpu_find(cpu)->pc_curthread; if (!sched_shouldpreempt(pri, ctd->td_priority, 1)) return; + + /* + * Make sure that our caller's earlier update to tdq_load is + * globally visible before we read tdq_cpu_idle. Idle thread + * accesses both of them without locks, and the order is important. + */ + mb(); + if (TD_IS_IDLETHREAD(ctd)) { /* * If the MD code has an idle wakeup routine try that before @@ -2640,6 +2648,12 @@ sched_idletd(void *dummy) /* Run main MD idle handler. */ tdq->tdq_cpu_idle = 1; + /* + * Make sure that tdq_cpu_idle update is globally visible + * before cpu_idle() read tdq_load. The order is important + * to avoid race with tdq_notify. + */ + mb(); cpu_idle(switchcnt * 4 > sched_idlespinthresh); tdq->tdq_cpu_idle = 0; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 7e2e5fb7e998..974c54039962 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -135,6 +135,7 @@ struct device { #define DF_DONENOMATCH 0x20 /* don't execute DEVICE_NOMATCH again */ #define DF_EXTERNALSOFTC 0x40 /* softc not allocated by us */ #define DF_REBID 0x80 /* Can rebid after attach */ +#define DF_SUSPENDED 0x100 /* Device is suspended. */ u_int order; /**< order from device_add_child_ordered() */ void *ivars; /**< instance variables */ void *softc; /**< current driver's variables */ @@ -3301,7 +3302,10 @@ resource_list_alloc(struct resource_list *rl, device_t bus, device_t child, rle->flags |= RLE_ALLOCATED; return (rle->res); } - panic("resource_list_alloc: resource entry is busy"); + device_printf(bus, + "resource entry %#x type %d for child %s is busy\n", *rid, + type, device_get_nameunit(child)); + return (NULL); } if (isdefault) { @@ -3630,6 +3634,39 @@ bus_generic_shutdown(device_t dev) return (0); } +/** + * @brief Default function for suspending a child device. + * + * This function is to be used by a bus's DEVICE_SUSPEND_CHILD(). + */ +int +bus_generic_suspend_child(device_t dev, device_t child) +{ + int error; + + error = DEVICE_SUSPEND(child); + + if (error == 0) + dev->flags |= DF_SUSPENDED; + + return (error); +} + +/** + * @brief Default function for resuming a child device. + * + * This function is to be used by a bus's DEVICE_RESUME_CHILD(). + */ +int +bus_generic_resume_child(device_t dev, device_t child) +{ + + DEVICE_RESUME(child); + dev->flags &= ~DF_SUSPENDED; + + return (0); +} + /** * @brief Helper function for implementing DEVICE_SUSPEND() * @@ -3646,12 +3683,12 @@ bus_generic_suspend(device_t dev) device_t child, child2; TAILQ_FOREACH(child, &dev->children, link) { - error = DEVICE_SUSPEND(child); + error = BUS_SUSPEND_CHILD(dev, child); if (error) { for (child2 = TAILQ_FIRST(&dev->children); child2 && child2 != child; child2 = TAILQ_NEXT(child2, link)) - DEVICE_RESUME(child2); + BUS_RESUME_CHILD(dev, child2); return (error); } } @@ -3670,7 +3707,7 @@ bus_generic_resume(device_t dev) device_t child; TAILQ_FOREACH(child, &dev->children, link) { - DEVICE_RESUME(child); + BUS_RESUME_CHILD(dev, child); /* if resume fails, there's nothing we can usefully do... */ } return (0); diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 01cfeb9c1ffd..b39c4fe2e247 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -152,6 +153,7 @@ static fo_stat_t pipe_stat; static fo_close_t pipe_close; static fo_chmod_t pipe_chmod; static fo_chown_t pipe_chown; +static fo_fill_kinfo_t pipe_fill_kinfo; struct fileops pipeops = { .fo_read = pipe_read, @@ -165,6 +167,7 @@ struct fileops pipeops = { .fo_chmod = pipe_chmod, .fo_chown = pipe_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = pipe_fill_kinfo, .fo_flags = DFLAG_PASSABLE }; @@ -1324,11 +1327,15 @@ pipe_truncate(fp, length, active_cred, td) struct ucred *active_cred; struct thread *td; { + struct pipe *cpipe; + int error; - /* For named pipes call the vnode operation. */ - if (fp->f_vnode != NULL) - return (vnops.fo_truncate(fp, length, active_cred, td)); - return (EINVAL); + cpipe = fp->f_data; + if (cpipe->pipe_state & PIPE_NAMED) + error = vnops.fo_truncate(fp, length, active_cred, td); + else + error = invfo_truncate(fp, length, active_cred, td); + return (error); } /* @@ -1603,6 +1610,21 @@ pipe_chown(fp, uid, gid, active_cred, td) return (error); } +static int +pipe_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + struct pipe *pi; + + if (fp->f_type == DTYPE_FIFO) + return (vn_fill_kinfo(fp, kif, fdp)); + kif->kf_type = KF_TYPE_PIPE; + pi = fp->f_data; + kif->kf_un.kf_pipe.kf_pipe_addr = (uintptr_t)pi; + kif->kf_un.kf_pipe.kf_pipe_peer = (uintptr_t)pi->pipe_peer; + kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt; + return (0); +} + static void pipe_free_kmem(cpipe) struct pipe *cpipe; diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 1039dac6e2a8..948595f8751e 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -87,29 +88,25 @@ FEATURE(process_descriptors, "Process Descriptors"); static uma_zone_t procdesc_zone; -static fo_rdwr_t procdesc_read; -static fo_rdwr_t procdesc_write; -static fo_truncate_t procdesc_truncate; -static fo_ioctl_t procdesc_ioctl; static fo_poll_t procdesc_poll; static fo_kqfilter_t procdesc_kqfilter; static fo_stat_t procdesc_stat; static fo_close_t procdesc_close; -static fo_chmod_t procdesc_chmod; -static fo_chown_t procdesc_chown; +static fo_fill_kinfo_t procdesc_fill_kinfo; static struct fileops procdesc_ops = { - .fo_read = procdesc_read, - .fo_write = procdesc_write, - .fo_truncate = procdesc_truncate, - .fo_ioctl = procdesc_ioctl, + .fo_read = invfo_rdwr, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, + .fo_ioctl = invfo_ioctl, .fo_poll = procdesc_poll, .fo_kqfilter = procdesc_kqfilter, .fo_stat = procdesc_stat, .fo_close = procdesc_close, - .fo_chmod = procdesc_chmod, - .fo_chown = procdesc_chown, + .fo_chmod = invfo_chmod, + .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = procdesc_fill_kinfo, .fo_flags = DFLAG_PASSABLE, }; @@ -412,38 +409,6 @@ procdesc_close(struct file *fp, struct thread *td) return (0); } -static int -procdesc_read(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_write(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_ioctl(struct file *fp, u_long com, void *data, - struct ucred *active_cred, struct thread *td) -{ - - return (EOPNOTSUPP); -} - static int procdesc_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td) @@ -570,17 +535,13 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, } static int -procdesc_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, - struct thread *td) +procdesc_fill_kinfo(struct file *fp, struct kinfo_file *kif, + struct filedesc *fdp) { + struct procdesc *pdp; - return (EOPNOTSUPP); -} - -static int -procdesc_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); + kif->kf_type = KF_TYPE_PROCDESC; + pdp = fp->f_data; + kif->kf_un.kf_proc.kf_pid = pdp->pd_pid; + return (0); } diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index b30e12a5ac63..d97b5834a15f 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1240,7 +1240,7 @@ protect_setchild(struct thread *td, struct proc *p, int flags) { PROC_LOCK_ASSERT(p, MA_OWNED); - if (p->p_flag & P_SYSTEM || p_cansee(td, p) != 0) + if (p->p_flag & P_SYSTEM || p_cansched(td, p) != 0) return (0); if (flags & PPROT_SET) { p->p_flag |= P_PROTECTED; diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 4af12e0be1e7..47cedfeab4b8 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -34,8 +34,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include #include @@ -48,12 +50,18 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include #include #include +#include +#include + #include static fo_rdwr_t soo_read; @@ -63,6 +71,7 @@ static fo_poll_t soo_poll; extern fo_kqfilter_t soo_kqfilter; static fo_stat_t soo_stat; static fo_close_t soo_close; +static fo_fill_kinfo_t soo_fill_kinfo; struct fileops socketops = { .fo_read = soo_read, @@ -76,6 +85,7 @@ struct fileops socketops = { .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = soo_fill_kinfo, .fo_flags = DFLAG_PASSABLE }; @@ -293,3 +303,58 @@ soo_close(struct file *fp, struct thread *td) error = soclose(so); return (error); } + +static int +soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + struct sockaddr *sa; + struct inpcb *inpcb; + struct unpcb *unpcb; + struct socket *so; + int error; + + kif->kf_type = KF_TYPE_SOCKET; + so = fp->f_data; + kif->kf_sock_domain = so->so_proto->pr_domain->dom_family; + kif->kf_sock_type = so->so_type; + kif->kf_sock_protocol = so->so_proto->pr_protocol; + kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; + switch (kif->kf_sock_domain) { + case AF_INET: + case AF_INET6: + if (kif->kf_sock_protocol == IPPROTO_TCP) { + if (so->so_pcb != NULL) { + inpcb = (struct inpcb *)(so->so_pcb); + kif->kf_un.kf_sock.kf_sock_inpcb = + (uintptr_t)inpcb->inp_ppcb; + } + } + break; + case AF_UNIX: + if (so->so_pcb != NULL) { + unpcb = (struct unpcb *)(so->so_pcb); + if (unpcb->unp_conn) { + kif->kf_un.kf_sock.kf_sock_unpconn = + (uintptr_t)unpcb->unp_conn; + kif->kf_un.kf_sock.kf_sock_rcv_sb_state = + so->so_rcv.sb_state; + kif->kf_un.kf_sock.kf_sock_snd_sb_state = + so->so_snd.sb_state; + } + } + break; + } + error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); + if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) { + bcopy(sa, &kif->kf_sa_local, sa->sa_len); + free(sa, M_SONAME); + } + error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); + if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) { + bcopy(sa, &kif->kf_sa_peer, sa->sa_len); + free(sa, M_SONAME); + } + strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, + sizeof(kif->kf_path)); + return (0); +} diff --git a/sys/kern/tty.c b/sys/kern/tty.c index e918d1cfd187..e2a0fa3582a3 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1055,13 +1055,13 @@ tty_rel_free(struct tty *tp) tp->t_dev = NULL; tty_unlock(tp); - sx_xlock(&tty_list_sx); - TAILQ_REMOVE(&tty_list, tp, t_list); - tty_list_count--; - sx_xunlock(&tty_list_sx); - - if (dev != NULL) + if (dev != NULL) { + sx_xlock(&tty_list_sx); + TAILQ_REMOVE(&tty_list, tp, t_list); + tty_list_count--; + sx_xunlock(&tty_list_sx); destroy_dev_sched_cb(dev, tty_dealloc, tp); + } } void diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 8d2ac0324b35..58cbc526d273 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -252,14 +253,6 @@ done: ttydisc_rint_done(tp); return (error); } -static int -ptsdev_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td) -{ - - return (EINVAL); -} - static int ptsdev_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td) @@ -588,10 +581,22 @@ ptsdev_close(struct file *fp, struct thread *td) return (0); } +static int +ptsdev_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + struct tty *tp; + + kif->kf_type = KF_TYPE_PTS; + tp = fp->f_data; + kif->kf_un.kf_pts.kf_pts_dev = tty_udev(tp); + strlcpy(kif->kf_path, tty_devname(tp), sizeof(kif->kf_path)); + return (0); +} + static struct fileops ptsdev_ops = { .fo_read = ptsdev_read, .fo_write = ptsdev_write, - .fo_truncate = ptsdev_truncate, + .fo_truncate = invfo_truncate, .fo_ioctl = ptsdev_ioctl, .fo_poll = ptsdev_poll, .fo_kqfilter = ptsdev_kqfilter, @@ -600,6 +605,7 @@ static struct fileops ptsdev_ops = { .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = ptsdev_fill_kinfo, .fo_flags = DFLAG_PASSABLE, }; diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index 8ddf356488af..154c1e76613d 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -2417,35 +2418,6 @@ mq_proc_exit(void *arg __unused, struct proc *p) KASSERT(LIST_EMPTY(&p->p_mqnotifier), ("mq notifiers left")); } -static int -mqf_read(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - return (EOPNOTSUPP); -} - -static int -mqf_write(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - return (EOPNOTSUPP); -} - -static int -mqf_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td) -{ - - return (EINVAL); -} - -static int -mqf_ioctl(struct file *fp, u_long cmd, void *data, - struct ucred *active_cred, struct thread *td) -{ - return (ENOTTY); -} - static int mqf_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td) @@ -2600,18 +2572,27 @@ filt_mqwrite(struct knote *kn, long hint) return (mq->mq_curmsgs < mq->mq_maxmsg); } +static int +mqf_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + + kif->kf_type = KF_TYPE_MQUEUE; + return (0); +} + static struct fileops mqueueops = { - .fo_read = mqf_read, - .fo_write = mqf_write, - .fo_truncate = mqf_truncate, - .fo_ioctl = mqf_ioctl, + .fo_read = invfo_rdwr, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, + .fo_ioctl = invfo_ioctl, .fo_poll = mqf_poll, .fo_kqfilter = mqf_kqfilter, .fo_stat = mqf_stat, + .fo_close = mqf_close, .fo_chmod = mqf_chmod, .fo_chown = mqf_chown, - .fo_close = mqf_close, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = mqf_fill_kinfo, }; static struct vop_vector mqfs_vnodeops = { diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index b957d9bf49dc..63b1cec0e036 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -126,82 +127,31 @@ static int ksem_module_init(void); static int ksem_remove(char *path, Fnv32_t fnv, struct ucred *ucred); static int sem_modload(struct module *module, int cmd, void *arg); -static fo_rdwr_t ksem_read; -static fo_rdwr_t ksem_write; -static fo_truncate_t ksem_truncate; -static fo_ioctl_t ksem_ioctl; -static fo_poll_t ksem_poll; -static fo_kqfilter_t ksem_kqfilter; static fo_stat_t ksem_stat; static fo_close_t ksem_closef; static fo_chmod_t ksem_chmod; static fo_chown_t ksem_chown; +static fo_fill_kinfo_t ksem_fill_kinfo; /* File descriptor operations. */ static struct fileops ksem_ops = { - .fo_read = ksem_read, - .fo_write = ksem_write, - .fo_truncate = ksem_truncate, - .fo_ioctl = ksem_ioctl, - .fo_poll = ksem_poll, - .fo_kqfilter = ksem_kqfilter, + .fo_read = invfo_rdwr, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, + .fo_ioctl = invfo_ioctl, + .fo_poll = invfo_poll, + .fo_kqfilter = invfo_kqfilter, .fo_stat = ksem_stat, .fo_close = ksem_closef, .fo_chmod = ksem_chmod, .fo_chown = ksem_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = ksem_fill_kinfo, .fo_flags = DFLAG_PASSABLE }; FEATURE(posix_sem, "POSIX semaphores"); -static int -ksem_read(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -ksem_write(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -ksem_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td) -{ - - return (EINVAL); -} - -static int -ksem_ioctl(struct file *fp, u_long com, void *data, - struct ucred *active_cred, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -ksem_poll(struct file *fp, int events, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -ksem_kqfilter(struct file *fp, struct knote *kn) -{ - - return (EOPNOTSUPP); -} - static int ksem_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) @@ -305,6 +255,26 @@ ksem_closef(struct file *fp, struct thread *td) return (0); } +static int +ksem_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + struct ksem *ks; + + kif->kf_type = KF_TYPE_SEM; + ks = fp->f_data; + mtx_lock(&sem_lock); + kif->kf_un.kf_sem.kf_sem_value = ks->ks_value; + kif->kf_un.kf_sem.kf_sem_mode = S_IFREG | ks->ks_mode; /* XXX */ + mtx_unlock(&sem_lock); + if (ks->ks_path != NULL) { + sx_slock(&ksem_dict_lock); + if (ks->ks_path != NULL) + strlcpy(kif->kf_path, ks->ks_path, sizeof(kif->kf_path)); + sx_sunlock(&ksem_dict_lock); + } + return (0); +} + /* * ksem object management including creation and reference counting * routines. @@ -441,20 +411,6 @@ ksem_remove(char *path, Fnv32_t fnv, struct ucred *ucred) return (ENOENT); } -static void -ksem_info_impl(struct ksem *ks, char *path, size_t size, uint32_t *value) -{ - - if (ks->ks_path == NULL) - return; - sx_slock(&ksem_dict_lock); - if (ks->ks_path != NULL) - strlcpy(path, ks->ks_path, size); - if (value != NULL) - *value = ks->ks_value; - sx_sunlock(&ksem_dict_lock); -} - static int ksem_create_copyout_semid(struct thread *td, semid_t *semidp, int fd, int compat32) @@ -1036,7 +992,6 @@ ksem_module_init(void) p31b_setcfg(CTL_P1003_1B_SEMAPHORES, 200112L); p31b_setcfg(CTL_P1003_1B_SEM_NSEMS_MAX, SEM_MAX); p31b_setcfg(CTL_P1003_1B_SEM_VALUE_MAX, SEM_VALUE_MAX); - ksem_info = ksem_info_impl; error = syscall_helper_register(ksem_syscalls); if (error) @@ -1058,7 +1013,6 @@ ksem_module_destroy(void) #endif syscall_helper_unregister(ksem_syscalls); - ksem_info = NULL; p31b_setcfg(CTL_P1003_1B_SEMAPHORES, 0); hashdestroy(ksem_dictionary, M_KSEM, ksem_hash); sx_destroy(&ksem_dict_lock); diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 435b8e10be23..7829620a7be6 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -120,29 +121,28 @@ static int shm_dotruncate(struct shmfd *shmfd, off_t length); static fo_rdwr_t shm_read; static fo_rdwr_t shm_write; static fo_truncate_t shm_truncate; -static fo_ioctl_t shm_ioctl; -static fo_poll_t shm_poll; -static fo_kqfilter_t shm_kqfilter; static fo_stat_t shm_stat; static fo_close_t shm_close; static fo_chmod_t shm_chmod; static fo_chown_t shm_chown; static fo_seek_t shm_seek; +static fo_fill_kinfo_t shm_fill_kinfo; /* File descriptor operations. */ static struct fileops shm_ops = { .fo_read = shm_read, .fo_write = shm_write, .fo_truncate = shm_truncate, - .fo_ioctl = shm_ioctl, - .fo_poll = shm_poll, - .fo_kqfilter = shm_kqfilter, + .fo_ioctl = invfo_ioctl, + .fo_poll = invfo_poll, + .fo_kqfilter = invfo_kqfilter, .fo_stat = shm_stat, .fo_close = shm_close, .fo_chmod = shm_chmod, .fo_chown = shm_chown, .fo_sendfile = vn_sendfile, .fo_seek = shm_seek, + .fo_fill_kinfo = shm_fill_kinfo, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE }; @@ -354,29 +354,6 @@ shm_truncate(struct file *fp, off_t length, struct ucred *active_cred, return (shm_dotruncate(shmfd, length)); } -static int -shm_ioctl(struct file *fp, u_long com, void *data, - struct ucred *active_cred, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -shm_poll(struct file *fp, int events, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -shm_kqfilter(struct file *fp, struct knote *kn) -{ - - return (EOPNOTSUPP); -} - static int shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) @@ -1048,14 +1025,24 @@ shm_unmap(struct file *fp, void *mem, size_t size) return (0); } -void -shm_path(struct shmfd *shmfd, char *path, size_t size) +static int +shm_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) { + struct shmfd *shmfd; - if (shmfd->shm_path == NULL) - return; - sx_slock(&shm_dict_lock); - if (shmfd->shm_path != NULL) - strlcpy(path, shmfd->shm_path, size); - sx_sunlock(&shm_dict_lock); + kif->kf_type = KF_TYPE_SHM; + shmfd = fp->f_data; + + mtx_lock(&shm_timestamp_lock); + kif->kf_un.kf_file.kf_file_mode = S_IFREG | shmfd->shm_mode; /* XXX */ + mtx_unlock(&shm_timestamp_lock); + kif->kf_un.kf_file.kf_file_size = shmfd->shm_size; + if (shmfd->shm_path != NULL) { + sx_slock(&shm_dict_lock); + if (shmfd->shm_path != NULL) + strlcpy(kif->kf_path, shmfd->shm_path, + sizeof(kif->kf_path)); + sx_sunlock(&shm_dict_lock); + } + return (0); } diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 258208959801..c74343b8f812 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -1014,6 +1014,37 @@ sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff) return (ret); } +/* + * Return the first mbuf and the mbuf data offset for the provided + * send offset without changing the "sb_sndptroff" field. + */ +struct mbuf * +sbsndmbuf(struct sockbuf *sb, u_int off, u_int *moff) +{ + struct mbuf *m; + + KASSERT(sb->sb_mb != NULL, ("%s: sb_mb is NULL", __func__)); + + /* + * If the "off" is below the stored offset, which happens on + * retransmits, just use "sb_mb": + */ + if (sb->sb_sndptr == NULL || sb->sb_sndptroff > off) { + m = sb->sb_mb; + } else { + m = sb->sb_sndptr; + off -= sb->sb_sndptroff; + } + while (off > 0 && m != NULL) { + if (off < m->m_len) + break; + off -= m->m_len; + m = m->m_next; + } + *moff = off; + return (m); +} + /* * Drop a record off the front of a sockbuf and move the next record to the * front. diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 9b12bd7c467d..706632716b1f 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -391,26 +391,25 @@ soalloc(struct vnet *vnet) sx_init(&so->so_snd.sb_sx, "so_snd_sx"); sx_init(&so->so_rcv.sb_sx, "so_rcv_sx"); TAILQ_INIT(&so->so_aiojobq); +#ifdef VIMAGE + VNET_ASSERT(vnet != NULL, ("%s:%d vnet is NULL, so=%p", + __func__, __LINE__, so)); + so->so_vnet = vnet; +#endif + /* We shouldn't need the so_global_mtx */ + if (hhook_run_socket(so, NULL, HHOOK_SOCKET_CREATE)) { + /* Do we need more comprehensive error returns? */ + uma_zfree(socket_zone, so); + return (NULL); + } mtx_lock(&so_global_mtx); so->so_gencnt = ++so_gencnt; ++numopensockets; #ifdef VIMAGE - VNET_ASSERT(vnet != NULL, ("%s:%d vnet is NULL, so=%p", - __func__, __LINE__, so)); vnet->vnet_sockcnt++; - so->so_vnet = vnet; #endif mtx_unlock(&so_global_mtx); - CURVNET_SET(vnet); - /* We shouldn't need the so_global_mtx */ - if (V_socket_hhh[HHOOK_SOCKET_CREATE]->hhh_nhooks > 0) { - if (hhook_run_socket(so, NULL, HHOOK_SOCKET_CREATE)) - /* Do we need more comprehensive error returns? */ - so = NULL; - } - CURVNET_RESTORE(); - return (so); } @@ -447,10 +446,7 @@ sodealloc(struct socket *so) #ifdef MAC mac_socket_destroy(so); #endif - CURVNET_SET(so->so_vnet); - if (V_socket_hhh[HHOOK_SOCKET_CLOSE]->hhh_nhooks > 0) - hhook_run_socket(so, NULL, HHOOK_SOCKET_CLOSE); - CURVNET_RESTORE(); + hhook_run_socket(so, NULL, HHOOK_SOCKET_CLOSE); crfree(so->so_cred); khelp_destroy_osd(&so->osd); @@ -2406,10 +2402,13 @@ hhook_run_socket(struct socket *so, void *hctx, int32_t h_id) struct socket_hhook_data hhook_data = { .so = so, .hctx = hctx, - .m = NULL + .m = NULL, + .status = 0 }; - hhook_run_hooks(V_socket_hhh[h_id], &hhook_data, &so->osd); + CURVNET_SET(so->so_vnet); + HHOOKS_RUN_IF(V_socket_hhh[h_id], &hhook_data, &so->osd); + CURVNET_RESTORE(); /* Ugly but needed, since hhooks return void for now */ return (hhook_data.status); @@ -3265,11 +3264,8 @@ filt_soread(struct knote *kn, long hint) return 1; } - if (V_socket_hhh[HHOOK_FILT_SOREAD]->hhh_nhooks > 0) - /* This hook returning non-zero indicates an event, not error */ - return (hhook_run_socket(so, NULL, HHOOK_FILT_SOREAD)); - - return (0); + /* This hook returning non-zero indicates an event, not error */ + return (hhook_run_socket(so, NULL, HHOOK_FILT_SOREAD)); } static void @@ -3294,8 +3290,7 @@ filt_sowrite(struct knote *kn, long hint) SOCKBUF_LOCK_ASSERT(&so->so_snd); kn->kn_data = sbspace(&so->so_snd); - if (V_socket_hhh[HHOOK_FILT_SOWRITE]->hhh_nhooks > 0) - hhook_run_socket(so, kn, HHOOK_FILT_SOWRITE); + hhook_run_socket(so, kn, HHOOK_FILT_SOWRITE); if (so->so_snd.sb_state & SBS_CANTSENDMORE) { kn->kn_flags |= EV_EOF; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 2c011173d2ab..439d06e6eb9d 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -721,7 +721,6 @@ vop_stdgetpages(ap) vm_page_t *a_m; int a_count; int a_reqpage; - vm_ooffset_t a_offset; } */ *ap; { @@ -744,7 +743,6 @@ vop_stdputpages(ap) int a_count; int a_sync; int *a_rtvals; - vm_ooffset_t a_offset; } */ *ap; { diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 9289e6a3524a..8d2e07e84103 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1863,8 +1863,15 @@ sched_sync(void) continue; } - if (first_printf == 0) + if (first_printf == 0) { + /* + * Drop the sync mutex, because some watchdog + * drivers need to sleep while patting + */ + mtx_unlock(&sync_mtx); wdog_kern_pat(WD_LASTVAL); + mtx_lock(&sync_mtx); + } } if (syncer_state == SYNCER_FINAL_DELAY && syncer_final_iter > 0) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 1406e0f8bc5f..976da4ed1475 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1551,10 +1551,10 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2, cap_rights_t rights; int error; +again: bwillwrite(); NDINIT_AT(&nd, LOOKUP, follow | AUDITVNODE1, segflg, path1, fd1, td); -again: if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1563,50 +1563,65 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2, vrele(vp); return (EPERM); /* POSIX */ } - if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) { - vrele(vp); - return (error); - } NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE2, segflg, path2, fd2, cap_rights_init(&rights, CAP_LINKAT), td); if ((error = namei(&nd)) == 0) { if (nd.ni_vp != NULL) { + NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vrele(nd.ni_vp); - error = EEXIST; - } else if ((error = vn_lock(vp, LK_EXCLUSIVE)) == 0) { + vrele(vp); + return (EEXIST); + } else if (nd.ni_dvp->v_mount != vp->v_mount) { /* - * Check for cross-device links. No need to - * recheck vp->v_type, since it cannot change - * for non-doomed vnode. + * Cross-device link. No need to recheck + * vp->v_type, since it cannot change, except + * to VBAD. */ - if (nd.ni_dvp->v_mount != vp->v_mount) - error = EXDEV; - else - error = can_hardlink(vp, td->td_ucred); - if (error == 0) + NDFREE(&nd, NDF_ONLY_PNBUF); + vput(nd.ni_dvp); + vrele(vp); + return (EXDEV); + } else if ((error = vn_lock(vp, LK_EXCLUSIVE)) == 0) { + error = can_hardlink(vp, td->td_ucred); #ifdef MAC + if (error == 0) error = mac_vnode_check_link(td->td_ucred, nd.ni_dvp, vp, &nd.ni_cnd); - if (error == 0) #endif - error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); + if (error != 0) { + vput(vp); + vput(nd.ni_dvp); + NDFREE(&nd, NDF_ONLY_PNBUF); + return (error); + } + error = vn_start_write(vp, &mp, V_NOWAIT); + if (error != 0) { + vput(vp); + vput(nd.ni_dvp); + NDFREE(&nd, NDF_ONLY_PNBUF); + error = vn_start_write(NULL, &mp, + V_XSLEEP | PCATCH); + if (error != 0) + return (error); + goto again; + } + error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); VOP_UNLOCK(vp, 0); vput(nd.ni_dvp); + vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); } else { vput(nd.ni_dvp); NDFREE(&nd, NDF_ONLY_PNBUF); vrele(vp); - vn_finished_write(mp); goto again; } - NDFREE(&nd, NDF_ONLY_PNBUF); } vrele(vp); - vn_finished_write(mp); return (error); } @@ -2055,6 +2070,9 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg, cap_rights_t rights; int error; + if (amode != F_OK && (amode & ~(R_OK | W_OK | X_OK)) != 0) + return (EINVAL); + /* * Create and modify a temporary credential instead of one that * is potentially shared. @@ -3516,6 +3534,7 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new, cap_rights_t rights; int error; +again: bwillwrite(); #ifdef MAC NDINIT_ATRIGHTS(&fromnd, DELETE, LOCKPARENT | LOCKLEAF | SAVESTART | @@ -3536,14 +3555,6 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new, VOP_UNLOCK(fromnd.ni_vp, 0); #endif fvp = fromnd.ni_vp; - if (error == 0) - error = vn_start_write(fvp, &mp, V_WAIT | PCATCH); - if (error != 0) { - NDFREE(&fromnd, NDF_ONLY_PNBUF); - vrele(fromnd.ni_dvp); - vrele(fvp); - goto out1; - } NDINIT_ATRIGHTS(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | AUDITVNODE2, pathseg, new, newfd, cap_rights_init(&rights, CAP_LINKAT), td); @@ -3556,11 +3567,30 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new, NDFREE(&fromnd, NDF_ONLY_PNBUF); vrele(fromnd.ni_dvp); vrele(fvp); - vn_finished_write(mp); goto out1; } tdvp = tond.ni_dvp; tvp = tond.ni_vp; + error = vn_start_write(fvp, &mp, V_NOWAIT); + if (error != 0) { + NDFREE(&fromnd, NDF_ONLY_PNBUF); + NDFREE(&tond, NDF_ONLY_PNBUF); + if (tvp != NULL) + vput(tvp); + if (tdvp == tvp) + vrele(tdvp); + else + vput(tdvp); + vrele(fromnd.ni_dvp); + vrele(fvp); + vrele(tond.ni_startdir); + if (fromnd.ni_startdir != NULL) + vrele(fromnd.ni_startdir); + error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH); + if (error != 0) + return (error); + goto again; + } if (tvp != NULL) { if (fvp->v_type == VDIR && tvp->v_type != VDIR) { error = ENOTDIR; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 98823f383433..617bda0d4ce6 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -103,6 +104,7 @@ struct fileops vnops = { .fo_chown = vn_chown, .fo_sendfile = vn_sendfile, .fo_seek = vn_seek, + .fo_fill_kinfo = vn_fill_kinfo, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE }; @@ -2249,3 +2251,61 @@ vn_utimes_perm(struct vnode *vp, struct vattr *vap, struct ucred *cred, error = VOP_ACCESS(vp, VWRITE, cred, td); return (error); } + +int +vn_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + struct vnode *vp; + int error; + + if (fp->f_type == DTYPE_FIFO) + kif->kf_type = KF_TYPE_FIFO; + else + kif->kf_type = KF_TYPE_VNODE; + vp = fp->f_vnode; + vref(vp); + FILEDESC_SUNLOCK(fdp); + error = vn_fill_kinfo_vnode(vp, kif); + vrele(vp); + FILEDESC_SLOCK(fdp); + return (error); +} + +int +vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif) +{ + struct vattr va; + char *fullpath, *freepath; + int error; + + kif->kf_vnode_type = vntype_to_kinfo(vp->v_type); + freepath = NULL; + fullpath = "-"; + error = vn_fullpath(curthread, vp, &fullpath, &freepath); + if (error == 0) { + strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path)); + } + if (freepath != NULL) + free(freepath, M_TEMP); + + /* + * Retrieve vnode attributes. + */ + va.va_fsid = VNOVAL; + va.va_rdev = NODEV; + vn_lock(vp, LK_SHARED | LK_RETRY); + error = VOP_GETATTR(vp, &va, curthread->td_ucred); + VOP_UNLOCK(vp, 0); + if (error != 0) + return (error); + if (va.va_fsid != VNOVAL) + kif->kf_un.kf_file.kf_file_fsid = va.va_fsid; + else + kif->kf_un.kf_file.kf_file_fsid = + vp->v_mount->mnt_stat.f_fsid.val[0]; + kif->kf_un.kf_file.kf_file_fileid = va.va_fileid; + kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode); + kif->kf_un.kf_file.kf_file_size = va.va_size; + kif->kf_un.kf_file.kf_file_rdev = va.va_rdev; + return (0); +} diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 3793ef35d37f..6399ff4e7219 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -473,7 +473,6 @@ vop_getpages { IN vm_page_t *m; IN int count; IN int reqpage; - IN vm_ooffset_t offset; }; @@ -485,7 +484,6 @@ vop_putpages { IN int count; IN int sync; IN int *rtvals; - IN vm_ooffset_t offset; }; diff --git a/sys/libkern/memmem.c b/sys/libkern/memmem.c new file mode 100644 index 000000000000..11c3d9eec508 --- /dev/null +++ b/sys/libkern/memmem.c @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2005 Pascal Gloor + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. 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 + +void * +memmem(const void *l, size_t l_len, const void *s, size_t s_len) +{ + register char *cur, *last; + const char *cl = (const char *)l; + const char *cs = (const char *)s; + + /* we need something to compare */ + if (l_len == 0 || s_len == 0) + return NULL; + + /* "s" must be smaller or equal to "l" */ + if (l_len < s_len) + return NULL; + + /* special case where s_len == 1 */ + if (s_len == 1) + return memchr(l, (int)*cs, l_len); + + /* the last position where its possible to find "s" in "l" */ + last = __DECONST(char *, cl) + l_len - s_len; + + for (cur = __DECONST(char *, cl); cur <= last; cur++) + if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0) + return cur; + + return NULL; +} diff --git a/sys/mips/adm5120/if_admsw.c b/sys/mips/adm5120/if_admsw.c index b06901522233..11f96b5f4ed3 100644 --- a/sys/mips/adm5120/if_admsw.c +++ b/sys/mips/adm5120/if_admsw.c @@ -925,7 +925,7 @@ admsw_txintr(struct admsw_softc *sc, int prio) gotone = 1; /* printf("clear tx slot %d\n",i); */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); sc->sc_txfree++; } @@ -1047,7 +1047,7 @@ admsw_rxintr(struct admsw_softc *sc, int high) m = ds->ds_mbuf; if (admsw_add_rxlbuf(sc, i) != 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); ADMSW_INIT_RXLDESC(sc, i); bus_dmamap_sync(sc->sc_bufs_dmat, ds->ds_dmamap, BUS_DMASYNC_PREREAD); @@ -1066,7 +1066,7 @@ admsw_rxintr(struct admsw_softc *sc, int high) /* Pass it on. */ (*ifp->if_input)(ifp, m); - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); } /* Update the receive pointer. */ diff --git a/sys/mips/atheros/ar724x_pci.c b/sys/mips/atheros/ar724x_pci.c index 0ce9177b1508..854cd6560f0d 100644 --- a/sys/mips/atheros/ar724x_pci.c +++ b/sys/mips/atheros/ar724x_pci.c @@ -122,8 +122,12 @@ ar724x_pci_read_config(device_t dev, u_int bus, u_int slot, u_int func, /* Register access is 32-bit aligned */ shift = (reg & 3) * 8; - if (shift) - mask = (1 << shift) - 1; + + /* Create a mask based on the width, post-shift */ + if (bytes == 2) + mask = 0xffff; + else if (bytes == 1) + mask = 0xff; else mask = 0xffffffff; @@ -155,10 +159,18 @@ ar724x_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func, return; /* - * WAR for BAR issue on AR7240 - We are unable to access the PCI device - * space if we set the BAR with proper base address. + * WAR for BAR issue on AR7240 - We are unable to access the PCI + * device space if we set the BAR with proper base address. + * + * However, we _do_ want to allow programming in the probe value + * (0xffffffff) so the PCI code can find out how big the memory + * map is for this device. Without it, it'll think the memory + * map is 32 bits wide, the PCI code will then end up thinking + * the register window is '0' and fail to allocate resources. */ - if (reg == PCIR_BAR(0) && bytes == 4 && ar71xx_soc == AR71XX_SOC_AR7240) + if (reg == PCIR_BAR(0) && bytes == 4 + && ar71xx_soc == AR71XX_SOC_AR7240 + && data != 0xffffffff) ar724x_pci_write(AR724X_PCI_CFG_BASE, reg, 0xffff, bytes); else ar724x_pci_write(AR724X_PCI_CFG_BASE, reg, data, bytes); @@ -337,7 +349,6 @@ ar724x_pci_slot_fixup(device_t dev) return; } - device_printf(dev, "found EEPROM at 0x%lx on %d.%d.%d\n", flash_addr, 0, 0, 0); ar724x_pci_fixup(dev, flash_addr, size); @@ -486,7 +497,6 @@ ar724x_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, } } - return (rv); } diff --git a/sys/mips/atheros/if_arge.c b/sys/mips/atheros/if_arge.c index 85617387f5d7..e88f1e81c39d 100644 --- a/sys/mips/atheros/if_arge.c +++ b/sys/mips/atheros/if_arge.c @@ -2147,7 +2147,7 @@ arge_tx_locked(struct arge_softc *sc) txd = &sc->arge_cdata.arge_txdesc[cons]; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); bus_dmamap_sync(sc->arge_cdata.arge_tx_tag, txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); @@ -2209,7 +2209,7 @@ arge_rx_locked(struct arge_softc *sc) m->m_pkthdr.rcvif = ifp; /* Skip 4 bytes of CRC */ m->m_pkthdr.len = m->m_len = packet_len - ETHER_CRC_LEN; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); rx_npkts++; ARGE_UNLOCK(sc); diff --git a/sys/mips/beri/beri_simplebus.c b/sys/mips/beri/beri_simplebus.c index 3862a04e481e..87ad3beb1f15 100644 --- a/sys/mips/beri/beri_simplebus.c +++ b/sys/mips/beri/beri_simplebus.c @@ -198,7 +198,7 @@ simplebus_attach(device_t dev) continue; } - if (fdt_intr_to_rl(dev, dt_child, &di->di_res, di->di_intr_sl)) { + if (ofw_bus_intr_to_rl(dev, dt_child, &di->di_res)) { device_printf(dev, "%s: could not process " "'interrupts' property\n", di->di_ofw.obd_name); resource_list_free(&di->di_res); diff --git a/sys/mips/cavium/ciu.c b/sys/mips/cavium/ciu.c index 87895bb4960b..4e069f9b1aab 100644 --- a/sys/mips/cavium/ciu.c +++ b/sys/mips/cavium/ciu.c @@ -91,13 +91,13 @@ static void ciu_hinted_child(device_t, const char *, int); static void ciu_en0_intr_mask(void *); static void ciu_en0_intr_unmask(void *); #ifdef SMP -static int ciu_en0_intr_bind(void *, u_char); +static int ciu_en0_intr_bind(void *, int); #endif static void ciu_en1_intr_mask(void *); static void ciu_en1_intr_unmask(void *); #ifdef SMP -static int ciu_en1_intr_bind(void *, u_char); +static int ciu_en1_intr_bind(void *, int); #endif static int ciu_intr(void *); @@ -208,7 +208,7 @@ ciu_setup_intr(device_t bus, device_t child, struct resource *res, int flags, struct intr_event *event, **eventp; void (*mask_func)(void *); void (*unmask_func)(void *); - int (*bind_func)(void *, u_char); + int (*bind_func)(void *, int); mips_intrcnt_t intrcnt; int error; int irq; @@ -343,7 +343,7 @@ ciu_en0_intr_unmask(void *arg) #ifdef SMP static int -ciu_en0_intr_bind(void *arg, u_char target) +ciu_en0_intr_bind(void *arg, int target) { uint64_t mask; int core; @@ -389,7 +389,7 @@ ciu_en1_intr_unmask(void *arg) #ifdef SMP static int -ciu_en1_intr_bind(void *arg, u_char target) +ciu_en1_intr_bind(void *arg, int target) { uint64_t mask; int core; diff --git a/sys/mips/cavium/if_octm.c b/sys/mips/cavium/if_octm.c index 461d1bbb0ef9..a689a0fe6726 100644 --- a/sys/mips/cavium/if_octm.c +++ b/sys/mips/cavium/if_octm.c @@ -347,10 +347,10 @@ octm_transmit(struct ifnet *ifp, struct mbuf *m) if (result == CVMX_MGMT_PORT_SUCCESS) { ETHER_BPF_MTAP(ifp, m); - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); } else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); @@ -517,7 +517,7 @@ octm_rx_intr(void *arg) m->m_pkthdr.rcvif = sc->sc_ifp; m->m_pkthdr.len = m->m_len = len; - sc->sc_ifp->if_ipackets++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); (*sc->sc_ifp->if_input)(sc->sc_ifp, m); @@ -529,7 +529,7 @@ octm_rx_intr(void *arg) if (len == 0) break; - sc->sc_ifp->if_ierrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); } /* Acknowledge interrupts. */ diff --git a/sys/mips/cavium/octe/ethernet-mdio.c b/sys/mips/cavium/octe/ethernet-mdio.c index d95669a6037f..c61a2a643bc6 100644 --- a/sys/mips/cavium/octe/ethernet-mdio.c +++ b/sys/mips/cavium/octe/ethernet-mdio.c @@ -71,6 +71,7 @@ int cvm_oct_mdio_read(struct ifnet *ifp, int phy_id, int location) cvmx_write_csr(CVMX_SMI_CMD, smi_cmd.u64); do { + cvmx_wait(1000); smi_rd.u64 = cvmx_read_csr(CVMX_SMI_RD_DAT); } while (smi_rd.s.pending); @@ -108,6 +109,7 @@ void cvm_oct_mdio_write(struct ifnet *ifp, int phy_id, int location, int val) cvmx_write_csr(CVMX_SMI_CMD, smi_cmd.u64); do { + cvmx_wait(1000); smi_wr.u64 = cvmx_read_csr(CVMX_SMI_WR_DAT); } while (smi_wr.s.pending); MDIO_UNLOCK(); diff --git a/sys/mips/cavium/octe/ethernet-rx.c b/sys/mips/cavium/octe/ethernet-rx.c index 79470be1dd46..492d3e0b3265 100644 --- a/sys/mips/cavium/octe/ethernet-rx.c +++ b/sys/mips/cavium/octe/ethernet-rx.c @@ -304,7 +304,7 @@ void cvm_oct_tasklet_rx(void *context, int pending) m->m_pkthdr.csum_flags = 0; /* XXX */ } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, m); } else { diff --git a/sys/mips/cavium/octe/ethernet-tx.c b/sys/mips/cavium/octe/ethernet-tx.c index b55ada64db20..b1d1f1435803 100644 --- a/sys/mips/cavium/octe/ethernet-tx.c +++ b/sys/mips/cavium/octe/ethernet-tx.c @@ -158,7 +158,7 @@ int cvm_oct_xmit(struct mbuf *m, struct ifnet *ifp) work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL); if (work == NULL) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return 1; } @@ -231,7 +231,7 @@ int cvm_oct_xmit(struct mbuf *m, struct ifnet *ifp) if (__predict_false(dropped)) { m_freem(m); cvmx_fau_atomic_add32(priv->fau+qos*4, -1); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else { /* Put this packet on the queue to be freed later */ _IF_ENQUEUE(&priv->tx_free_queue[qos], m); @@ -239,8 +239,8 @@ int cvm_oct_xmit(struct mbuf *m, struct ifnet *ifp) /* Pass it to any BPF listeners. */ ETHER_BPF_MTAP(ifp, m); - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); } /* Free mbufs not in use by the hardware */ diff --git a/sys/mips/cavium/octeon_ds1337.c b/sys/mips/cavium/octeon_ds1337.c index a5cba94e7457..73405a939056 100644 --- a/sys/mips/cavium/octeon_ds1337.c +++ b/sys/mips/cavium/octeon_ds1337.c @@ -81,7 +81,7 @@ static int validate_ct_struct(struct clocktime *ct) CT_CHECK(ct->min < 0 || ct->min > 59, "minute"); CT_CHECK(ct->hour < 0 || ct->hour > 23, "hour"); CT_CHECK(ct->day < 1 || ct->day > 31, "day"); - CT_CHECK(ct->dow < 1 || ct->dow > 7, "day of week"); + CT_CHECK(ct->dow < 0 || ct->dow > 6, "day of week"); CT_CHECK(ct->mon < 1 || ct->mon > 12, "month"); CT_CHECK(ct->year > 2037,"year"); @@ -124,7 +124,7 @@ uint32_t cvmx_rtc_ds1337_read(void) { ct.hour = (ct.hour + 12) % 24; } - ct.dow = (reg[3] & 0x7); /* Day of week field is 1..7 */ + ct.dow = (reg[3] & 0x7) - 1; /* Day of week field is 0..6 */ ct.day = bcd2bin(reg[4] & 0x3f); ct.mon = bcd2bin(reg[5] & 0x1f); /* Month field is 1..12 */ #if defined(OCTEON_BOARD_CAPK_0100ND) @@ -136,7 +136,6 @@ uint32_t cvmx_rtc_ds1337_read(void) ct.year = ((reg[5] & 0x80) ? 2000 : 1900) + bcd2bin(reg[6]); #endif - if (validate_ct_struct(&ct)) cvmx_dprintf("Warning: RTC calendar is not configured properly\n"); @@ -174,13 +173,15 @@ int cvmx_rtc_ds1337_write(uint32_t time) reg[0] = bin2bcd(ct.sec); reg[1] = bin2bcd(ct.min); reg[2] = bin2bcd(ct.hour); /* Force 0..23 format even if using AM/PM */ - reg[3] = bin2bcd(ct.dow); + reg[3] = bin2bcd(ct.dow + 1); reg[4] = bin2bcd(ct.day); reg[5] = bin2bcd(ct.mon); +#if !defined(OCTEON_BOARD_CAPK_0100ND) if (ct.year >= 2000) /* Set century bit*/ { reg[5] |= 0x80; } +#endif reg[6] = bin2bcd(ct.year % 100); /* Lockless write: detects the infrequent roll-over and retries */ diff --git a/sys/mips/conf/TP-MR3020 b/sys/mips/conf/TP-MR3020 new file mode 100644 index 000000000000..f0ecb4be017a --- /dev/null +++ b/sys/mips/conf/TP-MR3020 @@ -0,0 +1,65 @@ +# +# TP Link MR3020 - an AR9331 based SoC wifi device. +# +# This is for the 32 RAM/4 flash part. There is little to no +# chance that this will ever boot FreeBSD directly from the 3.5MB +# of flash. The kernel can fit into the space, but userland is just +# too big even when stripped down to its limits. +# +# * AR9331 SoC +# * 32MB RAM +# * 4MB flash +# * Integrated 1x1 2GHz wifi and 10/100 bridge +# * USB powered +# * USB storage +# +# $FreeBSD$ +# + +# Include the default AR933x parameters +include "AR933X_BASE" + +ident TP-MR3020 + +# Override hints with board values +hints "TP-MR3020.hints" + +# Board memory - 32MB +options AR71XX_REALMEM=(32*1024*1024) + +# i2c GPIO bus +device gpioiic +device iicbb +device iicbus +device iic + +# Options required for miiproxy and mdiobus +options ARGE_MDIO # Export an MDIO bus separate from arge +device miiproxy # MDIO bus <-> MII PHY rendezvous + +device etherswitch +device arswitch + +# Enable the uboot environment stuff rather then the +# redboot stuff. +options AR71XX_ENV_UBOOT + +# uzip - to boot natively from flash +device geom_uncompress + +# Used for the static uboot partition map +device geom_map + +# Boot off of the rootfs, as defined in the geom_map setup. +# Probably, this should be a USB device as the memory available +# compressed rootfs is simply too small for FreeBSD +#options ROOTDEVNAME=\"ufs:map/rootfs.uncompress\" + +# Boot off of a uboot tftp ramdisk kernel image. Because the flash +# on this unit is so small, this is the only way to do dev work. +# For full deployment, you will *have* to use a usb storage device +# as a rootfs and use the flash to hold the kernel only. +options MD_ROOT # md device usable as a potential root device +options MD_ROOT_SIZE=10240 +#makeoptions MFS_IMAGE=/tftpboot/mfsroot-tl-mr3020.img.ulzma +options ROOTDEVNAME=\"ufs:md0.uncompress\" diff --git a/sys/mips/conf/TP-MR3020.hints b/sys/mips/conf/TP-MR3020.hints new file mode 100644 index 000000000000..dfabb42c14d3 --- /dev/null +++ b/sys/mips/conf/TP-MR3020.hints @@ -0,0 +1,101 @@ +# +# This file adds to the values in AR933X_BASE.hints +# +# $FreeBSD$ + +# mdiobus on arge1 +hint.argemdio.0.at="nexus0" +hint.argemdio.0.maddr=0x1a000000 +hint.argemdio.0.msize=0x1000 +hint.argemdio.0.order=0 + +# There's no need to set the ar933x GMAC configuration bits. +# This just creates a switch instance and correctly uses it. + +# Embedded Atheros Switch +hint.arswitch.0.at="mdio0" + +# XXX this should really say it's an AR933x switch, as there +# are some vlan specific differences here! +hint.arswitch.0.is_7240=1 +hint.arswitch.0.numphys=4 +hint.arswitch.0.phy4cpu=1 # phy 4 is a "CPU" separate PHY +hint.arswitch.0.is_rgmii=0 +hint.arswitch.0.is_gmii=1 # arge1 <-> switch PHY is GMII + +# arge0 - MII, autoneg, phy(4) +hint.arge.0.phymask=0x10 # PHY4 +hint.arge.0.mdio=mdioproxy1 # .. off of the switch mdiobus + +# arge1 - GMII, 1000/full +hint.arge.1.phymask=0x0 # No directly mapped PHYs +hint.arge.1.media=1000 +hint.arge.1.fduplex=1 + +# Where the ART is - last 64k in the flash +# 0x9fff1000 ? +hint.ath.0.eepromaddr=0x1fff0000 +hint.ath.0.eepromsize=16384 + +# The board 16MiB flash layout in uboot env: +# +# 256k(u-boot),64k(u-boot-env),2752k(rootfs),896k(uImage),64k(NVRAM),64k(ART) + +# However, it boots from 0x9f050000, which is the front of the flsah! +# Thus the kernel/rootfs are switched around. + +# 256KB +hint.map.0.at="flash/spi0" +hint.map.0.start=0x00000000 +hint.map.0.end=0x00040000 +hint.map.0.name="uboot" +hint.map.0.readonly=1 + +# 64KB +hint.map.1.at="flash/spi0" +hint.map.1.start=0x00040000 +hint.map.1.end=0x00050000 +hint.map.1.name="uboot-env" +hint.map.1.readonly=0 + +# 2752KB +hint.map.2.at="flash/spi0" +hint.map.2.start=0x00050000 +hint.map.2.end="search:0x00100000:0x10000:.!/bin/sh" +hint.map.2.name="kernel" +hint.map.2.readonly=0 + +# 896KB +hint.map.3.at="flash/spi0" +hint.map.3.start="search:0x00100000:0x10000:.!/bin/sh" +hint.map.3.end=0x003e0000 +hint.map.3.name="rootfs" +hint.map.3.readonly=0 + +# 64K NVRAM +hint.map.4.at="flash/spi0" +hint.map.4.start=0x003e0000 +hint.map.4.end=0x003f0000 +hint.map.4.name="cfg" +hint.map.4.readonly=0 + +# 64K ART +hint.map.5.at="flash/spi0" +hint.map.5.start=0x003f0000 +hint.map.5.end=0x00400000 +hint.map.5.name="art" +hint.map.5.readonly=1 + +# GPIO specific configuration block + +# Don't flip on anything that isn't already enabled. +# This includes leaving the SPI CS1/CS2 pins as GPIO pins as they're +# not used here. +hint.gpio.0.function_set=0x00000000 +hint.gpio.0.function_clear=0x00000000 + +# These are the GPIO LEDs and buttons which can be software controlled. +#hint.gpio.0.pinmask=0x001c02ae +#hint.gpio.0.pinmask=0x00001803 + +# XXX TODO: the button and LEDs! diff --git a/sys/mips/conf/WZR-300HP b/sys/mips/conf/WZR-300HP index ce864035f2df..8f84776a7f63 100644 --- a/sys/mips/conf/WZR-300HP +++ b/sys/mips/conf/WZR-300HP @@ -21,12 +21,6 @@ options AR71XX_REALMEM=64*1024*1024 options AR71XX_ENV_UBOOT options BOOTVERBOSE -# Don't include the SCSI/CAM strings in the default build -options SCSI_NO_SENSE_STRINGS -options SCSI_NO_OP_STRINGS - -# .. And no sysctl strings -options NO_SYSCTL_DESCR # GEOM modules device geom_map # to get access to the SPI flash partitions diff --git a/sys/mips/conf/WZR-300HP.hints b/sys/mips/conf/WZR-300HP.hints index 070f38172577..07d8a7170242 100644 --- a/sys/mips/conf/WZR-300HP.hints +++ b/sys/mips/conf/WZR-300HP.hints @@ -108,7 +108,7 @@ hint.map.4.name="rootfs" hint.map.4.readonly=1 #hint.map.5.at="flash/spi1" -hint.map.5.at="flash/spi0" +hint.map.5.at="flash/spi1" hint.map.5.start=0x00FF0000 hint.map.5.end= 0x01000000 hint.map.5.name="cfg" diff --git a/sys/mips/idt/if_kr.c b/sys/mips/idt/if_kr.c index fdd60ea01a0e..4b5d3bfb43d0 100644 --- a/sys/mips/idt/if_kr.c +++ b/sys/mips/idt/if_kr.c @@ -1395,13 +1395,13 @@ kr_tx(struct kr_softc *sc) txd = &sc->kr_cdata.kr_txdesc[cons]; if (devcs & KR_DMATX_DEVCS_TOK) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); else { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* collisions: medium busy, late collision */ if ((devcs & KR_DMATX_DEVCS_EC) || (devcs & KR_DMATX_DEVCS_LC)) - ifp->if_collisions++; + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1); } bus_dmamap_sync(sc->kr_cdata.kr_tx_tag, txd->tx_dmamap, @@ -1460,11 +1460,11 @@ kr_rx(struct kr_softc *sc) error = 1; if (packet_len != count) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); else if (count < 64) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); else if ((cur_rx->kr_devcs & KR_DMARX_DEVCS_LD) == 0) - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); else if ((cur_rx->kr_devcs & KR_DMARX_DEVCS_ROK) != 0) { error = 0; bus_dmamap_sync(sc->kr_cdata.kr_rx_tag, rxd->rx_dmamap, @@ -1474,7 +1474,7 @@ kr_rx(struct kr_softc *sc) m->m_pkthdr.rcvif = ifp; /* Skip 4 bytes of CRC */ m->m_pkthdr.len = m->m_len = packet_len - ETHER_CRC_LEN; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); KR_UNLOCK(sc); (*ifp->if_input)(ifp, m); diff --git a/sys/mips/include/sf_buf.h b/sys/mips/include/sf_buf.h index 76fb993da878..d61bc9153697 100644 --- a/sys/mips/include/sf_buf.h +++ b/sys/mips/include/sf_buf.h @@ -47,5 +47,23 @@ sf_buf_page(struct sf_buf *sf) return ((vm_page_t)sf); } -#endif /* __mips_n64 */ +#else /* !__mips_n64 */ + +static inline void +sf_buf_map(struct sf_buf *sf, int flags) +{ + + pmap_qenter(sf->kva, &sf->m, 1); +} + +static inline int +sf_buf_unmap(struct sf_buf *sf) +{ + + pmap_qremove(sf->kva, 1); + return (1); +} + +#endif /* __mips_n64 */ + #endif /* !_MACHINE_SF_BUF_H_ */ diff --git a/sys/mips/include/vmparam.h b/sys/mips/include/vmparam.h index d3b833ebd4a8..756a8a60a3f8 100644 --- a/sys/mips/include/vmparam.h +++ b/sys/mips/include/vmparam.h @@ -189,6 +189,7 @@ #ifndef __mips_n64 #define SFBUF +#define SFBUF_MAP #endif #endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/mips/mips/machdep.c b/sys/mips/mips/machdep.c index 6e9a4bdfb995..5d25d881fb6c 100644 --- a/sys/mips/mips/machdep.c +++ b/sys/mips/mips/machdep.c @@ -167,9 +167,6 @@ extern char MipsCache[], MipsCacheEnd[]; extern char MipsWaitStart[], MipsWaitEnd[]; extern char edata[], end[]; -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif u_int32_t bootdev; struct bootinfo bootinfo; @@ -434,6 +431,8 @@ mips_postboot_fixup(void) #ifdef DDB Elf_Size *trampoline_data = (Elf_Size*)kernel_kseg0_end; Elf_Size symtabsize = 0; + vm_offset_t ksym_start; + vm_offset_t ksym_end; if (trampoline_data[0] == SYMTAB_MAGIC) { symtabsize = trampoline_data[1]; @@ -443,6 +442,7 @@ mips_postboot_fixup(void) kernel_kseg0_end += symtabsize; /* end of .strtab */ ksym_end = kernel_kseg0_end; + db_fetch_ksymtab(ksym_start, ksym_end); } #endif } diff --git a/sys/mips/nlm/dev/net/xlpge.c b/sys/mips/nlm/dev/net/xlpge.c index 2c6cba5ec647..41962dfaebdb 100644 --- a/sys/mips/nlm/dev/net/xlpge.c +++ b/sys/mips/nlm/dev/net/xlpge.c @@ -897,8 +897,7 @@ xlpge_tx(struct ifnet *ifp, struct mbuf *mbuf_chain) if (p2p) uma_zfree(nl_tx_desc_zone, p2p); m_freem(mbuf_chain); - /*atomic_incr_long(&ifp->if_iqdrops); */ - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (err); } @@ -1433,8 +1432,7 @@ nlm_xlpge_rx(struct nlm_xlpge_softc *sc, int port, vm_paddr_t paddr, int len) } else m->m_pkthdr.len = m->m_len = len; - /*atomic_incr_long(&ifp->if_ipackets);*/ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); #ifdef XLP_DRIVER_LOOPBACK if (port == 16 || port == 17) (*ifp->if_input)(ifp, m); @@ -1515,8 +1513,7 @@ nlm_xlpge_msgring_handler(int vc, int size, int code, int src_id, nlm_xlpge_release_mbuf(phys_addr); - /*atomic_incr_long(&ifp->if_opackets);*/ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } else if (size > 1) { /* Recieve packet */ phys_addr = msg->msg[1] & 0xffffffffc0ULL; diff --git a/sys/mips/rmi/dev/nlge/if_nlge.c b/sys/mips/rmi/dev/nlge/if_nlge.c index 9c7ff052d4fa..832c518224c7 100644 --- a/sys/mips/rmi/dev/nlge/if_nlge.c +++ b/sys/mips/rmi/dev/nlge/if_nlge.c @@ -697,7 +697,9 @@ nlge_msgring_handler(int bucket, int size, int code, int stid, printf("ERROR: Tx fb error (%d) on port %d\n", tx_error, port); } - tx_error ? ifp->if_oerrors++ : ifp->if_opackets++; + tx_error ? + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1) : + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } else if (ctrl == CTRL_SNGL || ctrl == CTRL_START) { /* Rx Packet */ @@ -776,7 +778,7 @@ nlge_start_locked(struct ifnet *ifp, struct nlge_softc *sc, struct mbuf *m) NLGE_UNLOCK(sc); } m_freem(m); - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); } return (error); } @@ -825,7 +827,7 @@ nlge_rx(struct nlge_softc *sc, vm_paddr_t paddr, int len) m->m_pkthdr.len = m->m_len = len; m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, m); } diff --git a/sys/mips/rmi/dev/xlr/rge.c b/sys/mips/rmi/dev/xlr/rge.c index 2d2ba9e4bf79..6fd2bc68b1e4 100644 --- a/sys/mips/rmi/dev/xlr/rge.c +++ b/sys/mips/rmi/dev/xlr/rge.c @@ -2019,7 +2019,7 @@ rge_rx(struct rge_softc *sc, vm_paddr_t paddr, int len) printf("\n"); } #endif - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input) (ifp, m); } @@ -2116,7 +2116,7 @@ rge_start_locked(struct ifnet *ifp, int threshold) ifp->if_drv_flags |= IFF_DRV_OACTIVE; return; } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); xlr_rge_tx_done[vcpu]++; } } diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 50e437148b8d..58ddecca06f4 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -242,7 +242,7 @@ SUBDIR= \ my \ ${_nandfs} \ ${_nandsim} \ - ${_ncp} \ + ${_ncr} \ ${_ncv} \ ${_ndis} \ netfpga10g \ @@ -537,6 +537,7 @@ _mlx4ib= mlx4ib _mlxen= mlxen _mthca= mthca .endif +_ncr= ncr _ncv= ncv _ndis= ndis _nsp= nsp @@ -624,8 +625,6 @@ _iwnfw= iwnfw .endif _ixgb= ixgb _ixgbe= ixgbe -_ixl= ixl -_ixlv= ixlv _mly= mly _nfe= nfe _nvd= nvd diff --git a/sys/modules/acpi/acpi/Makefile b/sys/modules/acpi/acpi/Makefile deleted file mode 100644 index 572269224272..000000000000 --- a/sys/modules/acpi/acpi/Makefile +++ /dev/null @@ -1,129 +0,0 @@ -# $FreeBSD$ - -.if !defined(FORCE_BUILD) -.error "The ACPI module is deprecated, set FORCE_BUILD to force it" -.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 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 tbprint.c tbutils.c tbxface.c tbxfload.c -SRCS+= tbxfroot.c -SRCS+= utaddress.c utalloc.c utbuffer.c utcache.c utcopy.c utdebug.c -SRCS+= utdecode.c utdelete.c uterror.c uteval.c utexcep.c utglobal.c utids.c -SRCS+= utinit.c utlock.c utmath.c utmisc.c utmutex.c utobject.c utosi.c -SRCS+= utownerid.c utpredef.c utresrc.c utstate.c utstring.c utxface.c -SRCS+= 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} diff --git a/sys/modules/bce/Makefile b/sys/modules/bce/Makefile index 44b0713fdca8..1be2a3f98ce2 100644 --- a/sys/modules/bce/Makefile +++ b/sys/modules/bce/Makefile @@ -5,9 +5,4 @@ SRCS= opt_bce.h if_bce.c miibus_if.h miidevs.h device_if.h bus_if.h pci_if.h #CFLAGS += -DBCE_DEBUG=0 -clean: - rm -f opt_bdg.h device_if.h bus_if.h pci_if.h export_syms - rm -f *.o *.kld *.ko - rm -f @ machine x86 miibus_if.h miidevs.h opt_bce.h - .include diff --git a/sys/modules/bxe/Makefile b/sys/modules/bxe/Makefile index dff22bdc6a8f..b2e32f7db05c 100644 --- a/sys/modules/bxe/Makefile +++ b/sys/modules/bxe/Makefile @@ -18,9 +18,4 @@ SRCS += bxe.c \ CFLAGS += -I${BXE} -clean: - rm -f opt_bdg.h device_if.h bus_if.h pci_if.h export_syms - rm -f *.o *.kld *.ko - rm -f @ machine x86 - .include diff --git a/sys/modules/drm2/i915kms/Makefile b/sys/modules/drm2/i915kms/Makefile index 75f08d24182b..61657c61661c 100644 --- a/sys/modules/drm2/i915kms/Makefile +++ b/sys/modules/drm2/i915kms/Makefile @@ -7,6 +7,7 @@ SRCS = \ i915_dma.c \ i915_drv.c \ i915_gem.c \ + i915_gem_context.c \ i915_gem_execbuffer.c \ i915_gem_evict.c \ i915_gem_gtt.c \ diff --git a/sys/modules/fdc/Makefile b/sys/modules/fdc/Makefile index 43b85f50cf11..40eb42719379 100644 --- a/sys/modules/fdc/Makefile +++ b/sys/modules/fdc/Makefile @@ -2,11 +2,10 @@ KMOD= fdc +.PATH: ${.CURDIR}/../../dev/fdc .if ${MACHINE} == "pc98" -.PATH: ${.CURDIR}/../../pc98/cbus SRCS= fdc.c fdc_cbus.c .else -.PATH: ${.CURDIR}/../../dev/fdc SRCS= fdc.c fdc_isa.c fdc_pccard.c .if ${MACHINE} == "i386" || ${MACHINE} == "amd64" SRCS+= opt_acpi.h acpi_if.h fdc_acpi.c diff --git a/sys/modules/hyperv/utilities/Makefile b/sys/modules/hyperv/utilities/Makefile index 57a242801449..f94e4410aecd 100644 --- a/sys/modules/hyperv/utilities/Makefile +++ b/sys/modules/hyperv/utilities/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../../dev/hyperv/utilities KMOD= hv_utils -SRCS= hv_util.c +SRCS= hv_util.c hv_kvp.c SRCS+= bus_if.h device_if.h CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \ diff --git a/sys/modules/i2c/controllers/alpm/Makefile b/sys/modules/i2c/controllers/alpm/Makefile index 885b983a8998..adddfb796f39 100644 --- a/sys/modules/i2c/controllers/alpm/Makefile +++ b/sys/modules/i2c/controllers/alpm/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../pci +.PATH: ${.CURDIR}/../../../../dev/alpm KMOD = alpm SRCS = device_if.h bus_if.h iicbus_if.h smbus_if.h pci_if.h \ alpm.c diff --git a/sys/modules/i2c/controllers/amdpm/Makefile b/sys/modules/i2c/controllers/amdpm/Makefile index 5f6d7ed295ba..2f6fcec1201b 100644 --- a/sys/modules/i2c/controllers/amdpm/Makefile +++ b/sys/modules/i2c/controllers/amdpm/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../pci +.PATH: ${.CURDIR}/../../../../dev/amdpm KMOD = amdpm SRCS = device_if.h bus_if.h pci_if.h smbus_if.h \ amdpm.c diff --git a/sys/modules/i2c/controllers/amdsmb/Makefile b/sys/modules/i2c/controllers/amdsmb/Makefile index d7306cebf689..43d1122b9751 100644 --- a/sys/modules/i2c/controllers/amdsmb/Makefile +++ b/sys/modules/i2c/controllers/amdsmb/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../pci +.PATH: ${.CURDIR}/../../../../dev/amdsmb KMOD= amdsmb SRCS= amdsmb.c diff --git a/sys/modules/i2c/controllers/intpm/Makefile b/sys/modules/i2c/controllers/intpm/Makefile index 7cef578707b9..73d5254076ee 100644 --- a/sys/modules/i2c/controllers/intpm/Makefile +++ b/sys/modules/i2c/controllers/intpm/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../pci +.PATH: ${.CURDIR}/../../../../dev/intpm KMOD = intpm SRCS = device_if.h bus_if.h iicbus_if.h smbus_if.h pci_if.h \ opt_intpm.h intpmreg.h intpm.c diff --git a/sys/modules/i2c/controllers/nfsmb/Makefile b/sys/modules/i2c/controllers/nfsmb/Makefile index 21b67f3196f9..bb2a0f2fe5a1 100644 --- a/sys/modules/i2c/controllers/nfsmb/Makefile +++ b/sys/modules/i2c/controllers/nfsmb/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../pci +.PATH: ${.CURDIR}/../../../../dev/nfsmb KMOD= nfsmb SRCS= nfsmb.c diff --git a/sys/modules/i2c/controllers/viapm/Makefile b/sys/modules/i2c/controllers/viapm/Makefile index 37100301b84a..f08b053c2cfa 100644 --- a/sys/modules/i2c/controllers/viapm/Makefile +++ b/sys/modules/i2c/controllers/viapm/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../pci +.PATH: ${.CURDIR}/../../../../dev/viapm KMOD = viapm SRCS = device_if.h bus_if.h iicbb_if.h isa_if.h pci_if.h smbus_if.h \ opt_isa.h viapm.c diff --git a/sys/modules/if_gif/Makefile b/sys/modules/if_gif/Makefile index fd1ace27ebb0..9e2ae973adbc 100644 --- a/sys/modules/if_gif/Makefile +++ b/sys/modules/if_gif/Makefile @@ -9,7 +9,7 @@ KMOD= if_gif SRCS= if_gif.c in_gif.c opt_inet.h opt_inet6.h opt_mrouting.h .if defined(KERNBUILDDIR) -OPT_INET6!= cat ${KERNBUILDDIR}/opt_inet6.h +OPT_INET6!= cat ${KERNBUILDDIR}/opt_inet6.h; echo .if empty(OPT_INET6) MK_INET6_SUPPORT=no .endif diff --git a/sys/modules/ixgbe/Makefile b/sys/modules/ixgbe/Makefile index 16bee5b1e1d0..923e2174d02c 100644 --- a/sys/modules/ixgbe/Makefile +++ b/sys/modules/ixgbe/Makefile @@ -10,6 +10,6 @@ SRCS += ixgbe.c ixv.c SRCS += ixgbe_common.c ixgbe_api.c ixgbe_phy.c ixgbe_mbx.c ixgbe_vf.c SRCS += ixgbe_dcb.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c SRCS += ixgbe_82599.c ixgbe_82598.c ixgbe_x540.c -CFLAGS+= -I${.CURDIR}/../../dev/ixgbe -DSMP -DIXGBE_FDIR +CFLAGS+= -I${.CURDIR}/../../dev/ixgbe -DSMP .include diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index 25615a7464b8..e02ac880a611 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -13,6 +13,7 @@ SRCS= linux_fork.c linux${SFX}_dummy.c linux_emul.c linux_file.c \ linux${SFX}_machdep.c linux_mib.c linux_misc.c linux_signal.c \ linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \ linux${SFX}_sysvec.c linux_uid16.c linux_util.c linux_time.c \ + linux_timer.c \ opt_inet6.h opt_compat.h opt_posix.h opt_usb.h vnode_if.h \ device_if.h bus_if.h assym.s diff --git a/sys/modules/mlx4/Makefile b/sys/modules/mlx4/Makefile index dec1ba955f68..1087123dd535 100644 --- a/sys/modules/mlx4/Makefile +++ b/sys/modules/mlx4/Makefile @@ -2,7 +2,7 @@ .PATH: ${.CURDIR}/../../ofed/drivers/net/mlx4 .PATH: ${.CURDIR}/../../ofed/include/linux KMOD = mlx4 -SRCS = device_if.h bus_if.h pci_if.h vnode_if.h +SRCS = device_if.h bus_if.h pci_if.h vnode_if.h opt_inet.h opt_inet6.h SRCS+= alloc.c catas.c cmd.c cq.c eq.c fw.c icm.c intf.c main.c mcg.c mr.c linux_compat.c linux_radix.c linux_idr.c SRCS+= pd.c port.c profile.c qp.c reset.c sense.c srq.c resource_tracker.c sys_tune.c diff --git a/sys/modules/mlxen/Makefile b/sys/modules/mlxen/Makefile index 4e1415d8578f..258cf7e7bf98 100644 --- a/sys/modules/mlxen/Makefile +++ b/sys/modules/mlxen/Makefile @@ -3,8 +3,8 @@ KMOD = mlxen SRCS = device_if.h bus_if.h pci_if.h vnode_if.h -SRCS += en_cq.c en_frag.c en_main.c en_netdev.c en_port.c en_resources.c -SRCS += en_rx.c en_tx.c +SRCS += en_cq.c en_main.c en_netdev.c en_port.c en_resources.c +SRCS += en_rx.c en_tx.c utils.c SRCS += opt_inet.h opt_inet6.h CFLAGS+= -I${.CURDIR}/../../ofed/drivers/net/mlx4 CFLAGS+= -I${.CURDIR}/../../ofed/include/ diff --git a/sys/modules/ncr/Makefile b/sys/modules/ncr/Makefile new file mode 100644 index 000000000000..7ba6c68381a5 --- /dev/null +++ b/sys/modules/ncr/Makefile @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/ncr + +KMOD= ncr +SRCS= ncr.c +SRCS+= device_if.h bus_if.h pci_if.h opt_ncr.h opt_cam.h + +.include diff --git a/sys/modules/netmap/Makefile b/sys/modules/netmap/Makefile index 647cd103600f..8e5364bbe7a2 100644 --- a/sys/modules/netmap/Makefile +++ b/sys/modules/netmap/Makefile @@ -16,5 +16,6 @@ SRCS += netmap_vale.c SRCS += netmap_freebsd.c SRCS += netmap_offloadings.c SRCS += netmap_pipe.c +SRCS += netmap_monitor.c .include diff --git a/sys/modules/rl/Makefile b/sys/modules/rl/Makefile index e846579a8ed7..16046adc59bb 100644 --- a/sys/modules/rl/Makefile +++ b/sys/modules/rl/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../pci +.PATH: ${.CURDIR}/../../dev/rl KMOD= if_rl SRCS= if_rl.c device_if.h bus_if.h pci_if.h diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile index 76f9364433fb..702587bb72c1 100644 --- a/sys/modules/vmm/Makefile +++ b/sys/modules/vmm/Makefile @@ -19,7 +19,6 @@ SRCS+= vmm.c \ vmm_ipi.c \ vmm_lapic.c \ vmm_mem.c \ - vmm_msr.c \ vmm_stat.c \ vmm_util.c \ x86.c \ diff --git a/sys/modules/zfs/Makefile b/sys/modules/zfs/Makefile index 3e857264d1b9..ad9f398e057d 100644 --- a/sys/modules/zfs/Makefile +++ b/sys/modules/zfs/Makefile @@ -21,6 +21,7 @@ SRCS+= u8_textprep.c .PATH: ${SYSDIR}/cddl/compat/opensolaris/kern SRCS+= opensolaris_acl.c +SRCS+= opensolaris_dtrace.c SRCS+= opensolaris_kobj.c SRCS+= opensolaris_kstat.c SRCS+= opensolaris_lookup.c @@ -93,8 +94,10 @@ CFLAGS+=-DBUILDING_ZFS CFLAGS+=-mminimal-toc .endif -#CFLAGS+=-DDEBUG=1 -#DEBUG_FLAGS=-g +.ifdef ZFS_DEBUG +CFLAGS+=-DDEBUG=1 +DEBUG_FLAGS=-g +.endif .include diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index 12cc72176187..548e81b8baa8 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -190,14 +190,15 @@ static const char *lacp_format_portid(const struct lacp_portid *, char *, static void lacp_dprintf(const struct lacp_port *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -static int lacp_debug = 0; +static VNET_DEFINE(int, lacp_debug); +#define V_lacp_debug VNET(lacp_debug) SYSCTL_NODE(_net_link_lagg, OID_AUTO, lacp, CTLFLAG_RD, 0, "ieee802.3ad"); -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RWTUN, - &lacp_debug, 0, "Enable LACP debug logging (1=debug, 2=trace)"); +SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RWTUN | CTLFLAG_VNET, + &VNET_NAME(lacp_debug), 0, "Enable LACP debug logging (1=debug, 2=trace)"); -#define LACP_DPRINTF(a) if (lacp_debug & 0x01) { lacp_dprintf a ; } -#define LACP_TRACE(a) if (lacp_debug & 0x02) { lacp_dprintf(a,"%s\n",__func__); } -#define LACP_TPRINTF(a) if (lacp_debug & 0x04) { lacp_dprintf a ; } +#define LACP_DPRINTF(a) if (V_lacp_debug & 0x01) { lacp_dprintf a ; } +#define LACP_TRACE(a) if (V_lacp_debug & 0x02) { lacp_dprintf(a,"%s\n",__func__); } +#define LACP_TPRINTF(a) if (V_lacp_debug & 0x04) { lacp_dprintf a ; } /* * partner administration variables. @@ -300,7 +301,7 @@ lacp_pdu_input(struct lacp_port *lp, struct mbuf *m) goto bad; } - if (lacp_debug > 0) { + if (V_lacp_debug > 0) { lacp_dprintf(lp, "lacpdu receive\n"); lacp_dump_lacpdu(du); } @@ -385,7 +386,7 @@ lacp_xmit_lacpdu(struct lacp_port *lp) sizeof(du->ldu_collector)); du->ldu_collector.lci_maxdelay = 0; - if (lacp_debug > 0) { + if (V_lacp_debug > 0) { lacp_dprintf(lp, "lacpdu transmit\n"); lacp_dump_lacpdu(du); } @@ -497,12 +498,14 @@ lacp_tick(void *arg) if ((lp->lp_state & LACP_STATE_AGGREGATION) == 0) continue; + CURVNET_SET(lp->lp_ifp->if_vnet); lacp_run_timers(lp); lacp_select(lp); lacp_sm_mux(lp); lacp_sm_tx(lp); lacp_sm_ptx_tx_schedule(lp); + CURVNET_RESTORE(); } callout_reset(&lsc->lsc_callout, hz, lacp_tick, lsc); } @@ -528,7 +531,8 @@ lacp_port_create(struct lagg_port *lgp) LLADDR(&sdl), ETHER_ADDR_LEN); error = if_addmulti(ifp, (struct sockaddr *)&sdl, &rifma); if (error) { - printf("%s: ADDMULTI failed on %s\n", __func__, lgp->lp_ifname); + printf("%s: ADDMULTI failed on %s\n", __func__, + lgp->lp_ifp->if_xname); return (error); } @@ -538,7 +542,7 @@ lacp_port_create(struct lagg_port *lgp) return (ENOMEM); LACP_LOCK(lsc); - lgp->lp_psc = (caddr_t)lp; + lgp->lp_psc = lp; lp->lp_ifp = ifp; lp->lp_lagg = lgp; lp->lp_lsc = lsc; @@ -585,7 +589,7 @@ lacp_port_destroy(struct lagg_port *lgp) } void -lacp_req(struct lagg_softc *sc, caddr_t data) +lacp_req(struct lagg_softc *sc, void *data) { struct lacp_opreq *req = (struct lacp_opreq *)data; struct lacp_softc *lsc = LACP_SOFTC(sc); @@ -593,7 +597,7 @@ lacp_req(struct lagg_softc *sc, caddr_t data) bzero(req, sizeof(struct lacp_opreq)); - /* + /* * If the LACP softc is NULL, return with the opreq structure full of * zeros. It is normal for the softc to be NULL while the lagg is * being destroyed. @@ -624,7 +628,7 @@ lacp_req(struct lagg_softc *sc, caddr_t data) } void -lacp_portreq(struct lagg_port *lgp, caddr_t data) +lacp_portreq(struct lagg_port *lgp, void *data) { struct lacp_opreq *req = (struct lacp_opreq *)data; struct lacp_port *lp = LACP_PORT(lgp); @@ -746,55 +750,14 @@ lacp_transit_expire(void *vp) lsc->lsc_suppress_distributing = FALSE; } -static void -lacp_attach_sysctl(struct lacp_softc *lsc, struct sysctl_oid *p_oid) -{ - struct lagg_softc *sc = lsc->lsc_softc; - - SYSCTL_ADD_UINT(&sc->ctx, SYSCTL_CHILDREN(p_oid), OID_AUTO, - "lacp_strict_mode", - CTLFLAG_RW, - &lsc->lsc_strict_mode, - lsc->lsc_strict_mode, - "Enable LACP strict mode"); -} - -static void -lacp_attach_sysctl_debug(struct lacp_softc *lsc, struct sysctl_oid *p_oid) -{ - struct lagg_softc *sc = lsc->lsc_softc; - struct sysctl_oid *oid; - - /* Create a child of the parent lagg interface */ - oid = SYSCTL_ADD_NODE(&sc->ctx, SYSCTL_CHILDREN(p_oid), - OID_AUTO, "debug", CTLFLAG_RD, NULL, "DEBUG"); - - SYSCTL_ADD_UINT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "rx_test", - CTLFLAG_RW, - &lsc->lsc_debug.lsc_rx_test, - lsc->lsc_debug.lsc_rx_test, - "Bitmap of if_dunit entries to drop RX frames for"); - SYSCTL_ADD_UINT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "tx_test", - CTLFLAG_RW, - &lsc->lsc_debug.lsc_tx_test, - lsc->lsc_debug.lsc_tx_test, - "Bitmap of if_dunit entries to drop TX frames for"); -} - -int +void lacp_attach(struct lagg_softc *sc) { struct lacp_softc *lsc; - struct sysctl_oid *oid; - lsc = malloc(sizeof(struct lacp_softc), - M_DEVBUF, M_NOWAIT|M_ZERO); - if (lsc == NULL) - return (ENOMEM); + lsc = malloc(sizeof(struct lacp_softc), M_DEVBUF, M_WAITOK | M_ZERO); - sc->sc_psc = (caddr_t)lsc; + sc->sc_psc = lsc; lsc->lsc_softc = sc; lsc->lsc_hashkey = arc4random(); @@ -804,41 +767,29 @@ lacp_attach(struct lagg_softc *sc) TAILQ_INIT(&lsc->lsc_aggregators); LIST_INIT(&lsc->lsc_ports); - /* Create a child of the parent lagg interface */ - oid = SYSCTL_ADD_NODE(&sc->ctx, SYSCTL_CHILDREN(sc->sc_oid), - OID_AUTO, "lacp", CTLFLAG_RD, NULL, "LACP"); - - /* Attach sysctl nodes */ - lacp_attach_sysctl(lsc, oid); - lacp_attach_sysctl_debug(lsc, oid); - callout_init_mtx(&lsc->lsc_transit_callout, &lsc->lsc_mtx, 0); callout_init_mtx(&lsc->lsc_callout, &lsc->lsc_mtx, 0); /* if the lagg is already up then do the same */ if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) lacp_init(sc); - - return (0); } -int -lacp_detach(struct lagg_softc *sc) +void +lacp_detach(void *psc) { - struct lacp_softc *lsc = LACP_SOFTC(sc); + struct lacp_softc *lsc = (struct lacp_softc *)psc; KASSERT(TAILQ_EMPTY(&lsc->lsc_aggregators), ("aggregators still active")); KASSERT(lsc->lsc_active_aggregator == NULL, ("aggregator still attached")); - sc->sc_psc = NULL; callout_drain(&lsc->lsc_transit_callout); callout_drain(&lsc->lsc_callout); LACP_LOCK_DESTROY(lsc); free(lsc, M_DEVBUF); - return (0); } void @@ -881,7 +832,7 @@ lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m) return (NULL); } - if (sc->use_flowid && (m->m_flags & M_FLOWID)) + if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && (m->m_flags & M_FLOWID)) hash = m->m_pkthdr.flowid >> sc->flowid_shift; else hash = lagg_hashmbuf(sc, m, lsc->lsc_hashkey); @@ -993,13 +944,13 @@ lacp_select_active_aggregator(struct lacp_softc *lsc) lacp_format_lagid_aggregator(la, buf, sizeof(buf)), speed, la->la_nports)); - /* This aggregator is chosen if - * the partner has a better system priority - * or, the total aggregated speed is higher - * or, it is already the chosen aggregator + /* + * This aggregator is chosen if the partner has a better + * system priority or, the total aggregated speed is higher + * or, it is already the chosen aggregator */ if ((best_la != NULL && LACP_SYS_PRI(la->la_partner) < - LACP_SYS_PRI(best_la->la_partner)) || + LACP_SYS_PRI(best_la->la_partner)) || speed > best_speed || (speed == best_speed && la == lsc->lsc_active_aggregator)) { @@ -1380,7 +1331,7 @@ lacp_sm_mux(struct lacp_port *lp) enum lacp_selected selected = lp->lp_selected; struct lacp_aggregator *la; - if (lacp_debug > 1) + if (V_lacp_debug > 1) lacp_dprintf(lp, "%s: state= 0x%x, selected= 0x%x, " "p_sync= 0x%x, p_collecting= 0x%x\n", __func__, lp->lp_mux_state, selected, p_sync, p_collecting); diff --git a/sys/net/ieee8023ad_lacp.h b/sys/net/ieee8023ad_lacp.h index ca5f76eaaba9..535cf1fd1dfa 100644 --- a/sys/net/ieee8023ad_lacp.h +++ b/sys/net/ieee8023ad_lacp.h @@ -282,15 +282,15 @@ struct lacp_softc { struct mbuf *lacp_input(struct lagg_port *, struct mbuf *); struct lagg_port *lacp_select_tx_port(struct lagg_softc *, struct mbuf *); -int lacp_attach(struct lagg_softc *); -int lacp_detach(struct lagg_softc *); +void lacp_attach(struct lagg_softc *); +void lacp_detach(void *); void lacp_init(struct lagg_softc *); void lacp_stop(struct lagg_softc *); int lacp_port_create(struct lagg_port *); void lacp_port_destroy(struct lagg_port *); void lacp_linkstate(struct lagg_port *); -void lacp_req(struct lagg_softc *, caddr_t); -void lacp_portreq(struct lagg_port *, caddr_t); +void lacp_req(struct lagg_softc *, void *); +void lacp_portreq(struct lagg_port *, void *); static __inline int lacp_isactive(struct lagg_port *lgp) diff --git a/sys/net/if.c b/sys/net/if.c index 06993e3cb46e..a7fb2a95feec 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -468,6 +468,10 @@ if_alloc(u_char type) refcount_init(&ifp->if_refcount, 1); /* Index reference. */ ifnet_setbyindex(ifp->if_index, ifp); + + for (int i = 0; i < IFCOUNTERS; i++) + ifp->if_counters[i] = counter_u64_alloc(M_WAITOK); + return (ifp); } @@ -495,6 +499,10 @@ if_free_internal(struct ifnet *ifp) IF_AFDATA_DESTROY(ifp); IF_ADDR_LOCK_DESTROY(ifp); ifq_delete(&ifp->if_snd); + + for (int i = 0; i < IFCOUNTERS; i++) + counter_u64_free(ifp->if_counters[i]); + free(ifp, M_IFNET); } @@ -584,6 +592,57 @@ if_attach(struct ifnet *ifp) if_attach_internal(ifp, 0); } +/* + * Compute the least common TSO limit. + */ +void +if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *pmax) +{ + /* + * 1) If there is no limit currently, take the limit from + * the network adapter. + * + * 2) If the network adapter has a limit below the current + * limit, apply it. + */ + if (pmax->tsomaxbytes == 0 || (ifp->if_hw_tsomax != 0 && + ifp->if_hw_tsomax < pmax->tsomaxbytes)) { + pmax->tsomaxbytes = ifp->if_hw_tsomax; + } + if (pmax->tsomaxsegcount == 0 || (ifp->if_hw_tsomaxsegcount != 0 && + ifp->if_hw_tsomaxsegcount < pmax->tsomaxsegcount)) { + pmax->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; + } + if (pmax->tsomaxsegsize == 0 || (ifp->if_hw_tsomaxsegsize != 0 && + ifp->if_hw_tsomaxsegsize < pmax->tsomaxsegsize)) { + pmax->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; + } +} + +/* + * Update TSO limit of a network adapter. + * + * Returns zero if no change. Else non-zero. + */ +int +if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsomax *pmax) +{ + int retval = 0; + if (ifp->if_hw_tsomax != pmax->tsomaxbytes) { + ifp->if_hw_tsomax = pmax->tsomaxbytes; + retval++; + } + if (ifp->if_hw_tsomaxsegsize != pmax->tsomaxsegsize) { + ifp->if_hw_tsomaxsegsize = pmax->tsomaxsegsize; + retval++; + } + if (ifp->if_hw_tsomaxsegcount != pmax->tsomaxsegcount) { + ifp->if_hw_tsomaxsegcount = pmax->tsomaxsegcount; + retval++; + } + return (retval); +} + static void if_attach_internal(struct ifnet *ifp, int vmove) { @@ -616,7 +675,7 @@ if_attach_internal(struct ifnet *ifp, int vmove) } if (ifp->if_get_counter == NULL) - ifp->if_get_counter = if_get_counter_compat; + ifp->if_get_counter = if_get_counter_default; if (!vmove) { #ifdef MAC @@ -659,13 +718,36 @@ if_attach_internal(struct ifnet *ifp, int vmove) ifp->if_broadcastaddr = NULL; #if defined(INET) || defined(INET6) - /* Initialize to max value. */ - if (ifp->if_hw_tsomax == 0) - ifp->if_hw_tsomax = min(IP_MAXPACKET, 32 * MCLBYTES - + /* Use defaults for TSO, if nothing is set */ + if (ifp->if_hw_tsomax == 0 && + ifp->if_hw_tsomaxsegcount == 0 && + ifp->if_hw_tsomaxsegsize == 0) { + /* + * The TSO defaults needs to be such that an + * NFS mbuf list of 35 mbufs totalling just + * below 64K works and that a chain of mbufs + * can be defragged into at most 32 segments: + */ + ifp->if_hw_tsomax = min(IP_MAXPACKET, (32 * MCLBYTES) - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN)); - KASSERT(ifp->if_hw_tsomax <= IP_MAXPACKET && - ifp->if_hw_tsomax >= IP_MAXPACKET / 8, - ("%s: tsomax outside of range", __func__)); + ifp->if_hw_tsomaxsegcount = 35; + ifp->if_hw_tsomaxsegsize = 2048; /* 2K */ + + /* XXX some drivers set IFCAP_TSO after ethernet attach */ + if (ifp->if_capabilities & IFCAP_TSO) { + if_printf(ifp, "Using defaults for TSO: %u/%u/%u\n", + ifp->if_hw_tsomax, + ifp->if_hw_tsomaxsegcount, + ifp->if_hw_tsomaxsegsize); + } + } + /* + * If the "if_hw_tsomax" limit is set, check if it is + * too small: + */ + KASSERT(ifp->if_hw_tsomax == 0 || + ifp->if_hw_tsomax >= (IP_MAXPACKET / 8), + ("%s: if_hw_tsomax is outside of range", __func__)); #endif } #ifdef VIMAGE @@ -1386,39 +1468,28 @@ if_rtdel(struct radix_node *rn, void *arg) } /* - * Return counter values from old racy non-pcpu counters. + * Return counter values from counter(9)s stored in ifnet. */ uint64_t -if_get_counter_compat(struct ifnet *ifp, ifnet_counter cnt) +if_get_counter_default(struct ifnet *ifp, ift_counter cnt) { - switch (cnt) { - case IFCOUNTER_IPACKETS: - return (ifp->if_ipackets); - case IFCOUNTER_IERRORS: - return (ifp->if_ierrors); - case IFCOUNTER_OPACKETS: - return (ifp->if_opackets); - case IFCOUNTER_OERRORS: - return (ifp->if_oerrors); - case IFCOUNTER_COLLISIONS: - return (ifp->if_collisions); - case IFCOUNTER_IBYTES: - return (ifp->if_ibytes); - case IFCOUNTER_OBYTES: - return (ifp->if_obytes); - case IFCOUNTER_IMCASTS: - return (ifp->if_imcasts); - case IFCOUNTER_OMCASTS: - return (ifp->if_omcasts); - case IFCOUNTER_IQDROPS: - return (ifp->if_iqdrops); - case IFCOUNTER_OQDROPS: - return (ifp->if_oqdrops); - case IFCOUNTER_NOPROTO: - return (ifp->if_noproto); - } - panic("%s: unknown counter %d", __func__, cnt); + KASSERT(cnt < IFCOUNTERS, ("%s: invalid cnt %d", __func__, cnt)); + + return (counter_u64_fetch(ifp->if_counters[cnt])); +} + +/* + * Increase an ifnet counter. Usually used for counters shared + * between the stack and a driver, but function supports them all. + */ +void +if_inc_counter(struct ifnet *ifp, ift_counter cnt, int64_t inc) +{ + + KASSERT(cnt < IFCOUNTERS, ("%s: invalid cnt %d", __func__, cnt)); + + counter_u64_add(ifp->if_counters[cnt], inc); } /* @@ -1694,13 +1765,15 @@ ifa_ifwithaddr_check(struct sockaddr *addr) */ /* ARGSUSED */ struct ifaddr * -ifa_ifwithbroadaddr(struct sockaddr *addr) +ifa_ifwithbroadaddr(struct sockaddr *addr, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { + if ((fibnum != RT_ALL_FIBS) && (ifp->if_fib != fibnum)) + continue; IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != addr->sa_family) @@ -1727,7 +1800,7 @@ ifa_ifwithbroadaddr(struct sockaddr *addr) */ /*ARGSUSED*/ struct ifaddr * -ifa_ifwithdstaddr_fib(struct sockaddr *addr, int fibnum) +ifa_ifwithdstaddr(struct sockaddr *addr, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1757,19 +1830,12 @@ ifa_ifwithdstaddr_fib(struct sockaddr *addr, int fibnum) return (ifa); } -struct ifaddr * -ifa_ifwithdstaddr(struct sockaddr *addr) -{ - - return (ifa_ifwithdstaddr_fib(addr, RT_ALL_FIBS)); -} - /* * Find an interface on a specific network. If many, choice * is most specific found. */ struct ifaddr * -ifa_ifwithnet_fib(struct sockaddr *addr, int ignore_ptp, int fibnum) +ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1867,13 +1933,6 @@ next: continue; return (ifa); } -struct ifaddr * -ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp) -{ - - return (ifa_ifwithnet_fib(addr, ignore_ptp, RT_ALL_FIBS)); -} - /* * Find an interface address specific to an interface best matching * a given address. @@ -3483,15 +3542,15 @@ if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust) IF_LOCK(ifq); if (_IF_QFULL(ifq)) { - _IF_DROP(ifq); IF_UNLOCK(ifq); + if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); m_freem(m); return (0); } if (ifp != NULL) { - ifp->if_obytes += m->m_pkthdr.len + adjust; + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len + adjust); if (m->m_flags & (M_BCAST|M_MCAST)) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); active = ifp->if_drv_flags & IFF_DRV_OACTIVE; } _IF_ENQUEUE(ifq, m); @@ -3735,139 +3794,12 @@ if_getvtag(struct mbuf *m) return (m->m_pkthdr.ether_vtag); } -/* Statistics */ -int -if_incipackets(if_t ifp, int pkts) -{ - ((struct ifnet *)ifp)->if_ipackets += pkts; - return (0); -} - -int -if_incopackets(if_t ifp, int pkts) -{ - ((struct ifnet *)ifp)->if_opackets += pkts; - return (0); -} - -int -if_incierrors(if_t ifp, int ierrors) -{ - ((struct ifnet *)ifp)->if_ierrors += ierrors; - return (0); -} - - -int -if_setierrors(if_t ifp, int ierrors) -{ - ((struct ifnet *)ifp)->if_ierrors = ierrors; - return (0); -} - -int -if_setoerrors(if_t ifp, int oerrors) -{ - ((struct ifnet *)ifp)->if_oerrors = oerrors; - return (0); -} - -int if_incoerrors(if_t ifp, int oerrors) -{ - ((struct ifnet *)ifp)->if_oerrors += oerrors; - return (0); -} - -int if_inciqdrops(if_t ifp, int val) -{ - ((struct ifnet *)ifp)->if_iqdrops += val; - return (0); -} - -int -if_setcollisions(if_t ifp, int collisions) -{ - ((struct ifnet *)ifp)->if_collisions = collisions; - return (0); -} - -int -if_inccollisions(if_t ifp, int collisions) -{ - ((struct ifnet *)ifp)->if_collisions += collisions; - return (0); -} - -int -if_setipackets(if_t ifp, int pkts) -{ - ((struct ifnet *)ifp)->if_ipackets = pkts; - return (0); -} - -int -if_setopackets(if_t ifp, int pkts) -{ - ((struct ifnet *)ifp)->if_opackets = pkts; - return (0); -} - -int -if_incobytes(if_t ifp, int bytes) -{ - ((struct ifnet *)ifp)->if_obytes += bytes; - return (0); -} - -int -if_setibytes(if_t ifp, int bytes) -{ - ((struct ifnet *)ifp)->if_ibytes = bytes; - return (0); -} - -int -if_setobytes(if_t ifp, int bytes) -{ - ((struct ifnet *)ifp)->if_obytes = bytes; - return (0); -} - - int if_sendq_empty(if_t ifp) { return IFQ_DRV_IS_EMPTY(&((struct ifnet *)ifp)->if_snd); } -int if_getiqdrops(if_t ifp) -{ - return ((struct ifnet *)ifp)->if_iqdrops; -} - -int -if_incimcasts(if_t ifp, int mcast) -{ - ((struct ifnet *)ifp)->if_imcasts += mcast; - return (0); -} - - -int -if_incomcasts(if_t ifp, int mcast) -{ - ((struct ifnet *)ifp)->if_omcasts += mcast; - return (0); -} - -int -if_setimcasts(if_t ifp, int mcast) -{ - ((struct ifnet *)ifp)->if_imcasts = mcast; - return (0); -} - - struct ifaddr * if_getifaddr(if_t ifp) { @@ -4057,6 +3989,13 @@ void if_setqflushfn(if_t ifp, if_qflush_fn_t flush_fn) } +void +if_setgetcounterfn(if_t ifp, if_get_counter_t fn) +{ + + ifp->if_get_counter = fn; +} + /* Revisit these - These are inline functions originally. */ int drbr_inuse_drv(if_t ifh, struct buf_ring *br) diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index f59315040abb..617f9ee13d88 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -357,7 +357,7 @@ arc_defrag(struct ifnet *ifp, struct mbuf *m) if (m->m_len < ARC_HDRNEWLEN) { m = m_pullup(m, ARC_HDRNEWLEN); if (m == NULL) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } } @@ -377,7 +377,7 @@ arc_defrag(struct ifnet *ifp, struct mbuf *m) if (m->m_len < ARC_HDRNEWLEN) { m = m_pullup(m, ARC_HDRNEWLEN); if (m == NULL) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return NULL; } } @@ -530,11 +530,11 @@ arc_input(struct ifnet *ifp, struct mbuf *m) return; } - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); if (ah->arc_dhost == arcbroadcastaddr) { m->m_flags |= M_BCAST|M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } atype = ah->arc_type; diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 8bf8534bc851..e1c4a6753973 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -252,7 +252,7 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m, #ifdef MAC mac_ifnet_create_mbuf(ifp, m); #endif - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); if (ng_atm_input_p != NULL) { (*ng_atm_input_p)(ifp, &m, ah, rxhand); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 59d63ee4f227..252404f328e6 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1848,7 +1848,7 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m) if (m == NULL) { if_printf(dst_ifp, "unable to prepend VLAN header\n"); - dst_ifp->if_oerrors++; + if_inc_counter(dst_ifp, IFCOUNTER_OERRORS, 1); continue; } m->m_flags &= ~M_VLANTAG; @@ -1856,14 +1856,14 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m) if ((err = dst_ifp->if_transmit(dst_ifp, m))) { m_freem(m0); - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); break; } - sc->sc_ifp->if_opackets++; - sc->sc_ifp->if_obytes += len; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(sc->sc_ifp, IFCOUNTER_OBYTES, len); if (mflags & M_MCAST) - sc->sc_ifp->if_omcasts++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OMCASTS, 1); } return (err); @@ -1994,7 +1994,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, } else { mc = m_copypacket(m, M_NOWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -2084,8 +2084,8 @@ bridge_forward(struct bridge_softc *sc, struct bridge_iflist *sbif, src_if = m->m_pkthdr.rcvif; ifp = sc->sc_ifp; - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); vlan = VLANTAGOF(m); if ((sbif->bif_flags & IFBIF_STP) && @@ -2137,7 +2137,7 @@ bridge_forward(struct bridge_softc *sc, struct bridge_iflist *sbif, goto drop; /* ...forward it to all interfaces. */ - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); dst_if = NULL; } @@ -2245,8 +2245,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) if ((bifp->if_flags & IFF_MONITOR) != 0) { m->m_pkthdr.rcvif = bifp; ETHER_BPF_MTAP(bifp, m); - bifp->if_ipackets++; - bifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(bifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(bifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); m_freem(m); return (NULL); } @@ -2347,8 +2347,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) ) { \ if ((iface)->if_type == IFT_BRIDGE) { \ ETHER_BPF_MTAP(iface, m); \ - iface->if_ipackets++; \ - iface->if_ibytes += m->m_pkthdr.len; \ + if_inc_counter(iface, IFCOUNTER_IPACKETS, 1); \ + if_inc_counter(iface, IFCOUNTER_IBYTES, m->m_pkthdr.len); \ /* Filter on the physical interface. */ \ if (pfil_local_phys && \ (PFIL_HOOKED(&V_inet_pfil_hook) \ @@ -2478,7 +2478,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if, } else { mc = m_dup(m, M_NOWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -2498,7 +2498,7 @@ bridge_broadcast(struct bridge_softc *sc, struct ifnet *src_if, i = min(mc->m_pkthdr.len, max_protohdr); mc = m_copyup(mc, i, ETHER_ALIGN); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } } @@ -2541,7 +2541,7 @@ bridge_span(struct bridge_softc *sc, struct mbuf *m) mc = m_copypacket(m, M_NOWAIT); if (mc == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); continue; } diff --git a/sys/net/if_debug.c b/sys/net/if_debug.c index e731937462c9..1d198eb925f2 100644 --- a/sys/net/if_debug.c +++ b/sys/net/if_debug.c @@ -79,7 +79,6 @@ if_show_ifnet(struct ifnet *ifp) IF_DB_PRINTF("%p", if_snd.ifq_tail); IF_DB_PRINTF("%d", if_snd.ifq_len); IF_DB_PRINTF("%d", if_snd.ifq_maxlen); - IF_DB_PRINTF("%d", if_snd.ifq_drops); IF_DB_PRINTF("%p", if_snd.ifq_drv_head); IF_DB_PRINTF("%p", if_snd.ifq_drv_tail); IF_DB_PRINTF("%d", if_snd.ifq_drv_len); diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 370cce822e5b..4cce4847d02b 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -174,8 +174,8 @@ discoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m->m_pkthdr.rcvif = ifp; - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); m_freem(m); return (0); diff --git a/sys/net/if_edsc.c b/sys/net/if_edsc.c index 3ee1c6d864af..b75f134c9bc6 100644 --- a/sys/net/if_edsc.c +++ b/sys/net/if_edsc.c @@ -291,8 +291,8 @@ edsc_start(struct ifnet *ifp) /* * Update the interface counters. */ - ifp->if_obytes += m->m_pkthdr.len; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * Finally, just drop the packet. diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 3c5c94ed3e81..13d7e0b30d1a 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -418,7 +418,7 @@ epair_start_locked(struct ifnet *ifp) */ if ((oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || (oifp->if_flags & IFF_UP) ==0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); continue; } @@ -434,15 +434,15 @@ epair_start_locked(struct ifnet *ifp) error = netisr_queue(NETISR_EPAIR, m); CURVNET_RESTORE(); if (!error) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* Someone else received the packet. */ - oifp->if_ipackets++; + if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); } else { /* The packet was freed already. */ epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; ifp->if_drv_flags |= IFF_DRV_OACTIVE; (void) epair_add_ifp_for_draining(ifp); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); EPAIR_REFCOUNT_RELEASE(&sc->refcount); EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, ("%s: ifp=%p sc->refcount not >= 1: %d", @@ -503,7 +503,7 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) oifp = sc->oifp; if ((oifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || (oifp->if_flags & IFF_UP) ==0) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); return (0); } @@ -517,12 +517,12 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) if (ALTQ_IS_ENABLED(&ifp->if_snd)) { ALTQ_ENQUEUE(&ifp->if_snd, m, NULL, error); if (error) - ifp->if_snd.ifq_drops++; + if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); IF_UNLOCK(&ifp->if_snd); if (!error) { - ifp->if_obytes += len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); if (mflags & (M_BCAST|M_MCAST)) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) epair_start_locked(ifp); @@ -556,22 +556,22 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m) error = netisr_queue(NETISR_EPAIR, m); CURVNET_RESTORE(); if (!error) { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * IFQ_HANDOFF_ADJ/ip_handoff() update statistics, * but as we bypass all this we have to duplicate * the logic another time. */ - ifp->if_obytes += len; + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); if (mflags & (M_BCAST|M_MCAST)) - ifp->if_omcasts++; + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); /* Someone else received the packet. */ - oifp->if_ipackets++; + if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); } else { /* The packet was freed already. */ epair_dpcpu->epair_drv_flags |= IFF_DRV_OACTIVE; ifp->if_drv_flags |= IFF_DRV_OACTIVE; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); EPAIR_REFCOUNT_RELEASE(&sc->refcount); EPAIR_REFCOUNT_ASSERT((int)sc->refcount >= 1, ("%s: ifp=%p sc->refcount not >= 1: %d", diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 4c2bd4ecb70b..5f315ec02cb8 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -306,7 +306,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m, update_mbuf_csumflags(m, n); (void)if_simloop(ifp, n, dst->sa_family, hlen); } else - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) == 0) { update_mbuf_csumflags(m, m); @@ -404,7 +404,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) */ if ((m->m_flags & M_PKTHDR) == 0) { if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -413,7 +413,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) if_printf(ifp, "discard frame w/o leading ethernet " "header (len %u pkt len %u)\n", m->m_len, m->m_pkthdr.len); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -421,7 +421,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) etype = ntohs(eh->ether_type); if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -439,7 +439,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } #ifdef MAC @@ -466,7 +466,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) } if (!(ifp->if_capenable & IFCAP_HWSTATS)) - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* Allow monitor mode to claim this frame, after stats are updated. */ if (ifp->if_flags & IFF_MONITOR) { @@ -502,7 +502,7 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m) #ifdef DIAGNOSTIC if_printf(ifp, "cannot pullup VLAN header\n"); #endif - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); CURVNET_RESTORE(); return; @@ -715,7 +715,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m) if ((m->m_flags & M_VLANTAG) && EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) != 0) { if (ifp->if_vlantrunk == NULL) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); m_freem(m); return; } diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 5d22a4a9dbe0..2aeb14adfdbb 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -211,8 +211,8 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, return (rt->rt_flags & RTF_BLACKHOLE ? 0 : rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); switch (af) { #ifdef INET case AF_INET: @@ -232,8 +232,8 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /* XXX do we need more sanity checks? */ m->m_pkthdr.rcvif = ifp; - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); netisr_dispatch(isr, m); return (0); } diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 1680dcac1dd8..4056396b6a68 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -288,12 +288,12 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, error = (ifp->if_transmit)(ifp, m); if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (m) m_freem(m); return (error); @@ -317,20 +317,20 @@ fddi_input(ifp, m) */ if ((m->m_flags & M_PKTHDR) == 0) { if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } m = m_pullup(m, FDDI_HDR_LEN); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } fh = mtod(m, struct fddi_header *); @@ -362,7 +362,7 @@ fddi_input(ifp, m) /* * Update interface statistics. */ - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); getmicrotime(&ifp->if_lastchange); /* @@ -383,7 +383,7 @@ fddi_input(ifp, m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } #ifdef M_LINK0 @@ -401,7 +401,7 @@ fddi_input(ifp, m) m = m_pullup(m, LLC_SNAPFRAMELEN); if (m == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } l = mtod(m, struct llc *); @@ -412,13 +412,13 @@ fddi_input(ifp, m) u_int16_t type; if ((l->llc_control != LLC_UI) || (l->llc_ssap != LLC_SNAP_LSAP)) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } if (l->llc_snap.org_code[0] != 0 || l->llc_snap.org_code[1] != 0 || l->llc_snap.org_code[2] != 0) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } @@ -451,7 +451,7 @@ fddi_input(ifp, m) #endif default: /* printf("fddi_input: unknown protocol 0x%x\n", type); */ - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } break; @@ -459,7 +459,7 @@ fddi_input(ifp, m) default: /* printf("fddi_input: unknown dsap 0x%x\n", l->llc_dsap); */ - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } M_SETFIB(m, ifp->if_fib); @@ -467,7 +467,7 @@ fddi_input(ifp, m) return; dropanyway: - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (m) m_freem(m); return; diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index 5f0f9238794c..39e9cf9fd867 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -537,7 +537,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src) if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } @@ -582,7 +582,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src) return; } - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* Discard packet if interface is not up */ if ((ifp->if_flags & IFF_UP) == 0) { @@ -591,7 +591,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src) } if (m->m_flags & (M_BCAST|M_MCAST)) - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); switch (type) { #ifdef INET diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 6cf04373a4d8..f4cc3d8ca060 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -92,13 +92,20 @@ static const char gifname[] = "gif"; /* - * gif_mtx protects the global gif_softc_list. + * gif_mtx protects a per-vnet gif_softc_list. */ -static struct mtx gif_mtx; +static VNET_DEFINE(struct mtx, gif_mtx); +#define V_gif_mtx VNET(gif_mtx) static MALLOC_DEFINE(M_GIF, "gif", "Generic Tunnel Interface"); static VNET_DEFINE(LIST_HEAD(, gif_softc), gif_softc_list); #define V_gif_softc_list VNET(gif_softc_list) +#define GIF_LIST_LOCK_INIT(x) mtx_init(&V_gif_mtx, "gif_mtx", \ + NULL, MTX_DEF) +#define GIF_LIST_LOCK_DESTROY(x) mtx_destroy(&V_gif_mtx) +#define GIF_LIST_LOCK(x) mtx_lock(&V_gif_mtx) +#define GIF_LIST_UNLOCK(x) mtx_unlock(&V_gif_mtx) + void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp, int af); void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m, int af); void (*ng_gif_attach_p)(struct ifnet *ifp); @@ -107,7 +114,8 @@ void (*ng_gif_detach_p)(struct ifnet *ifp); static void gif_start(struct ifnet *); static int gif_clone_create(struct if_clone *, int, caddr_t); static void gif_clone_destroy(struct ifnet *); -static struct if_clone *gif_cloner; +static VNET_DEFINE(struct if_clone *, gif_cloner); +#define V_gif_cloner VNET(gif_cloner) static int gifmodevent(module_t, int, void *); @@ -189,9 +197,9 @@ gif_clone_create(struct if_clone *ifc, int unit, caddr_t params) if (ng_gif_attach_p != NULL) (*ng_gif_attach_p)(GIF2IFP(sc)); - mtx_lock(&gif_mtx); + GIF_LIST_LOCK(); LIST_INSERT_HEAD(&V_gif_softc_list, sc, gif_list); - mtx_unlock(&gif_mtx); + GIF_LIST_UNLOCK(); return (0); } @@ -204,9 +212,9 @@ gif_clone_destroy(struct ifnet *ifp) #endif struct gif_softc *sc = ifp->if_softc; - mtx_lock(&gif_mtx); + GIF_LIST_LOCK(); LIST_REMOVE(sc, gif_list); - mtx_unlock(&gif_mtx); + GIF_LIST_UNLOCK(); gif_delete_tunnel(ifp); #ifdef INET6 @@ -238,9 +246,22 @@ vnet_gif_init(const void *unused __unused) { LIST_INIT(&V_gif_softc_list); + GIF_LIST_LOCK_INIT(); + V_gif_cloner = if_clone_simple(gifname, gif_clone_create, + gif_clone_destroy, 0); } -VNET_SYSINIT(vnet_gif_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, vnet_gif_init, - NULL); +VNET_SYSINIT(vnet_gif_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_gif_init, NULL); + +static void +vnet_gif_uninit(const void *unused __unused) +{ + + if_clone_detach(V_gif_cloner); + GIF_LIST_LOCK_DESTROY(); +} +VNET_SYSUNINIT(vnet_gif_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_gif_uninit, NULL); static int gifmodevent(module_t mod, int type, void *data) @@ -248,19 +269,12 @@ gifmodevent(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: - mtx_init(&gif_mtx, "gif_mtx", NULL, MTX_DEF); - gif_cloner = if_clone_simple(gifname, gif_clone_create, - gif_clone_destroy, 0); - break; - case MOD_UNLOAD: - if_clone_detach(gif_cloner); - mtx_destroy(&gif_mtx); break; default: - return EOPNOTSUPP; + return (EOPNOTSUPP); } - return 0; + return (0); } static moduledata_t gif_mod = { @@ -364,7 +378,7 @@ gif_start(struct ifnet *ifp) #endif #ifdef INET6 if (sc->gif_psrc->sa_family == AF_INET6) - m->m_pkthdr.len -= GIF_HDR_LEN6; + m->m_pkthdr.len -= GIF_HDR_LEN6; #endif #endif /* @@ -373,15 +387,15 @@ gif_start(struct ifnet *ifp) */ af = m->m_pkthdr.csum_data; + /* override to IPPROTO_ETHERIP for bridged traffic */ if (ifp->if_bridge) af = AF_LINK; BPF_MTAP2(ifp, &af, sizeof(af), m); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* Done by IFQ_HANDOFF */ -/* ifp->if_obytes += m->m_pkthdr.len;*/ - /* override to IPPROTO_ETHERIP for bridged traffic */ +/* if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);*/ M_SETFIB(m, sc->gif_fibnum); /* inner AF-specific encapsulation */ @@ -403,7 +417,7 @@ gif_start(struct ifnet *ifp) error = ENETDOWN; } if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -513,7 +527,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, IFQ_HANDOFF(ifp, m, error); end: if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); } @@ -544,8 +558,8 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) } if ((ifp->if_flags & IFF_MONITOR) != 0) { - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); m_freem(m); return; } @@ -583,7 +597,7 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) if (n > m->m_len) { m = m_pullup(m, n); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return; } } @@ -622,7 +636,7 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } BRIDGE_INPUT(ifp, m); @@ -647,8 +661,8 @@ gif_input(struct mbuf *m, int af, struct ifnet *ifp) return; } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); } @@ -904,7 +918,7 @@ gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst) struct sockaddr *osrc, *odst, *sa; int error = 0; - mtx_lock(&gif_mtx); + GIF_LIST_LOCK(); LIST_FOREACH(sc2, &V_gif_softc_list, gif_list) { if (sc2 == sc) continue; @@ -924,13 +938,13 @@ gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst) bcmp(sc2->gif_pdst, dst, dst->sa_len) == 0 && bcmp(sc2->gif_psrc, src, src->sa_len) == 0) { error = EADDRNOTAVAIL; - mtx_unlock(&gif_mtx); + GIF_LIST_UNLOCK(); goto bad; } /* XXX both end must be valid? (I mean, not 0.0.0.0) */ } - mtx_unlock(&gif_mtx); + GIF_LIST_UNLOCK(); /* XXX we can detach from both, but be polite just in case */ if (sc->gif_psrc) diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 302780a03b8c..8954f5c56ee8 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -102,15 +102,16 @@ struct mtag_gre_nesting { * gre_mtx protects all global variables in if_gre.c. * XXX: gre_softc data not protected yet. */ -struct mtx gre_mtx; +VNET_DEFINE(struct mtx, gre_mtx); +VNET_DEFINE(struct gre_softc_head, gre_softc_list); + static const char grename[] = "gre"; static MALLOC_DEFINE(M_GRE, grename, "Generic Routing Encapsulation"); -struct gre_softc_head gre_softc_list; - static int gre_clone_create(struct if_clone *, int, caddr_t); static void gre_clone_destroy(struct ifnet *); -static struct if_clone *gre_cloner; +static VNET_DEFINE(struct if_clone *, gre_cloner); +#define V_gre_cloner VNET(gre_cloner) static int gre_ioctl(struct ifnet *, u_long, caddr_t); static int gre_output(struct ifnet *, struct mbuf *, @@ -118,8 +119,6 @@ static int gre_output(struct ifnet *, struct mbuf *, static int gre_compute_route(struct gre_softc *sc); -static void greattach(void); - #ifdef INET extern struct domain inetdomain; static const struct protosw in_gre_protosw = { @@ -160,26 +159,34 @@ static SYSCTL_NODE(_net_link, IFT_TUNNEL, gre, CTLFLAG_RW, 0, */ #define MAX_GRE_NEST 1 #endif -static int max_gre_nesting = MAX_GRE_NEST; -SYSCTL_INT(_net_link_gre, OID_AUTO, max_nesting, CTLFLAG_RW, - &max_gre_nesting, 0, "Max nested tunnels"); +static VNET_DEFINE(int, max_gre_nesting) = MAX_GRE_NEST; +#define V_max_gre_nesting VNET(max_gre_nesting) +SYSCTL_INT(_net_link_gre, OID_AUTO, max_nesting, CTLFLAG_RW | CTLFLAG_VNET, + &VNET_NAME(max_gre_nesting), 0, "Max nested tunnels"); -/* ARGSUSED */ static void -greattach(void) +vnet_gre_init(const void *unused __unused) { - - mtx_init(&gre_mtx, "gre_mtx", NULL, MTX_DEF); - LIST_INIT(&gre_softc_list); - gre_cloner = if_clone_simple(grename, gre_clone_create, + LIST_INIT(&V_gre_softc_list); + GRE_LIST_LOCK_INIT(); + V_gre_cloner = if_clone_simple(grename, gre_clone_create, gre_clone_destroy, 0); } +VNET_SYSINIT(vnet_gre_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_gre_init, NULL); + +static void +vnet_gre_uninit(const void *unused __unused) +{ + + if_clone_detach(V_gre_cloner); + GRE_LIST_LOCK_DESTROY(); +} +VNET_SYSUNINIT(vnet_gre_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_gre_uninit, NULL); static int -gre_clone_create(ifc, unit, params) - struct if_clone *ifc; - int unit; - caddr_t params; +gre_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct gre_softc *sc; @@ -210,21 +217,20 @@ gre_clone_create(ifc, unit, params) sc->key = 0; if_attach(GRE2IFP(sc)); bpfattach(GRE2IFP(sc), DLT_NULL, sizeof(u_int32_t)); - mtx_lock(&gre_mtx); - LIST_INSERT_HEAD(&gre_softc_list, sc, sc_list); - mtx_unlock(&gre_mtx); + GRE_LIST_LOCK(); + LIST_INSERT_HEAD(&V_gre_softc_list, sc, sc_list); + GRE_LIST_UNLOCK(); return (0); } static void -gre_clone_destroy(ifp) - struct ifnet *ifp; +gre_clone_destroy(struct ifnet *ifp) { struct gre_softc *sc = ifp->if_softc; - mtx_lock(&gre_mtx); + GRE_LIST_LOCK(); LIST_REMOVE(sc, sc_list); - mtx_unlock(&gre_mtx); + GRE_LIST_UNLOCK(); #ifdef INET if (sc->encap != NULL) @@ -269,7 +275,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, gt = (struct mtag_gre_nesting *)(mtag + 1); gt->count++; - if (gt->count > min(gt->max,max_gre_nesting)) { + if (gt->count > min(gt->max, V_max_gre_nesting)) { printf("%s: hit maximum recursion limit %u on %s\n", __func__, gt->count - 1, ifp->if_xname); m_freem(m); @@ -301,7 +307,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * Note: the sysctl does not actually check for saneness, so we * limit the maximum numbers of possible recursions here. */ - max = imin(max_gre_nesting, 256); + max = imin(V_max_gre_nesting, 256); /* If someone sets the sysctl <= 0, we want at least 1. */ max = imax(max, 1); len = sizeof(struct mtag_gre_nesting) + @@ -361,7 +367,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * be encapsulated. */ if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) { - _IF_DROP(&ifp->if_snd); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EINVAL; /* is there better errno? */ goto end; @@ -390,7 +396,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if ((m->m_data - msiz) < m->m_pktdat) { m0 = m_gethdr(M_NOWAIT, MT_DATA); if (m0 == NULL) { - _IF_DROP(&ifp->if_snd); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = ENOBUFS; goto end; @@ -415,7 +421,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, memcpy((caddr_t)(ip + 1), &mob_h, (unsigned)msiz); ip->ip_len = htons(ntohs(ip->ip_len) + msiz); } else { /* AF_INET */ - _IF_DROP(&ifp->if_snd); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EINVAL; goto end; @@ -440,7 +446,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, break; #endif default: - _IF_DROP(&ifp->if_snd); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EAFNOSUPPORT; goto end; @@ -452,14 +458,14 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, hdrlen += sizeof(uint32_t); M_PREPEND(m, hdrlen, M_NOWAIT); } else { - _IF_DROP(&ifp->if_snd); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); error = EINVAL; goto end; } if (m == NULL) { /* mbuf allocation failed */ - _IF_DROP(&ifp->if_snd); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); error = ENOBUFS; goto end; } @@ -494,8 +500,8 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, gh->gi_len = htons(m->m_pkthdr.len); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* * Send it off and with IP_FORWARD flag to prevent it from * overwriting the ip_id again. ip_id is already set to the @@ -505,7 +511,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, (struct ip_moptions *)NULL, (struct inpcb *)NULL); end: if (error) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); } @@ -909,16 +915,12 @@ gremodevent(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: - greattach(); - break; case MOD_UNLOAD: - if_clone_detach(gre_cloner); - mtx_destroy(&gre_mtx); break; default: - return EOPNOTSUPP; + return (EOPNOTSUPP); } - return 0; + return (0); } static moduledata_t gre_mod = { diff --git a/sys/net/if_gre.h b/sys/net/if_gre.h index 74d16b1c57eb..cb2a44b9d774 100644 --- a/sys/net/if_gre.h +++ b/sys/net/if_gre.h @@ -176,8 +176,16 @@ struct mobip_h { #ifdef _KERNEL LIST_HEAD(gre_softc_head, gre_softc); -extern struct mtx gre_mtx; -extern struct gre_softc_head gre_softc_list; +VNET_DECLARE(struct gre_softc_head, gre_softc_list); +#define V_gre_softc_list VNET(gre_softc_list) + +VNET_DECLARE(struct mtx, gre_mtx); +#define V_gre_mtx VNET(gre_mtx) +#define GRE_LIST_LOCK_INIT(x) mtx_init(&V_gre_mtx, "gre_mtx", NULL, \ + MTX_DEF) +#define GRE_LIST_LOCK_DESTROY(x) mtx_destroy(&V_gre_mtx) +#define GRE_LIST_LOCK(x) mtx_lock(&V_gre_mtx) +#define GRE_LIST_UNLOCK(x) mtx_unlock(&V_gre_mtx) u_int16_t gre_in_cksum(u_int16_t *, u_int); #endif /* _KERNEL */ diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index 2c93b20a7c29..b03b70d79797 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -381,12 +381,12 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, IFQ_HANDOFF_ADJ(ifp, m, ISO88025_HDR_LEN + LLC_SNAPFRAMELEN, error); if (error) { printf("iso88025_output: packet dropped QFULL.\n"); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } return (error); bad: - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (m) m_freem(m); return (error); @@ -411,20 +411,20 @@ iso88025_input(ifp, m) */ if ((m->m_flags & M_PKTHDR) == 0) { if_printf(ifp, "discard frame w/o packet header\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } if (m->m_pkthdr.rcvif == NULL) { if_printf(ifp, "discard frame w/o interface pointer\n"); - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); m_freem(m); return; } m = m_pullup(m, ISO88025_HDR_LEN); if (m == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } th = mtod(m, struct iso88025_header *); @@ -456,7 +456,7 @@ iso88025_input(ifp, m) /* * Update interface statistics. */ - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); getmicrotime(&ifp->if_lastchange); /* @@ -478,7 +478,7 @@ iso88025_input(ifp, m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } mac_hdr_len = ISO88025_HDR_LEN; @@ -491,7 +491,7 @@ iso88025_input(ifp, m) m = m_pullup(m, LLC_SNAPFRAMELEN); if (m == 0) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto dropanyway; } l = mtod(m, struct llc *); @@ -501,14 +501,14 @@ iso88025_input(ifp, m) u_int16_t type; if ((l->llc_control != LLC_UI) || (l->llc_ssap != LLC_SNAP_LSAP)) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } if (l->llc_snap.org_code[0] != 0 || l->llc_snap.org_code[1] != 0 || l->llc_snap.org_code[2] != 0) { - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } @@ -537,7 +537,7 @@ iso88025_input(ifp, m) #endif /* INET6 */ default: printf("iso88025_input: unexpected llc_snap ether_type 0x%02x\n", type); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; } break; @@ -546,7 +546,7 @@ iso88025_input(ifp, m) case LLC_ISO_LSAP: switch (l->llc_control) { case LLC_UI: - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; break; case LLC_XID: @@ -595,7 +595,7 @@ iso88025_input(ifp, m) } default: printf("iso88025_input: unexpected llc control 0x%02x\n", l->llc_control); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; break; } @@ -603,7 +603,7 @@ iso88025_input(ifp, m) #endif /* ISO */ default: printf("iso88025_input: unknown dsap 0x%x\n", l->llc_dsap); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto dropanyway; break; } @@ -613,7 +613,7 @@ iso88025_input(ifp, m) return; dropanyway: - ifp->if_iqdrops++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); if (m) m_freem(m); return; diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 8d53526c6a02..67895de1895a 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -3,6 +3,7 @@ /* * Copyright (c) 2005, 2006 Reyk Floeter * Copyright (c) 2007 Andrew Thompson + * Copyright (c) 2014 Marcelo Araujo * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -50,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #if defined(INET) || defined(INET6) #include @@ -80,13 +82,21 @@ static struct { {0, NULL} }; -SLIST_HEAD(__trhead, lagg_softc) lagg_list; /* list of laggs */ -static struct mtx lagg_list_mtx; +VNET_DEFINE(SLIST_HEAD(__trhead, lagg_softc), lagg_list); /* list of laggs */ +#define V_lagg_list VNET(lagg_list) +static VNET_DEFINE(struct mtx, lagg_list_mtx); +#define V_lagg_list_mtx VNET(lagg_list_mtx) +#define LAGG_LIST_LOCK_INIT(x) mtx_init(&V_lagg_list_mtx, \ + "if_lagg list", NULL, MTX_DEF) +#define LAGG_LIST_LOCK_DESTROY(x) mtx_destroy(&V_lagg_list_mtx) +#define LAGG_LIST_LOCK(x) mtx_lock(&V_lagg_list_mtx) +#define LAGG_LIST_UNLOCK(x) mtx_unlock(&V_lagg_list_mtx) eventhandler_tag lagg_detach_cookie = NULL; static int lagg_clone_create(struct if_clone *, int, caddr_t); static void lagg_clone_destroy(struct ifnet *); -static struct if_clone *lagg_cloner; +static VNET_DEFINE(struct if_clone *, lagg_cloner); +#define V_lagg_cloner VNET(lagg_cloner) static const char laggname[] = "lagg"; static void lagg_lladdr(struct lagg_softc *, uint8_t *); @@ -114,6 +124,7 @@ static int lagg_ether_cmdmulti(struct lagg_port *, int); static int lagg_setflag(struct lagg_port *, int, int, int (*func)(struct ifnet *, int)); static int lagg_setflags(struct lagg_port *, int status); +static uint64_t lagg_get_counter(struct ifnet *ifp, ift_counter cnt); static int lagg_transmit(struct ifnet *, struct mbuf *); static void lagg_qflush(struct ifnet *); static int lagg_media_change(struct ifnet *); @@ -121,25 +132,21 @@ static void lagg_media_status(struct ifnet *, struct ifmediareq *); static struct lagg_port *lagg_link_active(struct lagg_softc *, struct lagg_port *); static const void *lagg_gethdr(struct mbuf *, u_int, u_int, void *); -static int lagg_sysctl_active(SYSCTL_HANDLER_ARGS); /* Simple round robin */ -static int lagg_rr_attach(struct lagg_softc *); -static int lagg_rr_detach(struct lagg_softc *); +static void lagg_rr_attach(struct lagg_softc *); static int lagg_rr_start(struct lagg_softc *, struct mbuf *); static struct mbuf *lagg_rr_input(struct lagg_softc *, struct lagg_port *, struct mbuf *); /* Active failover */ -static int lagg_fail_attach(struct lagg_softc *); -static int lagg_fail_detach(struct lagg_softc *); static int lagg_fail_start(struct lagg_softc *, struct mbuf *); static struct mbuf *lagg_fail_input(struct lagg_softc *, struct lagg_port *, struct mbuf *); /* Loadbalancing */ -static int lagg_lb_attach(struct lagg_softc *); -static int lagg_lb_detach(struct lagg_softc *); +static void lagg_lb_attach(struct lagg_softc *); +static void lagg_lb_detach(struct lagg_softc *); static int lagg_lb_port_create(struct lagg_port *); static void lagg_lb_port_destroy(struct lagg_port *); static int lagg_lb_start(struct lagg_softc *, struct mbuf *); @@ -147,56 +154,141 @@ static struct mbuf *lagg_lb_input(struct lagg_softc *, struct lagg_port *, struct mbuf *); static int lagg_lb_porttable(struct lagg_softc *, struct lagg_port *); +/* Broadcast */ +static int lagg_bcast_start(struct lagg_softc *, struct mbuf *); +static struct mbuf *lagg_bcast_input(struct lagg_softc *, struct lagg_port *, + struct mbuf *); + /* 802.3ad LACP */ -static int lagg_lacp_attach(struct lagg_softc *); -static int lagg_lacp_detach(struct lagg_softc *); +static void lagg_lacp_attach(struct lagg_softc *); +static void lagg_lacp_detach(struct lagg_softc *); static int lagg_lacp_start(struct lagg_softc *, struct mbuf *); static struct mbuf *lagg_lacp_input(struct lagg_softc *, struct lagg_port *, struct mbuf *); static void lagg_lacp_lladdr(struct lagg_softc *); -static void lagg_callout(void *); - /* lagg protocol table */ -static const struct { - int ti_proto; - int (*ti_attach)(struct lagg_softc *); +static const struct lagg_proto { + lagg_proto pr_num; + void (*pr_attach)(struct lagg_softc *); + void (*pr_detach)(struct lagg_softc *); + int (*pr_start)(struct lagg_softc *, struct mbuf *); + struct mbuf * (*pr_input)(struct lagg_softc *, struct lagg_port *, + struct mbuf *); + int (*pr_addport)(struct lagg_port *); + void (*pr_delport)(struct lagg_port *); + void (*pr_linkstate)(struct lagg_port *); + void (*pr_init)(struct lagg_softc *); + void (*pr_stop)(struct lagg_softc *); + void (*pr_lladdr)(struct lagg_softc *); + void (*pr_request)(struct lagg_softc *, void *); + void (*pr_portreq)(struct lagg_port *, void *); } lagg_protos[] = { - { LAGG_PROTO_ROUNDROBIN, lagg_rr_attach }, - { LAGG_PROTO_FAILOVER, lagg_fail_attach }, - { LAGG_PROTO_LOADBALANCE, lagg_lb_attach }, - { LAGG_PROTO_ETHERCHANNEL, lagg_lb_attach }, - { LAGG_PROTO_LACP, lagg_lacp_attach }, - { LAGG_PROTO_NONE, NULL } + { + .pr_num = LAGG_PROTO_NONE + }, + { + .pr_num = LAGG_PROTO_ROUNDROBIN, + .pr_attach = lagg_rr_attach, + .pr_start = lagg_rr_start, + .pr_input = lagg_rr_input, + }, + { + .pr_num = LAGG_PROTO_FAILOVER, + .pr_start = lagg_fail_start, + .pr_input = lagg_fail_input, + }, + { + .pr_num = LAGG_PROTO_LOADBALANCE, + .pr_attach = lagg_lb_attach, + .pr_detach = lagg_lb_detach, + .pr_start = lagg_lb_start, + .pr_input = lagg_lb_input, + .pr_addport = lagg_lb_port_create, + .pr_delport = lagg_lb_port_destroy, + }, + { + .pr_num = LAGG_PROTO_LACP, + .pr_attach = lagg_lacp_attach, + .pr_detach = lagg_lacp_detach, + .pr_start = lagg_lacp_start, + .pr_input = lagg_lacp_input, + .pr_addport = lacp_port_create, + .pr_delport = lacp_port_destroy, + .pr_linkstate = lacp_linkstate, + .pr_init = lacp_init, + .pr_stop = lacp_stop, + .pr_lladdr = lagg_lacp_lladdr, + .pr_request = lacp_req, + .pr_portreq = lacp_portreq, + }, + { + .pr_num = LAGG_PROTO_ETHERCHANNEL, + .pr_attach = lagg_lb_attach, + .pr_detach = lagg_lb_detach, + .pr_start = lagg_lb_start, + .pr_input = lagg_lb_input, + }, + { + .pr_num = LAGG_PROTO_BROADCAST, + .pr_start = lagg_bcast_start, + .pr_input = lagg_bcast_input, + }, }; SYSCTL_DECL(_net_link); SYSCTL_NODE(_net_link, OID_AUTO, lagg, CTLFLAG_RW, 0, "Link Aggregation"); -static int lagg_failover_rx_all = 0; /* Allow input on any failover links */ -SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW, - &lagg_failover_rx_all, 0, +/* Allow input on any failover links */ +static VNET_DEFINE(int, lagg_failover_rx_all); +#define V_lagg_failover_rx_all VNET(lagg_failover_rx_all) +SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW | CTLFLAG_VNET, + &VNET_NAME(lagg_failover_rx_all), 0, "Accept input from any interface in a failover lagg"); -static int def_use_flowid = 1; /* Default value for using M_FLOWID */ + +/* Default value for using M_FLOWID */ +static VNET_DEFINE(int, def_use_flowid) = 1; +#define V_def_use_flowid VNET(def_use_flowid) SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RWTUN, - &def_use_flowid, 0, + &VNET_NAME(def_use_flowid), 0, "Default setting for using flow id for load sharing"); -static int def_flowid_shift = 16; /* Default value for using M_FLOWID */ + +/* Default value for using M_FLOWID */ +static VNET_DEFINE(int, def_flowid_shift) = 16; +#define V_def_flowid_shift VNET(def_flowid_shift) SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN, - &def_flowid_shift, 0, + &VNET_NAME(def_flowid_shift), 0, "Default setting for flowid shift for load sharing"); +static void +vnet_lagg_init(const void *unused __unused) +{ + + LAGG_LIST_LOCK_INIT(); + SLIST_INIT(&V_lagg_list); + V_lagg_cloner = if_clone_simple(laggname, lagg_clone_create, + lagg_clone_destroy, 0); +} +VNET_SYSINIT(vnet_lagg_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_lagg_init, NULL); + +static void +vnet_lagg_uninit(const void *unused __unused) +{ + + if_clone_detach(V_lagg_cloner); + LAGG_LIST_LOCK_DESTROY(); +} +VNET_SYSUNINIT(vnet_lagg_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_lagg_uninit, NULL); + static int lagg_modevent(module_t mod, int type, void *data) { switch (type) { case MOD_LOAD: - mtx_init(&lagg_list_mtx, "if_lagg list", NULL, MTX_DEF); - SLIST_INIT(&lagg_list); - lagg_cloner = if_clone_simple(laggname, lagg_clone_create, - lagg_clone_destroy, 0); lagg_input_p = lagg_input; lagg_linkstate_p = lagg_port_state; lagg_detach_cookie = EVENTHANDLER_REGISTER( @@ -206,10 +298,8 @@ lagg_modevent(module_t mod, int type, void *data) case MOD_UNLOAD: EVENTHANDLER_DEREGISTER(ifnet_departure_event, lagg_detach_cookie); - if_clone_detach(lagg_cloner); lagg_input_p = NULL; lagg_linkstate_p = NULL; - mtx_destroy(&lagg_list_mtx); break; default: return (EOPNOTSUPP); @@ -226,6 +316,117 @@ static moduledata_t lagg_mod = { DECLARE_MODULE(if_lagg, lagg_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); MODULE_VERSION(if_lagg, 1); +static void +lagg_proto_attach(struct lagg_softc *sc, lagg_proto pr) +{ + + KASSERT(sc->sc_proto == LAGG_PROTO_NONE, ("%s: sc %p has proto", + __func__, sc)); + + if (sc->sc_ifflags & IFF_DEBUG) + if_printf(sc->sc_ifp, "using proto %u\n", pr); + + if (lagg_protos[pr].pr_attach != NULL) + lagg_protos[pr].pr_attach(sc); + sc->sc_proto = pr; +} + +static void +lagg_proto_detach(struct lagg_softc *sc) +{ + lagg_proto pr; + + LAGG_WLOCK_ASSERT(sc); + + pr = sc->sc_proto; + sc->sc_proto = LAGG_PROTO_NONE; + + if (lagg_protos[pr].pr_detach != NULL) + lagg_protos[pr].pr_detach(sc); + else + LAGG_WUNLOCK(sc); +} + +static int +lagg_proto_start(struct lagg_softc *sc, struct mbuf *m) +{ + + return (lagg_protos[sc->sc_proto].pr_start(sc, m)); +} + +static struct mbuf * +lagg_proto_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) +{ + + return (lagg_protos[sc->sc_proto].pr_input(sc, lp, m)); +} + +static int +lagg_proto_addport(struct lagg_softc *sc, struct lagg_port *lp) +{ + + if (lagg_protos[sc->sc_proto].pr_addport == NULL) + return (0); + else + return (lagg_protos[sc->sc_proto].pr_addport(lp)); +} + +static void +lagg_proto_delport(struct lagg_softc *sc, struct lagg_port *lp) +{ + + if (lagg_protos[sc->sc_proto].pr_delport != NULL) + lagg_protos[sc->sc_proto].pr_delport(lp); +} + +static void +lagg_proto_linkstate(struct lagg_softc *sc, struct lagg_port *lp) +{ + + if (lagg_protos[sc->sc_proto].pr_linkstate != NULL) + lagg_protos[sc->sc_proto].pr_linkstate(lp); +} + +static void +lagg_proto_init(struct lagg_softc *sc) +{ + + if (lagg_protos[sc->sc_proto].pr_init != NULL) + lagg_protos[sc->sc_proto].pr_init(sc); +} + +static void +lagg_proto_stop(struct lagg_softc *sc) +{ + + if (lagg_protos[sc->sc_proto].pr_stop != NULL) + lagg_protos[sc->sc_proto].pr_stop(sc); +} + +static void +lagg_proto_lladdr(struct lagg_softc *sc) +{ + + if (lagg_protos[sc->sc_proto].pr_lladdr != NULL) + lagg_protos[sc->sc_proto].pr_lladdr(sc); +} + +static void +lagg_proto_request(struct lagg_softc *sc, void *v) +{ + + if (lagg_protos[sc->sc_proto].pr_request != NULL) + lagg_protos[sc->sc_proto].pr_request(sc, v); +} + +static void +lagg_proto_portreq(struct lagg_softc *sc, struct lagg_port *lp, void *v) +{ + + if (lagg_protos[sc->sc_proto].pr_portreq != NULL) + lagg_protos[sc->sc_proto].pr_portreq(lp, v); +} + /* * This routine is run via an vlan * config EVENT @@ -233,19 +434,19 @@ MODULE_VERSION(if_lagg, 1); static void lagg_register_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag) { - struct lagg_softc *sc = ifp->if_softc; - struct lagg_port *lp; - struct rm_priotracker tracker; + struct lagg_softc *sc = ifp->if_softc; + struct lagg_port *lp; + struct rm_priotracker tracker; - if (ifp->if_softc != arg) /* Not our event */ - return; + if (ifp->if_softc != arg) /* Not our event */ + return; - LAGG_RLOCK(sc, &tracker); - if (!SLIST_EMPTY(&sc->sc_ports)) { - SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) - EVENTHANDLER_INVOKE(vlan_config, lp->lp_ifp, vtag); - } - LAGG_RUNLOCK(sc, &tracker); + LAGG_RLOCK(sc, &tracker); + if (!SLIST_EMPTY(&sc->sc_ports)) { + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) + EVENTHANDLER_INVOKE(vlan_config, lp->lp_ifp, vtag); + } + LAGG_RUNLOCK(sc, &tracker); } /* @@ -255,19 +456,19 @@ lagg_register_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag) static void lagg_unregister_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag) { - struct lagg_softc *sc = ifp->if_softc; - struct lagg_port *lp; - struct rm_priotracker tracker; + struct lagg_softc *sc = ifp->if_softc; + struct lagg_port *lp; + struct rm_priotracker tracker; - if (ifp->if_softc != arg) /* Not our event */ - return; + if (ifp->if_softc != arg) /* Not our event */ + return; - LAGG_RLOCK(sc, &tracker); - if (!SLIST_EMPTY(&sc->sc_ports)) { - SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) - EVENTHANDLER_INVOKE(vlan_unconfig, lp->lp_ifp, vtag); - } - LAGG_RUNLOCK(sc, &tracker); + LAGG_RLOCK(sc, &tracker); + if (!SLIST_EMPTY(&sc->sc_ports)) { + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) + EVENTHANDLER_INVOKE(vlan_unconfig, lp->lp_ifp, vtag); + } + LAGG_RUNLOCK(sc, &tracker); } static int @@ -275,10 +476,7 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct lagg_softc *sc; struct ifnet *ifp; - int i, error = 0; static const u_char eaddr[6]; /* 00:00:00:00:00:00 */ - struct sysctl_oid *oid; - char num[14]; /* sufficient for 32 bits */ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ETHER); @@ -287,60 +485,19 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) return (ENOSPC); } - sc->sc_ipackets = counter_u64_alloc(M_WAITOK); - sc->sc_opackets = counter_u64_alloc(M_WAITOK); - sc->sc_ibytes = counter_u64_alloc(M_WAITOK); - sc->sc_obytes = counter_u64_alloc(M_WAITOK); + if (V_def_use_flowid) + sc->sc_opts |= LAGG_OPT_USE_FLOWID; + sc->flowid_shift = V_def_flowid_shift; - sysctl_ctx_init(&sc->ctx); - snprintf(num, sizeof(num), "%u", unit); - sc->use_flowid = def_use_flowid; - sc->flowid_shift = def_flowid_shift; - sc->sc_oid = oid = SYSCTL_ADD_NODE(&sc->ctx, - &SYSCTL_NODE_CHILDREN(_net_link, lagg), - OID_AUTO, num, CTLFLAG_RD, NULL, ""); - SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "use_flowid", CTLTYPE_INT|CTLFLAG_RW, &sc->use_flowid, - sc->use_flowid, "Use flow id for load sharing"); - SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "flowid_shift", CTLTYPE_INT|CTLFLAG_RW, &sc->flowid_shift, - sc->flowid_shift, - "Shift flowid bits to prevent multiqueue collisions"); - SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "count", CTLTYPE_INT|CTLFLAG_RD, &sc->sc_count, sc->sc_count, - "Total number of ports"); - SYSCTL_ADD_PROC(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "active", CTLTYPE_INT|CTLFLAG_RD, sc, 0, lagg_sysctl_active, - "I", "Total number of active ports"); - SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, - "flapping", CTLTYPE_INT|CTLFLAG_RD, &sc->sc_flapping, - sc->sc_flapping, "Total number of port change events"); /* Hash all layers by default */ sc->sc_flags = LAGG_F_HASHL2|LAGG_F_HASHL3|LAGG_F_HASHL4; - sc->sc_proto = LAGG_PROTO_NONE; - for (i = 0; lagg_protos[i].ti_proto != LAGG_PROTO_NONE; i++) { - if (lagg_protos[i].ti_proto == LAGG_PROTO_DEFAULT) { - sc->sc_proto = lagg_protos[i].ti_proto; - if ((error = lagg_protos[i].ti_attach(sc)) != 0) { - if_free(ifp); - free(sc, M_DEVBUF); - return (error); - } - break; - } - } + lagg_proto_attach(sc, LAGG_PROTO_DEFAULT); + LAGG_LOCK_INIT(sc); - LAGG_CALLOUT_LOCK_INIT(sc); SLIST_INIT(&sc->sc_ports); TASK_INIT(&sc->sc_lladdr_task, 0, lagg_port_setlladdr, sc); - /* - * This uses the callout lock rather than the rmlock; one can't - * hold said rmlock during SWI. - */ - callout_init_mtx(&sc->sc_callout, &sc->sc_call_mtx, 0); - /* Initialise pseudo media types */ ifmedia_init(&sc->sc_media, 0, lagg_media_change, lagg_media_status); @@ -353,6 +510,7 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) ifp->if_qflush = lagg_qflush; ifp->if_init = lagg_init; ifp->if_ioctl = lagg_ioctl; + ifp->if_get_counter = lagg_get_counter; ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; ifp->if_capenable = ifp->if_capabilities = IFCAP_HWSTATS; @@ -368,11 +526,9 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) lagg_unregister_vlan, sc, EVENTHANDLER_PRI_FIRST); /* Insert into the global list of laggs */ - mtx_lock(&lagg_list_mtx); - SLIST_INSERT_HEAD(&lagg_list, sc, sc_entries); - mtx_unlock(&lagg_list_mtx); - - callout_reset(&sc->sc_callout, hz, lagg_callout, sc); + LAGG_LIST_LOCK(); + SLIST_INSERT_HEAD(&V_lagg_list, sc, sc_entries); + LAGG_LIST_UNLOCK(); return (0); } @@ -395,32 +551,18 @@ lagg_clone_destroy(struct ifnet *ifp) while ((lp = SLIST_FIRST(&sc->sc_ports)) != NULL) lagg_port_destroy(lp, 1); /* Unhook the aggregation protocol */ - if (sc->sc_detach != NULL) - (*sc->sc_detach)(sc); + lagg_proto_detach(sc); - LAGG_WUNLOCK(sc); - - sysctl_ctx_free(&sc->ctx); ifmedia_removeall(&sc->sc_media); ether_ifdetach(ifp); if_free(ifp); - /* This grabs sc_callout_mtx, serialising it correctly */ - callout_drain(&sc->sc_callout); - - /* At this point it's drained; we can free this */ - counter_u64_free(sc->sc_ipackets); - counter_u64_free(sc->sc_opackets); - counter_u64_free(sc->sc_ibytes); - counter_u64_free(sc->sc_obytes); - - mtx_lock(&lagg_list_mtx); - SLIST_REMOVE(&lagg_list, sc, lagg_softc, sc_entries); - mtx_unlock(&lagg_list_mtx); + LAGG_LIST_LOCK(); + SLIST_REMOVE(&V_lagg_list, sc, lagg_softc, sc_entries); + LAGG_LIST_UNLOCK(); taskqueue_drain(taskqueue_swi, &sc->sc_lladdr_task); LAGG_LOCK_DESTROY(sc); - LAGG_CALLOUT_LOCK_DESTROY(sc); free(sc, M_DEVBUF); } @@ -434,8 +576,7 @@ lagg_lladdr(struct lagg_softc *sc, uint8_t *lladdr) bcopy(lladdr, IF_LLADDR(ifp), ETHER_ADDR_LEN); /* Let the protocol know the MAC has changed */ - if (sc->sc_lladdr != NULL) - (*sc->sc_lladdr)(sc); + lagg_proto_lladdr(sc); EVENTHANDLER_INVOKE(iflladdr_event, ifp); } @@ -445,23 +586,18 @@ lagg_capabilities(struct lagg_softc *sc) struct lagg_port *lp; int cap = ~0, ena = ~0; u_long hwa = ~0UL; -#if defined(INET) || defined(INET6) - u_int hw_tsomax = IP_MAXPACKET; /* Initialize to the maximum value. */ -#else - u_int hw_tsomax = ~0; /* if_hw_tsomax is only for INET/INET6, but.. */ -#endif + struct ifnet_hw_tsomax hw_tsomax; LAGG_WLOCK_ASSERT(sc); + memset(&hw_tsomax, 0, sizeof(hw_tsomax)); + /* Get capabilities from the lagg ports */ SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { cap &= lp->lp_ifp->if_capabilities; ena &= lp->lp_ifp->if_capenable; hwa &= lp->lp_ifp->if_hwassist; - /* Set to the minimum value of the lagg ports. */ - if (lp->lp_ifp->if_hw_tsomax < hw_tsomax && - lp->lp_ifp->if_hw_tsomax > 0) - hw_tsomax = lp->lp_ifp->if_hw_tsomax; + if_hw_tsomax_common(lp->lp_ifp, &hw_tsomax); } cap = (cap == ~0 ? 0 : cap); ena = (ena == ~0 ? 0 : ena); @@ -470,11 +606,10 @@ lagg_capabilities(struct lagg_softc *sc) if (sc->sc_ifp->if_capabilities != cap || sc->sc_ifp->if_capenable != ena || sc->sc_ifp->if_hwassist != hwa || - sc->sc_ifp->if_hw_tsomax != hw_tsomax) { + if_hw_tsomax_update(sc->sc_ifp, &hw_tsomax) != 0) { sc->sc_ifp->if_capabilities = cap; sc->sc_ifp->if_capenable = ena; sc->sc_ifp->if_hwassist = hwa; - sc->sc_ifp->if_hw_tsomax = hw_tsomax; getmicrotime(&sc->sc_ifp->if_lastchange); if (sc->sc_ifflags & IFF_DEBUG) @@ -562,8 +697,9 @@ static int lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) { struct lagg_softc *sc_ptr; - struct lagg_port *lp; - int error = 0; + struct lagg_port *lp, *tlp; + int error, i; + uint64_t *pval; LAGG_WLOCK_ASSERT(sc); @@ -626,10 +762,10 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) return (ENOMEM); /* Check if port is a stacked lagg */ - mtx_lock(&lagg_list_mtx); - SLIST_FOREACH(sc_ptr, &lagg_list, sc_entries) { + LAGG_LIST_LOCK(); + SLIST_FOREACH(sc_ptr, &V_lagg_list, sc_entries) { if (ifp == sc_ptr->sc_ifp) { - mtx_unlock(&lagg_list_mtx); + LAGG_LIST_UNLOCK(); free(lp, M_DEVBUF); return (EINVAL); /* XXX disable stacking for the moment, its untested */ @@ -637,14 +773,14 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) lp->lp_flags |= LAGG_PORT_STACK; if (lagg_port_checkstacking(sc_ptr) >= LAGG_MAX_STACKING) { - mtx_unlock(&lagg_list_mtx); + LAGG_LIST_UNLOCK(); free(lp, M_DEVBUF); return (E2BIG); } #endif } } - mtx_unlock(&lagg_list_mtx); + LAGG_LIST_UNLOCK(); /* Change the interface type */ lp->lp_iftype = ifp->if_type; @@ -669,27 +805,39 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) lagg_port_lladdr(lp, IF_LLADDR(sc->sc_ifp)); } - /* Insert into the list of ports */ - SLIST_INSERT_HEAD(&sc->sc_ports, lp, lp_entries); + /* Insert into the list of ports. Keep ports sorted by if_index. */ + SLIST_FOREACH(tlp, &sc->sc_ports, lp_entries) { + if (tlp->lp_ifp->if_index < ifp->if_index && ( + SLIST_NEXT(tlp, lp_entries) == NULL || + SLIST_NEXT(tlp, lp_entries)->lp_ifp->if_index < + ifp->if_index)) + break; + } + if (tlp != NULL) + SLIST_INSERT_AFTER(tlp, lp, lp_entries); + else + SLIST_INSERT_HEAD(&sc->sc_ports, lp, lp_entries); sc->sc_count++; /* Update lagg capabilities */ lagg_capabilities(sc); lagg_linkstate(sc); + /* Read port counters */ + pval = lp->port_counters.val; + for (i = 0; i < IFCOUNTERS; i++, pval++) + *pval = ifp->if_get_counter(ifp, i); /* Add multicast addresses and interface flags to this port */ lagg_ether_cmdmulti(lp, 1); lagg_setflags(lp, 1); - if (sc->sc_port_create != NULL) - error = (*sc->sc_port_create)(lp); - if (error) { - /* remove the port again, without calling sc_port_destroy */ + if ((error = lagg_proto_addport(sc, lp)) != 0) { + /* Remove the port, without calling pr_delport. */ lagg_port_destroy(lp, 0); return (error); } - return (error); + return (0); } #ifdef LAGG_PORT_STACKING @@ -714,17 +862,19 @@ lagg_port_checkstacking(struct lagg_softc *sc) #endif static int -lagg_port_destroy(struct lagg_port *lp, int runpd) +lagg_port_destroy(struct lagg_port *lp, int rundelport) { struct lagg_softc *sc = lp->lp_softc; struct lagg_port *lp_ptr; struct lagg_llq *llq; struct ifnet *ifp = lp->lp_ifp; + uint64_t *pval, vdiff; + int i; LAGG_WLOCK_ASSERT(sc); - if (runpd && sc->sc_port_destroy != NULL) - (*sc->sc_port_destroy)(lp); + if (rundelport) + lagg_proto_delport(sc, lp); /* * Remove multicast addresses and interface flags from this port and @@ -742,6 +892,13 @@ lagg_port_destroy(struct lagg_port *lp, int runpd) ifp->if_output = lp->lp_output; ifp->if_lagg = NULL; + /* Update detached port counters */ + pval = lp->port_counters.val; + for (i = 0; i < IFCOUNTERS; i++, pval++) { + vdiff = ifp->if_get_counter(ifp, i) - *pval; + sc->detached_counters.val[i] += vdiff; + } + /* Finally, remove the port from the lagg */ SLIST_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entries); sc->sc_count--; @@ -854,6 +1011,61 @@ lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return (EINVAL); } +/* + * Requests counter @cnt data. + * + * Counter value is calculated the following way: + * 1) for each port, sum difference between current and "initial" measurements. + * 2) add lagg logical interface counters. + * 3) add data from detached_counters array. + * + * We also do the following things on ports attach/detach: + * 1) On port attach we store all counters it has into port_counter array. + * 2) On port detach we add the different between "initial" and + * current counters data to detached_counters array. + */ +static uint64_t +lagg_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct lagg_softc *sc; + struct lagg_port *lp; + struct ifnet *lpifp; + struct rm_priotracker tracker; + uint64_t newval, oldval, vsum; + + /* Revise this when we've got non-generic counters. */ + KASSERT(cnt < IFCOUNTERS, ("%s: invalid cnt %d", __func__, cnt)); + + sc = (struct lagg_softc *)ifp->if_softc; + LAGG_RLOCK(sc, &tracker); + + vsum = 0; + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { + /* Saved attached value */ + oldval = lp->port_counters.val[cnt]; + /* current value */ + lpifp = lp->lp_ifp; + newval = lpifp->if_get_counter(lpifp, cnt); + /* Calculate diff and save new */ + vsum += newval - oldval; + } + + /* + * Add counter data which might be added by upper + * layer protocols operating on logical interface. + */ + vsum += if_get_counter_default(ifp, cnt); + + /* + * Add counter data from detached ports counters + */ + vsum += sc->detached_counters.val[cnt]; + + LAGG_RUNLOCK(sc, &tracker); + + return (vsum); +} + /* * For direct output to child ports. */ @@ -903,8 +1115,7 @@ lagg_port2req(struct lagg_port *lp, struct lagg_reqport *rp) strlcpy(rp->rp_portname, lp->lp_ifp->if_xname, sizeof(rp->rp_portname)); rp->rp_prio = lp->lp_prio; rp->rp_flags = lp->lp_flags; - if (sc->sc_portreq != NULL) - (*sc->sc_portreq)(lp, (caddr_t)&rp->rp_psc); + lagg_proto_portreq(sc, lp, &rp->rp_psc); /* Add protocol specific flags */ switch (sc->sc_proto) { @@ -918,6 +1129,7 @@ lagg_port2req(struct lagg_port *lp, struct lagg_reqport *rp) case LAGG_PROTO_ROUNDROBIN: case LAGG_PROTO_LOADBALANCE: case LAGG_PROTO_ETHERCHANNEL: + case LAGG_PROTO_BROADCAST: if (LAGG_PORTACTIVE(lp)) rp->rp_flags |= LAGG_PORT_ACTIVE; break; @@ -952,8 +1164,7 @@ lagg_init(void *xsc) SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) lagg_port_lladdr(lp, IF_LLADDR(ifp)); - if (sc->sc_init != NULL) - (*sc->sc_init)(sc); + lagg_proto_init(sc); LAGG_WUNLOCK(sc); } @@ -970,8 +1181,7 @@ lagg_stop(struct lagg_softc *sc) ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - if (sc->sc_stop != NULL) - (*sc->sc_stop)(sc); + lagg_proto_stop(sc); } static int @@ -979,6 +1189,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc; struct lagg_reqall *ra = (struct lagg_reqall *)data; + struct lagg_reqopts *ro = (struct lagg_reqopts *)data; struct lagg_reqport *rp = (struct lagg_reqport *)data, rpbuf; struct lagg_reqflags *rf = (struct lagg_reqflags *)data; struct ifreq *ifr = (struct ifreq *)data; @@ -1004,9 +1215,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) LAGG_RLOCK(sc, &tracker); ra->ra_proto = sc->sc_proto; - if (sc->sc_req != NULL) - (*sc->sc_req)(sc, (caddr_t)&ra->ra_psc); - + lagg_proto_request(sc, &ra->ra_psc); count = 0; buf = outbuf; len = min(ra->ra_size, buflen); @@ -1030,50 +1239,115 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = priv_check(td, PRIV_NET_LAGG); if (error) break; - if (ra->ra_proto >= LAGG_PROTO_MAX) { + if (ra->ra_proto < 1 || ra->ra_proto >= LAGG_PROTO_MAX) { error = EPROTONOSUPPORT; break; } + LAGG_WLOCK(sc); - if (sc->sc_proto != LAGG_PROTO_NONE) { - /* Reset protocol first in case detach unlocks */ - sc->sc_proto = LAGG_PROTO_NONE; - error = sc->sc_detach(sc); - sc->sc_detach = NULL; - sc->sc_start = NULL; - sc->sc_input = NULL; - sc->sc_port_create = NULL; - sc->sc_port_destroy = NULL; - sc->sc_linkstate = NULL; - sc->sc_init = NULL; - sc->sc_stop = NULL; - sc->sc_lladdr = NULL; - sc->sc_req = NULL; - sc->sc_portreq = NULL; - } else if (sc->sc_input != NULL) { - /* Still detaching */ - error = EBUSY; + lagg_proto_detach(sc); + lagg_proto_attach(sc, ra->ra_proto); + break; + case SIOCGLAGGOPTS: + ro->ro_opts = sc->sc_opts; + if (sc->sc_proto == LAGG_PROTO_LACP) { + struct lacp_softc *lsc; + + lsc = (struct lacp_softc *)sc->sc_psc; + if (lsc->lsc_debug.lsc_tx_test != 0) + ro->ro_opts |= LAGG_OPT_LACP_TXTEST; + if (lsc->lsc_debug.lsc_rx_test != 0) + ro->ro_opts |= LAGG_OPT_LACP_RXTEST; + if (lsc->lsc_strict_mode != 0) + ro->ro_opts |= LAGG_OPT_LACP_STRICT; + + ro->ro_active = sc->sc_active; + } else { + ro->ro_active = 0; + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) + ro->ro_active += LAGG_PORTACTIVE(lp); } - if (error != 0) { - LAGG_WUNLOCK(sc); + ro->ro_flapping = sc->sc_flapping; + ro->ro_flowid_shift = sc->flowid_shift; + break; + case SIOCSLAGGOPTS: + error = priv_check(td, PRIV_NET_LAGG); + if (error) + break; + if (ro->ro_opts == 0) + break; + /* + * Set options. LACP options are stored in sc->sc_psc, + * not in sc_opts. + */ + int valid, lacp; + + switch (ro->ro_opts) { + case LAGG_OPT_USE_FLOWID: + case -LAGG_OPT_USE_FLOWID: + case LAGG_OPT_FLOWIDSHIFT: + valid = 1; + lacp = 0; + break; + case LAGG_OPT_LACP_TXTEST: + case -LAGG_OPT_LACP_TXTEST: + case LAGG_OPT_LACP_RXTEST: + case -LAGG_OPT_LACP_RXTEST: + case LAGG_OPT_LACP_STRICT: + case -LAGG_OPT_LACP_STRICT: + valid = lacp = 1; + break; + default: + valid = lacp = 0; break; } - for (int i = 0; i < (sizeof(lagg_protos) / - sizeof(lagg_protos[0])); i++) { - if (lagg_protos[i].ti_proto == ra->ra_proto) { - if (sc->sc_ifflags & IFF_DEBUG) - printf("%s: using proto %u\n", - sc->sc_ifname, - lagg_protos[i].ti_proto); - sc->sc_proto = lagg_protos[i].ti_proto; - if (sc->sc_proto != LAGG_PROTO_NONE) - error = lagg_protos[i].ti_attach(sc); - LAGG_WUNLOCK(sc); - return (error); + + LAGG_WLOCK(sc); + if (valid == 0 || + (lacp == 1 && sc->sc_proto != LAGG_PROTO_LACP)) { + /* Invalid combination of options specified. */ + error = EINVAL; + LAGG_WUNLOCK(sc); + break; /* Return from SIOCSLAGGOPTS. */ + } + /* + * Store new options into sc->sc_opts except for + * FLOWIDSHIFT and LACP options. + */ + if (lacp == 0) { + if (ro->ro_opts == LAGG_OPT_FLOWIDSHIFT) + sc->flowid_shift = ro->ro_flowid_shift; + else if (ro->ro_opts > 0) + sc->sc_opts |= ro->ro_opts; + else + sc->sc_opts &= ~ro->ro_opts; + } else { + struct lacp_softc *lsc; + + lsc = (struct lacp_softc *)sc->sc_psc; + + switch (ro->ro_opts) { + case LAGG_OPT_LACP_TXTEST: + lsc->lsc_debug.lsc_tx_test = 1; + break; + case -LAGG_OPT_LACP_TXTEST: + lsc->lsc_debug.lsc_tx_test = 0; + break; + case LAGG_OPT_LACP_RXTEST: + lsc->lsc_debug.lsc_rx_test = 1; + break; + case -LAGG_OPT_LACP_RXTEST: + lsc->lsc_debug.lsc_rx_test = 0; + break; + case LAGG_OPT_LACP_STRICT: + lsc->lsc_strict_mode = 1; + break; + case -LAGG_OPT_LACP_STRICT: + lsc->lsc_strict_mode = 0; + break; } } LAGG_WUNLOCK(sc); - error = EPROTONOSUPPORT; break; case SIOCGLAGGFLAGS: rf->rf_flags = sc->sc_flags; @@ -1258,7 +1532,7 @@ lagg_ether_cmdmulti(struct lagg_port *lp, int set) /* Handle a ref counted flag that should be set on the lagg port as well */ static int lagg_setflag(struct lagg_port *lp, int flag, int status, - int (*func)(struct ifnet *, int)) + int (*func)(struct ifnet *, int)) { struct lagg_softc *sc = lp->lp_softc; struct ifnet *scifp = sc->sc_ifp; @@ -1323,21 +1597,17 @@ lagg_transmit(struct ifnet *ifp, struct mbuf *m) if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) { LAGG_RUNLOCK(sc, &tracker); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENXIO); } ETHER_BPF_MTAP(ifp, m); - error = (*sc->sc_start)(sc, m); + error = lagg_proto_start(sc, m); LAGG_RUNLOCK(sc, &tracker); - if (error == 0) { - counter_u64_add(sc->sc_opackets, 1); - counter_u64_add(sc->sc_obytes, len); - ifp->if_omcasts += mcast; - } else - ifp->if_oerrors++; + if (error != 0) + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (error); } @@ -1369,12 +1639,9 @@ lagg_input(struct ifnet *ifp, struct mbuf *m) ETHER_BPF_MTAP(scifp, m); - m = (*sc->sc_input)(sc, lp, m); + m = lagg_proto_input(sc, lp, m); if (m != NULL) { - counter_u64_add(sc->sc_ipackets, 1); - counter_u64_add(sc->sc_ibytes, m->m_pkthdr.len); - if (scifp->if_flags & IFF_MONITOR) { m_freem(m); m = NULL; @@ -1424,7 +1691,7 @@ lagg_linkstate(struct lagg_softc *sc) /* Our link is considered up if at least one of our ports is active */ SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { - if (lp->lp_link_state == LINK_STATE_UP) { + if (lp->lp_ifp->if_link_state == LINK_STATE_UP) { new_link = LINK_STATE_UP; break; } @@ -1440,6 +1707,7 @@ lagg_linkstate(struct lagg_softc *sc) case LAGG_PROTO_ROUNDROBIN: case LAGG_PROTO_LOADBALANCE: case LAGG_PROTO_ETHERCHANNEL: + case LAGG_PROTO_BROADCAST: speed = 0; SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) speed += lp->lp_ifp->if_baudrate; @@ -1464,8 +1732,7 @@ lagg_port_state(struct ifnet *ifp, int state) LAGG_WLOCK(sc); lagg_linkstate(sc); - if (sc->sc_linkstate != NULL) - (*sc->sc_linkstate)(lp); + lagg_proto_linkstate(sc, lp); LAGG_WUNLOCK(sc); } @@ -1532,27 +1799,6 @@ lagg_gethdr(struct mbuf *m, u_int off, u_int len, void *buf) return (mtod(m, char *) + off); } -static int -lagg_sysctl_active(SYSCTL_HANDLER_ARGS) -{ - struct lagg_softc *sc = (struct lagg_softc *)arg1; - struct lagg_port *lp; - int error; - - /* LACP tracks active links automatically, the others do not */ - if (sc->sc_proto != LAGG_PROTO_LACP) { - sc->sc_active = 0; - SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) - sc->sc_active += LAGG_PORTACTIVE(lp); - } - - error = sysctl_handle_int(oidp, &sc->sc_active, 0, req); - if ((error) || (req->newptr == NULL)) - return (error); - - return (0); -} - uint32_t lagg_hashmbuf(struct lagg_softc *sc, struct mbuf *m, uint32_t key) { @@ -1665,24 +1911,11 @@ lagg_enqueue(struct ifnet *ifp, struct mbuf *m) /* * Simple round robin aggregation */ - -static int +static void lagg_rr_attach(struct lagg_softc *sc) { - sc->sc_detach = lagg_rr_detach; - sc->sc_start = lagg_rr_start; - sc->sc_input = lagg_rr_input; - sc->sc_port_create = NULL; sc->sc_capabilities = IFCAP_LAGG_FULLDUPLEX; sc->sc_seq = 0; - - return (0); -} - -static int -lagg_rr_detach(struct lagg_softc *sc) -{ - return (0); } static int @@ -1721,28 +1954,70 @@ lagg_rr_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) return (m); } +/* + * Broadcast mode + */ +static int +lagg_bcast_start(struct lagg_softc *sc, struct mbuf *m) +{ + int active_ports = 0; + int errors = 0; + int ret; + struct lagg_port *lp, *last = NULL; + struct mbuf *m0; + + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { + if (!LAGG_PORTACTIVE(lp)) + continue; + + active_ports++; + + if (last != NULL) { + m0 = m_copym(m, 0, M_COPYALL, M_NOWAIT); + if (m0 == NULL) { + ret = ENOBUFS; + errors++; + break; + } + + ret = lagg_enqueue(last->lp_ifp, m0); + if (ret != 0) + errors++; + } + last = lp; + } + if (last == NULL) { + m_freem(m); + return (ENOENT); + } + if ((last = lagg_link_active(sc, last)) == NULL) { + m_freem(m); + return (ENETDOWN); + } + + ret = lagg_enqueue(last->lp_ifp, m); + if (ret != 0) + errors++; + + if (errors == 0) + return (ret); + + return (0); +} + +static struct mbuf* +lagg_bcast_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) +{ + struct ifnet *ifp = sc->sc_ifp; + + /* Just pass in the packet to our lagg device */ + m->m_pkthdr.rcvif = ifp; + return (m); +} + /* * Active failover */ - -static int -lagg_fail_attach(struct lagg_softc *sc) -{ - sc->sc_detach = lagg_fail_detach; - sc->sc_start = lagg_fail_start; - sc->sc_input = lagg_fail_input; - sc->sc_port_create = NULL; - sc->sc_port_destroy = NULL; - - return (0); -} - -static int -lagg_fail_detach(struct lagg_softc *sc) -{ - return (0); -} - static int lagg_fail_start(struct lagg_softc *sc, struct mbuf *m) { @@ -1764,7 +2039,7 @@ lagg_fail_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) struct ifnet *ifp = sc->sc_ifp; struct lagg_port *tmp_tp; - if (lp == sc->sc_primary || lagg_failover_rx_all) { + if (lp == sc->sc_primary || V_lagg_failover_rx_all) { m->m_pkthdr.rcvif = ifp; return (m); } @@ -1788,40 +2063,32 @@ lagg_fail_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) /* * Loadbalancing */ - -static int +static void lagg_lb_attach(struct lagg_softc *sc) { struct lagg_port *lp; struct lagg_lb *lb; - if ((lb = (struct lagg_lb *)malloc(sizeof(struct lagg_lb), - M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) - return (ENOMEM); + lb = malloc(sizeof(struct lagg_lb), M_DEVBUF, M_WAITOK | M_ZERO); - sc->sc_detach = lagg_lb_detach; - sc->sc_start = lagg_lb_start; - sc->sc_input = lagg_lb_input; - sc->sc_port_create = lagg_lb_port_create; - sc->sc_port_destroy = lagg_lb_port_destroy; sc->sc_capabilities = IFCAP_LAGG_FULLDUPLEX; lb->lb_key = arc4random(); - sc->sc_psc = (caddr_t)lb; + sc->sc_psc = lb; SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) lagg_lb_port_create(lp); - - return (0); } -static int +static void lagg_lb_detach(struct lagg_softc *sc) { - struct lagg_lb *lb = (struct lagg_lb *)sc->sc_psc; + struct lagg_lb *lb; + + lb = (struct lagg_lb *)sc->sc_psc; + LAGG_WUNLOCK(sc); if (lb != NULL) free(lb, M_DEVBUF); - return (0); } static int @@ -1839,7 +2106,7 @@ lagg_lb_porttable(struct lagg_softc *sc, struct lagg_port *lp) return (EINVAL); if (sc->sc_ifflags & IFF_DEBUG) printf("%s: port %s at index %d\n", - sc->sc_ifname, lp_next->lp_ifname, i); + sc->sc_ifname, lp_next->lp_ifp->if_xname, i); lb->lb_ports[i++] = lp_next; } @@ -1867,7 +2134,7 @@ lagg_lb_start(struct lagg_softc *sc, struct mbuf *m) struct lagg_port *lp = NULL; uint32_t p = 0; - if (sc->use_flowid && (m->m_flags & M_FLOWID)) + if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && (m->m_flags & M_FLOWID)) p = m->m_pkthdr.flowid >> sc->flowid_shift; else p = lagg_hashmbuf(sc, m, lb->lb_key); @@ -1901,50 +2168,30 @@ lagg_lb_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) /* * 802.3ad LACP */ - -static int +static void lagg_lacp_attach(struct lagg_softc *sc) { struct lagg_port *lp; - int error; - - sc->sc_detach = lagg_lacp_detach; - sc->sc_port_create = lacp_port_create; - sc->sc_port_destroy = lacp_port_destroy; - sc->sc_linkstate = lacp_linkstate; - sc->sc_start = lagg_lacp_start; - sc->sc_input = lagg_lacp_input; - sc->sc_init = lacp_init; - sc->sc_stop = lacp_stop; - sc->sc_lladdr = lagg_lacp_lladdr; - sc->sc_req = lacp_req; - sc->sc_portreq = lacp_portreq; - - error = lacp_attach(sc); - if (error) - return (error); + lacp_attach(sc); SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) lacp_port_create(lp); - - return (error); } -static int +static void lagg_lacp_detach(struct lagg_softc *sc) { struct lagg_port *lp; - int error; + void *psc; SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) lacp_port_destroy(lp); - /* unlocking is safe here */ + psc = sc->sc_psc; + sc->sc_psc = NULL; LAGG_WUNLOCK(sc); - error = lacp_detach(sc); - LAGG_WLOCK(sc); - return (error); + lacp_detach(psc); } static void @@ -2006,16 +2253,3 @@ lagg_lacp_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) return (m); } -static void -lagg_callout(void *arg) -{ - struct lagg_softc *sc = (struct lagg_softc *)arg; - struct ifnet *ifp = sc->sc_ifp; - - ifp->if_ipackets = counter_u64_fetch(sc->sc_ipackets); - ifp->if_opackets = counter_u64_fetch(sc->sc_opackets); - ifp->if_ibytes = counter_u64_fetch(sc->sc_ibytes); - ifp->if_obytes = counter_u64_fetch(sc->sc_obytes); - - callout_reset(&sc->sc_callout, hz, lagg_callout, sc); -} diff --git a/sys/net/if_lagg.h b/sys/net/if_lagg.h index 4a1d9a0a77cb..bbb3497f96cd 100644 --- a/sys/net/if_lagg.h +++ b/sys/net/if_lagg.h @@ -47,26 +47,30 @@ "\05DISTRIBUTING\06DISABLED" /* Supported lagg PROTOs */ -#define LAGG_PROTO_NONE 0 /* no lagg protocol defined */ -#define LAGG_PROTO_ROUNDROBIN 1 /* simple round robin */ -#define LAGG_PROTO_FAILOVER 2 /* active failover */ -#define LAGG_PROTO_LOADBALANCE 3 /* loadbalance */ -#define LAGG_PROTO_LACP 4 /* 802.3ad lacp */ -#define LAGG_PROTO_ETHERCHANNEL 5 /* Cisco FEC */ -#define LAGG_PROTO_MAX 6 +typedef enum { + LAGG_PROTO_NONE = 0, /* no lagg protocol defined */ + LAGG_PROTO_ROUNDROBIN, /* simple round robin */ + LAGG_PROTO_FAILOVER, /* active failover */ + LAGG_PROTO_LOADBALANCE, /* loadbalance */ + LAGG_PROTO_LACP, /* 802.3ad lacp */ + LAGG_PROTO_ETHERCHANNEL,/* Cisco FEC */ + LAGG_PROTO_BROADCAST, /* broadcast */ + LAGG_PROTO_MAX, +} lagg_proto; struct lagg_protos { const char *lpr_name; - int lpr_proto; + lagg_proto lpr_proto; }; #define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER #define LAGG_PROTOS { \ - { "failover", LAGG_PROTO_FAILOVER }, \ + { "failover", LAGG_PROTO_FAILOVER }, \ { "fec", LAGG_PROTO_ETHERCHANNEL }, \ { "lacp", LAGG_PROTO_LACP }, \ { "loadbalance", LAGG_PROTO_LOADBALANCE }, \ - { "roundrobin", LAGG_PROTO_ROUNDROBIN }, \ + { "roundrobin", LAGG_PROTO_ROUNDROBIN }, \ + { "broadcast", LAGG_PROTO_BROADCAST }, \ { "none", LAGG_PROTO_NONE }, \ { "default", LAGG_PROTO_DEFAULT } \ } @@ -134,19 +138,35 @@ struct lagg_reqflags { #define SIOCGLAGGFLAGS _IOWR('i', 145, struct lagg_reqflags) #define SIOCSLAGGHASH _IOW('i', 146, struct lagg_reqflags) -#ifdef _KERNEL +struct lagg_reqopts { + char ro_ifname[IFNAMSIZ]; /* name of the lagg */ -#include + int ro_opts; /* Option bitmap */ +#define LAGG_OPT_NONE 0x00 +#define LAGG_OPT_USE_FLOWID 0x01 /* use M_FLOWID */ +/* Pseudo flags which are used in ro_opts but not stored into sc_opts. */ +#define LAGG_OPT_FLOWIDSHIFT 0x02 /* Set flowid */ +#define LAGG_OPT_FLOWIDSHIFT_MASK 0x1f /* flowid is uint32_t */ +#define LAGG_OPT_LACP_STRICT 0x10 /* LACP strict mode */ +#define LAGG_OPT_LACP_TXTEST 0x20 /* LACP debug: txtest */ +#define LAGG_OPT_LACP_RXTEST 0x40 /* LACP debug: rxtest */ + u_int ro_count; /* number of ports */ + u_int ro_active; /* active port count */ + u_int ro_flapping; /* number of flapping */ + int ro_flowid_shift; /* shift the flowid */ +}; + +#define SIOCGLAGGOPTS _IOWR('i', 152, struct lagg_reqopts) +#define SIOCSLAGGOPTS _IOW('i', 153, struct lagg_reqopts) + +#ifdef _KERNEL /* * Internal kernel part */ -#define lp_ifname lp_ifp->if_xname /* interface name */ -#define lp_link_state lp_ifp->if_link_state /* link state */ - #define LAGG_PORTACTIVE(_tp) ( \ - ((_tp)->lp_link_state == LINK_STATE_UP) && \ + ((_tp)->lp_ifp->if_link_state == LINK_STATE_UP) && \ ((_tp)->lp_ifp->if_flags & IFF_UP) \ ) @@ -186,10 +206,13 @@ struct lagg_llq { SLIST_ENTRY(lagg_llq) llq_entries; }; +struct lagg_counters { + uint64_t val[IFCOUNTERS]; +}; + struct lagg_softc { struct ifnet *sc_ifp; /* virtual interface */ struct rmlock sc_mtx; - struct mtx sc_call_mtx; int sc_proto; /* lagg protocol */ u_int sc_count; /* number of ports */ u_int sc_active; /* active port count */ @@ -197,42 +220,22 @@ struct lagg_softc { * events */ struct lagg_port *sc_primary; /* primary port */ struct ifmedia sc_media; /* media config */ - caddr_t sc_psc; /* protocol data */ + void *sc_psc; /* protocol data */ uint32_t sc_seq; /* sequence counter */ uint32_t sc_flags; - counter_u64_t sc_ipackets; - counter_u64_t sc_opackets; - counter_u64_t sc_ibytes; - counter_u64_t sc_obytes; - SLIST_HEAD(__tplhd, lagg_port) sc_ports; /* list of interfaces */ SLIST_ENTRY(lagg_softc) sc_entries; struct task sc_lladdr_task; SLIST_HEAD(__llqhd, lagg_llq) sc_llq_head; /* interfaces to program the lladdr on */ - - /* lagg protocol callbacks */ - int (*sc_detach)(struct lagg_softc *); - int (*sc_start)(struct lagg_softc *, struct mbuf *); - struct mbuf *(*sc_input)(struct lagg_softc *, struct lagg_port *, - struct mbuf *); - int (*sc_port_create)(struct lagg_port *); - void (*sc_port_destroy)(struct lagg_port *); - void (*sc_linkstate)(struct lagg_port *); - void (*sc_init)(struct lagg_softc *); - void (*sc_stop)(struct lagg_softc *); - void (*sc_lladdr)(struct lagg_softc *); - void (*sc_req)(struct lagg_softc *, caddr_t); - void (*sc_portreq)(struct lagg_port *, caddr_t); eventhandler_tag vlan_attach; eventhandler_tag vlan_detach; struct callout sc_callout; - struct sysctl_ctx_list ctx; /* sysctl variables */ - struct sysctl_oid *sc_oid; /* sysctl tree oid */ - int use_flowid; /* use M_FLOWID */ + u_int sc_opts; int flowid_shift; /* shift the flowid */ + struct lagg_counters detached_counters; /* detached ports sum */ }; struct lagg_port { @@ -245,7 +248,7 @@ struct lagg_port { uint32_t lp_flags; /* port flags */ int lp_ifflags; /* saved ifp flags */ void *lh_cookie; /* if state hook */ - caddr_t lp_psc; /* protocol data */ + void *lp_psc; /* protocol data */ int lp_detaching; /* ifnet is detaching */ SLIST_HEAD(__mclhd, lagg_mc) lp_mc_head; /* multicast addresses */ @@ -254,6 +257,7 @@ struct lagg_port { int (*lp_ioctl)(struct ifnet *, u_long, caddr_t); int (*lp_output)(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); + struct lagg_counters port_counters; /* ifp counters copy */ SLIST_ENTRY(lagg_port) lp_entries; }; @@ -267,11 +271,6 @@ struct lagg_port { #define LAGG_RLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_RLOCKED) #define LAGG_WLOCK_ASSERT(_sc) rm_assert(&(_sc)->sc_mtx, RA_WLOCKED) -#define LAGG_CALLOUT_LOCK_INIT(_sc) \ - mtx_init(&(_sc)->sc_call_mtx, "if_lagg callout mutex", NULL,\ - MTX_DEF) -#define LAGG_CALLOUT_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_call_mtx) - extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *); extern void (*lagg_linkstate_p)(struct ifnet *, int ); diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 068705029d4e..6d2b9143dfb1 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -226,8 +226,8 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); } - ifp->if_opackets++; - ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) @@ -358,8 +358,8 @@ if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen) m_freem(m); return (EAFNOSUPPORT); } - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); netisr_queue(isr, m); /* mbuf is free'd on failure. */ return (0); } diff --git a/sys/net/if_mib.c b/sys/net/if_mib.c index 3c90235aa043..b6d245a7aa8f 100644 --- a/sys/net/if_mib.c +++ b/sys/net/if_mib.c @@ -105,7 +105,8 @@ sysctl_ifdata(SYSCTL_HANDLER_ARGS) /* XXX bad syntax! */ ifmd.ifmd_flags = ifp->if_flags | ifp->if_drv_flags; ifmd.ifmd_snd_len = ifp->if_snd.ifq_len; ifmd.ifmd_snd_maxlen = ifp->if_snd.ifq_maxlen; - ifmd.ifmd_snd_drops = ifp->if_snd.ifq_drops; + ifmd.ifmd_snd_drops = + ifp->if_get_counter(ifp, IFCOUNTER_OQDROPS); error = SYSCTL_OUT(req, &ifmd, sizeof ifmd); if (error) diff --git a/sys/net/if_spppfr.c b/sys/net/if_spppfr.c index 8fda38b8797e..d84cc46c7cb6 100644 --- a/sys/net/if_spppfr.c +++ b/sys/net/if_spppfr.c @@ -250,9 +250,9 @@ bad: m_freem (m); switch (proto) { default: - ++ifp->if_noproto; -drop: ++ifp->if_ierrors; - ++ifp->if_iqdrops; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); +drop: if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); m_freem (m); return; #ifdef INET @@ -394,7 +394,7 @@ void sppp_fr_keepalive (struct sppp *sp) (u_char) sp->pp_rseq[IDX_LCP]); if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* @@ -508,7 +508,7 @@ static void sppp_fr_arp (struct sppp *sp, struct arp_req *req, reply->ptarget2 = htonl (his_ip_address) >> 16; if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 3340612e6ff5..9dc55c5ba12c 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -518,7 +518,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) if (ifp->if_flags & IFF_UP) /* Count received bytes, add FCS and one flag */ - ifp->if_ibytes += m->m_pkthdr.len + 3; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len + 3); if (m->m_pkthdr.len <= PPP_HEADER_LEN) { /* Too small packet, drop it. */ @@ -530,8 +530,8 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) m_freem (m); SPPP_UNLOCK(sp); drop2: - ++ifp->if_ierrors; - ++ifp->if_iqdrops; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return; } @@ -570,7 +570,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) sppp_cp_send (sp, PPP_LCP, PROTO_REJ, ++sp->pp_seq[IDX_LCP], m->m_pkthdr.len + 2, &h->protocol); - ++ifp->if_noproto; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto drop; case PPP_LCP: sppp_cp_input(&lcp, sp, m); @@ -682,7 +682,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) } switch (ntohs (h->protocol)) { default: - ++ifp->if_noproto; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); goto invalid; case CISCO_KEEPALIVE: sppp_cisco_input (sp, m); @@ -906,7 +906,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, nobufs: if (debug) log(LOG_DEBUG, SPP_FMT "no memory for transmit header\n", SPP_ARGS(ifp)); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); SPPP_UNLOCK(sp); return (ENOBUFS); } @@ -966,7 +966,7 @@ nobufs: if (debug) #endif default: m_freem (m); - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); SPPP_UNLOCK(sp); return (EAFNOSUPPORT); } @@ -981,7 +981,7 @@ nobufs: if (debug) else IFQ_HANDOFF_ADJ(ifp, m, 3, error); if (error) { - ++ifp->if_oerrors; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); SPPP_UNLOCK(sp); return (rv? rv: ENOBUFS); } @@ -1393,7 +1393,7 @@ sppp_cisco_send(struct sppp *sp, int type, long par1, long par2) (u_long)ch->par2, (u_int)ch->rel, (u_int)ch->time0, (u_int)ch->time1); if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* @@ -1442,7 +1442,7 @@ sppp_cp_send(struct sppp *sp, u_short proto, u_char type, log(-1, ">\n"); } if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* @@ -1484,7 +1484,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s invalid conf-req length %d\n", SPP_ARGS(ifp), cp->name, len); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } /* handle states where RCR doesn't get a SCA/SCN */ @@ -1540,7 +1540,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case CONF_ACK: @@ -1549,7 +1549,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s id mismatch 0x%x != 0x%x\n", SPP_ARGS(ifp), cp->name, h->ident, sp->confid[cp->protoidx]); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } switch (sp->state[cp->protoidx]) { @@ -1584,7 +1584,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case CONF_NAK: @@ -1594,7 +1594,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) log(-1, SPP_FMT "%s id mismatch 0x%x != 0x%x\n", SPP_ARGS(ifp), cp->name, h->ident, sp->confid[cp->protoidx]); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } if (h->type == CONF_NAK) @@ -1634,7 +1634,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; @@ -1667,7 +1667,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case TERM_ACK: @@ -1698,7 +1698,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case CODE_REJ: @@ -1725,7 +1725,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; case PROTO_REJ: @@ -1784,7 +1784,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, sppp_cp_type_name(h->type), sppp_state_name(sp->state[cp->protoidx])); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } break; } @@ -1800,7 +1800,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) if (debug) log(-1, SPP_FMT "lcp echo req but lcp closed\n", SPP_ARGS(ifp)); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } if (len < 8) { @@ -1834,7 +1834,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) if (cp->proto != PPP_LCP) goto illegal; if (h->ident != sp->lcp.echoid) { - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); break; } if (len < 8) { @@ -1859,7 +1859,7 @@ sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m) SPP_ARGS(ifp), cp->name, h->type); sppp_cp_send(sp, cp->proto, CODE_REJ, ++sp->pp_seq[cp->protoidx], m->m_pkthdr.len, h); - ++ifp->if_ierrors; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); } } @@ -4740,7 +4740,7 @@ sppp_auth_send(const struct cp *cp, struct sppp *sp, log(-1, ">\n"); } if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3)) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } /* diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 7b6fbcfb7418..b92346e9ec45 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -442,7 +442,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /* just in case */ if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETDOWN; } @@ -454,7 +454,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, ia6 = stf_getsrcifa6(ifp); if (ia6 == NULL) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETDOWN; } @@ -462,7 +462,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m = m_pullup(m, sizeof(*ip6)); if (!m) { ifa_free(&ia6->ia_ifa); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENOBUFS; } } @@ -481,7 +481,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, else { ifa_free(&ia6->ia_ifa); m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETUNREACH; } bcopy(ptr, &in4, sizeof(in4)); @@ -503,7 +503,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m = m_pullup(m, sizeof(struct ip)); if (m == NULL) { ifa_free(&ia6->ia_ifa); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENOBUFS; } ip = mtod(m, struct ip *); @@ -549,7 +549,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if (sc->sc_ro.ro_rt == NULL) { m_freem(m); mtx_unlock(&(sc)->sc_ro_mtx); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENETUNREACH; } } @@ -557,7 +557,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, sendit: M_SETFIB(m, sc->sc_fibnum); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); error = ip_output(m, NULL, cached_route, 0, NULL, NULL); if (cached_route != NULL) @@ -770,8 +770,8 @@ in_stf_input(struct mbuf **mp, int *offp, int proto) * See net/if_gif.c for possible issues with packet processing * reorder due to extra queueing. */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); M_SETFIB(m, ifp->if_fib); netisr_dispatch(NETISR_IPV6, m); return (IPPROTO_DONE); diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 89cac22f264e..5de424ca9b45 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -682,7 +682,7 @@ tapifstart(struct ifnet *ifp) IF_DEQUEUE(&ifp->if_snd, m); if (m != NULL) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } else break; } @@ -707,7 +707,7 @@ tapifstart(struct ifnet *ifp) selwakeuppri(&tp->tap_rsel, PZERO+1); KNOTE_LOCKED(&tp->tap_rsel.si_note, 0); - ifp->if_opackets ++; /* obytes are counted in ether_output */ + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* obytes are counted in ether_output */ } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -947,7 +947,7 @@ tapwrite(struct cdev *dev, struct uio *uio, int flag) if ((m = m_uiotombuf(uio, M_NOWAIT, 0, ETHER_ALIGN, M_PKTHDR)) == NULL) { - ifp->if_ierrors ++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (ENOBUFS); } @@ -974,7 +974,7 @@ tapwrite(struct cdev *dev, struct uio *uio, int flag) CURVNET_SET(ifp->if_vnet); (*ifp->if_input)(ifp, m); CURVNET_RESTORE(); - ifp->if_ipackets ++; /* ibytes are counted in parent */ + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); /* ibytes are counted in parent */ return (0); } /* tapwrite */ diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index e4bc2afc7afc..89af2882643d 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -619,8 +619,8 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, /* if allocation failed drop packet */ if (m0 == NULL) { - ifp->if_iqdrops++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } else { bcopy(dst, m0->m_data, dst->sa_len); @@ -633,8 +633,8 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, /* if allocation failed drop packet */ if (m0 == NULL) { - ifp->if_iqdrops++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } else *(u_int32_t *)m0->m_data = htonl(af); @@ -651,7 +651,7 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, error = (ifp->if_transmit)(ifp, m0); if (error) return (ENOBUFS); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); return (0); } @@ -866,7 +866,7 @@ tunwrite(struct cdev *dev, struct uio *uio, int flag) } if ((m = m_uiotombuf(uio, M_NOWAIT, 0, 0, M_PKTHDR)) == NULL) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); return (ENOBUFS); } @@ -908,8 +908,8 @@ tunwrite(struct cdev *dev, struct uio *uio, int flag) } if (harvest.point_to_point) random_harvest(&(m->m_data), 12, 2, RANDOM_NET_TUN); - ifp->if_ibytes += m->m_pkthdr.len; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); CURVNET_SET(ifp->if_vnet); M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 3bffefe107c1..f043717e5d0b 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -96,7 +96,7 @@ VNET_DECLARE(struct pfil_head, link_pfil_hook); /* packet filter hooks */ #endif /* _KERNEL */ typedef enum { - IFCOUNTER_IPACKETS = 1, + IFCOUNTER_IPACKETS = 0, IFCOUNTER_IERRORS, IFCOUNTER_OPACKETS, IFCOUNTER_OERRORS, @@ -108,7 +108,8 @@ typedef enum { IFCOUNTER_IQDROPS, IFCOUNTER_OQDROPS, IFCOUNTER_NOPROTO, -} ifnet_counter; + IFCOUNTERS /* Array size. */ +} ift_counter; typedef struct ifnet * if_t; @@ -117,7 +118,13 @@ typedef int (*if_ioctl_fn_t)(if_t, u_long, caddr_t); typedef void (*if_init_fn_t)(void *); typedef void (*if_qflush_fn_t)(if_t); typedef int (*if_transmit_fn_t)(if_t, struct mbuf *); -typedef uint64_t (*if_get_counter_t)(if_t, ifnet_counter); +typedef uint64_t (*if_get_counter_t)(if_t, ift_counter); + +struct ifnet_hw_tsomax { + u_int tsomaxbytes; /* TSO total burst length limit in bytes */ + u_int tsomaxsegcount; /* TSO maximum segment count */ + u_int tsomaxsegsize; /* TSO maximum segment size in bytes */ +}; /* * Structure defining a network interface. @@ -221,27 +228,19 @@ struct ifnet { (struct ifnet *, struct vnet *, char *); if_get_counter_t if_get_counter; /* get counter values */ + /* Statistics. */ + counter_u64_t if_counters[IFCOUNTERS]; + /* Stuff that's only temporary and doesn't belong here. */ - u_int if_hw_tsomax; /* tso burst length limit, the minimum - * is (IP_MAXPACKET / 8). - * XXXAO: Have to find a better place - * for it eventually. */ - /* - * Old, racy and expensive statistics, should not be used in - * new drivers. - */ - uint64_t if_ipackets; /* packets received on interface */ - uint64_t if_ierrors; /* input errors on interface */ - uint64_t if_opackets; /* packets sent on interface */ - uint64_t if_oerrors; /* output errors on interface */ - uint64_t if_collisions; /* collisions on csma interfaces */ - uint64_t if_ibytes; /* total number of octets received */ - uint64_t if_obytes; /* total number of octets sent */ - uint64_t if_imcasts; /* packets received via multicast */ - uint64_t if_omcasts; /* packets sent via multicast */ - uint64_t if_iqdrops; /* dropped on input */ - uint64_t if_oqdrops; /* dropped on output */ - uint64_t if_noproto; /* destined for unsupported protocol */ + u_int if_hw_tsomax; /* TSO total burst length + * limit in bytes. A value of + * zero means no limit. Have + * to find a better place for + * it eventually. */ + + /* TSO fields for segment limits. If a field is zero below, there is no limit. */ + u_int if_hw_tsomaxsegcount; /* TSO maximum segment count */ + u_int if_hw_tsomaxsegsize; /* TSO maximum segment size in bytes */ /* * Spare fields to be added before branching a stable branch, so @@ -250,8 +249,6 @@ struct ifnet { */ }; -#include /* XXXAO: temporary unconditional include */ - /* for compatibility with other BSDs */ #define if_addrlist if_addrhead #define if_list if_link @@ -513,13 +510,10 @@ int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *, int fib); struct ifaddr *ifa_ifwithaddr(struct sockaddr *); int ifa_ifwithaddr_check(struct sockaddr *); -struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); -struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); -struct ifaddr *ifa_ifwithdstaddr_fib(struct sockaddr *, int); -struct ifaddr *ifa_ifwithnet(struct sockaddr *, int); -struct ifaddr *ifa_ifwithnet_fib(struct sockaddr *, int, int); -struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); -struct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int); +struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *, int); +struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *, int); +struct ifaddr *ifa_ifwithnet(struct sockaddr *, int, int); +struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *, u_int); struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *); int ifa_preferred(struct ifaddr *, struct ifaddr *); @@ -530,7 +524,8 @@ typedef void if_com_free_t(void *com, u_char type); void if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f); void if_deregister_com_alloc(u_char type); void if_data_copy(struct ifnet *, struct if_data *); -uint64_t if_get_counter_compat(struct ifnet *, ifnet_counter); +uint64_t if_get_counter_default(struct ifnet *, ift_counter); +void if_inc_counter(struct ifnet *, ift_counter, int64_t); #define IF_LLADDR(ifp) \ LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr)) @@ -584,33 +579,13 @@ int if_multiaddr_count(if_t ifp, int max); int if_getamcount(if_t ifp); struct ifaddr * if_getifaddr(if_t ifp); -/* Statistics */ - -int if_incipackets(if_t ifp, int pkt); -int if_incopackets(if_t ifp, int pkts); -int if_incierrors(if_t ifp, int ierrors); -int if_incoerrors(if_t ifp, int oerrors); -int if_inciqdrops(if_t ifp, int val); -int if_setierrors(if_t ifp, int ierrors); -int if_setoerrors(if_t ifp, int oerrors); -int if_setcollisions(if_t ifp, int collisions); -int if_inccollisions(if_t ifp, int collisions); -int if_incobytes(if_t ifp, int bytes); -int if_getiqdrops(if_t ifp); -int if_incimcasts(if_t ifp, int imcasts); -int if_incomcasts(if_t ifp, int imcasts); -int if_setipackets(if_t ifp, int pkts); -int if_setopackets(if_t ifp, int pkts); -int if_setibytes(if_t ifp, int bytes); -int if_setobytes(if_t ifp, int bytes); -int if_setimcasts(if_t ifp, int pkts); - /* Functions */ void if_setinitfn(if_t ifp, void (*)(void *)); void if_setioctlfn(if_t ifp, int (*)(if_t, u_long, caddr_t)); void if_setstartfn(if_t ifp, void (*)(if_t)); void if_settransmitfn(if_t ifp, if_transmit_fn_t); void if_setqflushfn(if_t ifp, if_qflush_fn_t); +void if_setgetcounterfn(if_t ifp, if_get_counter_t); /* Revisit the below. These are inline functions originally */ int drbr_inuse_drv(if_t ifp, struct buf_ring *br); @@ -618,5 +593,20 @@ struct mbuf* drbr_dequeue_drv(if_t ifp, struct buf_ring *br); int drbr_needs_enqueue_drv(if_t ifp, struct buf_ring *br); int drbr_enqueue_drv(if_t ifp, struct buf_ring *br, struct mbuf *m); +/* TSO */ +void if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *); +int if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsomax *); + +#ifdef DEVICE_POLLING +enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS }; + +typedef int poll_handler_t(if_t ifp, enum poll_cmd cmd, int count); +int ether_poll_register(poll_handler_t *h, if_t ifp); +int ether_poll_deregister(if_t ifp); +#endif /* DEVICE_POLLING */ + #endif /* _KERNEL */ + +#include /* XXXAO: temporary unconditional include */ + #endif /* !_NET_IF_VAR_H_ */ diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index f551ffd618fc..1be288882019 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -84,7 +84,7 @@ LIST_HEAD(ifvlanhead, ifvlan); struct ifvlantrunk { struct ifnet *parent; /* parent interface of this trunk */ - struct rwlock rw; + struct rmlock lock; #ifdef VLAN_ARRAY #define VLAN_ARRAY_SIZE (EVL_VLID_MASK + 1) struct ifvlan *vlans[VLAN_ARRAY_SIZE]; /* static table */ @@ -104,9 +104,15 @@ struct vlan_mc_entry { struct ifvlan { struct ifvlantrunk *ifv_trunk; struct ifnet *ifv_ifp; - void *ifv_cookie; + counter_u64_t ifv_ipackets; + counter_u64_t ifv_ibytes; + counter_u64_t ifv_opackets; + counter_u64_t ifv_obytes; + counter_u64_t ifv_omcasts; + counter_u64_t ifv_oerrors; #define TRUNK(ifv) ((ifv)->ifv_trunk) #define PARENT(ifv) ((ifv)->ifv_trunk->parent) + void *ifv_cookie; int ifv_pflags; /* special flags we have set on parent */ struct ifv_linkmib { int ifvm_encaplen; /* encapsulation length */ @@ -142,9 +148,10 @@ static SYSCTL_NODE(_net_link, IFT_L2VLAN, vlan, CTLFLAG_RW, 0, static SYSCTL_NODE(_net_link_vlan, PF_LINK, link, CTLFLAG_RW, 0, "for consistency"); -static int soft_pad = 0; -SYSCTL_INT(_net_link_vlan, OID_AUTO, soft_pad, CTLFLAG_RW, &soft_pad, 0, - "pad short frames before tagging"); +static VNET_DEFINE(int, soft_pad); +#define V_soft_pad VNET(soft_pad) +SYSCTL_INT(_net_link_vlan, OID_AUTO, soft_pad, CTLFLAG_RW | CTLFLAG_VNET, + &VNET_NAME(soft_pad), 0, "pad short frames before tagging"); static const char vlanname[] = "vlan"; static MALLOC_DEFINE(M_VLAN, vlanname, "802.1Q Virtual LAN Interface"); @@ -170,14 +177,15 @@ static struct sx ifv_lock; #define VLAN_LOCK_ASSERT() sx_assert(&ifv_lock, SA_LOCKED) #define VLAN_LOCK() sx_xlock(&ifv_lock) #define VLAN_UNLOCK() sx_xunlock(&ifv_lock) -#define TRUNK_LOCK_INIT(trunk) rw_init(&(trunk)->rw, vlanname) -#define TRUNK_LOCK_DESTROY(trunk) rw_destroy(&(trunk)->rw) -#define TRUNK_LOCK(trunk) rw_wlock(&(trunk)->rw) -#define TRUNK_UNLOCK(trunk) rw_wunlock(&(trunk)->rw) -#define TRUNK_LOCK_ASSERT(trunk) rw_assert(&(trunk)->rw, RA_WLOCKED) -#define TRUNK_RLOCK(trunk) rw_rlock(&(trunk)->rw) -#define TRUNK_RUNLOCK(trunk) rw_runlock(&(trunk)->rw) -#define TRUNK_LOCK_RASSERT(trunk) rw_assert(&(trunk)->rw, RA_RLOCKED) +#define TRUNK_LOCK_INIT(trunk) rm_init(&(trunk)->lock, vlanname) +#define TRUNK_LOCK_DESTROY(trunk) rm_destroy(&(trunk)->lock) +#define TRUNK_LOCK(trunk) rm_wlock(&(trunk)->lock) +#define TRUNK_UNLOCK(trunk) rm_wunlock(&(trunk)->lock) +#define TRUNK_LOCK_ASSERT(trunk) rm_assert(&(trunk)->lock, RA_WLOCKED) +#define TRUNK_RLOCK(trunk) rm_rlock(&(trunk)->lock, &tracker) +#define TRUNK_RUNLOCK(trunk) rm_runlock(&(trunk)->lock, &tracker) +#define TRUNK_LOCK_RASSERT(trunk) rm_assert(&(trunk)->lock, RA_RLOCKED) +#define TRUNK_LOCK_READER struct rm_priotracker tracker #ifndef VLAN_ARRAY static void vlan_inithash(struct ifvlantrunk *trunk); @@ -194,6 +202,7 @@ static void vlan_init(void *foo); static void vlan_input(struct ifnet *ifp, struct mbuf *m); static int vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr); static void vlan_qflush(struct ifnet *ifp); +static uint64_t vlan_get_counter(struct ifnet *ifp, ift_counter cnt); static int vlan_setflag(struct ifnet *ifp, int flag, int status, int (*func)(struct ifnet *, int)); static int vlan_setflags(struct ifnet *ifp, int status); @@ -681,6 +690,7 @@ vlan_devat(struct ifnet *ifp, uint16_t vid) { struct ifvlantrunk *trunk; struct ifvlan *ifv; + TRUNK_LOCK_READER; trunk = ifp->if_vlantrunk; if (trunk == NULL) @@ -945,6 +955,13 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) return (ENOSPC); } SLIST_INIT(&ifv->vlan_mc_listhead); + /* Prepare pcpu counters */ + ifv->ifv_ipackets = counter_u64_alloc(M_WAITOK); + ifv->ifv_opackets = counter_u64_alloc(M_WAITOK); + ifv->ifv_ibytes = counter_u64_alloc(M_WAITOK); + ifv->ifv_obytes = counter_u64_alloc(M_WAITOK); + ifv->ifv_omcasts = counter_u64_alloc(M_WAITOK); + ifv->ifv_oerrors = counter_u64_alloc(M_WAITOK); ifp->if_softc = ifv; /* @@ -964,6 +981,7 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifp->if_qflush = vlan_qflush; ifp->if_ioctl = vlan_ioctl; ifp->if_flags = VLAN_IFFLAGS; + ifp->if_get_counter = vlan_get_counter; ether_ifattach(ifp, eaddr); /* Now undo some of the damage... */ ifp->if_baudrate = 0; @@ -1006,6 +1024,12 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) ether_ifdetach(ifp); /* first, remove it from system-wide lists */ vlan_unconfig(ifp); /* now it can be unconfigured and freed */ if_free(ifp); + counter_u64_free(ifv->ifv_ipackets); + counter_u64_free(ifv->ifv_opackets); + counter_u64_free(ifv->ifv_ibytes); + counter_u64_free(ifv->ifv_obytes); + counter_u64_free(ifv->ifv_omcasts); + counter_u64_free(ifv->ifv_oerrors); free(ifv, M_VLAN); ifc_free_unit(ifc, unit); @@ -1043,7 +1067,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) */ if (!UP_AND_RUNNING(p)) { m_freem(m); - ifp->if_oerrors++; + counter_u64_add(ifv->ifv_oerrors, 1); return (ENETDOWN); } @@ -1059,7 +1083,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) * devices that just discard such runts instead or mishandle * them somehow. */ - if (soft_pad && p->if_type == IFT_ETHER) { + if (V_soft_pad && p->if_type == IFT_ETHER) { static char pad[8]; /* just zeros */ int n; @@ -1070,7 +1094,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) if (n > 0) { if_printf(ifp, "cannot pad short frame\n"); - ifp->if_oerrors++; + counter_u64_add(ifv->ifv_oerrors, 1); m_freem(m); return (0); } @@ -1090,7 +1114,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) m = ether_vlanencap(m, ifv->ifv_vid); if (m == NULL) { if_printf(ifp, "unable to prepend VLAN header\n"); - ifp->if_oerrors++; + counter_u64_add(ifv->ifv_oerrors, 1); return (0); } } @@ -1099,15 +1123,41 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m) * Send it, precisely as ether_output() would have. */ error = (p->if_transmit)(p, m); - if (!error) { - ifp->if_opackets++; - ifp->if_omcasts += mcast; - ifp->if_obytes += len; + if (error == 0) { + counter_u64_add(ifv->ifv_opackets, 1); + counter_u64_add(ifv->ifv_obytes, len); + counter_u64_add(ifv->ifv_omcasts, mcast); } else - ifp->if_oerrors++; + counter_u64_add(ifv->ifv_oerrors, 1); return (error); } +static uint64_t +vlan_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + struct ifvlan *ifv; + + ifv = ifp->if_softc; + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (counter_u64_fetch(ifv->ifv_ipackets)); + case IFCOUNTER_OPACKETS: + return (counter_u64_fetch(ifv->ifv_opackets)); + case IFCOUNTER_IBYTES: + return (counter_u64_fetch(ifv->ifv_ibytes)); + case IFCOUNTER_OBYTES: + return (counter_u64_fetch(ifv->ifv_obytes)); + case IFCOUNTER_OMCASTS: + return (counter_u64_fetch(ifv->ifv_omcasts)); + case IFCOUNTER_OERRORS: + return (counter_u64_fetch(ifv->ifv_oerrors)); + default: + return (if_get_counter_default(ifp, cnt)); + } + /* NOTREACHED */ +} + /* * The ifp->if_qflush entry point for vlan(4) is a no-op. */ @@ -1121,6 +1171,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) { struct ifvlantrunk *trunk = ifp->if_vlantrunk; struct ifvlan *ifv; + TRUNK_LOCK_READER; uint16_t vid; KASSERT(trunk != NULL, ("%s: no trunk", __func__)); @@ -1165,7 +1216,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) __func__, ifp->if_xname, ifp->if_type); #endif m_freem(m); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); return; } } @@ -1175,13 +1226,14 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) if (ifv == NULL || !UP_AND_RUNNING(ifv->ifv_ifp)) { TRUNK_RUNLOCK(trunk); m_freem(m); - ifp->if_noproto++; + if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1); return; } TRUNK_RUNLOCK(trunk); m->m_pkthdr.rcvif = ifv->ifv_ifp; - ifv->ifv_ifp->if_ipackets++; + counter_u64_add(ifv->ifv_ipackets, 1); + counter_u64_add(ifv->ifv_ibytes, m->m_pkthdr.len); /* Pass it back through the parent's input routine. */ (*ifp->if_input)(ifv->ifv_ifp, m); @@ -1485,6 +1537,7 @@ vlan_capabilities(struct ifvlan *ifv) { struct ifnet *p = PARENT(ifv); struct ifnet *ifp = ifv->ifv_ifp; + struct ifnet_hw_tsomax hw_tsomax; TRUNK_LOCK_ASSERT(TRUNK(ifv)); @@ -1511,8 +1564,9 @@ vlan_capabilities(struct ifvlan *ifv) * propagate the hardware-assisted flag. TSO on VLANs * does not necessarily require hardware VLAN tagging. */ - if (p->if_hw_tsomax > 0) - ifp->if_hw_tsomax = p->if_hw_tsomax; + memset(&hw_tsomax, 0, sizeof(hw_tsomax)); + if_hw_tsomax_common(p, &hw_tsomax); + if_hw_tsomax_update(ifp, &hw_tsomax); if (p->if_capabilities & IFCAP_VLAN_HWTSO) ifp->if_capabilities |= p->if_capabilities & IFCAP_TSO; if (p->if_capenable & IFCAP_VLAN_HWTSO) { diff --git a/sys/net/ifq.h b/sys/net/ifq.h index cf0c5066fea1..d1fc3fe9e083 100644 --- a/sys/net/ifq.h +++ b/sys/net/ifq.h @@ -41,6 +41,10 @@ #include /* XXX */ #include /* struct ifqueue */ +/* + * Couple of ugly extra definitions that are required since ifq.h + * is splitted from if_var.h. + */ #define IF_DUNIT_NONE -1 #include @@ -53,7 +57,6 @@ struct ifqueue { struct mbuf *ifq_tail; int ifq_len; int ifq_maxlen; - int ifq_drops; struct mtx ifq_mtx; }; @@ -68,7 +71,6 @@ struct ifqueue { #define IF_UNLOCK(ifq) mtx_unlock(&(ifq)->ifq_mtx) #define IF_LOCK_ASSERT(ifq) mtx_assert(&(ifq)->ifq_mtx, MA_OWNED) #define _IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) -#define _IF_DROP(ifq) ((ifq)->ifq_drops++) #define _IF_QLEN(ifq) ((ifq)->ifq_len) #define _IF_ENQUEUE(ifq, m) do { \ @@ -171,8 +173,6 @@ do { \ (err) = 0; \ } \ } \ - if (err) \ - (ifq)->ifq_drops++; \ IF_UNLOCK(ifq); \ } while (0) @@ -234,7 +234,6 @@ do { \ #define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0) #define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++) #define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len) -#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++) #define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len)) /* @@ -250,12 +249,13 @@ do { \ mflags = (m)->m_flags; \ IFQ_ENQUEUE(&(ifp)->if_snd, m, err); \ if ((err) == 0) { \ - (ifp)->if_obytes += len + (adj); \ + if_inc_counter((ifp), IFCOUNTER_OBYTES, len + (adj)); \ if (mflags & M_MCAST) \ - (ifp)->if_omcasts++; \ + if_inc_counter((ifp), IFCOUNTER_OMCASTS, 1); \ if (((ifp)->if_drv_flags & IFF_DRV_OACTIVE) == 0) \ if_start(ifp); \ - } \ + } else \ + if_inc_counter((ifp), IFCOUNTER_OQDROPS, 1); \ } while (0) #define IFQ_HANDOFF(ifp, m, err) \ @@ -321,6 +321,8 @@ drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m) #ifdef ALTQ if (ALTQ_IS_ENABLED(&ifp->if_snd)) { IFQ_ENQUEUE(&ifp->if_snd, m, error); + if (error) + if_inc_counter((ifp), IFCOUNTER_OQDROPS, 1); return (error); } #endif @@ -478,17 +480,5 @@ void if_qflush(struct ifnet *); void ifq_init(struct ifaltq *, struct ifnet *ifp); void ifq_delete(struct ifaltq *); -#ifdef DEVICE_POLLING -enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS }; - -typedef int poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count); -int ether_poll_register(poll_handler_t *h, struct ifnet *ifp); -int ether_poll_deregister(struct ifnet *ifp); -/* The following should be temporary, till all drivers use the driver API */ -typedef int poll_handler_drv_t(if_t ifh, enum poll_cmd cmd, int count); -int ether_poll_register_drv(poll_handler_drv_t *h, if_t ifh); -int ether_poll_deregister_drv(if_t ifh); -#endif /* DEVICE_POLLING */ - #endif /* _KERNEL */ #endif /* !_NET_IFQ_H_ */ diff --git a/sys/net/netisr.h b/sys/net/netisr.h index b011c2162bb6..94a6cc479c5f 100644 --- a/sys/net/netisr.h +++ b/sys/net/netisr.h @@ -57,6 +57,8 @@ #define NETISR_IPV6 6 #define NETISR_NATM 7 #define NETISR_EPAIR 8 /* if_epair(4) */ +#define NETISR_IP_DIRECT 9 /* direct-dispatch IPv4 */ +#define NETISR_IPV6_DIRECT 10 /* direct-dispatch IPv6 */ /* * Protocol ordering and affinity policy constants. See the detailed diff --git a/sys/net/radix.c b/sys/net/radix.c index 62f57f80dac2..0447cba6f665 100644 --- a/sys/net/radix.c +++ b/sys/net/radix.c @@ -1122,9 +1122,6 @@ rn_inithead_internal(void **head, int off) R_Zalloc(rnh, struct radix_node_head *, sizeof (*rnh)); if (rnh == 0) return (0); -#ifdef _KERNEL - RADIX_NODE_HEAD_LOCK_INIT(rnh); -#endif *head = rnh; t = rn_newpair(rn_zeros, off, rnh->rnh_nodes); ttt = rnh->rnh_nodes + 2; @@ -1181,6 +1178,18 @@ rn_inithead(void **head, int off) return (1); } +static int +rn_freeentry(struct radix_node *rn, void *arg) +{ + struct radix_node_head * const rnh = arg; + struct radix_node *x; + + x = (struct radix_node *)rn_delete(rn + 2, NULL, rnh); + if (x != NULL) + Free(x); + return (0); +} + int rn_detachhead(void **head) { @@ -1191,6 +1200,7 @@ rn_detachhead(void **head) rnh = *head; + rn_walktree(rnh->rnh_masks, rn_freeentry, rnh->rnh_masks); rn_detachhead_internal((void **)&rnh->rnh_masks); rn_detachhead_internal(head); return (1); diff --git a/sys/net/route.c b/sys/net/route.c index 547418af84b9..38e610a841a3 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -108,9 +108,9 @@ SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, ""); * always work given the fib can be overridden and prefixes can be added * from the network stack context. */ -u_int rt_add_addr_allfibs = 1; -SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN, - &rt_add_addr_allfibs, 0, ""); +VNET_DEFINE(u_int, rt_add_addr_allfibs) = 1; +SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN | CTLFLAG_VNET, + &VNET_NAME(rt_add_addr_allfibs), 0, ""); VNET_DEFINE(struct rtstat, rtstat); #define V_rtstat VNET(rtstat) @@ -570,7 +570,7 @@ rtredirect_fib(struct sockaddr *dst, } /* verify the gateway is directly reachable */ - if ((ifa = ifa_ifwithnet_fib(gateway, 0, fibnum)) == NULL) { + if ((ifa = ifa_ifwithnet(gateway, 0, fibnum)) == NULL) { error = ENETUNREACH; goto out; } @@ -700,18 +700,8 @@ rtioctl_fib(u_long req, caddr_t data, u_int fibnum) #endif /* INET */ } -/* - * For both ifa_ifwithroute() routines, 'ifa' is returned referenced. - */ struct ifaddr * -ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) -{ - - return (ifa_ifwithroute_fib(flags, dst, gateway, RT_DEFAULT_FIB)); -} - -struct ifaddr * -ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway, +ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway, u_int fibnum) { struct ifaddr *ifa; @@ -727,7 +717,7 @@ ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway, */ ifa = NULL; if (flags & RTF_HOST) - ifa = ifa_ifwithdstaddr_fib(dst, fibnum); + ifa = ifa_ifwithdstaddr(dst, fibnum); if (ifa == NULL) ifa = ifa_ifwithaddr(gateway); } else { @@ -736,10 +726,10 @@ ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway, * or host, the gateway may still be on the * other end of a pt to pt link. */ - ifa = ifa_ifwithdstaddr_fib(gateway, fibnum); + ifa = ifa_ifwithdstaddr(gateway, fibnum); } if (ifa == NULL) - ifa = ifa_ifwithnet_fib(gateway, 0, fibnum); + ifa = ifa_ifwithnet(gateway, 0, fibnum); if (ifa == NULL) { struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum); if (rt == NULL) @@ -853,7 +843,7 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) */ if (info->rti_ifp == NULL && ifpaddr != NULL && ifpaddr->sa_family == AF_LINK && - (ifa = ifa_ifwithnet_fib(ifpaddr, 0, fibnum)) != NULL) { + (ifa = ifa_ifwithnet(ifpaddr, 0, fibnum)) != NULL) { info->rti_ifp = ifa->ifa_ifp; ifa_free(ifa); } @@ -867,10 +857,10 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) if (sa != NULL && info->rti_ifp != NULL) info->rti_ifa = ifaof_ifpforaddr(sa, info->rti_ifp); else if (dst != NULL && gateway != NULL) - info->rti_ifa = ifa_ifwithroute_fib(flags, dst, gateway, + info->rti_ifa = ifa_ifwithroute(flags, dst, gateway, fibnum); else if (sa != NULL) - info->rti_ifa = ifa_ifwithroute_fib(flags, sa, sa, + info->rti_ifa = ifa_ifwithroute(flags, sa, sa, fibnum); } if ((ifa = info->rti_ifa) != NULL) { @@ -1623,9 +1613,9 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum) break; } if (fibnum == RT_ALL_FIBS) { - if (rt_add_addr_allfibs == 0 && cmd == (int)RTM_ADD) { + if (V_rt_add_addr_allfibs == 0 && cmd == (int)RTM_ADD) startfib = endfib = ifa->ifa_ifp->if_fib; - } else { + else { startfib = 0; endfib = rt_numfibs - 1; } diff --git a/sys/net/route.h b/sys/net/route.h index df2fc5864a57..bbdf98dfc7c1 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -34,6 +34,7 @@ #define _NET_ROUTE_H_ #include +#include /* * Kernel resident routing tables. @@ -84,8 +85,11 @@ struct rt_metrics { #define RT_DEFAULT_FIB 0 /* Explicitly mark fib=0 restricted cases */ #define RT_ALL_FIBS -1 /* Announce event for every fib */ +#ifdef _KERNEL extern u_int rt_numfibs; /* number of usable routing tables */ -extern u_int rt_add_addr_allfibs; /* Announce interfaces to all fibs */ +VNET_DECLARE(u_int, rt_add_addr_allfibs); /* Announce interfaces to all fibs */ +#define V_rt_add_addr_allfibs VNET(rt_add_addr_allfibs) +#endif /* * We distinguish between routes to hosts and routes to networks, diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 10baeb2aa070..6fcbbc6ec431 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -752,7 +752,8 @@ route_output(struct mbuf *m, struct socket *so, ...) rt->rt_ifp->if_type == IFT_PROPVIRTUAL) { struct ifaddr *ifa; - ifa = ifa_ifwithnet(info.rti_info[RTAX_DST], 1); + ifa = ifa_ifwithnet(info.rti_info[RTAX_DST], 1, + RT_ALL_FIBS); if (ifa != NULL) rt_maskedcopy(ifa->ifa_addr, &laddr, @@ -1576,9 +1577,6 @@ sysctl_iflist_ifml(struct ifnet *ifp, struct rt_addrinfo *info, if_data_copy(ifp, ifd); - /* Some drivers still use ifqueue(9), add its stats. */ - ifd->ifi_oqdrops += ifp->if_snd.ifq_drops; - return (SYSCTL_OUT(w->w_req, (caddr_t)ifm, len)); } @@ -1611,9 +1609,6 @@ sysctl_iflist_ifm(struct ifnet *ifp, struct rt_addrinfo *info, if_data_copy(ifp, ifd); - /* Some drivers still use ifqueue(9), add its stats. */ - ifd->ifi_oqdrops += ifp->if_snd.ifq_drops; - return (SYSCTL_OUT(w->w_req, (caddr_t)ifm, len)); } diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 73018c18ebaa..e406f0f6fa76 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -238,7 +238,7 @@ static int null_transmit(struct ifnet *ifp, struct mbuf *m) { m_freem(m); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return EACCES; /* XXX EIO/EPERM? */ } diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c index 181b9220de62..c1b4b518a289 100644 --- a/sys/net80211/ieee80211_adhoc.c +++ b/sys/net80211/ieee80211_adhoc.c @@ -653,7 +653,7 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c index 8cb97b04f6a1..32eec45975c2 100644 --- a/sys/net80211/ieee80211_hostap.c +++ b/sys/net80211/ieee80211_hostap.c @@ -368,7 +368,7 @@ hostap_deliver_data(struct ieee80211vap *vap, /* * Do accounting. */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); IEEE80211_NODE_STAT(ni, rx_data); IEEE80211_NODE_STAT_ADD(ni, rx_bytes, m->m_pkthdr.len); if (ETHER_IS_MULTICAST(eh->ether_dhost)) { @@ -384,7 +384,7 @@ hostap_deliver_data(struct ieee80211vap *vap, if (m->m_flags & M_MCAST) { mcopy = m_dup(m, M_NOWAIT); if (mcopy == NULL) - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); else mcopy->m_flags |= M_MCAST; } else { @@ -422,7 +422,7 @@ hostap_deliver_data(struct ieee80211vap *vap, if (err) { /* NB: IFQ_HANDOFF reclaims mcopy */ } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } } } @@ -909,7 +909,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 6ea4f9bfcce8..a0f737dc2036 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -261,7 +261,7 @@ ieee80211_deliver_data(struct ieee80211vap *vap, /* * Do accounting. */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); IEEE80211_NODE_STAT(ni, rx_data); IEEE80211_NODE_STAT_ADD(ni, rx_bytes, m->m_pkthdr.len); if (ETHER_IS_MULTICAST(eh->ether_dhost)) { diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c index 51db327d9fad..e84d7f777bd7 100644 --- a/sys/net80211/ieee80211_mesh.c +++ b/sys/net80211/ieee80211_mesh.c @@ -1047,7 +1047,7 @@ mesh_transmit_to_gate(struct ieee80211vap *vap, struct mbuf *m, ni = ieee80211_mesh_find_txnode(vap, rt_gate->rt_dest); if (ni == NULL) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); return; } @@ -1183,7 +1183,7 @@ mesh_forward(struct ieee80211vap *vap, struct mbuf *m, IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, cannot dup"); vap->iv_stats.is_mesh_fwd_nobuf++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return; } mcopy = m_pullup(mcopy, ieee80211_hdrspace(ic, wh) + @@ -1192,7 +1192,7 @@ mesh_forward(struct ieee80211vap *vap, struct mbuf *m, IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, too short"); vap->iv_stats.is_mesh_fwd_tooshort++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(mcopy); return; } @@ -1250,7 +1250,7 @@ mesh_forward(struct ieee80211vap *vap, struct mbuf *m, /* NB: IFQ_HANDOFF reclaims mbuf */ ieee80211_free_node(ni); } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } } @@ -1844,7 +1844,7 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) @@ -3333,8 +3333,9 @@ mesh_airtime_calc(struct ieee80211_node *ni) ifp->if_mtu + IEEE80211_MESH_MAXOVERHEAD, rate, 0) << M_BITS; /* Error rate in percentage */ /* XXX assuming small failures are ok */ - errrate = (((ifp->if_oerrors + - ifp->if_ierrors) / 100) << M_BITS) / 100; + errrate = (((ifp->if_get_counter(ifp, IFCOUNTER_OERRORS) + + ifp->if_get_counter(ifp, IFCOUNTER_IERRORS)) / 100) << M_BITS) + / 100; res = (overhead + (nbits / rate)) * ((1 << S_FACTOR) / ((1 << M_BITS) - errrate)); diff --git a/sys/net80211/ieee80211_monitor.c b/sys/net80211/ieee80211_monitor.c index f52b0fb0763c..8909339bde29 100644 --- a/sys/net80211/ieee80211_monitor.c +++ b/sys/net80211/ieee80211_monitor.c @@ -130,7 +130,7 @@ monitor_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) struct ieee80211vap *vap = ni->ni_vap; struct ifnet *ifp = vap->iv_ifp; - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if (ieee80211_radiotap_active_vap(vap)) ieee80211_radiotap_rx(vap, m); diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index b923600108dd..a8d92f976283 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -157,7 +157,7 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m, ni->ni_macaddr, NULL, "%s", "classification failure"); vap->iv_stats.is_tx_classify++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); ieee80211_free_node(ni); @@ -251,7 +251,7 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m, /* NB: IFQ_HANDOFF reclaims mbuf */ ieee80211_free_node(ni); } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } ic->ic_lastdata = ticks; @@ -299,7 +299,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m) IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, "discard frame, %s\n", "m_pullup failed"); vap->iv_stats.is_tx_nobuf++; /* XXX */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENOBUFS); } eh = mtod(m, struct ether_header *); @@ -332,7 +332,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m) ni = ieee80211_find_txnode(vap, eh->ether_dhost); if (ni == NULL) { /* NB: ieee80211_find_txnode does stat+msg */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); /* XXX better status? */ return (ENOBUFS); @@ -344,7 +344,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m) "sta not associated (type 0x%04x)", htons(eh->ether_type)); vap->iv_stats.is_tx_notassoc++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); ieee80211_free_node(ni); /* XXX better status? */ @@ -363,7 +363,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m) eh->ether_dhost, NULL, "%s", "proxy not enabled"); vap->iv_stats.is_mesh_notproxy++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(m); /* XXX better status? */ return (ENOBUFS); @@ -380,7 +380,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m) * NB: ieee80211_mesh_discover holds/disposes * frame (e.g. queueing on path discovery). */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* XXX better status? */ return (ENOBUFS); } @@ -608,7 +608,7 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m, if (ieee80211_classify(ni, m)) senderr(EIO); /* XXX */ - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); IEEE80211_NODE_STAT(ni, tx_data); if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { IEEE80211_NODE_STAT(ni, tx_mcast); @@ -636,7 +636,7 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m, m_freem(m); if (ni != NULL) ieee80211_free_node(ni); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return error; #undef senderr } diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c index 302ddfcfafa0..89ed85627d60 100644 --- a/sys/net80211/ieee80211_sta.c +++ b/sys/net80211/ieee80211_sta.c @@ -938,7 +938,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/net80211/ieee80211_superg.c b/sys/net80211/ieee80211_superg.c index 94af70d53880..598c17ef7fa9 100644 --- a/sys/net80211/ieee80211_superg.c +++ b/sys/net80211/ieee80211_superg.c @@ -480,7 +480,7 @@ ff_transmit(struct ieee80211_node *ni, struct mbuf *m) /* NB: IFQ_HANDOFF reclaims mbuf */ ieee80211_free_node(ni); } else { - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } } else ieee80211_free_node(ni); diff --git a/sys/net80211/ieee80211_wds.c b/sys/net80211/ieee80211_wds.c index fdeaf25f06ae..ec1bd856062c 100644 --- a/sys/net80211/ieee80211_wds.c +++ b/sys/net80211/ieee80211_wds.c @@ -258,14 +258,14 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m) */ mcopy = m_copypacket(m, M_NOWAIT); if (mcopy == NULL) { - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* XXX stat + msg */ continue; } ni = ieee80211_find_txnode(vap, eh->ether_dhost); if (ni == NULL) { /* NB: ieee80211_find_txnode does stat+msg */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(mcopy); continue; } @@ -276,7 +276,7 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m) eh->ether_dhost, NULL, "%s", "classification failure"); vap->iv_stats.is_tx_classify++; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); m_freem(mcopy); ieee80211_free_node(ni); continue; @@ -299,10 +299,10 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m) err = ieee80211_parent_xmitpkt(ic, mcopy); if (err) { /* NB: IFQ_HANDOFF reclaims mbuf */ - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); ieee80211_free_node(ni); } else - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } } @@ -730,7 +730,7 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) break; } err: - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); out: if (m != NULL) { if (need_tap && ieee80211_radiotap_active_vap(vap)) diff --git a/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c b/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c index f2930abcdb02..9b174bb4c34e 100644 --- a/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c +++ b/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c @@ -560,7 +560,6 @@ ng_bt3c_rcvdata(hook_p hook, item_p item) NG_BT3C_ERR(sc->dev, "Outgoing queue is full. Dropping mbuf, len=%d\n", m->m_pkthdr.len); - _IF_DROP(&sc->outq); NG_BT3C_STAT_OERROR(sc->stat); NG_FREE_M(m); @@ -939,7 +938,6 @@ bt3c_receive(bt3c_softc_p sc) NG_BT3C_ERR(sc->dev, "Incoming queue is full. Dropping mbuf, len=%d\n", sc->m->m_pkthdr.len); - _IF_DROP(&sc->inq); NG_BT3C_STAT_IERROR(sc->stat); NG_FREE_M(sc->m); diff --git a/sys/netgraph/bluetooth/drivers/h4/ng_h4.c b/sys/netgraph/bluetooth/drivers/h4/ng_h4.c index 97cee2ed29ad..5cb0386b0ba6 100644 --- a/sys/netgraph/bluetooth/drivers/h4/ng_h4.c +++ b/sys/netgraph/bluetooth/drivers/h4/ng_h4.c @@ -798,7 +798,6 @@ ng_h4_rcvdata(hook_p hook, item_p item) NG_NODE_NAME(sc->node), m->m_pkthdr.len); NG_H4_STAT_OERROR(sc->stat); - _IF_DROP(&sc->outq); NG_H4_UNLOCK(sc); diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h b/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h index deea5b3db0df..493ea42146a6 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h @@ -162,7 +162,7 @@ struct ng_btsocket_l2cap_pcb { u_int16_t flush_timo; /* flush timeout */ u_int16_t link_timo; /* link timeout */ - struct callout_handle timo; /* timeout */ + struct callout timo; /* timeout */ u_int32_t token; /* message token */ ng_btsocket_l2cap_rtentry_p rt; /* routing info */ diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h b/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h index 4aaa658bd9ee..fdc1d00cbe6e 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h @@ -296,7 +296,7 @@ struct ng_btsocket_rfcomm_pcb { int16_t tx_cred; /* TX credits */ struct mtx pcb_mtx; /* PCB lock */ - struct callout_handle timo; /* timeout */ + struct callout timo; /* timeout */ LIST_ENTRY(ng_btsocket_rfcomm_pcb) session_next;/* link to next */ LIST_ENTRY(ng_btsocket_rfcomm_pcb) next; /* link to next */ diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c index af2ce1a5f468..bab8bbbbdd85 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c @@ -1967,8 +1967,6 @@ ng_btsocket_l2cap_attach(struct socket *so, int proto, struct thread *td) pcb->flush_timo = NG_L2CAP_FLUSH_TIMO_DEFAULT; pcb->link_timo = NG_L2CAP_LINK_TIMO_DEFAULT; - callout_handle_init(&pcb->timo); - /* * XXX Mark PCB mutex as DUPOK to prevent "duplicated lock of * the same type" message. When accepting new L2CAP connection @@ -1978,6 +1976,7 @@ ng_btsocket_l2cap_attach(struct socket *so, int proto, struct thread *td) mtx_init(&pcb->pcb_mtx, "btsocks_l2cap_pcb_mtx", NULL, MTX_DEF|MTX_DUPOK); + callout_init_mtx(&pcb->timo, &pcb->pcb_mtx, 0); /* * Add the PCB to the list @@ -2664,8 +2663,8 @@ ng_btsocket_l2cap_timeout(ng_btsocket_l2cap_pcb_p pcb) if (!(pcb->flags & NG_BTSOCKET_L2CAP_TIMO)) { pcb->flags |= NG_BTSOCKET_L2CAP_TIMO; - pcb->timo = timeout(ng_btsocket_l2cap_process_timeout, pcb, - bluetooth_l2cap_ertx_timeout()); + callout_reset(&pcb->timo, bluetooth_l2cap_ertx_timeout(), + ng_btsocket_l2cap_process_timeout, pcb); } else KASSERT(0, ("%s: Duplicated socket timeout?!\n", __func__)); @@ -2681,7 +2680,7 @@ ng_btsocket_l2cap_untimeout(ng_btsocket_l2cap_pcb_p pcb) mtx_assert(&pcb->pcb_mtx, MA_OWNED); if (pcb->flags & NG_BTSOCKET_L2CAP_TIMO) { - untimeout(ng_btsocket_l2cap_process_timeout, pcb, pcb->timo); + callout_stop(&pcb->timo); pcb->flags &= ~NG_BTSOCKET_L2CAP_TIMO; } else KASSERT(0, @@ -2697,7 +2696,7 @@ ng_btsocket_l2cap_process_timeout(void *xpcb) { ng_btsocket_l2cap_pcb_p pcb = (ng_btsocket_l2cap_pcb_p) xpcb; - mtx_lock(&pcb->pcb_mtx); + mtx_assert(&pcb->pcb_mtx, MA_OWNED); pcb->flags &= ~NG_BTSOCKET_L2CAP_TIMO; pcb->so->so_error = ETIMEDOUT; @@ -2731,8 +2730,6 @@ ng_btsocket_l2cap_process_timeout(void *xpcb) "%s: Invalid socket state=%d\n", __func__, pcb->state); break; } - - mtx_unlock(&pcb->pcb_mtx); } /* ng_btsocket_l2cap_process_timeout */ /* diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c b/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c index 215843cf94b6..cb3753d4bf04 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c @@ -434,7 +434,7 @@ ng_btsocket_rfcomm_attach(struct socket *so, int proto, struct thread *td) pcb->rx_cred = RFCOMM_DEFAULT_CREDITS; mtx_init(&pcb->pcb_mtx, "btsocks_rfcomm_pcb_mtx", NULL, MTX_DEF); - callout_handle_init(&pcb->timo); + callout_init_mtx(&pcb->timo, &pcb->pcb_mtx, 0); /* Add the PCB to the list */ mtx_lock(&ng_btsocket_rfcomm_sockets_mtx); @@ -3451,8 +3451,8 @@ ng_btsocket_rfcomm_timeout(ng_btsocket_rfcomm_pcb_p pcb) if (!(pcb->flags & NG_BTSOCKET_RFCOMM_DLC_TIMO)) { pcb->flags |= NG_BTSOCKET_RFCOMM_DLC_TIMO; pcb->flags &= ~NG_BTSOCKET_RFCOMM_DLC_TIMEDOUT; - pcb->timo = timeout(ng_btsocket_rfcomm_process_timeout, pcb, - ng_btsocket_rfcomm_timo * hz); + callout_reset(&pcb->timo, ng_btsocket_rfcomm_timo * hz, + ng_btsocket_rfcomm_process_timeout, pcb); } else panic("%s: Duplicated socket timeout?!\n", __func__); } /* ng_btsocket_rfcomm_timeout */ @@ -3467,7 +3467,7 @@ ng_btsocket_rfcomm_untimeout(ng_btsocket_rfcomm_pcb_p pcb) mtx_assert(&pcb->pcb_mtx, MA_OWNED); if (pcb->flags & NG_BTSOCKET_RFCOMM_DLC_TIMO) { - untimeout(ng_btsocket_rfcomm_process_timeout, pcb, pcb->timo); + callout_stop(&pcb->timo); pcb->flags &= ~NG_BTSOCKET_RFCOMM_DLC_TIMO; pcb->flags &= ~NG_BTSOCKET_RFCOMM_DLC_TIMEDOUT; } else @@ -3483,7 +3483,7 @@ ng_btsocket_rfcomm_process_timeout(void *xpcb) { ng_btsocket_rfcomm_pcb_p pcb = (ng_btsocket_rfcomm_pcb_p) xpcb; - mtx_lock(&pcb->pcb_mtx); + mtx_assert(&pcb->pcb_mtx, MA_OWNED); NG_BTSOCKET_RFCOMM_INFO( "%s: Timeout, so=%p, dlci=%d, state=%d, flags=%#x\n", @@ -3510,8 +3510,6 @@ ng_btsocket_rfcomm_process_timeout(void *xpcb) } ng_btsocket_rfcomm_task_wakeup(); - - mtx_unlock(&pcb->pcb_mtx); } /* ng_btsocket_rfcomm_process_timeout */ /* diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c index 723fbca8379e..cb40e69a9ae2 100644 --- a/sys/netgraph/ng_device.c +++ b/sys/netgraph/ng_device.c @@ -270,7 +270,6 @@ ng_device_rcvdata(hook_p hook, item_p item) IF_LOCK(&priv->readq); if (_IF_QFULL(&priv->readq)) { - _IF_DROP(&priv->readq); IF_UNLOCK(&priv->readq); NG_FREE_M(m); return (ENOBUFS); diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index a390e1bbc876..ae573da02541 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -247,7 +247,7 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2) BPF_MTAP(ifp, m); if (ifp->if_flags & IFF_MONITOR) { - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m_freem(m); continue; } @@ -262,9 +262,9 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2) /* Update stats */ if (error == 0) - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); else - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -597,7 +597,7 @@ ng_eiface_rcvdata(hook_p hook, item_p item) m->m_pkthdr.rcvif = ifp; /* Update interface stats */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); (*ifp->if_input)(ifp, m); diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index b44dcdd4f86e..7326d3e42381 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -393,10 +393,7 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m, if (ALTQ_IS_ENABLED(&ifp->if_snd)) { M_PREPEND(m, sizeof(sa_family_t), M_NOWAIT); if (m == NULL) { - IFQ_LOCK(&ifp->if_snd); - IFQ_INC_DROPS(&ifp->if_snd); - IFQ_UNLOCK(&ifp->if_snd); - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); return (ENOBUFS); } *(sa_family_t *)m->m_data = af; @@ -472,8 +469,8 @@ ng_iface_send(struct ifnet *ifp, struct mbuf *m, sa_family_t sa) /* Update stats. */ if (error == 0) { - ifp->if_obytes += len; - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OBYTES, len); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } return (error); @@ -736,8 +733,8 @@ ng_iface_rcvdata(hook_p hook, item_p item) } /* Update interface stats */ - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* Note receiving interface */ m->m_pkthdr.rcvif = ifp; diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index 9db1a2fb1eb5..e1a8a2a31985 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -237,6 +237,7 @@ static ng_rcvdata_t ng_ppp_rcvdata; static ng_disconnect_t ng_ppp_disconnect; static ng_rcvdata_t ng_ppp_rcvdata_inet; +static ng_rcvdata_t ng_ppp_rcvdata_inet_fast; static ng_rcvdata_t ng_ppp_rcvdata_ipv6; static ng_rcvdata_t ng_ppp_rcvdata_ipx; static ng_rcvdata_t ng_ppp_rcvdata_atalk; @@ -659,7 +660,7 @@ ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook) &priv->bundleStats : &priv->links[linkNum].stats; /* Make 64bit reply. */ - if (msg->header.cmd == NGM_PPP_GET_LINK_STATS64 || + if (msg->header.cmd == NGM_PPP_GET_LINK_STATS64 || msg->header.cmd == NGM_PPP_GETCLR_LINK_STATS64) { NG_MKRESPONSE(resp, msg, sizeof(struct ng_ppp_link_stat64), M_NOWAIT); @@ -668,7 +669,7 @@ ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook) bcopy(stats, resp->data, sizeof(*stats)); } else /* Make 32bit reply. */ - if (msg->header.cmd == NGM_PPP_GET_LINK_STATS || + if (msg->header.cmd == NGM_PPP_GET_LINK_STATS || msg->header.cmd == NGM_PPP_GETCLR_LINK_STATS) { struct ng_ppp_link_stat *rs; NG_MKRESPONSE(resp, msg, @@ -792,6 +793,19 @@ ng_ppp_rcvdata_inet(hook_p hook, item_p item) return (ng_ppp_hcomp_xmit(NG_HOOK_NODE(hook), item, PROT_IP)); } +/* + * Receive data on a hook inet and pass it directly to first link. + */ +static int +ng_ppp_rcvdata_inet_fast(hook_p hook, item_p item) +{ + const node_p node = NG_HOOK_NODE(hook); + const priv_p priv = NG_NODE_PRIVATE(node); + + return (ng_ppp_link_xmit(node, item, PROT_IP, priv->activeLinks[0], + NGI_M(item)->m_pkthdr.len)); +} + /* * Receive data on a hook ipv6. */ @@ -1077,10 +1091,10 @@ ng_ppp_comp_xmit(node_p node, item_p item, uint16_t proto) proto != PROT_COMPD && proto != PROT_CRYPTD && priv->hooks[HOOK_INDEX_COMPRESS] != NULL) { - struct mbuf *m; + struct mbuf *m; int error; - NGI_GET_M(item, m); + NGI_GET_M(item, m); if ((m = ng_ppp_addproto(m, proto, 0)) == NULL) { NG_FREE_ITEM(item); return (ENOBUFS); @@ -1183,8 +1197,8 @@ ng_ppp_rcvdata_decompress(hook_p hook, item_p item) } NGI_GET_M(item, m); if ((m = ng_ppp_cutproto(m, &proto)) == NULL) { - NG_FREE_ITEM(item); - return (EIO); + NG_FREE_ITEM(item); + return (EIO); } NGI_M(item) = m; if (!PROT_VALID(proto)) { @@ -1211,7 +1225,7 @@ ng_ppp_crypt_xmit(node_p node, item_p item, uint16_t proto) struct mbuf *m; int error; - NGI_GET_M(item, m); + NGI_GET_M(item, m); if ((m = ng_ppp_addproto(m, proto, 0)) == NULL) { NG_FREE_ITEM(item); return (ENOBUFS); @@ -1283,8 +1297,8 @@ ng_ppp_rcvdata_decrypt(hook_p hook, item_p item) } NGI_GET_M(item, m); if ((m = ng_ppp_cutproto(m, &proto)) == NULL) { - NG_FREE_ITEM(item); - return (EIO); + NG_FREE_ITEM(item); + return (EIO); } NGI_M(item) = m; if (!PROT_VALID(proto)) { @@ -1599,7 +1613,7 @@ ng_ppp_mp_recv(node_p node, item_p item, uint16_t proto, uint16_t linkNum) TAILQ_INSERT_AFTER(&priv->frags, qent, frag, f_qent); inserted = 1; break; - } else if (diff == 0) { /* should never happen! */ + } else if (diff == 0) { /* should never happen! */ link->stats.dupFragments++; NG_FREE_M(frag->data); TAILQ_INSERT_HEAD(&priv->fragsfree, frag, f_qent); @@ -1833,7 +1847,7 @@ ng_ppp_frag_process(node_p node, item_p oitem) if (item != NULL) { /* Stats */ priv->bundleStats.recvFrames++; - priv->bundleStats.recvOctets += + priv->bundleStats.recvOctets += NGI_M(item)->m_pkthdr.len; /* Drop mutex for the sending time. @@ -2369,10 +2383,9 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib) struct ng_ppp_link *const link = &priv->links[priv->activeLinks[sortByLatency[i]]]; - if (distrib[sortByLatency[slow]] == 0 - || (distrib[sortByLatency[i]] > 0 - && link->conf.bandwidth < - slowLink->conf.bandwidth)) { + if (distrib[sortByLatency[slow]] == 0 || + (distrib[sortByLatency[i]] > 0 && + link->conf.bandwidth < slowLink->conf.bandwidth)) { slow = i; slowLink = link; } @@ -2474,7 +2487,7 @@ ng_ppp_update(node_p node, int newConf) if (priv->links[i].conf.bandwidth == 0) continue; - + hdrBytes = MP_AVERAGE_LINK_OVERHEAD + (priv->links[i].conf.enableACFComp ? 0 : 2) + (priv->links[i].conf.enableProtoComp ? 1 : 2) @@ -2530,6 +2543,20 @@ ng_ppp_update(node_p node, int newConf) link->seq = MP_NOSEQ; } } + + if (priv->hooks[HOOK_INDEX_INET] != NULL) { + if (priv->conf.enableIP == 1 && + priv->numActiveLinks == 1 && + priv->conf.enableMultilink == 0 && + priv->conf.enableCompression == 0 && + priv->conf.enableEncryption == 0 && + priv->conf.enableVJCompression == 0) + NG_HOOK_SET_RCVDATA(priv->hooks[HOOK_INDEX_INET], + ng_ppp_rcvdata_inet_fast); + else + NG_HOOK_SET_RCVDATA(priv->hooks[HOOK_INDEX_INET], + ng_ppp_rcvdata_inet); + } } /* diff --git a/sys/netgraph/ng_sppp.c b/sys/netgraph/ng_sppp.c index 44db053ca447..95e9a60f56f9 100644 --- a/sys/netgraph/ng_sppp.c +++ b/sys/netgraph/ng_sppp.c @@ -364,7 +364,7 @@ ng_sppp_rcvdata (hook_p hook, item_p item) } /* Update interface stats */ - SP2IFP(pp)->if_ipackets++; + if_inc_counter(SP2IFP(pp), IFCOUNTER_IPACKETS, 1); /* Note receiving interface */ m->m_pkthdr.rcvif = SP2IFP(pp); diff --git a/sys/netgraph/ng_tty.c b/sys/netgraph/ng_tty.c index 35e17344825f..5e794a8a577f 100644 --- a/sys/netgraph/ng_tty.c +++ b/sys/netgraph/ng_tty.c @@ -327,7 +327,6 @@ ngt_rcvdata(hook_p hook, item_p item) IF_LOCK(&sc->outq); if (_IF_QFULL(&sc->outq)) { - _IF_DROP(&sc->outq); IF_UNLOCK(&sc->outq); NG_FREE_M(m); return (ENOBUFS); diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 52fc446c70b0..0a2b130d752d 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -674,7 +674,7 @@ in_addprefix(struct in_ifaddr *target, int flags) } else { int fibnum; - fibnum = rt_add_addr_allfibs ? RT_ALL_FIBS : + fibnum = V_rt_add_addr_allfibs ? RT_ALL_FIBS : target->ia_ifp->if_fib; rt_addrmsg(RTM_ADD, &target->ia_ifa, fibnum); IN_IFADDR_RUNLOCK(); @@ -745,7 +745,7 @@ in_scrubprefix(struct in_ifaddr *target, u_int flags) if ((target->ia_flags & IFA_ROUTE) == 0) { int fibnum; - fibnum = rt_add_addr_allfibs ? RT_ALL_FIBS : + fibnum = V_rt_add_addr_allfibs ? RT_ALL_FIBS : target->ia_ifp->if_fib; rt_addrmsg(RTM_DELETE, &target->ia_ifa, fibnum); return (0); diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 254401fc75e4..4776278e1b17 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -492,6 +492,8 @@ __END_DECLS #define IP_FLOWID 90 /* get flow id for the given socket/inp */ #define IP_FLOWTYPE 91 /* get flow type (M_HASHTYPE) */ #define IP_RSSBUCKETID 92 /* get RSS flowid -> bucket mapping */ +#define IP_RECVFLOWID 93 /* bool; receive IP flowid/flowtype w/ datagram */ +#define IP_RECVRSSBUCKETID 94 /* bool; receive IP RSS bucket id w/ datagram */ /* * Defaults and limits for options diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index 26d4e8e3a135..c377e4905be1 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -2928,7 +2928,7 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS) return (retval); } -#ifdef KTR +#if defined(KTR) && (KTR_COMPILE & KTR_IGMPV3) static const char *inm_modestrs[] = { "un", "in", "ex" }; @@ -3000,7 +3000,7 @@ inm_print(const struct in_multi *inm) printf("%s: --- end inm %p ---\n", __func__, inm); } -#else /* !KTR */ +#else /* !KTR || !(KTR_COMPILE & KTR_IGMPV3) */ void inm_print(const struct in_multi *inm) @@ -3008,6 +3008,6 @@ inm_print(const struct in_multi *inm) } -#endif /* KTR */ +#endif /* KTR && (KTR_COMPILE & KTR_IGMPV3) */ RB_GENERATE(ip_msource_tree, ip_msource, ims_link, ip_msource_cmp); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 1a5de4012cfa..a0a1b30a0272 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -792,9 +792,11 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr, struct in_ifaddr *ia; struct ifnet *ifp; - ia = ifatoia(ifa_ifwithdstaddr((struct sockaddr *)sin)); + ia = ifatoia(ifa_ifwithdstaddr((struct sockaddr *)sin, + inp->inp_socket->so_fibnum)); if (ia == NULL) - ia = ifatoia(ifa_ifwithnet((struct sockaddr *)sin, 0)); + ia = ifatoia(ifa_ifwithnet((struct sockaddr *)sin, 0, + inp->inp_socket->so_fibnum)); if (ia == NULL) { error = ENETUNREACH; goto done; @@ -909,9 +911,11 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr, sain.sin_len = sizeof(struct sockaddr_in); sain.sin_addr.s_addr = faddr->s_addr; - ia = ifatoia(ifa_ifwithdstaddr(sintosa(&sain))); + ia = ifatoia(ifa_ifwithdstaddr(sintosa(&sain), + inp->inp_socket->so_fibnum)); if (ia == NULL) - ia = ifatoia(ifa_ifwithnet(sintosa(&sain), 0)); + ia = ifatoia(ifa_ifwithnet(sintosa(&sain), 0, + inp->inp_socket->so_fibnum)); if (ia == NULL) ia = ifatoia(ifa_ifwithaddr(sintosa(&sain))); @@ -2046,7 +2050,7 @@ in_pcbinshash_internal(struct inpcb *inp, int do_pcbgroup_update) #ifdef INET6 if (inp->inp_vflag & INP_IPV6) - hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */; + hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr); else #endif hashkey_faddr = inp->inp_faddr.s_addr; @@ -2133,7 +2137,7 @@ in_pcbrehash_mbuf(struct inpcb *inp, struct mbuf *m) #ifdef INET6 if (inp->inp_vflag & INP_IPV6) - hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */; + hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr); else #endif hashkey_faddr = inp->inp_faddr.s_addr; diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 8c73f2d657ad..185bcfb2d06e 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -94,6 +94,7 @@ struct in_endpoints { struct in_addr_4in6 ie46_local; struct in6_addr ie6_local; } ie_dependladdr; + u_int32_t ie6_zoneid; /* scope zone id */ }; #define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4 #define ie_laddr ie_dependladdr.ie46_local.ia46_addr4 @@ -124,6 +125,7 @@ struct in_conninfo { #define inc_laddr inc_ie.ie_laddr #define inc6_faddr inc_ie.ie6_faddr #define inc6_laddr inc_ie.ie6_laddr +#define inc6_zoneid inc_ie.ie6_zoneid struct icmp6_filter; @@ -229,6 +231,7 @@ struct inpcb { #define in6p_faddr inp_inc.inc6_faddr #define in6p_laddr inp_inc.inc6_laddr +#define in6p_zoneid inp_inc.inc6_zoneid #define in6p_hops inp_depend6.inp6_hops /* default hop limit */ #define in6p_flowinfo inp_flow #define in6p_options inp_depend6.inp6_options @@ -487,6 +490,7 @@ short inp_so_options(const struct inpcb *inp); (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) #define INP_PCBPORTHASH(lport, mask) \ (ntohs((lport)) & (mask)) +#define INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3]) /* * Flags for inp_vflags -- historically version flags only @@ -549,6 +553,8 @@ short inp_so_options(const struct inpcb *inp); #define INP_REUSEADDR 0x00000020 /* SO_REUSEADDR option is set */ #define INP_BINDMULTI 0x00000040 /* IP_BINDMULTI option is set */ #define INP_RSS_BUCKET_SET 0x00000080 /* IP_RSS_LISTEN_BUCKET is set */ +#define INP_RECVFLOWID 0x00000100 /* populate recv datagram with flow info */ +#define INP_RECVRSSBUCKETID 0x00000200 /* populate recv datagram with bucket id */ /* * Flags passed to in_pcblookup*() functions. diff --git a/sys/netinet/in_pcbgroup.c b/sys/netinet/in_pcbgroup.c index aa2f1c642a23..4157290382d7 100644 --- a/sys/netinet/in_pcbgroup.c +++ b/sys/netinet/in_pcbgroup.c @@ -416,7 +416,7 @@ in_pcbgroup_update_internal(struct inpcbinfo *pcbinfo, if (newpcbgroup != NULL && oldpcbgroup != newpcbgroup) { #ifdef INET6 if (inp->inp_vflag & INP_IPV6) - hashkey_faddr = inp->in6p_faddr.s6_addr32[3]; /* XXX */ + hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr); else #endif hashkey_faddr = inp->inp_faddr.s_addr; diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c index bd5835ea29c8..09669e67cfc3 100644 --- a/sys/netinet/in_rmx.c +++ b/sys/netinet/in_rmx.c @@ -352,10 +352,12 @@ in_inithead(void **head, int off) if (!rn_inithead(head, 32)) return 0; + rnh = *head; + RADIX_NODE_HEAD_LOCK_INIT(rnh); + if (off == 0) /* XXX MRT see above */ return 1; /* only do the rest for a real routing table */ - rnh = *head; rnh->rnh_addaddr = in_addroute; in_setmatchfunc(rnh, V_drop_redirect); rnh->rnh_close = in_clsroute; diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 33b061aed395..7a548c2a8d2e 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -57,6 +57,11 @@ __FBSDID("$FreeBSD$"); #include #include +/* for software rss hash support */ +#include +#include +#include + /*- * Operating system parts of receiver-side scaling (RSS), which allows * network cards to direct flows to particular receive queues based on hashes @@ -170,6 +175,8 @@ struct rss_table_entry { }; static struct rss_table_entry rss_table[RSS_TABLE_MAXLEN]; +static inline u_int rss_gethashconfig_local(void); + static void rss_init(__unused void *arg) { @@ -490,6 +497,261 @@ rss_m2bucket(struct mbuf *m, uint32_t *bucket_id) bucket_id)); } +/* + * Calculate an appropriate ipv4 2-tuple or 4-tuple given the given + * IPv4 source/destination address, UDP or TCP source/destination ports + * and the protocol type. + * + * The protocol code may wish to do a software hash of the given + * tuple. This depends upon the currently configured RSS hash types. + * + * This assumes that the packet in question isn't a fragment. + * + * It also assumes the packet source/destination address + * are in "incoming" packet order (ie, source is "far" address.) + */ +int +rss_proto_software_hash_v4(struct in_addr s, struct in_addr d, + u_short sp, u_short dp, int proto, + uint32_t *hashval, uint32_t *hashtype) +{ + uint32_t hash; + + /* + * Next, choose the hash type depending upon the protocol + * identifier. + */ + if ((proto == IPPROTO_TCP) && + (rss_gethashconfig_local() & RSS_HASHTYPE_RSS_TCP_IPV4)) { + hash = rss_hash_ip4_4tuple(s, sp, d, dp); + *hashval = hash; + *hashtype = M_HASHTYPE_RSS_TCP_IPV4; + return (0); + } else if ((proto == IPPROTO_UDP) && + (rss_gethashconfig_local() & RSS_HASHTYPE_RSS_UDP_IPV4)) { + hash = rss_hash_ip4_4tuple(s, sp, d, dp); + *hashval = hash; + *hashtype = M_HASHTYPE_RSS_UDP_IPV4; + return (0); + } else if (rss_gethashconfig_local() & RSS_HASHTYPE_RSS_IPV4) { + /* RSS doesn't hash on other protocols like SCTP; so 2-tuple */ + hash = rss_hash_ip4_2tuple(s, d); + *hashval = hash; + *hashtype = M_HASHTYPE_RSS_IPV4; + return (0); + } + + /* No configured available hashtypes! */ + printf("%s: no available hashtypes!\n", __func__); + return (-1); +} + +/* + * Do a software calculation of the RSS for the given mbuf. + * + * This is typically used by the input path to recalculate the RSS after + * some form of packet processing (eg de-capsulation, IP fragment reassembly.) + * + * dir is the packet direction - RSS_HASH_PKT_INGRESS for incoming and + * RSS_HASH_PKT_EGRESS for outgoing. + * + * Returns 0 if a hash was done, -1 if no hash was done, +1 if + * the mbuf already had a valid RSS flowid. + * + * This function doesn't modify the mbuf. It's up to the caller to + * assign flowid/flowtype as appropriate. + */ +int +rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, + uint32_t *hashtype) +{ + const struct ip *ip; + const struct tcphdr *th; + const struct udphdr *uh; + uint8_t proto; + int iphlen; + int is_frag = 0; + + /* + * XXX For now this only handles hashing on incoming mbufs. + */ + if (dir != RSS_HASH_PKT_INGRESS) { + printf("%s: called on EGRESS packet!\n", __func__); + return (-1); + } + + /* + * First, validate that the mbuf we have is long enough + * to have an IPv4 header in it. + */ + if (m->m_pkthdr.len < (sizeof(struct ip))) { + printf("%s: short mbuf pkthdr\n", __func__); + return (-1); + } + if (m->m_len < (sizeof(struct ip))) { + printf("%s: short mbuf len\n", __func__); + return (-1); + } + + /* Ok, let's dereference that */ + ip = mtod(m, struct ip *); + proto = ip->ip_p; + iphlen = ip->ip_hl << 2; + + /* + * If this is a fragment then it shouldn't be four-tuple + * hashed just yet. Once it's reassembled into a full + * frame it should be re-hashed. + */ + if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) + is_frag = 1; + + /* + * If the mbuf flowid/flowtype matches the packet type, + * and we don't support the 4-tuple version of the given protocol, + * then signal to the owner that it can trust the flowid/flowtype + * details. + * + * This is a little picky - eg, if TCPv4 / UDPv4 hashing + * is supported but we got a TCP/UDP frame only 2-tuple hashed, + * then we shouldn't just "trust" the 2-tuple hash. We need + * a 4-tuple hash. + */ + if (m->m_flags & M_FLOWID) { + uint32_t flowid, flowtype; + + flowid = m->m_pkthdr.flowid; + flowtype = M_HASHTYPE_GET(m); + + switch (proto) { + case IPPROTO_UDP: + if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_UDP_IPV4) && + (flowtype == M_HASHTYPE_RSS_UDP_IPV4) && + (is_frag == 0)) { + return (1); + } + /* + * Only allow 2-tuple for UDP frames if we don't also + * support 4-tuple for UDP. + */ + if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_IPV4) && + ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_UDP_IPV4) == 0) && + flowtype == M_HASHTYPE_RSS_IPV4) { + return (1); + } + break; + case IPPROTO_TCP: + if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_TCP_IPV4) && + (flowtype == M_HASHTYPE_RSS_TCP_IPV4) && + (is_frag == 0)) { + return (1); + } + /* + * Only allow 2-tuple for TCP frames if we don't also + * support 2-tuple for TCP. + */ + if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_IPV4) && + ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_TCP_IPV4) == 0) && + flowtype == M_HASHTYPE_RSS_IPV4) { + return (1); + } + break; + default: + if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_IPV4) && + flowtype == M_HASHTYPE_RSS_IPV4) { + return (1); + } + break; + } + } + + /* + * Decode enough information to make a hash decision. + * + * XXX TODO: does the hardware hash on 4-tuple if IP + * options are present? + */ + if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_TCP_IPV4) && + (proto == IPPROTO_TCP) && + (is_frag == 0)) { + if (m->m_len < iphlen + sizeof(struct tcphdr)) { + printf("%s: short TCP frame?\n", __func__); + return (-1); + } + th = (struct tcphdr *)((caddr_t)ip + iphlen); + return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, + th->th_sport, + th->th_dport, + proto, + hashval, + hashtype); + } else if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_UDP_IPV4) && + (proto == IPPROTO_UDP) && + (is_frag == 0)) { + uh = (struct udphdr *)((caddr_t)ip + iphlen); + if (m->m_len < iphlen + sizeof(struct udphdr)) { + printf("%s: short UDP frame?\n", __func__); + return (-1); + } + return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, + uh->uh_sport, + uh->uh_dport, + proto, + hashval, + hashtype); + } else if (rss_gethashconfig_local() & RSS_HASHTYPE_RSS_IPV4) { + /* Default to 2-tuple hash */ + return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, + 0, /* source port */ + 0, /* destination port */ + 0, /* IPPROTO_IP */ + hashval, + hashtype); + } else { + printf("%s: no available hashtypes!\n", __func__); + return (-1); + } +} + +/* + * Similar to rss_m2cpuid, but designed to be used by the IP NETISR + * on incoming frames. + * + * If an existing RSS hash exists and it matches what the configured + * hashing is, then use it. + * + * If there's an existing RSS hash but the desired hash is different, + * or if there's no useful RSS hash, then calculate it via + * the software path. + * + * XXX TODO: definitely want statistics here! + */ +struct mbuf * +rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid) +{ + uint32_t hash_val, hash_type; + int ret; + + M_ASSERTPKTHDR(m); + + ret = rss_mbuf_software_hash_v4(m, RSS_HASH_PKT_INGRESS, + &hash_val, &hash_type); + if (ret > 0) { + /* mbuf has a valid hash already; don't need to modify it */ + *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m)); + } else if (ret == 0) { + /* hash was done; update */ + m->m_pkthdr.flowid = hash_val; + M_HASHTYPE_SET(m, hash_type); + m->m_flags |= M_FLOWID; + *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m)); + } else { /* ret < 0 */ + /* no hash was done */ + *cpuid = NETISR_CPUID_NONE; + } + return (m); +} + /* * Query the RSS hash algorithm. */ @@ -538,15 +800,10 @@ rss_getnumcpus(void) return (rss_ncpus); } -/* - * Return the supported RSS hash configuration. - * - * NICs should query this to determine what to configure in their redirection - * matching table. - */ -u_int -rss_gethashconfig(void) +static inline u_int +rss_gethashconfig_local(void) { + /* Return 4-tuple for TCP; 2-tuple for others */ /* * UDP may fragment more often than TCP and thus we'll end up with @@ -572,6 +829,19 @@ rss_gethashconfig(void) ); } +/* + * Return the supported RSS hash configuration. + * + * NICs should query this to determine what to configure in their redirection + * matching table. + */ +u_int +rss_gethashconfig(void) +{ + + return (rss_gethashconfig_local()); +} + /* * XXXRW: Confirm that sysctl -a won't dump this keying material, don't want * it appearing in debugging output unnecessarily. diff --git a/sys/netinet/in_rss.h b/sys/netinet/in_rss.h index a911e3c0f926..66fb61149091 100644 --- a/sys/netinet/in_rss.h +++ b/sys/netinet/in_rss.h @@ -82,6 +82,16 @@ */ #define RSS_KEYSIZE 40 +/* + * For RSS hash methods that do a software hash on an mbuf, the packet + * direction (ingress / egress) is required. + * + * The default direction (INGRESS) is the "receive into the NIC" - ie, + * what the hardware is hashing on. + */ +#define RSS_HASH_PKT_INGRESS 0 +#define RSS_HASH_PKT_EGRESS 1 + /* * Device driver interfaces to query RSS properties that must be programmed * into hardware. @@ -116,4 +126,17 @@ int rss_hash2bucket(uint32_t hash_val, uint32_t hash_type, uint32_t *bucket_id); int rss_m2bucket(struct mbuf *m, uint32_t *bucket_id); +/* + * Functions to calculate a software RSS hash for a given mbuf or + * packet detail. + */ +int rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, + uint32_t *hashval, uint32_t *hashtype); +int rss_proto_software_hash_v4(struct in_addr src, + struct in_addr dst, u_short src_port, u_short dst_port, + int proto, uint32_t *hashval, + uint32_t *hashtype); +struct mbuf * rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, + u_int *cpuid); + #endif /* !_NETINET_IN_RSS_H_ */ diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index 3a6e9255279c..6f0dcbf7872b 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -411,6 +411,7 @@ void in_rtqdrain(void); int in_addprefix(struct in_ifaddr *, int); int in_scrubprefix(struct in_ifaddr *, u_int); void ip_input(struct mbuf *); +void ip_direct_input(struct mbuf *); void in_ifadown(struct ifaddr *ifa, int); struct mbuf *ip_fastforward(struct mbuf *); void *in_domifattach(struct ifnet *); diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c index 5b41dfdd3b78..ded9103f31bb 100644 --- a/sys/netinet/ip_fastfwd.c +++ b/sys/netinet/ip_fastfwd.c @@ -296,9 +296,9 @@ ip_fastforward(struct mbuf *m) * Only IP packets without options */ if (ip->ip_hl != (sizeof(struct ip) >> 2)) { - if (ip_doopts == 1) + if (V_ip_doopts == 1) return m; - else if (ip_doopts == 2) { + else if (V_ip_doopts == 2) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_FILTER_PROHIB, 0, 0); return NULL; /* mbuf already free'd */ diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index 21a665a99e22..897adac41b33 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -142,8 +142,8 @@ gre_input2(struct mbuf *m ,int hlen, u_char proto) } gip = mtod(m, struct greip *); - GRE2IFP(sc)->if_ipackets++; - GRE2IFP(sc)->if_ibytes += m->m_pkthdr.len; + if_inc_counter(GRE2IFP(sc), IFCOUNTER_IPACKETS, 1); + if_inc_counter(GRE2IFP(sc), IFCOUNTER_IBYTES, m->m_pkthdr.len); switch (proto) { case IPPROTO_GRE: @@ -243,8 +243,8 @@ gre_mobile_input(struct mbuf **mp, int *offp, int proto) ip = mtod(m, struct ip *); mip = mtod(m, struct mobip_h *); - GRE2IFP(sc)->if_ipackets++; - GRE2IFP(sc)->if_ibytes += m->m_pkthdr.len; + if_inc_counter(GRE2IFP(sc), IFCOUNTER_IPACKETS, 1); + if_inc_counter(GRE2IFP(sc), IFCOUNTER_IBYTES, m->m_pkthdr.len); if (ntohs(mip->mh.proto) & MOB_H_SBIT) { msiz = MOB_H_SIZ_L; @@ -315,18 +315,18 @@ gre_lookup(struct mbuf *m, u_int8_t proto) struct ip *ip = mtod(m, struct ip *); struct gre_softc *sc; - mtx_lock(&gre_mtx); - for (sc = LIST_FIRST(&gre_softc_list); sc != NULL; + GRE_LIST_LOCK(); + for (sc = LIST_FIRST(&V_gre_softc_list); sc != NULL; sc = LIST_NEXT(sc, sc_list)) { if ((sc->g_dst.s_addr == ip->ip_src.s_addr) && (sc->g_src.s_addr == ip->ip_dst.s_addr) && (sc->g_proto == proto) && ((GRE2IFP(sc)->if_flags & IFF_UP) != 0)) { - mtx_unlock(&gre_mtx); + GRE_LIST_UNLOCK(); return (sc); } } - mtx_unlock(&gre_mtx); + GRE_LIST_UNLOCK(); return (NULL); } diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 007364375834..e5d32f03daea 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -149,6 +149,10 @@ SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, bmcastecho, CTLFLAG_RW, &VNET_NAME(icmpbmcastecho), 0, ""); +static VNET_DEFINE(int, icmptstamprepl) = 1; +#define V_icmptstamprepl VNET(icmptstamprepl) +SYSCTL_INT(_net_inet_icmp, OID_AUTO, tstamprepl, CTLFLAG_RW, + &VNET_NAME(icmptstamprepl), 0, "Respond to ICMP Timestamp packets"); #ifdef ICMPPRINTFS int icmpprintfs = 0; @@ -545,6 +549,8 @@ icmp_input(struct mbuf **mp, int *offp, int proto) goto reflect; case ICMP_TSTAMP: + if (V_icmptstamprepl == 0) + break; if (!V_icmpbmcastecho && (m->m_flags & (M_MCAST | M_BCAST)) != 0) { ICMPSTAT_INC(icps_bmcasttstamp); diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index d622e011ead0..01a4756a49ca 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ipstealth.h" #include "opt_ipsec.h" #include "opt_route.h" +#include "opt_rss.h" #include #include @@ -77,6 +78,7 @@ __FBSDID("$FreeBSD$"); #ifdef IPSEC #include #endif /* IPSEC */ +#include #include @@ -144,9 +146,33 @@ static struct netisr_handler ip_nh = { .nh_name = "ip", .nh_handler = ip_input, .nh_proto = NETISR_IP, +#ifdef RSS + .nh_m2cpuid = rss_soft_m2cpuid, + .nh_policy = NETISR_POLICY_CPU, + .nh_dispatch = NETISR_DISPATCH_HYBRID, +#else .nh_policy = NETISR_POLICY_FLOW, +#endif }; +#ifdef RSS +/* + * Directly dispatched frames are currently assumed + * to have a flowid already calculated. + * + * It should likely have something that assert it + * actually has valid flow details. + */ +static struct netisr_handler ip_direct_nh = { + .nh_name = "ip_direct", + .nh_handler = ip_direct_input, + .nh_proto = NETISR_IP_DIRECT, + .nh_m2cpuid = rss_m2cpuid, + .nh_policy = NETISR_POLICY_CPU, + .nh_dispatch = NETISR_DISPATCH_HYBRID, +}; +#endif + extern struct domain inetdomain; extern struct protosw inetsw[]; u_char ip_protox[IPPROTO_MAX]; @@ -266,6 +292,46 @@ SYSCTL_PROC(_net_inet_ip, IPCTL_INTRQDROPS, intr_queue_drops, CTLTYPE_INT|CTLFLAG_RD, 0, 0, sysctl_netinet_intr_queue_drops, "I", "Number of packets dropped from the IP input queue"); +#ifdef RSS +static int +sysctl_netinet_intr_direct_queue_maxlen(SYSCTL_HANDLER_ARGS) +{ + int error, qlimit; + + netisr_getqlimit(&ip_direct_nh, &qlimit); + error = sysctl_handle_int(oidp, &qlimit, 0, req); + if (error || !req->newptr) + return (error); + if (qlimit < 1) + return (EINVAL); + return (netisr_setqlimit(&ip_direct_nh, qlimit)); +} +SYSCTL_PROC(_net_inet_ip, IPCTL_INTRQMAXLEN, intr_direct_queue_maxlen, + CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_netinet_intr_direct_queue_maxlen, "I", + "Maximum size of the IP direct input queue"); + +static int +sysctl_netinet_intr_direct_queue_drops(SYSCTL_HANDLER_ARGS) +{ + u_int64_t qdrops_long; + int error, qdrops; + + netisr_getqdrops(&ip_direct_nh, &qdrops_long); + qdrops = qdrops_long; + error = sysctl_handle_int(oidp, &qdrops, 0, req); + if (error || !req->newptr) + return (error); + if (qdrops != 0) + return (EINVAL); + netisr_clearqdrops(&ip_direct_nh); + return (0); +} + +SYSCTL_PROC(_net_inet_ip, IPCTL_INTRQDROPS, intr_direct_queue_drops, + CTLTYPE_INT|CTLFLAG_RD, 0, 0, sysctl_netinet_intr_direct_queue_drops, "I", + "Number of packets dropped from the IP direct input queue"); +#endif /* RSS */ + /* * IP initialization: fill in IP protocol switch table. * All protocols not implemented in kernel go to raw IP protocol handler. @@ -327,6 +393,9 @@ ip_init(void) /* Initialize various other remaining things. */ IPQ_LOCK_INIT(); netisr_register(&ip_nh); +#ifdef RSS + netisr_register(&ip_direct_nh); +#endif } #ifdef VIMAGE @@ -350,6 +419,28 @@ ip_destroy(void) } #endif +#ifdef RSS +/* + * IP direct input routine. + * + * This is called when reinjecting completed fragments where + * all of the previous checking and book-keeping has been done. + */ +void +ip_direct_input(struct mbuf *m) +{ + struct ip *ip; + int hlen; + + ip = mtod(m, struct ip *); + hlen = ip->ip_hl << 2; + + IPSTAT_INC(ips_delivered); + (*inetsw[ip_protox[ip->ip_p]].pr_input)(&m, &hlen, ip->ip_p); + return; +} +#endif + /* * Ip input routine. Checksum and byte swap header. If fragmented * try to reassemble. Process options. Pass to next level. @@ -463,6 +554,7 @@ ip_input(struct mbuf *m) } else m_adj(m, ip_len - m->m_pkthdr.len); } + #ifdef IPSEC /* * Bypass packet filtering for packets previously handled by IPsec. @@ -817,6 +909,9 @@ ip_reass(struct mbuf *m) int i, hlen, next; u_int8_t ecn, ecn0; u_short hash; +#ifdef RSS + uint32_t rss_hash, rss_type; +#endif /* If maxnipq or maxfragsperpacket are 0, never accept fragments. */ if (V_maxnipq == 0 || V_maxfragsperpacket == 0) { @@ -1106,6 +1201,40 @@ ip_reass(struct mbuf *m) m_fixhdr(m); IPSTAT_INC(ips_reassembled); IPQ_UNLOCK(); + +#ifdef RSS + /* + * Query the RSS layer for the flowid / flowtype for the + * mbuf payload. + * + * For now, just assume we have to calculate a new one. + * Later on we should check to see if the assigned flowid matches + * what RSS wants for the given IP protocol and if so, just keep it. + * + * We then queue into the relevant netisr so it can be dispatched + * to the correct CPU. + * + * Note - this may return 1, which means the flowid in the mbuf + * is correct for the configured RSS hash types and can be used. + */ + if (rss_mbuf_software_hash_v4(m, 0, &rss_hash, &rss_type) == 0) { + m->m_pkthdr.flowid = rss_hash; + M_HASHTYPE_SET(m, rss_type); + m->m_flags |= M_FLOWID; + } + + /* + * Queue/dispatch for reprocessing. + * + * Note: this is much slower than just handling the frame in the + * current receive context. It's likely worth investigating + * why this is. + */ + netisr_dispatch(NETISR_IP_DIRECT, m); + return (NULL); +#endif + + /* Handle in-line */ return (m); dropfrag: @@ -1662,6 +1791,43 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip, if (*mp) mp = &(*mp)->m_next; } + + if (inp->inp_flags2 & INP_RECVFLOWID) { + uint32_t flowid, flow_type; + + flowid = m->m_pkthdr.flowid; + flow_type = M_HASHTYPE_GET(m); + + /* + * XXX should handle the failure of one or the + * other - don't populate both? + */ + *mp = sbcreatecontrol((caddr_t) &flowid, + sizeof(uint32_t), IP_FLOWID, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + *mp = sbcreatecontrol((caddr_t) &flow_type, + sizeof(uint32_t), IP_FLOWTYPE, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + } + +#ifdef RSS + if (inp->inp_flags2 & INP_RECVRSSBUCKETID) { + uint32_t flowid, flow_type; + uint32_t rss_bucketid; + + flowid = m->m_pkthdr.flowid; + flow_type = M_HASHTYPE_GET(m); + + if (rss_hash2bucket(flowid, flow_type, &rss_bucketid) == 0) { + *mp = sbcreatecontrol((caddr_t) &rss_bucketid, + sizeof(uint32_t), IP_RSSBUCKETID, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + } + } +#endif } /* diff --git a/sys/netinet/ip_ipsec.c b/sys/netinet/ip_ipsec.c index 6bd42c0a48c6..bf9f81f64f19 100644 --- a/sys/netinet/ip_ipsec.c +++ b/sys/netinet/ip_ipsec.c @@ -63,15 +63,12 @@ __FBSDID("$FreeBSD$"); #include -#ifdef IPSEC #include #include #include -#endif /*IPSEC*/ extern struct protosw inetsw[]; -#ifdef IPSEC #ifdef IPSEC_FILTERTUNNEL static VNET_DEFINE(int, ip4_ipsec_filtertunnel) = 1; #else @@ -83,7 +80,6 @@ SYSCTL_DECL(_net_inet_ipsec); SYSCTL_VNET_INT(_net_inet_ipsec, OID_AUTO, filtertunnel, CTLFLAG_RW, &VNET_NAME(ip4_ipsec_filtertunnel), 0, "If set filter packets from an IPsec tunnel."); -#endif /* IPSEC */ /* * Check if we have to jump over firewall processing for this packet. @@ -93,7 +89,6 @@ SYSCTL_VNET_INT(_net_inet_ipsec, OID_AUTO, filtertunnel, int ip_ipsec_filtertunnel(struct mbuf *m) { -#ifdef IPSEC /* * Bypass packet filtering for packets previously handled by IPsec. @@ -101,7 +96,6 @@ ip_ipsec_filtertunnel(struct mbuf *m) if (!V_ip4_ipsec_filtertunnel && m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) != NULL) return 1; -#endif return 0; } @@ -114,7 +108,6 @@ ip_ipsec_filtertunnel(struct mbuf *m) int ip_ipsec_fwd(struct mbuf *m) { -#ifdef IPSEC struct m_tag *mtag; struct tdb_ident *tdbi; struct secpolicy *sp; @@ -143,7 +136,6 @@ ip_ipsec_fwd(struct mbuf *m) IPSTAT_INC(ips_cantforward); return 1; } -#endif /* IPSEC */ return 0; } @@ -157,7 +149,6 @@ ip_ipsec_fwd(struct mbuf *m) int ip_ipsec_input(struct mbuf *m) { -#ifdef IPSEC struct ip *ip = mtod(m, struct ip *); struct m_tag *mtag; struct tdb_ident *tdbi; @@ -198,7 +189,6 @@ ip_ipsec_input(struct mbuf *m) if (error) return 1; } -#endif /* IPSEC */ return 0; } @@ -256,7 +246,6 @@ ip_ipsec_mtu(struct mbuf *m, int mtu) int ip_ipsec_output(struct mbuf **m, struct inpcb *inp, int *flags, int *error) { -#ifdef IPSEC struct secpolicy *sp = NULL; struct tdb_ident *tdbi; struct m_tag *mtag; @@ -388,6 +377,4 @@ ip_ipsec_output(struct mbuf **m, struct inpcb *inp, int *flags, int *error) if (sp != NULL) KEY_FREESP(&sp); return 1; -#endif /* IPSEC */ - return 0; } diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c index 891199261c9c..cdb98be83388 100644 --- a/sys/netinet/ip_options.c +++ b/sys/netinet/ip_options.c @@ -65,18 +65,21 @@ __FBSDID("$FreeBSD$"); #include -static int ip_dosourceroute = 0; -SYSCTL_INT(_net_inet_ip, IPCTL_SOURCEROUTE, sourceroute, CTLFLAG_RW, - &ip_dosourceroute, 0, "Enable forwarding source routed IP packets"); +static VNET_DEFINE(int, ip_dosourceroute); +SYSCTL_INT(_net_inet_ip, IPCTL_SOURCEROUTE, sourceroute, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip_dosourceroute), 0, + "Enable forwarding source routed IP packets"); +#define V_ip_dosourceroute VNET(ip_dosourceroute) -static int ip_acceptsourceroute = 0; +static VNET_DEFINE(int, ip_acceptsourceroute); SYSCTL_INT(_net_inet_ip, IPCTL_ACCEPTSOURCEROUTE, accept_sourceroute, - CTLFLAG_RW, &ip_acceptsourceroute, 0, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip_acceptsourceroute), 0, "Enable accepting source routed IP packets"); +#define V_ip_acceptsourceroute VNET(ip_acceptsourceroute) -int ip_doopts = 1; /* 0 = ignore, 1 = process, 2 = reject */ -SYSCTL_INT(_net_inet_ip, OID_AUTO, process_options, CTLFLAG_RW, - &ip_doopts, 0, "Enable IP options processing ([LS]SRR, RR, TS)"); +VNET_DEFINE(int, ip_doopts) = 1; /* 0 = ignore, 1 = process, 2 = reject */ +SYSCTL_INT(_net_inet_ip, OID_AUTO, process_options, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(ip_doopts), 0, "Enable IP options processing ([LS]SRR, RR, TS)"); static void save_rte(struct mbuf *m, u_char *, struct in_addr); @@ -104,9 +107,9 @@ ip_dooptions(struct mbuf *m, int pass) struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; /* Ignore or reject packets with IP options. */ - if (ip_doopts == 0) + if (V_ip_doopts == 0) return 0; - else if (ip_doopts == 2) { + else if (V_ip_doopts == 2) { type = ICMP_UNREACH; code = ICMP_UNREACH_FILTER_PROHIB; goto bad; @@ -167,7 +170,7 @@ ip_dooptions(struct mbuf *m, int pass) code = ICMP_UNREACH_SRCFAIL; goto bad; } - if (!ip_dosourceroute) + if (!V_ip_dosourceroute) goto nosourcerouting; /* * Loose routing, and not at next destination @@ -180,7 +183,7 @@ ip_dooptions(struct mbuf *m, int pass) /* * End of source route. Should be for us. */ - if (!ip_acceptsourceroute) + if (!V_ip_acceptsourceroute) goto nosourcerouting; save_rte(m, cp, ip->ip_src); break; @@ -189,7 +192,7 @@ ip_dooptions(struct mbuf *m, int pass) if (V_ipstealth) goto dropit; #endif - if (!ip_dosourceroute) { + if (!V_ip_dosourceroute) { if (V_ipforwarding) { char buf[16]; /* aaa.bbb.ccc.ddd\0 */ /* @@ -227,8 +230,11 @@ ip_dooptions(struct mbuf *m, int pass) if (opt == IPOPT_SSRR) { #define INA struct in_ifaddr * #define SA struct sockaddr * - if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == NULL) - ia = (INA)ifa_ifwithnet((SA)&ipaddr, 0); + ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr, + RT_ALL_FIBS); + if (ia == NULL) + ia = (INA)ifa_ifwithnet((SA)&ipaddr, 0, + RT_ALL_FIBS); } else /* XXX MRT 0 for routing */ ia = ip_rtaddr(ipaddr.sin_addr, M_GETFIB(m)); diff --git a/sys/netinet/ip_options.h b/sys/netinet/ip_options.h index 7cb447e05469..4a6ea420e20e 100644 --- a/sys/netinet/ip_options.h +++ b/sys/netinet/ip_options.h @@ -47,7 +47,8 @@ struct ipopt_tag { struct ipoptrt ip_srcrt; }; -extern int ip_doopts; /* process or ignore IP options */ +VNET_DECLARE(int, ip_doopts); /* process or ignore IP options */ +#define V_ip_doopts VNET(ip_doopts) int ip_checkrouteralert(struct mbuf *); int ip_dooptions(struct mbuf *, int); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 8503b2fe4475..827d25af34b6 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -136,7 +136,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, struct rtentry *rte; /* cache for ro->ro_rt */ struct in_addr odst; struct m_tag *fwd_tag = NULL; + uint32_t fibnum; int have_ia_ref; + int needfiblookup; #ifdef IPSEC int no_route_but_check_spd = 0; #endif @@ -145,7 +147,8 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, if (inp != NULL) { INP_LOCK_ASSERT(inp); M_SETFIB(m, inp->inp_inc.inc_fibnum); - if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { + if (((flags & IP_NODEFAULTFLOWID) == 0) && + inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { m->m_pkthdr.flowid = inp->inp_flowid; M_HASHTYPE_SET(m, inp->inp_flowtype); m->m_flags |= M_FLOWID; @@ -201,6 +204,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, * therefore we need restore gw if we're redoing lookup. */ gw = dst = (struct sockaddr_in *)&ro->ro_dst; + fibnum = (inp != NULL) ? inp->inp_inc.inc_fibnum : M_GETFIB(m); again: ia = NULL; have_ia_ref = 0; @@ -234,8 +238,10 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, * or the destination address of a ptp interface. */ if (flags & IP_SENDONES) { - if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst)))) == NULL && - (ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL) { + if ((ia = ifatoia(ifa_ifwithbroadaddr(sintosa(dst), + M_GETFIB(m)))) == NULL && + (ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst), + M_GETFIB(m)))) == NULL) { IPSTAT_INC(ips_noroute); error = ENETUNREACH; goto bad; @@ -247,8 +253,10 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, ip->ip_ttl = 1; isbroadcast = 1; } else if (flags & IP_ROUTETOIF) { - if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == NULL && - (ia = ifatoia(ifa_ifwithnet(sintosa(dst), 0))) == NULL) { + if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst), + M_GETFIB(m)))) == NULL && + (ia = ifatoia(ifa_ifwithnet(sintosa(dst), 0, + M_GETFIB(m)))) == NULL) { IPSTAT_INC(ips_noroute); error = ENETUNREACH; goto bad; @@ -278,10 +286,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, #ifdef RADIX_MPATH rtalloc_mpath_fib(ro, ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr), - inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m)); + fibnum); #else - in_rtalloc_ign(ro, 0, - inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m)); + in_rtalloc_ign(ro, 0, fibnum); #endif rte = ro->ro_rt; } @@ -440,43 +447,6 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, } } - /* - * Both in the SMP world, pre-emption world if_transmit() world, - * the following code doesn't really function as intended any further. - * - * + There can and will be multiple CPUs running this code path - * in parallel, and we do no lock holding when checking the - * queue depth; - * + And since other threads can be running concurrently, even if - * we do pass this check, another thread may queue some frames - * before this thread does and it will end up partially or fully - * failing to send anyway; - * + if_transmit() based drivers don't necessarily set ifq_len - * at all. - * - * This should be replaced with a method of pushing an entire list - * of fragment frames to the driver and have the driver decide - * whether it can queue or not queue the entire set. - */ -#if 0 - /* - * Verify that we have any chance at all of being able to queue the - * packet or packet fragments, unless ALTQ is enabled on the given - * interface in which case packetdrop should be done by queueing. - */ - n = ip_len / mtu + 1; /* how many fragments ? */ - if ( -#ifdef ALTQ - (!ALTQ_IS_ENABLED(&ifp->if_snd)) && -#endif /* ALTQ */ - (ifp->if_snd.ifq_len + n) >= ifp->if_snd.ifq_maxlen ) { - error = ENOBUFS; - IPSTAT_INC(ips_odropped); - ifp->if_snd.ifq_drops += n; - goto bad; - } -#endif - /* * Look for broadcast address and * verify user is allowed to send @@ -536,6 +506,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, goto done; ip = mtod(m, struct ip *); + needfiblookup = 0; /* See if destination IP address was changed by packet filter. */ if (odst.s_addr != ip->ip_dst.s_addr) { @@ -561,9 +532,18 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, } else { if (have_ia_ref) ifa_free(&ia->ia_ifa); - goto again; /* Redo the routing table lookup. */ + needfiblookup = 1; /* Redo the routing table lookup. */ } } + /* See if fib was changed by packet filter. */ + if (fibnum != M_GETFIB(m)) { + m->m_flags |= M_SKIP_FIREWALL; + fibnum = M_GETFIB(m); + RO_RTFREE(ro); + needfiblookup = 1; + } + if (needfiblookup) + goto again; /* See if local, if yes, send it to netisr with IP_FASTFWD_OURS. */ if (m->m_flags & M_FASTFWD_OURS) { @@ -1015,6 +995,10 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) case IP_ONESBCAST: case IP_DONTFRAG: case IP_RECVTOS: + case IP_RECVFLOWID: +#ifdef RSS + case IP_RECVRSSBUCKETID: +#endif error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); if (error) @@ -1093,6 +1077,9 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) case IP_BINDMULTI: OPTSET2(INP_BINDMULTI, optval); break; + case IP_RECVFLOWID: + OPTSET2(INP_RECVFLOWID, optval); + break; #ifdef RSS case IP_RSS_LISTEN_BUCKET: if ((optval >= 0) && @@ -1103,6 +1090,9 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) error = EINVAL; } break; + case IP_RECVRSSBUCKETID: + OPTSET2(INP_RECVRSSBUCKETID, optval); + break; #endif } break; @@ -1218,8 +1208,10 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) case IP_BINDMULTI: case IP_FLOWID: case IP_FLOWTYPE: + case IP_RECVFLOWID: #ifdef RSS case IP_RSSBUCKETID: + case IP_RECVRSSBUCKETID: #endif switch (sopt->sopt_name) { @@ -1289,6 +1281,9 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) case IP_FLOWTYPE: optval = inp->inp_flowtype; break; + case IP_RECVFLOWID: + optval = OPTBIT2(INP_RECVFLOWID); + break; #ifdef RSS case IP_RSSBUCKETID: retval = rss_hash2bucket(inp->inp_flowid, @@ -1299,6 +1294,9 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) else error = EINVAL; break; + case IP_RECVRSSBUCKETID: + optval = OPTBIT2(INP_RECVRSSBUCKETID); + break; #endif case IP_BINDMULTI: optval = OPTBIT2(INP_BINDMULTI); diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index c2ab8b43d843..9f4410107a96 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -161,6 +161,7 @@ void kmod_ipstat_dec(int statnum); #define IP_SENDTOIF 0x8 /* send on specific ifnet */ #define IP_ROUTETOIF SO_DONTROUTE /* 0x10 bypass routing tables */ #define IP_ALLOWBROADCAST SO_BROADCAST /* 0x20 can send broadcast packets */ +#define IP_NODEFAULTFLOWID 0x40 /* Don't set the flowid from inp */ #ifdef __NO_STRICT_ALIGNMENT #define IP_HDR_ALIGNED_P(ip) 1 diff --git a/sys/netinet/sctp_asconf.c b/sys/netinet/sctp_asconf.c index 127710171c38..6e44d151a692 100644 --- a/sys/netinet/sctp_asconf.c +++ b/sys/netinet/sctp_asconf.c @@ -148,7 +148,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap { struct sctp_nets *net; struct mbuf *m_reply = NULL; - struct sockaddr_storage sa_store; + union sctp_sockstore store; struct sctp_paramhdr *ph; uint16_t param_type, aparam_length; @@ -177,7 +177,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap #if defined(INET) || defined(INET6) param_length = ntohs(ph->param_length); #endif - sa = (struct sockaddr *)&sa_store; + sa = &store.sa; switch (param_type) { #ifdef INET case SCTP_IPV4_ADDRESS: @@ -186,7 +186,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap return (NULL); } v4addr = (struct sctp_ipv4addr_param *)ph; - sin = (struct sockaddr_in *)&sa_store; + sin = &store.sin; bzero(sin, sizeof(*sin)); sin->sin_family = AF_INET; sin->sin_len = sizeof(struct sockaddr_in); @@ -209,7 +209,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap return (NULL); } v6addr = (struct sctp_ipv6addr_param *)ph; - sin6 = (struct sockaddr_in6 *)&sa_store; + sin6 = &store.sin6; bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(struct sockaddr_in6); @@ -302,7 +302,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src, struct sctp_tcb *stcb, int response_required) { struct mbuf *m_reply = NULL; - struct sockaddr_storage sa_store; + union sctp_sockstore store; struct sctp_paramhdr *ph; uint16_t param_type, aparam_length; @@ -331,7 +331,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src, #if defined(INET) || defined(INET6) param_length = ntohs(ph->param_length); #endif - sa = (struct sockaddr *)&sa_store; + sa = &store.sa; switch (param_type) { #ifdef INET case SCTP_IPV4_ADDRESS: @@ -340,7 +340,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src, return (NULL); } v4addr = (struct sctp_ipv4addr_param *)ph; - sin = (struct sockaddr_in *)&sa_store; + sin = &store.sin; bzero(sin, sizeof(*sin)); sin->sin_family = AF_INET; sin->sin_len = sizeof(struct sockaddr_in); @@ -360,7 +360,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src, return (NULL); } v6addr = (struct sctp_ipv6addr_param *)ph; - sin6 = (struct sockaddr_in6 *)&sa_store; + sin6 = &store.sin6; bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(struct sockaddr_in6); @@ -437,7 +437,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src, struct sctp_tcb *stcb, int response_required) { struct mbuf *m_reply = NULL; - struct sockaddr_storage sa_store; + union sctp_sockstore store; struct sctp_paramhdr *ph; uint16_t param_type, aparam_length; @@ -465,7 +465,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src, #if defined(INET) || defined(INET6) param_length = ntohs(ph->param_length); #endif - sa = (struct sockaddr *)&sa_store; + sa = &store.sa; switch (param_type) { #ifdef INET case SCTP_IPV4_ADDRESS: @@ -474,7 +474,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src, return (NULL); } v4addr = (struct sctp_ipv4addr_param *)ph; - sin = (struct sockaddr_in *)&sa_store; + sin = &store.sin; bzero(sin, sizeof(*sin)); sin->sin_family = AF_INET; sin->sin_len = sizeof(struct sockaddr_in); @@ -492,7 +492,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src, return (NULL); } v6addr = (struct sctp_ipv6addr_param *)ph; - sin6 = (struct sockaddr_in6 *)&sa_store; + sin6 = &store.sin6; bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(struct sockaddr_in6); @@ -1268,7 +1268,7 @@ sctp_asconf_queue_mgmt(struct sctp_tcb *stcb, struct sctp_ifa *ifa, { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&ifa->address.sa; + sin6 = &ifa->address.sin6; aa->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; aa->ap.addrp.ph.param_length = (sizeof(struct sctp_ipv6addr_param)); aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_paramhdr) + @@ -1283,7 +1283,7 @@ sctp_asconf_queue_mgmt(struct sctp_tcb *stcb, struct sctp_ifa *ifa, { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&ifa->address.sa; + sin = &ifa->address.sin; aa->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; aa->ap.addrp.ph.param_length = (sizeof(struct sctp_ipv4addr_param)); aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_paramhdr) + @@ -1925,7 +1925,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&ifa->address.sin6; + sin6 = &ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { /* we skip unspecifed addresses */ return; @@ -1958,7 +1958,7 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_IPV6_V6ONLY(inp6)) return; - sin = (struct sockaddr_in *)&ifa->address.sa; + sin = &ifa->address.sin; if (sin->sin_addr.s_addr == 0) { /* we skip unspecifed addresses */ return; @@ -2115,7 +2115,7 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, else continue; } - sin6 = (struct sockaddr_in6 *)&ifa->address.sin6; + sin6 = &ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { /* we skip unspecifed addresses */ continue; @@ -2149,7 +2149,7 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_IPV6_V6ONLY(inp6)) continue; - sin = (struct sockaddr_in *)&ifa->address.sa; + sin = &ifa->address.sin; if (sin->sin_addr.s_addr == 0) { /* we skip unspecifed addresses */ continue; @@ -2466,7 +2466,7 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked) if (stcb->asoc.scope.ipv4_addr_legal) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&sctp_ifa->address.sa; + sin = &sctp_ifa->address.sin; if (sin->sin_addr.s_addr == 0) { /* skip unspecifed addresses */ continue; @@ -2500,7 +2500,7 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked) if (sctp_ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { continue; } - sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa; + sin6 = &sctp_ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { /* * we skip unspecifed @@ -2772,18 +2772,16 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, struct sctp_paramhdr tmp_param, *ph; uint16_t plen, ptype; struct sctp_ifa *sctp_ifa; + union sctp_sockstore store; #ifdef INET6 struct sctp_ipv6addr_param addr6_store; - struct sockaddr_in6 sin6; #endif #ifdef INET struct sctp_ipv4addr_param addr4_store; - struct sockaddr_in sin; #endif - struct sockaddr *sa; uint32_t vrf_id; SCTPDBG(SCTP_DEBUG_ASCONF2, "processing init-ack addresses\n"); @@ -2796,21 +2794,6 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, if ((offset + sizeof(struct sctp_paramhdr)) > length) { return; } - /* init the addresses */ -#ifdef INET6 - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(sin6); - sin6.sin6_port = stcb->rport; -#endif - -#ifdef INET - bzero(&sin, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(sin); - sin.sin_port = stcb->rport; -#endif - /* go through the addresses in the init-ack */ ph = (struct sctp_paramhdr *) sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr), @@ -2833,9 +2816,11 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, a6p == NULL) { return; } - memcpy(&sin6.sin6_addr, a6p->addr, - sizeof(struct in6_addr)); - sa = (struct sockaddr *)&sin6; + memset(&store, 0, sizeof(union sctp_sockstore)); + store.sin6.sin6_family = AF_INET6; + store.sin6.sin6_len = sizeof(struct sockaddr_in6); + store.sin6.sin6_port = stcb->rport; + memcpy(&store.sin6.sin6_addr, a6p->addr, sizeof(struct in6_addr)); break; } #endif @@ -2852,8 +2837,11 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, a4p == NULL) { return; } - sin.sin_addr.s_addr = a4p->addr; - sa = (struct sockaddr *)&sin; + memset(&store, 0, sizeof(union sctp_sockstore)); + store.sin.sin_family = AF_INET; + store.sin.sin_len = sizeof(struct sockaddr_in); + store.sin.sin_port = stcb->rport; + store.sin.sin_addr.s_addr = a4p->addr; break; } #endif @@ -2867,7 +2855,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, } else { vrf_id = SCTP_DEFAULT_VRFID; } - sctp_ifa = sctp_find_ifa_by_addr(sa, vrf_id, + sctp_ifa = sctp_find_ifa_by_addr(&store.sa, vrf_id, SCTP_ADDR_NOT_LOCKED); if (sctp_ifa == NULL) { /* address doesn't exist anymore */ @@ -2878,7 +2866,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, SCTP_PCB_FLAGS_DO_ASCONF)) && stcb->asoc.asconf_supported) { /* queue an ASCONF DEL_IP_ADDRESS */ - status = sctp_asconf_queue_sa_delete(stcb, sa); + status = sctp_asconf_queue_sa_delete(stcb, &store.sa); /* * if queued ok, and in correct state, send * out the ASCONF. @@ -3125,7 +3113,7 @@ sctp_check_address_list_all(struct sctp_tcb *stcb, struct mbuf *m, int offset, switch (sctp_ifa->address.sa.sa_family) { #ifdef INET case AF_INET: - sin = (struct sockaddr_in *)&sctp_ifa->address.sin; + sin = &sctp_ifa->address.sin; if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin->sin_addr) != 0) { continue; @@ -3139,7 +3127,7 @@ sctp_check_address_list_all(struct sctp_tcb *stcb, struct mbuf *m, int offset, #endif #ifdef INET6 case AF_INET6: - sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sin6; + sin6 = &sctp_ifa->address.sin6; if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, &sin6->sin6_addr) != 0) { continue; diff --git a/sys/netinet/sctp_auth.c b/sys/netinet/sctp_auth.c index 1f301030b2d4..8ce2aab4f936 100644 --- a/sys/netinet/sctp_auth.c +++ b/sys/netinet/sctp_auth.c @@ -631,7 +631,7 @@ sctp_copy_skeylist(const struct sctp_keyhead *src, struct sctp_keyhead *dest) sctp_hmaclist_t * -sctp_alloc_hmaclist(uint8_t num_hmacs) +sctp_alloc_hmaclist(uint16_t num_hmacs) { sctp_hmaclist_t *new_list; int alloc_size; @@ -1438,8 +1438,8 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m, p_random = (struct sctp_auth_random *)phdr; random_len = plen - sizeof(*p_random); } else if (ptype == SCTP_HMAC_LIST) { - int num_hmacs; - int i; + uint16_t num_hmacs; + uint16_t i; if (plen > sizeof(hmacs_store)) break; diff --git a/sys/netinet/sctp_auth.h b/sys/netinet/sctp_auth.h index 423a5cc50538..b98764e255cd 100644 --- a/sys/netinet/sctp_auth.h +++ b/sys/netinet/sctp_auth.h @@ -154,7 +154,7 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid, /* hmac list handling */ -extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint8_t num_hmacs); +extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs); extern void sctp_free_hmaclist(sctp_hmaclist_t * list); extern int sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id); extern sctp_hmaclist_t *sctp_copy_hmaclist(sctp_hmaclist_t * list); diff --git a/sys/netinet/sctp_cc_functions.c b/sys/netinet/sctp_cc_functions.c index d788ff2ffcda..e32faf95a0cf 100644 --- a/sys/netinet/sctp_cc_functions.c +++ b/sys/netinet/sctp_cc_functions.c @@ -1130,12 +1130,9 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, uint32_t * bottle_bw, uint32_t * on_queue) { uint32_t bw_avail; - int rtt; unsigned int incr; int old_cwnd = net->cwnd; - /* need real RTT in msd for this calc */ - rtt = net->rtt / 1000; /* get bottle neck bw */ *bottle_bw = ntohl(cp->bottle_bw); /* and whats on queue */ @@ -1144,10 +1141,11 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, * adjust the on-queue if our flight is more it could be that the * router has not yet gotten data "in-flight" to it */ - if (*on_queue < net->flight_size) + if (*on_queue < net->flight_size) { *on_queue = net->flight_size; - /* calculate the available space */ - bw_avail = (*bottle_bw * rtt) / 1000; + } + /* rtt is measured in micro seconds, bottle_bw in bytes per second */ + bw_avail = (uint32_t) (((uint64_t) (*bottle_bw) * net->rtt) / (uint64_t) 1000000); if (bw_avail > *bottle_bw) { /* * Cap the growth to no more than the bottle neck. This can @@ -1167,7 +1165,6 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, int seg_inflight, seg_onqueue, my_portion; net->partial_bytes_acked = 0; - /* how much are we over queue size? */ incr = *on_queue - bw_avail; if (stcb->asoc.seen_a_sack_this_pkt) { diff --git a/sys/netinet/sctp_constants.h b/sys/netinet/sctp_constants.h index 0ede04ca92df..de451651a6a6 100644 --- a/sys/netinet/sctp_constants.h +++ b/sys/netinet/sctp_constants.h @@ -267,18 +267,9 @@ __FBSDID("$FreeBSD$"); /* how many addresses per assoc remote and local */ #define SCTP_SCALE_FOR_ADDR 2 -/* default AUTO_ASCONF mode enable(1)/disable(0) value (sysctl) */ -#define SCTP_DEFAULT_AUTO_ASCONF 1 - /* default MULTIPLE_ASCONF mode enable(1)/disable(0) value (sysctl) */ #define SCTP_DEFAULT_MULTIPLE_ASCONFS 0 -/* default MOBILITY_BASE mode enable(1)/disable(0) value (sysctl) */ -#define SCTP_DEFAULT_MOBILITY_BASE 0 - -/* default MOBILITY_FASTHANDOFF mode enable(1)/disable(0) value (sysctl) */ -#define SCTP_DEFAULT_MOBILITY_FASTHANDOFF 0 - /* * Theshold for rwnd updates, we have to read (sb_hiwat >> * SCTP_RWND_HIWAT_SHIFT) before we will look to see if we need to send a diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index f7ebe57f4f17..fa108a394de9 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -562,21 +562,12 @@ static void sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, struct sctp_tcb *stcb, struct sctp_nets *net) { - struct sockaddr_storage store; + union sctp_sockstore store; struct sctp_nets *r_net, *f_net; struct timeval tv; int req_prim = 0; uint16_t old_error_counter; -#ifdef INET - struct sockaddr_in *sin; - -#endif -#ifdef INET6 - struct sockaddr_in6 *sin6; - -#endif - if (ntohs(cp->ch.chunk_length) != sizeof(struct sctp_heartbeat_chunk)) { /* Invalid length */ return; @@ -586,12 +577,11 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, #ifdef INET case AF_INET: if (cp->heartbeat.hb_info.addr_len == sizeof(struct sockaddr_in)) { - sin = (struct sockaddr_in *)&store; - sin->sin_family = cp->heartbeat.hb_info.addr_family; - sin->sin_len = cp->heartbeat.hb_info.addr_len; - sin->sin_port = stcb->rport; - memcpy(&sin->sin_addr, cp->heartbeat.hb_info.address, - sizeof(sin->sin_addr)); + store.sin.sin_family = cp->heartbeat.hb_info.addr_family; + store.sin.sin_len = cp->heartbeat.hb_info.addr_len; + store.sin.sin_port = stcb->rport; + memcpy(&store.sin.sin_addr, cp->heartbeat.hb_info.address, + sizeof(store.sin.sin_addr)); } else { return; } @@ -600,12 +590,10 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, #ifdef INET6 case AF_INET6: if (cp->heartbeat.hb_info.addr_len == sizeof(struct sockaddr_in6)) { - sin6 = (struct sockaddr_in6 *)&store; - sin6->sin6_family = cp->heartbeat.hb_info.addr_family; - sin6->sin6_len = cp->heartbeat.hb_info.addr_len; - sin6->sin6_port = stcb->rport; - memcpy(&sin6->sin6_addr, cp->heartbeat.hb_info.address, - sizeof(sin6->sin6_addr)); + store.sin6.sin6_family = cp->heartbeat.hb_info.addr_family; + store.sin6.sin6_len = cp->heartbeat.hb_info.addr_len; + store.sin6.sin6_port = stcb->rport; + memcpy(&store.sin6.sin6_addr, cp->heartbeat.hb_info.address, sizeof(struct in6_addr)); } else { return; } @@ -614,7 +602,7 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp, default: return; } - r_net = sctp_findnet(stcb, (struct sockaddr *)&store); + r_net = sctp_findnet(stcb, &store.sa); if (r_net == NULL) { SCTPDBG(SCTP_DEBUG_INPUT1, "Huh? I can't find the address I sent it to, discard\n"); return; @@ -2030,22 +2018,13 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, struct sctp_tcb *stcb; struct sctp_init_chunk *init_cp, init_buf; struct sctp_init_ack_chunk *initack_cp, initack_buf; - struct sockaddr_storage sa_store; - struct sockaddr *initack_src = (struct sockaddr *)&sa_store; + union sctp_sockstore store; struct sctp_association *asoc; int init_offset, initack_offset, initack_limit; int retval; int error = 0; uint8_t auth_chunk_buf[SCTP_PARAM_BUFFER_SIZE]; -#ifdef INET - struct sockaddr_in *sin; - -#endif -#ifdef INET6 - struct sockaddr_in6 *sin6; - -#endif #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) struct socket *so; @@ -2269,23 +2248,20 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, #ifdef INET case SCTP_IPV4_ADDRESS: /* source addr is IPv4 */ - sin = (struct sockaddr_in *)initack_src; - memset(sin, 0, sizeof(*sin)); - sin->sin_family = AF_INET; - sin->sin_len = sizeof(struct sockaddr_in); - sin->sin_addr.s_addr = cookie->laddress[0]; + memset(&store.sin, 0, sizeof(struct sockaddr_in)); + store.sin.sin_family = AF_INET; + store.sin.sin_len = sizeof(struct sockaddr_in); + store.sin.sin_addr.s_addr = cookie->laddress[0]; break; #endif #ifdef INET6 case SCTP_IPV6_ADDRESS: /* source addr is IPv6 */ - sin6 = (struct sockaddr_in6 *)initack_src; - memset(sin6, 0, sizeof(*sin6)); - sin6->sin6_family = AF_INET6; - sin6->sin6_len = sizeof(struct sockaddr_in6); - sin6->sin6_scope_id = cookie->scope_id; - memcpy(&sin6->sin6_addr, cookie->laddress, - sizeof(sin6->sin6_addr)); + memset(&store.sin6, 0, sizeof(struct sockaddr_in6)); + store.sin6.sin6_family = AF_INET6; + store.sin6.sin6_len = sizeof(struct sockaddr_in6); + store.sin6.sin6_scope_id = cookie->scope_id; + memcpy(&store.sin6.sin6_addr, cookie->laddress, sizeof(struct in6_addr)); break; #endif default: @@ -2366,7 +2342,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, sctp_check_address_list(stcb, m, initack_offset + sizeof(struct sctp_init_ack_chunk), initack_limit - (initack_offset + sizeof(struct sctp_init_ack_chunk)), - initack_src, cookie->local_scope, cookie->site_scope, + &store.sa, cookie->local_scope, cookie->site_scope, cookie->ipv4_scope, cookie->loopback_scope); @@ -2906,9 +2882,9 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_cookie_ack: handling COOKIE-ACK\n"); - if (stcb == NULL) + if ((stcb == NULL) || (net == NULL)) { return; - + } asoc = &stcb->asoc; sctp_stop_all_cookie_timers(stcb); diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index b241f75a0152..558d4e18357c 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -152,16 +152,10 @@ MALLOC_DECLARE(SCTP_M_MCORE); #define V_system_base_info VNET(system_base_info) #define SCTP_BASE_INFO(__m) V_system_base_info.sctppcbinfo.__m #define SCTP_BASE_STATS V_system_base_info.sctpstat -#define SCTP_BASE_STATS_SYSCTL VNET_NAME(system_base_info.sctpstat) -#define SCTP_BASE_STAT(__m) V_system_base_info.sctpstat.__m -#define SCTP_BASE_SYSCTL(__m) VNET_NAME(system_base_info.sctpsysctl.__m) +#define SCTP_BASE_STAT(__m) V_system_base_info.sctpstat.__m +#define SCTP_BASE_SYSCTL(__m) V_system_base_info.sctpsysctl.__m #define SCTP_BASE_VAR(__m) V_system_base_info.__m -/* - * - */ -#define USER_ADDR_NULL (NULL) /* FIX ME: temp */ - #define SCTP_PRINTF(params...) printf(params) #if defined(SCTP_DEBUG) #define SCTPDBG(level, params...) \ @@ -175,9 +169,9 @@ MALLOC_DECLARE(SCTP_M_MCORE); #define SCTPDBG_ADDR(level, addr) \ { \ do { \ - if (SCTP_BASE_SYSCTL(sctp_debug_on) & level ) { \ - sctp_print_address(addr); \ - } \ + if (SCTP_BASE_SYSCTL(sctp_debug_on) & level ) { \ + sctp_print_address(addr); \ + } \ } while (0); \ } #else @@ -328,7 +322,7 @@ typedef struct callout sctp_os_timer_t; /* MTU */ /*************************/ #define SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, af) ((struct ifnet *)ifn)->if_mtu -#define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, rt) ((rt != NULL) ? rt->rt_mtu : 0) +#define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, rt) ((uint32_t)((rt != NULL) ? rt->rt_mtu : 0)) #define SCTP_GATHER_MTU_FROM_INTFC(sctp_ifn) ((sctp_ifn->ifn_p != NULL) ? ((struct ifnet *)(sctp_ifn->ifn_p))->if_mtu : 0) #define SCTP_SET_MTU_OF_ROUTE(sa, rt, mtu) do { \ if (rt != NULL) \ diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index e1a6a03a1c41..c9b7722f2367 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -1881,7 +1881,7 @@ sctp_is_address_in_scope(struct sctp_ifa *ifa, if (scope->ipv4_addr_legal) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&ifa->address.sin; + sin = &ifa->address.sin; if (sin->sin_addr.s_addr == 0) { /* not in scope , unspecified */ return (0); @@ -1912,7 +1912,7 @@ sctp_is_address_in_scope(struct sctp_ifa *ifa, return (0); } /* ok to use deprecated addresses? */ - sin6 = (struct sockaddr_in6 *)&ifa->address.sin6; + sin6 = &ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { /* skip unspecifed addresses */ return (0); @@ -1987,7 +1987,7 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len) struct sctp_ipv4addr_param *ipv4p; struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&ifa->address.sin; + sin = &ifa->address.sin; ipv4p = (struct sctp_ipv4addr_param *)parmh; parmh->param_type = htons(SCTP_IPV4_ADDRESS); parmh->param_length = htons(plen); @@ -2002,7 +2002,7 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len) struct sctp_ipv6addr_param *ipv6p; struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&ifa->address.sin6; + sin6 = &ifa->address.sin6; ipv6p = (struct sctp_ipv6addr_param *)parmh; parmh->param_type = htons(SCTP_IPV6_ADDRESS); parmh->param_length = htons(plen); @@ -5921,8 +5921,8 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, parameter_len = (uint16_t) sizeof(struct sctp_paramhdr); ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len); ph->param_type = htons(SCTP_HAS_NAT_SUPPORT); - ph->param_length = htons(sizeof(struct sctp_paramhdr)); - chunk_len += sizeof(struct sctp_paramhdr); + ph->param_length = htons(parameter_len); + chunk_len += parameter_len; } /* And now tell the peer which extensions we support */ num_ext = 0; @@ -11301,7 +11301,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net, int so_locked hb->heartbeat.hb_info.time_value_1 = now.tv_sec; hb->heartbeat.hb_info.time_value_2 = now.tv_usec; /* Did our user request this one, put it in */ - hb->heartbeat.hb_info.addr_family = net->ro._l_addr.sa.sa_family; + hb->heartbeat.hb_info.addr_family = (uint8_t) net->ro._l_addr.sa.sa_family; hb->heartbeat.hb_info.addr_len = net->ro._l_addr.sa.sa_len; if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { /* @@ -13552,7 +13552,7 @@ sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t * ro) } ifa = (struct ifaddr *)sifa->ifa; mask = (struct sockaddr_in *)(ifa->ifa_netmask); - sin = (struct sockaddr_in *)&sifa->address.sin; + sin = &sifa->address.sin; srcnetaddr.s_addr = (sin->sin_addr.s_addr & mask->sin_addr.s_addr); SCTPDBG(SCTP_DEBUG_OUTPUT1, "match_nexthop4: src address is "); SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &sifa->address.sa); diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 39348a472042..2fa99b9e6243 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -625,7 +625,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&sctp_ifap->address.sin; + sin = &sctp_ifap->address.sin; if (SCTP_IFN_IS_IFT_LOOP(sctp_ifap->ifn_p) || (IN4_ISLOOPBACK_ADDRESS(&sin->sin_addr))) { sctp_ifap->src_is_loop = 1; @@ -645,7 +645,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, /* ok to use deprecated addresses? */ struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&sctp_ifap->address.sin6; + sin6 = &sctp_ifap->address.sin6; if (SCTP_IFN_IS_IFT_LOOP(sctp_ifap->ifn_p) || (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))) { sctp_ifap->src_is_loop = 1; @@ -974,7 +974,7 @@ sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) { struct sockaddr_in *sin, *rsin; - sin = (struct sockaddr_in *)&laddr->ifa->address.sin; + sin = &laddr->ifa->address.sin; rsin = (struct sockaddr_in *)to; if (sin->sin_addr.s_addr == rsin->sin_addr.s_addr) { SCTP_IPI_ADDR_RUNLOCK(); @@ -988,7 +988,7 @@ sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) { struct sockaddr_in6 *sin6, *rsin6; - sin6 = (struct sockaddr_in6 *)&laddr->ifa->address.sin6; + sin6 = &laddr->ifa->address.sin6; rsin6 = (struct sockaddr_in6 *)to; if (SCTP6_ARE_ADDR_EQUAL(sin6, rsin6)) { SCTP_IPI_ADDR_RUNLOCK(); @@ -2330,7 +2330,7 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int offset, struct sctp_inpcb **inp_p, struct sctp_nets **netp, uint32_t vrf_id) { struct sctp_tcb *stcb; - struct sockaddr_storage remote_store; + union sctp_sockstore remote_store; struct sctp_paramhdr parm_buf, *phdr; int ptype; int zero_address = 0; @@ -2372,7 +2372,7 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int offset, __FUNCTION__); return (NULL); } - sin6 = (struct sockaddr_in6 *)&remote_store; + sin6 = &remote_store.sin6; sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_port = sh->src_port; @@ -2399,7 +2399,7 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int offset, __FUNCTION__); return (NULL); } - sin = (struct sockaddr_in *)&remote_store; + sin = &remote_store.sin; sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); sin->sin_port = sh->src_port; @@ -2422,7 +2422,7 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int offset, } } else { stcb = sctp_findassociation_ep_addr(inp_p, - (struct sockaddr *)&remote_store, netp, + &remote_store.sa, netp, dst, NULL); } return (stcb); @@ -3126,31 +3126,21 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, * too (before adding). */ struct sctp_ifa *ifa; - struct sockaddr_storage store_sa; + union sctp_sockstore store; - memset(&store_sa, 0, sizeof(store_sa)); + memset(&store, 0, sizeof(store)); switch (addr->sa_family) { #ifdef INET case AF_INET: - { - struct sockaddr_in *sin; - - sin = (struct sockaddr_in *)&store_sa; - memcpy(sin, addr, sizeof(struct sockaddr_in)); - sin->sin_port = 0; - break; - } + memcpy(&store.sin, addr, sizeof(struct sockaddr_in)); + store.sin.sin_port = 0; + break; #endif #ifdef INET6 case AF_INET6: - { - struct sockaddr_in6 *sin6; - - sin6 = (struct sockaddr_in6 *)&store_sa; - memcpy(sin6, addr, sizeof(struct sockaddr_in6)); - sin6->sin6_port = 0; - break; - } + memcpy(&store.sin6, addr, sizeof(struct sockaddr_in6)); + store.sin6.sin6_port = 0; + break; #endif default: break; @@ -3168,7 +3158,7 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, * pass things in via the sctp_ifap argument * (Panda). */ - ifa = sctp_find_ifa_by_addr((struct sockaddr *)&store_sa, + ifa = sctp_find_ifa_by_addr(&store.sa, vrf_id, SCTP_ADDR_NOT_LOCKED); } if (ifa == NULL) { @@ -5976,6 +5966,9 @@ sctp_pcb_finish(void) LIST_FOREACH_SAFE(wi, &SCTP_BASE_INFO(addr_wq), sctp_nxt_addr, nwi) { LIST_REMOVE(wi, sctp_nxt_addr); SCTP_DECR_LADDR_COUNT(); + if (wi->action == SCTP_DEL_IP_ADDRESS) { + SCTP_FREE(wi->ifa, SCTP_M_IFA); + } SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_laddr), wi); } SCTP_WQ_ADDR_UNLOCK(); @@ -6130,7 +6123,6 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, peer_supports_prsctp = 0; peer_supports_auth = 0; peer_supports_asconf = 0; - peer_supports_asconf = 0; peer_supports_reconfig = 0; peer_supports_nrsack = 0; peer_supports_pktdrop = 0; @@ -6517,8 +6509,8 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, } got_random = 1; } else if (ptype == SCTP_HMAC_LIST) { - int num_hmacs; - int i; + uint16_t num_hmacs; + uint16_t i; if (plen > sizeof(hmacs_store)) break; diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h index 24c456c82654..3f6d935ba173 100644 --- a/sys/netinet/sctp_structs.h +++ b/sys/netinet/sctp_structs.h @@ -418,8 +418,8 @@ TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); #define CHUNK_FLAGS_FRAGMENT_OK 0x0100 struct chk_id { - uint16_t id; - uint16_t can_take_data; + uint8_t id; + uint8_t can_take_data; }; diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c index 460be0f0defd..6280af55571c 100644 --- a/sys/netinet/sctp_sysctl.c +++ b/sys/netinet/sctp_sysctl.c @@ -105,9 +105,7 @@ sctp_init_sysctls() SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT; SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT; SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT; - /* JRS - Variable for default congestion control module */ SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT; - /* RS - Variable for default stream scheduling module */ SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT; SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT; SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT; @@ -139,7 +137,7 @@ sctp_init_sysctls() /* It returns an upper limit. No filtering is done here */ static unsigned int -number_of_addresses(struct sctp_inpcb *inp) +sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp) { unsigned int cnt; struct sctp_vrf *vrf; @@ -189,7 +187,7 @@ number_of_addresses(struct sctp_inpcb *inp) } static int -copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req) +sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req) { struct sctp_ifn *sctp_ifn; struct sctp_ifa *sctp_ifa; @@ -254,7 +252,7 @@ copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct s if (ipv4_addr_legal) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&sctp_ifa->address.sa; + sin = &sctp_ifa->address.sin; if (sin->sin_addr.s_addr == 0) continue; if (prison_check_ip4(inp->ip_inp.inp.inp_cred, @@ -273,7 +271,7 @@ copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct s if (ipv6_addr_legal) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa; + sin6 = &sctp_ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) continue; if (prison_check_ip6(inp->ip_inp.inp.inp_cred, @@ -355,7 +353,7 @@ copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct s * sysctl functions */ static int -sctp_assoclist(SYSCTL_HANDLER_ARGS) +sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) { unsigned int number_of_endpoints; unsigned int number_of_local_addresses; @@ -377,14 +375,14 @@ sctp_assoclist(SYSCTL_HANDLER_ARGS) number_of_remote_addresses = 0; SCTP_INP_INFO_RLOCK(); - if (req->oldptr == USER_ADDR_NULL) { + if (req->oldptr == NULL) { LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { SCTP_INP_RLOCK(inp); number_of_endpoints++; - number_of_local_addresses += number_of_addresses(inp); + number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { number_of_associations++; - number_of_local_addresses += number_of_addresses(inp); + number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { number_of_remote_addresses++; } @@ -401,7 +399,7 @@ sctp_assoclist(SYSCTL_HANDLER_ARGS) req->oldidx = (n + n / 8); return (0); } - if (req->newptr != USER_ADDR_NULL) { + if (req->newptr != NULL) { SCTP_INP_INFO_RUNLOCK(); SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM); return (EPERM); @@ -439,7 +437,7 @@ sctp_assoclist(SYSCTL_HANDLER_ARGS) } SCTP_INP_INFO_RLOCK(); SCTP_INP_RLOCK(inp); - error = copy_out_local_addresses(inp, NULL, req); + error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req); if (error) { SCTP_INP_DECR_REF(inp); return (error); @@ -490,7 +488,7 @@ sctp_assoclist(SYSCTL_HANDLER_ARGS) } SCTP_INP_INFO_RLOCK(); SCTP_INP_RLOCK(inp); - error = copy_out_local_addresses(inp, stcb, req); + error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req); if (error) { SCTP_INP_DECR_REF(inp); atomic_subtract_int(&stcb->asoc.refcnt, 1); @@ -558,196 +556,97 @@ sctp_assoclist(SYSCTL_HANDLER_ARGS) return (error); } - -#define RANGECHK(var, min, max) \ - if ((var) < (min)) { (var) = (min); } \ - else if ((var) > (max)) { (var) = (max); } - static int -sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS) +sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) { int error; - uint32_t old_sctp_udp_tunneling_port; + uint32_t old, new; SCTP_INP_INFO_RLOCK(); - old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); + old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); SCTP_INP_INFO_RUNLOCK(); - error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if (error == 0) { - RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX); - if (old_sctp_udp_tunneling_port == SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) { - error = 0; - goto out; - } - SCTP_INP_INFO_WLOCK(); - if (old_sctp_udp_tunneling_port) { - sctp_over_udp_stop(); - } - if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) { - if (sctp_over_udp_start()) { - SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0; + new = old; + error = sysctl_handle_int(oidp, &new, 0, req); + if ((error == 0) && + (req->newptr != NULL)) { + if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) || + (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) { + error = EINVAL; + } else { + SCTP_INP_INFO_WLOCK(); + SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new; + if (old != 0) { + sctp_over_udp_stop(); } + if (new != 0) { + error = sctp_over_udp_start(); + } + SCTP_INP_INFO_WUNLOCK(); } - SCTP_INP_INFO_WUNLOCK(); } -out: return (error); } static int -sysctl_sctp_check(SYSCTL_HANDLER_ARGS) +sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) +{ + int error; + uint32_t new; + + new = SCTP_BASE_SYSCTL(sctp_auth_enable); + error = sysctl_handle_int(oidp, &new, 0, req); + if ((error == 0) && + (req->newptr != NULL)) { + if ((new < SCTPCTL_AUTH_ENABLE_MIN) || + (new > SCTPCTL_AUTH_ENABLE_MAX) || + ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { + error = EINVAL; + } else { + SCTP_BASE_SYSCTL(sctp_auth_enable) = new; + } + } + return (error); +} + +static int +sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) +{ + int error; + uint32_t new; + + new = SCTP_BASE_SYSCTL(sctp_asconf_enable); + error = sysctl_handle_int(oidp, &new, 0, req); + if ((error == 0) && + (req->newptr != NULL)) { + if ((new < SCTPCTL_ASCONF_ENABLE_MIN) || + (new > SCTPCTL_ASCONF_ENABLE_MAX) || + ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { + error = EINVAL; + } else { + SCTP_BASE_SYSCTL(sctp_asconf_enable) = new; + } + } + return (error); +} + +static int +sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) { int error; - error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if (error == 0) { - RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_pr_enable), SCTPCTL_PR_ENABLE_MIN, SCTPCTL_PR_ENABLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_reconfig_enable), SCTPCTL_RECONFIG_ENABLE_MIN, SCTPCTL_RECONFIG_ENABLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_nrsack_enable), SCTPCTL_NRSACK_ENABLE_MIN, SCTPCTL_NRSACK_ENABLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_pktdrop_enable), SCTPCTL_PKTDROP_ENABLE_MIN, SCTPCTL_PKTDROP_ENABLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), SCTPCTL_FRMAXBURST_MIN, SCTPCTL_FRMAXBURST_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_path_pf_threshold), SCTPCTL_PATH_PF_THRESHOLD_MIN, SCTPCTL_PATH_PF_THRESHOLD_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), SCTPCTL_INCOMING_STREAMS_MIN, SCTPCTL_INCOMING_STREAMS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_default_ss_module), SCTPCTL_DEFAULT_SS_MODULE_MIN, SCTPCTL_DEFAULT_SS_MODULE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_buffer_splitting), SCTPCTL_BUFFER_SPLITTING_MIN, SCTPCTL_BUFFER_SPLITTING_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_initial_cwnd), SCTPCTL_INITIAL_CWND_MIN, SCTPCTL_INITIAL_CWND_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_bw), SCTPCTL_RTTVAR_BW_MIN, SCTPCTL_RTTVAR_BW_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_rtt), SCTPCTL_RTTVAR_RTT_MIN, SCTPCTL_RTTVAR_RTT_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_eqret), SCTPCTL_RTTVAR_EQRET_MIN, SCTPCTL_RTTVAR_EQRET_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_steady_step), SCTPCTL_RTTVAR_STEADYS_MIN, SCTPCTL_RTTVAR_STEADYS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), SCTPCTL_RTTVAR_DCCCECN_MIN, SCTPCTL_RTTVAR_DCCCECN_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_blackhole), SCTPCTL_BLACKHOLE_MIN, SCTPCTL_BLACKHOLE_MAX); - RANGECHK(SCTP_BASE_SYSCTL(sctp_diag_info_code), SCTPCTL_DIAG_INFO_CODE_MIN, SCTPCTL_DIAG_INFO_CODE_MAX); +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + int cpu; + struct sctpstat sb, *sarry; -#ifdef SCTP_DEBUG - RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX); #endif -#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) - RANGECHK(SCTP_BASE_SYSCTL(sctp_output_unlocked), SCTPCTL_OUTPUT_UNLOCKED_MIN, SCTPCTL_OUTPUT_UNLOCKED_MAX); -#endif - } - return (error); -} -static int -sysctl_sctp_auth_check(SYSCTL_HANDLER_ARGS) -{ - int error; - - error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if (error == 0) { - if (SCTP_BASE_SYSCTL(sctp_auth_enable) < SCTPCTL_AUTH_ENABLE_MIN) { - SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_MIN; - } - if (SCTP_BASE_SYSCTL(sctp_auth_enable) > SCTPCTL_AUTH_ENABLE_MAX) { - SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_MAX; - } - if ((SCTP_BASE_SYSCTL(sctp_auth_enable) == 0) && - (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1)) { - /* - * You can't disable AUTH with disabling ASCONF - * first - */ - SCTP_BASE_SYSCTL(sctp_auth_enable) = 1; - } - } - return (error); -} - -static int -sysctl_sctp_asconf_check(SYSCTL_HANDLER_ARGS) -{ - int error; - - error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if (error == 0) { - if (SCTP_BASE_SYSCTL(sctp_asconf_enable) < SCTPCTL_ASCONF_ENABLE_MIN) { - SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_MIN; - } - if (SCTP_BASE_SYSCTL(sctp_asconf_enable) > SCTPCTL_ASCONF_ENABLE_MAX) { - SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_MAX; - } - if ((SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1) && - (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0)) { - /* - * You can't enable ASCONF without enabling AUTH - * first - */ - SCTP_BASE_SYSCTL(sctp_asconf_enable) = 0; - } - } - return (error); -} - -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) -static int -sysctl_stat_get(SYSCTL_HANDLER_ARGS) -{ - int cpu, error; - struct sctpstat sb, *sarry, *cpin = NULL; - - if ((req->newptr) && (req->newlen == sizeof(struct sctpstat))) { - /* - * User wants us to clear or at least reset the counters to - * the specified values. - */ - cpin = (struct sctpstat *)req->newptr; - } else if (req->newptr) { - /* Must be a stat structure */ + if ((req->newptr != NULL) && + (req->newlen != sizeof(struct sctpstat))) { return (EINVAL); } - memset(&sb, 0, sizeof(sb)); +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + memset(&sb, 0, sizeof(struct sctpstat)); for (cpu = 0; cpu < mp_maxid; cpu++) { sarry = &SCTP_BASE_STATS[cpu]; if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) { @@ -875,19 +774,29 @@ sysctl_stat_get(SYSCTL_HANDLER_ARGS) sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid; sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; - if (cpin) { - memcpy(sarry, cpin, sizeof(struct sctpstat)); + if (req->newptr != NULL) { + memcpy(sarry, req->newptr, sizeof(struct sctpstat)); } } - error = SYSCTL_OUT(req, &sb, sizeof(sb)); + error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat)); +#else + error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); +#endif return (error); } -#endif - #if defined(SCTP_LOCAL_TRACE_BUF) static int -sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS) +sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS) +{ + int error; + + error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); + return (error); +} + +static int +sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) { int error = 0; @@ -897,326 +806,119 @@ sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS) #endif +#define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ + static int \ + sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ + { \ + int error; \ + uint32_t new; \ + \ + new = SCTP_BASE_SYSCTL(var_name); \ + error = sysctl_handle_int(oidp, &new, 0, req); \ + if ((error == 0) && (req->newptr != NULL)) { \ + if ((new < prefix##_MIN) || \ + (new > prefix##_MAX)) { \ + error = EINVAL; \ + } else { \ + SCTP_BASE_SYSCTL(var_name) = new; \ + } \ + } \ + return (error); \ + } \ + SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ + CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ + sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); /* * sysctl definitions */ -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, sendspace, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sysctl_sctp_check, "IU", - SCTPCTL_MAXDGRAM_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, recvspace, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sysctl_sctp_check, "IU", - SCTPCTL_RECVSPACE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, auto_asconf, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sysctl_sctp_check, "IU", - SCTPCTL_AUTOASCONF_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, ecn_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sysctl_sctp_check, "IU", - SCTPCTL_ECN_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, pr_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_pr_enable), 0, sysctl_sctp_check, "IU", - SCTPCTL_PR_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_auth_enable), 0, sysctl_sctp_auth_check, "IU", - SCTPCTL_AUTH_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_asconf_enable), 0, sysctl_sctp_asconf_check, "IU", - SCTPCTL_ASCONF_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, reconfig_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_reconfig_enable), 0, sysctl_sctp_check, "IU", - SCTPCTL_RECONFIG_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, nrsack_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_nrsack_enable), 0, sysctl_sctp_check, "IU", - SCTPCTL_NRSACK_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, pktdrop_enable, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_pktdrop_enable), 0, sysctl_sctp_check, "IU", - SCTPCTL_PKTDROP_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, strict_sacks, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU", - SCTPCTL_STRICT_SACKS_DESC); - - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU", - SCTPCTL_PEER_CHKOH_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, maxburst, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_MAXBURST_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, fr_maxburst, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_FRMAXBURST_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, maxchunks, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sysctl_sctp_check, "IU", - SCTPCTL_MAXCHUNKS_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sysctl_sctp_check, "IU", - SCTPCTL_TCBHASHSIZE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sysctl_sctp_check, "IU", - SCTPCTL_PCBHASHSIZE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, min_split_point, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sysctl_sctp_check, "IU", - SCTPCTL_MIN_SPLIT_POINT_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, chunkscale, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sysctl_sctp_check, "IU", - SCTPCTL_CHUNKSCALE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_DELAYED_SACK_TIME_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, sack_freq, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_SACK_FREQ_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, sys_resource, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sysctl_sctp_check, "IU", - SCTPCTL_SYS_RESOURCE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, asoc_resource, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sysctl_sctp_check, "IU", - SCTPCTL_ASOC_RESOURCE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_HEARTBEAT_INTERVAL_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_PMTU_RAISE_TIME_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_SHUTDOWN_GUARD_TIME_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_SECRET_LIFETIME_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rto_max, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTO_MAX_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rto_min, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTO_MIN_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rto_initial, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTO_INITIAL_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, init_rto_max, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_INIT_RTO_MAX_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_VALID_COOKIE_LIFE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_INIT_RTX_MAX_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_ASSOC_RTX_MAX_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_PATH_RTX_MAX_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, path_pf_threshold, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_path_pf_threshold), 0, sysctl_sctp_check, "IU", - SCTPCTL_PATH_PF_THRESHOLD_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU", - SCTPCTL_ADD_MORE_ON_OUTPUT_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, incoming_streams, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_INCOMING_STREAMS_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU", - SCTPCTL_OUTGOING_STREAMS_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sysctl_sctp_check, "IU", - SCTPCTL_CMT_ON_OFF_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sysctl_sctp_check, "IU", - SCTPCTL_CMT_USE_DAC_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sysctl_sctp_check, "IU", - SCTPCTL_CWND_MAXBURST_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, nat_friendly, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sysctl_sctp_check, "IU", - SCTPCTL_NAT_FRIENDLY_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, abc_l_var, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sysctl_sctp_check, "IU", - SCTPCTL_ABC_L_VAR_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sysctl_sctp_check, "IU", - SCTPCTL_MAX_CHAINED_MBUFS_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sysctl_sctp_check, "IU", - SCTPCTL_DO_SCTP_DRAIN_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sysctl_sctp_check, "IU", - SCTPCTL_HB_MAX_BURST_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sysctl_sctp_check, "IU", - SCTPCTL_ABORT_AT_LIMIT_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, strict_data_order, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sysctl_sctp_check, "IU", - SCTPCTL_STRICT_DATA_ORDER_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, min_residual, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sysctl_sctp_check, "IU", - SCTPCTL_MIN_RESIDUAL_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sysctl_sctp_check, "IU", - SCTPCTL_MAX_RETRAN_CHUNK_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, log_level, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sysctl_sctp_check, "IU", - SCTPCTL_LOGGING_LEVEL_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, default_cc_module, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sysctl_sctp_check, "IU", - SCTPCTL_DEFAULT_CC_MODULE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, default_ss_module, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_default_ss_module), 0, sysctl_sctp_check, "IU", - SCTPCTL_DEFAULT_SS_MODULE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, default_frag_interleave, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sysctl_sctp_check, "IU", - SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, mobility_base, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sysctl_sctp_check, "IU", - SCTPCTL_MOBILITY_BASE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, mobility_fasthandoff, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sysctl_sctp_check, "IU", - SCTPCTL_MOBILITY_FASTHANDOFF_DESC); - +SCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM) +SCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE) +SCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF) +SCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE) +SCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE) +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, + NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC); +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, + NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC); +SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE) +SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE) +SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE) +SCTP_UINT_SYSCTL(strict_sacks, sctp_strict_sacks, SCTPCTL_STRICT_SACKS) +SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH) +SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST) +SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST) +SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS) +SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE) +SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE) +SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT) +SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE) +SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME) +SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ) +SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE) +SCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE) +SCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL) +SCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME) +SCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME) +SCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME) +SCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX) +SCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN) +SCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL) +SCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX) +SCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE) +SCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX) +SCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX) +SCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX) +SCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD) +SCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT) +SCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS) +SCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS) +SCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF) +SCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC) +SCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST) +SCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY) +SCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR) +SCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS) +SCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN) +SCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST) +SCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT) +SCTP_UINT_SYSCTL(strict_data_order, sctp_strict_data_order, SCTPCTL_STRICT_DATA_ORDER) +SCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL) +SCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK) +SCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL) +SCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE) +SCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE) +SCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE) +SCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE) +SCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF) #if defined(SCTP_LOCAL_TRACE_BUF) -SYSCTL_VNET_STRUCT(_net_inet_sctp, OID_AUTO, log, CTLFLAG_RD, - &SCTP_BASE_SYSCTL(sctp_log), sctp_log, - "SCTP logging (struct sctp_log)"); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_log), 0, sysctl_sctp_cleartrace, "IU", - "Clear SCTP Logging buffer"); +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RD, + NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)"); +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, + NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer"); #endif - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU", - SCTPCTL_UDP_TUNNELING_PORT_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU", - SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, nat_friendly_init, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sysctl_sctp_check, "IU", - SCTPCTL_NAT_FRIENDLY_INITS_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, vtag_time_wait, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sysctl_sctp_check, "IU", - SCTPCTL_TIME_WAIT_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, buffer_splitting, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sysctl_sctp_check, "IU", - SCTPCTL_BUFFER_SPLITTING_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, initial_cwnd, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_initial_cwnd), 0, sysctl_sctp_check, "IU", - SCTPCTL_INITIAL_CWND_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rttvar_bw, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_rttvar_bw), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTTVAR_BW_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rttvar_rtt, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_rttvar_rtt), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTTVAR_RTT_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rttvar_eqret, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_rttvar_eqret), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTTVAR_EQRET_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, rttvar_steady_step, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_steady_step), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTTVAR_STEADYS_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, use_dcccecn, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), 0, sysctl_sctp_check, "IU", - SCTPCTL_RTTVAR_DCCCECN_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, blackhole, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_blackhole), 0, sysctl_sctp_check, "IU", - SCTPCTL_BLACKHOLE_DESC); - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, diag_info_code, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_diag_info_code), 0, sysctl_sctp_check, "IU", - SCTPCTL_DIAG_INFO_CODE_DESC); - +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, + NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC); +SCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE) +SCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS) +SCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT) +SCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING) +SCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND) +SCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW) +SCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT) +SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET) +SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS) +SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN) +SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE) +SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE) #ifdef SCTP_DEBUG -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU", - SCTPCTL_DEBUG_DESC); +SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG) #endif - - #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_output_unlocked), 0, sysctl_sctp_check, "IU", - SCTPCTL_OUTPUT_UNLOCKED_DESC); +SCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED) #endif - -#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, stats, - CTLTYPE_STRUCT | CTLFLAG_RW, - 0, 0, sysctl_stat_get, "S,sctpstat", - "SCTP statistics (struct sctp_stat)"); -#else -SYSCTL_VNET_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW, - &SCTP_BASE_STATS_SYSCTL, sctpstat, - "SCTP statistics (struct sctp_stat)"); -#endif - -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLTYPE_OPAQUE | CTLFLAG_RD, - 0, 0, sctp_assoclist, - "S,xassoc", "List of active SCTP associations"); +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RW, + NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)"); +SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RD, + NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations"); diff --git a/sys/netinet/sctp_sysctl.h b/sys/netinet/sctp_sysctl.h index 8488919cb56f..e86910c69e55 100644 --- a/sys/netinet/sctp_sysctl.h +++ b/sys/netinet/sctp_sysctl.h @@ -143,7 +143,7 @@ struct sctp_sysctl { #define SCTPCTL_AUTOASCONF_DESC "Enable SCTP Auto-ASCONF" #define SCTPCTL_AUTOASCONF_MIN 0 #define SCTPCTL_AUTOASCONF_MAX 1 -#define SCTPCTL_AUTOASCONF_DEFAULT SCTP_DEFAULT_AUTO_ASCONF +#define SCTPCTL_AUTOASCONF_DEFAULT 1 /* autoasconf: Enable SCTP Auto-ASCONF */ #define SCTPCTL_MULTIPLEASCONFS_DESC "Enable SCTP Muliple-ASCONFs" @@ -474,13 +474,13 @@ struct sctp_sysctl { #define SCTPCTL_MOBILITY_BASE_DESC "Enable SCTP base mobility" #define SCTPCTL_MOBILITY_BASE_MIN 0 #define SCTPCTL_MOBILITY_BASE_MAX 1 -#define SCTPCTL_MOBILITY_BASE_DEFAULT SCTP_DEFAULT_MOBILITY_BASE +#define SCTPCTL_MOBILITY_BASE_DEFAULT 0 /* mobility_fasthandoff: Enable SCTP fast handoff support */ #define SCTPCTL_MOBILITY_FASTHANDOFF_DESC "Enable SCTP fast handoff" #define SCTPCTL_MOBILITY_FASTHANDOFF_MIN 0 #define SCTPCTL_MOBILITY_FASTHANDOFF_MAX 1 -#define SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT SCTP_DEFAULT_MOBILITY_FASTHANDOFF +#define SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT 0 /* Enable SCTP/UDP tunneling port */ #define SCTPCTL_UDP_TUNNELING_PORT_DESC "Set the SCTP/UDP tunneling port" diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index da22c1fbb089..e1fa35194ba8 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1188,7 +1188,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, if (ipv4_addr_legal) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&sctp_ifa->address.sa; + sin = &sctp_ifa->address.sin; if (sin->sin_addr.s_addr == 0) { /* * we skip @@ -1233,7 +1233,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp, if (ipv6_addr_legal) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa; + sin6 = &sctp_ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { /* * we skip @@ -4208,12 +4208,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, uint32_t i; SCTP_CHECK_AND_CAST(shmac, optval, struct sctp_hmacalgo, optsize); - if (optsize < sizeof(struct sctp_hmacalgo) + shmac->shmac_number_of_idents * sizeof(uint16_t)) { + if ((optsize < sizeof(struct sctp_hmacalgo) + shmac->shmac_number_of_idents * sizeof(uint16_t)) || + (shmac->shmac_number_of_idents > 0xffff)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; } - hmaclist = sctp_alloc_hmaclist(shmac->shmac_number_of_idents); + hmaclist = sctp_alloc_hmaclist((uint16_t) shmac->shmac_number_of_idents); if (hmaclist == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM); error = ENOMEM; @@ -6922,7 +6923,7 @@ sctp_ingetaddr(struct socket *so, struct sockaddr **addr) if (laddr->ifa->address.sa.sa_family == AF_INET) { struct sockaddr_in *sin_a; - sin_a = (struct sockaddr_in *)&laddr->ifa->address.sa; + sin_a = &laddr->ifa->address.sin; sin->sin_addr = sin_a->sin_addr; fnd = 1; break; diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 6bb1001268c0..fde23efc5572 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -2403,8 +2403,8 @@ sctp_calculate_rto(struct sctp_tcb *stcb, net->rtt = (uint64_t) 1000000 *(uint64_t) now.tv_sec + (uint64_t) now.tv_usec; - /* computer rtt in ms */ - rtt = net->rtt / 1000; + /* compute rtt in ms */ + rtt = (int32_t) (net->rtt / 1000); if ((asoc->cc_functions.sctp_rtt_calculated) && (rtt_from_sack == SCTP_RTT_FROM_DATA)) { /* * Tell the CC module that a new update has just occurred @@ -6710,7 +6710,7 @@ sctp_local_addr_count(struct sctp_tcb *stcb) if (ipv4_addr_legal) { struct sockaddr_in *sin; - sin = (struct sockaddr_in *)&sctp_ifa->address.sa; + sin = &sctp_ifa->address.sin; if (sin->sin_addr.s_addr == 0) { /* * skip unspecified @@ -6738,7 +6738,7 @@ sctp_local_addr_count(struct sctp_tcb *stcb) if (ipv6_addr_legal) { struct sockaddr_in6 *sin6; - sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa; + sin6 = &sctp_ifa->address.sin6; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { continue; } diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index d53323529890..a215325155f2 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -295,6 +295,7 @@ tcp_hc_lookup(struct in_conninfo *inc) */ TAILQ_FOREACH(hc_entry, &hc_head->hch_bucket, rmx_q) { if (inc->inc_flags & INC_ISIPV6) { + /* XXX: check ip6_zoneid */ if (memcmp(&inc->inc6_faddr, &hc_entry->ip6, sizeof(inc->inc6_faddr)) == 0) return hc_entry; @@ -386,9 +387,10 @@ tcp_hc_insert(struct in_conninfo *inc) * Initialize basic information of hostcache entry. */ bzero(hc_entry, sizeof(*hc_entry)); - if (inc->inc_flags & INC_ISIPV6) - bcopy(&inc->inc6_faddr, &hc_entry->ip6, sizeof(hc_entry->ip6)); - else + if (inc->inc_flags & INC_ISIPV6) { + hc_entry->ip6 = inc->inc6_faddr; + hc_entry->ip6_zoneid = inc->inc6_zoneid; + } else hc_entry->ip4 = inc->inc_faddr; hc_entry->rmx_head = hc_head; hc_entry->rmx_expire = V_tcp_hostcache.expire; diff --git a/sys/netinet/tcp_hostcache.h b/sys/netinet/tcp_hostcache.h index 8569edccec25..05aea125f3fb 100644 --- a/sys/netinet/tcp_hostcache.h +++ b/sys/netinet/tcp_hostcache.h @@ -51,6 +51,7 @@ struct hc_metrics { struct hc_head *rmx_head; /* head of bucket tail queue */ struct in_addr ip4; /* IP address */ struct in6_addr ip6; /* IP6 address */ + uint32_t ip6_zoneid; /* IPv6 scope zone id */ /* endpoint specific values for tcp */ u_long rmx_mtu; /* MTU for this path */ u_long rmx_ssthresh; /* outbound gateway buffer limit */ diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1be94340b035..e338b1ee573a 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -186,11 +186,17 @@ SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_RW, &VNET_NAME(tcp_ecn_maxretries), 0, "Max retries before giving up on ECN"); +VNET_DEFINE(int, tcp_insecure_syn) = 0; +#define V_tcp_insecure_syn VNET(tcp_insecure_syn) +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, insecure_syn, CTLFLAG_RW, + &VNET_NAME(tcp_insecure_syn), 0, + "Follow RFC793 instead of RFC5961 criteria for accepting SYN packets"); + VNET_DEFINE(int, tcp_insecure_rst) = 0; #define V_tcp_insecure_rst VNET(tcp_insecure_rst) SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_RW, &VNET_NAME(tcp_insecure_rst), 0, - "Follow the old (insecure) criteria for accepting RST packets"); + "Follow RFC793 instead of RFC5961 criteria for accepting RST packets"); VNET_DEFINE(int, tcp_recvspace) = 1024*64; #define V_tcp_recvspace VNET(tcp_recvspace) @@ -2044,102 +2050,87 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, * Then check that at least some bytes of segment are within * receive window. If segment begins before rcv_nxt, * drop leading data (and SYN); if nothing left, just ack. - * - * - * If the RST bit is set, check the sequence number to see - * if this is a valid reset segment. - * RFC 793 page 37: - * In all states except SYN-SENT, all reset (RST) segments - * are validated by checking their SEQ-fields. A reset is - * valid if its sequence number is in the window. - * Note: this does not take into account delayed ACKs, so - * we should test against last_ack_sent instead of rcv_nxt. - * The sequence number in the reset segment is normally an - * echo of our outgoing acknowlegement numbers, but some hosts - * send a reset with the sequence number at the rightmost edge - * of our receive window, and we have to handle this case. - * Note 2: Paul Watson's paper "Slipping in the Window" has shown - * that brute force RST attacks are possible. To combat this, - * we use a much stricter check while in the ESTABLISHED state, - * only accepting RSTs where the sequence number is equal to - * last_ack_sent. In all other states (the states in which a - * RST is more likely), the more permissive check is used. - * If we have multiple segments in flight, the initial reset - * segment sequence numbers will be to the left of last_ack_sent, - * but they will eventually catch up. - * In any case, it never made sense to trim reset segments to - * fit the receive window since RFC 1122 says: - * 4.2.2.12 RST Segment: RFC-793 Section 3.4 - * - * A TCP SHOULD allow a received RST segment to include data. - * - * DISCUSSION - * It has been suggested that a RST segment could contain - * ASCII text that encoded and explained the cause of the - * RST. No standard has yet been established for such - * data. - * - * If the reset segment passes the sequence number test examine - * the state: - * SYN_RECEIVED STATE: - * If passive open, return to LISTEN state. - * If active open, inform user that connection was refused. - * ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, CLOSE_WAIT STATES: - * Inform user that connection was reset, and close tcb. - * CLOSING, LAST_ACK STATES: - * Close the tcb. - * TIME_WAIT STATE: - * Drop the segment - see Stevens, vol. 2, p. 964 and - * RFC 1337. */ if (thflags & TH_RST) { - if (SEQ_GEQ(th->th_seq, tp->last_ack_sent - 1) && - SEQ_LEQ(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) { - switch (tp->t_state) { + /* + * RFC5961 Section 3.2 + * + * - RST drops connection only if SEG.SEQ == RCV.NXT. + * - If RST is in window, we send challenge ACK. + * + * Note: to take into account delayed ACKs, we should + * test against last_ack_sent instead of rcv_nxt. + * Note 2: we handle special case of closed window, not + * covered by the RFC. + */ + if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) && + SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) || + (tp->rcv_wnd == 0 && tp->last_ack_sent == th->th_seq)) { - case TCPS_SYN_RECEIVED: - so->so_error = ECONNREFUSED; - goto close; + INP_INFO_WLOCK_ASSERT(&V_tcbinfo); + KASSERT(ti_locked == TI_WLOCKED, + ("%s: TH_RST ti_locked %d, th %p tp %p", + __func__, ti_locked, th, tp)); + KASSERT(tp->t_state != TCPS_SYN_SENT, + ("%s: TH_RST for TCPS_SYN_SENT th %p tp %p", + __func__, th, tp)); - case TCPS_ESTABLISHED: - if (V_tcp_insecure_rst == 0 && - !(SEQ_GEQ(th->th_seq, tp->rcv_nxt - 1) && - SEQ_LEQ(th->th_seq, tp->rcv_nxt + 1)) && - !(SEQ_GEQ(th->th_seq, tp->last_ack_sent - 1) && - SEQ_LEQ(th->th_seq, tp->last_ack_sent + 1))) { - TCPSTAT_INC(tcps_badrst); - goto drop; - } - /* FALLTHROUGH */ - case TCPS_FIN_WAIT_1: - case TCPS_FIN_WAIT_2: - case TCPS_CLOSE_WAIT: - so->so_error = ECONNRESET; - close: - KASSERT(ti_locked == TI_WLOCKED, - ("tcp_do_segment: TH_RST 1 ti_locked %d", - ti_locked)); - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); - - tcp_state_change(tp, TCPS_CLOSED); + if (V_tcp_insecure_rst || + tp->last_ack_sent == th->th_seq) { TCPSTAT_INC(tcps_drops); - tp = tcp_close(tp); - break; - - case TCPS_CLOSING: - case TCPS_LAST_ACK: - KASSERT(ti_locked == TI_WLOCKED, - ("tcp_do_segment: TH_RST 2 ti_locked %d", - ti_locked)); - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); - - tp = tcp_close(tp); - break; + /* Drop the connection. */ + switch (tp->t_state) { + case TCPS_SYN_RECEIVED: + so->so_error = ECONNREFUSED; + goto close; + case TCPS_ESTABLISHED: + case TCPS_FIN_WAIT_1: + case TCPS_FIN_WAIT_2: + case TCPS_CLOSE_WAIT: + so->so_error = ECONNRESET; + close: + tcp_state_change(tp, TCPS_CLOSED); + /* FALLTHROUGH */ + default: + tp = tcp_close(tp); + } + } else { + TCPSTAT_INC(tcps_badrst); + /* Send challenge ACK. */ + tcp_respond(tp, mtod(m, void *), th, m, + tp->rcv_nxt, tp->snd_nxt, TH_ACK); + tp->last_ack_sent = tp->rcv_nxt; + m = NULL; } } goto drop; } + /* + * RFC5961 Section 4.2 + * Send challenge ACK for any SYN in synchronized state. + */ + if ((thflags & TH_SYN) && tp->t_state != TCPS_SYN_SENT) { + KASSERT(ti_locked == TI_WLOCKED, + ("tcp_do_segment: TH_SYN ti_locked %d", ti_locked)); + INP_INFO_WLOCK_ASSERT(&V_tcbinfo); + + TCPSTAT_INC(tcps_badsyn); + if (V_tcp_insecure_syn && + SEQ_GEQ(th->th_seq, tp->last_ack_sent) && + SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) { + tp = tcp_drop(tp, ECONNRESET); + rstreason = BANDLIM_UNLIMITED; + } else { + /* Send challenge ACK. */ + tcp_respond(tp, mtod(m, void *), th, m, tp->rcv_nxt, + tp->snd_nxt, TH_ACK); + tp->last_ack_sent = tp->rcv_nxt; + m = NULL; + } + goto drop; + } + /* * RFC 1323 PAWS: If we have a timestamp reply on this segment * and it's less than ts_recent, drop it. @@ -2185,11 +2176,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, todrop = tp->rcv_nxt - th->th_seq; if (todrop > 0) { - /* - * If this is a duplicate SYN for our current connection, - * advance over it and pretend and it's not a SYN. - */ - if (thflags & TH_SYN && th->th_seq == tp->irs) { + if (thflags & TH_SYN) { thflags &= ~TH_SYN; th->th_seq++; if (th->th_urp > 1) @@ -2310,20 +2297,6 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tp->ts_recent = to.to_tsval; } - /* - * If a SYN is in the window, then this is an - * error and we send an RST and drop the connection. - */ - if (thflags & TH_SYN) { - KASSERT(ti_locked == TI_WLOCKED, - ("tcp_do_segment: TH_SYN ti_locked %d", ti_locked)); - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); - - tp = tcp_drop(tp, ECONNRESET); - rstreason = BANDLIM_UNLIMITED; - goto drop; - } - /* * If the ACK bit is off: if in SYN-RECEIVED state or SENDSYN * flag is on (half-synchronized state), then queue data for @@ -3618,6 +3591,8 @@ tcp_mss(struct tcpcb *tp, int offer) if (cap.ifcap & CSUM_TSO) { tp->t_flags |= TF_TSO; tp->t_tsomax = cap.tsomax; + tp->t_tsomaxsegcount = cap.tsomaxsegcount; + tp->t_tsomaxsegsize = cap.tsomaxsegsize; } } diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 12d8e754ab5b..069776754432 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -767,28 +767,113 @@ tcp_output(struct tcpcb *tp) flags &= ~TH_FIN; if (tso) { + u_int if_hw_tsomax; + u_int if_hw_tsomaxsegcount; + u_int if_hw_tsomaxsegsize; + struct mbuf *mb; + u_int moff; + int max_len; + + /* extract TSO information */ + if_hw_tsomax = tp->t_tsomax; + if_hw_tsomaxsegcount = tp->t_tsomaxsegcount; + if_hw_tsomaxsegsize = tp->t_tsomaxsegsize; + + /* + * Limit a TSO burst to prevent it from + * overflowing or exceeding the maximum length + * allowed by the network interface: + */ KASSERT(ipoptlen == 0, ("%s: TSO can't do IP options", __func__)); /* - * Limit a burst to t_tsomax minus IP, - * TCP and options length to keep ip->ip_len - * from overflowing or exceeding the maximum - * length allowed by the network interface. + * Check if we should limit by maximum payload + * length: */ - if (len > tp->t_tsomax - hdrlen) { - len = tp->t_tsomax - hdrlen; - sendalot = 1; + if (if_hw_tsomax != 0) { + /* compute maximum TSO length */ + max_len = (if_hw_tsomax - hdrlen); + if (max_len <= 0) { + len = 0; + } else if (len > (u_int)max_len) { + sendalot = 1; + len = (u_int)max_len; + } + } + + /* + * Check if we should limit by maximum segment + * size and count: + */ + if (if_hw_tsomaxsegcount != 0 && if_hw_tsomaxsegsize != 0) { + max_len = 0; + mb = sbsndmbuf(&so->so_snd, off, &moff); + + while (mb != NULL && (u_int)max_len < len) { + u_int cur_length; + u_int cur_frags; + + /* + * Get length of mbuf fragment + * and how many hardware + * frags, rounded up, it would + * use: + */ + cur_length = (mb->m_len - moff); + cur_frags = (cur_length + if_hw_tsomaxsegsize - + 1) / if_hw_tsomaxsegsize; + + /* Handle special case: Zero Length Mbuf */ + if (cur_frags == 0) + cur_frags = 1; + + /* + * Check if the fragment limit + * will be reached or + * exceeded: + */ + if (cur_frags >= if_hw_tsomaxsegcount) { + max_len += min(cur_length, + if_hw_tsomaxsegcount * + if_hw_tsomaxsegsize); + break; + } + max_len += cur_length; + if_hw_tsomaxsegcount -= cur_frags; + moff = 0; + mb = mb->m_next; + } + if (max_len <= 0) { + len = 0; + } else if (len > (u_int)max_len) { + sendalot = 1; + len = (u_int)max_len; + } } /* * Prevent the last segment from being - * fractional unless the send sockbuf can - * be emptied. + * fractional unless the send sockbuf can be + * emptied: */ - if (sendalot && off + len < so->so_snd.sb_cc) { - len -= len % (tp->t_maxopd - optlen); + max_len = (tp->t_maxopd - optlen); + if ((off + len) < so->so_snd.sb_cc) { + moff = len % (u_int)max_len; + if (moff != 0) { + len -= moff; + sendalot = 1; + } + } + + /* + * In case there are too many small fragments + * don't use TSO: + */ + if (len <= (u_int)max_len) { + len = (u_int)max_len; sendalot = 1; + tso = 0; } /* diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index b8b08cf72425..65346f10010d 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1819,6 +1819,8 @@ tcp_maxmtu(struct in_conninfo *inc, struct tcp_ifcap *cap) ifp->if_hwassist & CSUM_TSO) { cap->ifcap |= CSUM_TSO; cap->tsomax = ifp->if_hw_tsomax; + cap->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; + cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; } } RTFREE(sro.ro_rt); @@ -1858,6 +1860,8 @@ tcp_maxmtu6(struct in_conninfo *inc, struct tcp_ifcap *cap) ifp->if_hwassist & CSUM_TSO) { cap->ifcap |= CSUM_TSO; cap->tsomax = ifp->if_hw_tsomax; + cap->tsomaxsegcount = ifp->if_hw_tsomaxsegcount; + cap->tsomaxsegsize = ifp->if_hw_tsomaxsegsize; } } RTFREE(sro6.ro_rt); @@ -1924,55 +1928,20 @@ tcp_signature_apply(void *fstate, void *data, u_int len) } /* - * Compute TCP-MD5 hash of a TCP segment. (RFC2385) - * - * Parameters: - * m pointer to head of mbuf chain - * _unused - * len length of TCP segment data, excluding options - * optlen length of TCP segment options - * buf pointer to storage for computed MD5 digest - * direction direction of flow (IPSEC_DIR_INBOUND or OUTBOUND) - * - * We do this over ip, tcphdr, segment data, and the key in the SADB. - * When called from tcp_input(), we can be sure that th_sum has been - * zeroed out and verified already. - * - * Return 0 if successful, otherwise return -1. - * * XXX The key is retrieved from the system's PF_KEY SADB, by keying a * search with the destination IP address, and a 'magic SPI' to be * determined by the application. This is hardcoded elsewhere to 1179 - * right now. Another branch of this code exists which uses the SPD to - * specify per-application flows but it is unstable. - */ -int -tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, - u_char *buf, u_int direction) +*/ +struct secasvar * +tcp_get_sav(struct mbuf *m, u_int direction) { union sockaddr_union dst; -#ifdef INET - struct ippseudo ippseudo; -#endif - MD5_CTX ctx; - int doff; - struct ip *ip; -#ifdef INET - struct ipovly *ipovly; -#endif struct secasvar *sav; - struct tcphdr *th; + struct ip *ip; #ifdef INET6 struct ip6_hdr *ip6; - struct in6_addr in6; char ip6buf[INET6_ADDRSTRLEN]; - uint32_t plen; - uint16_t nhdr; #endif - u_short savecsum; - - KASSERT(m != NULL, ("NULL mbuf chain")); - KASSERT(buf != NULL, ("NULL signature pointer")); /* Extract the destination from the IP header in the mbuf. */ bzero(&dst, sizeof(union sockaddr_union)); @@ -1999,7 +1968,7 @@ tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, break; #endif default: - return (EINVAL); + return (NULL); /* NOTREACHED */ break; } @@ -2014,9 +1983,61 @@ tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, ip6_sprintf(ip6buf, &dst.sin6.sin6_addr) : #endif "(unsupported)")); - return (EINVAL); } + return (sav); +} + +/* + * Compute TCP-MD5 hash of a TCP segment. (RFC2385) + * + * Parameters: + * m pointer to head of mbuf chain + * len length of TCP segment data, excluding options + * optlen length of TCP segment options + * buf pointer to storage for computed MD5 digest + * sav pointer to security assosiation + * + * We do this over ip, tcphdr, segment data, and the key in the SADB. + * When called from tcp_input(), we can be sure that th_sum has been + * zeroed out and verified already. + * + * Releases reference to SADB key before return. + * + * Return 0 if successful, otherwise return -1. + * + */ +int +tcp_signature_do_compute(struct mbuf *m, int len, int optlen, + u_char *buf, struct secasvar *sav) +{ +#ifdef INET + struct ippseudo ippseudo; +#endif + MD5_CTX ctx; + int doff; + struct ip *ip; +#ifdef INET + struct ipovly *ipovly; +#endif + struct tcphdr *th; +#ifdef INET6 + struct ip6_hdr *ip6; + struct in6_addr in6; + uint32_t plen; + uint16_t nhdr; +#endif + u_short savecsum; + + KASSERT(m != NULL, ("NULL mbuf chain")); + KASSERT(buf != NULL, ("NULL signature pointer")); + + /* Extract the destination from the IP header in the mbuf. */ + ip = mtod(m, struct ip *); +#ifdef INET6 + ip6 = NULL; /* Make the compiler happy. */ +#endif + MD5Init(&ctx); /* * Step 1: Update MD5 hash with IP(v6) pseudo-header. @@ -2073,7 +2094,7 @@ tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, break; #endif default: - return (EINVAL); + return (-1); /* NOTREACHED */ break; } @@ -2106,6 +2127,23 @@ tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, return (0); } +/* + * Compute TCP-MD5 hash of a TCP segment. (RFC2385) + * + * Return 0 if successful, otherwise return -1. + */ +int +tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, + u_char *buf, u_int direction) +{ + struct secasvar *sav; + + if ((sav = tcp_get_sav(m, direction)) == NULL) + return (-1); + + return (tcp_signature_do_compute(m, len, optlen, buf, sav)); +} + /* * Verify the TCP-MD5 hash of a TCP segment. (RFC2385) * diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 55a504460e6d..17f85ed38434 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -122,7 +122,7 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, syncookies_only, CTLFLAG_RW, static void syncache_drop(struct syncache *, struct syncache_head *); static void syncache_free(struct syncache *); static void syncache_insert(struct syncache *, struct syncache_head *); -static int syncache_respond(struct syncache *); +static int syncache_respond(struct syncache *, struct syncache_head *, int); static struct socket *syncache_socket(struct syncache *, struct socket *, struct mbuf *m); static void syncache_timeout(struct syncache *sc, struct syncache_head *sch, @@ -467,7 +467,7 @@ syncache_timer(void *xsch) free(s, M_TCPLOG); } - (void) syncache_respond(sc); + syncache_respond(sc, sch, 1); TCPSTAT_INC(tcps_sc_retransmitted); syncache_timeout(sc, sch, 0); } @@ -1213,7 +1213,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, s, __func__); free(s, M_TCPLOG); } - if (syncache_respond(sc) == 0) { + if (syncache_respond(sc, sch, 1) == 0) { sc->sc_rxmits = 0; syncache_timeout(sc, sch, 1); TCPSTAT_INC(tcps_sndacks); @@ -1325,11 +1325,9 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, } #ifdef TCP_SIGNATURE /* - * If listening socket requested TCP digests, and received SYN + * If listening socket requested TCP digests, OR received SYN * contains the option, flag this in the syncache so that * syncache_respond() will do the right thing with the SYN+ACK. - * XXX: Currently we always record the option by default and will - * attempt to use it in syncache_respond(). */ if (to->to_flags & TOF_SIGNATURE || ltflags & TF_SIGNATURE) sc->sc_flags |= SCF_SIGNATURE; @@ -1359,7 +1357,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, /* * Do a standard 3-way handshake. */ - if (syncache_respond(sc) == 0) { + if (syncache_respond(sc, sch, 0) == 0) { if (V_tcp_syncookies && V_tcp_syncookiesonly && sc != &scs) syncache_free(sc); else if (sc != &scs) @@ -1387,7 +1385,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, } static int -syncache_respond(struct syncache *sc) +syncache_respond(struct syncache *sc, struct syncache_head *sch, int locked) { struct ip *ip = NULL; struct mbuf *m; @@ -1398,6 +1396,9 @@ syncache_respond(struct syncache *sc) #ifdef INET6 struct ip6_hdr *ip6 = NULL; #endif +#ifdef TCP_SIGNATURE + struct secasvar *sav; +#endif hlen = #ifdef INET6 @@ -1508,8 +1509,29 @@ syncache_respond(struct syncache *sc) if (sc->sc_flags & SCF_SACK) to.to_flags |= TOF_SACKPERM; #ifdef TCP_SIGNATURE - if (sc->sc_flags & SCF_SIGNATURE) - to.to_flags |= TOF_SIGNATURE; + sav = NULL; + if (sc->sc_flags & SCF_SIGNATURE) { + sav = tcp_get_sav(m, IPSEC_DIR_OUTBOUND); + if (sav != NULL) + to.to_flags |= TOF_SIGNATURE; + else { + + /* + * We've got SCF_SIGNATURE flag + * inherited from listening socket, + * but to SADB key for given source + * address. Assume signature is not + * required and remove signature flag + * instead of silently dropping + * connection. + */ + if (locked == 0) + SCH_LOCK(sch); + sc->sc_flags &= ~SCF_SIGNATURE; + if (locked == 0) + SCH_UNLOCK(sch); + } + } #endif optlen = tcp_addoptions(&to, (u_char *)(th + 1)); @@ -1520,8 +1542,8 @@ syncache_respond(struct syncache *sc) #ifdef TCP_SIGNATURE if (sc->sc_flags & SCF_SIGNATURE) - tcp_signature_compute(m, 0, 0, optlen, - to.to_signature, IPSEC_DIR_OUTBOUND); + tcp_signature_do_compute(m, 0, optlen, + to.to_signature, sav); #endif #ifdef INET6 if (sc->sc_inc.inc_flags & INC_ISIPV6) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 42c1e1d6ccd6..22a160ca2b28 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1160,10 +1160,7 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) static int tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) { - struct inpcb *inp = tp->t_inpcb, *oinp; - struct socket *so = inp->inp_socket; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; - struct in6_addr addr6; + struct inpcb *inp = tp->t_inpcb; int error; INP_WLOCK_ASSERT(inp); @@ -1174,39 +1171,9 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) if (error) goto out; } - - /* - * Cannot simply call in_pcbconnect, because there might be an - * earlier incarnation of this same connection still in - * TIME_WAIT state, creating an ADDRINUSE error. - * in6_pcbladdr() also handles scope zone IDs. - * - * XXXRW: We wouldn't need to expose in6_pcblookup_hash_locked() - * outside of in6_pcb.c if there were an in6_pcbconnect_setup(). - */ - error = in6_pcbladdr(inp, nam, &addr6); - if (error) + error = in6_pcbconnect(inp, nam, td->td_ucred); + if (error != 0) goto out; - oinp = in6_pcblookup_hash_locked(inp->inp_pcbinfo, - &sin6->sin6_addr, sin6->sin6_port, - IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) - ? &addr6 - : &inp->in6p_laddr, - inp->inp_lport, 0, NULL); - if (oinp) { - error = EADDRINUSE; - goto out; - } - if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) - inp->in6p_laddr = addr6; - inp->in6p_faddr = sin6->sin6_addr; - inp->inp_fport = sin6->sin6_port; - /* update flowinfo - draft-itojun-ipv6-flowlabel-api-00 */ - inp->inp_flow &= ~IPV6_FLOWLABEL_MASK; - if (inp->inp_flags & IN6P_AUTOFLOWLABEL) - inp->inp_flow |= - (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); - in_pcbrehash(inp); INP_HASH_WUNLOCK(&V_tcbinfo); /* Compute window scaling to request. */ @@ -1214,7 +1181,7 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) (TCP_MAXWIN << tp->request_r_scale) < sb_max) tp->request_r_scale++; - soisconnecting(so); + soisconnecting(inp->inp_socket); TCPSTAT_INC(tcps_connattempt); tcp_state_change(tp, TCPS_SYN_SENT); tp->iss = tcp_new_isn(tp); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 5163f6e7177c..ac87f888169b 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -199,9 +199,12 @@ struct tcpcb { u_int t_keepintvl; /* interval between keepalives */ u_int t_keepcnt; /* number of keepalives before close */ - u_int t_tsomax; /* tso burst length limit */ + u_int t_tsomax; /* TSO total burst length limit in bytes */ + + uint32_t t_ispare[6]; /* 5 UTO, 1 TBD */ + uint32_t t_tsomaxsegcount; /* TSO maximum segment count */ + uint32_t t_tsomaxsegsize; /* TSO maximum segment size in bytes */ - uint32_t t_ispare[8]; /* 5 UTO, 3 TBD */ void *t_pspare2[4]; /* 1 TCP_SIGNATURE, 3 TBD */ uint64_t _pad[6]; /* 6 TBD (1-2 CC/RTT?) */ }; @@ -324,6 +327,8 @@ struct hc_metrics_lite { /* must stay in sync with hc_metrics */ struct tcp_ifcap { int ifcap; u_int tsomax; + u_int tsomaxsegcount; + u_int tsomaxsegsize; }; #ifndef _NETINET_IN_PCB_H_ @@ -680,9 +685,15 @@ int tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *, struct mbuf *, int); void tcp_setpersist(struct tcpcb *); #ifdef TCP_SIGNATURE +struct secasvar; +struct secasvar *tcp_get_sav(struct mbuf *, u_int); +int tcp_signature_do_compute(struct mbuf *, int, int, u_char *, + struct secasvar *); int tcp_signature_compute(struct mbuf *, int, int, int, u_char *, u_int); int tcp_signature_verify(struct mbuf *, int, int, int, struct tcpopt *, struct tcphdr *, u_int); +int tcp_signature_check(struct mbuf *m, int off0, int tlen, int optlen, + struct tcpopt *to, struct tcphdr *th, u_int tcpbflag); #endif void tcp_slowtimo(void); struct tcptemp * diff --git a/sys/netinet/toecore.c b/sys/netinet/toecore.c index 12f2c38e7ea0..1ab6c73c1ddb 100644 --- a/sys/netinet/toecore.c +++ b/sys/netinet/toecore.c @@ -329,7 +329,6 @@ toe_syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, { struct socket *lso = inp->inp_socket; - INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); syncache_add(inc, to, th, inp, &lso, NULL, tod, todctx); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 5860c579e749..92edcd196849 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" +#include "opt_rss.h" #include #include @@ -89,6 +90,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef IPSEC #include @@ -206,6 +208,13 @@ void udp_init(void) { + /* + * For now default to 2-tuple UDP hashing - until the fragment + * reassembly code can also update the flowid. + * + * Once we can calculate the flowid that way and re-establish + * a 4-tuple, flip this to 4-tuple. + */ in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE, "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE, IPI_HASHFIELDS_2TUPLE); @@ -435,9 +444,10 @@ udp_input(struct mbuf **mp, int *offp, int proto) */ len = ntohs((u_short)uh->uh_ulen); ip_len = ntohs(ip->ip_len) - iphlen; - if (proto == IPPROTO_UDPLITE && len == 0) { + if (proto == IPPROTO_UDPLITE && (len == 0 || len == ip_len)) { /* Zero means checksum over the complete packet. */ - len = ip_len; + if (len == 0) + len = ip_len; cscov_partial = 0; } if (ip_len != len) { @@ -488,8 +498,16 @@ udp_input(struct mbuf **mp, int *offp, int proto) m_freem(m); return (IPPROTO_DONE); } - } else - UDPSTAT_INC(udps_nosum); + } else { + if (proto == IPPROTO_UDP) { + UDPSTAT_INC(udps_nosum); + } else { + /* UDPLite requires a checksum */ + /* XXX: What is the right UDPLite MIB counter here? */ + m_freem(m); + return (IPPROTO_DONE); + } + } pcbinfo = get_inpcbinfo(proto); if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) || @@ -671,7 +689,7 @@ udp_input(struct mbuf **mp, int *offp, int proto) struct udpcb *up; up = intoudpcb(inp); - if (up->u_rxcslen > len) { + if (up->u_rxcslen == 0 || up->u_rxcslen > len) { INP_RUNLOCK(inp); m_freem(m); return (IPPROTO_DONE); @@ -1008,7 +1026,7 @@ udp_ctloutput(struct socket *so, struct sockopt *sopt) INP_WLOCK(inp); up = intoudpcb(inp); KASSERT(up != NULL, ("%s: up == NULL", __func__)); - if (optval != 0 && optval < 8) { + if ((optval != 0 && optval < 8) || (optval > 65535)) { INP_WUNLOCK(inp); error = EINVAL; break; @@ -1084,6 +1102,9 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, u_char tos; uint8_t pr; uint16_t cscov = 0; + uint32_t flowid = 0; + int flowid_type = 0; + int use_flowid = 0; /* * udp_output() may need to temporarily bind or connect the current @@ -1147,6 +1168,32 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, tos = *(u_char *)CMSG_DATA(cm); break; + case IP_FLOWID: + if (cm->cmsg_len != CMSG_LEN(sizeof(uint32_t))) { + error = EINVAL; + break; + } + flowid = *(uint32_t *) CMSG_DATA(cm); + break; + + case IP_FLOWTYPE: + if (cm->cmsg_len != CMSG_LEN(sizeof(uint32_t))) { + error = EINVAL; + break; + } + flowid_type = *(uint32_t *) CMSG_DATA(cm); + use_flowid = 1; + break; + +#ifdef RSS + case IP_RSSBUCKETID: + if (cm->cmsg_len != CMSG_LEN(sizeof(uint32_t))) { + error = EINVAL; + break; + } + /* This is just a placeholder for now */ + break; +#endif /* RSS */ default: error = ENOPROTOOPT; break; @@ -1395,6 +1442,59 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, ((struct ip *)ui)->ip_tos = tos; /* XXX */ UDPSTAT_INC(udps_opackets); + /* + * Setup flowid / RSS information for outbound socket. + * + * Once the UDP code decides to set a flowid some other way, + * this allows the flowid to be overridden by userland. + */ + if (use_flowid) { + m->m_flags |= M_FLOWID; + m->m_pkthdr.flowid = flowid; + M_HASHTYPE_SET(m, flowid_type); +#ifdef RSS + } else { + uint32_t hash_val, hash_type; + /* + * Calculate an appropriate RSS hash for UDP and + * UDP Lite. + * + * The called function will take care of figuring out + * whether a 2-tuple or 4-tuple hash is required based + * on the currently configured scheme. + * + * Later later on connected socket values should be + * cached in the inpcb and reused, rather than constantly + * re-calculating it. + * + * UDP Lite is a different protocol number and will + * likely end up being hashed as a 2-tuple until + * RSS / NICs grow UDP Lite protocol awareness. + */ + if (rss_proto_software_hash_v4(faddr, laddr, fport, lport, + pr, &hash_val, &hash_type) == 0) { + m->m_pkthdr.flowid = hash_val; + m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, hash_type); + } +#endif + } + +#ifdef RSS + /* + * Don't override with the inp cached flowid value. + * + * Depending upon the kind of send being done, the inp + * flowid/flowtype values may actually not be appropriate + * for this particular socket send. + * + * We should either leave the flowid at zero (which is what is + * currently done) or set it to some software generated + * hash value based on the packet contents. + */ + ipflags |= IP_NODEFAULTFLOWID; +#endif /* RSS */ + if (unlock_udbinfo == UH_WLOCKED) INP_HASH_WUNLOCK(pcbinfo); else if (unlock_udbinfo == UH_RLOCKED) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index a619318fad79..56f9aa199e90 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1714,6 +1714,29 @@ in6ifa_ifpforlinklocal(struct ifnet *ifp, int ignoreflags) } +/* + * find the internet address corresponding to a given address. + * ifaddr is returned referenced. + */ +struct in6_ifaddr * +in6ifa_ifwithaddr(const struct in6_addr *addr, uint32_t zoneid) +{ + struct in6_ifaddr *ia; + + IN6_IFADDR_RLOCK(); + LIST_FOREACH(ia, IN6ADDR_HASH(addr), ia6_hash) { + if (IN6_ARE_ADDR_EQUAL(IA6_IN6(ia), addr)) { + if (zoneid != 0 && + zoneid != ia->ia_addr.sin6_scope_id) + continue; + ifa_ref(&ia->ia_ifa); + break; + } + } + IN6_IFADDR_RUNLOCK(); + return (ia); +} + /* * find the internet address corresponding to a given interface and address. * ifaddr is returned referenced. diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 34daed8f46ec..5fbcf5f23d9f 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -647,9 +647,11 @@ struct ip6_hdr; int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t); int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t); +int in6_cksum_partial(struct mbuf *, u_int8_t, u_int32_t, u_int32_t, + u_int32_t); int in6_localaddr(struct in6_addr *); int in6_localip(struct in6_addr *); -int in6_addrscope(struct in6_addr *); +int in6_addrscope(const struct in6_addr *); struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *); extern void in6_if_up(struct ifnet *); struct sockaddr; diff --git a/sys/netinet6/in6_cksum.c b/sys/netinet6/in6_cksum.c index da8a2e6bf3c1..ce1961a60082 100644 --- a/sys/netinet6/in6_cksum.c +++ b/sys/netinet6/in6_cksum.c @@ -145,9 +145,11 @@ in6_cksum_pseudo(struct ip6_hdr *ip6, uint32_t len, uint8_t nxt, uint16_t csum) * off is an offset where TCP/UDP/ICMP6 header starts. * len is a total length of a transport segment. * (e.g. TCP header + TCP payload) + * cov is the number of bytes to be taken into account for the checksum */ int -in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) +in6_cksum_partial(struct mbuf *m, u_int8_t nxt, u_int32_t off, + u_int32_t len, u_int32_t cov) { struct ip6_hdr *ip6; u_int16_t *w, scope; @@ -215,9 +217,9 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) } w = (u_int16_t *)(mtod(m, u_char *) + off); mlen = m->m_len - off; - if (len < mlen) - mlen = len; - len -= mlen; + if (cov < mlen) + mlen = cov; + cov -= mlen; /* * Force to even boundary. */ @@ -273,7 +275,7 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) * Lastly calculate a summary of the rest of mbufs. */ - for (;m && len; m = m->m_next) { + for (;m && cov; m = m->m_next) { if (m->m_len == 0) continue; w = mtod(m, u_int16_t *); @@ -290,12 +292,12 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) sum += s_util.s; w = (u_int16_t *)((char *)w + 1); mlen = m->m_len - 1; - len--; + cov--; } else mlen = m->m_len; - if (len < mlen) - mlen = len; - len -= mlen; + if (cov < mlen) + mlen = cov; + cov -= mlen; /* * Force to even boundary. */ @@ -343,7 +345,7 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) } else if (mlen == -1) s_util.c[0] = *(char *)w; } - if (len) + if (cov) panic("in6_cksum: out of data"); if (mlen == -1) { /* The last mbuf has odd # of bytes. Follow the @@ -355,3 +357,9 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) REDUCE; return (~sum & 0xffff); } + +int +in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) +{ + return (in6_cksum_partial(m, nxt, off, len, len)); +} diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 65f7824f1006..2be2e8366af2 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -108,6 +108,9 @@ __FBSDID("$FreeBSD$"); #include #include +static struct inpcb *in6_pcblookup_hash_locked(struct inpcbinfo *, + struct in6_addr *, u_int, struct in6_addr *, u_int, int, struct ifnet *); + int in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) @@ -319,7 +322,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, * a bit of a kludge, but cleaning up the internal interfaces would * have forced minor changes in every protocol). */ -int +static int in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam, struct in6_addr *plocal_addr6) { @@ -709,8 +712,9 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr, * Look for an unconnected (wildcard foreign addr) PCB that * matches the local address and port we're looking for. */ - head = &pcbinfo->ipi_hashbase[INP_PCBHASH(INADDR_ANY, lport, - 0, pcbinfo->ipi_hashmask)]; + head = &pcbinfo->ipi_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(&in6addr_any), lport, 0, + pcbinfo->ipi_hashmask)]; LIST_FOREACH(inp, head, inp_hash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -878,9 +882,8 @@ in6_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, */ tmpinp = NULL; INP_GROUP_LOCK(pcbgroup); - head = &pcbgroup->ipg_hashbase[ - INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport, - pcbgroup->ipg_hashmask)]; + head = &pcbgroup->ipg_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(faddr), lport, fport, pcbgroup->ipg_hashmask)]; LIST_FOREACH(inp, head, inp_pcbgrouphash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -985,8 +988,9 @@ in6_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, * 3. non-jailed, non-wild. * 4. non-jailed, wild. */ - head = &pcbinfo->ipi_wildbase[INP_PCBHASH(INADDR_ANY, lport, - 0, pcbinfo->ipi_wildmask)]; + head = &pcbinfo->ipi_wildbase[INP_PCBHASH( + INP6_PCBHASHKEY(&in6addr_any), lport, 0, + pcbinfo->ipi_wildmask)]; LIST_FOREACH(inp, head, inp_pcbgroup_wild) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -1057,7 +1061,7 @@ in6_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, /* * Lookup PCB in hash list. */ -struct inpcb * +static struct inpcb * in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_int fport_arg, struct in6_addr *laddr, u_int lport_arg, int lookupflags, struct ifnet *ifp) @@ -1081,9 +1085,8 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, * First look for an exact match. */ tmpinp = NULL; - head = &pcbinfo->ipi_hashbase[ - INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport, - pcbinfo->ipi_hashmask)]; + head = &pcbinfo->ipi_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(faddr), lport, fport, pcbinfo->ipi_hashmask)]; LIST_FOREACH(inp, head, inp_hash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -1121,8 +1124,9 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, * 3. non-jailed, non-wild. * 4. non-jailed, wild. */ - head = &pcbinfo->ipi_hashbase[INP_PCBHASH(INADDR_ANY, lport, - 0, pcbinfo->ipi_hashmask)]; + head = &pcbinfo->ipi_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(&in6addr_any), lport, 0, + pcbinfo->ipi_hashmask)]; LIST_FOREACH(inp, head, inp_hash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) diff --git a/sys/netinet6/in6_pcb.h b/sys/netinet6/in6_pcb.h index 19d151b7d5d4..e758dacea3b8 100644 --- a/sys/netinet6/in6_pcb.h +++ b/sys/netinet6/in6_pcb.h @@ -86,7 +86,6 @@ int in6_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *); int in6_pcbconnect_mbuf(struct inpcb *, struct sockaddr *, struct ucred *, struct mbuf *); void in6_pcbdisconnect(struct inpcb *); -int in6_pcbladdr(struct inpcb *, struct sockaddr *, struct in6_addr *); struct inpcb * in6_pcblookup_local(struct inpcbinfo *, struct in6_addr *, u_short, int, @@ -95,10 +94,6 @@ struct inpcb * in6_pcblookup(struct inpcbinfo *, struct in6_addr *, u_int, struct in6_addr *, u_int, int, struct ifnet *); -struct inpcb * - in6_pcblookup_hash_locked(struct inpcbinfo *, struct in6_addr *, - u_int, struct in6_addr *, u_int, int, - struct ifnet *); struct inpcb * in6_pcblookup_mbuf(struct inpcbinfo *, struct in6_addr *, u_int, struct in6_addr *, u_int, int, diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c index 10e833a8ae58..c1caf2c721d6 100644 --- a/sys/netinet6/in6_rmx.c +++ b/sys/netinet6/in6_rmx.c @@ -270,10 +270,12 @@ in6_inithead(void **head, int off) if (!rn_inithead(head, offsetof(struct sockaddr_in6, sin6_addr) << 3)) return 0; /* See above */ + rnh = *head; + RADIX_NODE_HEAD_LOCK_INIT(rnh); + if (off == 0) /* See above */ return 1; /* only do the rest for the real thing */ - rnh = *head; rnh->rnh_addaddr = in6_addroute; if (V__in6_rt_was_here == 0) { diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 34fa0801354b..9e163da8a41d 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -451,6 +451,16 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, if (ifa_preferred(&ia->ia_ifa, &ia_best->ia_ifa)) NEXT(9); + /* + * Rule 10: prefer address with `prefer_source' flag. + */ + if ((ia_best->ia6_flags & IN6_IFF_PREFER_SOURCE) == 0 && + (ia->ia6_flags & IN6_IFF_PREFER_SOURCE) != 0) + REPLACE(10); + if ((ia_best->ia6_flags & IN6_IFF_PREFER_SOURCE) != 0 && + (ia->ia6_flags & IN6_IFF_PREFER_SOURCE) == 0) + NEXT(10); + /* * Rule 14: Use longest matching prefix. * Note: in the address selection draft, this rule is diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 70e3a94025ba..3fc7fee4fd79 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -498,6 +498,7 @@ struct in6_rrenumreq { */ #define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */ #define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */ +#define IN6_IFF_PREFER_SOURCE 0x0100 /* preferred address for SAS */ #define IN6_IFF_NOPFX 0x8000 /* skip kernel prefix management. * XXX: this should be temporary. */ @@ -525,7 +526,7 @@ VNET_DECLARE(u_long, in6_ifaddrhmask); (&V_in6_ifaddrhashtbl[IN6ADDR_HASHVAL(x) & V_in6_ifaddrhmask]) static __inline uint32_t -in6_addrhash(struct in6_addr *in6) +in6_addrhash(const struct in6_addr *in6) { uint32_t x; @@ -811,6 +812,7 @@ void in6_setmaxmtu(void); int in6_if2idlen(struct ifnet *); struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int); struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *); +struct in6_ifaddr *in6ifa_ifwithaddr(const struct in6_addr *, uint32_t); struct in6_ifaddr *in6ifa_llaonifp(struct ifnet *); char *ip6_sprintf(char *, const struct in6_addr *); int in6_addr2zoneid(struct ifnet *, struct in6_addr *, u_int32_t *); diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index fb8cedd779be..1b1b9d058b3a 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -422,8 +422,6 @@ ip6_forward(struct mbuf *m, int srcrt) if (mcopy) { u_long mtu; #ifdef IPSEC - struct secpolicy *sp; - int ipsecerror; size_t ipsechdrsiz; #endif /* IPSEC */ @@ -436,15 +434,10 @@ ip6_forward(struct mbuf *m, int srcrt) * case, as we have the outgoing interface for * encapsulated packet as "rt->rt_ifp". */ - sp = ipsec_getpolicybyaddr(mcopy, IPSEC_DIR_OUTBOUND, - IP_FORWARDING, &ipsecerror); - if (sp) { - ipsechdrsiz = ipsec_hdrsiz(mcopy, - IPSEC_DIR_OUTBOUND, NULL); - if (ipsechdrsiz < mtu) - mtu -= ipsechdrsiz; - } - + ipsechdrsiz = ipsec_hdrsiz(mcopy, IPSEC_DIR_OUTBOUND, + NULL); + if (ipsechdrsiz < mtu) + mtu -= ipsechdrsiz; /* * if mtu becomes less than minimum MTU, * tell minimum MTU (and I'll need to fragment it). diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 6f2e8927af5d..298a0d3bd078 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -227,6 +227,9 @@ in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset) * * ifpp - XXX: just for statistics */ +/* + * XXX TODO: no flowid is assigned for outbound flows? + */ int ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro, int flags, struct ip6_moptions *im6o, @@ -252,6 +255,8 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro_pmtu = NULL; int hdrsplit = 0; int sw_csum, tso; + int needfiblookup; + uint32_t fibnum; struct m_tag *fwd_tag = NULL; ip6 = mtod(m, struct ip6_hdr *); @@ -260,8 +265,14 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, goto bad; } - if (inp != NULL) + if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); + if (((flags & IP_NODEFAULTFLOWID) == 0) && + (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID))) { + m->m_pkthdr.flowid = inp->inp_flowid; + m->m_flags |= M_FLOWID; + } + } finaldst = ip6->ip6_dst; bzero(&exthdrs, sizeof(exthdrs)); @@ -439,6 +450,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, if (ro->ro_rt == NULL) (void )flowtable_lookup(AF_INET6, m, (struct route *)ro); #endif + fibnum = (inp != NULL) ? inp->inp_inc.inc_fibnum : M_GETFIB(m); again: /* * if specified, try to fill in the traffic class field. @@ -480,7 +492,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, dst_sa.sin6_addr = ip6->ip6_dst; } error = in6_selectroute_fib(&dst_sa, opt, im6o, ro, &ifp, - &rt, inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m)); + &rt, fibnum); if (error != 0) { if (ifp != NULL) in6_ifstat_inc(ifp, ifs6_out_discard); @@ -640,7 +652,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, /* Determine path MTU. */ if ((error = ip6_getpmtu(ro_pmtu, ro, ifp, &finaldst, &mtu, - &alwaysfrag, inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m))) != 0) + &alwaysfrag, fibnum)) != 0) goto bad; /* @@ -718,6 +730,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, goto done; ip6 = mtod(m, struct ip6_hdr *); + needfiblookup = 0; /* See if destination IP address was changed by packet filter. */ if (!IN6_ARE_ADDR_EQUAL(&odst, &ip6->ip6_dst)) { m->m_flags |= M_SKIP_FIREWALL; @@ -738,8 +751,17 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, error = netisr_queue(NETISR_IPV6, m); goto done; } else - goto again; /* Redo the routing table lookup. */ + needfiblookup = 1; /* Redo the routing table lookup. */ } + /* See if fib was changed by packet filter. */ + if (fibnum != M_GETFIB(m)) { + m->m_flags |= M_SKIP_FIREWALL; + fibnum = M_GETFIB(m); + RO_RTFREE(ro); + needfiblookup = 1; + } + if (needfiblookup) + goto again; /* See if local, if yes, send it to netisr. */ if (m->m_flags & M_FASTFWD_OURS) { @@ -2550,7 +2572,8 @@ ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt, sticky && !IN6_IS_ADDR_UNSPECIFIED(&pktinfo->ipi6_addr)) { return (EINVAL); } - + if (IN6_IS_ADDR_MULTICAST(&pktinfo->ipi6_addr)) + return (EINVAL); /* validate the interface index if specified. */ if (pktinfo->ipi6_ifindex > V_if_index) return (ENXIO); @@ -2559,7 +2582,19 @@ ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt, if (ifp == NULL) return (ENXIO); } + if (ifp != NULL && ( + ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) + return (ENETDOWN); + if (ifp != NULL && + !IN6_IS_ADDR_UNSPECIFIED(&pktinfo->ipi6_addr)) { + struct in6_ifaddr *ia; + + ia = in6ifa_ifpwithaddr(ifp, &pktinfo->ipi6_addr); + if (ia == NULL) + return (EADDRNOTAVAIL); + ifa_free(&ia->ia_ifa); + } /* * We store the address anyway, and let in6_selectsrc() * validate the specified address. This is because ipi6_addr diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 54366eecd948..e48cb8a7e5f5 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -945,7 +945,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) * If the address is assigned on the node of the other side of * a p2p interface, the address should be a neighbor. */ - dstaddr = ifa_ifwithdstaddr((struct sockaddr *)addr); + dstaddr = ifa_ifwithdstaddr((struct sockaddr *)addr, RT_ALL_FIBS); if (dstaddr != NULL) { if (dstaddr->ifa_ifp == ifp) { ifa_free(dstaddr); diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c index d0c665597a9f..63e925b99536 100644 --- a/sys/netinet6/scope6.c +++ b/sys/netinet6/scope6.c @@ -100,22 +100,14 @@ scope6_ifattach(struct ifnet *ifp) { struct scope6_id *sid; - sid = (struct scope6_id *)malloc(sizeof(*sid), M_IFADDR, M_WAITOK); - bzero(sid, sizeof(*sid)); - + sid = malloc(sizeof(*sid), M_IFADDR, M_WAITOK | M_ZERO); /* * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. * Should we rather hardcode here? */ sid->s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = ifp->if_index; sid->s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index; -#ifdef MULTI_SCOPE - /* by default, we don't care about scope boundary for these scopes. */ - sid->s6id_list[IPV6_ADDR_SCOPE_SITELOCAL] = 1; - sid->s6id_list[IPV6_ADDR_SCOPE_ORGLOCAL] = 1; -#endif - - return sid; + return (sid); } void @@ -235,62 +227,24 @@ scope6_get(struct ifnet *ifp, struct scope6_id *idlist) * Get a scope of the address. Node-local, link-local, site-local or global. */ int -in6_addrscope(struct in6_addr *addr) +in6_addrscope(const struct in6_addr *addr) { - int scope; - - if (addr->s6_addr[0] == 0xfe) { - scope = addr->s6_addr[1] & 0xc0; - - switch (scope) { - case 0x80: - return IPV6_ADDR_SCOPE_LINKLOCAL; - break; - case 0xc0: - return IPV6_ADDR_SCOPE_SITELOCAL; - break; - default: - return IPV6_ADDR_SCOPE_GLOBAL; /* just in case */ - break; - } - } - - - if (addr->s6_addr[0] == 0xff) { - scope = addr->s6_addr[1] & 0x0f; + if (IN6_IS_ADDR_MULTICAST(addr)) { /* - * due to other scope such as reserved, - * return scope doesn't work. + * Addresses with reserved value F must be treated as + * global multicast addresses. */ - switch (scope) { - case IPV6_ADDR_SCOPE_INTFACELOCAL: - return IPV6_ADDR_SCOPE_INTFACELOCAL; - break; - case IPV6_ADDR_SCOPE_LINKLOCAL: - return IPV6_ADDR_SCOPE_LINKLOCAL; - break; - case IPV6_ADDR_SCOPE_SITELOCAL: - return IPV6_ADDR_SCOPE_SITELOCAL; - break; - default: - return IPV6_ADDR_SCOPE_GLOBAL; - break; - } + if (IPV6_ADDR_MC_SCOPE(addr) == 0x0f) + return (IPV6_ADDR_SCOPE_GLOBAL); + return (IPV6_ADDR_MC_SCOPE(addr)); } - - /* - * Regard loopback and unspecified addresses as global, since - * they have no ambiguity. - */ - if (bcmp(&in6addr_loopback, addr, sizeof(*addr) - 1) == 0) { - if (addr->s6_addr[15] == 1) /* loopback */ - return IPV6_ADDR_SCOPE_LINKLOCAL; - if (addr->s6_addr[15] == 0) /* unspecified */ - return IPV6_ADDR_SCOPE_GLOBAL; /* XXX: correct? */ - } - - return IPV6_ADDR_SCOPE_GLOBAL; + if (IN6_IS_ADDR_LINKLOCAL(addr) || + IN6_IS_ADDR_LOOPBACK(addr)) + return (IPV6_ADDR_SCOPE_LINKLOCAL); + if (IN6_IS_ADDR_SITELOCAL(addr)) + return (IPV6_ADDR_SCOPE_SITELOCAL); + return (IPV6_ADDR_SCOPE_GLOBAL); } /* @@ -505,3 +459,77 @@ in6_getscope(struct in6_addr *in6) return (0); } + +/* + * Return pointer to ifnet structure, corresponding to the zone id of + * link-local scope. + */ +struct ifnet* +in6_getlinkifnet(uint32_t zoneid) +{ + + return (ifnet_byindex((u_short)zoneid)); +} + +/* + * Return zone id for the specified scope. + */ +uint32_t +in6_getscopezone(const struct ifnet *ifp, int scope) +{ + + if (scope == IPV6_ADDR_SCOPE_INTFACELOCAL || + scope == IPV6_ADDR_SCOPE_LINKLOCAL) + return (ifp->if_index); + if (scope >= 0 && scope < IPV6_ADDR_SCOPES_COUNT) + return (SID(ifp)->s6id_list[scope]); + return (0); +} + +/* + * This function is for checking sockaddr_in6 structure passed + * from the application level (usually). + * + * sin6_scope_id should be set for link-local unicast, link-local and + * interface-local multicast addresses. + * + * If it is zero, then look into default zone ids. If default zone id is + * not set or disabled, then return error. + */ +int +sa6_checkzone(struct sockaddr_in6 *sa6) +{ + int scope; + + scope = in6_addrscope(&sa6->sin6_addr); + if (scope == IPV6_ADDR_SCOPE_GLOBAL) + return (sa6->sin6_scope_id ? EINVAL: 0); + if (IN6_IS_ADDR_MULTICAST(&sa6->sin6_addr) && + scope != IPV6_ADDR_SCOPE_LINKLOCAL && + scope != IPV6_ADDR_SCOPE_INTFACELOCAL) { + if (sa6->sin6_scope_id == 0 && V_ip6_use_defzone != 0) + sa6->sin6_scope_id = V_sid_default.s6id_list[scope]; + return (0); + } + /* + * Since ::1 address always configured on the lo0, we can + * automatically set its zone id, when it is not specified. + * Return error, when specified zone id doesn't match with + * actual value. + */ + if (IN6_IS_ADDR_LOOPBACK(&sa6->sin6_addr)) { + if (sa6->sin6_scope_id == 0) + sa6->sin6_scope_id = in6_getscopezone(V_loif, scope); + else if (sa6->sin6_scope_id != in6_getscopezone(V_loif, scope)) + return (EADDRNOTAVAIL); + } + /* XXX: we can validate sin6_scope_id here */ + if (sa6->sin6_scope_id != 0) + return (0); + if (V_ip6_use_defzone != 0) + sa6->sin6_scope_id = V_sid_default.s6id_list[scope]; + /* Return error if we can't determine zone id */ + return (sa6->sin6_scope_id ? 0: EADDRNOTAVAIL); +} + + diff --git a/sys/netinet6/scope6_var.h b/sys/netinet6/scope6_var.h index 3398bbe6bd04..8a4b6fcf7754 100644 --- a/sys/netinet6/scope6_var.h +++ b/sys/netinet6/scope6_var.h @@ -36,12 +36,13 @@ #ifdef _KERNEL #include +#define IPV6_ADDR_SCOPES_COUNT 16 struct scope6_id { /* * 16 is correspondent to 4bit multicast scope field. * i.e. from node-local to global with some reserved/unassigned types. */ - u_int32_t s6id_list[16]; + uint32_t s6id_list[IPV6_ADDR_SCOPES_COUNT]; }; VNET_DECLARE(int, deembed_scopeid); @@ -56,9 +57,12 @@ int scope6_get_default(struct scope6_id *); u_int32_t scope6_addr2default(struct in6_addr *); int sa6_embedscope(struct sockaddr_in6 *, int); int sa6_recoverscope(struct sockaddr_in6 *); +int sa6_checkzone(struct sockaddr_in6 *); int in6_setscope(struct in6_addr *, struct ifnet *, u_int32_t *); int in6_clearscope(struct in6_addr *); uint16_t in6_getscope(struct in6_addr *); +uint32_t in6_getscopezone(const struct ifnet *, int); +struct ifnet* in6_getlinkifnet(uint32_t); #endif /* _KERNEL */ #endif /* _NETINET6_SCOPE6_VAR_H_ */ diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index 6c9f9ee1fc3e..a2393ec51202 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -844,7 +844,7 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) #ifdef INET struct in6pcb *inp6; struct sockaddr_in6 *sin6; - struct sockaddr_storage ss; + union sctp_sockstore store; #endif @@ -928,8 +928,8 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p) } if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { /* convert v4-mapped into v4 addr */ - in6_sin6_2_sin((struct sockaddr_in *)&ss, sin6); - addr = (struct sockaddr *)&ss; + in6_sin6_2_sin(&store.sin, sin6); + addr = &store.sa; } #endif /* INET */ /* Now do we connect? */ @@ -1057,7 +1057,7 @@ sctp6_getaddr(struct socket *so, struct sockaddr **addr) if (laddr->ifa->address.sa.sa_family == AF_INET6) { struct sockaddr_in6 *sin_a; - sin_a = (struct sockaddr_in6 *)&laddr->ifa->address.sin6; + sin_a = &laddr->ifa->address.sin6; sin6->sin6_addr = sin_a->sin6_addr; fnd = 1; break; diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 63afbef82ae8..e36f77896e59 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include "opt_ipfw.h" #include "opt_ipsec.h" +#include "opt_rss.h" #include #include @@ -111,6 +112,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -225,21 +227,26 @@ udp6_input(struct mbuf **mp, int *offp, int proto) nxt = ip6->ip6_nxt; cscov_partial = (nxt == IPPROTO_UDPLITE) ? 1 : 0; - if (nxt == IPPROTO_UDPLITE && ulen == 0) { + if (nxt == IPPROTO_UDPLITE) { /* Zero means checksum over the complete packet. */ - ulen = plen; - cscov_partial = 0; - } - if (plen != ulen) { - UDPSTAT_INC(udps_badlen); - goto badunlocked; - } - - /* - * Checksum extended UDP header and data. - */ - if (uh->uh_sum == 0) { - if (ulen > plen || ulen < sizeof(struct udphdr)) { + if (ulen == 0) + ulen = plen; + if (ulen == plen) + cscov_partial = 0; + if ((ulen < sizeof(struct udphdr)) || (ulen > plen)) { + /* XXX: What is the right UDPLite MIB counter? */ + goto badunlocked; + } + if (uh->uh_sum == 0) { + /* XXX: What is the right UDPLite MIB counter? */ + goto badunlocked; + } + } else { + if ((ulen < sizeof(struct udphdr)) || (plen != ulen)) { + UDPSTAT_INC(udps_badlen); + goto badunlocked; + } + if (uh->uh_sum == 0) { UDPSTAT_INC(udps_nosum); goto badunlocked; } @@ -254,11 +261,11 @@ udp6_input(struct mbuf **mp, int *offp, int proto) m->m_pkthdr.csum_data); uh_sum ^= 0xffff; } else - uh_sum = in6_cksum(m, nxt, off, ulen); + uh_sum = in6_cksum_partial(m, nxt, off, plen, ulen); if (uh_sum != 0) { UDPSTAT_INC(udps_badsum); - goto badunlocked; + /*goto badunlocked;*/ } /* @@ -478,7 +485,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto) INP_RLOCK_ASSERT(inp); up = intoudpcb(inp); if (cscov_partial) { - if (up->u_rxcslen > ulen) { + if (up->u_rxcslen == 0 || up->u_rxcslen > ulen) { INP_RUNLOCK(inp); m_freem(m); return (IPPROTO_DONE); @@ -841,8 +848,8 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, ip6->ip6_dst = *faddr; if (cscov_partial) { - if ((udp6->uh_sum = in6_cksum(m, 0, - sizeof(struct ip6_hdr), cscov)) == 0) + if ((udp6->uh_sum = in6_cksum_partial(m, nxt, + sizeof(struct ip6_hdr), plen, cscov)) == 0) udp6->uh_sum = 0xffff; } else { udp6->uh_sum = in6_cksum_pseudo(ip6, plen, nxt, 0); @@ -850,8 +857,30 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); } + /* + * XXX for now assume UDP is 2-tuple. + * Later on this may become configurable as 4-tuple; + * we should support that. + * + * XXX .. and we should likely cache this in the inpcb. + */ +#ifdef RSS + m->m_pkthdr.flowid = rss_hash_ip6_2tuple(*faddr, *laddr); + m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_RSS_IPV6); +#endif flags = 0; +#ifdef RSS + /* + * Don't override with the inp cached flowid. + * + * Until the whole UDP path is vetted, it may actually + * be incorrect. + */ + flags |= IP_NODEFAULTFLOWID; +#endif + UDP_PROBE(send, NULL, inp, ip6, inp, udp6); UDPSTAT_INC(udps_opackets); error = ip6_output(m, optp, NULL, flags, inp->in6p_moptions, diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c index 717ae9a805f7..b778fe5def23 100644 --- a/sys/netipsec/ipsec_input.c +++ b/sys/netipsec/ipsec_input.c @@ -376,8 +376,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, prot = ip->ip_p; #ifdef DEV_ENC - encif->if_ipackets++; - encif->if_ibytes += m->m_pkthdr.len; + if_inc_counter(encif, IFCOUNTER_IPACKETS, 1); + if_inc_counter(encif, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* * Pass the mbuf to enc0 for bpf and pfil. We will filter the IPIP @@ -391,7 +391,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, #endif /* DEV_ENC */ /* IP-in-IP encapsulation */ - if (prot == IPPROTO_IPIP) { + if (prot == IPPROTO_IPIP && + saidx->mode != IPSEC_MODE_TRANSPORT) { if (m->m_pkthdr.len - skip < sizeof(struct ip)) { IPSEC_ISTAT(sproto, hdrops); @@ -431,7 +432,8 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, } #ifdef INET6 /* IPv6-in-IP encapsulation. */ - if (prot == IPPROTO_IPV6) { + if (prot == IPPROTO_IPV6 && + saidx->mode != IPSEC_MODE_TRANSPORT) { if (m->m_pkthdr.len - skip < sizeof(struct ip6_hdr)) { IPSEC_ISTAT(sproto, hdrops); @@ -502,6 +504,12 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, key_sa_recordxfer(sav, m); /* record data transfer */ + /* + * In transport mode requeue decrypted mbuf back to IPv4 protocol + * handler. This is necessary to correctly expose rcvif. + */ + if (saidx->mode == IPSEC_MODE_TRANSPORT) + prot = IPPROTO_IPIP; #ifdef DEV_ENC /* * Pass the mbuf to enc0 for bpf and pfil. @@ -663,8 +671,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto m_copydata(m, protoff, 1, (unsigned char *) &prot); #ifdef DEV_ENC - encif->if_ipackets++; - encif->if_ibytes += m->m_pkthdr.len; + if_inc_counter(encif, IFCOUNTER_IPACKETS, 1); + if_inc_counter(encif, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* * Pass the mbuf to enc0 for bpf and pfil. We will filter the IPIP diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index 8566bb4ffa38..1f03196453d9 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -441,8 +441,8 @@ ipsec4_process_packet( sav = isr->sav; #ifdef DEV_ENC - encif->if_opackets++; - encif->if_obytes += m->m_pkthdr.len; + if_inc_counter(encif, IFCOUNTER_OPACKETS, 1); + if_inc_counter(encif, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* pass the mbuf to enc0 for bpf processing */ ipsec_bpf(m, sav, AF_INET, ENC_OUT|ENC_BEFORE); @@ -641,8 +641,8 @@ ipsec6_process_packet( dst = &sav->sah->saidx.dst; #ifdef DEV_ENC - encif->if_opackets++; - encif->if_obytes += m->m_pkthdr.len; + if_inc_counter(encif, IFCOUNTER_OPACKETS, 1); + if_inc_counter(encif, IFCOUNTER_OBYTES, m->m_pkthdr.len); /* pass the mbuf to enc0 for bpf processing */ ipsec_bpf(m, isr->sav, AF_INET6, ENC_OUT|ENC_BEFORE); diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index df298ae2dea8..b4cb69040f4a 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -751,10 +751,15 @@ dummynet_send(struct mbuf *m) /* extract the dummynet info, rename the tag * to carry reinject info. */ - dst = pkt->dn_dir; - ifp = pkt->ifp; - tag->m_tag_cookie = MTAG_IPFW_RULE; - tag->m_tag_id = 0; + if (pkt->dn_dir == (DIR_OUT | PROTO_LAYER2) && + pkt->ifp == NULL) { + dst = DIR_DROP; + } else { + dst = pkt->dn_dir; + ifp = pkt->ifp; + tag->m_tag_cookie = MTAG_IPFW_RULE; + tag->m_tag_id = 0; + } } switch (dst) { diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c index 30e345724bb0..4f34eeeac9b6 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -159,7 +159,6 @@ pflogstart(struct ifnet *ifp) for (;;) { IF_LOCK(&ifp->if_snd); - _IF_DROP(&ifp->if_snd); _IF_DEQUEUE(&ifp->if_snd, m); IF_UNLOCK(&ifp->if_snd); @@ -253,8 +252,8 @@ pflog_packet(struct pfi_kif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, } #endif /* INET */ - ifn->if_opackets++; - ifn->if_obytes += m->m_pkthdr.len; + if_inc_counter(ifn, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifn, IFCOUNTER_OBYTES, m->m_pkthdr.len); BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); return (0); diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index ffefbc4a883c..813f6596e9aa 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -598,8 +598,8 @@ pfsync_input(struct mbuf **mp, int *offp __unused, int proto __unused) goto done; } - sc->sc_ifp->if_ipackets++; - sc->sc_ifp->if_ibytes += m->m_pkthdr.len; + if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(sc->sc_ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); /* verify that the IP TTL is 255. */ if (ip->ip_ttl != PFSYNC_DFLTTL) { V_pfsyncstats.pfsyncs_badttl++; @@ -1525,7 +1525,7 @@ pfsync_sendout(int schedswi) m = m_get2(max_linkhdr + sc->sc_len, M_NOWAIT, MT_DATA, M_PKTHDR); if (m == NULL) { - sc->sc_ifp->if_oerrors++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); V_pfsyncstats.pfsyncs_onomem++; return; } @@ -1632,15 +1632,15 @@ pfsync_sendout(int schedswi) return; } - sc->sc_ifp->if_opackets++; - sc->sc_ifp->if_obytes += m->m_pkthdr.len; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(sc->sc_ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); sc->sc_len = PFSYNC_MINPKT; if (!_IF_QFULL(&sc->sc_ifp->if_snd)) _IF_ENQUEUE(&sc->sc_ifp->if_snd, m); else { m_freem(m); - sc->sc_ifp->if_snd.ifq_drops++; + if_inc_counter(sc->sc_ifp, IFCOUNTER_OQDROPS, 1); } if (schedswi) swi_sched(V_pfsync_swi_cookie, 0); diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 195aeb381461..dba56745fae8 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -191,6 +191,7 @@ static volatile VNET_DEFINE(int, pf_pfil_hooked); VNET_DEFINE(int, pf_end_threads); struct rwlock pf_rules_lock; +struct sx pf_ioctl_lock; /* pfsync */ pfsync_state_import_t *pfsync_state_import_ptr = NULL; @@ -1095,20 +1096,18 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td switch (cmd) { case DIOCSTART: - PF_RULES_WLOCK(); + sx_xlock(&pf_ioctl_lock); if (V_pf_status.running) error = EEXIST; else { int cpu; - PF_RULES_WUNLOCK(); error = hook_pf(); if (error) { DPFPRINTF(PF_DEBUG_MISC, ("pf: pfil registration failed\n")); break; } - PF_RULES_WLOCK(); V_pf_status.running = 1; V_pf_status.since = time_second; @@ -1117,27 +1116,23 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td DPFPRINTF(PF_DEBUG_MISC, ("pf: started\n")); } - PF_RULES_WUNLOCK(); break; case DIOCSTOP: - PF_RULES_WLOCK(); + sx_xlock(&pf_ioctl_lock); if (!V_pf_status.running) error = ENOENT; else { V_pf_status.running = 0; - PF_RULES_WUNLOCK(); error = dehook_pf(); if (error) { V_pf_status.running = 1; DPFPRINTF(PF_DEBUG_MISC, ("pf: pfil unregistration failed\n")); } - PF_RULES_WLOCK(); V_pf_status.since = time_second; DPFPRINTF(PF_DEBUG_MISC, ("pf: stopped\n")); } - PF_RULES_WUNLOCK(); break; case DIOCADDRULE: { @@ -3261,6 +3256,8 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td break; } fail: + if (sx_xlocked(&pf_ioctl_lock)) + sx_xunlock(&pf_ioctl_lock); CURVNET_RESTORE(); return (error); @@ -3734,6 +3731,7 @@ pf_load(void) VNET_LIST_RUNLOCK(); rw_init(&pf_rules_lock, "pf rulesets"); + sx_init(&pf_ioctl_lock, "pf ioctl"); pf_dev = make_dev(&pf_cdevsw, 0, 0, 0, 0600, PF_NAME); if ((error = pfattach()) != 0) @@ -3747,9 +3745,7 @@ pf_unload(void) { int error = 0; - PF_RULES_WLOCK(); V_pf_status.running = 0; - PF_RULES_WUNLOCK(); swi_remove(V_pf_swi_cookie); error = dehook_pf(); if (error) { @@ -3778,6 +3774,7 @@ pf_unload(void) PF_RULES_WUNLOCK(); destroy_dev(pf_dev); rw_destroy(&pf_rules_lock); + sx_destroy(&pf_ioctl_lock); return (error); } diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index d88a761eb648..b9f13b93de03 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -1853,14 +1853,10 @@ pfr_destroy_ktable(struct pfr_ktable *kt, int flushaddr) pfr_clean_node_mask(kt, &addrq); pfr_destroy_kentries(&addrq); } - if (kt->pfrkt_ip4 != NULL) { - RADIX_NODE_HEAD_DESTROY(kt->pfrkt_ip4); - free((caddr_t)kt->pfrkt_ip4, M_RTABLE); - } - if (kt->pfrkt_ip6 != NULL) { - RADIX_NODE_HEAD_DESTROY(kt->pfrkt_ip6); - free((caddr_t)kt->pfrkt_ip6, M_RTABLE); - } + if (kt->pfrkt_ip4 != NULL) + rn_detachhead((void **)&kt->pfrkt_ip4); + if (kt->pfrkt_ip6 != NULL) + rn_detachhead((void **)&kt->pfrkt_ip6); if (kt->pfrkt_shadow != NULL) pfr_destroy_ktable(kt->pfrkt_shadow, flushaddr); if (kt->pfrkt_rs != NULL) { diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index 1f07b4696c9c..1a5b15639d18 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -122,24 +122,21 @@ nfs_getpages(struct vop_getpages_args *ap) npages = btoc(count); + /* + * Since the caller has busied the requested page, that page's valid + * field will not be changed by other threads. + */ + vm_page_assert_xbusied(pages[ap->a_reqpage]); + /* * If the requested page is partially valid, just return it and * allow the pager to zero-out the blanks. Partially valid pages * can only occur at the file EOF. */ - VM_OBJECT_WLOCK(object); if (pages[ap->a_reqpage]->valid != 0) { - for (i = 0; i < npages; ++i) { - if (i != ap->a_reqpage) { - vm_page_lock(pages[i]); - vm_page_free(pages[i]); - vm_page_unlock(pages[i]); - } - } - VM_OBJECT_WUNLOCK(object); - return (0); + vm_pager_free_nonreq(object, pages, ap->a_reqpage, npages); + return (VM_PAGER_OK); } - VM_OBJECT_WUNLOCK(object); /* * We use only the kva address for the buffer, but this is extremely @@ -169,15 +166,7 @@ nfs_getpages(struct vop_getpages_args *ap) if (error && (uio.uio_resid == count)) { nfs_printf("nfs_getpages: error %d\n", error); - VM_OBJECT_WLOCK(object); - for (i = 0; i < npages; ++i) { - if (i != ap->a_reqpage) { - vm_page_lock(pages[i]); - vm_page_free(pages[i]); - vm_page_unlock(pages[i]); - } - } - VM_OBJECT_WUNLOCK(object); + vm_pager_free_nonreq(object, pages, ap->a_reqpage, npages); return (VM_PAGER_ERROR); } diff --git a/sys/ofed/drivers/infiniband/hw/mlx4/mad.c b/sys/ofed/drivers/infiniband/hw/mlx4/mad.c index b35cf1c2429e..74bbf5c5f352 100644 --- a/sys/ofed/drivers/infiniband/hw/mlx4/mad.c +++ b/sys/ofed/drivers/infiniband/hw/mlx4/mad.c @@ -1081,7 +1081,7 @@ static void handle_lid_change_event(struct mlx4_ib_dev *dev, u8 port_num) if (mlx4_is_master(dev->dev) && !dev->sriov.is_going_down) mlx4_gen_slaves_port_mgt_ev(dev->dev, port_num, - MLX4_EQ_PORT_INFO_LID_CHANGE_MASK); + MLX4_EQ_PORT_INFO_LID_CHANGE_MASK, 0, 0); } static void handle_client_rereg_event(struct mlx4_ib_dev *dev, u8 port_num) @@ -1093,7 +1093,7 @@ static void handle_client_rereg_event(struct mlx4_ib_dev *dev, u8 port_num) if (!dev->sriov.is_going_down) { mlx4_ib_mcg_port_cleanup(&dev->sriov.demux[port_num - 1], 0); mlx4_gen_slaves_port_mgt_ev(dev->dev, port_num, - MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK); + MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK, 0, 0); } } mlx4_ib_dispatch_event(dev, port_num, IB_EVENT_CLIENT_REREGISTER); @@ -1191,7 +1191,7 @@ void handle_port_mgmt_change_event(struct work_struct *work) /*if master, notify all slaves*/ if (mlx4_is_master(dev->dev)) mlx4_gen_slaves_port_mgt_ev(dev->dev, port, - MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK); + MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK, 0, 0); } if (changed_attr & MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK) diff --git a/sys/ofed/drivers/infiniband/hw/mlx4/main.c b/sys/ofed/drivers/infiniband/hw/mlx4/main.c index 1e728267b21d..343b193e81f4 100644 --- a/sys/ofed/drivers/infiniband/hw/mlx4/main.c +++ b/sys/ofed/drivers/infiniband/hw/mlx4/main.c @@ -1005,7 +1005,7 @@ static int flow_spec_to_net_rule(struct ib_device *dev, struct ib_flow_spec *flo case IB_FLOW_IB_UC: spec_l2->id = MLX4_NET_TRANS_RULE_ID_IB; if(flow_spec->l2_id.ib_uc.qpn) { - spec_l2->ib.r_u_qpn = cpu_to_be32(flow_spec->l2_id.ib_uc.qpn); + spec_l2->ib.l3_qpn = cpu_to_be32(flow_spec->l2_id.ib_uc.qpn); spec_l2->ib.qpn_msk = cpu_to_be32(0xffffff); } break; @@ -2013,7 +2013,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) for (i = 0; i < ibdev->num_ports; ++i) { if (mlx4_ib_port_link_layer(&ibdev->ib_dev, i + 1) == IB_LINK_LAYER_ETHERNET) { - err = mlx4_counter_alloc(ibdev->dev, &ibdev->counters[i]); + err = mlx4_counter_alloc(ibdev->dev, i + 1, &ibdev->counters[i]); if (err) ibdev->counters[i] = -1; } else @@ -2112,7 +2112,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) err_counter: for (; i; --i) if (ibdev->counters[i - 1] != -1) - mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]); + mlx4_counter_free(ibdev->dev, i, ibdev->counters[i - 1]); err_map: iounmap(ibdev->priv_uar.map); @@ -2200,7 +2200,7 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr) iounmap(ibdev->priv_uar.map); for (p = 0; p < ibdev->num_ports; ++p) if (ibdev->counters[p] != -1) - mlx4_counter_free(ibdev->dev, ibdev->counters[p]); + mlx4_counter_free(ibdev->dev, p + 1, ibdev->counters[p]); mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB) mlx4_CLOSE_PORT(dev, p); diff --git a/sys/ofed/drivers/infiniband/hw/mlx4/qp.c b/sys/ofed/drivers/infiniband/hw/mlx4/qp.c index 4c7d81920f1f..c5ebe6bac8c1 100644 --- a/sys/ofed/drivers/infiniband/hw/mlx4/qp.c +++ b/sys/ofed/drivers/infiniband/hw/mlx4/qp.c @@ -2679,10 +2679,10 @@ static int mlx4_wq_overflow(struct mlx4_ib_wq *wq, int nreq, struct ib_cq *ib_cq static __be32 convert_access(int acc) { - return (acc & IB_ACCESS_REMOTE_ATOMIC ? cpu_to_be32(MLX4_WQE_FMR_PERM_ATOMIC) : 0) | - (acc & IB_ACCESS_REMOTE_WRITE ? cpu_to_be32(MLX4_WQE_FMR_PERM_REMOTE_WRITE) : 0) | - (acc & IB_ACCESS_REMOTE_READ ? cpu_to_be32(MLX4_WQE_FMR_PERM_REMOTE_READ) : 0) | - (acc & IB_ACCESS_LOCAL_WRITE ? cpu_to_be32(MLX4_WQE_FMR_PERM_LOCAL_WRITE) : 0) | + return (acc & IB_ACCESS_REMOTE_ATOMIC ? cpu_to_be32(MLX4_WQE_FMR_AND_BIND_PERM_ATOMIC) : 0) | + (acc & IB_ACCESS_REMOTE_WRITE ? cpu_to_be32(MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_WRITE) : 0) | + (acc & IB_ACCESS_REMOTE_READ ? cpu_to_be32(MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_READ) : 0) | + (acc & IB_ACCESS_LOCAL_WRITE ? cpu_to_be32(MLX4_WQE_FMR_PERM_LOCAL_WRITE) : 0) | cpu_to_be32(MLX4_WQE_FMR_PERM_LOCAL_READ); } @@ -2709,10 +2709,12 @@ static void set_fmr_seg(struct mlx4_wqe_fmr_seg *fseg, struct ib_send_wr *wr) static void set_local_inv_seg(struct mlx4_wqe_local_inval_seg *iseg, u32 rkey) { - iseg->flags = 0; - iseg->mem_key = cpu_to_be32(rkey); - iseg->guest_id = 0; - iseg->pa = 0; + iseg->mem_key = cpu_to_be32(rkey); + + iseg->reserved1 = 0; + iseg->reserved2 = 0; + iseg->reserved3[0] = 0; + iseg->reserved3[1] = 0; } static __always_inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg, diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 2a9326973668..7763493d4223 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c @@ -510,7 +510,7 @@ void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) ipoib_dbg(priv, "cm recv error " "(status=%d, wrid=%d vend_err %x)\n", wc->status, wr_id, wc->vendor_err); - ++dev->if_ierrors; + if_inc_counter(dev, IFCOUNTER_IERRORS, 1); if (has_srq) goto repost; else { @@ -542,7 +542,7 @@ void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) * this packet and reuse the old buffer. */ ipoib_dbg(priv, "failed to allocate receive buffer %d\n", wr_id); - ++dev->if_ierrors; + if_inc_counter(dev, IFCOUNTER_IERRORS, 1); memcpy(&rx_ring[wr_id], &saverx, sizeof(saverx)); goto repost; } @@ -554,8 +554,8 @@ void ipoib_cm_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) ipoib_dma_mb(priv, mb, wc->byte_len); - ++dev->if_ipackets; - dev->if_ibytes += mb->m_pkthdr.len; + if_inc_counter(dev, IFCOUNTER_IPACKETS, 1); + if_inc_counter(dev, IFCOUNTER_IBYTES, mb->m_pkthdr.len); mb->m_pkthdr.rcvif = dev; proto = *mtod(mb, uint16_t *); @@ -615,7 +615,7 @@ void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm if (unlikely(mb->m_pkthdr.len > tx->mtu)) { ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", mb->m_pkthdr.len, tx->mtu); - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); ipoib_cm_mb_too_long(priv, mb, IPOIB_CM_MTU(tx->mtu)); return; } @@ -635,7 +635,7 @@ void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm tx_req->mb = mb; if (unlikely(ipoib_dma_map_tx(priv->ca, (struct ipoib_tx_buf *)tx_req, priv->cm.num_frags))) { - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); if (tx_req->mb) m_freem(tx_req->mb); return; @@ -643,7 +643,7 @@ void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm if (unlikely(post_send(priv, tx, tx_req, tx->tx_head & (ipoib_sendq_size - 1)))) { ipoib_warn(priv, "post_send failed\n"); - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); ipoib_dma_unmap_tx(priv->ca, (struct ipoib_tx_buf *)tx_req); m_freem(mb); } else { @@ -681,7 +681,7 @@ void ipoib_cm_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) ipoib_dma_unmap_tx(priv->ca, (struct ipoib_tx_buf *)tx_req); /* FIXME: is this right? Shouldn't we only increment on success? */ - ++dev->if_opackets; + if_inc_counter(dev, IFCOUNTER_OPACKETS, 1); m_freem(tx_req->mb); diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 339e30500786..6005a394170c 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -240,7 +240,7 @@ ipoib_ib_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) */ if (unlikely(!ipoib_alloc_rx_mb(priv, wr_id))) { memcpy(&priv->rx_ring[wr_id], &saverx, sizeof(saverx)); - dev->if_iqdrops++; + if_inc_counter(dev, IFCOUNTER_IQDROPS, 1); goto repost; } @@ -250,8 +250,8 @@ ipoib_ib_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) ipoib_dma_unmap_rx(priv, &saverx); ipoib_dma_mb(priv, mb, wc->byte_len); - ++dev->if_ipackets; - dev->if_ibytes += mb->m_pkthdr.len; + if_inc_counter(dev, IFCOUNTER_IPACKETS, 1); + if_inc_counter(dev, IFCOUNTER_IBYTES, mb->m_pkthdr.len); mb->m_pkthdr.rcvif = dev; m_adj(mb, sizeof(struct ib_grh) - INFINIBAND_ALEN); eh = mtod(mb, struct ipoib_header *); @@ -344,7 +344,7 @@ static void ipoib_ib_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc) ipoib_dma_unmap_tx(priv->ca, tx_req); - ++dev->if_opackets; + if_inc_counter(dev, IFCOUNTER_OPACKETS, 1); m_freem(tx_req->mb); @@ -487,7 +487,7 @@ ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb, phead = mtod(mb, void *); if (mb->m_len < hlen) { ipoib_warn(priv, "linear data too small\n"); - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); m_freem(mb); return; } @@ -496,7 +496,7 @@ ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb, if (unlikely(mb->m_pkthdr.len - IPOIB_ENCAP_LEN > priv->mcast_mtu)) { ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", mb->m_pkthdr.len, priv->mcast_mtu); - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); ipoib_cm_mb_too_long(priv, mb, priv->mcast_mtu); return; } @@ -517,7 +517,7 @@ ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb, tx_req = &priv->tx_ring[priv->tx_head & (ipoib_sendq_size - 1)]; tx_req->mb = mb; if (unlikely(ipoib_dma_map_tx(priv->ca, tx_req, IPOIB_UD_TX_SG))) { - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); if (tx_req->mb) m_freem(tx_req->mb); return; @@ -539,7 +539,7 @@ ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb, priv->tx_head & (ipoib_sendq_size - 1), address->ah, qpn, tx_req, phead, hlen))) { ipoib_warn(priv, "post_send failed\n"); - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); --priv->tx_outstanding; ipoib_dma_unmap_tx(priv->ca, tx_req); m_freem(mb); diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c index 46cd5d1a2038..5cd344187a8b 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -665,7 +665,7 @@ ipoib_unicast_send(struct mbuf *mb, struct ipoib_dev_priv *priv, struct ipoib_he } else __path_add(priv, path); } else { - ++priv->dev->if_oerrors; + if_inc_counter(priv->dev, IFCOUNTER_OERRORS, 1); m_freem(mb); } @@ -680,7 +680,7 @@ ipoib_unicast_send(struct mbuf *mb, struct ipoib_dev_priv *priv, struct ipoib_he path->queue.ifq_len < IPOIB_MAX_PATH_REC_QUEUE) { _IF_ENQUEUE(&path->queue, mb); } else { - ++priv->dev->if_oerrors; + if_inc_counter(priv->dev, IFCOUNTER_OERRORS, 1); m_freem(mb); } } @@ -745,7 +745,7 @@ ipoib_vlan_start(struct ifnet *dev) if (mb == NULL) break; m_freem(mb); - dev->if_oerrors++; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); } } @@ -1452,7 +1452,7 @@ ipoib_input(struct ifnet *ifp, struct mbuf *m) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; - ifp->if_imcasts++; + if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1); } ipoib_demux(ifp, m, ntohs(eh->proto)); diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index e5c40bf364b1..9c7bcec1a6f9 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c @@ -70,7 +70,7 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) tx_dropped = mcast->pkt_queue.ifq_len; _IF_DRAIN(&mcast->pkt_queue); /* XXX Locking. */ - dev->if_oerrors += tx_dropped; + if_inc_counter(dev, IFCOUNTER_OERRORS, tx_dropped); kfree(mcast); } @@ -255,7 +255,7 @@ ipoib_mcast_sendonly_join_complete(int status, mcast->mcmember.mgid.raw, ":", status); /* Flush out any queued packets */ - priv->dev->if_oerrors += mcast->pkt_queue.ifq_len; + if_inc_counter(priv->dev, IFCOUNTER_OERRORS, mcast->pkt_queue.ifq_len); _IF_DRAIN(&mcast->pkt_queue); /* Clear the busy flag so we try again */ @@ -617,7 +617,7 @@ ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb) if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags) || !priv->broadcast || !test_bit(IPOIB_MCAST_FLAG_ATTACHED, &priv->broadcast->flags)) { - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); m_freem(mb); return; } @@ -632,7 +632,7 @@ ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb) if (!mcast) { ipoib_warn(priv, "unable to allocate memory for " "multicast structure\n"); - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); m_freem(mb); goto out; } @@ -647,7 +647,7 @@ ipoib_mcast_send(struct ipoib_dev_priv *priv, void *mgid, struct mbuf *mb) if (mcast->pkt_queue.ifq_len < IPOIB_MAX_MCAST_QUEUE) { _IF_ENQUEUE(&mcast->pkt_queue, mb); } else { - ++dev->if_oerrors; + if_inc_counter(dev, IFCOUNTER_OERRORS, 1); m_freem(mb); } diff --git a/sys/ofed/drivers/net/mlx4/alloc.c b/sys/ofed/drivers/net/mlx4/alloc.c index b444bbdaa032..da36b34d98b5 100644 --- a/sys/ofed/drivers/net/mlx4/alloc.c +++ b/sys/ofed/drivers/net/mlx4/alloc.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -70,9 +70,9 @@ u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap) return obj; } -void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj) +void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj, int use_rr) { - mlx4_bitmap_free_range(bitmap, obj, 1); + mlx4_bitmap_free_range(bitmap, obj, 1, use_rr); } static unsigned long find_aligned_range(unsigned long *bitmap, @@ -148,11 +148,17 @@ u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap) return bitmap->avail; } -void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt) +void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt, + int use_rr) { obj &= bitmap->max + bitmap->reserved_top - 1; spin_lock(&bitmap->lock); + if (!use_rr) { + bitmap->last = min(bitmap->last, obj); + bitmap->top = (bitmap->top + bitmap->max + bitmap->reserved_top) + & bitmap->mask; + } bitmap_clear(bitmap->table, obj, cnt); bitmap->avail += cnt; spin_unlock(&bitmap->lock); diff --git a/sys/ofed/drivers/net/mlx4/catas.c b/sys/ofed/drivers/net/mlx4/catas.c index 185129a4b1d7..f62c16c9f583 100644 --- a/sys/ofed/drivers/net/mlx4/catas.c +++ b/sys/ofed/drivers/net/mlx4/catas.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -34,10 +34,11 @@ #include #include +#include + #include "mlx4.h" -#define MLX4_CATAS_POLL_INTERVAL (5 * HZ) - +#define MLX4_CATAS_POLL_INTERVAL (5 * HZ) static DEFINE_SPINLOCK(catas_lock); @@ -156,11 +157,13 @@ void mlx4_stop_catas_poll(struct mlx4_dev *dev) del_timer_sync(&priv->catas_err.timer); - if (priv->catas_err.map) + if (priv->catas_err.map) { iounmap(priv->catas_err.map); + priv->catas_err.map = NULL; + } spin_lock_irq(&catas_lock); - list_del(&priv->catas_err.list); + list_del_init(&priv->catas_err.list); spin_unlock_irq(&catas_lock); } diff --git a/sys/ofed/drivers/net/mlx4/cmd.c b/sys/ofed/drivers/net/mlx4/cmd.c index edbde9ce318e..828009d7ba65 100644 --- a/sys/ofed/drivers/net/mlx4/cmd.c +++ b/sys/ofed/drivers/net/mlx4/cmd.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -34,14 +34,17 @@ #include #include +#include #include #include #include +#include #include #include #include +#include #include "mlx4.h" #include "fw.h" @@ -110,6 +113,14 @@ enum { GO_BIT_TIMEOUT_MSECS = 10000 }; +enum mlx4_vlan_transition { + MLX4_VLAN_TRANSITION_VST_VST = 0, + MLX4_VLAN_TRANSITION_VST_VGT = 1, + MLX4_VLAN_TRANSITION_VGT_VST = 2, + MLX4_VLAN_TRANSITION_VGT_VGT = 3, +}; + + struct mlx4_cmd_context { struct completion done; int result; @@ -152,6 +163,131 @@ static int mlx4_status_to_errno(u8 status) return trans_table[status]; } +static const char *cmd_to_str(u16 cmd) +{ + switch (cmd) { + case MLX4_CMD_SYS_EN: return "SYS_EN"; + case MLX4_CMD_SYS_DIS: return "SYS_DIS"; + case MLX4_CMD_MAP_FA: return "MAP_FA"; + case MLX4_CMD_UNMAP_FA: return "UNMAP_FA"; + case MLX4_CMD_RUN_FW: return "RUN_FW"; + case MLX4_CMD_MOD_STAT_CFG: return "MOD_STAT_CFG"; + case MLX4_CMD_QUERY_DEV_CAP: return "QUERY_DEV_CAP"; + case MLX4_CMD_QUERY_FW: return "QUERY_FW"; + case MLX4_CMD_ENABLE_LAM: return "ENABLE_LAM"; + case MLX4_CMD_DISABLE_LAM: return "DISABLE_LAM"; + case MLX4_CMD_QUERY_DDR: return "QUERY_DDR"; + case MLX4_CMD_QUERY_ADAPTER: return "QUERY_ADAPTER"; + case MLX4_CMD_INIT_HCA: return "INIT_HCA"; + case MLX4_CMD_CLOSE_HCA: return "CLOSE_HCA"; + case MLX4_CMD_INIT_PORT: return "INIT_PORT"; + case MLX4_CMD_CLOSE_PORT: return "CLOSE_PORT"; + case MLX4_CMD_QUERY_HCA: return "QUERY_HCA"; + case MLX4_CMD_QUERY_PORT: return "QUERY_PORT"; + case MLX4_CMD_SENSE_PORT: return "SENSE_PORT"; + case MLX4_CMD_HW_HEALTH_CHECK: return "HW_HEALTH_CHECK"; + case MLX4_CMD_SET_PORT: return "SET_PORT"; + case MLX4_CMD_SET_NODE: return "SET_NODE"; + case MLX4_CMD_QUERY_FUNC: return "QUERY_FUNC"; + case MLX4_CMD_MAP_ICM: return "MAP_ICM"; + case MLX4_CMD_UNMAP_ICM: return "UNMAP_ICM"; + case MLX4_CMD_MAP_ICM_AUX: return "MAP_ICM_AUX"; + case MLX4_CMD_UNMAP_ICM_AUX: return "UNMAP_ICM_AUX"; + case MLX4_CMD_SET_ICM_SIZE: return "SET_ICM_SIZE"; + /*master notify fw on finish for slave's flr*/ + case MLX4_CMD_INFORM_FLR_DONE: return "INFORM_FLR_DONE"; + case MLX4_CMD_GET_OP_REQ: return "GET_OP_REQ"; + + /* TPT commands */ + case MLX4_CMD_SW2HW_MPT: return "SW2HW_MPT"; + case MLX4_CMD_QUERY_MPT: return "QUERY_MPT"; + case MLX4_CMD_HW2SW_MPT: return "HW2SW_MPT"; + case MLX4_CMD_READ_MTT: return "READ_MTT"; + case MLX4_CMD_WRITE_MTT: return "WRITE_MTT"; + case MLX4_CMD_SYNC_TPT: return "SYNC_TPT"; + + /* EQ commands */ + case MLX4_CMD_MAP_EQ: return "MAP_EQ"; + case MLX4_CMD_SW2HW_EQ: return "SW2HW_EQ"; + case MLX4_CMD_HW2SW_EQ: return "HW2SW_EQ"; + case MLX4_CMD_QUERY_EQ: return "QUERY_EQ"; + + /* CQ commands */ + case MLX4_CMD_SW2HW_CQ: return "SW2HW_CQ"; + case MLX4_CMD_HW2SW_CQ: return "HW2SW_CQ"; + case MLX4_CMD_QUERY_CQ: return "QUERY_CQ:"; + case MLX4_CMD_MODIFY_CQ: return "MODIFY_CQ:"; + + /* SRQ commands */ + case MLX4_CMD_SW2HW_SRQ: return "SW2HW_SRQ"; + case MLX4_CMD_HW2SW_SRQ: return "HW2SW_SRQ"; + case MLX4_CMD_QUERY_SRQ: return "QUERY_SRQ"; + case MLX4_CMD_ARM_SRQ: return "ARM_SRQ"; + + /* QP/EE commands */ + case MLX4_CMD_RST2INIT_QP: return "RST2INIT_QP"; + case MLX4_CMD_INIT2RTR_QP: return "INIT2RTR_QP"; + case MLX4_CMD_RTR2RTS_QP: return "RTR2RTS_QP"; + case MLX4_CMD_RTS2RTS_QP: return "RTS2RTS_QP"; + case MLX4_CMD_SQERR2RTS_QP: return "SQERR2RTS_QP"; + case MLX4_CMD_2ERR_QP: return "2ERR_QP"; + case MLX4_CMD_RTS2SQD_QP: return "RTS2SQD_QP"; + case MLX4_CMD_SQD2SQD_QP: return "SQD2SQD_QP"; + case MLX4_CMD_SQD2RTS_QP: return "SQD2RTS_QP"; + case MLX4_CMD_2RST_QP: return "2RST_QP"; + case MLX4_CMD_QUERY_QP: return "QUERY_QP"; + case MLX4_CMD_INIT2INIT_QP: return "INIT2INIT_QP"; + case MLX4_CMD_SUSPEND_QP: return "SUSPEND_QP"; + case MLX4_CMD_UNSUSPEND_QP: return "UNSUSPEND_QP"; + /* special QP and management commands */ + case MLX4_CMD_CONF_SPECIAL_QP: return "CONF_SPECIAL_QP"; + case MLX4_CMD_MAD_IFC: return "MAD_IFC"; + + /* multicast commands */ + case MLX4_CMD_READ_MCG: return "READ_MCG"; + case MLX4_CMD_WRITE_MCG: return "WRITE_MCG"; + case MLX4_CMD_MGID_HASH: return "MGID_HASH"; + + /* miscellaneous commands */ + case MLX4_CMD_DIAG_RPRT: return "DIAG_RPRT"; + case MLX4_CMD_NOP: return "NOP"; + case MLX4_CMD_ACCESS_MEM: return "ACCESS_MEM"; + case MLX4_CMD_SET_VEP: return "SET_VEP"; + + /* Ethernet specific commands */ + case MLX4_CMD_SET_VLAN_FLTR: return "SET_VLAN_FLTR"; + case MLX4_CMD_SET_MCAST_FLTR: return "SET_MCAST_FLTR"; + case MLX4_CMD_DUMP_ETH_STATS: return "DUMP_ETH_STATS"; + + /* Communication channel commands */ + case MLX4_CMD_ARM_COMM_CHANNEL: return "ARM_COMM_CHANNEL"; + case MLX4_CMD_GEN_EQE: return "GEN_EQE"; + + /* virtual commands */ + case MLX4_CMD_ALLOC_RES: return "ALLOC_RES"; + case MLX4_CMD_FREE_RES: return "FREE_RES"; + case MLX4_CMD_MCAST_ATTACH: return "MCAST_ATTACH"; + case MLX4_CMD_UCAST_ATTACH: return "UCAST_ATTACH"; + case MLX4_CMD_PROMISC: return "PROMISC"; + case MLX4_CMD_QUERY_FUNC_CAP: return "QUERY_FUNC_CAP"; + case MLX4_CMD_QP_ATTACH: return "QP_ATTACH"; + + /* debug commands */ + case MLX4_CMD_QUERY_DEBUG_MSG: return "QUERY_DEBUG_MSG"; + case MLX4_CMD_SET_DEBUG_MSG: return "SET_DEBUG_MSG"; + + /* statistics commands */ + case MLX4_CMD_QUERY_IF_STAT: return "QUERY_IF_STAT"; + case MLX4_CMD_SET_IF_STAT: return "SET_IF_STAT"; + + /* register/delete flow steering network rules */ + case MLX4_QP_FLOW_STEERING_ATTACH: return "QP_FLOW_STEERING_ATTACH"; + case MLX4_QP_FLOW_STEERING_DETACH: return "QP_FLOW_STEERING_DETACH"; + case MLX4_FLOW_STEERING_IB_UC_QP_RANGE: return "FLOW_STEERING_IB_UC_QP_RANGE"; + default: return "OTHER"; + } +} + static u8 mlx4_errno_to_status(int errno) { switch (errno) { @@ -244,6 +380,17 @@ static int mlx4_comm_cmd_wait(struct mlx4_dev *dev, u8 op, down(&cmd->event_sem); + end = msecs_to_jiffies(timeout) + jiffies; + while (comm_pending(dev) && time_before(jiffies, end)) + cond_resched(); + if (comm_pending(dev)) { + mlx4_warn(dev, "mlx4_comm_cmd_wait: Comm channel " + "is not idle. My toggle is %d (op: 0x%x)\n", + mlx4_priv(dev)->cmd.comm_toggle, op); + up(&cmd->event_sem); + return -EAGAIN; + } + spin_lock(&cmd->context_lock); BUG_ON(cmd->free_head < 0); context = &cmd->context[cmd->free_head]; @@ -255,12 +402,8 @@ static int mlx4_comm_cmd_wait(struct mlx4_dev *dev, u8 op, mlx4_comm_cmd_post(dev, op, param); - if (!wait_for_completion_timeout(&context->done, - msecs_to_jiffies(timeout))) { - mlx4_warn(dev, "communication channel command 0x%x timed out\n", op); - err = -EBUSY; - goto out; - } + /* In slave, wait unconditionally for completion */ + wait_for_completion(&context->done); err = context->result; if (err && context->fw_status != CMD_STAT_MULTI_FUNC_REQ) { @@ -309,14 +452,29 @@ static int cmd_pending(struct mlx4_dev *dev) !!(status & swab32(1 << HCR_T_BIT))); } -static int mlx4_cmd_post(struct mlx4_dev *dev, u64 in_param, u64 out_param, - u32 in_modifier, u8 op_modifier, u16 op, u16 token, - int event) +static int get_status(struct mlx4_dev *dev, u32 *status, int *go_bit, + int *t_bit) +{ + if (pci_channel_offline(dev->pdev)) + return -EIO; + + *status = readl(mlx4_priv(dev)->cmd.hcr + HCR_STATUS_OFFSET); + *t_bit = !!(*status & swab32(1 << HCR_T_BIT)); + *go_bit = !!(*status & swab32(1 << HCR_GO_BIT)); + + return 0; +} + +static int mlx4_cmd_post(struct mlx4_dev *dev, struct timespec *ts1, + u64 in_param, u64 out_param, u32 in_modifier, + u8 op_modifier, u16 op, u16 token, int event) { struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; u32 __iomem *hcr = cmd->hcr; int ret = -EAGAIN; unsigned long end; + int err, go_bit = 0, t_bit = 0; + u32 status = 0; mutex_lock(&cmd->hcr_mutex); @@ -363,6 +521,9 @@ static int mlx4_cmd_post(struct mlx4_dev *dev, u64 in_param, u64 out_param, __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), hcr + 4); __raw_writel((__force u32) cpu_to_be32(token << 16), hcr + 5); + if (ts1) + ktime_get_ts(ts1); + /* __raw_writel may not order writes. */ wmb(); @@ -383,6 +544,15 @@ static int mlx4_cmd_post(struct mlx4_dev *dev, u64 in_param, u64 out_param, ret = 0; out: + if (ret) { + err = get_status(dev, &status, &go_bit, &t_bit); + mlx4_warn(dev, "Could not post command %s (0x%x): ret=%d, " + "in_param=0x%llx, in_mod=0x%x, op_mod=0x%x, " + "get_status err=%d, status_reg=0x%x, go_bit=%d, " + "t_bit=%d, toggle=0x%x\n", cmd_to_str(op), op, ret, + (unsigned long long) in_param, in_modifier, op_modifier, err, status, + go_bit, t_bit, cmd->toggle); + } mutex_unlock(&cmd->hcr_mutex); return ret; } @@ -439,7 +609,7 @@ static int mlx4_slave_cmd(struct mlx4_dev *dev, u64 in_param, u64 *out_param, ret = mlx4_status_to_errno(vhcr->status); } else mlx4_err(dev, "failed execution of VHCR_POST command" - "opcode 0x%x\n", op); + "opcode %s (0x%x)\n", cmd_to_str(op), op); } mutex_unlock(&priv->cmd.slave_cmd_mutex); @@ -467,7 +637,7 @@ static int mlx4_cmd_poll(struct mlx4_dev *dev, u64 in_param, u64 *out_param, goto out; } - err = mlx4_cmd_post(dev, in_param, out_param ? *out_param : 0, + err = mlx4_cmd_post(dev, NULL, in_param, out_param ? *out_param : 0, in_modifier, op_modifier, op, CMD_POLL_TOKEN, 0); if (err) goto out; @@ -487,7 +657,8 @@ static int mlx4_cmd_poll(struct mlx4_dev *dev, u64 in_param, u64 *out_param, } if (cmd_pending(dev)) { - mlx4_warn(dev, "command 0x%x timed out (go bit not cleared)\n", op); + mlx4_warn(dev, "command %s (0x%x) timed out (go bit not cleared)\n", + cmd_to_str(op), op); err = -ETIMEDOUT; goto out; } @@ -502,8 +673,8 @@ static int mlx4_cmd_poll(struct mlx4_dev *dev, u64 in_param, u64 *out_param, __raw_readl(hcr + HCR_STATUS_OFFSET)) >> 24; err = mlx4_status_to_errno(stat); if (err) - mlx4_err(dev, "command 0x%x failed: fw status = 0x%x\n", - op, stat); + mlx4_err(dev, "command %s (0x%x) failed: fw status = 0x%x\n", + cmd_to_str(op), op, stat); out: up(&priv->cmd.poll_sem); @@ -527,19 +698,6 @@ void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param) complete(&context->done); } -static int get_status(struct mlx4_dev *dev, u32 *status, int *go_bit, - int *t_bit) -{ - if (pci_channel_offline(dev->pdev)) - return -EIO; - - *status = readl(mlx4_priv(dev)->cmd.hcr + HCR_STATUS_OFFSET); - *t_bit = !!(*status & swab32(1 << HCR_T_BIT)); - *go_bit = !!(*status & swab32(1 << HCR_GO_BIT)); - - return 0; -} - static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, int out_is_imm, u32 in_modifier, u8 op_modifier, u16 op, unsigned long timeout) @@ -549,6 +707,12 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, int err = 0; int go_bit = 0, t_bit = 0, stat_err; u32 status = 0; + struct timespec ts1, ts2; + ktime_t t1, t2, delta; + s64 ds; + + if (out_is_imm && !out_param) + return -EINVAL; down(&cmd->event_sem); @@ -561,29 +725,38 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, init_completion(&context->done); - err = mlx4_cmd_post(dev, in_param, out_param ? *out_param : 0, + err = mlx4_cmd_post(dev, &ts1, in_param, out_param ? *out_param : 0, in_modifier, op_modifier, op, context->token, 1); - if (err) { - mlx4_warn(dev, "command 0x%x could not be posted (%d)\n", - op, err); + if (err) goto out; - } if (!wait_for_completion_timeout(&context->done, msecs_to_jiffies(timeout))) { stat_err = get_status(dev, &status, &go_bit, &t_bit); - mlx4_warn(dev, "command 0x%x timed out: " - "get_status err=%d, status=0x%x, go_bit=%d, " - "t_bit=%d, toggle=0x%x\n", op, stat_err, status, - go_bit, t_bit, mlx4_priv(dev)->cmd.toggle); + mlx4_warn(dev, "command %s (0x%x) timed out: in_param=0x%llx, " + "in_mod=0x%x, op_mod=0x%x, get_status err=%d, " + "status_reg=0x%x, go_bit=%d, t_bit=%d, toggle=0x%x\n" + , cmd_to_str(op), op, (unsigned long long) in_param, in_modifier, + op_modifier, stat_err, status, go_bit, t_bit, + mlx4_priv(dev)->cmd.toggle); err = -EBUSY; goto out; } + if (mlx4_debug_level & MLX4_DEBUG_MASK_CMD_TIME) { + ktime_get_ts(&ts2); + t1 = timespec_to_ktime(ts1); + t2 = timespec_to_ktime(ts2); + delta = ktime_sub(t2, t1); + ds = ktime_to_ns(delta); + pr_info("mlx4: fw exec time for %s is %lld nsec\n", cmd_to_str(op), (long long) ds); + } err = context->result; if (err) { - mlx4_err(dev, "command 0x%x failed: fw status = 0x%x\n", - op, context->fw_status); + mlx4_err(dev, "command %s (0x%x) failed: in_param=0x%llx, " + "in_mod=0x%x, op_mod=0x%x, fw status = 0x%x\n", + cmd_to_str(op), op, (unsigned long long) in_param, in_modifier, + op_modifier, context->fw_status); goto out; } @@ -640,7 +813,7 @@ static int mlx4_ACCESS_MEM(struct mlx4_dev *dev, u64 master_addr, (slave & ~0x7f) | (size & 0xff)) { mlx4_err(dev, "Bad access mem params - slave_addr:0x%llx " "master_addr:0x%llx slave_id:%d size:%d\n", - (long long)slave_addr, (long long)master_addr, slave, size); + (unsigned long long) slave_addr, (unsigned long long) master_addr, slave, size); return -EINVAL; } @@ -813,6 +986,24 @@ static int mlx4_MAD_IFC_wrapper(struct mlx4_dev *dev, int slave, vhcr->op, MLX4_CMD_TIME_CLASS_C, MLX4_CMD_NATIVE); } +static int MLX4_CMD_DIAG_RPRT_wrapper(struct mlx4_dev *dev, int slave, + struct mlx4_vhcr *vhcr, + struct mlx4_cmd_mailbox *inbox, + struct mlx4_cmd_mailbox *outbox, + struct mlx4_cmd_info *cmd) +{ + return -EPERM; +} + +static int MLX4_CMD_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave, + struct mlx4_vhcr *vhcr, + struct mlx4_cmd_mailbox *inbox, + struct mlx4_cmd_mailbox *outbox, + struct mlx4_cmd_info *cmd) +{ + return -EPERM; +} + int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, @@ -949,6 +1140,16 @@ static struct mlx4_cmd_info cmd_info[] = { .verify = NULL, .wrapper = NULL }, + { + .opcode = MLX4_CMD_DIAG_RPRT, + .has_inbox = false, + .has_outbox = false, + .out_is_imm = false, + .encode_slave_id = false, + .skip_err_print = true, + .verify = NULL, + .wrapper = MLX4_CMD_DIAG_RPRT_wrapper + }, { .opcode = MLX4_CMD_NOP, .has_inbox = false, @@ -1246,6 +1447,16 @@ static struct mlx4_cmd_info cmd_info[] = { .verify = NULL, .wrapper = mlx4_GEN_QP_wrapper }, + { + .opcode = MLX4_CMD_UPDATE_QP, + .has_inbox = false, + .has_outbox = false, + .out_is_imm = false, + .encode_slave_id = false, + .skip_err_print = true, + .verify = NULL, + .wrapper = MLX4_CMD_UPDATE_QP_wrapper + }, { .opcode = MLX4_CMD_CONF_SPECIAL_QP, .has_inbox = false, @@ -1348,6 +1559,17 @@ static struct mlx4_cmd_info cmd_info[] = { .verify = NULL, .wrapper = mlx4_QP_FLOW_STEERING_DETACH_wrapper }, + /* wol commands */ + { + .opcode = MLX4_CMD_MOD_STAT_CFG, + .has_inbox = false, + .has_outbox = false, + .out_is_imm = false, + .encode_slave_id = false, + .skip_err_print = true, + .verify = NULL, + .wrapper = mlx4_MOD_STAT_CFG_wrapper + }, }; static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, @@ -1401,8 +1623,8 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, } } if (!cmd) { - mlx4_err(dev, "Unknown command:0x%x accepted from slave:%d\n", - vhcr->op, slave); + mlx4_err(dev, "unparavirt command: %s (0x%x) accepted from slave:%d\n", + cmd_to_str(vhcr->op), vhcr->op, slave); vhcr_cmd->status = CMD_STAT_BAD_PARAM; goto out_status; } @@ -1420,8 +1642,8 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, if (mlx4_ACCESS_MEM(dev, inbox->dma, slave, vhcr->in_param, MLX4_MAILBOX_SIZE, 1)) { - mlx4_err(dev, "%s: Failed reading inbox (cmd:0x%x)\n", - __func__, cmd->opcode); + mlx4_err(dev, "%s: Failed reading inbox for cmd %s (0x%x)\n", + __func__, cmd_to_str(cmd->opcode), cmd->opcode); vhcr_cmd->status = CMD_STAT_INTERNAL_ERR; goto out_status; } @@ -1429,9 +1651,9 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, /* Apply permission and bound checks if applicable */ if (cmd->verify && cmd->verify(dev, slave, vhcr, inbox)) { - mlx4_warn(dev, "Command:0x%x from slave: %d failed protection " - "checks for resource_id:%d\n", vhcr->op, slave, - vhcr->in_modifier); + mlx4_warn(dev, "Command %s (0x%x) from slave: %d failed protection " + "checks for resource_id: %d\n", cmd_to_str(vhcr->op), + vhcr->op, slave, vhcr->in_modifier); vhcr_cmd->status = CMD_STAT_BAD_OP; goto out_status; } @@ -1470,9 +1692,13 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, } if (err) { - mlx4_warn(dev, "vhcr command:0x%x slave:%d failed with" - " error:%d, status %d\n", - vhcr->op, slave, vhcr->errno, err); + if (!cmd->skip_err_print) + mlx4_warn(dev, "vhcr command %s (0x%x) slave:%d " + "in_param 0x%llx in_mod=0x%x, op_mod=0x%x " + "failed with error:%d, status %d\n", + cmd_to_str(vhcr->op), vhcr->op, slave, + (unsigned long long) vhcr->in_param, vhcr->in_modifier, + vhcr->op_modifier, vhcr->errno, err); vhcr_cmd->status = mlx4_errno_to_status(err); goto out_status; } @@ -1487,7 +1713,7 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, /* If we failed to write back the outbox after the *command was successfully executed, we must fail this * slave, as it is now in undefined state */ - mlx4_err(dev, "%s:Failed writing outbox\n", __func__); + mlx4_err(dev, "%s: Failed writing outbox\n", __func__); goto out; } } @@ -1516,6 +1742,75 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave, return ret; } +static int mlx4_master_immediate_activate_vlan_qos(struct mlx4_priv *priv, + int slave, int port) +{ + struct mlx4_vport_oper_state *vp_oper; + struct mlx4_vport_state *vp_admin; + struct mlx4_vf_immed_vlan_work *work; + int err; + int admin_vlan_ix = NO_INDX; + + vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; + vp_admin = &priv->mfunc.master.vf_admin[slave].vport[port]; + + if (vp_oper->state.default_vlan == vp_admin->default_vlan && + vp_oper->state.default_qos == vp_admin->default_qos) + return 0; + + work = kzalloc(sizeof(*work), GFP_KERNEL); + if (!work) + return -ENOMEM; + + if (vp_oper->state.default_vlan != vp_admin->default_vlan) { + if (MLX4_VGT != vp_admin->default_vlan) { + err = __mlx4_register_vlan(&priv->dev, port, + vp_admin->default_vlan, + &admin_vlan_ix); + if (err) { + mlx4_warn((&priv->dev), + "No vlan resources slave %d, port %d\n", + slave, port); + return err; + } + } else { + admin_vlan_ix = NO_INDX; + } + work->flags |= MLX4_VF_IMMED_VLAN_FLAG_VLAN; + mlx4_dbg((&(priv->dev)), + "alloc vlan %d idx %d slave %d port %d\n", + (int)(vp_admin->default_vlan), + admin_vlan_ix, slave, port); + } + + /* save original vlan ix and vlan id */ + work->orig_vlan_id = vp_oper->state.default_vlan; + work->orig_vlan_ix = vp_oper->vlan_idx; + + /* handle new qos */ + if (vp_oper->state.default_qos != vp_admin->default_qos) + work->flags |= MLX4_VF_IMMED_VLAN_FLAG_QOS; + + if (work->flags & MLX4_VF_IMMED_VLAN_FLAG_VLAN) + vp_oper->vlan_idx = admin_vlan_ix; + + vp_oper->state.default_vlan = vp_admin->default_vlan; + vp_oper->state.default_qos = vp_admin->default_qos; + + /* iterate over QPs owned by this slave, using UPDATE_QP */ + work->port = port; + work->slave = slave; + work->qos = vp_oper->state.default_qos; + work->vlan_id = vp_oper->state.default_vlan; + work->vlan_ix = vp_oper->vlan_idx; + work->priv = priv; + INIT_WORK(&work->work, mlx4_vf_immed_vlan_work_handler); + queue_work(priv->mfunc.master.comm_wq, &work->work); + + return 0; +} + + static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave) { int port, err; @@ -1527,7 +1822,7 @@ static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave) vp_admin = &priv->mfunc.master.vf_admin[slave].vport[port]; vp_oper->state = *vp_admin; if (MLX4_VGT != vp_admin->default_vlan) { - err = mlx4_register_vlan(&priv->dev, port, + err = __mlx4_register_vlan(&priv->dev, port, vp_admin->default_vlan, &(vp_oper->vlan_idx)); if (err) { vp_oper->vlan_idx = NO_INDX; @@ -1548,12 +1843,12 @@ static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave) err = vp_oper->mac_idx; vp_oper->mac_idx = NO_INDX; mlx4_warn((&priv->dev), - "No mac resorces slave %d, port %d\n", + "No mac resources slave %d, port %d\n", slave, port); return err; } mlx4_dbg((&(priv->dev)), "alloc mac %llx idx %d slave %d port %d\n", - (long long)vp_oper->state.mac, vp_oper->mac_idx, slave, port); + (unsigned long long) vp_oper->state.mac, vp_oper->mac_idx, slave, port); } } return 0; @@ -1599,6 +1894,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, if (cmd == MLX4_COMM_CMD_RESET) { mlx4_warn(dev, "Received reset from slave:%d\n", slave); slave_state[slave].active = false; + slave_state[slave].old_vlan_api = false; mlx4_master_deactivate_admin_state(priv, slave); for (i = 0; i < MLX4_EVENT_TYPES_NUM; ++i) { slave_state[slave].event_eq[i].eqn = -1; @@ -1619,7 +1915,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, /*command from slave in the middle of FLR*/ if (cmd != MLX4_COMM_CMD_RESET && MLX4_COMM_CMD_FLR == slave_state[slave].last_cmd) { - mlx4_warn(dev, "slave:%d is Trying to run cmd(0x%x) " + mlx4_warn(dev, "slave:%d is Trying to run cmd (0x%x) " "in the middle of FLR\n", slave, cmd); return; } @@ -1630,7 +1926,6 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, goto reset_slave; slave_state[slave].vhcr_dma = ((u64) param) << 48; priv->mfunc.master.slave_state[slave].cookie = 0; - mutex_init(&priv->mfunc.master.gen_eqe_mutex[slave]); break; case MLX4_COMM_CMD_VHCR1: if (slave_state[slave].last_cmd != MLX4_COMM_CMD_VHCR0) @@ -1658,7 +1953,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, mutex_lock(&priv->cmd.slave_cmd_mutex); if (mlx4_master_process_vhcr(dev, slave, NULL)) { - mlx4_err(dev, "Failed processing vhcr for slave:%d," + mlx4_err(dev, "Failed processing vhcr for slave: %d," " resetting slave.\n", slave); mutex_unlock(&priv->cmd.slave_cmd_mutex); goto reset_slave; @@ -1666,7 +1961,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, mutex_unlock(&priv->cmd.slave_cmd_mutex); break; default: - mlx4_warn(dev, "Bad comm cmd:%d from slave:%d\n", cmd, slave); + mlx4_warn(dev, "Bad comm cmd: %d from slave: %d\n", cmd, slave); goto reset_slave; } spin_lock_irqsave(&priv->mfunc.master.slave_state_lock, flags); @@ -1676,8 +1971,8 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, is_going_down = 1; spin_unlock_irqrestore(&priv->mfunc.master.slave_state_lock, flags); if (is_going_down) { - mlx4_warn(dev, "Slave is going down aborting command(%d)" - " executing from slave:%d\n", + mlx4_warn(dev, "Slave is going down aborting command (%d)" + " executing from slave: %d\n", cmd, slave); return; } @@ -1696,8 +1991,6 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, spin_unlock_irqrestore(&priv->mfunc.master.slave_state_lock, flags); /*with slave in the middle of flr, no need to clean resources again.*/ inform_slave_state: - memset(&slave_state[slave].event_eq, 0, - sizeof(struct mlx4_slave_event_eq_info)); __raw_writel((__force u32) cpu_to_be32(reply), &priv->mfunc.comm[slave].slave_read); wmb(); @@ -1751,7 +2044,10 @@ void mlx4_master_comm_channel(struct work_struct *work) comm_cmd >> 16 & 0xff, comm_cmd & 0xffff, toggle); ++served; - } + } else + mlx4_err(dev, "slave %d out of sync." + " read toggle %d, write toggle %d.\n", slave, slt, + toggle); } } @@ -1759,6 +2055,19 @@ void mlx4_master_comm_channel(struct work_struct *work) mlx4_warn(dev, "Got command event with bitmask from %d slaves" " but %d were served\n", reported, served); +} +/* master command processing */ +void mlx4_master_arm_comm_channel(struct work_struct *work) +{ + struct mlx4_mfunc_master_ctx *master = + container_of(work, + struct mlx4_mfunc_master_ctx, + arm_comm_work); + struct mlx4_mfunc *mfunc = + container_of(master, struct mlx4_mfunc, master); + struct mlx4_priv *priv = + container_of(mfunc, struct mlx4_priv, mfunc); + struct mlx4_dev *dev = &priv->dev; if (mlx4_ARM_COMM_CHANNEL(dev)) mlx4_warn(dev, "Failed to arm comm channel events\n"); @@ -1839,6 +2148,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) for (i = 0; i < dev->num_slaves; ++i) { s_state = &priv->mfunc.master.slave_state[i]; s_state->last_cmd = MLX4_COMM_CMD_RESET; + mutex_init(&priv->mfunc.master.gen_eqe_mutex[i]); for (j = 0; j < MLX4_EVENT_TYPES_NUM; ++j) s_state->event_eq[j].eqn = -1; __raw_writel((__force u32) 0, @@ -1868,6 +2178,8 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD; INIT_WORK(&priv->mfunc.master.comm_work, mlx4_master_comm_channel); + INIT_WORK(&priv->mfunc.master.arm_comm_work, + mlx4_master_arm_comm_channel); INIT_WORK(&priv->mfunc.master.slave_event_work, mlx4_gen_slave_eqe); INIT_WORK(&priv->mfunc.master.slave_flr_event_work, @@ -2081,6 +2393,8 @@ struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev) return ERR_PTR(-ENOMEM); } + memset(mailbox->buf, 0, MLX4_MAILBOX_SIZE); + return mailbox; } EXPORT_SYMBOL_GPL(mlx4_alloc_cmd_mailbox); @@ -2101,23 +2415,32 @@ u32 mlx4_comm_get_version(void) return ((u32) CMD_CHAN_IF_REV << 8) | (u32) CMD_CHAN_VER; } +static int mlx4_get_slave_indx(struct mlx4_dev *dev, int vf) +{ + if ((vf < 0) || (vf >= dev->num_vfs)) { + mlx4_err(dev, "Bad vf number:%d (number of activated vf: %d)\n", vf, dev->num_vfs); + return -EINVAL; + } + return (vf+1); +} + int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u8 *mac) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_vport_state *s_info; + int slave; if (!mlx4_is_master(dev)) return -EPROTONOSUPPORT; - if ((vf <= 0) || (vf > dev->num_vfs)) { - mlx4_err(dev, "Bad vf number:%d (max vf activated: %d)\n", vf, dev->num_vfs); + slave = mlx4_get_slave_indx(dev, vf); + if (slave < 0) return -EINVAL; - } - s_info = &priv->mfunc.master.vf_admin[vf].vport[port]; + s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; s_info->mac = mlx4_mac_to_u64(mac); mlx4_info(dev, "default mac on vf %d port %d to %llX will take afect only after vf restart\n", - vf, port, (long long)s_info->mac); + vf, port, (unsigned long long) s_info->mac); return 0; } EXPORT_SYMBOL_GPL(mlx4_set_vf_mac); @@ -2125,40 +2448,145 @@ EXPORT_SYMBOL_GPL(mlx4_set_vf_mac); int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos) { struct mlx4_priv *priv = mlx4_priv(dev); - struct mlx4_vport_state *s_info; + struct mlx4_vport_oper_state *vf_oper; + struct mlx4_vport_state *vf_admin; + int slave; if ((!mlx4_is_master(dev)) || - !(dev->caps.flags & MLX4_DEV_CAP_FLAG_ESWITCH_SUPPORT)) + !(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_VLAN_CONTROL)) return -EPROTONOSUPPORT; - if ((vf <= 0) || (vf > dev->num_vfs) || (vlan > 4095) || (qos > 7)) + if ((vlan > 4095) || (qos > 7)) return -EINVAL; - s_info = &priv->mfunc.master.vf_admin[vf].vport[port]; + slave = mlx4_get_slave_indx(dev, vf); + if (slave < 0) + return -EINVAL; + + vf_admin = &priv->mfunc.master.vf_admin[slave].vport[port]; + vf_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; + if ((0 == vlan) && (0 == qos)) - s_info->default_vlan = MLX4_VGT; + vf_admin->default_vlan = MLX4_VGT; else - s_info->default_vlan = vlan; - s_info->default_qos = qos; + vf_admin->default_vlan = vlan; + vf_admin->default_qos = qos; + + if (priv->mfunc.master.slave_state[slave].active && + dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_UPDATE_QP) { + mlx4_info(dev, "updating vf %d port %d config params immediately\n", + vf, port); + mlx4_master_immediate_activate_vlan_qos(priv, slave, port); + } return 0; } EXPORT_SYMBOL_GPL(mlx4_set_vf_vlan); + /* mlx4_get_slave_default_vlan - + * retrun true if VST ( default vlan) + * if VST will fill vlan & qos (if not NULL) */ +bool mlx4_get_slave_default_vlan(struct mlx4_dev *dev, int port, int slave, u16 *vlan, u8 *qos) +{ + struct mlx4_vport_oper_state *vp_oper; + struct mlx4_priv *priv; + + priv = mlx4_priv(dev); + vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; + + if (MLX4_VGT != vp_oper->state.default_vlan) { + if (vlan) + *vlan = vp_oper->state.default_vlan; + if (qos) + *qos = vp_oper->state.default_qos; + return true; + } + return false; +} +EXPORT_SYMBOL_GPL(mlx4_get_slave_default_vlan); + int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_vport_state *s_info; + int slave; if ((!mlx4_is_master(dev)) || - !(dev->caps.flags & MLX4_DEV_CAP_FLAG_ESWITCH_SUPPORT)) + !(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FSM)) return -EPROTONOSUPPORT; - if ((vf <= 0) || (vf > dev->num_vfs)) + slave = mlx4_get_slave_indx(dev, vf); + if (slave < 0) return -EINVAL; - s_info = &priv->mfunc.master.vf_admin[vf].vport[port]; + s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; s_info->spoofchk = setting; return 0; } EXPORT_SYMBOL_GPL(mlx4_set_vf_spoofchk); + +int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int link_state) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_vport_state *s_info; + struct mlx4_vport_oper_state *vp_oper; + int slave; + u8 link_stat_event; + + slave = mlx4_get_slave_indx(dev, vf); + if (slave < 0) + return -EINVAL; + + switch (link_state) { + case IFLA_VF_LINK_STATE_AUTO: + /* get link curent state */ + if (!priv->sense.do_sense_port[port]) + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_ACTIVE; + else + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_DOWN; + break; + + case IFLA_VF_LINK_STATE_ENABLE: + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_ACTIVE; + break; + + case IFLA_VF_LINK_STATE_DISABLE: + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_DOWN; + break; + + default: + mlx4_warn(dev, "unknown value for link_state %02x on slave %d port %d\n", + link_state, slave, port); + return -EINVAL; + }; + /* update the admin & oper state on the link state */ + s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; + vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; + s_info->link_state = link_state; + vp_oper->state.link_state = link_state; + + /* send event */ + mlx4_gen_port_state_change_eqe(dev, slave, port, link_stat_event); + return 0; +} +EXPORT_SYMBOL_GPL(mlx4_set_vf_link_state); + +int mlx4_get_vf_link_state(struct mlx4_dev *dev, int port, int vf) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_vport_state *s_info; + int slave; + + if (!mlx4_is_master(dev)) + return -EPROTONOSUPPORT; + + slave = mlx4_get_slave_indx(dev, vf); + if (slave < 0) + return -EINVAL; + + s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; + + return s_info->link_state; +} +EXPORT_SYMBOL_GPL(mlx4_get_vf_link_state); + diff --git a/sys/ofed/drivers/net/mlx4/cq.c b/sys/ofed/drivers/net/mlx4/cq.c index f87025acb191..b133ae615ea4 100644 --- a/sys/ofed/drivers/net/mlx4/cq.c +++ b/sys/ofed/drivers/net/mlx4/cq.c @@ -2,7 +2,7 @@ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2004 Voltaire, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -35,7 +35,7 @@ */ #include - +#include #include #include @@ -56,12 +56,14 @@ void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn) struct mlx4_cq_table *cq_table = &mlx4_priv(dev)->cq_table; struct mlx4_cq *cq; - spin_lock(&cq_table->lock); + read_lock(&cq_table->cq_table_lock); + cq = radix_tree_lookup(&mlx4_priv(dev)->cq_table.tree, cqn & (dev->caps.num_cqs - 1)); if (cq) atomic_inc(&cq->refcount); - spin_unlock(&cq_table->lock); + + read_unlock(&cq_table->cq_table_lock); if (!cq) { mlx4_dbg(dev, "Completion event for bogus CQ %08x\n", cqn); @@ -81,13 +83,13 @@ void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type) struct mlx4_cq_table *cq_table = &mlx4_priv(dev)->cq_table; struct mlx4_cq *cq; - spin_lock(&cq_table->lock); + read_lock(&cq_table->cq_table_lock); cq = radix_tree_lookup(&cq_table->tree, cqn & (dev->caps.num_cqs - 1)); if (cq) atomic_inc(&cq->refcount); - spin_unlock(&cq_table->lock); + read_unlock(&cq_table->cq_table_lock); if (!cq) { mlx4_warn(dev, "Async event for bogus CQ %08x\n", cqn); @@ -220,7 +222,7 @@ int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn) mlx4_table_put(dev, &cq_table->table, *cqn); err_out: - mlx4_bitmap_free(&cq_table->bitmap, *cqn); + mlx4_bitmap_free(&cq_table->bitmap, *cqn, MLX4_NO_RR); return err; } @@ -250,7 +252,7 @@ void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn) mlx4_table_put(dev, &cq_table->cmpt_table, cqn); mlx4_table_put(dev, &cq_table->table, cqn); - mlx4_bitmap_free(&cq_table->bitmap, cqn); + mlx4_bitmap_free(&cq_table->bitmap, cqn, MLX4_NO_RR); } static void mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn) @@ -269,23 +271,6 @@ static void mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn) __mlx4_cq_free_icm(dev, cqn); } -static int mlx4_find_least_loaded_vector(struct mlx4_priv *priv) -{ - int i; - int index = 0; - int min = priv->eq_table.eq[0].load; - - for (i = 1; i < priv->dev.caps.num_comp_vectors; i++) { - if (priv->eq_table.eq[i].load < min) { - index = i; - min = priv->eq_table.eq[i].load; - } - } - - return index; -} - - int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq, unsigned vector, int collapsed, @@ -298,24 +283,20 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, u64 mtt_addr; int err; - cq->vector = (vector == MLX4_LEAST_ATTACHED_VECTOR) ? - mlx4_find_least_loaded_vector(priv) : vector; - - if (cq->vector > dev->caps.num_comp_vectors + dev->caps.comp_pool) { + if (vector > dev->caps.num_comp_vectors + dev->caps.comp_pool) return -EINVAL; - } + + cq->vector = vector; err = mlx4_cq_alloc_icm(dev, &cq->cqn); - if (err) { + if (err) return err; - } spin_lock_irq(&cq_table->lock); err = radix_tree_insert(&cq_table->tree, cq->cqn, cq); spin_unlock_irq(&cq_table->lock); - if (err){ + if (err) goto err_icm; - } mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) { @@ -331,7 +312,7 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, cq_context->flags |= cpu_to_be32(1 << 19); cq_context->logsize_usrpage = cpu_to_be32((ilog2(nent) << 24) | uar->index); - cq_context->comp_eqn = priv->eq_table.eq[cq->vector].eqn; + cq_context->comp_eqn = priv->eq_table.eq[vector].eqn; cq_context->log_page_size = mtt->page_shift - MLX4_ICM_PAGE_SHIFT; mtt_addr = mlx4_mtt_addr(dev, mtt); @@ -344,7 +325,6 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, if (err) goto err_radix; - priv->eq_table.eq[cq->vector].load++; cq->cons_index = 0; cq->arm_sn = 1; cq->uar = uar; @@ -378,8 +358,6 @@ void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq) if (err) mlx4_warn(dev, "HW2SW_CQ failed (%d) for CQN %06x\n", err, cq->cqn); - - priv->eq_table.eq[cq->vector].load--; synchronize_irq(priv->eq_table.eq[cq->vector].irq); spin_lock_irq(&cq_table->lock); @@ -400,6 +378,7 @@ int mlx4_init_cq_table(struct mlx4_dev *dev) int err; spin_lock_init(&cq_table->lock); + rwlock_init(&cq_table->cq_table_lock); INIT_RADIX_TREE(&cq_table->tree, GFP_ATOMIC); if (mlx4_is_slave(dev)) return 0; diff --git a/sys/ofed/drivers/net/mlx4/en_cq.c b/sys/ofed/drivers/net/mlx4/en_cq.c index 9783e233774f..be043ce113ea 100644 --- a/sys/ofed/drivers/net/mlx4/en_cq.c +++ b/sys/ofed/drivers/net/mlx4/en_cq.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -31,12 +31,13 @@ * */ -#include "mlx4_en.h" - #include #include #include +#include "mlx4_en.h" + + static void mlx4_en_cq_event(struct mlx4_cq *cq, enum mlx4_event event) { return; @@ -44,52 +45,72 @@ static void mlx4_en_cq_event(struct mlx4_cq *cq, enum mlx4_event event) int mlx4_en_create_cq(struct mlx4_en_priv *priv, - struct mlx4_en_cq *cq, - int entries, int ring, enum cq_type mode) + struct mlx4_en_cq **pcq, + int entries, int ring, enum cq_type mode, + int node) { struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_cq *cq; int err; + cq = kzalloc_node(sizeof(struct mlx4_en_cq), GFP_KERNEL, node); + if (!cq) { + cq = kzalloc(sizeof(struct mlx4_en_cq), GFP_KERNEL); + if (!cq) { + en_err(priv, "Failed to allocate CW struture\n"); + return -ENOMEM; + } + } + cq->size = entries; + cq->buf_size = cq->size * mdev->dev->caps.cqe_size; + cq->tq = taskqueue_create_fast("mlx4_en_que", M_NOWAIT, - taskqueue_thread_enqueue, &cq->tq); - if (mode == RX) { - cq->buf_size = cq->size * sizeof(struct mlx4_cqe); - cq->vector = (ring + priv->port) % - mdev->dev->caps.num_comp_vectors; + taskqueue_thread_enqueue, &cq->tq); + if (mode == RX) { TASK_INIT(&cq->cq_task, 0, mlx4_en_rx_que, cq); taskqueue_start_threads(&cq->tq, 1, PI_NET, "%s rx cq", - if_name(priv->dev)); + if_name(priv->dev)); + } else { - cq->buf_size = sizeof(struct mlx4_cqe); - cq->vector = MLX4_LEAST_ATTACHED_VECTOR; TASK_INIT(&cq->cq_task, 0, mlx4_en_tx_que, cq); taskqueue_start_threads(&cq->tq, 1, PI_NET, "%s tx cq", - if_name(priv->dev)); + if_name(priv->dev)); } cq->ring = ring; cq->is_tx = mode; - mtx_init(&cq->lock.m, "mlx4 cq", NULL, MTX_DEF); + spin_lock_init(&cq->lock); err = mlx4_alloc_hwq_res(mdev->dev, &cq->wqres, cq->buf_size, 2 * PAGE_SIZE); if (err) - return err; + goto err_cq; err = mlx4_en_map_buffer(&cq->wqres.buf); if (err) - mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); - else - cq->buf = (struct mlx4_cqe *) cq->wqres.buf.direct.buf; + goto err_res; + cq->buf = (struct mlx4_cqe *) cq->wqres.buf.direct.buf; + *pcq = cq; + + return 0; + +err_res: + mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); +err_cq: + kfree(cq); return err; } -int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) + +int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, + int cq_idx) { struct mlx4_en_dev *mdev = priv->mdev; - int err; + int err = 0; + char name[25]; + int timestamp_en = 0; cq->dev = mdev->pndev[priv->port]; cq->mcq.set_ci_db = cq->wqres.db.db; @@ -98,52 +119,83 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) *cq->mcq.arm_db = 0; memset(cq->buf, 0, cq->buf_size); + if (cq->is_tx == RX) { + if (mdev->dev->caps.comp_pool) { + if (!cq->vector) { + sprintf(name, "%s-%d", if_name(priv->dev), + cq->ring); + /* Set IRQ for specific name (per ring) */ + if (mlx4_assign_eq(mdev->dev, name, &cq->vector)) { + cq->vector = (cq->ring + 1 + priv->port) + % mdev->dev->caps.num_comp_vectors; + mlx4_warn(mdev, "Failed Assigning an EQ to " + "%s ,Falling back to legacy EQ's\n", + name); + } + } + } else { + cq->vector = (cq->ring + 1 + priv->port) % + mdev->dev->caps.num_comp_vectors; + } + } else { + struct mlx4_en_cq *rx_cq; + /* + * For TX we use the same irq per + * ring we assigned for the RX + */ + cq_idx = cq_idx % priv->rx_ring_num; + rx_cq = priv->rx_cq[cq_idx]; + cq->vector = rx_cq->vector; + } + if (!cq->is_tx) - cq->size = priv->rx_ring[cq->ring].actual_size; - - - err = mlx4_cq_alloc(mdev->dev, cq->size, &cq->wqres.mtt, &mdev->priv_uar, - cq->wqres.db.dma, &cq->mcq, cq->vector, cq->is_tx, 0); - if (err) { + cq->size = priv->rx_ring[cq->ring]->actual_size; + err = mlx4_cq_alloc(mdev->dev, cq->size, &cq->wqres.mtt, + &mdev->priv_uar, cq->wqres.db.dma, &cq->mcq, + cq->vector, 0, timestamp_en); + if (err) return err; - } cq->mcq.comp = cq->is_tx ? mlx4_en_tx_irq : mlx4_en_rx_irq; cq->mcq.event = mlx4_en_cq_event; - if (cq->is_tx) { - init_timer(&cq->timer); - cq->timer.function = mlx4_en_poll_tx_cq; - cq->timer.data = (unsigned long) cq; - } + if (cq->is_tx) { + init_timer(&cq->timer); + cq->timer.function = mlx4_en_poll_tx_cq; + cq->timer.data = (unsigned long) cq; + } + return 0; } -void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) +void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq) { struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_cq *cq = *pcq; taskqueue_drain(cq->tq, &cq->cq_task); taskqueue_free(cq->tq); mlx4_en_unmap_buffer(&cq->wqres.buf); mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); - cq->buf_size = 0; - cq->buf = NULL; - mtx_destroy(&cq->lock.m); + if (priv->mdev->dev->caps.comp_pool && cq->vector) + mlx4_release_eq(priv->mdev->dev, cq->vector); + kfree(cq); + *pcq = NULL; } void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) { - struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_dev *mdev = priv->mdev; - taskqueue_drain(cq->tq, &cq->cq_task); - if (cq->is_tx) - del_timer(&cq->timer); + taskqueue_drain(cq->tq, &cq->cq_task); + if (cq->is_tx) + del_timer(&cq->timer); - mlx4_cq_free(mdev->dev, &cq->mcq); + mlx4_cq_free(mdev->dev, &cq->mcq); } + /* Set rx cq moderation parameters */ int mlx4_en_set_cq_moder(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) { diff --git a/sys/ofed/drivers/net/mlx4/en_ethtool.c b/sys/ofed/drivers/net/mlx4/en_ethtool.c index 927994413144..6569a535f412 100644 --- a/sys/ofed/drivers/net/mlx4/en_ethtool.c +++ b/sys/ofed/drivers/net/mlx4/en_ethtool.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -34,26 +34,57 @@ #include #include #include -#include +#include +#include +#include +#include #include "mlx4_en.h" #include "en_port.h" +#define EN_ETHTOOL_QP_ATTACH (1ull << 63) -static void mlx4_en_update_lro_stats(struct mlx4_en_priv *priv) -{ - int i; +union mlx4_ethtool_flow_union { + struct ethtool_tcpip4_spec tcp_ip4_spec; + struct ethtool_tcpip4_spec udp_ip4_spec; + struct ethtool_tcpip4_spec sctp_ip4_spec; + struct ethtool_ah_espip4_spec ah_ip4_spec; + struct ethtool_ah_espip4_spec esp_ip4_spec; + struct ethtool_usrip4_spec usr_ip4_spec; + struct ethhdr ether_spec; + __u8 hdata[52]; +}; - priv->port_stats.lro_aggregated = 0; - priv->port_stats.lro_flushed = 0; - priv->port_stats.lro_no_desc = 0; +struct mlx4_ethtool_flow_ext { + __u8 padding[2]; + unsigned char h_dest[ETH_ALEN]; + __be16 vlan_etype; + __be16 vlan_tci; + __be32 data[2]; +}; - for (i = 0; i < priv->rx_ring_num; i++) { - priv->port_stats.lro_aggregated += priv->rx_ring[i].lro.stats.aggregated; - priv->port_stats.lro_flushed += priv->rx_ring[i].lro.stats.flushed; - priv->port_stats.lro_no_desc += priv->rx_ring[i].lro.stats.no_desc; - } -} +struct mlx4_ethtool_rx_flow_spec { + __u32 flow_type; + union mlx4_ethtool_flow_union h_u; + struct mlx4_ethtool_flow_ext h_ext; + union mlx4_ethtool_flow_union m_u; + struct mlx4_ethtool_flow_ext m_ext; + __u64 ring_cookie; + __u32 location; +}; + +struct mlx4_ethtool_rxnfc { + __u32 cmd; + __u32 flow_type; + __u64 data; + struct mlx4_ethtool_rx_flow_spec fs; + __u32 rule_cnt; + __u32 rule_locs[0]; +}; + +#ifndef FLOW_MAC_EXT +#define FLOW_MAC_EXT 0x40000000 +#endif static void mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) @@ -61,104 +92,142 @@ mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; - sprintf(drvinfo->driver, DRV_NAME " (%s)", mdev->dev->board_id); - strncpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", 32); - sprintf(drvinfo->fw_version, "%d.%d.%d", + strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", + sizeof(drvinfo->version)); + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%d.%d.%d", (u16) (mdev->dev->caps.fw_ver >> 32), (u16) ((mdev->dev->caps.fw_ver >> 16) & 0xffff), (u16) (mdev->dev->caps.fw_ver & 0xffff)); - strncpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), 32); + strlcpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = 0; drvinfo->regdump_len = 0; drvinfo->eedump_len = 0; } -static u32 mlx4_en_get_tso(struct net_device *dev) -{ - return (dev->features & NETIF_F_TSO) != 0; -} - -static int mlx4_en_set_tso(struct net_device *dev, u32 data) -{ - struct mlx4_en_priv *priv = netdev_priv(dev); - - if (data) { - if (!priv->mdev->LSO_support) - return -EPERM; - dev->features |= (NETIF_F_TSO | NETIF_F_TSO6); -#ifdef HAVE_NETDEV_VLAN_FEATURES - dev->vlan_features |= (NETIF_F_TSO | NETIF_F_TSO6); -#else - if (priv->vlgrp) { - int i; - struct net_device *vdev; - for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) { - vdev = vlan_group_get_device(priv->vlgrp, i); - if (vdev) { - vdev->features |= (NETIF_F_TSO | NETIF_F_TSO6); - vlan_group_set_device(priv->vlgrp, i, vdev); - } - } - } -#endif - } else { - dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); -#ifdef HAVE_NETDEV_VLAN_FEATURES - dev->vlan_features &= ~(NETIF_F_TSO | NETIF_F_TSO6); -#else - if (priv->vlgrp) { - int i; - struct net_device *vdev; - for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) { - vdev = vlan_group_get_device(priv->vlgrp, i); - if (vdev) { - vdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); - vlan_group_set_device(priv->vlgrp, i, vdev); - } - } - } -#endif - } - return 0; -} - -static u32 mlx4_en_get_rx_csum(struct net_device *dev) -{ - struct mlx4_en_priv *priv = netdev_priv(dev); - return priv->rx_csum; -} - -static int mlx4_en_set_rx_csum(struct net_device *dev, u32 data) -{ - struct mlx4_en_priv *priv = netdev_priv(dev); - priv->rx_csum = (data != 0); - return 0; -} - static const char main_strings[][ETH_GSTRING_LEN] = { - "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", - "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", - "rx_length_errors", "rx_over_errors", "rx_crc_errors", - "rx_frame_errors", "rx_fifo_errors", "rx_missed_errors", - "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors", - "tx_heartbeat_errors", "tx_window_errors", + /* packet statistics */ + "rx_packets", + "rx_bytes", + "rx_multicast_packets", + "rx_broadcast_packets", + "rx_errors", + "rx_dropped", + "rx_length_errors", + "rx_over_errors", + "rx_crc_errors", + "rx_jabbers", + "rx_in_range_length_error", + "rx_out_range_length_error", + "rx_lt_64_bytes_packets", + "rx_127_bytes_packets", + "rx_255_bytes_packets", + "rx_511_bytes_packets", + "rx_1023_bytes_packets", + "rx_1518_bytes_packets", + "rx_1522_bytes_packets", + "rx_1548_bytes_packets", + "rx_gt_1548_bytes_packets", + "tx_packets", + "tx_bytes", + "tx_multicast_packets", + "tx_broadcast_packets", + "tx_errors", + "tx_dropped", + "tx_lt_64_bytes_packets", + "tx_127_bytes_packets", + "tx_255_bytes_packets", + "tx_511_bytes_packets", + "tx_1023_bytes_packets", + "tx_1518_bytes_packets", + "tx_1522_bytes_packets", + "tx_1548_bytes_packets", + "tx_gt_1548_bytes_packets", + "rx_prio_0_packets", "rx_prio_0_bytes", + "rx_prio_1_packets", "rx_prio_1_bytes", + "rx_prio_2_packets", "rx_prio_2_bytes", + "rx_prio_3_packets", "rx_prio_3_bytes", + "rx_prio_4_packets", "rx_prio_4_bytes", + "rx_prio_5_packets", "rx_prio_5_bytes", + "rx_prio_6_packets", "rx_prio_6_bytes", + "rx_prio_7_packets", "rx_prio_7_bytes", + "rx_novlan_packets", "rx_novlan_bytes", + "tx_prio_0_packets", "tx_prio_0_bytes", + "tx_prio_1_packets", "tx_prio_1_bytes", + "tx_prio_2_packets", "tx_prio_2_bytes", + "tx_prio_3_packets", "tx_prio_3_bytes", + "tx_prio_4_packets", "tx_prio_4_bytes", + "tx_prio_5_packets", "tx_prio_5_bytes", + "tx_prio_6_packets", "tx_prio_6_bytes", + "tx_prio_7_packets", "tx_prio_7_bytes", + "tx_novlan_packets", "tx_novlan_bytes", + + /* flow control statistics */ + "rx_pause_prio_0", "rx_pause_duration_prio_0", + "rx_pause_transition_prio_0", "tx_pause_prio_0", + "tx_pause_duration_prio_0", "tx_pause_transition_prio_0", + "rx_pause_prio_1", "rx_pause_duration_prio_1", + "rx_pause_transition_prio_1", "tx_pause_prio_1", + "tx_pause_duration_prio_1", "tx_pause_transition_prio_1", + "rx_pause_prio_2", "rx_pause_duration_prio_2", + "rx_pause_transition_prio_2", "tx_pause_prio_2", + "tx_pause_duration_prio_2", "tx_pause_transition_prio_2", + "rx_pause_prio_3", "rx_pause_duration_prio_3", + "rx_pause_transition_prio_3", "tx_pause_prio_3", + "tx_pause_duration_prio_3", "tx_pause_transition_prio_3", + "rx_pause_prio_4", "rx_pause_duration_prio_4", + "rx_pause_transition_prio_4", "tx_pause_prio_4", + "tx_pause_duration_prio_4", "tx_pause_transition_prio_4", + "rx_pause_prio_5", "rx_pause_duration_prio_5", + "rx_pause_transition_prio_5", "tx_pause_prio_5", + "tx_pause_duration_prio_5", "tx_pause_transition_prio_5", + "rx_pause_prio_6", "rx_pause_duration_prio_6", + "rx_pause_transition_prio_6", "tx_pause_prio_6", + "tx_pause_duration_prio_6", "tx_pause_transition_prio_6", + "rx_pause_prio_7", "rx_pause_duration_prio_7", + "rx_pause_transition_prio_7", "tx_pause_prio_7", + "tx_pause_duration_prio_7", "tx_pause_transition_prio_7", + + /* VF statistics */ + "rx_packets", + "rx_bytes", + "rx_multicast_packets", + "rx_broadcast_packets", + "rx_errors", + "rx_dropped", + "tx_packets", + "tx_bytes", + "tx_multicast_packets", + "tx_broadcast_packets", + "tx_errors", + + /* VPort statistics */ + "vport_rx_unicast_packets", + "vport_rx_unicast_bytes", + "vport_rx_multicast_packets", + "vport_rx_multicast_bytes", + "vport_rx_broadcast_packets", + "vport_rx_broadcast_bytes", + "vport_rx_dropped", + "vport_rx_errors", + "vport_tx_unicast_packets", + "vport_tx_unicast_bytes", + "vport_tx_multicast_packets", + "vport_tx_multicast_bytes", + "vport_tx_broadcast_packets", + "vport_tx_broadcast_bytes", + "vport_tx_errors", /* port statistics */ - "lro_aggregated", "lro_flushed", "lro_no_desc", "tso_packets", - "queue_stopped", "wake_queue", "tx_timeout", "rx_alloc_failed", + "tx_tso_packets", + "tx_queue_stopped", "tx_wake_queue", "tx_timeout", "rx_alloc_failed", "rx_csum_good", "rx_csum_none", "tx_chksum_offload", - - /* packet statistics */ - "broadcast", "rx_prio_0", "rx_prio_1", "rx_prio_2", "rx_prio_3", - "rx_prio_4", "rx_prio_5", "rx_prio_6", "rx_prio_7", "tx_prio_0", - "tx_prio_1", "tx_prio_2", "tx_prio_3", "tx_prio_4", "tx_prio_5", - "tx_prio_6", "tx_prio_7", }; -#define NUM_MAIN_STATS 21 -#define NUM_ALL_STATS (NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + NUM_PERF_STATS) static const char mlx4_en_test_names[][ETH_GSTRING_LEN]= { - "Interupt Test", + "Interrupt Test", "Link Test", "Speed Test", "Register Test", @@ -178,56 +247,265 @@ static void mlx4_en_set_msglevel(struct net_device *dev, u32 val) static void mlx4_en_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { - wol->supported = 0; - wol->wolopts = 0; + struct mlx4_en_priv *priv = netdev_priv(netdev); + int err = 0; + u64 config = 0; + u64 mask; - return; + if ((priv->port < 1) || (priv->port > 2)) { + en_err(priv, "Failed to get WoL information\n"); + return; + } + + mask = (priv->port == 1) ? MLX4_DEV_CAP_FLAG_WOL_PORT1 : + MLX4_DEV_CAP_FLAG_WOL_PORT2; + + if (!(priv->mdev->dev->caps.flags & mask)) { + wol->supported = 0; + wol->wolopts = 0; + return; + } + + err = mlx4_wol_read(priv->mdev->dev, &config, priv->port); + if (err) { + en_err(priv, "Failed to get WoL information\n"); + return; + } + + if (config & MLX4_EN_WOL_MAGIC) + wol->supported = WAKE_MAGIC; + else + wol->supported = 0; + + if (config & MLX4_EN_WOL_ENABLED) + wol->wolopts = WAKE_MAGIC; + else + wol->wolopts = 0; } -static int mlx4_en_get_sset_count(struct net_device *dev, int sset) +static int mlx4_en_set_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) +{ + struct mlx4_en_priv *priv = netdev_priv(netdev); + u64 config = 0; + int err = 0; + u64 mask; + + if ((priv->port < 1) || (priv->port > 2)) + return -EOPNOTSUPP; + + mask = (priv->port == 1) ? MLX4_DEV_CAP_FLAG_WOL_PORT1 : + MLX4_DEV_CAP_FLAG_WOL_PORT2; + + if (!(priv->mdev->dev->caps.flags & mask)) + return -EOPNOTSUPP; + + if (wol->supported & ~WAKE_MAGIC) + return -EINVAL; + + err = mlx4_wol_read(priv->mdev->dev, &config, priv->port); + if (err) { + en_err(priv, "Failed to get WoL info, unable to modify\n"); + return err; + } + + if (wol->wolopts & WAKE_MAGIC) { + config |= MLX4_EN_WOL_DO_MODIFY | MLX4_EN_WOL_ENABLED | + MLX4_EN_WOL_MAGIC; + } else { + config &= ~(MLX4_EN_WOL_ENABLED | MLX4_EN_WOL_MAGIC); + config |= MLX4_EN_WOL_DO_MODIFY; + } + + err = mlx4_wol_write(priv->mdev->dev, config, priv->port); + if (err) + en_err(priv, "Failed to set WoL information\n"); + + return err; +} + +struct bitmap_sim_iterator { + bool advance_array; + unsigned long *stats_bitmap; + unsigned int count; + unsigned int j; +}; + +static inline void bitmap_sim_iterator_init(struct bitmap_sim_iterator *h, + unsigned long *stats_bitmap, + int count) +{ + h->j = 0; + h->advance_array = !bitmap_empty(stats_bitmap, count); + h->count = h->advance_array ? bitmap_weight(stats_bitmap, count) + : count; + h->stats_bitmap = stats_bitmap; +} + +static inline int bitmap_sim_iterator_test(struct bitmap_sim_iterator *h) +{ + return !h->advance_array ? 1 : test_bit(h->j, h->stats_bitmap); +} + +static inline int bitmap_sim_iterator_inc(struct bitmap_sim_iterator *h) +{ + return h->j++; +} + +static inline unsigned int bitmap_sim_iterator_count( + struct bitmap_sim_iterator *h) +{ + return h->count; +} + +int mlx4_en_get_sset_count(struct net_device *dev, int sset) { struct mlx4_en_priv *priv = netdev_priv(dev); + struct bitmap_sim_iterator it; + + int num_of_stats = NUM_ALL_STATS - + ((priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) ? 0 : NUM_FLOW_STATS); + + bitmap_sim_iterator_init(&it, priv->stats_bitmap, num_of_stats); switch (sset) { case ETH_SS_STATS: - return NUM_ALL_STATS + - (priv->tx_ring_num + priv->rx_ring_num) * 2; + return bitmap_sim_iterator_count(&it) + + (priv->tx_ring_num * 2) + +#ifdef LL_EXTENDED_STATS + (priv->rx_ring_num * 5); +#else + (priv->rx_ring_num * 2); +#endif case ETH_SS_TEST: - return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.loopback_support) * 2; + return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags + & MLX4_DEV_CAP_FLAG_UC_LOOPBACK) * 2; default: return -EOPNOTSUPP; } } -static void mlx4_en_get_ethtool_stats(struct net_device *dev, - struct ethtool_stats *stats, uint64_t *data) +void mlx4_en_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) { struct mlx4_en_priv *priv = netdev_priv(dev); int index = 0; int i; + struct bitmap_sim_iterator it; + + int num_of_stats = NUM_ALL_STATS - + ((priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) ? 0 : NUM_FLOW_STATS); + + bitmap_sim_iterator_init(&it, priv->stats_bitmap, num_of_stats); + + if (!data || !priv->port_up) + return; spin_lock_bh(&priv->stats_lock); - mlx4_en_update_lro_stats(priv); + for (i = 0; i < NUM_PKT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + data[index++] = + ((unsigned long *)&priv->pkstats)[i]; + for (i = 0; i < NUM_FLOW_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) + if (bitmap_sim_iterator_test(&it)) + data[index++] = + ((u64 *)&priv->flowstats)[i]; + for (i = 0; i < NUM_VF_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + data[index++] = + ((unsigned long *)&priv->vf_stats)[i]; + for (i = 0; i < NUM_VPORT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + data[index++] = + ((unsigned long *)&priv->vport_stats)[i]; + for (i = 0; i < NUM_PORT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + data[index++] = + ((unsigned long *)&priv->port_stats)[i]; - for (i = 0; i < NUM_MAIN_STATS; i++) - data[index++] = ((unsigned long *) &priv->stats)[i]; - for (i = 0; i < NUM_PORT_STATS; i++) - data[index++] = ((unsigned long *) &priv->port_stats)[i]; for (i = 0; i < priv->tx_ring_num; i++) { - data[index++] = priv->tx_ring[i].packets; - data[index++] = priv->tx_ring[i].bytes; + data[index++] = priv->tx_ring[i]->packets; + data[index++] = priv->tx_ring[i]->bytes; } for (i = 0; i < priv->rx_ring_num; i++) { - data[index++] = priv->rx_ring[i].packets; - data[index++] = priv->rx_ring[i].bytes; + data[index++] = priv->rx_ring[i]->packets; + data[index++] = priv->rx_ring[i]->bytes; +#ifdef LL_EXTENDED_STATS + data[index++] = priv->rx_ring[i]->yields; + data[index++] = priv->rx_ring[i]->misses; + data[index++] = priv->rx_ring[i]->cleaned; +#endif } - for (i = 0; i < NUM_PKT_STATS; i++) - data[index++] = ((unsigned long *) &priv->pkstats)[i]; spin_unlock_bh(&priv->stats_lock); } +void mlx4_en_restore_ethtool_stats(struct mlx4_en_priv *priv, u64 *data) +{ + int index = 0; + int i; + struct bitmap_sim_iterator it; + + int num_of_stats = NUM_ALL_STATS - + ((priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) ? 0 : NUM_FLOW_STATS); + + bitmap_sim_iterator_init(&it, priv->stats_bitmap, num_of_stats); + + if (!data || !priv->port_up) + return; + + spin_lock_bh(&priv->stats_lock); + + for (i = 0; i < NUM_PKT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + ((unsigned long *)&priv->pkstats)[i] = + data[index++]; + for (i = 0; i < NUM_FLOW_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) + if (bitmap_sim_iterator_test(&it)) + ((u64 *)&priv->flowstats)[i] = + data[index++]; + for (i = 0; i < NUM_VF_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + ((unsigned long *)&priv->vf_stats)[i] = + data[index++]; + for (i = 0; i < NUM_VPORT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + ((unsigned long *)&priv->vport_stats)[i] = + data[index++]; + for (i = 0; i < NUM_PORT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + ((unsigned long *)&priv->port_stats)[i] = + data[index++]; + + for (i = 0; i < priv->tx_ring_num; i++) { + priv->tx_ring[i]->packets = data[index++]; + priv->tx_ring[i]->bytes = data[index++]; + } + for (i = 0; i < priv->rx_ring_num; i++) { + priv->rx_ring[i]->packets = data[index++]; + priv->rx_ring[i]->bytes = data[index++]; + } + spin_unlock_bh(&priv->stats_lock); +} + static void mlx4_en_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) { @@ -239,24 +517,47 @@ static void mlx4_en_get_strings(struct net_device *dev, { struct mlx4_en_priv *priv = netdev_priv(dev); int index = 0; - int i; + int i, k; + struct bitmap_sim_iterator it; + + int num_of_stats = NUM_ALL_STATS - + ((priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) ? 0 : NUM_FLOW_STATS); + + bitmap_sim_iterator_init(&it, priv->stats_bitmap, num_of_stats); switch (stringset) { case ETH_SS_TEST: for (i = 0; i < MLX4_EN_NUM_SELF_TEST - 2; i++) strcpy(data + i * ETH_GSTRING_LEN, mlx4_en_test_names[i]); - if (priv->mdev->dev->caps.loopback_support) + if (priv->mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UC_LOOPBACK) for (; i < MLX4_EN_NUM_SELF_TEST; i++) strcpy(data + i * ETH_GSTRING_LEN, mlx4_en_test_names[i]); break; case ETH_SS_STATS: /* Add main counters */ - for (i = 0; i < NUM_MAIN_STATS; i++) - strcpy(data + (index++) * ETH_GSTRING_LEN, main_strings[i]); - for (i = 0; i< NUM_PORT_STATS; i++) - strcpy(data + (index++) * ETH_GSTRING_LEN, - main_strings[i + NUM_MAIN_STATS]); + for (i = 0; i < NUM_PKT_STATS; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + strcpy(data + (index++) * ETH_GSTRING_LEN, + main_strings[i]); + + for (k = 0; k < NUM_FLOW_STATS; k++, + bitmap_sim_iterator_inc(&it)) + if (priv->mdev->dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) + if (bitmap_sim_iterator_test(&it)) + strcpy(data + (index++) * + ETH_GSTRING_LEN, + main_strings[i + k]); + + for (; (i + k) < num_of_stats; i++, + bitmap_sim_iterator_inc(&it)) + if (bitmap_sim_iterator_test(&it)) + strcpy(data + (index++) * ETH_GSTRING_LEN, + main_strings[i + k]); + for (i = 0; i < priv->tx_ring_num; i++) { sprintf(data + (index++) * ETH_GSTRING_LEN, "tx%d_packets", i); @@ -268,32 +569,79 @@ static void mlx4_en_get_strings(struct net_device *dev, "rx%d_packets", i); sprintf(data + (index++) * ETH_GSTRING_LEN, "rx%d_bytes", i); +#ifdef LL_EXTENDED_STATS + sprintf(data + (index++) * ETH_GSTRING_LEN, + "rx%d_napi_yield", i); + sprintf(data + (index++) * ETH_GSTRING_LEN, + "rx%d_misses", i); + sprintf(data + (index++) * ETH_GSTRING_LEN, + "rx%d_cleaned", i); +#endif } - for (i = 0; i< NUM_PKT_STATS; i++) - strcpy(data + (index++) * ETH_GSTRING_LEN, - main_strings[i + NUM_MAIN_STATS + NUM_PORT_STATS]); break; } } +static u32 mlx4_en_autoneg_get(struct net_device *dev) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + u32 autoneg = AUTONEG_DISABLE; + + if ((mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP) && + priv->port_state.autoneg) { + autoneg = AUTONEG_ENABLE; + } + + return autoneg; +} + static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { struct mlx4_en_priv *priv = netdev_priv(dev); int trans_type; - cmd->autoneg = AUTONEG_DISABLE; - cmd->supported = SUPPORTED_10000baseT_Full; - cmd->advertising = ADVERTISED_10000baseT_Full; + /* SUPPORTED_1000baseT_Half isn't supported */ + cmd->supported = SUPPORTED_1000baseT_Full + |SUPPORTED_10000baseT_Full; + + cmd->advertising = ADVERTISED_1000baseT_Full + |ADVERTISED_10000baseT_Full; + + cmd->supported |= SUPPORTED_1000baseKX_Full + |SUPPORTED_10000baseKX4_Full + |SUPPORTED_10000baseKR_Full + |SUPPORTED_10000baseR_FEC + |SUPPORTED_40000baseKR4_Full + |SUPPORTED_40000baseCR4_Full + |SUPPORTED_40000baseSR4_Full + |SUPPORTED_40000baseLR4_Full; + + /* ADVERTISED_1000baseT_Half isn't advertised */ + cmd->advertising |= ADVERTISED_1000baseKX_Full + |ADVERTISED_10000baseKX4_Full + |ADVERTISED_10000baseKR_Full + |ADVERTISED_10000baseR_FEC + |ADVERTISED_40000baseKR4_Full + |ADVERTISED_40000baseCR4_Full + |ADVERTISED_40000baseSR4_Full + |ADVERTISED_40000baseLR4_Full; if (mlx4_en_QUERY_PORT(priv->mdev, priv->port)) return -ENOMEM; + cmd->autoneg = mlx4_en_autoneg_get(dev); + if (cmd->autoneg == AUTONEG_ENABLE) { + cmd->supported |= SUPPORTED_Autoneg; + cmd->advertising |= ADVERTISED_Autoneg; + } + trans_type = priv->port_state.transciver; if (netif_carrier_ok(dev)) { - cmd->speed = priv->port_state.link_speed; + ethtool_cmd_speed_set(cmd, priv->port_state.link_speed); cmd->duplex = DUPLEX_FULL; } else { - cmd->speed = -1; + ethtool_cmd_speed_set(cmd, -1); cmd->duplex = -1; } @@ -314,13 +662,38 @@ static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) return 0; } +static const char *mlx4_en_duplex_to_string(int duplex) +{ + switch (duplex) { + case DUPLEX_FULL: + return "FULL"; + case DUPLEX_HALF: + return "HALF"; + default: + break; + } + return "UNKNOWN"; +} + static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) { - if ((cmd->autoneg == AUTONEG_ENABLE) || - (cmd->speed != SPEED_10000) || (cmd->duplex != DUPLEX_FULL)) - return -EINVAL; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_port_state *port_state = &priv->port_state; - /* Nothing to change */ + if ((cmd->autoneg != port_state->autoneg) || + (ethtool_cmd_speed(cmd) != port_state->link_speed) || + (cmd->duplex != DUPLEX_FULL)) { + en_info(priv, "Changing port state properties (auto-negotiation" + " , speed/duplex) is not supported. Current:" + " auto-negotiation=%d speed/duplex=%d/%s\n", + port_state->autoneg, port_state->link_speed, + mlx4_en_duplex_to_string(DUPLEX_FULL)); + return -EOPNOTSUPP; + } + + /* User provided same port state properties that are currently set. + * Nothing to change + */ return 0; } @@ -329,8 +702,8 @@ static int mlx4_en_get_coalesce(struct net_device *dev, { struct mlx4_en_priv *priv = netdev_priv(dev); - coal->tx_coalesce_usecs = 0; - coal->tx_max_coalesced_frames = 0; + coal->tx_coalesce_usecs = priv->tx_usecs; + coal->tx_max_coalesced_frames = priv->tx_frames; coal->rx_coalesce_usecs = priv->rx_usecs; coal->rx_max_coalesced_frames = priv->rx_frames; @@ -359,6 +732,21 @@ static int mlx4_en_set_coalesce(struct net_device *dev, MLX4_EN_RX_COAL_TIME : coal->rx_coalesce_usecs; + /* Setting TX coalescing parameters */ + if (coal->tx_coalesce_usecs != priv->tx_usecs || + coal->tx_max_coalesced_frames != priv->tx_frames) { + priv->tx_usecs = coal->tx_coalesce_usecs; + priv->tx_frames = coal->tx_max_coalesced_frames; + if (priv->port_up) { + for (i = 0; i < priv->tx_ring_num; i++) { + priv->tx_cq[i]->moder_cnt = priv->tx_frames; + priv->tx_cq[i]->moder_time = priv->tx_usecs; + if (mlx4_en_set_cq_moder(priv, priv->tx_cq[i])) + en_warn(priv, "Failed changing moderation for TX cq %d\n", i); + } + } + } + /* Set adaptive coalescing params */ priv->pkt_rate_low = coal->pkt_rate_low; priv->rx_usecs_low = coal->rx_coalesce_usecs_low; @@ -369,14 +757,17 @@ static int mlx4_en_set_coalesce(struct net_device *dev, if (priv->adaptive_rx_coal) return 0; - for (i = 0; i < priv->rx_ring_num; i++) { - priv->rx_cq[i].moder_cnt = priv->rx_frames; - priv->rx_cq[i].moder_time = priv->rx_usecs; - priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; - err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); - if (err) - return err; + if (priv->port_up) { + for (i = 0; i < priv->rx_ring_num; i++) { + priv->rx_cq[i]->moder_cnt = priv->rx_frames; + priv->rx_cq[i]->moder_time = priv->rx_usecs; + priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; + err = mlx4_en_set_cq_moder(priv, priv->rx_cq[i]); + if (err) + return err; + } } + return 0; } @@ -387,10 +778,13 @@ static int mlx4_en_set_pauseparam(struct net_device *dev, struct mlx4_en_dev *mdev = priv->mdev; int err; + if (pause->autoneg) + return -EOPNOTSUPP; + priv->prof->tx_pause = pause->tx_pause != 0; priv->prof->rx_pause = pause->rx_pause != 0; err = mlx4_SET_PORT_general(mdev->dev, priv->port, - priv->rx_mb_size + ETH_FCS_LEN, + priv->rx_skb_size + ETH_FCS_LEN, priv->prof->tx_pause, priv->prof->tx_ppp, priv->prof->rx_pause, @@ -408,6 +802,41 @@ static void mlx4_en_get_pauseparam(struct net_device *dev, pause->tx_pause = priv->prof->tx_pause; pause->rx_pause = priv->prof->rx_pause; + pause->autoneg = mlx4_en_autoneg_get(dev); +} + +/* rtnl lock must be taken before calling */ +int mlx4_en_pre_config(struct mlx4_en_priv *priv) +{ +#ifdef CONFIG_RFS_ACCEL + struct cpu_rmap *rmap; + + if (!priv->dev->rx_cpu_rmap) + return 0; + + /* Disable RFS events + * Must have all RFS jobs flushed before freeing resources + */ + rmap = priv->dev->rx_cpu_rmap; + priv->dev->rx_cpu_rmap = NULL; + + rtnl_unlock(); + free_irq_cpu_rmap(rmap); + rtnl_lock(); + + if (priv->dev->rx_cpu_rmap) + return -EBUSY; /* another configuration completed while lock + * was free + */ + + /* Make sure all currently running filter_work are being processed + * Other work will return immediatly because of disable_rfs + */ + flush_workqueue(priv->mdev->workqueue); + +#endif + + return 0; } static int mlx4_en_set_ringparam(struct net_device *dev, @@ -418,7 +847,11 @@ static int mlx4_en_set_ringparam(struct net_device *dev, u32 rx_size, tx_size; int port_up = 0; int err = 0; - int i; + int i, n_stats; + u64 *data = NULL; + + if (!priv->port_up) + return -ENOMEM; if (param->rx_jumbo_pending || param->rx_mini_pending) return -EINVAL; @@ -430,10 +863,13 @@ static int mlx4_en_set_ringparam(struct net_device *dev, tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); tx_size = min_t(u32, tx_size, MLX4_EN_MAX_TX_SIZE); - if (rx_size == (priv->port_up ? priv->rx_ring[0].actual_size : - priv->rx_ring[0].size) && - tx_size == priv->tx_ring[0].size) + if (rx_size == (priv->port_up ? priv->rx_ring[0]->actual_size : + priv->rx_ring[0]->size) && + tx_size == priv->tx_ring[0]->size) return 0; + err = mlx4_en_pre_config(priv); + if (err) + return err; mutex_lock(&mdev->state_lock); if (priv->port_up) { @@ -441,6 +877,14 @@ static int mlx4_en_set_ringparam(struct net_device *dev, mlx4_en_stop_port(dev); } + /* Cache port statistics */ + n_stats = mlx4_en_get_sset_count(dev, ETH_SS_STATS); + if (n_stats > 0) { + data = kmalloc(n_stats * sizeof(u64), GFP_KERNEL); + if (data) + mlx4_en_get_ethtool_stats(dev, NULL, data); + } + mlx4_en_free_resources(priv); priv->prof->tx_ring_size = tx_size; @@ -451,22 +895,30 @@ static int mlx4_en_set_ringparam(struct net_device *dev, en_err(priv, "Failed reallocating port resources\n"); goto out; } + + /* Restore port statistics */ + if (n_stats > 0 && data) + mlx4_en_restore_ethtool_stats(priv, data); + if (port_up) { err = mlx4_en_start_port(dev); - if (err) + if (err) { en_err(priv, "Failed starting port\n"); - } - - for (i = 0; i < priv->rx_ring_num; i++) { - priv->rx_cq[i].moder_cnt = priv->rx_frames; - priv->rx_cq[i].moder_time = priv->rx_usecs; - priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; - err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); - if (err) goto out; + } + + for (i = 0; i < priv->rx_ring_num; i++) { + priv->rx_cq[i]->moder_cnt = priv->rx_frames; + priv->rx_cq[i]->moder_time = priv->rx_usecs; + priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; + err = mlx4_en_set_cq_moder(priv, priv->rx_cq[i]); + if (err) + goto out; + } } out: + kfree(data); mutex_unlock(&mdev->state_lock); return err; } @@ -476,29 +928,665 @@ static void mlx4_en_get_ringparam(struct net_device *dev, { struct mlx4_en_priv *priv = netdev_priv(dev); + if (!priv->port_up) + return; + memset(param, 0, sizeof(*param)); param->rx_max_pending = MLX4_EN_MAX_RX_SIZE; param->tx_max_pending = MLX4_EN_MAX_TX_SIZE; param->rx_pending = priv->port_up ? - priv->rx_ring[0].actual_size : priv->rx_ring[0].size; - param->tx_pending = priv->tx_ring[0].size; + priv->rx_ring[0]->actual_size : priv->rx_ring[0]->size; + param->tx_pending = priv->tx_ring[0]->size; +} + +static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + + return priv->rx_ring_num; +} + +static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_rss_map *rss_map = &priv->rss_map; + int rss_rings; + size_t n = priv->rx_ring_num; + int err = 0; + + rss_rings = priv->prof->rss_rings ?: priv->rx_ring_num; + rss_rings = 1 << ilog2(rss_rings); + + while (n--) { + ring_index[n] = rss_map->qps[n % rss_rings].qpn - + rss_map->base_qpn; + } + + return err; +} + +static int mlx4_en_set_rxfh_indir(struct net_device *dev, + const u32 *ring_index) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + int port_up = 0; + int err = 0; + int i; + int rss_rings = 0; + + /* Calculate RSS table size and make sure flows are spread evenly + * between rings + */ + for (i = 0; i < priv->rx_ring_num; i++) { + if (i > 0 && !ring_index[i] && !rss_rings) + rss_rings = i; + + if (ring_index[i] != (i % (rss_rings ?: priv->rx_ring_num))) + return -EINVAL; + } + + if (!rss_rings) + rss_rings = priv->rx_ring_num; + + /* RSS table size must be an order of 2 */ + if (!is_power_of_2(rss_rings)) + return -EINVAL; + + mutex_lock(&mdev->state_lock); + if (priv->port_up) { + port_up = 1; + mlx4_en_stop_port(dev); + } + + priv->prof->rss_rings = rss_rings; + + if (port_up) { + err = mlx4_en_start_port(dev); + if (err) + en_err(priv, "Failed starting port\n"); + } + + mutex_unlock(&mdev->state_lock); + return err; +} + +#define all_zeros_or_all_ones(field) \ + ((field) == 0 || (field) == (__force typeof(field))-1) + +static int mlx4_en_validate_flow(struct net_device *dev, + struct mlx4_ethtool_rxnfc *cmd) +{ + struct ethtool_usrip4_spec *l3_mask; + struct ethtool_tcpip4_spec *l4_mask; + struct ethhdr *eth_mask; + + if (cmd->fs.location >= MAX_NUM_OF_FS_RULES) + return -EINVAL; + + if (cmd->fs.flow_type & FLOW_MAC_EXT) { + /* dest mac mask must be ff:ff:ff:ff:ff:ff */ + if (!is_broadcast_ether_addr(cmd->fs.m_ext.h_dest)) + return -EINVAL; + } + + switch (cmd->fs.flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) { + case TCP_V4_FLOW: + case UDP_V4_FLOW: + if (cmd->fs.m_u.tcp_ip4_spec.tos) + return -EINVAL; + l4_mask = &cmd->fs.m_u.tcp_ip4_spec; + /* don't allow mask which isn't all 0 or 1 */ + if (!all_zeros_or_all_ones(l4_mask->ip4src) || + !all_zeros_or_all_ones(l4_mask->ip4dst) || + !all_zeros_or_all_ones(l4_mask->psrc) || + !all_zeros_or_all_ones(l4_mask->pdst)) + return -EINVAL; + break; + case IP_USER_FLOW: + l3_mask = &cmd->fs.m_u.usr_ip4_spec; + if (l3_mask->l4_4_bytes || l3_mask->tos || l3_mask->proto || + cmd->fs.h_u.usr_ip4_spec.ip_ver != ETH_RX_NFC_IP4 || + (!l3_mask->ip4src && !l3_mask->ip4dst) || + !all_zeros_or_all_ones(l3_mask->ip4src) || + !all_zeros_or_all_ones(l3_mask->ip4dst)) + return -EINVAL; + break; + case ETHER_FLOW: + eth_mask = &cmd->fs.m_u.ether_spec; + /* source mac mask must not be set */ + if (!is_zero_ether_addr(eth_mask->h_source)) + return -EINVAL; + + /* dest mac mask must be ff:ff:ff:ff:ff:ff */ + if (!is_broadcast_ether_addr(eth_mask->h_dest)) + return -EINVAL; + + if (!all_zeros_or_all_ones(eth_mask->h_proto)) + return -EINVAL; + break; + default: + return -EINVAL; + } + + if ((cmd->fs.flow_type & FLOW_EXT)) { + if (cmd->fs.m_ext.vlan_etype || + !(cmd->fs.m_ext.vlan_tci == 0 || + cmd->fs.m_ext.vlan_tci == cpu_to_be16(0xfff))) + return -EINVAL; + if (cmd->fs.m_ext.vlan_tci) { + if (be16_to_cpu(cmd->fs.h_ext.vlan_tci) < + VLAN_MIN_VALUE || + be16_to_cpu(cmd->fs.h_ext.vlan_tci) > + VLAN_MAX_VALUE) + return -EINVAL; + } + } + + return 0; +} + +static int mlx4_en_ethtool_add_mac_rule(struct mlx4_ethtool_rxnfc *cmd, + struct list_head *rule_list_h, + struct mlx4_spec_list *spec_l2, + unsigned char *mac) +{ + int err = 0; + __be64 mac_msk = cpu_to_be64(MLX4_MAC_MASK << 16); + + spec_l2->id = MLX4_NET_TRANS_RULE_ID_ETH; + memcpy(spec_l2->eth.dst_mac_msk, &mac_msk, ETH_ALEN); + memcpy(spec_l2->eth.dst_mac, mac, ETH_ALEN); + + if ((cmd->fs.flow_type & FLOW_EXT) && cmd->fs.m_ext.vlan_tci) { + spec_l2->eth.vlan_id = cmd->fs.h_ext.vlan_tci; + spec_l2->eth.vlan_id_msk = cpu_to_be16(0xfff); + } + + list_add_tail(&spec_l2->list, rule_list_h); + + return err; +} + +static int mlx4_en_ethtool_add_mac_rule_by_ipv4(struct mlx4_en_priv *priv, + struct mlx4_ethtool_rxnfc *cmd, + struct list_head *rule_list_h, + struct mlx4_spec_list *spec_l2, + __be32 ipv4_dst) +{ + unsigned char mac[ETH_ALEN]; + + if (!ipv4_is_multicast(ipv4_dst)) { + if (cmd->fs.flow_type & FLOW_MAC_EXT) + memcpy(&mac, cmd->fs.h_ext.h_dest, ETH_ALEN); + else + memcpy(&mac, priv->dev->dev_addr, ETH_ALEN); + } else { + ip_eth_mc_map(ipv4_dst, mac); + } + + return mlx4_en_ethtool_add_mac_rule(cmd, rule_list_h, spec_l2, &mac[0]); +} + +static int add_ip_rule(struct mlx4_en_priv *priv, + struct mlx4_ethtool_rxnfc *cmd, + struct list_head *list_h) +{ + struct mlx4_spec_list *spec_l2 = NULL; + struct mlx4_spec_list *spec_l3 = NULL; + struct ethtool_usrip4_spec *l3_mask = &cmd->fs.m_u.usr_ip4_spec; + + spec_l3 = kzalloc(sizeof(*spec_l3), GFP_KERNEL); + spec_l2 = kzalloc(sizeof(*spec_l2), GFP_KERNEL); + if (!spec_l2 || !spec_l3) { + en_err(priv, "Fail to alloc ethtool rule.\n"); + kfree(spec_l2); + kfree(spec_l3); + return -ENOMEM; + } + + mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, spec_l2, + cmd->fs.h_u. + usr_ip4_spec.ip4dst); + spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4; + spec_l3->ipv4.src_ip = cmd->fs.h_u.usr_ip4_spec.ip4src; + if (l3_mask->ip4src) + spec_l3->ipv4.src_ip_msk = MLX4_BE_WORD_MASK; + spec_l3->ipv4.dst_ip = cmd->fs.h_u.usr_ip4_spec.ip4dst; + if (l3_mask->ip4dst) + spec_l3->ipv4.dst_ip_msk = MLX4_BE_WORD_MASK; + list_add_tail(&spec_l3->list, list_h); + + return 0; +} + +static int add_tcp_udp_rule(struct mlx4_en_priv *priv, + struct mlx4_ethtool_rxnfc *cmd, + struct list_head *list_h, int proto) +{ + struct mlx4_spec_list *spec_l2 = NULL; + struct mlx4_spec_list *spec_l3 = NULL; + struct mlx4_spec_list *spec_l4 = NULL; + struct ethtool_tcpip4_spec *l4_mask = &cmd->fs.m_u.tcp_ip4_spec; + + spec_l2 = kzalloc(sizeof(*spec_l2), GFP_KERNEL); + spec_l3 = kzalloc(sizeof(*spec_l3), GFP_KERNEL); + spec_l4 = kzalloc(sizeof(*spec_l4), GFP_KERNEL); + if (!spec_l2 || !spec_l3 || !spec_l4) { + en_err(priv, "Fail to alloc ethtool rule.\n"); + kfree(spec_l2); + kfree(spec_l3); + kfree(spec_l4); + return -ENOMEM; + } + + spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4; + + if (proto == TCP_V4_FLOW) { + mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, + spec_l2, + cmd->fs.h_u. + tcp_ip4_spec.ip4dst); + spec_l4->id = MLX4_NET_TRANS_RULE_ID_TCP; + spec_l3->ipv4.src_ip = cmd->fs.h_u.tcp_ip4_spec.ip4src; + spec_l3->ipv4.dst_ip = cmd->fs.h_u.tcp_ip4_spec.ip4dst; + spec_l4->tcp_udp.src_port = cmd->fs.h_u.tcp_ip4_spec.psrc; + spec_l4->tcp_udp.dst_port = cmd->fs.h_u.tcp_ip4_spec.pdst; + } else { + mlx4_en_ethtool_add_mac_rule_by_ipv4(priv, cmd, list_h, + spec_l2, + cmd->fs.h_u. + udp_ip4_spec.ip4dst); + spec_l4->id = MLX4_NET_TRANS_RULE_ID_UDP; + spec_l3->ipv4.src_ip = cmd->fs.h_u.udp_ip4_spec.ip4src; + spec_l3->ipv4.dst_ip = cmd->fs.h_u.udp_ip4_spec.ip4dst; + spec_l4->tcp_udp.src_port = cmd->fs.h_u.udp_ip4_spec.psrc; + spec_l4->tcp_udp.dst_port = cmd->fs.h_u.udp_ip4_spec.pdst; + } + + if (l4_mask->ip4src) + spec_l3->ipv4.src_ip_msk = MLX4_BE_WORD_MASK; + if (l4_mask->ip4dst) + spec_l3->ipv4.dst_ip_msk = MLX4_BE_WORD_MASK; + + if (l4_mask->psrc) + spec_l4->tcp_udp.src_port_msk = MLX4_BE_SHORT_MASK; + if (l4_mask->pdst) + spec_l4->tcp_udp.dst_port_msk = MLX4_BE_SHORT_MASK; + + list_add_tail(&spec_l3->list, list_h); + list_add_tail(&spec_l4->list, list_h); + + return 0; +} + +static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev, + struct mlx4_ethtool_rxnfc *cmd, + struct list_head *rule_list_h) +{ + int err; + struct ethhdr *eth_spec; + struct mlx4_spec_list *spec_l2; + struct mlx4_en_priv *priv = netdev_priv(dev); + + err = mlx4_en_validate_flow(dev, cmd); + if (err) + return err; + + switch (cmd->fs.flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) { + case ETHER_FLOW: + spec_l2 = kzalloc(sizeof(*spec_l2), GFP_KERNEL); + if (!spec_l2) + return -ENOMEM; + + eth_spec = &cmd->fs.h_u.ether_spec; + mlx4_en_ethtool_add_mac_rule(cmd, rule_list_h, spec_l2, ð_spec->h_dest[0]); + spec_l2->eth.ether_type = eth_spec->h_proto; + if (eth_spec->h_proto) + spec_l2->eth.ether_type_enable = 1; + break; + case IP_USER_FLOW: + err = add_ip_rule(priv, cmd, rule_list_h); + break; + case TCP_V4_FLOW: + err = add_tcp_udp_rule(priv, cmd, rule_list_h, TCP_V4_FLOW); + break; + case UDP_V4_FLOW: + err = add_tcp_udp_rule(priv, cmd, rule_list_h, UDP_V4_FLOW); + break; + } + + return err; +} + +static int mlx4_en_flow_replace(struct net_device *dev, + struct mlx4_ethtool_rxnfc *cmd) +{ + int err; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + struct ethtool_flow_id *loc_rule; + struct mlx4_spec_list *spec, *tmp_spec; + u32 qpn; + u64 reg_id; + + struct mlx4_net_trans_rule rule = { + .queue_mode = MLX4_NET_TRANS_Q_FIFO, + .exclusive = 0, + .allow_loopback = 1, + .promisc_mode = MLX4_FS_REGULAR, + }; + + rule.port = priv->port; + rule.priority = MLX4_DOMAIN_ETHTOOL | cmd->fs.location; + INIT_LIST_HEAD(&rule.list); + + /* Allow direct QP attaches if the EN_ETHTOOL_QP_ATTACH flag is set */ + if (cmd->fs.ring_cookie == RX_CLS_FLOW_DISC) + qpn = priv->drop_qp.qpn; + else if (cmd->fs.ring_cookie & EN_ETHTOOL_QP_ATTACH) { + qpn = cmd->fs.ring_cookie & (EN_ETHTOOL_QP_ATTACH - 1); + } else { + if (cmd->fs.ring_cookie >= priv->rx_ring_num) { + en_warn(priv, "rxnfc: RX ring (%llu) doesn't exist.\n", + cmd->fs.ring_cookie); + return -EINVAL; + } + qpn = priv->rss_map.qps[cmd->fs.ring_cookie].qpn; + if (!qpn) { + en_warn(priv, "rxnfc: RX ring (%llu) is inactive.\n", + cmd->fs.ring_cookie); + return -EINVAL; + } + } + rule.qpn = qpn; + err = mlx4_en_ethtool_to_net_trans_rule(dev, cmd, &rule.list); + if (err) + goto out_free_list; + + mutex_lock(&mdev->state_lock); + loc_rule = &priv->ethtool_rules[cmd->fs.location]; + if (loc_rule->id) { + err = mlx4_flow_detach(priv->mdev->dev, loc_rule->id); + if (err) { + en_err(priv, "Fail to detach network rule at location %d. registration id = %llx\n", + cmd->fs.location, loc_rule->id); + goto unlock; + } + loc_rule->id = 0; + memset(&loc_rule->flow_spec, 0, + sizeof(struct ethtool_rx_flow_spec)); + list_del(&loc_rule->list); + } + err = mlx4_flow_attach(priv->mdev->dev, &rule, ®_id); + if (err) { + en_err(priv, "Fail to attach network rule at location %d.\n", + cmd->fs.location); + goto unlock; + } + loc_rule->id = reg_id; + memcpy(&loc_rule->flow_spec, &cmd->fs, + sizeof(struct ethtool_rx_flow_spec)); + list_add_tail(&loc_rule->list, &priv->ethtool_list); + +unlock: + mutex_unlock(&mdev->state_lock); +out_free_list: + list_for_each_entry_safe(spec, tmp_spec, &rule.list, list) { + list_del(&spec->list); + kfree(spec); + } + return err; +} + +static int mlx4_en_flow_detach(struct net_device *dev, + struct mlx4_ethtool_rxnfc *cmd) +{ + int err = 0; + struct ethtool_flow_id *rule; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + + if (cmd->fs.location >= MAX_NUM_OF_FS_RULES) + return -EINVAL; + + mutex_lock(&mdev->state_lock); + rule = &priv->ethtool_rules[cmd->fs.location]; + if (!rule->id) { + err = -ENOENT; + goto out; + } + + err = mlx4_flow_detach(priv->mdev->dev, rule->id); + if (err) { + en_err(priv, "Fail to detach network rule at location %d. registration id = 0x%llx\n", + cmd->fs.location, rule->id); + goto out; + } + rule->id = 0; + memset(&rule->flow_spec, 0, sizeof(struct ethtool_rx_flow_spec)); + + list_del(&rule->list); +out: + mutex_unlock(&mdev->state_lock); + return err; + +} + +static int mlx4_en_get_flow(struct net_device *dev, struct mlx4_ethtool_rxnfc *cmd, + int loc) +{ + int err = 0; + struct ethtool_flow_id *rule; + struct mlx4_en_priv *priv = netdev_priv(dev); + + if (loc < 0 || loc >= MAX_NUM_OF_FS_RULES) + return -EINVAL; + + rule = &priv->ethtool_rules[loc]; + if (rule->id) + memcpy(&cmd->fs, &rule->flow_spec, + sizeof(struct ethtool_rx_flow_spec)); + else + err = -ENOENT; + + return err; +} + +static int mlx4_en_get_num_flows(struct mlx4_en_priv *priv) +{ + + int i, res = 0; + for (i = 0; i < MAX_NUM_OF_FS_RULES; i++) { + if (priv->ethtool_rules[i].id) + res++; + } + return res; + +} + +static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *c, + u32 *rule_locs) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + int err = 0; + int i = 0, priority = 0; + struct mlx4_ethtool_rxnfc *cmd = (struct mlx4_ethtool_rxnfc *)c; + + if ((cmd->cmd == ETHTOOL_GRXCLSRLCNT || + cmd->cmd == ETHTOOL_GRXCLSRULE || + cmd->cmd == ETHTOOL_GRXCLSRLALL) && + (mdev->dev->caps.steering_mode != + MLX4_STEERING_MODE_DEVICE_MANAGED || !priv->port_up)) + return -EINVAL; + + switch (cmd->cmd) { + case ETHTOOL_GRXRINGS: + cmd->data = priv->rx_ring_num; + break; + case ETHTOOL_GRXCLSRLCNT: + cmd->rule_cnt = mlx4_en_get_num_flows(priv); + break; + case ETHTOOL_GRXCLSRULE: + err = mlx4_en_get_flow(dev, cmd, cmd->fs.location); + break; + case ETHTOOL_GRXCLSRLALL: + while ((!err || err == -ENOENT) && priority < cmd->rule_cnt) { + err = mlx4_en_get_flow(dev, cmd, i); + if (!err) + rule_locs[priority++] = i; + i++; + } + err = 0; + break; + default: + err = -EOPNOTSUPP; + break; + } + + return err; +} + +static int mlx4_en_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *c) +{ + int err = 0; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_ethtool_rxnfc *cmd = (struct mlx4_ethtool_rxnfc *)c; + + if (mdev->dev->caps.steering_mode != + MLX4_STEERING_MODE_DEVICE_MANAGED || !priv->port_up) + return -EINVAL; + + switch (cmd->cmd) { + case ETHTOOL_SRXCLSRLINS: + err = mlx4_en_flow_replace(dev, cmd); + break; + case ETHTOOL_SRXCLSRLDEL: + err = mlx4_en_flow_detach(dev, cmd); + break; + default: + en_warn(priv, "Unsupported ethtool command. (%d)\n", cmd->cmd); + return -EINVAL; + } + + return err; +} + +static void mlx4_en_get_channels(struct net_device *dev, + struct ethtool_channels *channel) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + + memset(channel, 0, sizeof(*channel)); + + channel->max_rx = MAX_RX_RINGS; + channel->max_tx = MLX4_EN_MAX_TX_RING_P_UP; + + channel->rx_count = priv->rx_ring_num; + channel->tx_count = priv->tx_ring_num / MLX4_EN_NUM_UP; +} + +static int mlx4_en_set_channels(struct net_device *dev, + struct ethtool_channels *channel) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + int port_up = 0; + int i; + int err = 0; + + if (channel->other_count || channel->combined_count || + channel->tx_count > MLX4_EN_MAX_TX_RING_P_UP || + channel->rx_count > MAX_RX_RINGS || + !channel->tx_count || !channel->rx_count) + return -EINVAL; + + err = mlx4_en_pre_config(priv); + if (err) + return err; + + mutex_lock(&mdev->state_lock); + if (priv->port_up) { + port_up = 1; + mlx4_en_stop_port(dev); + } + + mlx4_en_free_resources(priv); + + priv->num_tx_rings_p_up = channel->tx_count; + priv->tx_ring_num = channel->tx_count * MLX4_EN_NUM_UP; + priv->rx_ring_num = channel->rx_count; + + err = mlx4_en_alloc_resources(priv); + if (err) { + en_err(priv, "Failed reallocating port resources\n"); + goto out; + } + + netif_set_real_num_tx_queues(dev, priv->tx_ring_num); + netif_set_real_num_rx_queues(dev, priv->rx_ring_num); + + mlx4_en_setup_tc(dev, MLX4_EN_NUM_UP); + + en_warn(priv, "Using %d TX rings\n", priv->tx_ring_num); + en_warn(priv, "Using %d RX rings\n", priv->rx_ring_num); + + if (port_up) { + err = mlx4_en_start_port(dev); + if (err) + en_err(priv, "Failed starting port\n"); + + for (i = 0; i < priv->rx_ring_num; i++) { + priv->rx_cq[i]->moder_cnt = priv->rx_frames; + priv->rx_cq[i]->moder_time = priv->rx_usecs; + priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; + err = mlx4_en_set_cq_moder(priv, priv->rx_cq[i]); + if (err) + goto out; + } + } + +out: + mutex_unlock(&mdev->state_lock); + return err; +} + +static int mlx4_en_get_ts_info(struct net_device *dev, + struct ethtool_ts_info *info) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + int ret; + + ret = ethtool_op_get_ts_info(dev, info); + if (ret) + return ret; + + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) { + info->so_timestamping |= + SOF_TIMESTAMPING_TX_HARDWARE | + SOF_TIMESTAMPING_RX_HARDWARE | + SOF_TIMESTAMPING_RAW_HARDWARE; + + info->tx_types = + (1 << HWTSTAMP_TX_OFF) | + (1 << HWTSTAMP_TX_ON); + + info->rx_filters = + (1 << HWTSTAMP_FILTER_NONE) | + (1 << HWTSTAMP_FILTER_ALL); + } + + return ret; } const struct ethtool_ops mlx4_en_ethtool_ops = { .get_drvinfo = mlx4_en_get_drvinfo, .get_settings = mlx4_en_get_settings, .set_settings = mlx4_en_set_settings, -#ifdef NETIF_F_TSO - .get_tso = mlx4_en_get_tso, - .set_tso = mlx4_en_set_tso, -#endif - .get_sg = ethtool_op_get_sg, - .set_sg = ethtool_op_set_sg, .get_link = ethtool_op_get_link, - .get_rx_csum = mlx4_en_get_rx_csum, - .set_rx_csum = mlx4_en_set_rx_csum, - .get_tx_csum = ethtool_op_get_tx_csum, - .set_tx_csum = ethtool_op_set_tx_ipv6_csum, .get_strings = mlx4_en_get_strings, .get_sset_count = mlx4_en_get_sset_count, .get_ethtool_stats = mlx4_en_get_ethtool_stats, @@ -513,8 +1601,14 @@ const struct ethtool_ops mlx4_en_ethtool_ops = { .set_pauseparam = mlx4_en_set_pauseparam, .get_ringparam = mlx4_en_get_ringparam, .set_ringparam = mlx4_en_set_ringparam, - .get_flags = ethtool_op_get_flags, - .set_flags = ethtool_op_set_flags, + .get_rxnfc = mlx4_en_get_rxnfc, + .set_rxnfc = mlx4_en_set_rxnfc, + .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size, + .get_rxfh_indir = mlx4_en_get_rxfh_indir, + .set_rxfh_indir = mlx4_en_set_rxfh_indir, + .get_channels = mlx4_en_get_channels, + .set_channels = mlx4_en_set_channels, + .get_ts_info = mlx4_en_get_ts_info, }; diff --git a/sys/ofed/drivers/net/mlx4/en_main.c b/sys/ofed/drivers/net/mlx4/en_main.c index 302be528544d..cbbf37df0e5d 100644 --- a/sys/ofed/drivers/net/mlx4/en_main.c +++ b/sys/ofed/drivers/net/mlx4/en_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -60,20 +61,9 @@ static const char mlx4_en_version[] = * Device scope module parameters */ - -/* Enable RSS TCP traffic */ -MLX4_EN_PARM_INT(tcp_rss, 1, - "Enable RSS for incomming TCP traffic or disabled (0)"); /* Enable RSS UDP traffic */ MLX4_EN_PARM_INT(udp_rss, 1, - "Enable RSS for incomming UDP traffic or disabled (0)"); - -/* Number of LRO sessions per Rx ring (rounded up to a power of two) */ -MLX4_EN_PARM_INT(num_lro, MLX4_EN_MAX_LRO_DESCRIPTORS, - "Number of LRO sessions per ring or disabled (0)"); - -/* Allow reassembly of fragmented IP packets */ -MLX4_EN_PARM_INT(ip_reasm, 1, "Allow reassembly of fragmented IP packets (!0)"); + "Enable RSS for incoming UDP traffic"); /* Priority pausing */ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]." @@ -81,20 +71,23 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]." MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." " Per priority bit mask"); +#define MAX_PFC_TX 0xff +#define MAX_PFC_RX 0xff + + static int mlx4_en_get_profile(struct mlx4_en_dev *mdev) { struct mlx4_en_profile *params = &mdev->profile; int i; - params->tcp_rss = tcp_rss; params->udp_rss = udp_rss; - if (params->udp_rss && !(mdev->dev->caps.flags - & MLX4_DEV_CAP_FLAG_UDP_RSS)) { + params->num_tx_rings_p_up = min_t(int, mp_ncpus, + MLX4_EN_MAX_TX_RING_P_UP); + if (params->udp_rss && !(mdev->dev->caps.flags + & MLX4_DEV_CAP_FLAG_UDP_RSS)) { mlx4_warn(mdev, "UDP RSS is not supported on this device.\n"); params->udp_rss = 0; } - params->num_lro = min_t(int, num_lro , MLX4_EN_MAX_LRO_DESCRIPTORS); - params->ip_reasm = ip_reasm; for (i = 1; i <= MLX4_MAX_PORTS; i++) { params->prof[i].rx_pause = 1; params->prof[i].rx_ppp = pfcrx; @@ -102,14 +95,15 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev) params->prof[i].tx_ppp = pfctx; params->prof[i].tx_ring_size = MLX4_EN_DEF_TX_RING_SIZE; params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE; - params->prof[i].tx_ring_num = MLX4_EN_NUM_HASH_RINGS + 1 + - (!!pfcrx) * MLX4_EN_NUM_PPP_RINGS; + params->prof[i].tx_ring_num = params->num_tx_rings_p_up * + MLX4_EN_NUM_UP; + params->prof[i].rss_rings = 0; } return 0; } -static void *get_netdev(struct mlx4_dev *dev, void *ctx, u8 port) +static void *mlx4_en_get_netdev(struct mlx4_dev *dev, void *ctx, u8 port) { struct mlx4_en_dev *endev = ctx; @@ -138,6 +132,9 @@ static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr, mlx4_err(mdev, "Internal error detected, restarting device\n"); break; + case MLX4_DEV_EVENT_SLAVE_INIT: + case MLX4_DEV_EVENT_SLAVE_SHUTDOWN: + break; default: if (port < 1 || port > dev->caps.num_ports || !mdev->pndev[port]) @@ -150,7 +147,7 @@ static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr, static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr) { struct mlx4_en_dev *mdev = endev_ptr; - int i; + int i, ret; mutex_lock(&mdev->state_lock); mdev->device_up = false; @@ -162,25 +159,22 @@ static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr) flush_workqueue(mdev->workqueue); destroy_workqueue(mdev->workqueue); - mlx4_mr_free(dev, &mdev->mr); + ret = mlx4_mr_free(dev, &mdev->mr); + if (ret) + mlx4_err(mdev, "Error deregistering MR. The system may have become unstable."); + iounmap(mdev->uar_map); mlx4_uar_free(dev, &mdev->priv_uar); mlx4_pd_free(dev, mdev->priv_pdn); - sx_destroy(&mdev->state_lock.sx); - mtx_destroy(&mdev->uar_lock.m); kfree(mdev); } static void *mlx4_en_add(struct mlx4_dev *dev) { - static int mlx4_en_version_printed; struct mlx4_en_dev *mdev; int i; int err; - if (!mlx4_en_version_printed) { - printk(KERN_INFO "%s", mlx4_en_version); - mlx4_en_version_printed++; - } + printk_once(KERN_INFO "%s", mlx4_en_version); mdev = kzalloc(sizeof *mdev, GFP_KERNEL); if (!mdev) { @@ -196,10 +190,11 @@ static void *mlx4_en_add(struct mlx4_dev *dev) if (mlx4_uar_alloc(dev, &mdev->priv_uar)) goto err_pd; - mtx_init(&mdev->uar_lock.m, "mlx4 uar", NULL, MTX_DEF); - mdev->uar_map = ioremap(mdev->priv_uar.pfn << PAGE_SHIFT, PAGE_SIZE); + mdev->uar_map = ioremap((phys_addr_t) mdev->priv_uar.pfn << PAGE_SHIFT, + PAGE_SIZE); if (!mdev->uar_map) goto err_uar; + spin_lock_init(&mdev->uar_lock); mdev->dev = dev; mdev->dma_device = &(dev->pdev->dev); @@ -215,7 +210,7 @@ static void *mlx4_en_add(struct mlx4_dev *dev) MLX4_PERM_LOCAL_WRITE | MLX4_PERM_LOCAL_READ, 0, 0, &mdev->mr)) { mlx4_err(mdev, "Failed allocating memory region\n"); - goto err_uar; + goto err_map; } if (mlx4_mr_enable(mdev->dev, &mdev->mr)) { mlx4_err(mdev, "Failed enabling memory region\n"); @@ -229,21 +224,24 @@ static void *mlx4_en_add(struct mlx4_dev *dev) goto err_mr; } - /* Configure wich ports to start according to module parameters */ + /* Configure which ports to start according to module parameters */ mdev->port_cnt = 0; mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) mdev->port_cnt++; - /* If we did not receive an explicit number of Rx rings, default to - * the number of completion vectors populated by the mlx4_core */ - mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { - mlx4_info(mdev, "Using %d tx rings for port:%d\n", - mdev->profile.prof[i].tx_ring_num, i); - mdev->profile.prof[i].rx_ring_num = rounddown_pow_of_two( - min_t(int, dev->caps.num_comp_vectors, MAX_RX_RINGS)); - mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n", - mdev->profile.prof[i].rx_ring_num, i); + mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { + if (!dev->caps.comp_pool) { + mdev->profile.prof[i].rx_ring_num = + rounddown_pow_of_two(max_t(int, MIN_RX_RINGS, + min_t(int, + dev->caps.num_comp_vectors, + DEF_RX_RINGS))); + } else { + mdev->profile.prof[i].rx_ring_num = rounddown_pow_of_two( + min_t(int, dev->caps.comp_pool/ + dev->caps.num_ports - 1 , MAX_MSIX_P_PORT - 1)); + } } /* Create our own workqueue for reset/multicast tasks @@ -257,7 +255,7 @@ static void *mlx4_en_add(struct mlx4_dev *dev) /* At this stage all non-port specific tasks are complete: * mark the card state as up */ - sx_init(&mdev->state_lock.sx, "mlxen state"); + mutex_init(&mdev->state_lock); mdev->device_up = true; /* Setup ports */ @@ -265,32 +263,20 @@ static void *mlx4_en_add(struct mlx4_dev *dev) /* Create a netdev for each port */ mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { mlx4_info(mdev, "Activating port:%d\n", i); - if (mlx4_en_init_netdev(mdev, i, &mdev->profile.prof[i])) { + if (mlx4_en_init_netdev(mdev, i, &mdev->profile.prof[i])) mdev->pndev[i] = NULL; - goto err_free_netdev; - } } + return mdev; - -err_free_netdev: - mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { - if (mdev->pndev[i]) - mlx4_en_destroy_netdev(mdev->pndev[i]); - } - - mutex_lock(&mdev->state_lock); - mdev->device_up = false; - mutex_unlock(&mdev->state_lock); - flush_workqueue(mdev->workqueue); - - /* Stop event queue before we drop down to release shared SW state */ - destroy_workqueue(mdev->workqueue); - err_mr: - mlx4_mr_free(dev, &mdev->mr); + err = mlx4_mr_free(dev, &mdev->mr); + if (err) + mlx4_err(mdev, "Error deregistering MR. The system may have become unstable."); +err_map: + if (mdev->uar_map) + iounmap(mdev->uar_map); err_uar: - mtx_destroy(&mdev->uar_lock.m); mlx4_uar_free(dev, &mdev->priv_uar); err_pd: mlx4_pd_free(dev, mdev->priv_pdn); @@ -300,73 +286,51 @@ static void *mlx4_en_add(struct mlx4_dev *dev) return NULL; } -enum mlx4_query_reply mlx4_en_query(void *endev_ptr, void *int_dev) -{ - struct mlx4_en_dev *mdev = endev_ptr; - struct net_device *netdev = int_dev; - int p; - - for (p = 1; p <= MLX4_MAX_PORTS; ++p) - if (mdev->pndev[p] == netdev) - return p; - - return MLX4_QUERY_NOT_MINE; -} - -#if 0 -static struct pci_device_id mlx4_en_pci_table[] = { - { PCI_VDEVICE(MELLANOX, 0x6340) }, /* MT25408 "Hermon" SDR */ - { PCI_VDEVICE(MELLANOX, 0x634a) }, /* MT25408 "Hermon" DDR */ - { PCI_VDEVICE(MELLANOX, 0x6354) }, /* MT25408 "Hermon" QDR */ - { PCI_VDEVICE(MELLANOX, 0x6732) }, /* MT25408 "Hermon" DDR PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x673c) }, /* MT25408 "Hermon" QDR PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x6368) }, /* MT25408 "Hermon" EN 10GigE */ - { PCI_VDEVICE(MELLANOX, 0x6750) }, /* MT25408 "Hermon" EN 10GigE PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x6372) }, /* MT25458 ConnectX EN 10GBASE-T 10GigE */ - { PCI_VDEVICE(MELLANOX, 0x675a) }, /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */ - { PCI_VDEVICE(MELLANOX, 0x6764) }, /* MT26468 ConnectX EN 10GigE PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x6746) }, /* MT26438 ConnectX VPI PCIe 2.0 5GT/s - IB QDR / 10GigE Virt+ */ - { PCI_VDEVICE(MELLANOX, 0x676e) }, /* MT26478 ConnectX EN 40GigE PCIe 2.0 5GT/s */ - { PCI_VDEVICE(MELLANOX, 0x6778) }, /* MT26488 ConnectX VPI PCIe 2.0 5GT/s - IB DDR / 10GigE Virt+ */ - { PCI_VDEVICE(MELLANOX, 0x1000) }, - { PCI_VDEVICE(MELLANOX, 0x1001) }, - { PCI_VDEVICE(MELLANOX, 0x1002) }, - { PCI_VDEVICE(MELLANOX, 0x1003) }, - { PCI_VDEVICE(MELLANOX, 0x1004) }, - { PCI_VDEVICE(MELLANOX, 0x1005) }, - { PCI_VDEVICE(MELLANOX, 0x1006) }, - { PCI_VDEVICE(MELLANOX, 0x1007) }, - { PCI_VDEVICE(MELLANOX, 0x1008) }, - { PCI_VDEVICE(MELLANOX, 0x1009) }, - { PCI_VDEVICE(MELLANOX, 0x100a) }, - { PCI_VDEVICE(MELLANOX, 0x100b) }, - { PCI_VDEVICE(MELLANOX, 0x100c) }, - { PCI_VDEVICE(MELLANOX, 0x100d) }, - { PCI_VDEVICE(MELLANOX, 0x100e) }, - { PCI_VDEVICE(MELLANOX, 0x100f) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, mlx4_en_pci_table); -#endif - static struct mlx4_interface mlx4_en_interface = { - .add = mlx4_en_add, - .remove = mlx4_en_remove, - .event = mlx4_en_event, - .query = mlx4_en_query, - .get_dev = get_netdev, + .add = mlx4_en_add, + .remove = mlx4_en_remove, + .event = mlx4_en_event, + .get_dev = mlx4_en_get_netdev, .protocol = MLX4_PROT_ETH, }; +static void mlx4_en_verify_params(void) +{ + if (pfctx > MAX_PFC_TX) { + pr_warn("mlx4_en: WARNING: illegal module parameter pfctx 0x%x - " + "should be in range 0-0x%x, will be changed to default (0)\n", + pfctx, MAX_PFC_TX); + pfctx = 0; + } + + if (pfcrx > MAX_PFC_RX) { + pr_warn("mlx4_en: WARNING: illegal module parameter pfcrx 0x%x - " + "should be in range 0-0x%x, will be changed to default (0)\n", + pfcrx, MAX_PFC_RX); + pfcrx = 0; + } +} + + static int __init mlx4_en_init(void) { + mlx4_en_verify_params(); + +#ifdef CONFIG_DEBUG_FS + int err = 0; + err = mlx4_en_register_debugfs(); + if (err) + pr_err(KERN_ERR "Failed to register debugfs\n"); +#endif return mlx4_register_interface(&mlx4_en_interface); } static void __exit mlx4_en_cleanup(void) { mlx4_unregister_interface(&mlx4_en_interface); +#ifdef CONFIG_DEBUG_FS + mlx4_en_unregister_debugfs(); +#endif } module_init(mlx4_en_init); diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c index d8b015b1407d..e76da65f288e 100644 --- a/sys/ofed/drivers/net/mlx4/en_netdev.c +++ b/sys/ofed/drivers/net/mlx4/en_netdev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -31,221 +31,809 @@ * */ -#include "mlx4_en.h" +#include +#include +#include +#ifdef CONFIG_NET_RX_BUSY_POLL +#include +#endif + +#include +#include #include #include #include #include -#include -#include -#include #include #include -static void mlx4_en_init_locked(struct mlx4_en_priv *priv); +#include "mlx4_en.h" +#include "en_port.h" + static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv); +static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv); +static int mlx4_en_unit; + +#ifdef CONFIG_NET_RX_BUSY_POLL +/* must be called with local_bh_disable()d */ +static int mlx4_en_low_latency_recv(struct napi_struct *napi) +{ + struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi); + struct net_device *dev = cq->dev; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_rx_ring *rx_ring = priv->rx_ring[cq->ring]; + int done; + + if (!priv->port_up) + return LL_FLUSH_FAILED; + + if (!mlx4_en_cq_lock_poll(cq)) + return LL_FLUSH_BUSY; + + done = mlx4_en_process_rx_cq(dev, cq, 4); +#ifdef LL_EXTENDED_STATS + if (done) + rx_ring->cleaned += done; + else + rx_ring->misses++; +#endif + + mlx4_en_cq_unlock_poll(cq); + + return done; +} +#endif /* CONFIG_NET_RX_BUSY_POLL */ + +#ifdef CONFIG_RFS_ACCEL + +struct mlx4_en_filter { + struct list_head next; + struct work_struct work; + + u8 ip_proto; + __be32 src_ip; + __be32 dst_ip; + __be16 src_port; + __be16 dst_port; + + int rxq_index; + struct mlx4_en_priv *priv; + u32 flow_id; /* RFS infrastructure id */ + int id; /* mlx4_en driver id */ + u64 reg_id; /* Flow steering API id */ + u8 activated; /* Used to prevent expiry before filter + * is attached + */ + struct hlist_node filter_chain; +}; + +static void mlx4_en_filter_rfs_expire(struct mlx4_en_priv *priv); + +static enum mlx4_net_trans_rule_id mlx4_ip_proto_to_trans_rule_id(u8 ip_proto) +{ + switch (ip_proto) { + case IPPROTO_UDP: + return MLX4_NET_TRANS_RULE_ID_UDP; + case IPPROTO_TCP: + return MLX4_NET_TRANS_RULE_ID_TCP; + default: + return -EPROTONOSUPPORT; + } +}; + +static void mlx4_en_filter_work(struct work_struct *work) +{ + struct mlx4_en_filter *filter = container_of(work, + struct mlx4_en_filter, + work); + struct mlx4_en_priv *priv = filter->priv; + struct mlx4_spec_list spec_tcp_udp = { + .id = mlx4_ip_proto_to_trans_rule_id(filter->ip_proto), + { + .tcp_udp = { + .dst_port = filter->dst_port, + .dst_port_msk = (__force __be16)-1, + .src_port = filter->src_port, + .src_port_msk = (__force __be16)-1, + }, + }, + }; + struct mlx4_spec_list spec_ip = { + .id = MLX4_NET_TRANS_RULE_ID_IPV4, + { + .ipv4 = { + .dst_ip = filter->dst_ip, + .dst_ip_msk = (__force __be32)-1, + .src_ip = filter->src_ip, + .src_ip_msk = (__force __be32)-1, + }, + }, + }; + struct mlx4_spec_list spec_eth = { + .id = MLX4_NET_TRANS_RULE_ID_ETH, + }; + struct mlx4_net_trans_rule rule = { + .list = LIST_HEAD_INIT(rule.list), + .queue_mode = MLX4_NET_TRANS_Q_LIFO, + .exclusive = 1, + .allow_loopback = 1, + .promisc_mode = MLX4_FS_REGULAR, + .port = priv->port, + .priority = MLX4_DOMAIN_RFS, + }; + int rc; + __be64 mac_mask = cpu_to_be64(MLX4_MAC_MASK << 16); + + if (spec_tcp_udp.id < 0) { + en_warn(priv, "RFS: ignoring unsupported ip protocol (%d)\n", + filter->ip_proto); + goto ignore; + } + list_add_tail(&spec_eth.list, &rule.list); + list_add_tail(&spec_ip.list, &rule.list); + list_add_tail(&spec_tcp_udp.list, &rule.list); + + rule.qpn = priv->rss_map.qps[filter->rxq_index].qpn; + memcpy(spec_eth.eth.dst_mac, priv->dev->dev_addr, ETH_ALEN); + memcpy(spec_eth.eth.dst_mac_msk, &mac_mask, ETH_ALEN); + + filter->activated = 0; + + if (filter->reg_id) { + rc = mlx4_flow_detach(priv->mdev->dev, filter->reg_id); + if (rc && rc != -ENOENT) + en_err(priv, "Error detaching flow. rc = %d\n", rc); + } + + rc = mlx4_flow_attach(priv->mdev->dev, &rule, &filter->reg_id); + if (rc) + en_err(priv, "Error attaching flow. err = %d\n", rc); + +ignore: + mlx4_en_filter_rfs_expire(priv); + + filter->activated = 1; +} + +static inline struct hlist_head * +filter_hash_bucket(struct mlx4_en_priv *priv, __be32 src_ip, __be32 dst_ip, + __be16 src_port, __be16 dst_port) +{ + unsigned long l; + int bucket_idx; + + l = (__force unsigned long)src_port | + ((__force unsigned long)dst_port << 2); + l ^= (__force unsigned long)(src_ip ^ dst_ip); + + bucket_idx = hash_long(l, MLX4_EN_FILTER_HASH_SHIFT); + + return &priv->filter_hash[bucket_idx]; +} + +static struct mlx4_en_filter * +mlx4_en_filter_alloc(struct mlx4_en_priv *priv, int rxq_index, __be32 src_ip, + __be32 dst_ip, u8 ip_proto, __be16 src_port, + __be16 dst_port, u32 flow_id) +{ + struct mlx4_en_filter *filter = NULL; + + filter = kzalloc(sizeof(struct mlx4_en_filter), GFP_ATOMIC); + if (!filter) + return NULL; + + filter->priv = priv; + filter->rxq_index = rxq_index; + INIT_WORK(&filter->work, mlx4_en_filter_work); + + filter->src_ip = src_ip; + filter->dst_ip = dst_ip; + filter->ip_proto = ip_proto; + filter->src_port = src_port; + filter->dst_port = dst_port; + + filter->flow_id = flow_id; + + filter->id = priv->last_filter_id++ % RPS_NO_FILTER; + + list_add_tail(&filter->next, &priv->filters); + hlist_add_head(&filter->filter_chain, + filter_hash_bucket(priv, src_ip, dst_ip, src_port, + dst_port)); + + return filter; +} + +static void mlx4_en_filter_free(struct mlx4_en_filter *filter) +{ + struct mlx4_en_priv *priv = filter->priv; + int rc; + + list_del(&filter->next); + + rc = mlx4_flow_detach(priv->mdev->dev, filter->reg_id); + if (rc && rc != -ENOENT) + en_err(priv, "Error detaching flow. rc = %d\n", rc); + + kfree(filter); +} + +static inline struct mlx4_en_filter * +mlx4_en_filter_find(struct mlx4_en_priv *priv, __be32 src_ip, __be32 dst_ip, + u8 ip_proto, __be16 src_port, __be16 dst_port) +{ + struct hlist_node *elem; + struct mlx4_en_filter *filter; + struct mlx4_en_filter *ret = NULL; + + hlist_for_each_entry(filter, elem, + filter_hash_bucket(priv, src_ip, dst_ip, + src_port, dst_port), + filter_chain) { + if (filter->src_ip == src_ip && + filter->dst_ip == dst_ip && + filter->ip_proto == ip_proto && + filter->src_port == src_port && + filter->dst_port == dst_port) { + ret = filter; + break; + } + } + + return ret; +} + +static int +mlx4_en_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb, + u16 rxq_index, u32 flow_id) +{ + struct mlx4_en_priv *priv = netdev_priv(net_dev); + struct mlx4_en_filter *filter; + const struct iphdr *ip; + const __be16 *ports; + u8 ip_proto; + __be32 src_ip; + __be32 dst_ip; + __be16 src_port; + __be16 dst_port; + int nhoff = skb_network_offset(skb); + int ret = 0; + + if (skb->protocol != htons(ETH_P_IP)) + return -EPROTONOSUPPORT; + + ip = (const struct iphdr *)(skb->data + nhoff); + if (ip_is_fragment(ip)) + return -EPROTONOSUPPORT; + + if ((ip->protocol != IPPROTO_TCP) && (ip->protocol != IPPROTO_UDP)) + return -EPROTONOSUPPORT; + ports = (const __be16 *)(skb->data + nhoff + 4 * ip->ihl); + + ip_proto = ip->protocol; + src_ip = ip->saddr; + dst_ip = ip->daddr; + src_port = ports[0]; + dst_port = ports[1]; + + spin_lock_bh(&priv->filters_lock); + filter = mlx4_en_filter_find(priv, src_ip, dst_ip, ip_proto, + src_port, dst_port); + if (filter) { + if (filter->rxq_index == rxq_index) + goto out; + + filter->rxq_index = rxq_index; + } else { + filter = mlx4_en_filter_alloc(priv, rxq_index, + src_ip, dst_ip, ip_proto, + src_port, dst_port, flow_id); + if (!filter) { + ret = -ENOMEM; + goto err; + } + } + + queue_work(priv->mdev->workqueue, &filter->work); + +out: + ret = filter->id; +err: + spin_unlock_bh(&priv->filters_lock); + + return ret; +} + +void mlx4_en_cleanup_filters(struct mlx4_en_priv *priv, + struct mlx4_en_rx_ring *rx_ring) +{ + struct mlx4_en_filter *filter, *tmp; + LIST_HEAD(del_list); + + spin_lock_bh(&priv->filters_lock); + list_for_each_entry_safe(filter, tmp, &priv->filters, next) { + list_move(&filter->next, &del_list); + hlist_del(&filter->filter_chain); + } + spin_unlock_bh(&priv->filters_lock); + + list_for_each_entry_safe(filter, tmp, &del_list, next) { + cancel_work_sync(&filter->work); + mlx4_en_filter_free(filter); + } +} + +static void mlx4_en_filter_rfs_expire(struct mlx4_en_priv *priv) +{ + struct mlx4_en_filter *filter = NULL, *tmp, *last_filter = NULL; + LIST_HEAD(del_list); + int i = 0; + + spin_lock_bh(&priv->filters_lock); + list_for_each_entry_safe(filter, tmp, &priv->filters, next) { + if (i > MLX4_EN_FILTER_EXPIRY_QUOTA) + break; + + if (filter->activated && + !work_pending(&filter->work) && + rps_may_expire_flow(priv->dev, + filter->rxq_index, filter->flow_id, + filter->id)) { + list_move(&filter->next, &del_list); + hlist_del(&filter->filter_chain); + } else + last_filter = filter; + + i++; + } + + if (last_filter && (&last_filter->next != priv->filters.next)) + list_move(&priv->filters, &last_filter->next); + + spin_unlock_bh(&priv->filters_lock); + + list_for_each_entry_safe(filter, tmp, &del_list, next) + mlx4_en_filter_free(filter); +} +#endif static void mlx4_en_vlan_rx_add_vid(void *arg, struct net_device *dev, u16 vid) { struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + int err; int idx; - u8 field; if (arg != priv) return; - if ((vid == 0) || (vid > 4095)) /* Invalid */ - return; en_dbg(HW, priv, "adding VLAN:%d\n", vid); - idx = vid >> 5; - field = 1 << (vid & 0x1f); - spin_lock(&priv->vlan_lock); - priv->vlgrp_modified = true; - if (priv->vlan_unregister[idx] & field) - priv->vlan_unregister[idx] &= ~field; - else - priv->vlan_register[idx] |= field; - priv->vlans[idx] |= field; - spin_unlock(&priv->vlan_lock); + + set_bit(vid, priv->active_vlans); + + /* Add VID to port VLAN filter */ + mutex_lock(&mdev->state_lock); + if (mdev->device_up && priv->port_up) { + err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); + if (err) + en_err(priv, "Failed configuring VLAN filter\n"); + } + if (mlx4_register_vlan(mdev->dev, priv->port, vid, &idx)) + en_dbg(HW, priv, "failed adding vlan %d\n", vid); + mutex_unlock(&mdev->state_lock); + } static void mlx4_en_vlan_rx_kill_vid(void *arg, struct net_device *dev, u16 vid) { struct mlx4_en_priv *priv = netdev_priv(dev); - int idx; - u8 field; + struct mlx4_en_dev *mdev = priv->mdev; + int err; if (arg != priv) return; - if ((vid == 0) || (vid > 4095)) /* Invalid */ - return; en_dbg(HW, priv, "Killing VID:%d\n", vid); - idx = vid >> 5; - field = 1 << (vid & 0x1f); - spin_lock(&priv->vlan_lock); - priv->vlgrp_modified = true; - if (priv->vlan_register[idx] & field) - priv->vlan_register[idx] &= ~field; - else - priv->vlan_unregister[idx] |= field; - priv->vlans[idx] &= ~field; - spin_unlock(&priv->vlan_lock); + + clear_bit(vid, priv->active_vlans); + + /* Remove VID from port VLAN filter */ + mutex_lock(&mdev->state_lock); + mlx4_unregister_vlan(mdev->dev, priv->port, vid); + + if (mdev->device_up && priv->port_up) { + err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); + if (err) + en_err(priv, "Failed configuring VLAN filter\n"); + } + mutex_unlock(&mdev->state_lock); + } -u64 mlx4_en_mac_to_u64(u8 *addr) +static int mlx4_en_uc_steer_add(struct mlx4_en_priv *priv, + unsigned char *mac, int *qpn, u64 *reg_id) { - u64 mac = 0; - int i; + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_dev *dev = mdev->dev; + int err; - for (i = 0; i < ETHER_ADDR_LEN; i++) { - mac <<= 8; - mac |= addr[i]; + switch (dev->caps.steering_mode) { + case MLX4_STEERING_MODE_B0: { + struct mlx4_qp qp; + u8 gid[16] = {0}; + + qp.qpn = *qpn; + memcpy(&gid[10], mac, ETH_ALEN); + gid[5] = priv->port; + + err = mlx4_unicast_attach(dev, &qp, gid, 0, MLX4_PROT_ETH); + break; } - return mac; + case MLX4_STEERING_MODE_DEVICE_MANAGED: { + struct mlx4_spec_list spec_eth = { {NULL} }; + __be64 mac_mask = cpu_to_be64(MLX4_MAC_MASK << 16); + + struct mlx4_net_trans_rule rule = { + .queue_mode = MLX4_NET_TRANS_Q_FIFO, + .exclusive = 0, + .allow_loopback = 1, + .promisc_mode = MLX4_FS_REGULAR, + .priority = MLX4_DOMAIN_NIC, + }; + + rule.port = priv->port; + rule.qpn = *qpn; + INIT_LIST_HEAD(&rule.list); + + spec_eth.id = MLX4_NET_TRANS_RULE_ID_ETH; + memcpy(spec_eth.eth.dst_mac, mac, ETH_ALEN); + memcpy(spec_eth.eth.dst_mac_msk, &mac_mask, ETH_ALEN); + list_add_tail(&spec_eth.list, &rule.list); + + err = mlx4_flow_attach(dev, &rule, reg_id); + break; + } + default: + return -EINVAL; + } + if (err) + en_warn(priv, "Failed Attaching Unicast\n"); + + return err; } -static int mlx4_en_cache_mclist(struct net_device *dev, u64 **mcaddrp) +static void mlx4_en_uc_steer_release(struct mlx4_en_priv *priv, + unsigned char *mac, int qpn, u64 reg_id) { - struct ifmultiaddr *ifma; - u64 *mcaddr; - int cnt; - int i; + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_dev *dev = mdev->dev; - *mcaddrp = NULL; -restart: - cnt = 0; - if_maddr_rlock(dev); - TAILQ_FOREACH(ifma, &dev->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - if (((struct sockaddr_dl *)ifma->ifma_addr)->sdl_alen != - ETHER_ADDR_LEN) - continue; - cnt++; + switch (dev->caps.steering_mode) { + case MLX4_STEERING_MODE_B0: { + struct mlx4_qp qp; + u8 gid[16] = {0}; + + qp.qpn = qpn; + memcpy(&gid[10], mac, ETH_ALEN); + gid[5] = priv->port; + + mlx4_unicast_detach(dev, &qp, gid, MLX4_PROT_ETH); + break; } - if_maddr_runlock(dev); - if (cnt == 0) - return (0); - mcaddr = kmalloc(sizeof(u64) * cnt, GFP_KERNEL); - if (mcaddr == NULL) - return (0); - i = 0; - if_maddr_rlock(dev); - TAILQ_FOREACH(ifma, &dev->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - if (((struct sockaddr_dl *)ifma->ifma_addr)->sdl_alen != - ETHER_ADDR_LEN) - continue; - /* Make sure the list didn't grow. */ - if (i == cnt) { - if_maddr_runlock(dev); - kfree(mcaddr); - goto restart; + case MLX4_STEERING_MODE_DEVICE_MANAGED: { + mlx4_flow_detach(dev, reg_id); + break; + } + default: + en_err(priv, "Invalid steering mode.\n"); + } +} + +static int mlx4_en_get_qp(struct mlx4_en_priv *priv) +{ + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_dev *dev = mdev->dev; + struct mlx4_mac_entry *entry; + int index = 0; + int err = 0; + u64 reg_id; + int *qpn = &priv->base_qpn; + u64 mac = mlx4_mac_to_u64(IF_LLADDR(priv->dev)); + + en_dbg(DRV, priv, "Registering MAC: %pM for adding\n", + IF_LLADDR(priv->dev)); + index = mlx4_register_mac(dev, priv->port, mac); + if (index < 0) { + err = index; + en_err(priv, "Failed adding MAC: %pM\n", + IF_LLADDR(priv->dev)); + return err; + } + + if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) { + int base_qpn = mlx4_get_base_qpn(dev, priv->port); + *qpn = base_qpn + index; + return 0; + } + + err = mlx4_qp_reserve_range(dev, 1, 1, qpn, 0); + en_dbg(DRV, priv, "Reserved qp %d\n", *qpn); + if (err) { + en_err(priv, "Failed to reserve qp for mac registration\n"); + goto qp_err; + } + + err = mlx4_en_uc_steer_add(priv, IF_LLADDR(priv->dev), qpn, ®_id); + if (err) + goto steer_err; + + entry = kmalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) { + err = -ENOMEM; + goto alloc_err; + } + memcpy(entry->mac, IF_LLADDR(priv->dev), sizeof(entry->mac)); + entry->reg_id = reg_id; + + hlist_add_head(&entry->hlist, + &priv->mac_hash[entry->mac[MLX4_EN_MAC_HASH_IDX]]); + + return 0; + +alloc_err: + mlx4_en_uc_steer_release(priv, IF_LLADDR(priv->dev), *qpn, reg_id); + +steer_err: + mlx4_qp_release_range(dev, *qpn, 1); + +qp_err: + mlx4_unregister_mac(dev, priv->port, mac); + return err; +} + +static void mlx4_en_put_qp(struct mlx4_en_priv *priv) +{ + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_dev *dev = mdev->dev; + int qpn = priv->base_qpn; + u64 mac; + + if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) { + mac = mlx4_mac_to_u64(IF_LLADDR(priv->dev)); + en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", + IF_LLADDR(priv->dev)); + mlx4_unregister_mac(dev, priv->port, mac); + } else { + struct mlx4_mac_entry *entry; + struct hlist_node *n, *tmp; + struct hlist_head *bucket; + unsigned int i; + + for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) { + bucket = &priv->mac_hash[i]; + hlist_for_each_entry_safe(entry, n, tmp, bucket, hlist) { + mac = mlx4_mac_to_u64(entry->mac); + en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", + entry->mac); + mlx4_en_uc_steer_release(priv, entry->mac, + qpn, entry->reg_id); + + mlx4_unregister_mac(dev, priv->port, mac); + hlist_del(&entry->hlist); + kfree(entry); + } } - mcaddr[i++] = mlx4_en_mac_to_u64( - LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); + + en_dbg(DRV, priv, "Releasing qp: port %d, qpn %d\n", + priv->port, qpn); + mlx4_qp_release_range(dev, qpn, 1); + priv->flags &= ~MLX4_EN_FLAG_FORCE_PROMISC; } - if_maddr_runlock(dev); - *mcaddrp = mcaddr; - return (i); } -static void mlx4_en_stop_port(struct net_device *dev) +static void mlx4_en_clear_list(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); - - queue_work(priv->mdev->workqueue, &priv->stop_port_task); + struct mlx4_en_mc_list *tmp, *mc_to_del; + + list_for_each_entry_safe(mc_to_del, tmp, &priv->mc_list, list) { + list_del(&mc_to_del->list); + kfree(mc_to_del); + } } -static void mlx4_en_start_port(struct net_device *dev) +static void mlx4_en_cache_mclist(struct net_device *dev) { + struct ifmultiaddr *ifma; + struct mlx4_en_mc_list *tmp; struct mlx4_en_priv *priv = netdev_priv(dev); - queue_work(priv->mdev->workqueue, &priv->start_port_task); + TAILQ_FOREACH(ifma, &dev->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + if (((struct sockaddr_dl *)ifma->ifma_addr)->sdl_alen != + ETHER_ADDR_LEN) + continue; + /* Make sure the list didn't grow. */ + tmp = kzalloc(sizeof(struct mlx4_en_mc_list), GFP_ATOMIC); + memcpy(tmp->addr, + LLADDR((struct sockaddr_dl *)ifma->ifma_addr), ETH_ALEN); + list_add_tail(&tmp->list, &priv->mc_list); + } } -static void mlx4_en_set_multicast(struct net_device *dev) +static void update_mclist_flags(struct mlx4_en_priv *priv, + struct list_head *dst, + struct list_head *src) +{ + struct mlx4_en_mc_list *dst_tmp, *src_tmp, *new_mc; + bool found; + + /* Find all the entries that should be removed from dst, + * These are the entries that are not found in src + */ + list_for_each_entry(dst_tmp, dst, list) { + found = false; + list_for_each_entry(src_tmp, src, list) { + if (!memcmp(dst_tmp->addr, src_tmp->addr, ETH_ALEN)) { + found = true; + break; + } + } + if (!found) + dst_tmp->action = MCLIST_REM; + } + + /* Add entries that exist in src but not in dst + * mark them as need to add + */ + list_for_each_entry(src_tmp, src, list) { + found = false; + list_for_each_entry(dst_tmp, dst, list) { + if (!memcmp(dst_tmp->addr, src_tmp->addr, ETH_ALEN)) { + dst_tmp->action = MCLIST_NONE; + found = true; + break; + } + } + if (!found) { + new_mc = kmalloc(sizeof(struct mlx4_en_mc_list), + GFP_KERNEL); + if (!new_mc) { + en_err(priv, "Failed to allocate current multicast list\n"); + return; + } + memcpy(new_mc, src_tmp, + sizeof(struct mlx4_en_mc_list)); + new_mc->action = MCLIST_ADD; + list_add_tail(&new_mc->list, dst); + } + } +} + +static void mlx4_en_set_rx_mode(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); if (!priv->port_up) return; - queue_work(priv->mdev->workqueue, &priv->mcast_task); + queue_work(priv->mdev->workqueue, &priv->rx_mode_task); } -static void mlx4_en_do_set_multicast(struct work_struct *work) +static void mlx4_en_set_promisc_mode(struct mlx4_en_priv *priv, + struct mlx4_en_dev *mdev) { - struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, - mcast_task); - struct net_device *dev = priv->dev; - struct mlx4_en_dev *mdev = priv->mdev; - int err; + int err = 0; + if (!(priv->flags & MLX4_EN_FLAG_PROMISC)) { + priv->flags |= MLX4_EN_FLAG_PROMISC; - mutex_lock(&mdev->state_lock); - if (!mdev->device_up) { - en_dbg(HW, priv, "Card is not up, " - "ignoring multicast change.\n"); - goto out; - } - if (!priv->port_up) { - en_dbg(HW, priv, "Port is down, " - "ignoring multicast change.\n"); - goto out; - } - - /* - * Promsicuous mode: disable all filters - */ - - if (dev->if_flags & IFF_PROMISC) { - if (!(priv->flags & MLX4_EN_FLAG_PROMISC)) { - priv->flags |= MLX4_EN_FLAG_PROMISC; - - /* Enable promiscouos mode */ - err = mlx4_SET_PORT_qpn_calc(mdev->dev, priv->port, - priv->base_qpn, 1); + /* Enable promiscouos mode */ + switch (mdev->dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + err = mlx4_flow_steer_promisc_add(mdev->dev, + priv->port, + priv->base_qpn, + MLX4_FS_ALL_DEFAULT); if (err) - en_err(priv, "Failed enabling " - "promiscous mode\n"); + en_err(priv, "Failed enabling promiscuous mode\n"); + priv->flags |= MLX4_EN_FLAG_MC_PROMISC; + break; - /* Disable port multicast filter (unconditionally) */ - err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, - 0, MLX4_MCAST_DISABLE); + case MLX4_STEERING_MODE_B0: + err = mlx4_unicast_promisc_add(mdev->dev, + priv->base_qpn, + priv->port); if (err) - en_err(priv, "Failed disabling " - "multicast filter\n"); + en_err(priv, "Failed enabling unicast promiscuous mode\n"); - /* Disable port VLAN filter */ - err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, NULL); + /* Add the default qp number as multicast + * promisc + */ + if (!(priv->flags & MLX4_EN_FLAG_MC_PROMISC)) { + err = mlx4_multicast_promisc_add(mdev->dev, + priv->base_qpn, + priv->port); + if (err) + en_err(priv, "Failed enabling multicast promiscuous mode\n"); + priv->flags |= MLX4_EN_FLAG_MC_PROMISC; + } + break; + + case MLX4_STEERING_MODE_A0: + err = mlx4_SET_PORT_qpn_calc(mdev->dev, + priv->port, + priv->base_qpn, + 1); if (err) - en_err(priv, "Failed disabling VLAN filter\n"); + en_err(priv, "Failed enabling promiscuous mode\n"); + break; } - goto out; + + /* Disable port multicast filter (unconditionally) */ + err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, + 0, MLX4_MCAST_DISABLE); + if (err) + en_err(priv, "Failed disabling multicast filter\n"); } +} - /* - * Not in promiscous mode - */ +static void mlx4_en_clear_promisc_mode(struct mlx4_en_priv *priv, + struct mlx4_en_dev *mdev) +{ + int err = 0; - if (priv->flags & MLX4_EN_FLAG_PROMISC) { - priv->flags &= ~MLX4_EN_FLAG_PROMISC; + priv->flags &= ~MLX4_EN_FLAG_PROMISC; - /* Disable promiscouos mode */ - err = mlx4_SET_PORT_qpn_calc(mdev->dev, priv->port, + /* Disable promiscouos mode */ + switch (mdev->dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + err = mlx4_flow_steer_promisc_remove(mdev->dev, + priv->port, + MLX4_FS_ALL_DEFAULT); + if (err) + en_err(priv, "Failed disabling promiscuous mode\n"); + priv->flags &= ~MLX4_EN_FLAG_MC_PROMISC; + break; + + case MLX4_STEERING_MODE_B0: + err = mlx4_unicast_promisc_remove(mdev->dev, + priv->base_qpn, + priv->port); + if (err) + en_err(priv, "Failed disabling unicast promiscuous mode\n"); + /* Disable Multicast promisc */ + if (priv->flags & MLX4_EN_FLAG_MC_PROMISC) { + err = mlx4_multicast_promisc_remove(mdev->dev, + priv->base_qpn, + priv->port); + if (err) + en_err(priv, "Failed disabling multicast promiscuous mode\n"); + priv->flags &= ~MLX4_EN_FLAG_MC_PROMISC; + } + break; + + case MLX4_STEERING_MODE_A0: + err = mlx4_SET_PORT_qpn_calc(mdev->dev, + priv->port, priv->base_qpn, 0); if (err) - en_err(priv, "Failed disabling promiscous mode\n"); - - /* Enable port VLAN filter */ - err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlans); - if (err) - en_err(priv, "Failed enabling VLAN filter\n"); + en_err(priv, "Failed disabling promiscuous mode\n"); + break; } +} + +static void mlx4_en_do_multicast(struct mlx4_en_priv *priv, + struct net_device *dev, + struct mlx4_en_dev *mdev) +{ + struct mlx4_en_mc_list *mclist, *tmp; + u8 mc_list[16] = {0}; + int err = 0; + u64 mcast_addr = 0; + /* Enable/disable the multicast filter according to IFF_ALLMULTI */ if (dev->if_flags & IFF_ALLMULTI) { @@ -253,10 +841,53 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) 0, MLX4_MCAST_DISABLE); if (err) en_err(priv, "Failed disabling multicast filter\n"); + + /* Add the default qp number as multicast promisc */ + if (!(priv->flags & MLX4_EN_FLAG_MC_PROMISC)) { + switch (mdev->dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + err = mlx4_flow_steer_promisc_add(mdev->dev, + priv->port, + priv->base_qpn, + MLX4_FS_MC_DEFAULT); + break; + + case MLX4_STEERING_MODE_B0: + err = mlx4_multicast_promisc_add(mdev->dev, + priv->base_qpn, + priv->port); + break; + + case MLX4_STEERING_MODE_A0: + break; + } + if (err) + en_err(priv, "Failed entering multicast promisc mode\n"); + priv->flags |= MLX4_EN_FLAG_MC_PROMISC; + } } else { - u64 *mcaddr; - int mccount; - int i; + /* Disable Multicast promisc */ + if (priv->flags & MLX4_EN_FLAG_MC_PROMISC) { + switch (mdev->dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + err = mlx4_flow_steer_promisc_remove(mdev->dev, + priv->port, + MLX4_FS_MC_DEFAULT); + break; + + case MLX4_STEERING_MODE_B0: + err = mlx4_multicast_promisc_remove(mdev->dev, + priv->base_qpn, + priv->port); + break; + + case MLX4_STEERING_MODE_A0: + break; + } + if (err) + en_err(priv, "Failed disabling multicast promiscuous mode\n"); + priv->flags &= ~MLX4_EN_FLAG_MC_PROMISC; + } err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 0, MLX4_MCAST_DISABLE); @@ -269,17 +900,93 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) /* Update multicast list - we cache all addresses so they won't * change while HW is updated holding the command semaphor */ - mccount = mlx4_en_cache_mclist(dev, &mcaddr); - for (i = 0; i < mccount; i++) + mlx4_en_cache_mclist(dev); + list_for_each_entry(mclist, &priv->mc_list, list) { + mcast_addr = mlx4_mac_to_u64(mclist->addr); mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, - mcaddr[i], 0, MLX4_MCAST_CONFIG); + mcast_addr, 0, MLX4_MCAST_CONFIG); + } err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 0, MLX4_MCAST_ENABLE); if (err) en_err(priv, "Failed enabling multicast filter\n"); - kfree(mcaddr); + update_mclist_flags(priv, &priv->curr_list, &priv->mc_list); + list_for_each_entry_safe(mclist, tmp, &priv->curr_list, list) { + if (mclist->action == MCLIST_REM) { + /* detach this address and delete from list */ + memcpy(&mc_list[10], mclist->addr, ETH_ALEN); + mc_list[5] = priv->port; + err = mlx4_multicast_detach(mdev->dev, + &priv->rss_map.indir_qp, + mc_list, + MLX4_PROT_ETH, + mclist->reg_id); + if (err) + en_err(priv, "Fail to detach multicast address\n"); + + /* remove from list */ + list_del(&mclist->list); + kfree(mclist); + } else if (mclist->action == MCLIST_ADD) { + /* attach the address */ + memcpy(&mc_list[10], mclist->addr, ETH_ALEN); + /* needed for B0 steering support */ + mc_list[5] = priv->port; + err = mlx4_multicast_attach(mdev->dev, + &priv->rss_map.indir_qp, + mc_list, + priv->port, 0, + MLX4_PROT_ETH, + &mclist->reg_id); + if (err) + en_err(priv, "Fail to attach multicast address\n"); + + } + } } +} + +static void mlx4_en_do_set_rx_mode(struct work_struct *work) +{ + struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, + rx_mode_task); + struct mlx4_en_dev *mdev = priv->mdev; + struct net_device *dev = priv->dev; + + + mutex_lock(&mdev->state_lock); + if (!mdev->device_up) { + en_dbg(HW, priv, "Card is not up, ignoring rx mode change.\n"); + goto out; + } + if (!priv->port_up) { + en_dbg(HW, priv, "Port is down, ignoring rx mode change.\n"); + goto out; + } + if (!mlx4_en_QUERY_PORT(mdev, priv->port)) { + if (priv->port_state.link_state) { + priv->last_link_state = MLX4_DEV_EVENT_PORT_UP; + /* Important note: the following call for if_link_state_change + * is needed for interface up scenario (start port, link state + * change) */ + if_link_state_change(priv->dev, LINK_STATE_UP); + en_dbg(HW, priv, "Link Up\n"); + } + } + + /* Promsicuous mode: disable all filters */ + if ((dev->if_flags & IFF_PROMISC) || + (priv->flags & MLX4_EN_FLAG_FORCE_PROMISC)) { + mlx4_en_set_promisc_mode(priv, mdev); + goto out; + } + + /* Not in promiscuous mode */ + if (priv->flags & MLX4_EN_FLAG_PROMISC) + mlx4_en_clear_promisc_mode(priv, mdev); + + mlx4_en_do_multicast(priv, dev, mdev); out: mutex_unlock(&mdev->state_lock); } @@ -293,7 +1000,7 @@ static void mlx4_en_netpoll(struct net_device *dev) int i; for (i = 0; i < priv->rx_ring_num; i++) { - cq = &priv->rx_cq[i]; + cq = priv->rx_cq[i]; spin_lock_irqsave(&cq->lock, flags); napi_synchronize(&cq->napi); mlx4_en_process_rx_cq(dev, cq, 0); @@ -304,38 +1011,40 @@ static void mlx4_en_netpoll(struct net_device *dev) static void mlx4_en_watchdog_timeout(void *arg) { - struct mlx4_en_priv *priv = arg; - struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_priv *priv = arg; + struct mlx4_en_dev *mdev = priv->mdev; - en_dbg(DRV, priv, "Scheduling watchdog\n"); - queue_work(mdev->workqueue, &priv->watchdog_task); - if (priv->port_up) - callout_reset(&priv->watchdog_timer, MLX4_EN_WATCHDOG_TIMEOUT, - mlx4_en_watchdog_timeout, priv); + en_dbg(DRV, priv, "Scheduling watchdog\n"); + queue_work(mdev->workqueue, &priv->watchdog_task); + if (priv->port_up) + callout_reset(&priv->watchdog_timer, MLX4_EN_WATCHDOG_TIMEOUT, + mlx4_en_watchdog_timeout, priv); } -/* XXX This clears user settings in too many cases. */ + static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv) { struct mlx4_en_cq *cq; int i; /* If we haven't received a specific coalescing setting - * (module param), we set the moderation paramters as follows: + * (module param), we set the moderation parameters as follows: * - moder_cnt is set to the number of mtu sized packets to * satisfy our coelsing target. * - moder_time is set to a fixed value. */ priv->rx_frames = MLX4_EN_RX_COAL_TARGET / priv->dev->if_mtu + 1; priv->rx_usecs = MLX4_EN_RX_COAL_TIME; - en_dbg(INTR, priv, "Default coalesing params for mtu:%u - " - "rx_frames:%d rx_usecs:%d\n", - priv->dev->if_mtu, priv->rx_frames, priv->rx_usecs); + priv->tx_frames = MLX4_EN_TX_COAL_PKTS; + priv->tx_usecs = MLX4_EN_TX_COAL_TIME; + en_dbg(INTR, priv, "Default coalesing params for mtu: %u - " + "rx_frames:%d rx_usecs:%d\n", + (unsigned)priv->dev->if_mtu, priv->rx_frames, priv->rx_usecs); /* Setup cq moderation params */ for (i = 0; i < priv->rx_ring_num; i++) { - cq = &priv->rx_cq[i]; + cq = priv->rx_cq[i]; cq->moder_cnt = priv->rx_frames; cq->moder_time = priv->rx_usecs; priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; @@ -344,9 +1053,9 @@ static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv) } for (i = 0; i < priv->tx_ring_num; i++) { - cq = &priv->tx_cq[i]; - cq->moder_cnt = MLX4_EN_TX_COAL_PKTS; - cq->moder_time = MLX4_EN_TX_COAL_TIME; + cq = priv->tx_cq[i]; + cq->moder_cnt = priv->tx_frames; + cq->moder_time = priv->tx_usecs; } /* Reset auto-moderation params */ @@ -375,10 +1084,11 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv) if (!priv->adaptive_rx_coal || period < priv->sample_interval * HZ) return; + for (ring = 0; ring < priv->rx_ring_num; ring++) { - spin_lock(&priv->stats_lock); - rx_packets = priv->rx_ring[ring].packets; - rx_bytes = priv->rx_ring[ring].bytes; + spin_lock(&priv->stats_lock); + rx_packets = priv->rx_ring[ring]->packets; + rx_bytes = priv->rx_ring[ring]->bytes; spin_unlock(&priv->stats_lock); rx_pkt_diff = ((unsigned long) (rx_packets - @@ -389,11 +1099,10 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv) priv->last_moder_bytes[ring])) / packets : 0; /* Apply auto-moderation only when packet rate - * exceeds a rate that it matters */ + * exceeds a rate that it matters */ if (rate > (MLX4_EN_RX_RATE_THRESH / priv->rx_ring_num) && - avg_pkt_size > MLX4_EN_AVG_PKT_SMALL) { - if (rate < priv->pkt_rate_low || - avg_pkt_size < MLX4_EN_AVG_PKT_SMALL) + avg_pkt_size > MLX4_EN_AVG_PKT_SMALL) { + if (rate < priv->pkt_rate_low) moder_time = priv->rx_usecs_low; else if (rate > priv->pkt_rate_high) moder_time = priv->rx_usecs_high; @@ -408,12 +1117,12 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv) if (moder_time != priv->last_moder_time[ring]) { priv->last_moder_time[ring] = moder_time; - cq = &priv->rx_cq[ring]; + cq = priv->rx_cq[ring]; cq->moder_time = moder_time; err = mlx4_en_set_cq_moder(priv, cq); if (err) - en_err(priv, "Failed modifying moderation " - "for cq:%d\n", ring); + en_err(priv, "Failed modifying moderation for cq:%d\n", + ring); } priv->last_moder_packets[ring] = rx_packets; priv->last_moder_bytes[ring] = rx_bytes; @@ -422,47 +1131,6 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv) priv->last_moder_jiffies = jiffies; } -static void mlx4_en_handle_vlans(struct mlx4_en_priv *priv) -{ - u8 vlan_register[VLAN_FLTR_SIZE]; - u8 vlan_unregister[VLAN_FLTR_SIZE]; - int i, j, idx; - u16 vid; - - /* cache the vlan data for processing - * done under lock to avoid changes during work */ - spin_lock(&priv->vlan_lock); - for (i = 0; i < VLAN_FLTR_SIZE; i++) { - vlan_register[i] = priv->vlan_register[i]; - priv->vlan_register[i] = 0; - vlan_unregister[i] = priv->vlan_unregister[i]; - priv->vlan_unregister[i] = 0; - } - priv->vlgrp_modified = false; - spin_unlock(&priv->vlan_lock); - - /* Configure the vlan filter - * The vlgrp is updated with all the vids that need to be allowed */ - if (mlx4_SET_VLAN_FLTR(priv->mdev->dev, priv->port, priv->vlans)) - en_err(priv, "Failed configuring VLAN filter\n"); - - /* Configure the VLAN table */ - for (i = 0; i < VLAN_FLTR_SIZE; i++) { - for (j = 0; j < 32; j++) { - vid = (i << 5) + j; - if (vlan_register[i] & (1 << j)) - if (mlx4_register_vlan(priv->mdev->dev, priv->port, vid, &idx)) - en_dbg(HW, priv, "failed registering vlan %d\n", vid); - if (vlan_unregister[i] & (1 << j)) { - if (!mlx4_find_cached_vlan(priv->mdev->dev, priv->port, vid, &idx)) - mlx4_unregister_vlan(priv->mdev->dev, priv->port, idx); - else - en_dbg(HW, priv, "could not find vid %d in cache\n", vid); - } - } - } -} - static void mlx4_en_do_get_stats(struct work_struct *work) { struct delayed_work *delay = to_delayed_work(work); @@ -471,23 +1139,36 @@ static void mlx4_en_do_get_stats(struct work_struct *work) struct mlx4_en_dev *mdev = priv->mdev; int err; - err = mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 0); - if (err) - en_dbg(HW, priv, "Could not update stats \n"); - - mutex_lock(&mdev->state_lock); if (mdev->device_up) { if (priv->port_up) { - if (priv->vlgrp_modified) - mlx4_en_handle_vlans(priv); + err = mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 0); + if (err) + en_dbg(HW, priv, "Could not update stats\n"); mlx4_en_auto_moderation(priv); } queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY); } - mlx4_en_QUERY_PORT(priv->mdev, priv->port); + mutex_unlock(&mdev->state_lock); +} + +/* mlx4_en_service_task - Run service task for tasks that needed to be done + * periodically + */ +static void mlx4_en_service_task(struct work_struct *work) +{ + struct delayed_work *delay = to_delayed_work(work); + struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, + service_task); + struct mlx4_en_dev *mdev = priv->mdev; + + mutex_lock(&mdev->state_lock); + if (mdev->device_up) { + queue_delayed_work(mdev->workqueue, &priv->service_task, + SERVICE_TASK_DELAY); + } mutex_unlock(&mdev->state_lock); } @@ -503,8 +1184,15 @@ static void mlx4_en_linkstate(struct work_struct *work) * report to system log */ if (priv->last_link_state != linkstate) { if (linkstate == MLX4_DEV_EVENT_PORT_DOWN) { + en_info(priv, "Link Down\n"); if_link_state_change(priv->dev, LINK_STATE_DOWN); - } else { + /* make sure the port is up before notifying the OS. + * This is tricky since we get here on INIT_PORT and + * in such case we can't tell the OS the port is up. + * To solve this there is a call to if_link_state_change + * in set_rx_mode. + * */ + } else if (priv->port_up && (linkstate == MLX4_DEV_EVENT_PORT_UP)){ en_info(priv, "Link Up\n"); if_link_state_change(priv->dev, LINK_STATE_UP); } @@ -513,51 +1201,38 @@ static void mlx4_en_linkstate(struct work_struct *work) mutex_unlock(&mdev->state_lock); } -static void mlx4_en_lock_and_stop_port(struct work_struct *work) -{ - struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, - stop_port_task); - struct net_device *dev = priv->dev; - struct mlx4_en_dev *mdev = priv->mdev; - - mutex_lock(&mdev->state_lock); - mlx4_en_do_stop_port(dev); - mutex_unlock(&mdev->state_lock); -} -static void mlx4_en_lock_and_start_port(struct work_struct *work) -{ - struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, - start_port_task); - struct net_device *dev = priv->dev; - struct mlx4_en_dev *mdev = priv->mdev; - - mutex_lock(&mdev->state_lock); - mlx4_en_do_start_port(dev); - mutex_unlock(&mdev->state_lock); -} - -int mlx4_en_do_start_port(struct net_device *dev) +int mlx4_en_start_port(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_cq *cq; struct mlx4_en_tx_ring *tx_ring; - u64 config; int rx_index = 0; int tx_index = 0; int err = 0; int i; int j; + u8 mc_list[16] = {0}; + if (priv->port_up) { en_dbg(DRV, priv, "start port called while port already up\n"); return 0; } + INIT_LIST_HEAD(&priv->mc_list); + INIT_LIST_HEAD(&priv->curr_list); + INIT_LIST_HEAD(&priv->ethtool_list); + /* Calculate Rx buf size */ dev->if_mtu = min(dev->if_mtu, priv->max_mtu); - mlx4_en_calc_rx_buf(dev); + mlx4_en_calc_rx_buf(dev); + priv->rx_alloc_size = max_t(int, 2 * roundup_pow_of_two(priv->rx_mb_size), + PAGE_SIZE); + priv->rx_alloc_order = get_order(priv->rx_alloc_size); + priv->rx_buf_size = roundup_pow_of_two(priv->rx_mb_size); + priv->log_rx_info = ROUNDUP_LOG2(sizeof(struct mlx4_en_rx_buf)); en_dbg(DRV, priv, "Rx buf size:%d\n", priv->rx_mb_size); /* Configure rx cq's and rings */ @@ -566,11 +1241,11 @@ int mlx4_en_do_start_port(struct net_device *dev) en_err(priv, "Failed to activate RX rings\n"); return err; } - for (i = 0; i < priv->rx_ring_num; i++) { - cq = &priv->rx_cq[i]; + cq = priv->rx_cq[i]; - err = mlx4_en_activate_cq(priv, cq); + mlx4_en_cq_init_lock(cq); + err = mlx4_en_activate_cq(priv, cq, i); if (err) { en_err(priv, "Failed activating Rx CQ\n"); goto cq_err; @@ -584,21 +1259,41 @@ int mlx4_en_do_start_port(struct net_device *dev) goto cq_err; } mlx4_en_arm_cq(priv, cq); - priv->rx_ring[i].cqn = cq->mcq.cqn; + priv->rx_ring[i]->cqn = cq->mcq.cqn; ++rx_index; } + /* Set qp number */ + en_dbg(DRV, priv, "Getting qp number for port %d\n", priv->port); + err = mlx4_en_get_qp(priv); + if (err) { + en_err(priv, "Failed getting eth qp\n"); + goto cq_err; + } + mdev->mac_removed[priv->port] = 0; + + /* gets default allocated counter index from func cap */ + /* or sink counter index if no resources */ + priv->counter_index = mdev->dev->caps.def_counter_index[priv->port - 1]; + + en_dbg(DRV, priv, "%s: default counter index %d for port %d\n", + __func__, priv->counter_index, priv->port); + err = mlx4_en_config_rss_steer(priv); if (err) { en_err(priv, "Failed configuring rss steering\n"); - goto cq_err; + goto mac_err; } + err = mlx4_en_create_drop_qp(priv); + if (err) + goto rss_err; + /* Configure tx cq's and rings */ for (i = 0; i < priv->tx_ring_num; i++) { /* Configure cq */ - cq = &priv->tx_cq[i]; - err = mlx4_en_activate_cq(priv, cq); + cq = priv->tx_cq[i]; + err = mlx4_en_activate_cq(priv, cq, i); if (err) { en_err(priv, "Failed allocating Tx CQ\n"); goto tx_err; @@ -613,13 +1308,19 @@ int mlx4_en_do_start_port(struct net_device *dev) cq->buf->wqe_index = cpu_to_be16(0xffff); /* Configure ring */ - tx_ring = &priv->tx_ring[i]; - err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn); + tx_ring = priv->tx_ring[i]; + + err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn, + i / priv->num_tx_rings_p_up); if (err) { en_err(priv, "Failed allocating Tx ring\n"); mlx4_en_deactivate_cq(priv, cq); goto tx_err; } + + /* Arm CQ for TX completions */ + mlx4_en_arm_cq(priv, cq); + /* Set initial ownership of all Tx TXBBs to SW (1) */ for (j = 0; j < tx_ring->buf_size; j += STAMP_STRIDE) *((u32 *) (tx_ring->buf + j)) = 0xffffffff; @@ -628,14 +1329,14 @@ int mlx4_en_do_start_port(struct net_device *dev) /* Configure port */ err = mlx4_SET_PORT_general(mdev->dev, priv->port, - priv->rx_mb_size + ETHER_CRC_LEN, + priv->rx_mb_size, priv->prof->tx_pause, priv->prof->tx_ppp, priv->prof->rx_pause, priv->prof->rx_ppp); if (err) { - en_err(priv, "Failed setting port general configurations " - "for port %d, with error %d\n", priv->port, err); + en_err(priv, "Failed setting port general configurations for port %d, with error %d\n", + priv->port, err); goto tx_err; } /* Set default qp number */ @@ -644,134 +1345,166 @@ int mlx4_en_do_start_port(struct net_device *dev) en_err(priv, "Failed setting default qp numbers\n"); goto tx_err; } - /* Set port mac number */ - en_dbg(DRV, priv, "Setting mac for port %d\n", priv->port); - err = mlx4_register_mac(mdev->dev, priv->port, - mlx4_en_mac_to_u64(IF_LLADDR(dev))); - if (err < 0) { - en_err(priv, "Failed setting port mac err=%d\n", err); - goto tx_err; - } - mdev->mac_removed[priv->port] = 0; /* Init port */ en_dbg(HW, priv, "Initializing port\n"); err = mlx4_INIT_PORT(mdev->dev, priv->port); if (err) { en_err(priv, "Failed Initializing port\n"); - goto mac_err; + goto tx_err; } - /* Set the various hardware offload abilities */ - dev->if_hwassist = 0; - if (dev->if_capenable & IFCAP_TSO4) - dev->if_hwassist |= CSUM_TSO; - if (dev->if_capenable & IFCAP_TXCSUM) - dev->if_hwassist |= (CSUM_TCP | CSUM_UDP | CSUM_IP); - if (dev->if_capenable & IFCAP_RXCSUM) - priv->rx_csum = 1; - else - priv->rx_csum = 0; + /* Attach rx QP to bradcast address */ + memset(&mc_list[10], 0xff, ETH_ALEN); + mc_list[5] = priv->port; /* needed for B0 steering support */ + if (mlx4_multicast_attach(mdev->dev, &priv->rss_map.indir_qp, mc_list, + priv->port, 0, MLX4_PROT_ETH, + &priv->broadcast_id)) + mlx4_warn(mdev, "Failed Attaching Broadcast\n"); - err = mlx4_wol_read(priv->mdev->dev, &config, priv->port); - if (err) { - en_err(priv, "Failed to get WoL info, unable to modify\n"); - goto wol_err; - } - if (dev->if_capenable & IFCAP_WOL_MAGIC) { - config |= MLX4_EN_WOL_DO_MODIFY | MLX4_EN_WOL_ENABLED | - MLX4_EN_WOL_MAGIC; - } else { - config &= ~(MLX4_EN_WOL_ENABLED | MLX4_EN_WOL_MAGIC); - config |= MLX4_EN_WOL_DO_MODIFY; - } + /* Must redo promiscuous mode setup. */ + priv->flags &= ~(MLX4_EN_FLAG_PROMISC | MLX4_EN_FLAG_MC_PROMISC); - err = mlx4_wol_write(priv->mdev->dev, config, priv->port); - if (err) { - en_err(priv, "Failed to set WoL information\n"); - goto wol_err; - } + /* Schedule multicast task to populate multicast list */ + queue_work(mdev->workqueue, &priv->rx_mode_task); + + mlx4_set_stats_bitmap(mdev->dev, priv->stats_bitmap); priv->port_up = true; - /* Populate multicast list */ - mlx4_en_set_multicast(dev); + /* Enable the queues. */ + dev->if_drv_flags &= ~IFF_DRV_OACTIVE; + dev->if_drv_flags |= IFF_DRV_RUNNING; +#ifdef CONFIG_DEBUG_FS + mlx4_en_create_debug_files(priv); +#endif + callout_reset(&priv->watchdog_timer, MLX4_EN_WATCHDOG_TIMEOUT, + mlx4_en_watchdog_timeout, priv); - /* Enable the queues. */ - dev->if_drv_flags &= ~IFF_DRV_OACTIVE; - dev->if_drv_flags |= IFF_DRV_RUNNING; - - callout_reset(&priv->watchdog_timer, MLX4_EN_WATCHDOG_TIMEOUT, - mlx4_en_watchdog_timeout, priv); return 0; -wol_err: - /* close port*/ - mlx4_CLOSE_PORT(mdev->dev, priv->port); - -mac_err: - mlx4_unregister_mac(mdev->dev, priv->port, priv->mac); tx_err: while (tx_index--) { - mlx4_en_deactivate_tx_ring(priv, &priv->tx_ring[tx_index]); - mlx4_en_deactivate_cq(priv, &priv->tx_cq[tx_index]); + mlx4_en_deactivate_tx_ring(priv, priv->tx_ring[tx_index]); + mlx4_en_deactivate_cq(priv, priv->tx_cq[tx_index]); } - + mlx4_en_destroy_drop_qp(priv); +rss_err: mlx4_en_release_rss_steer(priv); +mac_err: + mlx4_en_put_qp(priv); cq_err: while (rx_index--) - mlx4_en_deactivate_cq(priv, &priv->rx_cq[rx_index]); + mlx4_en_deactivate_cq(priv, priv->rx_cq[rx_index]); for (i = 0; i < priv->rx_ring_num; i++) - mlx4_en_deactivate_rx_ring(priv, &priv->rx_ring[i]); + mlx4_en_deactivate_rx_ring(priv, priv->rx_ring[i]); return err; /* need to close devices */ } -void mlx4_en_do_stop_port(struct net_device *dev) +void mlx4_en_stop_port(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_mc_list *mclist, *tmp; int i; + u8 mc_list[16] = {0}; if (!priv->port_up) { en_dbg(DRV, priv, "stop port called while port already down\n"); return; } - /* Set port as not active */ - priv->port_up = false; - - /* Unregister Mac address for the port */ - mlx4_unregister_mac(mdev->dev, priv->port, priv->mac); - mdev->mac_removed[priv->port] = 1; - - /* Free TX Rings */ - for (i = 0; i < priv->tx_ring_num; i++) { - mlx4_en_deactivate_tx_ring(priv, &priv->tx_ring[i]); - mlx4_en_deactivate_cq(priv, &priv->tx_cq[i]); - } - msleep(10); - - for (i = 0; i < priv->tx_ring_num; i++) - mlx4_en_free_tx_buf(dev, &priv->tx_ring[i]); - - /* Free RSS qps */ - mlx4_en_release_rss_steer(priv); - - /* Free RX Rings */ - for (i = 0; i < priv->rx_ring_num; i++) { - mlx4_en_deactivate_rx_ring(priv, &priv->rx_ring[i]); - mlx4_en_deactivate_cq(priv, &priv->rx_cq[i]); - } +#ifdef CONFIG_DEBUG_FS + mlx4_en_delete_debug_files(priv); +#endif /* close port*/ mlx4_CLOSE_PORT(mdev->dev, priv->port); - callout_stop(&priv->watchdog_timer); + /* Set port as not active */ + priv->port_up = false; + if (priv->counter_index != 0xff) { + mlx4_counter_free(mdev->dev, priv->port, priv->counter_index); + priv->counter_index = 0xff; + } - dev->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + /* Promsicuous mode */ + if (mdev->dev->caps.steering_mode == + MLX4_STEERING_MODE_DEVICE_MANAGED) { + priv->flags &= ~(MLX4_EN_FLAG_PROMISC | + MLX4_EN_FLAG_MC_PROMISC); + mlx4_flow_steer_promisc_remove(mdev->dev, + priv->port, + MLX4_FS_ALL_DEFAULT); + mlx4_flow_steer_promisc_remove(mdev->dev, + priv->port, + MLX4_FS_MC_DEFAULT); + } else if (priv->flags & MLX4_EN_FLAG_PROMISC) { + priv->flags &= ~MLX4_EN_FLAG_PROMISC; + + /* Disable promiscouos mode */ + mlx4_unicast_promisc_remove(mdev->dev, priv->base_qpn, + priv->port); + + /* Disable Multicast promisc */ + if (priv->flags & MLX4_EN_FLAG_MC_PROMISC) { + mlx4_multicast_promisc_remove(mdev->dev, priv->base_qpn, + priv->port); + priv->flags &= ~MLX4_EN_FLAG_MC_PROMISC; + } + } + + /* Detach All multicasts */ + memset(&mc_list[10], 0xff, ETH_ALEN); + mc_list[5] = priv->port; /* needed for B0 steering support */ + mlx4_multicast_detach(mdev->dev, &priv->rss_map.indir_qp, mc_list, + MLX4_PROT_ETH, priv->broadcast_id); + list_for_each_entry(mclist, &priv->curr_list, list) { + memcpy(&mc_list[10], mclist->addr, ETH_ALEN); + mc_list[5] = priv->port; + mlx4_multicast_detach(mdev->dev, &priv->rss_map.indir_qp, + mc_list, MLX4_PROT_ETH, mclist->reg_id); + } + mlx4_en_clear_list(dev); + list_for_each_entry_safe(mclist, tmp, &priv->curr_list, list) { + list_del(&mclist->list); + kfree(mclist); + } + + /* Flush multicast filter */ + mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 1, MLX4_MCAST_CONFIG); + mlx4_en_destroy_drop_qp(priv); + + /* Free TX Rings */ + for (i = 0; i < priv->tx_ring_num; i++) { + mlx4_en_deactivate_tx_ring(priv, priv->tx_ring[i]); + mlx4_en_deactivate_cq(priv, priv->tx_cq[i]); + } + msleep(10); + + for (i = 0; i < priv->tx_ring_num; i++) + mlx4_en_free_tx_buf(dev, priv->tx_ring[i]); + + /* Free RSS qps */ + mlx4_en_release_rss_steer(priv); + + /* Unregister Mac address for the port */ + mlx4_en_put_qp(priv); + mdev->mac_removed[priv->port] = 1; + + /* Free RX Rings */ + for (i = 0; i < priv->rx_ring_num; i++) { + struct mlx4_en_cq *cq = priv->rx_cq[i]; + mlx4_en_deactivate_rx_ring(priv, priv->rx_ring[i]); + mlx4_en_deactivate_cq(priv, cq); + } + + callout_stop(&priv->watchdog_timer); + + dev->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); } static void mlx4_en_restart(struct work_struct *work) @@ -783,12 +1516,13 @@ static void mlx4_en_restart(struct work_struct *work) struct mlx4_en_tx_ring *ring; int i; + if (priv->blocked == 0 || priv->port_up == 0) return; for (i = 0; i < priv->tx_ring_num; i++) { - ring = &priv->tx_ring[i]; + ring = priv->tx_ring[i]; if (ring->blocked && - ring->watchdog_time + MLX4_EN_WATCHDOG_TIMEOUT < ticks) + ring->watchdog_time + MLX4_EN_WATCHDOG_TIMEOUT < ticks) goto reset; } return; @@ -799,129 +1533,175 @@ static void mlx4_en_restart(struct work_struct *work) mutex_lock(&mdev->state_lock); if (priv->port_up) { - mlx4_en_do_stop_port(dev); - if (mlx4_en_do_start_port(dev)) + mlx4_en_stop_port(dev); + //for (i = 0; i < priv->tx_ring_num; i++) + // netdev_tx_reset_queue(priv->tx_ring[i]->tx_queue); + if (mlx4_en_start_port(dev)) en_err(priv, "Failed restarting port %d\n", priv->port); } mutex_unlock(&mdev->state_lock); } - -static void -mlx4_en_init(void *arg) +static void mlx4_en_clear_stats(struct net_device *dev) { - struct mlx4_en_priv *priv; - struct mlx4_en_dev *mdev; - - priv = arg; - mdev = priv->mdev; - mutex_lock(&mdev->state_lock); - mlx4_en_init_locked(priv); - mutex_unlock(&mdev->state_lock); -} - -static void -mlx4_en_init_locked(struct mlx4_en_priv *priv) -{ - - struct mlx4_en_dev *mdev; - struct ifnet *dev; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; int i; - dev = priv->dev; - mdev = priv->mdev; - if (dev->if_drv_flags & IFF_DRV_RUNNING) - mlx4_en_do_stop_port(dev); + if (!mlx4_is_slave(mdev->dev)) + if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1)) + en_dbg(HW, priv, "Failed dumping statistics\n"); + + memset(&priv->pstats, 0, sizeof(priv->pstats)); + memset(&priv->pkstats, 0, sizeof(priv->pkstats)); + memset(&priv->port_stats, 0, sizeof(priv->port_stats)); + memset(&priv->vport_stats, 0, sizeof(priv->vport_stats)); + + for (i = 0; i < priv->tx_ring_num; i++) { + priv->tx_ring[i]->bytes = 0; + priv->tx_ring[i]->packets = 0; + priv->tx_ring[i]->tx_csum = 0; + } + for (i = 0; i < priv->rx_ring_num; i++) { + priv->rx_ring[i]->bytes = 0; + priv->rx_ring[i]->packets = 0; + priv->rx_ring[i]->csum_ok = 0; + priv->rx_ring[i]->csum_none = 0; + } +} + +static void mlx4_en_open(void* arg) +{ + + struct mlx4_en_priv *priv; + struct mlx4_en_dev *mdev; + struct net_device *dev; + int err = 0; + + priv = arg; + mdev = priv->mdev; + dev = priv->dev; + + + mutex_lock(&mdev->state_lock); if (!mdev->device_up) { en_err(priv, "Cannot open - device down/disabled\n"); - return; + goto out; } - /* Reset HW statistics and performance counters */ - if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1)) - en_dbg(HW, priv, "Failed dumping statistics\n"); + /* Reset HW statistics and SW counters */ + mlx4_en_clear_stats(dev); - memset(&priv->pstats, 0, sizeof(priv->pstats)); - - for (i = 0; i < priv->tx_ring_num; i++) { - priv->tx_ring[i].bytes = 0; - priv->tx_ring[i].packets = 0; - } - for (i = 0; i < priv->rx_ring_num; i++) { - priv->rx_ring[i].bytes = 0; - priv->rx_ring[i].packets = 0; - } - - mlx4_en_set_default_moderation(priv); - if (mlx4_en_do_start_port(dev)) + err = mlx4_en_start_port(dev); + if (err) en_err(priv, "Failed starting port:%d\n", priv->port); + +out: + mutex_unlock(&mdev->state_lock); + return; } void mlx4_en_free_resources(struct mlx4_en_priv *priv) { int i; +#ifdef CONFIG_RFS_ACCEL + if (priv->dev->rx_cpu_rmap) { + free_irq_cpu_rmap(priv->dev->rx_cpu_rmap); + priv->dev->rx_cpu_rmap = NULL; + } +#endif + for (i = 0; i < priv->tx_ring_num; i++) { - if (priv->tx_ring[i].tx_info) + if (priv->tx_ring && priv->tx_ring[i]) mlx4_en_destroy_tx_ring(priv, &priv->tx_ring[i]); - if (priv->tx_cq[i].buf) + if (priv->tx_cq && priv->tx_cq[i]) mlx4_en_destroy_cq(priv, &priv->tx_cq[i]); } for (i = 0; i < priv->rx_ring_num; i++) { - if (priv->rx_ring[i].rx_info) - mlx4_en_destroy_rx_ring(priv, &priv->rx_ring[i]); - if (priv->rx_cq[i].buf) + if (priv->rx_ring[i]) + mlx4_en_destroy_rx_ring(priv, &priv->rx_ring[i], + priv->prof->rx_ring_size, priv->stride); + if (priv->rx_cq[i]) mlx4_en_destroy_cq(priv, &priv->rx_cq[i]); } - /* Free the stats tree when we resize the rings. */ + if (priv->sysctl) sysctl_ctx_free(&priv->stat_ctx); + } int mlx4_en_alloc_resources(struct mlx4_en_priv *priv) { struct mlx4_en_port_profile *prof = priv->prof; int i; - - /* Create tx Rings */ - for (i = 0; i < priv->tx_ring_num; i++) { - if (mlx4_en_create_cq(priv, &priv->tx_cq[i], - prof->tx_ring_size, i, TX)) - goto err; - - if (mlx4_en_create_tx_ring(priv, &priv->tx_ring[i], - prof->tx_ring_size, TXBB_SIZE)) - goto err; - } + int node = 0; /* Create rx Rings */ for (i = 0; i < priv->rx_ring_num; i++) { if (mlx4_en_create_cq(priv, &priv->rx_cq[i], - prof->rx_ring_size, i, RX)) + prof->rx_ring_size, i, RX, node)) goto err; if (mlx4_en_create_rx_ring(priv, &priv->rx_ring[i], - prof->rx_ring_size)) + prof->rx_ring_size, node)) goto err; } - /* Re-create stat sysctls in case the number of rings changed. */ + /* Create tx Rings */ + for (i = 0; i < priv->tx_ring_num; i++) { + if (mlx4_en_create_cq(priv, &priv->tx_cq[i], + prof->tx_ring_size, i, TX, node)) + goto err; + + if (mlx4_en_create_tx_ring(priv, &priv->tx_ring[i], + prof->tx_ring_size, TXBB_SIZE, node, i)) + goto err; + } + +#ifdef CONFIG_RFS_ACCEL + priv->dev->rx_cpu_rmap = alloc_irq_cpu_rmap(priv->rx_ring_num); + if (!priv->dev->rx_cpu_rmap) + goto err; +#endif + /* Re-create stat sysctls in case the number of rings changed. */ mlx4_en_sysctl_stat(priv); - - /* Populate Tx priority mappings */ - mlx4_en_set_prio_map(priv, priv->tx_prio_map, - priv->tx_ring_num - MLX4_EN_NUM_HASH_RINGS); - return 0; err: en_err(priv, "Failed to allocate NIC resources\n"); + for (i = 0; i < priv->rx_ring_num; i++) { + if (priv->rx_ring[i]) + mlx4_en_destroy_rx_ring(priv, &priv->rx_ring[i], + prof->rx_ring_size, + priv->stride); + if (priv->rx_cq[i]) + mlx4_en_destroy_cq(priv, &priv->rx_cq[i]); + } + for (i = 0; i < priv->tx_ring_num; i++) { + if (priv->tx_ring[i]) + mlx4_en_destroy_tx_ring(priv, &priv->tx_ring[i]); + if (priv->tx_cq[i]) + mlx4_en_destroy_cq(priv, &priv->tx_cq[i]); + } + priv->port_up = false; return -ENOMEM; } +struct en_port_attribute { + struct attribute attr; + ssize_t (*show)(struct en_port *, struct en_port_attribute *, char *buf); + ssize_t (*store)(struct en_port *, struct en_port_attribute *, char *buf, size_t count); +}; + +#define PORT_ATTR_RO(_name) \ +struct en_port_attribute en_port_attr_##_name = __ATTR_RO(_name) + +#define EN_PORT_ATTR(_name, _mode, _show, _store) \ +struct en_port_attribute en_port_attr_##_name = __ATTR(_name, _mode, _show, _store) void mlx4_en_destroy_netdev(struct net_device *dev) { @@ -930,10 +1710,10 @@ void mlx4_en_destroy_netdev(struct net_device *dev) en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); - if (priv->vlan_attach != NULL) - EVENTHANDLER_DEREGISTER(vlan_config, priv->vlan_attach); - if (priv->vlan_detach != NULL) - EVENTHANDLER_DEREGISTER(vlan_unconfig, priv->vlan_detach); + if (priv->vlan_attach != NULL) + EVENTHANDLER_DEREGISTER(vlan_config, priv->vlan_attach); + if (priv->vlan_detach != NULL) + EVENTHANDLER_DEREGISTER(vlan_unconfig, priv->vlan_detach); /* Unregister device - this will close the port if it was up */ if (priv->registered) @@ -943,28 +1723,34 @@ void mlx4_en_destroy_netdev(struct net_device *dev) mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE); mutex_lock(&mdev->state_lock); - mlx4_en_do_stop_port(dev); + mlx4_en_stop_port(dev); mutex_unlock(&mdev->state_lock); + cancel_delayed_work(&priv->stats_task); + cancel_delayed_work(&priv->service_task); /* flush any pending task for this netdev */ flush_workqueue(mdev->workqueue); - callout_drain(&priv->watchdog_timer); + callout_drain(&priv->watchdog_timer); /* Detach the netdev so tasks would not attempt to access it */ mutex_lock(&mdev->state_lock); mdev->pndev[priv->port] = NULL; mutex_unlock(&mdev->state_lock); + mlx4_en_free_resources(priv); + /* freeing the sysctl conf cannot be called from within mlx4_en_free_resources */ if (priv->sysctl) sysctl_ctx_free(&priv->conf_ctx); - mtx_destroy(&priv->stats_lock.m); - mtx_destroy(&priv->vlan_lock.m); - kfree(priv); - if_free(dev); + kfree(priv->tx_ring); + kfree(priv->tx_cq); + + kfree(priv); + if_free(dev); + } static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) @@ -973,8 +1759,8 @@ static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) struct mlx4_en_dev *mdev = priv->mdev; int err = 0; - en_dbg(DRV, priv, "Change MTU called - current:%u new:%d\n", - dev->if_mtu, new_mtu); + en_dbg(DRV, priv, "Change MTU called - current:%u new:%u\n", + (unsigned)dev->if_mtu, (unsigned)new_mtu); if ((new_mtu < MLX4_EN_MIN_MTU) || (new_mtu > priv->max_mtu)) { en_err(priv, "Bad MTU size:%d.\n", new_mtu); @@ -985,15 +1771,14 @@ static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu) if (dev->if_drv_flags & IFF_DRV_RUNNING) { if (!mdev->device_up) { /* NIC is probably restarting - let watchdog task reset - * the port */ + * * the port */ en_dbg(DRV, priv, "Change MTU called with card down!?\n"); } else { - mlx4_en_do_stop_port(dev); - mlx4_en_set_default_moderation(priv); - err = mlx4_en_do_start_port(dev); + mlx4_en_stop_port(dev); + err = mlx4_en_start_port(dev); if (err) { en_err(priv, "Failed restarting port:%d\n", - priv->port); + priv->port); queue_work(mdev->workqueue, &priv->watchdog_task); } } @@ -1042,7 +1827,6 @@ static int mlx4_en_calc_media(struct mlx4_en_priv *priv) return (active); } - static void mlx4_en_media_status(struct ifnet *dev, struct ifmediareq *ifmr) { struct mlx4_en_priv *priv; @@ -1077,9 +1861,10 @@ static int mlx4_en_media_change(struct ifnet *dev) case IFM_10G_SR: case IFM_10G_CX4: case IFM_1000_T: - if (IFM_SUBTYPE(ifm->ifm_media) == - IFM_SUBTYPE(mlx4_en_calc_media(priv)) && - (ifm->ifm_media & IFM_FDX)) + case IFM_40G_CR4: + if ((IFM_SUBTYPE(ifm->ifm_media) + == IFM_SUBTYPE(mlx4_en_calc_media(priv))) + && (ifm->ifm_media & IFM_FDX)) break; /* Fallthrough */ default: @@ -1116,36 +1901,28 @@ static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data) mdev = priv->mdev; ifr = (struct ifreq *) data; switch (command) { + case SIOCSIFMTU: error = -mlx4_en_change_mtu(dev, ifr->ifr_mtu); break; case SIOCSIFFLAGS: + mutex_lock(&mdev->state_lock); if (dev->if_flags & IFF_UP) { if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0) mlx4_en_start_port(dev); else - mlx4_en_set_multicast(dev); + mlx4_en_set_rx_mode(dev); } else { if (dev->if_drv_flags & IFF_DRV_RUNNING) { mlx4_en_stop_port(dev); if_link_state_change(dev, LINK_STATE_DOWN); - /* - * Since mlx4_en_stop_port is defered we - * have to wait till it's finished. - */ - for (int count=0; count<10; count++) { - if (dev->if_drv_flags & IFF_DRV_RUNNING) { - DELAY(20000); - } else { - break; - } - } } } + mutex_unlock(&mdev->state_lock); break; case SIOCADDMULTI: case SIOCDELMULTI: - mlx4_en_set_multicast(dev); + mlx4_en_set_rx_mode(dev); break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: @@ -1158,6 +1935,8 @@ static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data) dev->if_capenable ^= IFCAP_HWCSUM; if (mask & IFCAP_TSO4) dev->if_capenable ^= IFCAP_TSO4; + if (mask & IFCAP_TSO6) + dev->if_capenable ^= IFCAP_TSO6; if (mask & IFCAP_LRO) dev->if_capenable ^= IFCAP_LRO; if (mask & IFCAP_VLAN_HWTAGGING) @@ -1167,7 +1946,7 @@ static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data) if (mask & IFCAP_WOL_MAGIC) dev->if_capenable ^= IFCAP_WOL_MAGIC; if (dev->if_drv_flags & IFF_DRV_RUNNING) - mlx4_en_init_locked(priv); + mlx4_en_start_port(dev); mutex_unlock(&mdev->state_lock); VLAN_CAPABILITIES(dev); break; @@ -1179,228 +1958,441 @@ static int mlx4_en_ioctl(struct ifnet *dev, u_long command, caddr_t data) return (error); } + +int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, + struct mlx4_en_port_profile *prof) +{ + struct net_device *dev; + struct mlx4_en_priv *priv; + uint8_t dev_addr[ETHER_ADDR_LEN]; + int err; + int i; + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + dev = priv->dev = if_alloc(IFT_ETHER); + if (dev == NULL) { + en_err(priv, "Net device allocation failed\n"); + kfree(priv); + return -ENOMEM; + } + dev->if_softc = priv; + if_initname(dev, "mlxen", atomic_fetchadd_int(&mlx4_en_unit, 1)); + dev->if_mtu = ETHERMTU; + dev->if_baudrate = 1000000000; + dev->if_init = mlx4_en_open; + dev->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + dev->if_ioctl = mlx4_en_ioctl; + dev->if_transmit = mlx4_en_transmit; + dev->if_qflush = mlx4_en_qflush; + dev->if_snd.ifq_maxlen = prof->tx_ring_size; + + /* + * Initialize driver private data + */ + priv->counter_index = 0xff; + spin_lock_init(&priv->stats_lock); + INIT_WORK(&priv->rx_mode_task, mlx4_en_do_set_rx_mode); + INIT_WORK(&priv->watchdog_task, mlx4_en_restart); + INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate); + INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats); + INIT_DELAYED_WORK(&priv->service_task, mlx4_en_service_task); + callout_init(&priv->watchdog_timer, 1); +#ifdef CONFIG_RFS_ACCEL + INIT_LIST_HEAD(&priv->filters); + spin_lock_init(&priv->filters_lock); +#endif + + priv->msg_enable = MLX4_EN_MSG_LEVEL; + priv->dev = dev; + priv->mdev = mdev; + priv->ddev = &mdev->pdev->dev; + priv->prof = prof; + priv->port = port; + priv->port_up = false; + priv->flags = prof->flags; + priv->ctrl_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE | + MLX4_WQE_CTRL_SOLICITED); + + priv->num_tx_rings_p_up = mdev->profile.num_tx_rings_p_up; + priv->tx_ring_num = prof->tx_ring_num; + priv->tx_ring = kcalloc(MAX_TX_RINGS, + sizeof(struct mlx4_en_tx_ring *), GFP_KERNEL); + if (!priv->tx_ring) { + err = -ENOMEM; + goto out; + } + priv->tx_cq = kcalloc(sizeof(struct mlx4_en_cq *), MAX_TX_RINGS, + GFP_KERNEL); + if (!priv->tx_cq) { + err = -ENOMEM; + goto out; + } + + priv->rx_ring_num = prof->rx_ring_num; + priv->cqe_factor = (mdev->dev->caps.cqe_size == 64) ? 1 : 0; + priv->mac_index = -1; + priv->last_ifq_jiffies = 0; + priv->if_counters_rx_errors = 0; + priv->if_counters_rx_no_buffer = 0; +#ifdef CONFIG_MLX4_EN_DCB + if (!mlx4_is_slave(priv->mdev->dev)) { + priv->dcbx_cap = DCB_CAP_DCBX_HOST; + priv->flags |= MLX4_EN_FLAG_DCB_ENABLED; + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETS_CFG) { + dev->dcbnl_ops = &mlx4_en_dcbnl_ops; + } else { + en_info(priv, "QoS disabled - no HW support\n"); + dev->dcbnl_ops = &mlx4_en_dcbnl_pfc_ops; + } + } +#endif + + for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) + INIT_HLIST_HEAD(&priv->mac_hash[i]); + + + /* Query for default mac and max mtu */ + priv->max_mtu = mdev->dev->caps.eth_mtu_cap[priv->port]; + priv->mac = mdev->dev->caps.def_mac[priv->port]; + if (ILLEGAL_MAC(priv->mac)) { +#if BITS_PER_LONG == 64 + en_err(priv, "Port: %d, invalid mac burned: 0x%lx, quiting\n", + priv->port, priv->mac); +#elif BITS_PER_LONG == 32 + en_err(priv, "Port: %d, invalid mac burned: 0x%llx, quiting\n", + priv->port, priv->mac); +#endif + err = -EINVAL; + goto out; + } + + + + priv->stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) + + DS_SIZE); + + mlx4_en_sysctl_conf(priv); + + err = mlx4_en_alloc_resources(priv); + if (err) + goto out; + + /* Allocate page for receive rings */ + err = mlx4_alloc_hwq_res(mdev->dev, &priv->res, + MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE); + if (err) { + en_err(priv, "Failed to allocate page for rx qps\n"); + goto out; + } + priv->allocated = 1; + + /* + * Set driver features + */ + dev->if_capabilities |= IFCAP_RXCSUM | IFCAP_TXCSUM; + dev->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING; + dev->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER; + dev->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU; + dev->if_capabilities |= IFCAP_LRO; + + if (mdev->LSO_support) + dev->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6 | IFCAP_VLAN_HWTSO; + + /* set TSO limits so that we don't have to drop TX packets */ + dev->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + dev->if_hw_tsomaxsegcount = 16; + dev->if_hw_tsomaxsegsize = 65536; /* XXX can do up to 4GByte */ + + dev->if_capenable = dev->if_capabilities; + + dev->if_hwassist = 0; + if (dev->if_capenable & (IFCAP_TSO4 | IFCAP_TSO6)) + dev->if_hwassist |= CSUM_TSO; + if (dev->if_capenable & IFCAP_TXCSUM) + dev->if_hwassist |= (CSUM_TCP | CSUM_UDP | CSUM_IP); + + + /* Register for VLAN events */ + priv->vlan_attach = EVENTHANDLER_REGISTER(vlan_config, + mlx4_en_vlan_rx_add_vid, priv, EVENTHANDLER_PRI_FIRST); + priv->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, + mlx4_en_vlan_rx_kill_vid, priv, EVENTHANDLER_PRI_FIRST); + + mdev->pndev[priv->port] = dev; + + priv->last_link_state = MLX4_DEV_EVENT_PORT_DOWN; + mlx4_en_set_default_moderation(priv); + + /* Set default MAC */ + for (i = 0; i < ETHER_ADDR_LEN; i++) + dev_addr[ETHER_ADDR_LEN - 1 - i] = (u8) (priv->mac >> (8 * i)); + + + ether_ifattach(dev, dev_addr); + if_link_state_change(dev, LINK_STATE_DOWN); + ifmedia_init(&priv->media, IFM_IMASK | IFM_ETH_FMASK, + mlx4_en_media_change, mlx4_en_media_status); + ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_1000_T, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_10G_SR, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_10G_CX4, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_40G_CR4, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); + + en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num); + en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num); + + priv->registered = 1; + + en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num); + en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num); + + + priv->rx_mb_size = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN; + err = mlx4_SET_PORT_general(mdev->dev, priv->port, + priv->rx_mb_size, + prof->tx_pause, prof->tx_ppp, + prof->rx_pause, prof->rx_ppp); + if (err) { + en_err(priv, "Failed setting port general configurations " + "for port %d, with error %d\n", priv->port, err); + goto out; + } + + /* Init port */ + en_warn(priv, "Initializing port\n"); + err = mlx4_INIT_PORT(mdev->dev, priv->port); + if (err) { + en_err(priv, "Failed Initializing port\n"); + goto out; + } + + queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY); + + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) + queue_delayed_work(mdev->workqueue, &priv->service_task, SERVICE_TASK_DELAY); + + + + return 0; + +out: + mlx4_en_destroy_netdev(dev); + return err; +} static int mlx4_en_set_ring_size(struct net_device *dev, int rx_size, int tx_size) { - struct mlx4_en_priv *priv = netdev_priv(dev); - struct mlx4_en_dev *mdev = priv->mdev; - int port_up = 0; - int err = 0; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + int port_up = 0; + int err = 0; - rx_size = roundup_pow_of_two(rx_size); - rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE); - rx_size = min_t(u32, rx_size, MLX4_EN_MAX_RX_SIZE); - tx_size = roundup_pow_of_two(tx_size); - tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); - tx_size = min_t(u32, tx_size, MLX4_EN_MAX_TX_SIZE); + rx_size = roundup_pow_of_two(rx_size); + rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE); + rx_size = min_t(u32, rx_size, MLX4_EN_MAX_RX_SIZE); + tx_size = roundup_pow_of_two(tx_size); + tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); + tx_size = min_t(u32, tx_size, MLX4_EN_MAX_TX_SIZE); - if (rx_size == (priv->port_up ? - priv->rx_ring[0].actual_size : priv->rx_ring[0].size) && - tx_size == priv->tx_ring[0].size) - return 0; - - mutex_lock(&mdev->state_lock); - if (priv->port_up) { - port_up = 1; - mlx4_en_do_stop_port(dev); - } - mlx4_en_free_resources(priv); - priv->prof->tx_ring_size = tx_size; - priv->prof->rx_ring_size = rx_size; - err = mlx4_en_alloc_resources(priv); - if (err) { - en_err(priv, "Failed reallocating port resources\n"); - goto out; - } - if (port_up) { - err = mlx4_en_do_start_port(dev); - if (err) - en_err(priv, "Failed starting port\n"); - } + if (rx_size == (priv->port_up ? + priv->rx_ring[0]->actual_size : priv->rx_ring[0]->size) && + tx_size == priv->tx_ring[0]->size) + return 0; + mutex_lock(&mdev->state_lock); + if (priv->port_up) { + port_up = 1; + mlx4_en_stop_port(dev); + } + mlx4_en_free_resources(priv); + priv->prof->tx_ring_size = tx_size; + priv->prof->rx_ring_size = rx_size; + err = mlx4_en_alloc_resources(priv); + if (err) { + en_err(priv, "Failed reallocating port resources\n"); + goto out; + } + if (port_up) { + err = mlx4_en_start_port(dev); + if (err) + en_err(priv, "Failed starting port\n"); + } out: - mutex_unlock(&mdev->state_lock); - return err; + mutex_unlock(&mdev->state_lock); + return err; } - static int mlx4_en_set_rx_ring_size(SYSCTL_HANDLER_ARGS) { - struct mlx4_en_priv *priv; - int size; - int error; + struct mlx4_en_priv *priv; + int size; + int error; - priv = arg1; - size = priv->prof->rx_ring_size; - error = sysctl_handle_int(oidp, &size, 0, req); - if (error || !req->newptr) - return (error); - error = -mlx4_en_set_ring_size(priv->dev, size, - priv->prof->tx_ring_size); - - return (error); + priv = arg1; + size = priv->prof->rx_ring_size; + error = sysctl_handle_int(oidp, &size, 0, req); + if (error || !req->newptr) + return (error); + error = -mlx4_en_set_ring_size(priv->dev, size, + priv->prof->tx_ring_size); + return (error); } static int mlx4_en_set_tx_ring_size(SYSCTL_HANDLER_ARGS) { - struct mlx4_en_priv *priv; - int size; - int error; + struct mlx4_en_priv *priv; + int size; + int error; - priv = arg1; - size = priv->prof->tx_ring_size; - error = sysctl_handle_int(oidp, &size, 0, req); - if (error || !req->newptr) - return (error); - error = -mlx4_en_set_ring_size(priv->dev, priv->prof->rx_ring_size, - size); + priv = arg1; + size = priv->prof->tx_ring_size; + error = sysctl_handle_int(oidp, &size, 0, req); + if (error || !req->newptr) + return (error); + error = -mlx4_en_set_ring_size(priv->dev, priv->prof->rx_ring_size, + size); - return (error); + return (error); } static int mlx4_en_set_tx_ppp(SYSCTL_HANDLER_ARGS) { - struct mlx4_en_priv *priv; - int ppp; - int error; + struct mlx4_en_priv *priv; + int ppp; + int error; - priv = arg1; - ppp = priv->prof->tx_ppp; - error = sysctl_handle_int(oidp, &ppp, 0, req); - if (error || !req->newptr) - return (error); - if (ppp > 0xff || ppp < 0) - return (-EINVAL); - priv->prof->tx_ppp = ppp; - error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port, - priv->rx_mb_size + ETHER_CRC_LEN, - priv->prof->tx_pause, - priv->prof->tx_ppp, - priv->prof->rx_pause, - priv->prof->rx_ppp); + priv = arg1; + ppp = priv->prof->tx_ppp; + error = sysctl_handle_int(oidp, &ppp, 0, req); + if (error || !req->newptr) + return (error); + if (ppp > 0xff || ppp < 0) + return (-EINVAL); + priv->prof->tx_ppp = ppp; + error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port, + priv->rx_mb_size + ETHER_CRC_LEN, + priv->prof->tx_pause, + priv->prof->tx_ppp, + priv->prof->rx_pause, + priv->prof->rx_ppp); - return (error); + return (error); } static int mlx4_en_set_rx_ppp(SYSCTL_HANDLER_ARGS) { - struct mlx4_en_priv *priv; - struct mlx4_en_dev *mdev; - int tx_ring_num; - int ppp; - int error; - int port_up; + struct mlx4_en_priv *priv; + struct mlx4_en_dev *mdev; + int ppp; + int error; + int port_up; - port_up = 0; - priv = arg1; - mdev = priv->mdev; - ppp = priv->prof->rx_ppp; - error = sysctl_handle_int(oidp, &ppp, 0, req); - if (error || !req->newptr) - return (error); - if (ppp > 0xff || ppp < 0) - return (-EINVAL); - /* See if we have to change the number of tx queues. */ - if (!ppp != !priv->prof->rx_ppp) { - tx_ring_num = MLX4_EN_NUM_HASH_RINGS + 1 + - (!!ppp) * MLX4_EN_NUM_PPP_RINGS; - mutex_lock(&mdev->state_lock); - if (priv->port_up) { - port_up = 1; - mlx4_en_do_stop_port(priv->dev); - } - mlx4_en_free_resources(priv); - priv->tx_ring_num = tx_ring_num; - priv->prof->rx_ppp = ppp; - error = -mlx4_en_alloc_resources(priv); - if (error) - en_err(priv, "Failed reallocating port resources\n"); - if (error == 0 && port_up) { - error = -mlx4_en_do_start_port(priv->dev); - if (error) - en_err(priv, "Failed starting port\n"); - } - mutex_unlock(&mdev->state_lock); - return (error); + port_up = 0; + priv = arg1; + mdev = priv->mdev; + ppp = priv->prof->rx_ppp; + error = sysctl_handle_int(oidp, &ppp, 0, req); + if (error || !req->newptr) + return (error); + if (ppp > 0xff || ppp < 0) + return (-EINVAL); + /* See if we have to change the number of tx queues. */ + if (!ppp != !priv->prof->rx_ppp) { + mutex_lock(&mdev->state_lock); + if (priv->port_up) { + port_up = 1; + mlx4_en_stop_port(priv->dev); + } + mlx4_en_free_resources(priv); + priv->prof->rx_ppp = ppp; + error = -mlx4_en_alloc_resources(priv); + if (error) + en_err(priv, "Failed reallocating port resources\n"); + if (error == 0 && port_up) { + error = -mlx4_en_start_port(priv->dev); + if (error) + en_err(priv, "Failed starting port\n"); + } + mutex_unlock(&mdev->state_lock); + return (error); - } - priv->prof->rx_ppp = ppp; - error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port, - priv->rx_mb_size + ETHER_CRC_LEN, - priv->prof->tx_pause, - priv->prof->tx_ppp, - priv->prof->rx_pause, - priv->prof->rx_ppp); + } + priv->prof->rx_ppp = ppp; + error = -mlx4_SET_PORT_general(priv->mdev->dev, priv->port, + priv->rx_mb_size + ETHER_CRC_LEN, + priv->prof->tx_pause, + priv->prof->tx_ppp, + priv->prof->rx_pause, + priv->prof->rx_ppp); - return (error); + return (error); } static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv) { - struct net_device *dev; - struct sysctl_ctx_list *ctx; - struct sysctl_oid *node; - struct sysctl_oid_list *node_list; - struct sysctl_oid *coal; - struct sysctl_oid_list *coal_list; + struct net_device *dev; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *node; + struct sysctl_oid_list *node_list; + struct sysctl_oid *coal; + struct sysctl_oid_list *coal_list; - dev = priv->dev; - ctx = &priv->conf_ctx; + dev = priv->dev; + ctx = &priv->conf_ctx; - sysctl_ctx_init(ctx); - priv->sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw), - OID_AUTO, dev->if_xname, CTLFLAG_RD, 0, "mlx4 10gig ethernet"); - node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO, - "conf", CTLFLAG_RD, NULL, "Configuration"); - node_list = SYSCTL_CHILDREN(node); + sysctl_ctx_init(ctx); + priv->sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw), + OID_AUTO, dev->if_xname, CTLFLAG_RD, 0, "mlx4 10gig ethernet"); + node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO, + "conf", CTLFLAG_RD, NULL, "Configuration"); + node_list = SYSCTL_CHILDREN(node); - SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "msg_enable", - CTLFLAG_RW, &priv->msg_enable, 0, - "Driver message enable bitfield"); - SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "rx_rings", - CTLTYPE_INT | CTLFLAG_RD, &priv->rx_ring_num, 0, - "Number of receive rings"); - SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "tx_rings", - CTLTYPE_INT | CTLFLAG_RD, &priv->tx_ring_num, 0, - "Number of transmit rings"); - SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "rx_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, - mlx4_en_set_rx_ring_size, "I", "Receive ring size"); - SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "tx_size", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, - mlx4_en_set_tx_ring_size, "I", "Transmit ring size"); - SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "ip_reasm", - CTLFLAG_RW, &priv->ip_reasm, 0, - "Allow reassembly of IP fragments."); - SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "tx_ppp", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, - mlx4_en_set_tx_ppp, "I", "TX Per-priority pause"); - SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "rx_ppp", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, - mlx4_en_set_rx_ppp, "I", "RX Per-priority pause"); + SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "msg_enable", + CTLFLAG_RW, &priv->msg_enable, 0, + "Driver message enable bitfield"); + SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "rx_rings", + CTLTYPE_INT | CTLFLAG_RD, &priv->rx_ring_num, 0, + "Number of receive rings"); + SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "tx_rings", + CTLTYPE_INT | CTLFLAG_RD, &priv->tx_ring_num, 0, + "Number of transmit rings"); + SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "rx_size", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, + mlx4_en_set_rx_ring_size, "I", "Receive ring size"); + SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "tx_size", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, + mlx4_en_set_tx_ring_size, "I", "Transmit ring size"); + SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "tx_ppp", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, + mlx4_en_set_tx_ppp, "I", "TX Per-priority pause"); + SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "rx_ppp", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, + mlx4_en_set_rx_ppp, "I", "RX Per-priority pause"); - /* Add coalescer configuration. */ - coal = SYSCTL_ADD_NODE(ctx, node_list, OID_AUTO, - "coalesce", CTLFLAG_RD, NULL, "Interrupt coalesce configuration"); - coal_list = SYSCTL_CHILDREN(node); - SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "pkt_rate_low", - CTLFLAG_RW, &priv->pkt_rate_low, 0, - "Packets per-second for minimum delay"); - SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "rx_usecs_low", - CTLFLAG_RW, &priv->rx_usecs_low, 0, - "Minimum RX delay in micro-seconds"); - SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "pkt_rate_high", - CTLFLAG_RW, &priv->pkt_rate_high, 0, - "Packets per-second for maximum delay"); - SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "rx_usecs_high", - CTLFLAG_RW, &priv->rx_usecs_high, 0, - "Maximum RX delay in micro-seconds"); - SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "sample_interval", - CTLFLAG_RW, &priv->sample_interval, 0, - "adaptive frequency in units of HZ ticks"); - SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "adaptive_rx_coal", - CTLFLAG_RW, &priv->adaptive_rx_coal, 0, - "Enable adaptive rx coalescing"); + /* Add coalescer configuration. */ + coal = SYSCTL_ADD_NODE(ctx, node_list, OID_AUTO, + "coalesce", CTLFLAG_RD, NULL, "Interrupt coalesce configuration"); + coal_list = SYSCTL_CHILDREN(node); + SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "pkt_rate_low", + CTLFLAG_RW, &priv->pkt_rate_low, 0, + "Packets per-second for minimum delay"); + SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "rx_usecs_low", + CTLFLAG_RW, &priv->rx_usecs_low, 0, + "Minimum RX delay in micro-seconds"); + SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "pkt_rate_high", + CTLFLAG_RW, &priv->pkt_rate_high, 0, + "Packets per-second for maximum delay"); + SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "rx_usecs_high", + CTLFLAG_RW, &priv->rx_usecs_high, 0, + "Maximum RX delay in micro-seconds"); + SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "sample_interval", + CTLFLAG_RW, &priv->sample_interval, 0, + "adaptive frequency in units of HZ ticks"); + SYSCTL_ADD_UINT(ctx, coal_list, OID_AUTO, "adaptive_rx_coal", + CTLFLAG_RW, &priv->adaptive_rx_coal, 0, + "Enable adaptive rx coalescing"); } + static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv) { struct net_device *dev; @@ -1454,43 +2446,111 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv) "TX checksum offloads"); /* Could strdup the names and add in a loop. This is simpler. */ - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "broadcast", CTLFLAG_RD, - &priv->pkstats.broadcast, "Broadcast packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio0", CTLFLAG_RD, - &priv->pkstats.tx_prio[0], "TX Priority 0 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio1", CTLFLAG_RD, - &priv->pkstats.tx_prio[1], "TX Priority 1 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio2", CTLFLAG_RD, - &priv->pkstats.tx_prio[2], "TX Priority 2 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio3", CTLFLAG_RD, - &priv->pkstats.tx_prio[3], "TX Priority 3 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio4", CTLFLAG_RD, - &priv->pkstats.tx_prio[4], "TX Priority 4 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio5", CTLFLAG_RD, - &priv->pkstats.tx_prio[5], "TX Priority 5 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio6", CTLFLAG_RD, - &priv->pkstats.tx_prio[6], "TX Priority 6 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_prio7", CTLFLAG_RD, - &priv->pkstats.tx_prio[7], "TX Priority 7 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio0", CTLFLAG_RD, - &priv->pkstats.rx_prio[0], "RX Priority 0 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio1", CTLFLAG_RD, - &priv->pkstats.rx_prio[1], "RX Priority 1 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio2", CTLFLAG_RD, - &priv->pkstats.rx_prio[2], "RX Priority 2 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio3", CTLFLAG_RD, - &priv->pkstats.rx_prio[3], "RX Priority 3 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio4", CTLFLAG_RD, - &priv->pkstats.rx_prio[4], "RX Priority 4 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio5", CTLFLAG_RD, - &priv->pkstats.rx_prio[5], "RX Priority 5 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio6", CTLFLAG_RD, - &priv->pkstats.rx_prio[6], "RX Priority 6 packets"); - SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_prio7", CTLFLAG_RD, - &priv->pkstats.rx_prio[7], "RX Priority 7 packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_bytes", CTLFLAG_RD, + &priv->pkstats.rx_bytes, "RX Bytes"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_packets", CTLFLAG_RD, + &priv->pkstats.rx_packets, "RX packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_multicast_packets", CTLFLAG_RD, + &priv->pkstats.rx_multicast_packets, "RX Multicast Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_broadcast_packets", CTLFLAG_RD, + &priv->pkstats.rx_broadcast_packets, "RX Broadcast Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_errors", CTLFLAG_RD, + &priv->pkstats.rx_errors, "RX Errors"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_dropped", CTLFLAG_RD, + &priv->pkstats.rx_dropped, "RX Dropped"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_length_errors", CTLFLAG_RD, + &priv->pkstats.rx_length_errors, "RX Length Errors"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_over_errors", CTLFLAG_RD, + &priv->pkstats.rx_over_errors, "RX Over Errors"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_crc_errors", CTLFLAG_RD, + &priv->pkstats.rx_crc_errors, "RX CRC Errors"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_jabbers", CTLFLAG_RD, + &priv->pkstats.rx_jabbers, "RX Jabbers"); + + + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_in_range_length_error", CTLFLAG_RD, + &priv->pkstats.rx_in_range_length_error, "RX IN_Range Length Error"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_out_range_length_error", + CTLFLAG_RD, &priv->pkstats.rx_out_range_length_error, + "RX Out Range Length Error"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_lt_64_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_lt_64_bytes_packets, "RX Lt 64 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_127_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_127_bytes_packets, "RX 127 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_255_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_255_bytes_packets, "RX 255 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_511_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_511_bytes_packets, "RX 511 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_1023_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_1023_bytes_packets, "RX 1023 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_1518_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_1518_bytes_packets, "RX 1518 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_1522_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_1522_bytes_packets, "RX 1522 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_1548_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_1548_bytes_packets, "RX 1548 bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_gt_1548_bytes_packets", CTLFLAG_RD, + &priv->pkstats.rx_gt_1548_bytes_packets, + "RX Greater Then 1548 bytes Packets"); + +struct mlx4_en_pkt_stats { + unsigned long tx_packets; + unsigned long tx_bytes; + unsigned long tx_multicast_packets; + unsigned long tx_broadcast_packets; + unsigned long tx_errors; + unsigned long tx_dropped; + unsigned long tx_lt_64_bytes_packets; + unsigned long tx_127_bytes_packets; + unsigned long tx_255_bytes_packets; + unsigned long tx_511_bytes_packets; + unsigned long tx_1023_bytes_packets; + unsigned long tx_1518_bytes_packets; + unsigned long tx_1522_bytes_packets; + unsigned long tx_1548_bytes_packets; + unsigned long tx_gt_1548_bytes_packets; + unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; + unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; +#define NUM_PKT_STATS 72 +}; + + + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_packets", CTLFLAG_RD, + &priv->pkstats.tx_packets, "TX packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_bytes", CTLFLAG_RD, + &priv->pkstats.tx_packets, "TX Bytes"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_multicast_packets", CTLFLAG_RD, + &priv->pkstats.tx_multicast_packets, "TX Multicast Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_broadcast_packets", CTLFLAG_RD, + &priv->pkstats.tx_broadcast_packets, "TX Broadcast Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_errors", CTLFLAG_RD, + &priv->pkstats.tx_errors, "TX Errors"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_dropped", CTLFLAG_RD, + &priv->pkstats.tx_dropped, "TX Dropped"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_lt_64_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_lt_64_bytes_packets, "TX Less Then 64 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_127_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_127_bytes_packets, "TX 127 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_255_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_255_bytes_packets, "TX 255 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_511_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_511_bytes_packets, "TX 511 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_1023_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_1023_bytes_packets, "TX 1023 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_1518_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_1518_bytes_packets, "TX 1518 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_1522_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_1522_bytes_packets, "TX 1522 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_1548_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_1548_bytes_packets, "TX 1548 Bytes Packets"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_gt_1548_bytes_packets", CTLFLAG_RD, + &priv->pkstats.tx_gt_1548_bytes_packets, + "TX Greater Then 1548 Bytes Packets"); + + for (i = 0; i < priv->tx_ring_num; i++) { - tx_ring = &priv->tx_ring[i]; + tx_ring = priv->tx_ring[i]; snprintf(namebuf, sizeof(namebuf), "tx_ring%d", i); ring_node = SYSCTL_ADD_NODE(ctx, node_list, OID_AUTO, namebuf, CTLFLAG_RD, NULL, "TX Ring"); @@ -1499,12 +2559,10 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv) CTLFLAG_RD, &tx_ring->packets, "TX packets"); SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "bytes", CTLFLAG_RD, &tx_ring->bytes, "TX bytes"); - SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "error", - CTLFLAG_RD, &tx_ring->errors, "TX soft errors"); } for (i = 0; i < priv->rx_ring_num; i++) { - rx_ring = &priv->rx_ring[i]; + rx_ring = priv->rx_ring[i]; snprintf(namebuf, sizeof(namebuf), "rx_ring%d", i); ring_node = SYSCTL_ADD_NODE(ctx, node_list, OID_AUTO, namebuf, CTLFLAG_RD, NULL, "RX Ring"); @@ -1515,153 +2573,5 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv) CTLFLAG_RD, &rx_ring->bytes, "RX bytes"); SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "error", CTLFLAG_RD, &rx_ring->errors, "RX soft errors"); - SYSCTL_ADD_UINT(ctx, ring_list, OID_AUTO, "lro_queued", - CTLFLAG_RD, &rx_ring->lro.lro_queued, 0, "LRO Queued"); - SYSCTL_ADD_UINT(ctx, ring_list, OID_AUTO, "lro_flushed", - CTLFLAG_RD, &rx_ring->lro.lro_flushed, 0, "LRO Flushed"); } } - -int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, - struct mlx4_en_port_profile *prof) -{ - static volatile int mlx4_en_unit; - struct net_device *dev; - struct mlx4_en_priv *priv; - uint8_t dev_addr[ETHER_ADDR_LEN]; - int err; - int i; - - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - dev = priv->dev = if_alloc(IFT_ETHER); - if (dev == NULL) { - mlx4_err(mdev, "Net device allocation failed\n"); - kfree(priv); - return -ENOMEM; - } - dev->if_softc = priv; - if_initname(dev, "mlxen", atomic_fetchadd_int(&mlx4_en_unit, 1)); - dev->if_mtu = ETHERMTU; - dev->if_baudrate = 1000000000; - dev->if_init = mlx4_en_init; - dev->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - dev->if_ioctl = mlx4_en_ioctl; - dev->if_transmit = mlx4_en_transmit; - dev->if_qflush = mlx4_en_qflush; - dev->if_snd.ifq_maxlen = prof->tx_ring_size; - - /* - * Initialize driver private data - */ - priv->dev = dev; - priv->mdev = mdev; - priv->prof = prof; - priv->port = port; - priv->port_up = false; - priv->rx_csum = 1; - priv->flags = prof->flags; - priv->tx_ring_num = prof->tx_ring_num; - priv->rx_ring_num = prof->rx_ring_num; - priv->mac_index = -1; - priv->msg_enable = MLX4_EN_MSG_LEVEL; - priv->ip_reasm = priv->mdev->profile.ip_reasm; - mtx_init(&priv->stats_lock.m, "mlx4 stats", NULL, MTX_DEF); - mtx_init(&priv->vlan_lock.m, "mlx4 vlan", NULL, MTX_DEF); - INIT_WORK(&priv->start_port_task, mlx4_en_lock_and_start_port); - INIT_WORK(&priv->stop_port_task, mlx4_en_lock_and_stop_port); - INIT_WORK(&priv->mcast_task, mlx4_en_do_set_multicast); - INIT_WORK(&priv->watchdog_task, mlx4_en_restart); - INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate); - INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats); - callout_init(&priv->watchdog_timer, 1); - - /* Query for default mac and max mtu */ - priv->max_mtu = mdev->dev->caps.eth_mtu_cap[priv->port]; - priv->mac = mdev->dev->caps.def_mac[priv->port]; - - if (ILLEGAL_MAC(priv->mac)) { - en_err(priv, "Port: %d, invalid mac burned: 0x%llx, quiting\n", - priv->port, (long long)priv->mac); - err = -EINVAL; - goto out; - } - - mlx4_en_sysctl_conf(priv); - - err = mlx4_en_alloc_resources(priv); - if (err) - goto out; - - /* Allocate page for receive rings */ - err = mlx4_alloc_hwq_res(mdev->dev, &priv->res, - MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE); - if (err) { - en_err(priv, "Failed to allocate page for rx qps\n"); - goto out; - } - priv->allocated = 1; - - /* - * Set driver features - */ - dev->if_capabilities |= IFCAP_RXCSUM | IFCAP_TXCSUM; - dev->if_capabilities |= IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING; - dev->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER; - dev->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU; - if (mdev->LSO_support) - dev->if_capabilities |= IFCAP_TSO4 | IFCAP_VLAN_HWTSO; - if (mdev->profile.num_lro) - dev->if_capabilities |= IFCAP_LRO; - dev->if_capenable = dev->if_capabilities; - /* - * Setup wake-on-lan. - */ -#if 0 - if (priv->mdev->dev->caps.wol) { - u64 config; - if (mlx4_wol_read(priv->mdev->dev, &config, priv->port) == 0) { - if (config & MLX4_EN_WOL_MAGIC) - dev->if_capabilities |= IFCAP_WOL_MAGIC; - if (config & MLX4_EN_WOL_ENABLED) - dev->if_capenable |= IFCAP_WOL_MAGIC; - } - } -#endif - - /* Register for VLAN events */ - priv->vlan_attach = EVENTHANDLER_REGISTER(vlan_config, - mlx4_en_vlan_rx_add_vid, priv, EVENTHANDLER_PRI_FIRST); - priv->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, - mlx4_en_vlan_rx_kill_vid, priv, EVENTHANDLER_PRI_FIRST); - - mdev->pndev[priv->port] = dev; - - priv->last_link_state = MLX4_DEV_EVENT_PORT_DOWN; - if_link_state_change(dev, LINK_STATE_DOWN); - - /* Set default MAC */ - for (i = 0; i < ETHER_ADDR_LEN; i++) - dev_addr[ETHER_ADDR_LEN - 1 - i] = (u8) (priv->mac >> (8 * i)); - - ether_ifattach(dev, dev_addr); - ifmedia_init(&priv->media, IFM_IMASK | IFM_ETH_FMASK, - mlx4_en_media_change, mlx4_en_media_status); - ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_1000_T, 0, NULL); - ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_10G_SR, 0, NULL); - ifmedia_add(&priv->media, IFM_ETHER | IFM_FDX | IFM_10G_CX4, 0, NULL); - ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); - - en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num); - en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num); - - priv->registered = 1; - queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY); - - return 0; - -out: - mlx4_en_destroy_netdev(dev); - return err; -} - diff --git a/sys/ofed/drivers/net/mlx4/en_port.c b/sys/ofed/drivers/net/mlx4/en_port.c index 303bb2bef1f9..33eb0b9f4542 100644 --- a/sys/ofed/drivers/net/mlx4/en_port.c +++ b/sys/ofed/drivers/net/mlx4/en_port.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -31,28 +31,25 @@ * */ - -#include "mlx4_en.h" - +#include #include #include #include -#if 0 // moved to port.c -int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, - u64 mac, u64 clear, u8 mode) -{ - return mlx4_cmd(dev, (mac | (clear << 63)), port, mode, - MLX4_CMD_SET_MCAST_FLTR, MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); -} -#endif +#include "en_port.h" +#include "mlx4_en.h" +#define EN_IFQ_MIN_INTERVAL 3000 -int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, u32 *vlans) + +int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv) { struct mlx4_cmd_mailbox *mailbox; struct mlx4_set_vlan_fltr_mbox *filter; - int i, j; + int i; + int j; + int index = 0; + u32 entry; int err = 0; mailbox = mlx4_alloc_cmd_mailbox(dev); @@ -60,86 +57,21 @@ int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, u32 *vlans) return PTR_ERR(mailbox); filter = mailbox->buf; - memset(filter, 0, sizeof *filter); - if (vlans) - for (i = 0, j = VLAN_FLTR_SIZE - 1; i < VLAN_FLTR_SIZE; - i++, j--) - filter->entry[j] = cpu_to_be32(vlans[i]); - err = mlx4_cmd(dev, mailbox->dma, port, 0, MLX4_CMD_SET_VLAN_FLTR, - MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); + memset(filter, 0, sizeof(*filter)); + for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) { + entry = 0; + for (j = 0; j < 32; j++) + if (test_bit(index, priv->active_vlans)) + entry |= 1 << j; + index++; + filter->entry[i] = cpu_to_be32(entry); + } + err = mlx4_cmd(dev, mailbox->dma, priv->port, 0, MLX4_CMD_SET_VLAN_FLTR, + MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); mlx4_free_cmd_mailbox(dev, mailbox); return err; } - -#if 0 //moved to port.c - shahark -int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, - u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx) -{ - struct mlx4_cmd_mailbox *mailbox; - struct mlx4_set_port_general_context *context; - int err; - u32 in_mod; - - mailbox = mlx4_alloc_cmd_mailbox(dev); - if (IS_ERR(mailbox)) - return PTR_ERR(mailbox); - context = mailbox->buf; - memset(context, 0, sizeof *context); - - context->flags = SET_PORT_GEN_ALL_VALID; - context->mtu = cpu_to_be16(mtu); - context->pptx = (pptx * (!pfctx)) << 7; - context->pfctx = pfctx; - context->pprx = (pprx * (!pfcrx)) << 7; - context->pfcrx = pfcrx; - - in_mod = MLX4_SET_PORT_GENERAL << 8 | port; - err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT, - MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); - - mlx4_free_cmd_mailbox(dev, mailbox); - return err; -} -int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, - u8 promisc) -{ - - printf("%s %s:%d\n", __func__, __FILE__, __LINE__); - - - - struct mlx4_cmd_mailbox *mailbox; - struct mlx4_set_port_rqp_calc_context *context; - int err; - u32 in_mod; - - mailbox = mlx4_alloc_cmd_mailbox(dev); - if (IS_ERR(mailbox)) - return PTR_ERR(mailbox); - context = mailbox->buf; - memset(context, 0, sizeof *context); - - context->base_qpn = cpu_to_be32(base_qpn); - context->promisc = cpu_to_be32(promisc << SET_PORT_PROMISC_EN_SHIFT | base_qpn); -/* - context->mcast = cpu_to_be32((dev->caps.mc_promisc_mode << - SET_PORT_PROMISC_MODE_SHIFT) | base_qpn); -*/ - context->intra_no_vlan = 0; - context->no_vlan = MLX4_NO_VLAN_IDX; - context->intra_vlan_miss = 0; - context->vlan_miss = MLX4_VLAN_MISS_IDX; - - in_mod = MLX4_SET_PORT_RQP_CALC << 8 | port; - err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT, - MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); - - mlx4_free_cmd_mailbox(dev, mailbox); - return err; -} -#endif - int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port) { struct mlx4_en_query_port_context *qport_context; @@ -153,7 +85,8 @@ int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port) return PTR_ERR(mailbox); memset(mailbox->buf, 0, sizeof(*qport_context)); err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, port, 0, - MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); + MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B, + MLX4_CMD_WRAPPED); if (err) goto out; qport_context = mailbox->buf; @@ -169,95 +102,77 @@ int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port) case MLX4_EN_10G_SPEED_XFI: state->link_speed = 10000; break; + case MLX4_EN_20G_SPEED: + state->link_speed = 20000; + break; case MLX4_EN_40G_SPEED: state->link_speed = 40000; break; + case MLX4_EN_56G_SPEED: + state->link_speed = 56000; + break; default: state->link_speed = -1; break; } state->transciver = qport_context->transceiver; - if (be32_to_cpu(qport_context->transceiver_code_hi) & 0x400) - state->transciver = 0x80; + state->autoneg = !!(qport_context->autoneg & MLX4_EN_AUTONEG_MASK); out: mlx4_free_cmd_mailbox(mdev->dev, mailbox); return err; } -#if 0 -static int read_iboe_counters(struct mlx4_dev *dev, int index, u64 counters[]) -{ - struct mlx4_cmd_mailbox *mailbox; - int err; - int mode; - struct mlx4_counters_ext *ext; - struct mlx4_counters *reg; - - mailbox = mlx4_alloc_cmd_mailbox(dev); - if (IS_ERR(mailbox)) - return -ENOMEM; - - err = mlx4_cmd_box(dev, 0, mailbox->dma, index, 0, - MLX4_CMD_QUERY_IF_STAT, MLX4_CMD_TIME_CLASS_C, MLX4_CMD_WRAPPED); - if (err) - goto out; - - mode = be32_to_cpu(((struct mlx4_counters *)mailbox->buf)->counter_mode) & 0xf; - switch (mode) { - case 0: - reg = mailbox->buf; - counters[0] = be64_to_cpu(reg->rx_frames); - counters[1] = be64_to_cpu(reg->tx_frames); - counters[2] = be64_to_cpu(reg->rx_bytes); - counters[3] = be64_to_cpu(reg->tx_bytes); - break; - case 1: - ext = mailbox->buf; - counters[0] = be64_to_cpu(ext->rx_uni_frames); - counters[1] = be64_to_cpu(ext->tx_uni_frames); - counters[2] = be64_to_cpu(ext->rx_uni_bytes); - counters[3] = be64_to_cpu(ext->tx_uni_bytes); - break; - default: - err = -EINVAL; - } - -out: - mlx4_free_cmd_mailbox(dev, mailbox); - return err; -} -#endif - int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) { struct mlx4_en_stat_out_mbox *mlx4_en_stats; - struct net_device *dev; - struct mlx4_en_priv *priv; - struct mlx4_cmd_mailbox *mailbox; + struct mlx4_en_stat_out_flow_control_mbox *flowstats; + struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]); + struct mlx4_en_vport_stats *vport_stats = &priv->vport_stats; + struct mlx4_cmd_mailbox *mailbox = NULL; + struct mlx4_cmd_mailbox *mailbox_flow = NULL; u64 in_mod = reset << 8 | port; - unsigned long oerror; - unsigned long ierror; int err; int i; - //int counter; - u64 counters[4]; + int do_if_stat = 1; + unsigned long period = (unsigned long) (jiffies - priv->last_ifq_jiffies); + struct mlx4_en_vport_stats tmp_vport_stats; + struct net_device *dev; - dev = mdev->pndev[port]; - priv = netdev_priv(dev); - memset(counters, 0, sizeof counters); - /* - counter = mlx4_get_iboe_counter(priv->mdev->dev, port); - if (counter >= 0) - err = read_iboe_counters(priv->mdev->dev, counter, counters); - */ + if (jiffies_to_msecs(period) < EN_IFQ_MIN_INTERVAL || + priv->counter_index == 0xff) + do_if_stat = 0; mailbox = mlx4_alloc_cmd_mailbox(mdev->dev); - if (IS_ERR(mailbox)) - return PTR_ERR(mailbox); - memset(mailbox->buf, 0, sizeof(*mlx4_en_stats)); + if (IS_ERR(mailbox)) { + err = PTR_ERR(mailbox); + goto mailbox_out; + } + + mailbox_flow = mlx4_alloc_cmd_mailbox(mdev->dev); + if (IS_ERR(mailbox_flow)) { + mlx4_free_cmd_mailbox(mdev->dev, mailbox); + err = PTR_ERR(mailbox_flow); + goto mailbox_out; + } + + /* 0xffs indicates invalid value */ + memset(mailbox_flow->buf, 0xff, sizeof(*flowstats) * + MLX4_NUM_PRIORITIES); + + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) { + memset(mailbox_flow->buf, 0, sizeof(*flowstats)); + err = mlx4_cmd_box(mdev->dev, 0, mailbox_flow->dma, + in_mod | 1<<12, 0, MLX4_CMD_DUMP_ETH_STATS, + MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); + + if (err) + goto out; + } + err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, in_mod, 0, - MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); + MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B, + MLX4_CMD_NATIVE); if (err) goto out; @@ -265,74 +180,404 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) spin_lock(&priv->stats_lock); - oerror = ierror = 0; - dev->if_ipackets = counters[0]; - dev->if_ibytes = counters[2]; + priv->port_stats.rx_chksum_good = 0; + priv->port_stats.rx_chksum_none = 0; for (i = 0; i < priv->rx_ring_num; i++) { - dev->if_ipackets += priv->rx_ring[i].packets; - dev->if_ibytes += priv->rx_ring[i].bytes; - ierror += priv->rx_ring[i].errors; - } - dev->if_opackets = counters[1]; - dev->if_obytes = counters[3]; - for (i = 0; i <= priv->tx_ring_num; i++) { - dev->if_opackets += priv->tx_ring[i].packets; - dev->if_obytes += priv->tx_ring[i].bytes; - oerror += priv->tx_ring[i].errors; + priv->port_stats.rx_chksum_good += priv->rx_ring[i]->csum_ok; + priv->port_stats.rx_chksum_none += priv->rx_ring[i]->csum_none; } - dev->if_ierrors = be32_to_cpu(mlx4_en_stats->RDROP) + ierror; - dev->if_oerrors = be32_to_cpu(mlx4_en_stats->TDROP) + oerror; - dev->if_imcasts = be64_to_cpu(mlx4_en_stats->MCAST_prio_0) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_1) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_2) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_3) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_4) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_5) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_6) + - be64_to_cpu(mlx4_en_stats->MCAST_prio_7) + - be64_to_cpu(mlx4_en_stats->MCAST_novlan); - dev->if_omcasts = be64_to_cpu(mlx4_en_stats->TMCAST_prio_0) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_1) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_2) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_3) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_4) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_5) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_6) + - be64_to_cpu(mlx4_en_stats->TMCAST_prio_7) + - be64_to_cpu(mlx4_en_stats->TMCAST_novlan); - dev->if_collisions = 0; + priv->port_stats.tx_chksum_offload = 0; + priv->port_stats.queue_stopped = 0; + priv->port_stats.wake_queue = 0; + for (i = 0; i < priv->tx_ring_num; i++) { + priv->port_stats.tx_chksum_offload += priv->tx_ring[i]->tx_csum; + priv->port_stats.queue_stopped += priv->tx_ring[i]->queue_stopped; + priv->port_stats.wake_queue += priv->tx_ring[i]->wake_queue; + } + /* RX Statistics */ + priv->pkstats.rx_packets = be64_to_cpu(mlx4_en_stats->RTOT_prio_0) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_1) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_2) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_3) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_4) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_5) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_6) + + be64_to_cpu(mlx4_en_stats->RTOT_prio_7) + + be64_to_cpu(mlx4_en_stats->RTOT_novlan); + priv->pkstats.rx_bytes = be64_to_cpu(mlx4_en_stats->ROCT_prio_0) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_1) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_2) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_3) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_4) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_5) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_6) + + be64_to_cpu(mlx4_en_stats->ROCT_prio_7) + + be64_to_cpu(mlx4_en_stats->ROCT_novlan); + priv->pkstats.rx_multicast_packets = be64_to_cpu(mlx4_en_stats->MCAST_prio_0) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_1) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_2) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_3) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_4) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_5) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_6) + + be64_to_cpu(mlx4_en_stats->MCAST_prio_7) + + be64_to_cpu(mlx4_en_stats->MCAST_novlan); + priv->pkstats.rx_broadcast_packets = be64_to_cpu(mlx4_en_stats->RBCAST_prio_0) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_1) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_2) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_3) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_4) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_5) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_6) + + be64_to_cpu(mlx4_en_stats->RBCAST_prio_7) + + be64_to_cpu(mlx4_en_stats->RBCAST_novlan); + priv->pkstats.rx_errors = be64_to_cpu(mlx4_en_stats->PCS) + + be32_to_cpu(mlx4_en_stats->RJBBR) + + be32_to_cpu(mlx4_en_stats->RCRC) + + be32_to_cpu(mlx4_en_stats->RRUNT) + + be64_to_cpu(mlx4_en_stats->RInRangeLengthErr) + + be64_to_cpu(mlx4_en_stats->ROutRangeLengthErr) + + be32_to_cpu(mlx4_en_stats->RSHORT) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_0) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_1) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_2) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_3) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_4) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_5) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_6) + + be64_to_cpu(mlx4_en_stats->RGIANT_prio_7) + + be64_to_cpu(mlx4_en_stats->RGIANT_novlan); + priv->pkstats.rx_dropped = be32_to_cpu(mlx4_en_stats->RdropOvflw); + priv->pkstats.rx_length_errors = be32_to_cpu(mlx4_en_stats->RdropLength); + priv->pkstats.rx_over_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw); + priv->pkstats.rx_crc_errors = be32_to_cpu(mlx4_en_stats->RCRC); + priv->pkstats.rx_jabbers = be32_to_cpu(mlx4_en_stats->RJBBR); + priv->pkstats.rx_in_range_length_error = be64_to_cpu(mlx4_en_stats->RInRangeLengthErr); + priv->pkstats.rx_out_range_length_error = be64_to_cpu(mlx4_en_stats->ROutRangeLengthErr); + priv->pkstats.rx_lt_64_bytes_packets = be64_to_cpu(mlx4_en_stats->R64_prio_0) + + be64_to_cpu(mlx4_en_stats->R64_prio_1) + + be64_to_cpu(mlx4_en_stats->R64_prio_2) + + be64_to_cpu(mlx4_en_stats->R64_prio_3) + + be64_to_cpu(mlx4_en_stats->R64_prio_4) + + be64_to_cpu(mlx4_en_stats->R64_prio_5) + + be64_to_cpu(mlx4_en_stats->R64_prio_6) + + be64_to_cpu(mlx4_en_stats->R64_prio_7) + + be64_to_cpu(mlx4_en_stats->R64_novlan); + priv->pkstats.rx_127_bytes_packets = be64_to_cpu(mlx4_en_stats->R127_prio_0) + + be64_to_cpu(mlx4_en_stats->R127_prio_1) + + be64_to_cpu(mlx4_en_stats->R127_prio_2) + + be64_to_cpu(mlx4_en_stats->R127_prio_3) + + be64_to_cpu(mlx4_en_stats->R127_prio_4) + + be64_to_cpu(mlx4_en_stats->R127_prio_5) + + be64_to_cpu(mlx4_en_stats->R127_prio_6) + + be64_to_cpu(mlx4_en_stats->R127_prio_7) + + be64_to_cpu(mlx4_en_stats->R127_novlan); + priv->pkstats.rx_255_bytes_packets = be64_to_cpu(mlx4_en_stats->R255_prio_0) + + be64_to_cpu(mlx4_en_stats->R255_prio_1) + + be64_to_cpu(mlx4_en_stats->R255_prio_2) + + be64_to_cpu(mlx4_en_stats->R255_prio_3) + + be64_to_cpu(mlx4_en_stats->R255_prio_4) + + be64_to_cpu(mlx4_en_stats->R255_prio_5) + + be64_to_cpu(mlx4_en_stats->R255_prio_6) + + be64_to_cpu(mlx4_en_stats->R255_prio_7) + + be64_to_cpu(mlx4_en_stats->R255_novlan); + priv->pkstats.rx_511_bytes_packets = be64_to_cpu(mlx4_en_stats->R511_prio_0) + + be64_to_cpu(mlx4_en_stats->R511_prio_1) + + be64_to_cpu(mlx4_en_stats->R511_prio_2) + + be64_to_cpu(mlx4_en_stats->R511_prio_3) + + be64_to_cpu(mlx4_en_stats->R511_prio_4) + + be64_to_cpu(mlx4_en_stats->R511_prio_5) + + be64_to_cpu(mlx4_en_stats->R511_prio_6) + + be64_to_cpu(mlx4_en_stats->R511_prio_7) + + be64_to_cpu(mlx4_en_stats->R511_novlan); + priv->pkstats.rx_1023_bytes_packets = be64_to_cpu(mlx4_en_stats->R1023_prio_0) + + be64_to_cpu(mlx4_en_stats->R1023_prio_1) + + be64_to_cpu(mlx4_en_stats->R1023_prio_2) + + be64_to_cpu(mlx4_en_stats->R1023_prio_3) + + be64_to_cpu(mlx4_en_stats->R1023_prio_4) + + be64_to_cpu(mlx4_en_stats->R1023_prio_5) + + be64_to_cpu(mlx4_en_stats->R1023_prio_6) + + be64_to_cpu(mlx4_en_stats->R1023_prio_7) + + be64_to_cpu(mlx4_en_stats->R1023_novlan); + priv->pkstats.rx_1518_bytes_packets = be64_to_cpu(mlx4_en_stats->R1518_prio_0) + + be64_to_cpu(mlx4_en_stats->R1518_prio_1) + + be64_to_cpu(mlx4_en_stats->R1518_prio_2) + + be64_to_cpu(mlx4_en_stats->R1518_prio_3) + + be64_to_cpu(mlx4_en_stats->R1518_prio_4) + + be64_to_cpu(mlx4_en_stats->R1518_prio_5) + + be64_to_cpu(mlx4_en_stats->R1518_prio_6) + + be64_to_cpu(mlx4_en_stats->R1518_prio_7) + + be64_to_cpu(mlx4_en_stats->R1518_novlan); + priv->pkstats.rx_1522_bytes_packets = be64_to_cpu(mlx4_en_stats->R1522_prio_0) + + be64_to_cpu(mlx4_en_stats->R1522_prio_1) + + be64_to_cpu(mlx4_en_stats->R1522_prio_2) + + be64_to_cpu(mlx4_en_stats->R1522_prio_3) + + be64_to_cpu(mlx4_en_stats->R1522_prio_4) + + be64_to_cpu(mlx4_en_stats->R1522_prio_5) + + be64_to_cpu(mlx4_en_stats->R1522_prio_6) + + be64_to_cpu(mlx4_en_stats->R1522_prio_7) + + be64_to_cpu(mlx4_en_stats->R1522_novlan); + priv->pkstats.rx_1548_bytes_packets = be64_to_cpu(mlx4_en_stats->R1548_prio_0) + + be64_to_cpu(mlx4_en_stats->R1548_prio_1) + + be64_to_cpu(mlx4_en_stats->R1548_prio_2) + + be64_to_cpu(mlx4_en_stats->R1548_prio_3) + + be64_to_cpu(mlx4_en_stats->R1548_prio_4) + + be64_to_cpu(mlx4_en_stats->R1548_prio_5) + + be64_to_cpu(mlx4_en_stats->R1548_prio_6) + + be64_to_cpu(mlx4_en_stats->R1548_prio_7) + + be64_to_cpu(mlx4_en_stats->R1548_novlan); + priv->pkstats.rx_gt_1548_bytes_packets = be64_to_cpu(mlx4_en_stats->R2MTU_prio_0) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_1) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_2) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_3) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_4) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_5) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_6) + + be64_to_cpu(mlx4_en_stats->R2MTU_prio_7) + + be64_to_cpu(mlx4_en_stats->R2MTU_novlan); + + /* Tx Stats */ + priv->pkstats.tx_packets = be64_to_cpu(mlx4_en_stats->TTOT_prio_0) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_1) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_2) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_3) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_4) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_5) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_6) + + be64_to_cpu(mlx4_en_stats->TTOT_prio_7) + + be64_to_cpu(mlx4_en_stats->TTOT_novlan); + priv->pkstats.tx_bytes = be64_to_cpu(mlx4_en_stats->TOCT_prio_0) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_1) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_2) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_3) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_4) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_5) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_6) + + be64_to_cpu(mlx4_en_stats->TOCT_prio_7) + + be64_to_cpu(mlx4_en_stats->TOCT_novlan); + priv->pkstats.tx_multicast_packets = be64_to_cpu(mlx4_en_stats->TMCAST_prio_0) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_1) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_2) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_3) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_4) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_5) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_6) + + be64_to_cpu(mlx4_en_stats->TMCAST_prio_7) + + be64_to_cpu(mlx4_en_stats->TMCAST_novlan); + priv->pkstats.tx_broadcast_packets = be64_to_cpu(mlx4_en_stats->TBCAST_prio_0) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_1) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_2) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_3) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_4) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_5) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_6) + + be64_to_cpu(mlx4_en_stats->TBCAST_prio_7) + + be64_to_cpu(mlx4_en_stats->TBCAST_novlan); + priv->pkstats.tx_errors = be64_to_cpu(mlx4_en_stats->TGIANT_prio_0) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_1) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_2) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_3) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_4) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_5) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_6) + + be64_to_cpu(mlx4_en_stats->TGIANT_prio_7) + + be64_to_cpu(mlx4_en_stats->TGIANT_novlan); + priv->pkstats.tx_dropped = be32_to_cpu(mlx4_en_stats->TDROP) - + priv->pkstats.tx_errors; + priv->pkstats.tx_lt_64_bytes_packets = be64_to_cpu(mlx4_en_stats->T64_prio_0) + + be64_to_cpu(mlx4_en_stats->T64_prio_1) + + be64_to_cpu(mlx4_en_stats->T64_prio_2) + + be64_to_cpu(mlx4_en_stats->T64_prio_3) + + be64_to_cpu(mlx4_en_stats->T64_prio_4) + + be64_to_cpu(mlx4_en_stats->T64_prio_5) + + be64_to_cpu(mlx4_en_stats->T64_prio_6) + + be64_to_cpu(mlx4_en_stats->T64_prio_7) + + be64_to_cpu(mlx4_en_stats->T64_novlan); + priv->pkstats.tx_127_bytes_packets = be64_to_cpu(mlx4_en_stats->T127_prio_0) + + be64_to_cpu(mlx4_en_stats->T127_prio_1) + + be64_to_cpu(mlx4_en_stats->T127_prio_2) + + be64_to_cpu(mlx4_en_stats->T127_prio_3) + + be64_to_cpu(mlx4_en_stats->T127_prio_4) + + be64_to_cpu(mlx4_en_stats->T127_prio_5) + + be64_to_cpu(mlx4_en_stats->T127_prio_6) + + be64_to_cpu(mlx4_en_stats->T127_prio_7) + + be64_to_cpu(mlx4_en_stats->T127_novlan); + priv->pkstats.tx_255_bytes_packets = be64_to_cpu(mlx4_en_stats->T255_prio_0) + + be64_to_cpu(mlx4_en_stats->T255_prio_1) + + be64_to_cpu(mlx4_en_stats->T255_prio_2) + + be64_to_cpu(mlx4_en_stats->T255_prio_3) + + be64_to_cpu(mlx4_en_stats->T255_prio_4) + + be64_to_cpu(mlx4_en_stats->T255_prio_5) + + be64_to_cpu(mlx4_en_stats->T255_prio_6) + + be64_to_cpu(mlx4_en_stats->T255_prio_7) + + be64_to_cpu(mlx4_en_stats->T255_novlan); + priv->pkstats.tx_511_bytes_packets = be64_to_cpu(mlx4_en_stats->T511_prio_0) + + be64_to_cpu(mlx4_en_stats->T511_prio_1) + + be64_to_cpu(mlx4_en_stats->T511_prio_2) + + be64_to_cpu(mlx4_en_stats->T511_prio_3) + + be64_to_cpu(mlx4_en_stats->T511_prio_4) + + be64_to_cpu(mlx4_en_stats->T511_prio_5) + + be64_to_cpu(mlx4_en_stats->T511_prio_6) + + be64_to_cpu(mlx4_en_stats->T511_prio_7) + + be64_to_cpu(mlx4_en_stats->T511_novlan); + priv->pkstats.tx_1023_bytes_packets = be64_to_cpu(mlx4_en_stats->T1023_prio_0) + + be64_to_cpu(mlx4_en_stats->T1023_prio_1) + + be64_to_cpu(mlx4_en_stats->T1023_prio_2) + + be64_to_cpu(mlx4_en_stats->T1023_prio_3) + + be64_to_cpu(mlx4_en_stats->T1023_prio_4) + + be64_to_cpu(mlx4_en_stats->T1023_prio_5) + + be64_to_cpu(mlx4_en_stats->T1023_prio_6) + + be64_to_cpu(mlx4_en_stats->T1023_prio_7) + + be64_to_cpu(mlx4_en_stats->T1023_novlan); + priv->pkstats.tx_1518_bytes_packets = be64_to_cpu(mlx4_en_stats->T1518_prio_0) + + be64_to_cpu(mlx4_en_stats->T1518_prio_1) + + be64_to_cpu(mlx4_en_stats->T1518_prio_2) + + be64_to_cpu(mlx4_en_stats->T1518_prio_3) + + be64_to_cpu(mlx4_en_stats->T1518_prio_4) + + be64_to_cpu(mlx4_en_stats->T1518_prio_5) + + be64_to_cpu(mlx4_en_stats->T1518_prio_6) + + be64_to_cpu(mlx4_en_stats->T1518_prio_7) + + be64_to_cpu(mlx4_en_stats->T1518_novlan); + priv->pkstats.tx_1522_bytes_packets = be64_to_cpu(mlx4_en_stats->T1522_prio_0) + + be64_to_cpu(mlx4_en_stats->T1522_prio_1) + + be64_to_cpu(mlx4_en_stats->T1522_prio_2) + + be64_to_cpu(mlx4_en_stats->T1522_prio_3) + + be64_to_cpu(mlx4_en_stats->T1522_prio_4) + + be64_to_cpu(mlx4_en_stats->T1522_prio_5) + + be64_to_cpu(mlx4_en_stats->T1522_prio_6) + + be64_to_cpu(mlx4_en_stats->T1522_prio_7) + + be64_to_cpu(mlx4_en_stats->T1522_novlan); + priv->pkstats.tx_1548_bytes_packets = be64_to_cpu(mlx4_en_stats->T1548_prio_0) + + be64_to_cpu(mlx4_en_stats->T1548_prio_1) + + be64_to_cpu(mlx4_en_stats->T1548_prio_2) + + be64_to_cpu(mlx4_en_stats->T1548_prio_3) + + be64_to_cpu(mlx4_en_stats->T1548_prio_4) + + be64_to_cpu(mlx4_en_stats->T1548_prio_5) + + be64_to_cpu(mlx4_en_stats->T1548_prio_6) + + be64_to_cpu(mlx4_en_stats->T1548_prio_7) + + be64_to_cpu(mlx4_en_stats->T1548_novlan); + priv->pkstats.tx_gt_1548_bytes_packets = be64_to_cpu(mlx4_en_stats->T2MTU_prio_0) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_1) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_2) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_3) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_4) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_5) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_6) + + be64_to_cpu(mlx4_en_stats->T2MTU_prio_7) + + be64_to_cpu(mlx4_en_stats->T2MTU_novlan); + + priv->pkstats.rx_prio[0][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_0); + priv->pkstats.rx_prio[0][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_0); + priv->pkstats.rx_prio[1][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_1); + priv->pkstats.rx_prio[1][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_1); + priv->pkstats.rx_prio[2][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_2); + priv->pkstats.rx_prio[2][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_2); + priv->pkstats.rx_prio[3][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_3); + priv->pkstats.rx_prio[3][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_3); + priv->pkstats.rx_prio[4][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_4); + priv->pkstats.rx_prio[4][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_4); + priv->pkstats.rx_prio[5][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_5); + priv->pkstats.rx_prio[5][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_5); + priv->pkstats.rx_prio[6][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_6); + priv->pkstats.rx_prio[6][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_6); + priv->pkstats.rx_prio[7][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_7); + priv->pkstats.rx_prio[7][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_7); + priv->pkstats.rx_prio[8][0] = be64_to_cpu(mlx4_en_stats->RTOT_novlan); + priv->pkstats.rx_prio[8][1] = be64_to_cpu(mlx4_en_stats->ROCT_novlan); + priv->pkstats.tx_prio[0][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_0); + priv->pkstats.tx_prio[0][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_0); + priv->pkstats.tx_prio[1][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_1); + priv->pkstats.tx_prio[1][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_1); + priv->pkstats.tx_prio[2][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_2); + priv->pkstats.tx_prio[2][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_2); + priv->pkstats.tx_prio[3][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_3); + priv->pkstats.tx_prio[3][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_3); + priv->pkstats.tx_prio[4][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_4); + priv->pkstats.tx_prio[4][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_4); + priv->pkstats.tx_prio[5][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_5); + priv->pkstats.tx_prio[5][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_5); + priv->pkstats.tx_prio[6][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_6); + priv->pkstats.tx_prio[6][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_6); + priv->pkstats.tx_prio[7][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_7); + priv->pkstats.tx_prio[7][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_7); + priv->pkstats.tx_prio[8][0] = be64_to_cpu(mlx4_en_stats->TTOT_novlan); + priv->pkstats.tx_prio[8][1] = be64_to_cpu(mlx4_en_stats->TOCT_novlan); + + flowstats = mailbox_flow->buf; + + for (i = 0; i < MLX4_NUM_PRIORITIES; i++) { + priv->flowstats[i].rx_pause = + be64_to_cpu(flowstats[i].rx_pause); + priv->flowstats[i].rx_pause_duration = + be64_to_cpu(flowstats[i].rx_pause_duration); + priv->flowstats[i].rx_pause_transition = + be64_to_cpu(flowstats[i].rx_pause_transition); + priv->flowstats[i].tx_pause = + be64_to_cpu(flowstats[i].tx_pause); + priv->flowstats[i].tx_pause_duration = + be64_to_cpu(flowstats[i].tx_pause_duration); + priv->flowstats[i].tx_pause_transition = + be64_to_cpu(flowstats[i].tx_pause_transition); + } + + memset(&tmp_vport_stats, 0, sizeof(tmp_vport_stats)); + spin_unlock(&priv->stats_lock); + err = mlx4_get_vport_ethtool_stats(mdev->dev, port, + &tmp_vport_stats, reset); + spin_lock(&priv->stats_lock); + if (!err) { + /* ethtool stats format */ + vport_stats->rx_unicast_packets = tmp_vport_stats.rx_unicast_packets; + vport_stats->rx_unicast_bytes = tmp_vport_stats.rx_unicast_bytes; + vport_stats->rx_multicast_packets = tmp_vport_stats.rx_multicast_packets; + vport_stats->rx_multicast_bytes = tmp_vport_stats.rx_multicast_bytes; + vport_stats->rx_broadcast_packets = tmp_vport_stats.rx_broadcast_packets; + vport_stats->rx_broadcast_bytes = tmp_vport_stats.rx_broadcast_bytes; + vport_stats->rx_dropped = tmp_vport_stats.rx_dropped; + vport_stats->rx_errors = tmp_vport_stats.rx_errors; + vport_stats->tx_unicast_packets = tmp_vport_stats.tx_unicast_packets; + vport_stats->tx_unicast_bytes = tmp_vport_stats.tx_unicast_bytes; + vport_stats->tx_multicast_packets = tmp_vport_stats.tx_multicast_packets; + vport_stats->tx_multicast_bytes = tmp_vport_stats.tx_multicast_bytes; + vport_stats->tx_broadcast_packets = tmp_vport_stats.tx_broadcast_packets; + vport_stats->tx_broadcast_bytes = tmp_vport_stats.tx_broadcast_bytes; + vport_stats->tx_errors = tmp_vport_stats.tx_errors; + } + + if (!mlx4_is_mfunc(mdev->dev)) { + if (reset == 0) { + /* netdevice stats format */ + dev = mdev->pndev[port]; + if_inc_counter(dev, IFCOUNTER_IPACKETS, + priv->pkstats.rx_packets - priv->pkstats_last.rx_packets); + if_inc_counter(dev, IFCOUNTER_OPACKETS, + priv->pkstats.tx_packets - priv->pkstats_last.tx_packets); + if_inc_counter(dev, IFCOUNTER_IBYTES, + priv->pkstats.rx_bytes - priv->pkstats_last.rx_bytes); + if_inc_counter(dev, IFCOUNTER_OBYTES, + priv->pkstats.tx_bytes - priv->pkstats_last.tx_bytes); + if_inc_counter(dev, IFCOUNTER_IERRORS, + priv->pkstats.rx_errors - priv->pkstats_last.rx_errors); + if_inc_counter(dev, IFCOUNTER_IQDROPS, + priv->pkstats.rx_dropped - priv->pkstats_last.rx_dropped); + if_inc_counter(dev, IFCOUNTER_IMCASTS, + priv->pkstats.rx_multicast_packets - priv->pkstats_last.rx_multicast_packets); + if_inc_counter(dev, IFCOUNTER_OMCASTS, + priv->pkstats.tx_multicast_packets - priv->pkstats_last.tx_multicast_packets); + } + priv->pkstats_last = priv->pkstats; + } - priv->pkstats.broadcast = - be64_to_cpu(mlx4_en_stats->RBCAST_prio_0) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_1) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_2) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_3) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_4) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_5) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_6) + - be64_to_cpu(mlx4_en_stats->RBCAST_prio_7) + - be64_to_cpu(mlx4_en_stats->RBCAST_novlan); - priv->pkstats.rx_prio[0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_0); - priv->pkstats.rx_prio[1] = be64_to_cpu(mlx4_en_stats->RTOT_prio_1); - priv->pkstats.rx_prio[2] = be64_to_cpu(mlx4_en_stats->RTOT_prio_2); - priv->pkstats.rx_prio[3] = be64_to_cpu(mlx4_en_stats->RTOT_prio_3); - priv->pkstats.rx_prio[4] = be64_to_cpu(mlx4_en_stats->RTOT_prio_4); - priv->pkstats.rx_prio[5] = be64_to_cpu(mlx4_en_stats->RTOT_prio_5); - priv->pkstats.rx_prio[6] = be64_to_cpu(mlx4_en_stats->RTOT_prio_6); - priv->pkstats.rx_prio[7] = be64_to_cpu(mlx4_en_stats->RTOT_prio_7); - priv->pkstats.tx_prio[0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_0); - priv->pkstats.tx_prio[1] = be64_to_cpu(mlx4_en_stats->TTOT_prio_1); - priv->pkstats.tx_prio[2] = be64_to_cpu(mlx4_en_stats->TTOT_prio_2); - priv->pkstats.tx_prio[3] = be64_to_cpu(mlx4_en_stats->TTOT_prio_3); - priv->pkstats.tx_prio[4] = be64_to_cpu(mlx4_en_stats->TTOT_prio_4); - priv->pkstats.tx_prio[5] = be64_to_cpu(mlx4_en_stats->TTOT_prio_5); - priv->pkstats.tx_prio[6] = be64_to_cpu(mlx4_en_stats->TTOT_prio_6); - priv->pkstats.tx_prio[7] = be64_to_cpu(mlx4_en_stats->TTOT_prio_7); spin_unlock(&priv->stats_lock); out: + mlx4_free_cmd_mailbox(mdev->dev, mailbox_flow); mlx4_free_cmd_mailbox(mdev->dev, mailbox); + +mailbox_out: + if (do_if_stat) + priv->last_ifq_jiffies = jiffies; + return err; } - diff --git a/sys/ofed/drivers/net/mlx4/en_port.h b/sys/ofed/drivers/net/mlx4/en_port.h index 531981452333..6301717e1814 100644 --- a/sys/ofed/drivers/net/mlx4/en_port.h +++ b/sys/ofed/drivers/net/mlx4/en_port.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -36,39 +36,10 @@ #define SET_PORT_GEN_ALL_VALID 0x7 -#define SET_PORT_PROMISC_EN_SHIFT 31 -#define SET_PORT_PROMISC_MODE_SHIFT 30 +#define SET_PORT_PROMISC_SHIFT 31 +#define SET_PORT_MC_PROMISC_SHIFT 30 -#if 0 //moved to port.c - shahark - -struct mlx4_set_port_general_context { - u8 reserved[3]; - u8 flags; - u16 reserved2; - __be16 mtu; - u8 pptx; - u8 pfctx; - u16 reserved3; - u8 pprx; - u8 pfcrx; - u16 reserved4; -}; - -struct mlx4_set_port_rqp_calc_context { - __be32 base_qpn; - __be32 flags; - u8 reserved[3]; - u8 mac_miss; - u8 intra_no_vlan; - u8 no_vlan; - u8 intra_vlan_miss; - u8 vlan_miss; - u8 reserved2[3]; - u8 no_vlan_prio; - __be32 promisc; - __be32 mcast; -}; -#endif +#define MLX4_EN_NUM_TC 8 #define VLAN_FLTR_SIZE 128 struct mlx4_set_vlan_fltr_mbox { @@ -83,29 +54,27 @@ enum { }; enum { - MLX4_EN_1G_SPEED = 0x02, - MLX4_EN_10G_SPEED_XFI = 0x01, MLX4_EN_10G_SPEED_XAUI = 0x00, + MLX4_EN_10G_SPEED_XFI = 0x01, + MLX4_EN_1G_SPEED = 0x02, + MLX4_EN_20G_SPEED = 0x08, MLX4_EN_40G_SPEED = 0x40, + MLX4_EN_56G_SPEED = 0x20, MLX4_EN_OTHER_SPEED = 0x0f, }; struct mlx4_en_query_port_context { u8 link_up; #define MLX4_EN_LINK_UP_MASK 0x80 - u8 reserved; + u8 autoneg; +#define MLX4_EN_AUTONEG_MASK 0x80 __be16 mtu; u8 reserved2; u8 link_speed; -#define MLX4_EN_SPEED_MASK 0x43 +#define MLX4_EN_SPEED_MASK 0x6b u16 reserved3[5]; __be64 mac; u8 transceiver; - u8 reserved4[3]; - __be32 wavelenth; - u32 reserved5; - __be32 transceiver_code_hi; - __be32 transceiver_code_low; }; @@ -590,6 +559,5 @@ struct mlx4_en_stat_out_mbox { __be32 TDROP; }; -enum mlx4_query_reply mlx4_en_query(void *endev_ptr, void *int_dev); #endif diff --git a/sys/ofed/drivers/net/mlx4/en_resources.c b/sys/ofed/drivers/net/mlx4/en_resources.c index a147153803fd..669ecbd11843 100644 --- a/sys/ofed/drivers/net/mlx4/en_resources.c +++ b/sys/ofed/drivers/net/mlx4/en_resources.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -31,24 +31,26 @@ * */ +#include #include #include #include "mlx4_en.h" + void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride, int is_tx, int rss, int qpn, int cqn, - struct mlx4_qp_context *context) + int user_prio, struct mlx4_qp_context *context) { struct mlx4_en_dev *mdev = priv->mdev; + struct net_device *dev = priv->dev; memset(context, 0, sizeof *context); - context->flags = cpu_to_be32(7 << 16 | rss << 13); + context->flags = cpu_to_be32(7 << 16 | rss << MLX4_RSS_QPC_FLAG_OFFSET); context->pd = cpu_to_be32(mdev->priv_pdn); context->mtu_msgmax = 0xff; - if (!is_tx && !rss) { + if (!is_tx && !rss) context->rq_size_stride = ilog2(size) << 3 | (ilog2(stride) - 4); - } if (is_tx) context->sq_size_stride = ilog2(size) << 3 | (ilog2(stride) - 4); else @@ -57,10 +59,25 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride, context->local_qpn = cpu_to_be32(qpn); context->pri_path.ackto = 1 & 0x07; context->pri_path.sched_queue = 0x83 | (priv->port - 1) << 6; - context->pri_path.counter_index = 0xff; + if (user_prio >= 0) { + context->pri_path.sched_queue |= user_prio << 3; + context->pri_path.feup = 1 << 6; + } + context->pri_path.counter_index = (u8)(priv->counter_index); + if (!rss && + (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_LB_SRC_CHK) && + context->pri_path.counter_index != 0xFF) { + /* disable multicast loopback to qp with same counter */ + context->pri_path.fl |= MLX4_FL_ETH_SRC_CHECK_MC_LB; + context->pri_path.vlan_control |= + MLX4_VLAN_CTRL_ETH_SRC_CHECK_IF_COUNTER; + } + context->cqn_send = cpu_to_be32(cqn); context->cqn_recv = cpu_to_be32(cqn); context->db_rec_addr = cpu_to_be64(priv->res.db.dma << 2); + if (!(dev->if_capabilities & IFCAP_VLAN_HWCSUM)) + context->param3 |= cpu_to_be32(1 << 30); } @@ -69,6 +86,8 @@ int mlx4_en_map_buffer(struct mlx4_buf *buf) struct page **pages; int i; + // if nbufs == 1 - there is no need to vmap + // if buf->direct.buf is not NULL it means that vmap was already done by mlx4_alloc_buff if (buf->direct.buf != NULL || buf->nbufs == 1) return 0; @@ -89,11 +108,10 @@ int mlx4_en_map_buffer(struct mlx4_buf *buf) void mlx4_en_unmap_buffer(struct mlx4_buf *buf) { - if (buf->direct.buf != NULL || buf->nbufs == 1) + if (BITS_PER_LONG == 64 || buf->nbufs == 1) return; vunmap(buf->direct.buf); - buf->direct.buf = NULL; } void mlx4_en_sqp_event(struct mlx4_qp *qp, enum mlx4_event event) diff --git a/sys/ofed/drivers/net/mlx4/en_rx.c b/sys/ofed/drivers/net/mlx4/en_rx.c index ca46721dd28b..320462ec02ad 100644 --- a/sys/ofed/drivers/net/mlx4/en_rx.c +++ b/sys/ofed/drivers/net/mlx4/en_rx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -30,20 +30,48 @@ * SOFTWARE. * */ - #include "opt_inet.h" +#include +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_NET_RX_BUSY_POLL +#include +#endif + #include "mlx4_en.h" -#include -#include -#include -#include -#include +static void mlx4_en_init_rx_desc(struct mlx4_en_priv *priv, + struct mlx4_en_rx_ring *ring, + int index) +{ + struct mlx4_en_rx_desc *rx_desc = ring->buf + ring->stride * index; + int possible_frags; + int i; -enum { - MIN_RX_ARM = 1024, -}; + + /* Set size and memtype fields */ + for (i = 0; i < priv->num_frags; i++) { + rx_desc->data[i].byte_count = + cpu_to_be32(priv->frag_info[i].frag_size); + rx_desc->data[i].lkey = cpu_to_be32(priv->mdev->mr.key); + } + + /* If the number of used fragments does not fill up the ring stride, + * * remaining (unused) fragments must be padded with null address/size + * * and a special memory key */ + possible_frags = (ring->stride - sizeof(struct mlx4_en_rx_desc)) / DS_SIZE; + for (i = priv->num_frags; i < possible_frags; i++) { + rx_desc->data[i].byte_count = 0; + rx_desc->data[i].lkey = cpu_to_be32(MLX4_EN_MEMTYPE_PAD); + rx_desc->data[i].addr = 0; + } + +} static int mlx4_en_alloc_buf(struct mlx4_en_priv *priv, struct mlx4_en_rx_desc *rx_desc, @@ -70,48 +98,24 @@ static int mlx4_en_alloc_buf(struct mlx4_en_priv *priv, return 0; } -static void mlx4_en_init_rx_desc(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring, int index) -{ - struct mlx4_en_rx_desc *rx_desc = ring->buf + ring->stride * index; - int possible_frags; - int i; - - /* Set size and memtype fields */ - for (i = 0; i < priv->num_frags; i++) { - rx_desc->data[i].byte_count = - cpu_to_be32(priv->frag_info[i].frag_size); - rx_desc->data[i].lkey = cpu_to_be32(priv->mdev->mr.key); - } - - /* If the number of used fragments does not fill up the ring stride, - * remaining (unused) fragments must be padded with null address/size - * and a special memory key */ - possible_frags = (ring->stride - sizeof(struct mlx4_en_rx_desc)) / DS_SIZE; - for (i = priv->num_frags; i < possible_frags; i++) { - rx_desc->data[i].byte_count = 0; - rx_desc->data[i].lkey = cpu_to_be32(MLX4_EN_MEMTYPE_PAD); - rx_desc->data[i].addr = 0; - } -} static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring, int index) + struct mlx4_en_rx_ring *ring, int index) { - struct mlx4_en_rx_desc *rx_desc = ring->buf + (index * ring->stride); - struct mbuf **mb_list = ring->rx_info + (index << priv->log_rx_info); - int i; + struct mlx4_en_rx_desc *rx_desc = ring->buf + (index * ring->stride); + struct mbuf **mb_list = ring->rx_info + (index << priv->log_rx_info); + int i; - for (i = 0; i < priv->num_frags; i++) - if (mlx4_en_alloc_buf(priv, rx_desc, mb_list, i)) - goto err; + for (i = 0; i < priv->num_frags; i++) + if (mlx4_en_alloc_buf(priv, rx_desc, mb_list, i)) + goto err; - return 0; + return 0; err: - while (i--) - m_free(mb_list[i]); - return -ENOMEM; + while (i--) + m_free(mb_list[i]); + return -ENOMEM; } static inline void mlx4_en_update_rx_prod_db(struct mlx4_en_rx_ring *ring) @@ -136,7 +140,11 @@ static void mlx4_en_free_rx_desc(struct mlx4_en_priv *priv, frag_info = &priv->frag_info[nr]; dma = be64_to_cpu(rx_desc->data[nr].addr); - en_dbg(DRV, priv, "Unmaping buffer at dma:0x%llx\n", (long long) dma); +#if BITS_PER_LONG == 64 + en_dbg(DRV, priv, "Unmaping buffer at dma:0x%lx\n", (u64) dma); +#elif BITS_PER_LONG == 32 + en_dbg(DRV, priv, "Unmaping buffer at dma:0x%llx\n", (u64) dma); +#endif pci_unmap_single(mdev->pdev, dma, frag_info->frag_size, PCI_DMA_FROMDEVICE); m_free(mb_list[nr]); @@ -153,7 +161,7 @@ static int mlx4_en_fill_rx_buffers(struct mlx4_en_priv *priv) for (buf_ind = 0; buf_ind < priv->prof->rx_ring_size; buf_ind++) { for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { - ring = &priv->rx_ring[ring_ind]; + ring = priv->rx_ring[ring_ind]; err = mlx4_en_prepare_rx_desc(priv, ring, ring->actual_size); @@ -163,7 +171,8 @@ static int mlx4_en_fill_rx_buffers(struct mlx4_en_priv *priv) "enough rx buffers\n"); return -ENOMEM; } else { - new_size = rounddown_pow_of_two(ring->actual_size); + new_size = + rounddown_pow_of_two(ring->actual_size); en_warn(priv, "Only %d buffers allocated " "reducing ring size to %d\n", ring->actual_size, new_size); @@ -178,7 +187,7 @@ static int mlx4_en_fill_rx_buffers(struct mlx4_en_priv *priv) reduce_rings: for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { - ring = &priv->rx_ring[ring_ind]; + ring = priv->rx_ring[ring_ind]; while (ring->actual_size > new_size) { ring->actual_size--; ring->prod--; @@ -207,407 +216,6 @@ static void mlx4_en_free_rx_buf(struct mlx4_en_priv *priv, } } - -int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring, u32 size) -{ - struct mlx4_en_dev *mdev = priv->mdev; - int err; - int tmp; - - - ring->prod = 0; - ring->cons = 0; - ring->size = size; - ring->size_mask = size - 1; - ring->stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) + - DS_SIZE * MLX4_EN_MAX_RX_FRAGS); - ring->log_stride = ffs(ring->stride) - 1; - ring->buf_size = ring->size * ring->stride + TXBB_SIZE; - - tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS * - sizeof(struct mbuf *)); - - ring->rx_info = kmalloc(tmp, GFP_KERNEL); - if (!ring->rx_info) { - en_err(priv, "Failed allocating rx_info ring\n"); - return -ENOMEM; - } - en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d stride:%d (%d)\n", - ring->rx_info, tmp, ring->stride, ring->log_stride); - - err = mlx4_alloc_hwq_res(mdev->dev, &ring->wqres, - ring->buf_size, 2 * PAGE_SIZE); - if (err) - goto err_ring; - - err = mlx4_en_map_buffer(&ring->wqres.buf); - if (err) { - en_err(priv, "Failed to map RX buffer\n"); - goto err_hwq; - } - ring->buf = ring->wqres.buf.direct.buf; - - return 0; - - mlx4_en_unmap_buffer(&ring->wqres.buf); -err_hwq: - mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size); -err_ring: - kfree(ring->rx_info); - ring->rx_info = NULL; - return err; -} - -int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv) -{ - struct mlx4_en_rx_ring *ring; - int i; - int ring_ind; - int err; - int stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) + - DS_SIZE * priv->num_frags); - for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { - ring = &priv->rx_ring[ring_ind]; - - ring->prod = 0; - ring->cons = 0; - ring->actual_size = 0; - ring->cqn = priv->rx_cq[ring_ind].mcq.cqn; - ring->stride = stride; - if (ring->stride <= TXBB_SIZE) - ring->buf += TXBB_SIZE; - - ring->log_stride = ffs(ring->stride) - 1; - ring->buf_size = ring->size * ring->stride; - - memset(ring->buf, 0, ring->buf_size); - mlx4_en_update_rx_prod_db(ring); - - /* Initailize all descriptors */ - for (i = 0; i < ring->size; i++) - mlx4_en_init_rx_desc(priv, ring, i); -#ifdef INET - /* Configure lro mngr */ - if (priv->dev->if_capenable & IFCAP_LRO) { - if (tcp_lro_init(&ring->lro)) - priv->dev->if_capenable &= ~IFCAP_LRO; - else - ring->lro.ifp = priv->dev; - } -#endif - } - err = mlx4_en_fill_rx_buffers(priv); - if (err) - goto err_buffers; - - for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { - ring = &priv->rx_ring[ring_ind]; - - ring->size_mask = ring->actual_size - 1; - mlx4_en_update_rx_prod_db(ring); - } - - - return 0; - -err_buffers: - for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) - mlx4_en_free_rx_buf(priv, &priv->rx_ring[ring_ind]); - - return err; -} - -void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring) -{ - struct mlx4_en_dev *mdev = priv->mdev; - - mlx4_en_unmap_buffer(&ring->wqres.buf); - mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size + TXBB_SIZE); - kfree(ring->rx_info); - ring->rx_info = NULL; -} - -void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring) -{ -#ifdef INET - tcp_lro_free(&ring->lro); -#endif - mlx4_en_free_rx_buf(priv, ring); - if (ring->stride <= TXBB_SIZE) - ring->buf -= TXBB_SIZE; -} - - -/* Unmap a completed descriptor and free unused pages */ -static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv, - struct mlx4_en_rx_desc *rx_desc, - struct mbuf **mb_list, - int length) -{ - struct mlx4_en_dev *mdev = priv->mdev; - struct mlx4_en_frag_info *frag_info; - dma_addr_t dma; - struct mbuf *mb; - int nr; - - mb = mb_list[0]; - mb->m_pkthdr.len = length; - /* Collect used fragments while replacing them in the HW descirptors */ - for (nr = 0; nr < priv->num_frags; nr++) { - frag_info = &priv->frag_info[nr]; - if (length <= frag_info->frag_prefix_size) - break; - if (nr) - mb->m_next = mb_list[nr]; - mb = mb_list[nr]; - mb->m_len = frag_info[nr].frag_size; - dma = be64_to_cpu(rx_desc->data[nr].addr); - - /* Allocate a replacement page */ - if (mlx4_en_alloc_buf(priv, rx_desc, mb_list, nr)) - goto fail; - - /* Unmap buffer */ - pci_unmap_single(mdev->pdev, dma, frag_info[nr].frag_size, - PCI_DMA_FROMDEVICE); - } - /* Adjust size of last fragment to match actual length */ - mb->m_len = length - priv->frag_info[nr - 1].frag_prefix_size; - mb->m_next = NULL; - return 0; - -fail: - /* Drop all accumulated fragments (which have already been replaced in - * the descriptor) of this packet; remaining fragments are reused... */ - while (nr > 0) { - nr--; - m_free(mb_list[nr]); - } - return -ENOMEM; -} - - -static inline int invalid_cqe(struct mlx4_en_priv *priv, - struct mlx4_cqe *cqe) -{ - /* Drop packet on bad receive or bad checksum */ - if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == - MLX4_CQE_OPCODE_ERROR)) { - en_err(priv, "CQE completed in error - vendor " - "syndrom:%d syndrom:%d\n", - ((struct mlx4_err_cqe *) cqe)->vendor_err_syndrome, - ((struct mlx4_err_cqe *) cqe)->syndrome); - return 1; - } - if (unlikely(cqe->badfcs_enc & MLX4_CQE_BAD_FCS)) { - en_dbg(RX_ERR, priv, "Accepted frame with bad FCS\n"); - return 1; - } - - return 0; -} - -static void validate_loopback(struct mlx4_en_priv *priv, struct mbuf *mb) -{ - int i; - int offset = ETHER_HDR_LEN; - - for (i = 0; i < MLX4_LOOPBACK_TEST_PAYLOAD; i++, offset++) { - if (*(mb->m_data + offset) != (unsigned char) (i & 0xff)) - goto out_loopback; - } - /* Loopback found */ - priv->loopback_ok = 1; - -out_loopback: - m_freem(mb); -} - -static struct mbuf *mlx4_en_rx_mb(struct mlx4_en_priv *priv, - struct mlx4_en_rx_desc *rx_desc, - struct mbuf **mb_list, - unsigned int length) -{ - struct mbuf *mb; - - mb = mb_list[0]; - /* Move relevant fragments to mb */ - if (unlikely(mlx4_en_complete_rx_desc(priv, rx_desc, mb_list, length))) - return NULL; - - return mb; -} - - -int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget) -{ - struct mlx4_en_priv *priv = netdev_priv(dev); - struct mlx4_cqe *cqe; - struct mlx4_en_rx_ring *ring = &priv->rx_ring[cq->ring]; - struct mbuf **mb_list; - struct mlx4_en_rx_desc *rx_desc; - struct mbuf *mb; -#ifdef INET - struct lro_entry *queued; -#endif - int index; - unsigned int length; - int polled = 0; - - if (!priv->port_up) - return 0; - - /* We assume a 1:1 mapping between CQEs and Rx descriptors, so Rx - * descriptor offset can be deduced from the CQE index instead of - * reading 'cqe->index' */ - index = cq->mcq.cons_index & ring->size_mask; - cqe = &cq->buf[index]; - - /* Process all completed CQEs */ - while (XNOR(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK, - cq->mcq.cons_index & cq->size)) { - - mb_list = ring->rx_info + (index << priv->log_rx_info); - rx_desc = ring->buf + (index << ring->log_stride); - - /* - * make sure we read the CQE after we read the ownership bit - */ - rmb(); - - if (invalid_cqe(priv, cqe)) - goto next; - - /* - * Packet is OK - process it. - */ - length = be32_to_cpu(cqe->byte_cnt); - mb = mlx4_en_rx_mb(priv, rx_desc, mb_list, length); - if (!mb) { - ring->errors++; - goto next; - } - - ring->bytes += length; - ring->packets++; - - if (unlikely(priv->validate_loopback)) { - validate_loopback(priv, mb); - goto next; - } - - mb->m_pkthdr.flowid = cq->ring; - mb->m_flags |= M_FLOWID; - mb->m_pkthdr.rcvif = dev; - if (be32_to_cpu(cqe->vlan_my_qpn) & - MLX4_CQE_VLAN_PRESENT_MASK) { - mb->m_pkthdr.ether_vtag = be16_to_cpu(cqe->sl_vid); - mb->m_flags |= M_VLANTAG; - } - if (likely(priv->rx_csum) && - (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) && - (cqe->checksum == cpu_to_be16(0xffff))) { - priv->port_stats.rx_chksum_good++; - mb->m_pkthdr.csum_flags = - CSUM_IP_CHECKED | CSUM_IP_VALID | - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; - mb->m_pkthdr.csum_data = htons(0xffff); - /* This packet is eligible for LRO if it is: - * - DIX Ethernet (type interpretation) - * - TCP/IP (v4) - * - without IP options - * - not an IP fragment - */ -#ifdef INET - if (mlx4_en_can_lro(cqe->status) && - (dev->if_capenable & IFCAP_LRO)) { - if (ring->lro.lro_cnt != 0 && - tcp_lro_rx(&ring->lro, mb, 0) == 0) - goto next; - } -#endif - - /* LRO not possible, complete processing here */ - INC_PERF_COUNTER(priv->pstats.lro_misses); - } else { - mb->m_pkthdr.csum_flags = 0; - priv->port_stats.rx_chksum_none++; -#ifdef INET - if (priv->ip_reasm && - cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV4) && - !mlx4_en_rx_frags(priv, ring, mb, cqe)) - goto next; -#endif - } - - /* Push it up the stack */ - dev->if_input(dev, mb); - -next: - ++cq->mcq.cons_index; - index = (cq->mcq.cons_index) & ring->size_mask; - cqe = &cq->buf[index]; - if (++polled == budget) - goto out; - } - /* Flush all pending IP reassembly sessions */ -out: -#ifdef INET - mlx4_en_flush_frags(priv, ring); - while ((queued = SLIST_FIRST(&ring->lro.lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&ring->lro.lro_active, next); - tcp_lro_flush(&ring->lro, queued); - } -#endif - AVG_PERF_COUNTER(priv->pstats.rx_coal_avg, polled); - mlx4_cq_set_ci(&cq->mcq); - wmb(); /* ensure HW sees CQ consumer before we post new buffers */ - ring->cons = cq->mcq.cons_index; - ring->prod += polled; /* Polled descriptors were realocated in place */ - mlx4_en_update_rx_prod_db(ring); - return polled; -} - - -/* Rx CQ polling - called by NAPI */ -static int mlx4_en_poll_rx_cq(struct mlx4_en_cq *cq, int budget) -{ - struct net_device *dev = cq->dev; - int done; - - done = mlx4_en_process_rx_cq(dev, cq, budget); - cq->tot_rx += done; - - return done; -} - -void mlx4_en_rx_que(void *context, int pending) -{ - struct mlx4_en_cq *cq; - - cq = context; - while (mlx4_en_poll_rx_cq(cq, MLX4_EN_MAX_RX_POLL) - == MLX4_EN_MAX_RX_POLL); - mlx4_en_arm_cq(cq->dev->if_softc, cq); -} - -void mlx4_en_rx_irq(struct mlx4_cq *mcq) -{ - struct mlx4_en_cq *cq = container_of(mcq, struct mlx4_en_cq, mcq); - struct mlx4_en_priv *priv = netdev_priv(cq->dev); - int done; - - done = mlx4_en_poll_rx_cq(cq, MLX4_EN_MAX_RX_POLL); - if (done == MLX4_EN_MAX_RX_POLL) - taskqueue_enqueue(cq->tq, &cq->cq_task); - else - mlx4_en_arm_cq(priv, cq); -} - - #if MLX4_EN_MAX_RX_FRAGS == 3 static int frag_sizes[] = { FRAG_SZ0, @@ -626,7 +234,7 @@ static int frag_sizes[] = { void mlx4_en_calc_rx_buf(struct net_device *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); - int eff_mtu = dev->if_mtu + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ETH_LLC_SNAP_SIZE; + int eff_mtu = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN; int buf_size = 0; int i, frag; @@ -652,10 +260,456 @@ void mlx4_en_calc_rx_buf(struct net_device *dev) for (i = 0; i < priv->num_frags; i++) { en_dbg(DRV, priv, " frag:%d - size:%d prefix:%d\n", i, priv->frag_info[i].frag_size, - priv->frag_info[i].frag_prefix_size) + priv->frag_info[i].frag_prefix_size); } } + +int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv, + struct mlx4_en_rx_ring **pring, + u32 size, int node) +{ + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_rx_ring *ring; + int err = -ENOMEM; + int tmp; + + ring = kzalloc(sizeof(struct mlx4_en_rx_ring), GFP_KERNEL); + if (!ring) { + en_err(priv, "Failed to allocate RX ring structure\n"); + return -ENOMEM; + } + + ring->prod = 0; + ring->cons = 0; + ring->size = size; + ring->size_mask = size - 1; + ring->stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) + + DS_SIZE * MLX4_EN_MAX_RX_FRAGS); + ring->log_stride = ffs(ring->stride) - 1; + ring->buf_size = ring->size * ring->stride + TXBB_SIZE; + + tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS * + sizeof(struct mbuf *)); + + ring->rx_info = kmalloc(tmp, GFP_KERNEL); + if (!ring->rx_info) { + err = -ENOMEM; + goto err_ring; + } + + en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d\n", + ring->rx_info, tmp); + + err = mlx4_alloc_hwq_res(mdev->dev, &ring->wqres, + ring->buf_size, 2 * PAGE_SIZE); + if (err) + goto err_info; + + err = mlx4_en_map_buffer(&ring->wqres.buf); + if (err) { + en_err(priv, "Failed to map RX buffer\n"); + goto err_hwq; + } + ring->buf = ring->wqres.buf.direct.buf; + *pring = ring; + return 0; + +err_hwq: + mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size); +err_info: + vfree(ring->rx_info); +err_ring: + kfree(ring); + + return err; +} + + +int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv) +{ + struct mlx4_en_rx_ring *ring; + int i; + int ring_ind; + int err; + int stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) + + DS_SIZE * priv->num_frags); + + for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { + ring = priv->rx_ring[ring_ind]; + + ring->prod = 0; + ring->cons = 0; + ring->actual_size = 0; + ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn; + ring->rx_alloc_order = priv->rx_alloc_order; + ring->rx_alloc_size = priv->rx_alloc_size; + ring->rx_buf_size = priv->rx_buf_size; + ring->rx_mb_size = priv->rx_mb_size; + + ring->stride = stride; + if (ring->stride <= TXBB_SIZE) + ring->buf += TXBB_SIZE; + + ring->log_stride = ffs(ring->stride) - 1; + ring->buf_size = ring->size * ring->stride; + + memset(ring->buf, 0, ring->buf_size); + mlx4_en_update_rx_prod_db(ring); + + /* Initialize all descriptors */ + for (i = 0; i < ring->size; i++) + mlx4_en_init_rx_desc(priv, ring, i); + +#ifdef INET + /* Configure lro mngr */ + if (priv->dev->if_capenable & IFCAP_LRO) { + if (tcp_lro_init(&ring->lro)) + priv->dev->if_capenable &= ~IFCAP_LRO; + else + ring->lro.ifp = priv->dev; + } +#endif + } + + + err = mlx4_en_fill_rx_buffers(priv); + if (err) + goto err_buffers; + + for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { + ring = priv->rx_ring[ring_ind]; + + ring->size_mask = ring->actual_size - 1; + mlx4_en_update_rx_prod_db(ring); + } + + return 0; + +err_buffers: + for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) + mlx4_en_free_rx_buf(priv, priv->rx_ring[ring_ind]); + + ring_ind = priv->rx_ring_num - 1; + + while (ring_ind >= 0) { + ring = priv->rx_ring[ring_ind]; + if (ring->stride <= TXBB_SIZE) + ring->buf -= TXBB_SIZE; + ring_ind--; + } + + return err; +} + + +void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv, + struct mlx4_en_rx_ring **pring, + u32 size, u16 stride) +{ + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_rx_ring *ring = *pring; + + mlx4_en_unmap_buffer(&ring->wqres.buf); + mlx4_free_hwq_res(mdev->dev, &ring->wqres, size * stride + TXBB_SIZE); + vfree(ring->rx_info); + kfree(ring); + *pring = NULL; +#ifdef CONFIG_RFS_ACCEL + mlx4_en_cleanup_filters(priv, ring); +#endif +} + + +void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv, + struct mlx4_en_rx_ring *ring) +{ +#ifdef INET + tcp_lro_free(&ring->lro); +#endif + mlx4_en_free_rx_buf(priv, ring); + if (ring->stride <= TXBB_SIZE) + ring->buf -= TXBB_SIZE; +} + + +static void validate_loopback(struct mlx4_en_priv *priv, struct mbuf *mb) +{ + int i; + int offset = ETHER_HDR_LEN; + + for (i = 0; i < MLX4_LOOPBACK_TEST_PAYLOAD; i++, offset++) { + if (*(mb->m_data + offset) != (unsigned char) (i & 0xff)) + goto out_loopback; + } + /* Loopback found */ + priv->loopback_ok = 1; + +out_loopback: + m_freem(mb); +} + + +static inline int invalid_cqe(struct mlx4_en_priv *priv, + struct mlx4_cqe *cqe) +{ + /* Drop packet on bad receive or bad checksum */ + if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == + MLX4_CQE_OPCODE_ERROR)) { + en_err(priv, "CQE completed in error - vendor syndrom:%d syndrom:%d\n", + ((struct mlx4_err_cqe *)cqe)->vendor_err_syndrome, + ((struct mlx4_err_cqe *)cqe)->syndrome); + return 1; + } + if (unlikely(cqe->badfcs_enc & MLX4_CQE_BAD_FCS)) { + en_dbg(RX_ERR, priv, "Accepted frame with bad FCS\n"); + return 1; + } + + return 0; +} + + +/* Unmap a completed descriptor and free unused pages */ +static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv, + struct mlx4_en_rx_desc *rx_desc, + struct mbuf **mb_list, + int length) +{ + struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_frag_info *frag_info; + dma_addr_t dma; + struct mbuf *mb; + int nr; + + mb = mb_list[0]; + mb->m_pkthdr.len = length; + /* Collect used fragments while replacing them in the HW descirptors */ + for (nr = 0; nr < priv->num_frags; nr++) { + frag_info = &priv->frag_info[nr]; + if (length <= frag_info->frag_prefix_size) + break; + if (nr) + mb->m_next = mb_list[nr]; + mb = mb_list[nr]; + mb->m_len = frag_info[nr].frag_size; + dma = be64_to_cpu(rx_desc->data[nr].addr); + + /* Allocate a replacement page */ + if (mlx4_en_alloc_buf(priv, rx_desc, mb_list, nr)) + goto fail; + + /* Unmap buffer */ + pci_unmap_single(mdev->pdev, dma, frag_info[nr].frag_size, + PCI_DMA_FROMDEVICE); + } + /* Adjust size of last fragment to match actual length */ + mb->m_len = length - priv->frag_info[nr - 1].frag_prefix_size; + mb->m_next = NULL; + return 0; + +fail: + /* Drop all accumulated fragments (which have already been replaced in + * the descriptor) of this packet; remaining fragments are reused... */ + while (nr > 0) { + nr--; + m_free(mb_list[nr]); + } + return -ENOMEM; + +} + +static struct mbuf *mlx4_en_rx_mb(struct mlx4_en_priv *priv, + struct mlx4_en_rx_desc *rx_desc, + struct mbuf **mb_list, + unsigned int length) +{ + struct mbuf *mb; + + mb = mb_list[0]; + /* Move relevant fragments to mb */ + if (unlikely(mlx4_en_complete_rx_desc(priv, rx_desc, mb_list, length))) + return NULL; + + return mb; +} + +/* For cpu arch with cache line of 64B the performance is better when cqe size==64B + * To enlarge cqe size from 32B to 64B --> 32B of garbage (i.e. 0xccccccc) + * was added in the beginning of each cqe (the real data is in the corresponding 32B). + * The following calc ensures that when factor==1, it means we are alligned to 64B + * and we get the real cqe data*/ +#define CQE_FACTOR_INDEX(index, factor) ((index << factor) + factor) +int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_cqe *cqe; + struct mlx4_en_rx_ring *ring = priv->rx_ring[cq->ring]; + struct mbuf **mb_list; + struct mlx4_en_rx_desc *rx_desc; + struct mbuf *mb; + struct mlx4_cq *mcq = &cq->mcq; + struct mlx4_cqe *buf = cq->buf; +#ifdef INET + struct lro_entry *queued; +#endif + int index; + unsigned int length; + int polled = 0; + u32 cons_index = mcq->cons_index; + u32 size_mask = ring->size_mask; + int size = cq->size; + int factor = priv->cqe_factor; + + if (!priv->port_up) + return 0; + + /* We assume a 1:1 mapping between CQEs and Rx descriptors, so Rx + * descriptor offset can be deducted from the CQE index instead of + * reading 'cqe->index' */ + index = cons_index & size_mask; + cqe = &buf[CQE_FACTOR_INDEX(index, factor)]; + + /* Process all completed CQEs */ + while (XNOR(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK, + cons_index & size)) { + mb_list = ring->rx_info + (index << priv->log_rx_info); + rx_desc = ring->buf + (index << ring->log_stride); + + /* + * make sure we read the CQE after we read the ownership bit + */ + rmb(); + + if (invalid_cqe(priv, cqe)) { + goto next; + } + /* + * Packet is OK - process it. + */ + length = be32_to_cpu(cqe->byte_cnt); + length -= ring->fcs_del; + mb = mlx4_en_rx_mb(priv, rx_desc, mb_list, length); + if (!mb) { + ring->errors++; + goto next; + } + + ring->bytes += length; + ring->packets++; + + if (unlikely(priv->validate_loopback)) { + validate_loopback(priv, mb); + goto next; + } + + mb->m_pkthdr.flowid = cq->ring; + mb->m_flags |= M_FLOWID; + mb->m_pkthdr.rcvif = dev; + if (be32_to_cpu(cqe->vlan_my_qpn) & + MLX4_CQE_VLAN_PRESENT_MASK) { + mb->m_pkthdr.ether_vtag = be16_to_cpu(cqe->sl_vid); + mb->m_flags |= M_VLANTAG; + } + if (likely(dev->if_capabilities & IFCAP_RXCSUM) && + (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) && + (cqe->checksum == cpu_to_be16(0xffff))) { + priv->port_stats.rx_chksum_good++; + mb->m_pkthdr.csum_flags = + CSUM_IP_CHECKED | CSUM_IP_VALID | + CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + mb->m_pkthdr.csum_data = htons(0xffff); + /* This packet is eligible for LRO if it is: + * - DIX Ethernet (type interpretation) + * - TCP/IP (v4) + * - without IP options + * - not an IP fragment + */ +#ifdef INET + if (mlx4_en_can_lro(cqe->status) && + (dev->if_capenable & IFCAP_LRO)) { + if (ring->lro.lro_cnt != 0 && + tcp_lro_rx(&ring->lro, mb, 0) == 0) + goto next; + } + +#endif + /* LRO not possible, complete processing here */ + INC_PERF_COUNTER(priv->pstats.lro_misses); + } else { + mb->m_pkthdr.csum_flags = 0; + priv->port_stats.rx_chksum_none++; + } + + /* Push it up the stack */ + dev->if_input(dev, mb); + +next: + ++cons_index; + index = cons_index & size_mask; + cqe = &buf[CQE_FACTOR_INDEX(index, factor)]; + if (++polled == budget) + goto out; + } + /* Flush all pending IP reassembly sessions */ +out: +#ifdef INET + while ((queued = SLIST_FIRST(&ring->lro.lro_active)) != NULL) { + SLIST_REMOVE_HEAD(&ring->lro.lro_active, next); + tcp_lro_flush(&ring->lro, queued); + } +#endif + AVG_PERF_COUNTER(priv->pstats.rx_coal_avg, polled); + mcq->cons_index = cons_index; + mlx4_cq_set_ci(mcq); + wmb(); /* ensure HW sees CQ consumer before we post new buffers */ + ring->cons = mcq->cons_index; + ring->prod += polled; /* Polled descriptors were realocated in place */ + mlx4_en_update_rx_prod_db(ring); + return polled; + +} + +/* Rx CQ polling - called by NAPI */ +static int mlx4_en_poll_rx_cq(struct mlx4_en_cq *cq, int budget) +{ + struct net_device *dev = cq->dev; + int done; + + done = mlx4_en_process_rx_cq(dev, cq, budget); + cq->tot_rx += done; + + return done; + +} +void mlx4_en_rx_irq(struct mlx4_cq *mcq) +{ + struct mlx4_en_cq *cq = container_of(mcq, struct mlx4_en_cq, mcq); + struct mlx4_en_priv *priv = netdev_priv(cq->dev); + int done; + + // Shoot one within the irq context + // Because there is no NAPI in freeBSD + done = mlx4_en_poll_rx_cq(cq, MLX4_EN_RX_BUDGET); + if (priv->port_up && (done == MLX4_EN_RX_BUDGET) ) { + taskqueue_enqueue(cq->tq, &cq->cq_task); + } + else { + mlx4_en_arm_cq(priv, cq); + } +} + +void mlx4_en_rx_que(void *context, int pending) +{ + struct mlx4_en_cq *cq; + + cq = context; + while (mlx4_en_poll_rx_cq(cq, MLX4_EN_RX_BUDGET) + == MLX4_EN_RX_BUDGET); + mlx4_en_arm_cq(cq->dev->if_softc, cq); +} + + /* RSS related functions */ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, @@ -672,6 +726,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, en_err(priv, "Failed to allocate qp context\n"); return -ENOMEM; } + err = mlx4_qp_alloc(mdev->dev, qpn, qp); if (err) { en_err(priv, "Failed to allocate qp #%x\n", qpn); @@ -681,9 +736,16 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, memset(context, 0, sizeof *context); mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0, - qpn, ring->cqn, context); + qpn, ring->cqn, -1, context); context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma); + /* Cancel FCS removal if FW allows */ + if (mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_FCS_KEEP) { + context->param3 |= cpu_to_be32(1 << 29); + ring->fcs_del = ETH_FCS_LEN; + } else + ring->fcs_del = 0; + err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, context, qp, state); if (err) { mlx4_qp_remove(mdev->dev, qp); @@ -695,26 +757,57 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, return err; } +int mlx4_en_create_drop_qp(struct mlx4_en_priv *priv) +{ + int err; + u32 qpn; + + err = mlx4_qp_reserve_range(priv->mdev->dev, 1, 1, &qpn, 0); + if (err) { + en_err(priv, "Failed reserving drop qpn\n"); + return err; + } + err = mlx4_qp_alloc(priv->mdev->dev, qpn, &priv->drop_qp); + if (err) { + en_err(priv, "Failed allocating drop qp\n"); + mlx4_qp_release_range(priv->mdev->dev, qpn, 1); + return err; + } + + return 0; +} + +void mlx4_en_destroy_drop_qp(struct mlx4_en_priv *priv) +{ + u32 qpn; + + qpn = priv->drop_qp.qpn; + mlx4_qp_remove(priv->mdev->dev, &priv->drop_qp); + mlx4_qp_free(priv->mdev->dev, &priv->drop_qp); + mlx4_qp_release_range(priv->mdev->dev, qpn, 1); +} + /* Allocate rx qp's and configure them according to rss map */ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) { struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_rss_map *rss_map = &priv->rss_map; struct mlx4_qp_context context; - struct mlx4_en_rss_context *rss_context; + struct mlx4_rss_context *rss_context; + int rss_rings; void *ptr; - u8 rss_mask; - int i, qpn; + u8 rss_mask = (MLX4_RSS_IPV4 | MLX4_RSS_TCP_IPV4 | MLX4_RSS_IPV6 | + MLX4_RSS_TCP_IPV6); + int i; int err = 0; int good_qps = 0; + static const u32 rsskey[10] = { 0xD181C62C, 0xF7F4DB5B, 0x1983A2FC, + 0x943E1ADB, 0xD9389E6B, 0xD1039C2C, 0xA74499AD, + 0x593D56D9, 0xF3253C06, 0x2ADC1FFC}; - if (mdev->profile.udp_rss) - rss_mask = 0x3f; - else - rss_mask = 0x14; en_dbg(DRV, priv, "Configuring rss steering\n"); err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num, - roundup_pow_of_two(priv->rx_ring_num), + priv->rx_ring_num, &rss_map->base_qpn, 0); if (err) { en_err(priv, "Failed reserving %d qps\n", priv->rx_ring_num); @@ -722,9 +815,9 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) } for (i = 0; i < priv->rx_ring_num; i++) { - qpn = rss_map->base_qpn + i; - err = mlx4_en_config_rss_qp(priv, qpn, - &priv->rx_ring[i], + priv->rx_ring[i]->qpn = rss_map->base_qpn + i; + err = mlx4_en_config_rss_qp(priv, priv->rx_ring[i]->qpn, + priv->rx_ring[i], &rss_map->state[i], &rss_map->qps[i]); if (err) @@ -734,28 +827,34 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) } /* Configure RSS indirection qp */ - err = mlx4_qp_reserve_range(mdev->dev, 1, 1, &priv->base_qpn, 0); - if (err) { - en_err(priv, "Failed to reserve range for RSS " - "indirection qp\n"); - goto rss_err; - } err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, &rss_map->indir_qp); if (err) { en_err(priv, "Failed to allocate RSS indirection QP\n"); - goto reserve_err; + goto rss_err; } rss_map->indir_qp.event = mlx4_en_sqp_event; mlx4_en_fill_qp_context(priv, 0, 0, 0, 1, priv->base_qpn, - priv->rx_ring[0].cqn, &context); + priv->rx_ring[0]->cqn, -1, &context); - ptr = ((void *) &context) + 0x3c; - rss_context = (struct mlx4_en_rss_context *) ptr; - rss_context->base_qpn = cpu_to_be32(ilog2(priv->rx_ring_num) << 24 | + if (!priv->prof->rss_rings || priv->prof->rss_rings > priv->rx_ring_num) + rss_rings = priv->rx_ring_num; + else + rss_rings = priv->prof->rss_rings; + + ptr = ((void *) &context) + offsetof(struct mlx4_qp_context, pri_path) + + MLX4_RSS_OFFSET_IN_QPC_PRI_PATH; + rss_context = ptr; + rss_context->base_qpn = cpu_to_be32(ilog2(rss_rings) << 24 | (rss_map->base_qpn)); rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn); + if (priv->mdev->profile.udp_rss) { + rss_mask |= MLX4_RSS_UDP_IPV4 | MLX4_RSS_UDP_IPV6; + rss_context->base_qpn_udp = rss_context->default_qpn; + } rss_context->flags = rss_mask; - rss_context->base_qpn_udp = rss_context->default_qpn; + rss_context->hash_fn = MLX4_RSS_HASH_TOP; + for (i = 0; i < 10; i++) + rss_context->rss_key[i] = cpu_to_be32(rsskey[i]); err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, &context, &rss_map->indir_qp, &rss_map->indir_state); @@ -769,8 +868,6 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) MLX4_QP_STATE_RST, NULL, 0, 0, &rss_map->indir_qp); mlx4_qp_remove(mdev->dev, &rss_map->indir_qp); mlx4_qp_free(mdev->dev, &rss_map->indir_qp); -reserve_err: - mlx4_qp_release_range(mdev->dev, priv->base_qpn, 1); rss_err: for (i = 0; i < good_qps; i++) { mlx4_qp_modify(mdev->dev, NULL, rss_map->state[i], @@ -792,7 +889,6 @@ void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv) MLX4_QP_STATE_RST, NULL, 0, 0, &rss_map->indir_qp); mlx4_qp_remove(mdev->dev, &rss_map->indir_qp); mlx4_qp_free(mdev->dev, &rss_map->indir_qp); - mlx4_qp_release_range(mdev->dev, priv->base_qpn, 1); for (i = 0; i < priv->rx_ring_num; i++) { mlx4_qp_modify(mdev->dev, NULL, rss_map->state[i], @@ -802,3 +898,4 @@ void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv) } mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, priv->rx_ring_num); } + diff --git a/sys/ofed/drivers/net/mlx4/en_selftest.c b/sys/ofed/drivers/net/mlx4/en_selftest.c index 0e62027321c7..2a28315d5965 100644 --- a/sys/ofed/drivers/net/mlx4/en_selftest.c +++ b/sys/ofed/drivers/net/mlx4/en_selftest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -31,24 +31,24 @@ * */ -#include "mlx4_en.h" - #include #include #include #include #include +#include "mlx4_en.h" + static int mlx4_en_test_registers(struct mlx4_en_priv *priv) { return mlx4_cmd(priv->mdev->dev, 0, 0, 0, MLX4_CMD_HW_HEALTH_CHECK, - MLX4_CMD_TIME_CLASS_A); + MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); } static int mlx4_en_test_loopback_xmit(struct mlx4_en_priv *priv) { - struct mbuf *mb; + struct sk_buff *skb; struct ethhdr *ethh; unsigned char *packet; unsigned int packet_size = MLX4_LOOPBACK_TEST_PAYLOAD; @@ -57,24 +57,24 @@ static int mlx4_en_test_loopback_xmit(struct mlx4_en_priv *priv) /* build the pkt before xmit */ - mb = netdev_alloc_mb(priv->dev, MLX4_LOOPBACK_TEST_PAYLOAD + ETH_HLEN + NET_IP_ALIGN); - if (!mb) { - en_err(priv, "-LOOPBACK_TEST_XMIT- failed to create mb for xmit\n"); + skb = netdev_alloc_skb(priv->dev, MLX4_LOOPBACK_TEST_PAYLOAD + ETH_HLEN + NET_IP_ALIGN); + if (!skb) { + en_err(priv, "-LOOPBACK_TEST_XMIT- failed to create skb for xmit\n"); return -ENOMEM; } - mb_reserve(mb, NET_IP_ALIGN); + skb_reserve(skb, NET_IP_ALIGN); - ethh = (struct ethhdr *)mb_put(mb, sizeof(struct ethhdr)); - packet = (unsigned char *)mb_put(mb, packet_size); + ethh = (struct ethhdr *)skb_put(skb, sizeof(struct ethhdr)); + packet = (unsigned char *)skb_put(skb, packet_size); memcpy(ethh->h_dest, priv->dev->dev_addr, ETH_ALEN); memset(ethh->h_source, 0, ETH_ALEN); ethh->h_proto = htons(ETH_P_ARP); - mb_set_mac_header(mb, 0); + skb_set_mac_header(skb, 0); for (i = 0; i < packet_size; ++i) /* fill our packet */ packet[i] = (unsigned char)(i & 0xff); /* xmit the pkt */ - err = mlx4_en_xmit(mb, priv->dev); + err = mlx4_en_xmit(skb, priv->dev); return err; } @@ -87,6 +87,8 @@ static int mlx4_en_test_loopback(struct mlx4_en_priv *priv) priv->loopback_ok = 0; priv->validate_loopback = 1; + mlx4_en_update_loopback_state(priv->dev, priv->dev->features); + /* xmit */ if (mlx4_en_test_loopback_xmit(priv)) { en_err(priv, "Transmitting loopback packet failed\n"); @@ -107,7 +109,8 @@ static int mlx4_en_test_loopback(struct mlx4_en_priv *priv) mlx4_en_test_loopback_exit: priv->validate_loopback = 0; - return (!loopback_ok); + mlx4_en_update_loopback_state(priv->dev, priv->dev->features); + return !loopback_ok; } @@ -127,8 +130,10 @@ static int mlx4_en_test_speed(struct mlx4_en_priv *priv) if (mlx4_en_QUERY_PORT(priv->mdev, priv->port)) return -ENOMEM; - /* The device currently only supports 10G speed */ - if (priv->port_state.link_speed != SPEED_10000) + /* The device supports 1G, 10G and 40G speed */ + if (priv->port_state.link_speed != MLX4_EN_LINK_SPEED_1G && + priv->port_state.link_speed != MLX4_EN_LINK_SPEED_10G && + priv->port_state.link_speed != MLX4_EN_LINK_SPEED_40G) return priv->port_state.link_speed; return 0; } @@ -138,7 +143,6 @@ void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; - struct mlx4_en_tx_ring *tx_ring; int i, carrier_ok; memset(buf, 0, sizeof(u64) * MLX4_EN_NUM_SELF_TEST); @@ -148,20 +152,16 @@ void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf) carrier_ok = netif_carrier_ok(dev); netif_carrier_off(dev); -retry_tx: - /* Wait untill all tx queues are empty. + /* Wait until all tx queues are empty. * there should not be any additional incoming traffic * since we turned the carrier off */ msleep(200); - for (i = 0; i < priv->tx_ring_num && carrier_ok; i++) { - tx_ring = &priv->tx_ring[i]; - if (tx_ring->prod != (tx_ring->cons + tx_ring->last_nr_txbb)) - goto retry_tx; - } - if (priv->mdev->dev->caps.loopback_support){ + if (priv->mdev->dev->caps.flags & + MLX4_DEV_CAP_FLAG_UC_LOOPBACK) { buf[3] = mlx4_en_test_registers(priv); - buf[4] = mlx4_en_test_loopback(priv); + if (priv->port_up) + buf[4] = mlx4_en_test_loopback(priv); } if (carrier_ok) diff --git a/sys/ofed/drivers/net/mlx4/en_tx.c b/sys/ofed/drivers/net/mlx4/en_tx.c index 4661024a3eb8..94ac8c547d2d 100644 --- a/sys/ofed/drivers/net/mlx4/en_tx.c +++ b/sys/ofed/drivers/net/mlx4/en_tx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -31,15 +31,13 @@ * */ -#include "mlx4_en.h" - +#include #include +#include #include +#include #include - -#include -#include -#include +#include #include #include @@ -50,59 +48,78 @@ #include #include +#include "mlx4_en.h" +#include "utils.h" + enum { MAX_INLINE = 104, /* 128 - 16 - 4 - 4 */ MAX_BF = 256, + MIN_PKT_LEN = 17, }; -static int inline_thold = MAX_INLINE; +static int inline_thold __read_mostly = MAX_INLINE; -module_param_named(inline_thold, inline_thold, int, 0444); -MODULE_PARM_DESC(inline_thold, "treshold for using inline data"); +module_param_named(inline_thold, inline_thold, uint, 0444); +MODULE_PARM_DESC(inline_thold, "threshold for using inline data"); int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_tx_ring *ring, u32 size, - u16 stride) + struct mlx4_en_tx_ring **pring, u32 size, + u16 stride, int node, int queue_idx) { struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_tx_ring *ring; int tmp; int err; + ring = kzalloc_node(sizeof(struct mlx4_en_tx_ring), GFP_KERNEL, node); + if (!ring) { + ring = kzalloc(sizeof(struct mlx4_en_tx_ring), GFP_KERNEL); + if (!ring) { + en_err(priv, "Failed allocating TX ring\n"); + return -ENOMEM; + } + } + ring->size = size; ring->size_mask = size - 1; ring->stride = stride; - - inline_thold = min(inline_thold, MAX_INLINE); - + ring->full_size = ring->size - HEADROOM - MAX_DESC_TXBBS; + ring->inline_thold = min(inline_thold, MAX_INLINE); mtx_init(&ring->tx_lock.m, "mlx4 tx", NULL, MTX_DEF); mtx_init(&ring->comp_lock.m, "mlx4 comp", NULL, MTX_DEF); /* Allocate the buf ring */ ring->br = buf_ring_alloc(MLX4_EN_DEF_TX_QUEUE_SIZE, M_DEVBUF, - M_WAITOK, &ring->tx_lock.m); + M_WAITOK, &ring->tx_lock.m); if (ring->br == NULL) { en_err(priv, "Failed allocating tx_info ring\n"); return -ENOMEM; } tmp = size * sizeof(struct mlx4_en_tx_info); - ring->tx_info = kmalloc(tmp, GFP_KERNEL); + ring->tx_info = vmalloc_node(tmp, node); if (!ring->tx_info) { - en_err(priv, "Failed allocating tx_info ring\n"); - err = -ENOMEM; - goto err_tx; + ring->tx_info = vmalloc(tmp); + if (!ring->tx_info) { + err = -ENOMEM; + goto err_ring; + } } + en_dbg(DRV, priv, "Allocated tx_info ring at addr:%p size:%d\n", ring->tx_info, tmp); - ring->bounce_buf = kmalloc(MAX_DESC_SIZE, GFP_KERNEL); + ring->bounce_buf = kmalloc_node(MAX_DESC_SIZE, GFP_KERNEL, node); if (!ring->bounce_buf) { - en_err(priv, "Failed allocating bounce buffer\n"); - err = -ENOMEM; - goto err_tx; + ring->bounce_buf = kmalloc(MAX_DESC_SIZE, GFP_KERNEL); + if (!ring->bounce_buf) { + err = -ENOMEM; + goto err_info; + } } ring->buf_size = ALIGN(size * ring->stride, MLX4_EN_PAGE_SIZE); + /* Allocate HW buffers on provided NUMA node */ err = mlx4_alloc_hwq_res(mdev->dev, &ring->wqres, ring->buf_size, 2 * PAGE_SIZE); if (err) { @@ -122,9 +139,10 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, "buf_size:%d dma:%llx\n", ring, ring->buf, ring->size, ring->buf_size, (unsigned long long) ring->wqres.buf.direct.map); - err = mlx4_qp_reserve_range(mdev->dev, 1, 256, &ring->qpn, MLX4_RESERVE_BF_QP); + err = mlx4_qp_reserve_range(mdev->dev, 1, 1, &ring->qpn, + MLX4_RESERVE_BF_QP); if (err) { - en_err(priv, "Failed reserving qp for tx ring.\n"); + en_err(priv, "failed reserving qp for TX ring\n"); goto err_map; } @@ -135,14 +153,19 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, } ring->qp.event = mlx4_en_sqp_event; - err = mlx4_bf_alloc(mdev->dev, &ring->bf, 0); + err = mlx4_bf_alloc(mdev->dev, &ring->bf, node); if (err) { + en_dbg(DRV, priv, "working without blueflame (%d)", err); ring->bf.uar = &mdev->priv_uar; ring->bf.uar->map = mdev->uar_map; ring->bf_enabled = false; } else ring->bf_enabled = true; + ring->queue_index = queue_idx; + if (queue_idx < priv->num_tx_rings_p_up ) + CPU_SET(queue_idx, &ring->affinity_mask); + *pring = ring; return 0; err_reserve: @@ -153,18 +176,19 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size); err_bounce: kfree(ring->bounce_buf); - ring->bounce_buf = NULL; -err_tx: +err_info: + vfree(ring->tx_info); +err_ring: buf_ring_free(ring->br, M_DEVBUF); - kfree(ring->tx_info); - ring->tx_info = NULL; + kfree(ring); return err; } void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_tx_ring *ring) + struct mlx4_en_tx_ring **pring) { struct mlx4_en_dev *mdev = priv->mdev; + struct mlx4_en_tx_ring *ring = *pring; en_dbg(DRV, priv, "Destroying tx ring, qpn: %d\n", ring->qpn); buf_ring_free(ring->br, M_DEVBUF); @@ -172,20 +196,20 @@ void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, mlx4_bf_free(mdev->dev, &ring->bf); mlx4_qp_remove(mdev->dev, &ring->qp); mlx4_qp_free(mdev->dev, &ring->qp); - mlx4_qp_release_range(mdev->dev, ring->qpn, 1); + mlx4_qp_release_range(priv->mdev->dev, ring->qpn, 1); mlx4_en_unmap_buffer(&ring->wqres.buf); mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size); kfree(ring->bounce_buf); - ring->bounce_buf = NULL; - kfree(ring->tx_info); - ring->tx_info = NULL; + vfree(ring->tx_info); mtx_destroy(&ring->tx_lock.m); mtx_destroy(&ring->comp_lock.m); + kfree(ring); + *pring = NULL; } int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring, - int cq) + int cq, int user_prio) { struct mlx4_en_dev *mdev = priv->mdev; int err; @@ -200,16 +224,15 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, memset(ring->buf, 0, ring->buf_size); ring->qp_state = MLX4_QP_STATE_RST; - ring->doorbell_qpn = swab32(ring->qp.qpn << 8); + ring->doorbell_qpn = ring->qp.qpn << 8; mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 1, 0, ring->qpn, - ring->cqn, &ring->context); + ring->cqn, user_prio, &ring->context); if (ring->bf_enabled) ring->context.usr_page = cpu_to_be32(ring->bf.uar->index); err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, &ring->context, &ring->qp, &ring->qp_state); - return err; } @@ -222,65 +245,98 @@ void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv, MLX4_QP_STATE_RST, NULL, 0, 0, &ring->qp); } +static void mlx4_en_stamp_wqe(struct mlx4_en_priv *priv, + struct mlx4_en_tx_ring *ring, + int index, u8 owner) +{ + struct mlx4_en_tx_info *tx_info = &ring->tx_info[index]; + struct mlx4_en_tx_desc *tx_desc = ring->buf + index * TXBB_SIZE; + void *end = ring->buf + ring->buf_size; + __be32 *ptr = (__be32 *)tx_desc; + __be32 stamp = cpu_to_be32(STAMP_VAL | (!!owner << STAMP_SHIFT)); + int i; + + /* Optimize the common case when there are no wraparounds */ + if (likely((void *)tx_desc + tx_info->nr_txbb * TXBB_SIZE <= end)) + /* Stamp the freed descriptor */ + for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) { + *ptr = stamp; + ptr += STAMP_DWORDS; + } + else + /* Stamp the freed descriptor */ + for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) { + *ptr = stamp; + ptr += STAMP_DWORDS; + if ((void *)ptr >= end) { + ptr = ring->buf; + stamp ^= cpu_to_be32(0x80000000); + } + } +} static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring, - int index, u8 owner) + int index, u8 owner, u64 timestamp) { struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_tx_info *tx_info = &ring->tx_info[index]; struct mlx4_en_tx_desc *tx_desc = ring->buf + index * TXBB_SIZE; struct mlx4_wqe_data_seg *data = (void *) tx_desc + tx_info->data_offset; - struct mbuf *mb = tx_info->mb; + struct mbuf *mb = tx_info->mb; void *end = ring->buf + ring->buf_size; - int frags = tx_info->nr_segs; + int frags = tx_info->nr_segs;; int i; - __be32 *ptr = (__be32 *)tx_desc; - __be32 stamp = cpu_to_be32(STAMP_VAL | (!!owner << STAMP_SHIFT)); /* Optimize the common case when there are no wraparounds */ if (likely((void *) tx_desc + tx_info->nr_txbb * TXBB_SIZE <= end)) { if (!tx_info->inl) { + if (tx_info->linear) { + dma_unmap_single(priv->ddev, + (dma_addr_t) be64_to_cpu(data->addr), + be32_to_cpu(data->byte_count), + PCI_DMA_TODEVICE); + ++data; + } + for (i = 0; i < frags; i++) { - pci_unmap_single(mdev->pdev, - (dma_addr_t) be64_to_cpu(data[i].addr), - data[i].byte_count, PCI_DMA_TODEVICE); + pci_unmap_single(mdev->pdev, + (dma_addr_t) be64_to_cpu(data[i].addr), + data[i].byte_count, PCI_DMA_TODEVICE); } } - /* Stamp the freed descriptor */ - for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) { - *ptr = stamp; - ptr += STAMP_DWORDS; - } - } else { if (!tx_info->inl) { + if ((void *) data >= end) { + data = ring->buf + ((void *)data - end); + } + + if (tx_info->linear) { + dma_unmap_single(priv->ddev, + (dma_addr_t) be64_to_cpu(data->addr), + be32_to_cpu(data->byte_count), + PCI_DMA_TODEVICE); + ++data; + } + for (i = 0; i < frags; i++) { /* Check for wraparound before unmapping */ if ((void *) data >= end) - data = (struct mlx4_wqe_data_seg *) ring->buf; - pci_unmap_single(mdev->pdev, - (dma_addr_t) be64_to_cpu(data->addr), - data->byte_count, PCI_DMA_TODEVICE); + data = ring->buf; + pci_unmap_single(mdev->pdev, + (dma_addr_t) be64_to_cpu(data->addr), + data->byte_count, PCI_DMA_TODEVICE); ++data; } } - /* Stamp the freed descriptor */ - for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) { - *ptr = stamp; - ptr += STAMP_DWORDS; - if ((void *) ptr >= end) { - ptr = ring->buf; - stamp ^= cpu_to_be32(0x80000000); - } - } - } - m_freem(mb); + /* Send a copy of the frame to the BPF listener */ + if (priv->dev && priv->dev->if_bpf) + ETHER_BPF_MTAP(priv->dev, mb); + m_freem(mb); return tx_info->nr_txbb; } - int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring) { struct mlx4_en_priv *priv = netdev_priv(dev); @@ -292,14 +348,14 @@ int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring) ring->cons, ring->prod); if ((u32) (ring->prod - ring->cons) > ring->size) { - en_warn(priv, "Tx consumer passed producer!\n"); + en_warn(priv, "Tx consumer passed producer!\n"); return 0; } while (ring->cons != ring->prod) { ring->last_nr_txbb = mlx4_en_free_tx_desc(priv, ring, ring->cons & ring->size_mask, - !!(ring->cons & ring->size)); + !!(ring->cons & ring->size), 0); ring->cons += ring->last_nr_txbb; cnt++; } @@ -310,109 +366,105 @@ int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring) return cnt; } -void mlx4_en_set_prio_map(struct mlx4_en_priv *priv, u16 *prio_map, u32 ring_num) -{ - int block = 8 / ring_num; - int extra = 8 - (block * ring_num); - int num = 0; - u16 ring = 1; - int prio; - - if (ring_num == 1) { - for (prio = 0; prio < 8; prio++) - prio_map[prio] = 0; - return; - } - - for (prio = 0; prio < 8; prio++) { - if (extra && (num == block + 1)) { - ring++; - num = 0; - extra--; - } else if (!extra && (num == block)) { - ring++; - num = 0; - } - prio_map[prio] = ring; - en_dbg(DRV, priv, " prio:%d --> ring:%d\n", prio, ring); - num++; - } -} - -static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq) +static int mlx4_en_process_tx_cq(struct net_device *dev, + struct mlx4_en_cq *cq) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_cq *mcq = &cq->mcq; - struct mlx4_en_tx_ring *ring = &priv->tx_ring[cq->ring]; - struct mlx4_cqe *cqe = cq->buf; + struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring]; + struct mlx4_cqe *cqe; u16 index; - u16 new_index; + u16 new_index, ring_index, stamp_index; u32 txbbs_skipped = 0; - u32 cq_last_sav; + u32 txbbs_stamp = 0; + u32 cons_index = mcq->cons_index; + int size = cq->size; + u32 size_mask = ring->size_mask; + struct mlx4_cqe *buf = cq->buf; + u32 packets = 0; + u32 bytes = 0; + int factor = priv->cqe_factor; + u64 timestamp = 0; + int done = 0; - /* index always points to the first TXBB of the last polled descriptor */ - index = ring->cons & ring->size_mask; - new_index = be16_to_cpu(cqe->wqe_index) & ring->size_mask; - if (index == new_index) - return; if (!priv->port_up) - return; + return 0; + + index = cons_index & size_mask; + cqe = &buf[(index << factor) + factor]; + ring_index = ring->cons & size_mask; + stamp_index = ring_index; + + /* Process all completed CQEs */ + while (XNOR(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK, + cons_index & size)) { + /* + * make sure we read the CQE after we read the + * ownership bit + */ + rmb(); + + if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == + MLX4_CQE_OPCODE_ERROR)) { + en_err(priv, "CQE completed in error - vendor syndrom: 0x%x syndrom: 0x%x\n", + ((struct mlx4_err_cqe *)cqe)-> + vendor_err_syndrome, + ((struct mlx4_err_cqe *)cqe)->syndrome); + } + + /* Skip over last polled CQE */ + new_index = be16_to_cpu(cqe->wqe_index) & size_mask; - /* - * We use a two-stage loop: - * - the first samples the HW-updated CQE - * - the second frees TXBBs until the last sample - * This lets us amortize CQE cache misses, while still polling the CQ - * until is quiescent. - */ - cq_last_sav = mcq->cons_index; - do { do { - /* Skip over last polled CQE */ - index = (index + ring->last_nr_txbb) & ring->size_mask; txbbs_skipped += ring->last_nr_txbb; - - /* Poll next CQE */ + ring_index = (ring_index + ring->last_nr_txbb) & size_mask; + /* free next descriptor */ ring->last_nr_txbb = mlx4_en_free_tx_desc( - priv, ring, index, - !!((ring->cons + txbbs_skipped) & - ring->size)); - ++mcq->cons_index; + priv, ring, ring_index, + !!((ring->cons + txbbs_skipped) & + ring->size), timestamp); + mlx4_en_stamp_wqe(priv, ring, stamp_index, + !!((ring->cons + txbbs_stamp) & + ring->size)); + stamp_index = ring_index; + txbbs_stamp = txbbs_skipped; + packets++; + bytes += ring->tx_info[ring_index].nr_bytes; + } while (ring_index != new_index); - } while (index != new_index); + ++cons_index; + index = cons_index & size_mask; + cqe = &buf[(index << factor) + factor]; + } - new_index = be16_to_cpu(cqe->wqe_index) & ring->size_mask; - } while (index != new_index); - AVG_PERF_COUNTER(priv->pstats.tx_coal_avg, - (u32) (mcq->cons_index - cq_last_sav)); /* * To prevent CQ overflow we first update CQ consumer and only then * the ring consumer. */ + mcq->cons_index = cons_index; mlx4_cq_set_ci(mcq); wmb(); ring->cons += txbbs_skipped; - /* Wakeup Tx queue if this ring stopped it */ - if (unlikely(ring->blocked)) { - if ((u32) (ring->prod - ring->cons) <= - ring->size - HEADROOM - MAX_DESC_TXBBS) { - ring->blocked = 0; - if (atomic_fetchadd_int(&priv->blocked, -1) == 1) - atomic_clear_int(&dev->if_drv_flags, - IFF_DRV_OACTIVE); - priv->port_stats.wake_queue++; - } + /* Wakeup Tx queue if it was stopped and ring is not full */ + if (unlikely(ring->blocked) && + (ring->prod - ring->cons) <= ring->full_size) { + ring->blocked = 0; + if (atomic_fetchadd_int(&priv->blocked, -1) == 1) + atomic_clear_int(&dev->if_drv_flags ,IFF_DRV_OACTIVE); + ring->wake_queue++; + priv->port_stats.wake_queue++; } + return done; } void mlx4_en_tx_irq(struct mlx4_cq *mcq) { struct mlx4_en_cq *cq = container_of(mcq, struct mlx4_en_cq, mcq); struct mlx4_en_priv *priv = netdev_priv(cq->dev); - struct mlx4_en_tx_ring *ring = &priv->tx_ring[cq->ring]; + struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring]; if (!spin_trylock(&ring->comp_lock)) return; @@ -421,12 +473,11 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq) spin_unlock(&ring->comp_lock); } - void mlx4_en_poll_tx_cq(unsigned long data) { struct mlx4_en_cq *cq = (struct mlx4_en_cq *) data; struct mlx4_en_priv *priv = netdev_priv(cq->dev); - struct mlx4_en_tx_ring *ring = &priv->tx_ring[cq->ring]; + struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring]; u32 inflight; INC_PERF_COUNTER(priv->pstats.tx_poll); @@ -477,8 +528,8 @@ static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv, static inline void mlx4_en_xmit_poll(struct mlx4_en_priv *priv, int tx_ind) { - struct mlx4_en_cq *cq = &priv->tx_cq[tx_ind]; - struct mlx4_en_tx_ring *ring = &priv->tx_ring[tx_ind]; + struct mlx4_en_cq *cq = priv->tx_cq[tx_ind]; + struct mlx4_en_tx_ring *ring = priv->tx_ring[tx_ind]; /* If we don't have a pending timer, set one up to catch our recent post in case the interface becomes idle */ @@ -493,14 +544,13 @@ static inline void mlx4_en_xmit_poll(struct mlx4_en_priv *priv, int tx_ind) } } -static int is_inline(struct mbuf *mb) +static int is_inline(struct mbuf *mb, int thold) { - - if (inline_thold && mb->m_pkthdr.len <= inline_thold && - (mb->m_pkthdr.csum_flags & CSUM_TSO) == 0) + if (thold && mb->m_pkthdr.len <= thold && + (mb->m_pkthdr.csum_flags & CSUM_TSO) == 0) return 1; - return 0; + return 0; } static int inline_size(struct mbuf *mb) @@ -519,81 +569,108 @@ static int inline_size(struct mbuf *mb) static int get_head_size(struct mbuf *mb) { - struct tcphdr *th; - struct ip *ip; - int ip_hlen, tcp_hlen; - int len; + struct ether_vlan_header *eh; + struct tcphdr *th; + struct ip *ip; + int ip_hlen, tcp_hlen; + struct ip6_hdr *ip6; + uint16_t eth_type; + int eth_hdr_len; - len = ETHER_HDR_LEN; - if (mb->m_len < len + sizeof(struct ip)) + eh = mtod(mb, struct ether_vlan_header *); + if (mb->m_len < ETHER_HDR_LEN) return (0); - ip = (struct ip *)(mtod(mb, char *) + len); - if (ip->ip_p != IPPROTO_TCP) + if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { + eth_type = ntohs(eh->evl_proto); + eth_hdr_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; + } else { + eth_type = ntohs(eh->evl_encap_proto); + eth_hdr_len = ETHER_HDR_LEN; + } + if (mb->m_len < eth_hdr_len) return (0); - ip_hlen = ip->ip_hl << 2; - len += ip_hlen; - if (mb->m_len < len + sizeof(struct tcphdr)) + switch (eth_type) { + case ETHERTYPE_IP: + ip = (struct ip *)(mb->m_data + eth_hdr_len); + if (mb->m_len < eth_hdr_len + sizeof(*ip)) + return (0); + if (ip->ip_p != IPPROTO_TCP) + return (0); + ip_hlen = ip->ip_hl << 2; + eth_hdr_len += ip_hlen; + break; + case ETHERTYPE_IPV6: + ip6 = (struct ip6_hdr *)(mb->m_data + eth_hdr_len); + if (mb->m_len < eth_hdr_len + sizeof(*ip6)) + return (0); + if (ip6->ip6_nxt != IPPROTO_TCP) + return (0); + eth_hdr_len += sizeof(*ip6); + break; + default: return (0); - th = (struct tcphdr *)(mtod(mb, char *) + len); + } + if (mb->m_len < eth_hdr_len + sizeof(*th)) + return (0); + th = (struct tcphdr *)(mb->m_data + eth_hdr_len); tcp_hlen = th->th_off << 2; - len += tcp_hlen; - if (mb->m_len < len) + eth_hdr_len += tcp_hlen; + if (mb->m_len < eth_hdr_len) return (0); - return (len); + return (eth_hdr_len); } -static int get_real_size(struct mbuf *mb, struct net_device *dev, int *segsp, - int *lso_header_size) +static int get_real_size(struct mbuf *mb, struct net_device *dev, int *p_n_segs, + int *lso_header_size, int inl) { - struct mbuf *m; - int nr_segs; + struct mbuf *m; + int nr_segs = 0; - nr_segs = 0; - for (m = mb; m != NULL; m = m->m_next) - if (m->m_len) - nr_segs++; + for (m = mb; m != NULL; m = m->m_next) + if (m->m_len) + nr_segs++; - if (mb->m_pkthdr.csum_flags & CSUM_TSO) { - *lso_header_size = get_head_size(mb); - if (*lso_header_size) { - if (mb->m_len == *lso_header_size) - nr_segs--; - *segsp = nr_segs; - return CTRL_SIZE + nr_segs * DS_SIZE + - ALIGN(*lso_header_size + 4, DS_SIZE); - } - } else - *lso_header_size = 0; - *segsp = nr_segs; - if (is_inline(mb)) - return inline_size(mb); - return (CTRL_SIZE + nr_segs * DS_SIZE); + if (mb->m_pkthdr.csum_flags & CSUM_TSO) { + *lso_header_size = get_head_size(mb); + if (*lso_header_size) { + if (mb->m_len == *lso_header_size) + nr_segs--; + *p_n_segs = nr_segs; + return CTRL_SIZE + nr_segs * DS_SIZE + + ALIGN(*lso_header_size + 4, DS_SIZE); + } + } else + *lso_header_size = 0; + *p_n_segs = nr_segs; + if (inl) + return inline_size(mb); + return (CTRL_SIZE + nr_segs * DS_SIZE); } static struct mbuf *mb_copy(struct mbuf *mb, int *offp, char *data, int len) { - int bytes; - int off; + int bytes; + int off; - off = *offp; - while (len) { - bytes = min(mb->m_len - off, len); - if (bytes) - memcpy(data, mb->m_data + off, bytes); - len -= bytes; - data += bytes; - off += bytes; - if (off == mb->m_len) { - off = 0; - mb = mb->m_next; - } - } - *offp = off; - return (mb); + off = *offp; + while (len) { + bytes = min(mb->m_len - off, len); + if (bytes) + memcpy(data, mb->m_data + off, bytes); + len -= bytes; + data += bytes; + off += bytes; + if (off == mb->m_len) { + off = 0; + mb = mb->m_next; + } + } + *offp = off; + return (mb); } static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct mbuf *mb, - int real_size, u16 *vlan_tag, int tx_ind) + int real_size, u16 *vlan_tag, int tx_ind) { struct mlx4_wqe_inline_seg *inl = &tx_desc->inl; int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl; @@ -603,8 +680,12 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct mbuf *mb, off = 0; len = mb->m_pkthdr.len; if (len <= spc) { - inl->byte_count = cpu_to_be32(1 << 31 | len); + inl->byte_count = cpu_to_be32(1 << 31 | + (max_t(typeof(len), len, MIN_PKT_LEN))); mb_copy(mb, &off, (void *)(inl + 1), len); + if (len < MIN_PKT_LEN) + memset(((void *)(inl + 1)) + len, 0, + MIN_PKT_LEN - len); } else { inl->byte_count = cpu_to_be32(1 << 31 | spc); mb = mb_copy(mb, &off, (void *)(inl + 1), spc); @@ -618,74 +699,50 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct mbuf *mb, tx_desc->ctrl.fence_size = (real_size / 16) & 0x3f; } +static unsigned long hashrandom; +static void hashrandom_init(void *arg) +{ + hashrandom = random(); +} +SYSINIT(hashrandom_init, SI_SUB_KLD, SI_ORDER_SECOND, &hashrandom_init, NULL); + u16 mlx4_en_select_queue(struct net_device *dev, struct mbuf *mb) { struct mlx4_en_priv *priv = netdev_priv(dev); - struct mlx4_en_tx_hash_entry *entry; - struct ether_header *eth; - struct tcphdr *th; - struct ip *iph; - u32 hash_index; - int tx_ind = 0; - u16 vlan_tag = 0; - int len; + u32 rings_p_up = priv->num_tx_rings_p_up; + u32 vlan_tag = 0; + u32 up = 0; + u32 queue_index; /* Obtain VLAN information if present */ if (mb->m_flags & M_VLANTAG) { vlan_tag = mb->m_pkthdr.ether_vtag; - /* Set the Tx ring to use according to vlan priority */ - tx_ind = priv->tx_prio_map[vlan_tag >> 13]; - if (tx_ind) - return tx_ind; - } - if (mb->m_len < - ETHER_HDR_LEN + sizeof(struct ip) + sizeof(struct tcphdr)) - return MLX4_EN_NUM_HASH_RINGS; - eth = mtod(mb, struct ether_header *); - /* Hashing is only done for TCP/IP or UDP/IP packets */ - if (be16_to_cpu(eth->ether_type) != ETHERTYPE_IP) - return MLX4_EN_NUM_HASH_RINGS; - len = ETHER_HDR_LEN; - iph = (struct ip *)(mtod(mb, char *) + len); - len += iph->ip_hl << 2; - th = (struct tcphdr *)(mtod(mb, char *) + len); - hash_index = be32_to_cpu(iph->ip_dst.s_addr) & MLX4_EN_TX_HASH_MASK; - switch(iph->ip_p) { - case IPPROTO_UDP: - break; - case IPPROTO_TCP: - if (mb->m_len < len + sizeof(struct tcphdr)) - return MLX4_EN_NUM_HASH_RINGS; - hash_index = - (hash_index ^ be16_to_cpu(th->th_dport ^ th->th_sport)) & - MLX4_EN_TX_HASH_MASK; - break; - default: - return MLX4_EN_NUM_HASH_RINGS; + up = (vlan_tag >> 13); } - entry = &priv->tx_hash[hash_index]; - if(unlikely(!entry->cnt)) { - tx_ind = hash_index & (MLX4_EN_NUM_HASH_RINGS / 2 - 1); - if (2 * entry->small_pkts > entry->big_pkts) - tx_ind += MLX4_EN_NUM_HASH_RINGS / 2; - entry->small_pkts = entry->big_pkts = 0; - entry->ring = tx_ind; - } + /* hash mbuf */ + queue_index = mlx4_en_hashmbuf(MLX4_F_HASHL3 | MLX4_F_HASHL4, mb, hashrandom); - entry->cnt++; - if (mb->m_pkthdr.len > MLX4_EN_SMALL_PKT_SIZE) - entry->big_pkts++; - else - entry->small_pkts++; - return entry->ring; + return ((queue_index % rings_p_up) + (up * rings_p_up)); } -static void mlx4_bf_copy(unsigned long *dst, unsigned long *src, unsigned bytecnt) +static void mlx4_bf_copy(void __iomem *dst, unsigned long *src, unsigned bytecnt) { __iowrite64_copy(dst, src, bytecnt / 8); } +static u64 mlx4_en_mac_to_u64(u8 *addr) +{ + u64 mac = 0; + int i; + + for (i = 0; i < ETHER_ADDR_LEN; i++) { + mac <<= 8; + mac |= addr[i]; + } + return mac; +} + static int mlx4_en_xmit(struct net_device *dev, int tx_ind, struct mbuf **mbp) { struct mlx4_en_priv *priv = netdev_priv(dev); @@ -701,57 +758,73 @@ static int mlx4_en_xmit(struct net_device *dev, int tx_ind, struct mbuf **mbp) int desc_size; int real_size; dma_addr_t dma; - u32 index, bf_index; + u32 index, bf_index, ring_size; __be32 op_own; u16 vlan_tag = 0; int i; int lso_header_size; bool bounce = false; + bool inl = false; struct mbuf *mb; + mb = *mbp; int defrag = 1; - ring = &priv->tx_ring[tx_ind]; - mb = *mbp; if (!priv->port_up) goto tx_drop; + ring = priv->tx_ring[tx_ind]; + ring_size = ring->size; + inl = is_inline(mb, ring->inline_thold); + retry: - real_size = get_real_size(mb, dev, &nr_segs, &lso_header_size); + real_size = get_real_size(mb, dev, &nr_segs, &lso_header_size, inl); if (unlikely(!real_size)) goto tx_drop; - /* Allign descriptor to TXBB size */ + /* Align descriptor to TXBB size */ desc_size = ALIGN(real_size, TXBB_SIZE); nr_txbb = desc_size / TXBB_SIZE; if (unlikely(nr_txbb > MAX_DESC_TXBBS)) { if (defrag) { - mb = m_defrag(*mbp, M_NOWAIT); - if (mb == NULL) { - mb = *mbp; - goto tx_drop; - } - *mbp = mb; - defrag = 0; - goto retry; - } + mb = m_defrag(*mbp, M_NOWAIT); + if (mb == NULL) { + mb = *mbp; + goto tx_drop; + } + *mbp = mb; + defrag = 0; + goto retry; + } + en_warn(priv, "Oversized header or SG list\n"); goto tx_drop; } - /* Check available TXBBs And 2K spare for prefetch */ - if (unlikely(((int)(ring->prod - ring->cons)) > - ring->size - HEADROOM - MAX_DESC_TXBBS)) { + /* Obtain VLAN information if present */ + if (mb->m_flags & M_VLANTAG) { + vlan_tag = mb->m_pkthdr.ether_vtag; + } + + /* Check available TXBBs and 2K spare for prefetch + * Even if netif_tx_stop_queue() will be called + * driver will send current packet to ensure + * that at least one completion will be issued after + * stopping the queue + */ + if (unlikely((int)(ring->prod - ring->cons) > ring->full_size)) { /* every full Tx ring stops queue */ if (ring->blocked == 0) - atomic_add_int(&priv->blocked, 1); + atomic_add_int(&priv->blocked, 1); + /* Set HW-queue-is-full flag */ atomic_set_int(&dev->if_drv_flags, IFF_DRV_OACTIVE); ring->blocked = 1; priv->port_stats.queue_stopped++; + ring->queue_stopped++; /* Use interrupts to find out when queue opened */ - cq = &priv->tx_cq[tx_ind]; + cq = priv->tx_cq[tx_ind]; mlx4_en_arm_cq(priv, cq); return EBUSY; - } + } /* Track current inflight packets for performance analysis */ AVG_PERF_COUNTER(priv->pstats.inflight_avg, @@ -763,128 +836,135 @@ static int mlx4_en_xmit(struct net_device *dev, int tx_ind, struct mbuf **mbp) /* See if we have enough space for whole descriptor TXBB for setting * SW ownership on next descriptor; if not, use a bounce buffer. */ - if (likely(index + nr_txbb <= ring->size)) + if (likely(index + nr_txbb <= ring_size)) tx_desc = ring->buf + index * TXBB_SIZE; else { tx_desc = (struct mlx4_en_tx_desc *) ring->bounce_buf; bounce = true; } + /* Save mb in tx_info ring */ + tx_info = &ring->tx_info[index]; + tx_info->mb = mb; + tx_info->nr_txbb = nr_txbb; + tx_info->nr_segs = nr_segs; + + if (lso_header_size) { + memcpy(tx_desc->lso.header, mb->m_data, lso_header_size); + data = ((void *)&tx_desc->lso + ALIGN(lso_header_size + 4, + DS_SIZE)); + /* lso header is part of m_data. + * need to omit when mapping DMA */ + mb->m_data += lso_header_size; + mb->m_len -= lso_header_size; + } + else + data = &tx_desc->data; + + /* valid only for none inline segments */ + tx_info->data_offset = (void *)data - (void *)tx_desc; + + if (inl) { + tx_info->inl = 1; + } else { + for (i = 0, m = mb; i < nr_segs; i++, m = m->m_next) { + if (m->m_len == 0) { + i--; + continue; + } + dma = pci_map_single(mdev->dev->pdev, m->m_data, + m->m_len, PCI_DMA_TODEVICE); + data->addr = cpu_to_be64(dma); + data->lkey = cpu_to_be32(mdev->mr.key); + wmb(); + data->byte_count = cpu_to_be32(m->m_len); + data++; + } + if (lso_header_size) { + mb->m_data -= lso_header_size; + mb->m_len += lso_header_size; + } + tx_info->inl = 0; + } + + /* Prepare ctrl segement apart opcode+ownership, which depends on * whether LSO is used */ - if (mb->m_flags & M_VLANTAG) - vlan_tag = mb->m_pkthdr.ether_vtag; tx_desc->ctrl.vlan_tag = cpu_to_be16(vlan_tag); - tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_VLAN * !!vlan_tag; + tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_VLAN * + !!vlan_tag; tx_desc->ctrl.fence_size = (real_size / 16) & 0x3f; - tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE | - MLX4_WQE_CTRL_SOLICITED); - if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) { - if (mb->m_pkthdr.csum_flags & CSUM_IP) - tx_desc->ctrl.srcrb_flags |= - cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM); - if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP)) - tx_desc->ctrl.srcrb_flags |= - cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM); + tx_desc->ctrl.srcrb_flags = priv->ctrl_flags; + if (mb->m_pkthdr.csum_flags & (CSUM_IP | CSUM_TSO | + CSUM_TCP | CSUM_UDP | CSUM_TCP_IPV6 | CSUM_UDP_IPV6)) { + if (mb->m_pkthdr.csum_flags & (CSUM_IP | CSUM_TSO)) + tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM); + if (mb->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP | + CSUM_UDP_IPV6 | CSUM_TCP_IPV6 | CSUM_TSO)) + tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM); priv->port_stats.tx_chksum_offload++; - } + ring->tx_csum++; + } if (unlikely(priv->validate_loopback)) { /* Copy dst mac address to wqe */ - struct ether_header *ethh; - u64 mac; - u32 mac_l, mac_h; + struct ether_header *ethh; + u64 mac; + u32 mac_l, mac_h; - ethh = mtod(mb, struct ether_header *); - mac = mlx4_en_mac_to_u64(ethh->ether_dhost); - if (mac) { - mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16); - mac_l = (u32) (mac & 0xffffffff); - tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h); - tx_desc->ctrl.imm = cpu_to_be32(mac_l); - } + ethh = mtod(mb, struct ether_header *); + mac = mlx4_en_mac_to_u64(ethh->ether_dhost); + if (mac) { + mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16); + mac_l = (u32) (mac & 0xffffffff); + tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h); + tx_desc->ctrl.imm = cpu_to_be32(mac_l); + } } /* Handle LSO (TSO) packets */ if (lso_header_size) { int segsz; - /* Mark opcode as LSO */ op_own = cpu_to_be32(MLX4_OPCODE_LSO | (1 << 6)) | - ((ring->prod & ring->size) ? + ((ring->prod & ring_size) ? cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0); /* Fill in the LSO prefix */ tx_desc->lso.mss_hdr_size = cpu_to_be32( mb->m_pkthdr.tso_segsz << 16 | lso_header_size); - /* Copy headers; - * note that we already verified that it is linear */ - memcpy(tx_desc->lso.header, mb->m_data, lso_header_size); - data = ((void *) &tx_desc->lso + - ALIGN(lso_header_size + 4, DS_SIZE)); - - priv->port_stats.tso_packets++; - segsz = mb->m_pkthdr.tso_segsz; - i = ((mb->m_pkthdr.len - lso_header_size) / segsz) + - !!((mb->m_pkthdr.len - lso_header_size) % segsz); - ring->bytes += mb->m_pkthdr.len + (i - 1) * lso_header_size; - ring->packets += i; - mb->m_data += lso_header_size; - mb->m_len -= lso_header_size; + priv->port_stats.tso_packets++; + segsz = mb->m_pkthdr.tso_segsz; + i = ((mb->m_pkthdr.len - lso_header_size + segsz - 1) / segsz); + tx_info->nr_bytes= mb->m_pkthdr.len + (i - 1) * lso_header_size; + ring->packets += i; } else { /* Normal (Non LSO) packet */ op_own = cpu_to_be32(MLX4_OPCODE_SEND) | - ((ring->prod & ring->size) ? + ((ring->prod & ring_size) ? cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0); - data = &tx_desc->data; - ring->bytes += max(mb->m_pkthdr.len, - (unsigned int)ETHER_MIN_LEN - ETHER_CRC_LEN); + tx_info->nr_bytes = max(mb->m_pkthdr.len, + (unsigned int)ETHER_MIN_LEN - ETHER_CRC_LEN); ring->packets++; } + ring->bytes += tx_info->nr_bytes; AVG_PERF_COUNTER(priv->pstats.tx_pktsz_avg, mb->m_pkthdr.len); - /* Save mb in tx_info ring */ - tx_info = &ring->tx_info[index]; - tx_info->mb = mb; - tx_info->nr_txbb = nr_txbb; - tx_info->nr_segs = nr_segs; - /* valid only for non inline segments */ - tx_info->data_offset = (void *) data - (void *) tx_desc; - - if (!is_inline(mb)) { - for (i = 0, m = mb; i < nr_segs; i++, m = m->m_next) { - if (m->m_len == 0) { - i--; - continue; - } - dma = pci_map_single(mdev->dev->pdev, m->m_data, - m->m_len, PCI_DMA_TODEVICE); - data->addr = cpu_to_be64(dma); - data->lkey = cpu_to_be32(mdev->mr.key); - wmb(); - data->byte_count = cpu_to_be32(m->m_len); - data++; - } - if (lso_header_size) { - mb->m_data -= lso_header_size; - mb->m_len += lso_header_size; - } - tx_info->inl = 0; - } else { + if (tx_info->inl) { build_inline_wqe(tx_desc, mb, real_size, &vlan_tag, tx_ind); tx_info->inl = 1; } ring->prod += nr_txbb; - /* If we used a bounce buffer then copy descriptor back into place */ - if (bounce) - tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size); + /* If we used a bounce buffer then copy descriptor back into place */ + if (unlikely(bounce)) + tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size); if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tag) { - *(u32 *) (&tx_desc->ctrl.vlan_tag) |= ring->doorbell_qpn; + *(__be32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn); op_own |= htonl((bf_index & 0xffff) << 8); /* Ensure new descirptor hits memory * before setting ownership of this descriptor to HW */ @@ -905,19 +985,16 @@ static int mlx4_en_xmit(struct net_device *dev, int tx_ind, struct mbuf **mbp) wmb(); tx_desc->ctrl.owner_opcode = op_own; wmb(); - writel(ring->doorbell_qpn, ring->bf.uar->map + MLX4_SEND_DOORBELL); + writel(cpu_to_be32(ring->doorbell_qpn), ring->bf.uar->map + MLX4_SEND_DOORBELL); } return 0; - tx_drop: *mbp = NULL; m_freem(mb); - ring->errors++; return EINVAL; } - static int mlx4_en_transmit_locked(struct ifnet *dev, int tx_ind, struct mbuf *m) { @@ -926,12 +1003,12 @@ mlx4_en_transmit_locked(struct ifnet *dev, int tx_ind, struct mbuf *m) struct mbuf *next; int enqueued, err = 0; - ring = &priv->tx_ring[tx_ind]; + ring = priv->tx_ring[tx_ind]; if ((dev->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING || priv->port_up == 0) { if (m != NULL) err = drbr_enqueue(dev, ring->br, m); - return (err); + return (err); } enqueued = 0; @@ -951,11 +1028,6 @@ mlx4_en_transmit_locked(struct ifnet *dev, int tx_ind, struct mbuf *m) } drbr_advance(dev, ring->br); enqueued++; - dev->if_obytes += next->m_pkthdr.len; - if (next->m_flags & M_MCAST) - dev->if_omcasts++; - /* Send a copy of the frame to the BPF listener */ - ETHER_BPF_MTAP(dev, next); if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0) break; } @@ -974,12 +1046,11 @@ mlx4_en_tx_que(void *context, int pending) struct net_device *dev; struct mlx4_en_cq *cq; int tx_ind; - cq = context; dev = cq->dev; priv = dev->if_softc; tx_ind = cq->ring; - ring = &priv->tx_ring[tx_ind]; + ring = priv->tx_ring[tx_ind]; if (dev->if_drv_flags & IFF_DRV_RUNNING) { mlx4_en_xmit_poll(priv, tx_ind); spin_lock(&ring->tx_lock); @@ -998,12 +1069,13 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) int i = 0, err = 0; /* Which queue to use */ - if ((m->m_flags & (M_FLOWID | M_VLANTAG)) == M_FLOWID) - i = m->m_pkthdr.flowid % (MLX4_EN_NUM_HASH_RINGS - 1); - else + if ((m->m_flags & (M_FLOWID | M_VLANTAG)) == M_FLOWID) { + i = m->m_pkthdr.flowid % (priv->tx_ring_num - 1); + } + else { i = mlx4_en_select_queue(dev, m); - - ring = &priv->tx_ring[i]; + } + ring = priv->tx_ring[i]; if (spin_trylock(&ring->tx_lock)) { err = mlx4_en_transmit_locked(dev, i, m); @@ -1012,7 +1084,7 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) mlx4_en_xmit_poll(priv, i); } else { err = drbr_enqueue(dev, ring->br, m); - cq = &priv->tx_cq[i]; + cq = priv->tx_cq[i]; taskqueue_enqueue(cq->tq, &cq->cq_task); } @@ -1026,10 +1098,11 @@ void mlx4_en_qflush(struct ifnet *dev) { struct mlx4_en_priv *priv = netdev_priv(dev); - struct mlx4_en_tx_ring *ring = priv->tx_ring; + struct mlx4_en_tx_ring *ring; struct mbuf *m; - for (int i = 0; i < priv->tx_ring_num; i++, ring++) { + for (int i = 0; i < priv->tx_ring_num; i++) { + ring = priv->tx_ring[i]; spin_lock(&ring->tx_lock); while ((m = buf_ring_dequeue_sc(ring->br)) != NULL) m_freem(m); diff --git a/sys/ofed/drivers/net/mlx4/eq.c b/sys/ofed/drivers/net/mlx4/eq.c index b585e8cbfcff..31fafbe01d72 100644 --- a/sys/ofed/drivers/net/mlx4/eq.c +++ b/sys/ofed/drivers/net/mlx4/eq.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -86,6 +87,8 @@ static u64 get_async_ev_mask(struct mlx4_dev *dev) u64 async_ev_mask = MLX4_ASYNC_EVENT_MASK; if (dev->caps.flags & MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV) async_ev_mask |= (1ull << MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT); + if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT) + async_ev_mask |= (1ull << MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT); return async_ev_mask; } @@ -147,12 +150,9 @@ void mlx4_gen_slave_eqe(struct work_struct *work) /* All active slaves need to receive the event */ if (slave == ALL_SLAVES) { for (i = 0; i < dev->num_slaves; i++) { - if (i != dev->caps.function && - master->slave_state[i].active) - if (mlx4_GEN_EQE(dev, i, eqe)) - mlx4_warn(dev, "Failed to " - " generate event " - "for slave %d\n", i); + if (mlx4_GEN_EQE(dev, i, eqe)) + mlx4_warn(dev, "Failed to generate " + "event for slave %d\n", i); } } else { if (mlx4_GEN_EQE(dev, slave, eqe)) @@ -197,13 +197,13 @@ static void mlx4_slave_event(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe) { struct mlx4_priv *priv = mlx4_priv(dev); - struct mlx4_slave_state *s_slave = - &priv->mfunc.master.slave_state[slave]; - if (!s_slave->active) { - /*mlx4_warn(dev, "Trying to pass event to inactive slave\n");*/ + if (slave < 0 || slave >= dev->num_slaves || + slave == dev->caps.function) + return; + + if (!priv->mfunc.master.slave_state[slave].active) return; - } slave_event(dev, slave, eqe); } @@ -375,7 +375,7 @@ int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave, EXPORT_SYMBOL(set_and_calc_slave_port_state); -int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr) +int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr, u16 sm_lid, u8 sm_sl) { struct mlx4_eqe eqe; @@ -386,6 +386,12 @@ int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr) eqe.event.port_mgmt_change.port = port; eqe.event.port_mgmt_change.params.port_info.changed_attr = cpu_to_be32((u32) attr); + if (attr & MSTR_SM_CHANGE_MASK) { + eqe.event.port_mgmt_change.params.port_info.mstr_sm_lid = + cpu_to_be16(sm_lid); + eqe.event.port_mgmt_change.params.port_info.mstr_sm_sl = + sm_sl; + } slave_event(dev, ALL_SLAVES, &eqe); return 0; @@ -446,6 +452,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) int i; enum slave_port_gen_event gen_event; unsigned long flags; + struct mlx4_vport_state *s_info; while ((eqe = next_eqe_sw(eq, dev->caps.eqe_factor))) { /* @@ -495,8 +502,9 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) break; case MLX4_EVENT_TYPE_SRQ_LIMIT: - mlx4_warn(dev, "%s: MLX4_EVENT_TYPE_SRQ_LIMIT\n", - __func__); + mlx4_dbg(dev, "%s: MLX4_EVENT_TYPE_SRQ_LIMIT\n", + __func__); + /* fall through */ case MLX4_EVENT_TYPE_SRQ_CATAS_ERROR: if (mlx4_is_master(dev)) { /* forward only to slave owning the SRQ */ @@ -513,17 +521,15 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) eq->eqn, eq->cons_index, ret); break; } - mlx4_warn(dev, "%s: slave:%d, srq_no:0x%x," - " event: %02x(%02x)\n", __func__, - slave, - be32_to_cpu(eqe->event.srq.srqn), - eqe->type, eqe->subtype); + mlx4_dbg(dev, "%s: slave:%d, srq_no:0x%x, event: %02x(%02x)\n", + __func__, slave, + be32_to_cpu(eqe->event.srq.srqn), + eqe->type, eqe->subtype); if (!ret && slave != dev->caps.function) { - mlx4_warn(dev, "%s: sending event " - "%02x(%02x) to slave:%d\n", - __func__, eqe->type, - eqe->subtype, slave); + mlx4_dbg(dev, "%s: sending event %02x(%02x) to slave:%d\n", + __func__, eqe->type, + eqe->subtype, slave); mlx4_slave_event(dev, slave, eqe); break; } @@ -554,7 +560,9 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) mlx4_dbg(dev, "%s: Sending MLX4_PORT_CHANGE_SUBTYPE_DOWN" " to slave: %d, port:%d\n", __func__, i, port); - mlx4_slave_event(dev, i, eqe); + s_info = &priv->mfunc.master.vf_oper[slave].vport[port].state; + if (IFLA_VF_LINK_STATE_AUTO == s_info->link_state) + mlx4_slave_event(dev, i, eqe); } else { /* IB port */ set_and_calc_slave_port_state(dev, i, port, MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN, @@ -578,7 +586,9 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) for (i = 0; i < dev->num_slaves; i++) { if (i == mlx4_master_func_num(dev)) continue; - mlx4_slave_event(dev, i, eqe); + s_info = &priv->mfunc.master.vf_oper[slave].vport[port].state; + if (IFLA_VF_LINK_STATE_AUTO == s_info->link_state) + mlx4_slave_event(dev, i, eqe); } else /* IB port */ /* port-up event will be sent to a slave when the @@ -635,11 +645,18 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) "for non master device\n"); break; } + memcpy(&priv->mfunc.master.comm_arm_bit_vector, eqe->event.comm_channel_arm.bit_vec, sizeof eqe->event.comm_channel_arm.bit_vec); - queue_work(priv->mfunc.master.comm_wq, - &priv->mfunc.master.comm_work); + + if (!queue_work(priv->mfunc.master.comm_wq, + &priv->mfunc.master.comm_work)) + mlx4_warn(dev, "Failed to queue comm channel work\n"); + + if (!queue_work(priv->mfunc.master.comm_wq, + &priv->mfunc.master.arm_comm_work)) + mlx4_warn(dev, "Failed to queue arm comm channel work\n"); break; case MLX4_EVENT_TYPE_FLR_EVENT: @@ -704,6 +721,27 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq) (unsigned long) eqe); break; + case MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT: + switch (eqe->subtype) { + case MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_BAD_CABLE: + mlx4_warn(dev, "Bad cable detected on port %u\n", + eqe->event.bad_cable.port); + break; + case MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_UNSUPPORTED_CABLE: + mlx4_warn(dev, "Unsupported cable detected\n"); + break; + default: + mlx4_dbg(dev, "Unhandled recoverable error event " + "detected: %02x(%02x) on EQ %d at index %u. " + "owner=%x, nent=0x%x, ownership=%s\n", + eqe->type, eqe->subtype, eq->eqn, + eq->cons_index, eqe->owner, eq->nent, + !!(eqe->owner & 0x80) ^ + !!(eq->cons_index & eq->nent) ? "HW" : "SW"); + break; + } + break; + case MLX4_EVENT_TYPE_EEC_CATAS_ERROR: case MLX4_EVENT_TYPE_ECC_DETECT: default: @@ -747,7 +785,6 @@ static irqreturn_t mlx4_interrupt(int irq, void *dev_ptr) int work = 0; int i; - writel(priv->eq_table.clr_mask, priv->eq_table.clr_int); for (i = 0; i < dev->caps.num_comp_vectors + 1; ++i) @@ -777,7 +814,7 @@ int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_slave_event_eq_info *event_eq = priv->mfunc.master.slave_state[slave].event_eq; u32 in_modifier = vhcr->in_modifier; - u32 eqn = in_modifier & 0x1FF; + u32 eqn = in_modifier & 0x3FF; u64 in_param = vhcr->in_param; int err = 0; int i; @@ -956,7 +993,7 @@ static int mlx4_create_eq(struct mlx4_dev *dev, int nent, mlx4_mtt_cleanup(dev, &eq->mtt); err_out_free_eq: - mlx4_bitmap_free(&priv->eq_table.bitmap, eq->eqn); + mlx4_bitmap_free(&priv->eq_table.bitmap, eq->eqn, MLX4_USE_RR); err_out_free_pages: for (i = 0; i < npages; ++i) @@ -1011,7 +1048,7 @@ static void mlx4_free_eq(struct mlx4_dev *dev, eq->page_list[i].map); kfree(eq->page_list); - mlx4_bitmap_free(&priv->eq_table.bitmap, eq->eqn); + mlx4_bitmap_free(&priv->eq_table.bitmap, eq->eqn, MLX4_USE_RR); mlx4_free_cmd_mailbox(dev, mailbox); } @@ -1306,7 +1343,7 @@ int mlx4_test_interrupts(struct mlx4_dev *dev) } EXPORT_SYMBOL(mlx4_test_interrupts); -int mlx4_assign_eq(struct mlx4_dev *dev, char *name, int *vector) +int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector) { struct mlx4_priv *priv = mlx4_priv(dev); diff --git a/sys/ofed/drivers/net/mlx4/fw.c b/sys/ofed/drivers/net/mlx4/fw.c index cf079eab233c..93f7f714700f 100644 --- a/sys/ofed/drivers/net/mlx4/fw.c +++ b/sys/ofed/drivers/net/mlx4/fw.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -32,8 +32,10 @@ * SOFTWARE. */ +#include #include #include +#include #include "fw.h" #include "icm.h" @@ -106,6 +108,7 @@ static void dump_dev_cap_flags(struct mlx4_dev *dev, u64 flags) [40] = "UDP RSS support", [41] = "Unicast VEP steering support", [42] = "Multicast VEP steering support", + [44] = "Cross-channel (sync_qp) operations support", [48] = "Counters support", [59] = "Port management change event support", [60] = "eSwitch support", @@ -126,7 +129,18 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags) [0] = "RSS support", [1] = "RSS Toeplitz Hash Function support", [2] = "RSS XOR Hash Function support", - [3] = "Device manage flow steering support" + [3] = "Device manage flow steering support", + [4] = "FSM (MAC unti-spoofing) support", + [5] = "VST (control vlan insertion/stripping) support", + [6] = "Dynamic QP updates support", + [7] = "Loopback source checks support", + [8] = "Device managed flow steering IPoIB support", + [9] = "ETS configuration support", + [10] = "ETH backplane autoneg report", + [11] = "Ethernet Flow control statistics support", + [12] = "Recoverable error events support", + [13] = "Time stamping support", + [14] = "Report driver version to FW support" }; int i; @@ -170,7 +184,7 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_cmd_info *cmd) { struct mlx4_priv *priv = mlx4_priv(dev); - u8 field; + u8 field, port; u32 size; int err = 0; @@ -178,23 +192,32 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, #define QUERY_FUNC_CAP_NUM_PORTS_OFFSET 0x1 #define QUERY_FUNC_CAP_PF_BHVR_OFFSET 0x4 #define QUERY_FUNC_CAP_FMR_OFFSET 0x8 -#define QUERY_FUNC_CAP_QP_QUOTA_OFFSET 0x10 -#define QUERY_FUNC_CAP_CQ_QUOTA_OFFSET 0x14 -#define QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET 0x18 -#define QUERY_FUNC_CAP_MPT_QUOTA_OFFSET 0x20 -#define QUERY_FUNC_CAP_MTT_QUOTA_OFFSET 0x24 -#define QUERY_FUNC_CAP_MCG_QUOTA_OFFSET 0x28 +#define QUERY_FUNC_CAP_QP_QUOTA_OFFSET_DEP 0x10 +#define QUERY_FUNC_CAP_CQ_QUOTA_OFFSET_DEP 0x14 +#define QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET_DEP 0x18 +#define QUERY_FUNC_CAP_MPT_QUOTA_OFFSET_DEP 0x20 +#define QUERY_FUNC_CAP_MTT_QUOTA_OFFSET_DEP 0x24 +#define QUERY_FUNC_CAP_MCG_QUOTA_OFFSET_DEP 0x28 #define QUERY_FUNC_CAP_MAX_EQ_OFFSET 0x2c #define QUERY_FUNC_CAP_RESERVED_EQ_OFFSET 0x30 +#define QUERY_FUNC_CAP_QP_QUOTA_OFFSET 0x50 +#define QUERY_FUNC_CAP_CQ_QUOTA_OFFSET 0x54 +#define QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET 0x58 +#define QUERY_FUNC_CAP_MPT_QUOTA_OFFSET 0x60 +#define QUERY_FUNC_CAP_MTT_QUOTA_OFFSET 0x64 +#define QUERY_FUNC_CAP_MCG_QUOTA_OFFSET 0x68 + #define QUERY_FUNC_CAP_FMR_FLAG 0x80 #define QUERY_FUNC_CAP_FLAG_RDMA 0x40 #define QUERY_FUNC_CAP_FLAG_ETH 0x80 +#define QUERY_FUNC_CAP_FLAG_QUOTAS 0x10 /* when opcode modifier = 1 */ #define QUERY_FUNC_CAP_PHYS_PORT_OFFSET 0x3 -#define QUERY_FUNC_CAP_RDMA_PROPS_OFFSET 0x8 -#define QUERY_FUNC_CAP_ETH_PROPS_OFFSET 0xc +#define QUERY_FUNC_CAP_FLAGS0_OFFSET 0x8 +#define QUERY_FUNC_CAP_FLAGS1_OFFSET 0xc +#define QUERY_FUNC_CAP_COUNTER_INDEX_OFFSET 0xd #define QUERY_FUNC_CAP_QP0_TUNNEL 0x10 #define QUERY_FUNC_CAP_QP0_PROXY 0x14 @@ -203,35 +226,45 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, #define QUERY_FUNC_CAP_ETH_PROPS_FORCE_MAC 0x40 #define QUERY_FUNC_CAP_ETH_PROPS_FORCE_VLAN 0x80 +#define QUERY_FUNC_CAP_PROPS_DEF_COUNTER 0x20 #define QUERY_FUNC_CAP_RDMA_PROPS_FORCE_PHY_WQE_GID 0x80 if (vhcr->op_modifier == 1) { - field = 0; - /* ensure force vlan and force mac bits are not set */ - MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_ETH_PROPS_OFFSET); - /* ensure that phy_wqe_gid bit is not set */ - MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_RDMA_PROPS_OFFSET); + port = vhcr->in_modifier; /* phys-port = logical-port */ + MLX4_PUT(outbox->buf, port, QUERY_FUNC_CAP_PHYS_PORT_OFFSET); - field = vhcr->in_modifier; /* phys-port = logical-port */ - MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_PHYS_PORT_OFFSET); + field = 0; + /* ensure that phy_wqe_gid bit is not set */ + MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS0_OFFSET); + + /* ensure force vlan and force mac bits are not set + * and that default counter bit is set + */ + field = QUERY_FUNC_CAP_PROPS_DEF_COUNTER; /* def counter */ + MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS1_OFFSET); + + /* There is always default counter legal or sink counter */ + field = mlx4_get_default_counter_index(dev, slave, vhcr->in_modifier); + MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_COUNTER_INDEX_OFFSET); /* size is now the QP number */ - size = dev->phys_caps.base_tunnel_sqpn + 8 * slave + field - 1; + size = dev->phys_caps.base_tunnel_sqpn + 8 * slave + port - 1; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP0_TUNNEL); size += 2; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP1_TUNNEL); - size = dev->phys_caps.base_proxy_sqpn + 8 * slave + field - 1; + size = dev->phys_caps.base_proxy_sqpn + 8 * slave + port - 1; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP0_PROXY); size += 2; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP1_PROXY); } else if (vhcr->op_modifier == 0) { - /* enable rdma and ethernet interfaces */ - field = (QUERY_FUNC_CAP_FLAG_ETH | QUERY_FUNC_CAP_FLAG_RDMA); + /* enable rdma and ethernet interfaces, and new quota locations */ + field = (QUERY_FUNC_CAP_FLAG_ETH | QUERY_FUNC_CAP_FLAG_RDMA | + QUERY_FUNC_CAP_FLAG_QUOTAS); MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS_OFFSET); field = dev->caps.num_ports; @@ -245,12 +278,18 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, size = priv->mfunc.master.res_tracker.res_alloc[RES_QP].quota[slave]; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP_QUOTA_OFFSET); + size = dev->caps.num_qps; + MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP_QUOTA_OFFSET_DEP); size = priv->mfunc.master.res_tracker.res_alloc[RES_SRQ].quota[slave]; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET); + size = dev->caps.num_srqs; + MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET_DEP); size = priv->mfunc.master.res_tracker.res_alloc[RES_CQ].quota[slave]; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET); + size = dev->caps.num_cqs; + MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET_DEP); size = dev->caps.num_eqs; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MAX_EQ_OFFSET); @@ -260,12 +299,17 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, size = priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[slave]; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET); + size = dev->caps.num_mpts; + MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET_DEP); size = priv->mfunc.master.res_tracker.res_alloc[RES_MTT].quota[slave]; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET); + size = dev->caps.num_mtts; + MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET_DEP); size = dev->caps.num_mgms + dev->caps.num_amgms; MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET); + MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET_DEP); } else err = -EINVAL; @@ -280,7 +324,7 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, u32 *outbox; u8 field, op_modifier; u32 size; - int err = 0; + int err = 0, quotas = 0; op_modifier = !!gen_or_port; /* 0 = general, 1 = logical port */ @@ -304,6 +348,7 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, goto out; } func_cap->flags = field; + quotas = !!(func_cap->flags & QUERY_FUNC_CAP_FLAG_QUOTAS); MLX4_GET(field, outbox, QUERY_FUNC_CAP_NUM_PORTS_OFFSET); func_cap->num_ports = field; @@ -311,29 +356,50 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, MLX4_GET(size, outbox, QUERY_FUNC_CAP_PF_BHVR_OFFSET); func_cap->pf_context_behaviour = size; - MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP_QUOTA_OFFSET); - func_cap->qp_quota = size & 0xFFFFFF; + if (quotas) { + MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP_QUOTA_OFFSET); + func_cap->qp_quota = size & 0xFFFFFF; - MLX4_GET(size, outbox, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET); - func_cap->srq_quota = size & 0xFFFFFF; + MLX4_GET(size, outbox, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET); + func_cap->srq_quota = size & 0xFFFFFF; - MLX4_GET(size, outbox, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET); - func_cap->cq_quota = size & 0xFFFFFF; + MLX4_GET(size, outbox, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET); + func_cap->cq_quota = size & 0xFFFFFF; + MLX4_GET(size, outbox, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET); + func_cap->mpt_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET); + func_cap->mtt_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET); + func_cap->mcg_quota = size & 0xFFFFFF; + + } else { + MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP_QUOTA_OFFSET_DEP); + func_cap->qp_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET_DEP); + func_cap->srq_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET_DEP); + func_cap->cq_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET_DEP); + func_cap->mpt_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET_DEP); + func_cap->mtt_quota = size & 0xFFFFFF; + + MLX4_GET(size, outbox, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET_DEP); + func_cap->mcg_quota = size & 0xFFFFFF; + } MLX4_GET(size, outbox, QUERY_FUNC_CAP_MAX_EQ_OFFSET); func_cap->max_eq = size & 0xFFFFFF; MLX4_GET(size, outbox, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET); func_cap->reserved_eq = size & 0xFFFFFF; - MLX4_GET(size, outbox, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET); - func_cap->mpt_quota = size & 0xFFFFFF; - - MLX4_GET(size, outbox, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET); - func_cap->mtt_quota = size & 0xFFFFFF; - - MLX4_GET(size, outbox, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET); - func_cap->mcg_quota = size & 0xFFFFFF; goto out; } @@ -344,7 +410,7 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, } if (dev->caps.port_type[gen_or_port] == MLX4_PORT_TYPE_ETH) { - MLX4_GET(field, outbox, QUERY_FUNC_CAP_ETH_PROPS_OFFSET); + MLX4_GET(field, outbox, QUERY_FUNC_CAP_FLAGS1_OFFSET); if (field & QUERY_FUNC_CAP_ETH_PROPS_FORCE_VLAN) { mlx4_err(dev, "VLAN is enforced on this port\n"); err = -EPROTONOSUPPORT; @@ -357,7 +423,7 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, goto out; } } else if (dev->caps.port_type[gen_or_port] == MLX4_PORT_TYPE_IB) { - MLX4_GET(field, outbox, QUERY_FUNC_CAP_RDMA_PROPS_OFFSET); + MLX4_GET(field, outbox, QUERY_FUNC_CAP_FLAGS0_OFFSET); if (field & QUERY_FUNC_CAP_RDMA_PROPS_FORCE_PHY_WQE_GID) { mlx4_err(dev, "phy_wqe_gid is " "enforced on this ib port\n"); @@ -373,6 +439,14 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, goto out; } + MLX4_GET(field, outbox, QUERY_FUNC_CAP_FLAGS1_OFFSET); + if (field & QUERY_FUNC_CAP_PROPS_DEF_COUNTER) { + MLX4_GET(field, outbox, QUERY_FUNC_CAP_COUNTER_INDEX_OFFSET); + func_cap->def_counter_index = field; + } else { + func_cap->def_counter_index = MLX4_SINK_COUNTER_INDEX; + } + MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_TUNNEL); func_cap->qp0_tunnel_qpn = size & 0xFFFFFF; @@ -466,7 +540,10 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) #define QUERY_DEV_CAP_MAX_XRC_OFFSET 0x67 #define QUERY_DEV_CAP_MAX_BASIC_COUNTERS_OFFSET 0x68 #define QUERY_DEV_CAP_MAX_EXTENDED_COUNTERS_OFFSET 0x6c +#define QUERY_DEV_CAP_PORT_FLOWSTATS_COUNTERS_OFFSET 0x70 #define QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET 0x76 +#define QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET 0x70 +#define QUERY_DEV_CAP_FLOW_STEERING_IPOIB_OFFSET 0x74 #define QUERY_DEV_CAP_FLOW_STEERING_MAX_QP_OFFSET 0x77 #define QUERY_DEV_CAP_RDMARC_ENTRY_SZ_OFFSET 0x80 #define QUERY_DEV_CAP_QPC_ENTRY_SZ_OFFSET 0x82 @@ -480,6 +557,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) #define QUERY_DEV_CAP_D_MPT_ENTRY_SZ_OFFSET 0x92 #define QUERY_DEV_CAP_BMME_FLAGS_OFFSET 0x94 #define QUERY_DEV_CAP_RSVD_LKEY_OFFSET 0x98 +#define QUERY_DEV_CAP_ETS_CFG_OFFSET 0x9c #define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0 dev_cap->flags2 = 0; @@ -551,16 +629,23 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) dev_cap->num_ports = field & 0xf; MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MSG_SZ_OFFSET); dev_cap->max_msg_sz = 1 << (field & 0x1f); + MLX4_GET(field, outbox, QUERY_DEV_CAP_PORT_FLOWSTATS_COUNTERS_OFFSET); + if (field & 0x10) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN; MLX4_GET(field, outbox, QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET); if (field & 0x80) dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_FS_EN; + MLX4_GET(field, outbox, QUERY_DEV_CAP_FLOW_STEERING_IPOIB_OFFSET); + if (field & 0x80) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_DMFS_IPOIB; dev_cap->fs_log_max_ucast_qp_range_size = field & 0x1f; MLX4_GET(field, outbox, QUERY_DEV_CAP_FLOW_STEERING_MAX_QP_OFFSET); dev_cap->fs_max_num_qp_per_entry = field; MLX4_GET(stat_rate, outbox, QUERY_DEV_CAP_RATE_SUPPORT_OFFSET); dev_cap->stat_rate_support = stat_rate; MLX4_GET(field, outbox, QUERY_DEV_CAP_CQ_TS_SUPPORT_OFFSET); - dev_cap->timestamp_support = field & 0x80; + if (field & 0x80) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_TS; MLX4_GET(ext_flags, outbox, QUERY_DEV_CAP_EXT_FLAGS_OFFSET); MLX4_GET(flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET); dev_cap->flags = flags | (u64)ext_flags << 32; @@ -644,6 +729,16 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) QUERY_DEV_CAP_BMME_FLAGS_OFFSET); MLX4_GET(dev_cap->reserved_lkey, outbox, QUERY_DEV_CAP_RSVD_LKEY_OFFSET); + MLX4_GET(field32, outbox, QUERY_DEV_CAP_ETS_CFG_OFFSET); + if (field32 & (1 << 0)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP; + if (field32 & (1 << 7)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT; + if (field32 & (1 << 8)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW; + if (field32 & (1 << 13)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_ETS_CFG; + MLX4_GET(dev_cap->max_icm_sz, outbox, QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET); if (dev_cap->flags & MLX4_DEV_CAP_FLAG_COUNTERS) @@ -655,6 +750,16 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) MLX4_GET(dev_cap->max_extended_counters, outbox, QUERY_DEV_CAP_MAX_EXTENDED_COUNTERS_OFFSET); + MLX4_GET(field32, outbox, QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET); + if (field32 & (1 << 16)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_UPDATE_QP; + if (field32 & (1 << 19)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_LB_SRC_CHK; + if (field32 & (1 << 20)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_FSM; + if (field32 & (1 << 26)) + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_VLAN_CONTROL; + if (dev->flags & MLX4_FLAG_OLD_PORT_CMDS) { for (i = 1; i <= dev_cap->num_ports; ++i) { MLX4_GET(field, outbox, QUERY_DEV_CAP_VL_PORT_OFFSET); @@ -786,6 +891,14 @@ int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave, field &= 0x7f; MLX4_PUT(outbox->buf, field, QUERY_DEV_CAP_BF_OFFSET); + /* turn off device-managed steering capability if not enabled */ + if (dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED) { + MLX4_GET(field, outbox->buf, + QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET); + field &= 0x7f; + MLX4_PUT(outbox->buf, field, + QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET); + } return 0; } @@ -800,8 +913,10 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, u8 port_type; u16 short_field; int err; + int admin_link_state; #define MLX4_VF_PORT_NO_LINK_SENSE_MASK 0xE0 +#define MLX4_PORT_LINK_UP_MASK 0x80 #define QUERY_PORT_CUR_MAX_PKEY_OFFSET 0x0c #define QUERY_PORT_CUR_MAX_GID_OFFSET 0x0e @@ -810,12 +925,8 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, MLX4_CMD_NATIVE); if (!err && dev->caps.function != slave) { - /* set slave default_mac address */ - MLX4_GET(def_mac, outbox->buf, QUERY_PORT_MAC_OFFSET); - def_mac += slave << 8; - /* if config MAC in DB use it */ - if (priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac) - def_mac = priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac; + /* set slave default_mac address to be zero MAC */ + def_mac = priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac; MLX4_PUT(outbox->buf, def_mac, QUERY_PORT_MAC_OFFSET); /* get port type - currently only eth is enabled */ @@ -827,6 +938,12 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, /* set port type to currently operating port type */ port_type |= (dev->caps.port_type[vhcr->in_modifier] & 0x3); + admin_link_state = priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.link_state; + if (IFLA_VF_LINK_STATE_ENABLE == admin_link_state) + port_type |= MLX4_PORT_LINK_UP_MASK; + else if (IFLA_VF_LINK_STATE_DISABLE == admin_link_state) + port_type &= ~MLX4_PORT_LINK_UP_MASK; + MLX4_PUT(outbox->buf, port_type, QUERY_PORT_SUPPORTED_TYPE_OFFSET); @@ -1078,14 +1195,14 @@ int mlx4_QUERY_FW(struct mlx4_dev *dev) MLX4_GET(fw->comm_bar, outbox, QUERY_FW_COMM_BAR_OFFSET); fw->comm_bar = (fw->comm_bar >> 6) * 2; mlx4_dbg(dev, "Communication vector bar:%d offset:0x%llx\n", - fw->comm_bar, (long long)fw->comm_base); + fw->comm_bar, (unsigned long long)fw->comm_base); mlx4_dbg(dev, "FW size %d KB\n", fw->fw_pages >> 2); MLX4_GET(fw->clock_offset, outbox, QUERY_FW_CLOCK_OFFSET); MLX4_GET(fw->clock_bar, outbox, QUERY_FW_CLOCK_BAR); fw->clock_bar = (fw->clock_bar >> 6) * 2; mlx4_dbg(dev, "Internal clock bar:%d offset:0x%llx\n", - fw->comm_bar, (long long)fw->comm_base); + fw->comm_bar, (unsigned long long)fw->comm_base); /* * Round up number of system pages needed in case @@ -1127,7 +1244,7 @@ int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave, return 0; } -static void get_board_id(void *vsd, char *board_id) +static void get_board_id(void *vsd, char *board_id, char *vsdstr) { int i; @@ -1135,9 +1252,16 @@ static void get_board_id(void *vsd, char *board_id) #define VSD_OFFSET_SIG2 0xde #define VSD_OFFSET_MLX_BOARD_ID 0xd0 #define VSD_OFFSET_TS_BOARD_ID 0x20 +#define VSD_LEN 0xd0 #define VSD_SIGNATURE_TOPSPIN 0x5ad + memset(vsdstr, 0, MLX4_VSD_LEN); + + for (i = 0; i < VSD_LEN / 4; i++) + ((u32 *)vsdstr)[i] = + swab32(*(u32 *)(vsd + i * 4)); + memset(board_id, 0, MLX4_BOARD_ID_LEN); if (be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN && @@ -1164,6 +1288,7 @@ int mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter *adapter) #define QUERY_ADAPTER_OUT_SIZE 0x100 #define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10 #define QUERY_ADAPTER_VSD_OFFSET 0x20 +#define QUERY_ADAPTER_VSD_VENDOR_ID_OFFSET 0x1e mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) @@ -1177,8 +1302,11 @@ int mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter *adapter) MLX4_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET); + adapter->vsd_vendor_id = be16_to_cpup((u16 *)outbox + + QUERY_ADAPTER_VSD_VENDOR_ID_OFFSET / 2); + get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4, - adapter->board_id); + adapter->board_id, adapter->vsd); out: mlx4_free_cmd_mailbox(dev, mailbox); @@ -1189,13 +1317,16 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) { struct mlx4_cmd_mailbox *mailbox; __be32 *inbox; + u32 mw_enable; int err; #define INIT_HCA_IN_SIZE 0x200 +#define INIT_HCA_DRV_NAME_FOR_FW_MAX_SIZE 64 #define INIT_HCA_VERSION_OFFSET 0x000 #define INIT_HCA_VERSION 2 #define INIT_HCA_CACHELINE_SZ_OFFSET 0x0e #define INIT_HCA_FLAGS_OFFSET 0x014 +#define INIT_HCA_RECOVERABLE_ERROR_EVENT_OFFSET 0x018 #define INIT_HCA_QPC_OFFSET 0x020 #define INIT_HCA_QPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x10) #define INIT_HCA_LOG_QP_OFFSET (INIT_HCA_QPC_OFFSET + 0x17) @@ -1217,6 +1348,7 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) #define INIT_HCA_UC_STEERING_OFFSET (INIT_HCA_MCAST_OFFSET + 0x18) #define INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b) #define INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN 0x6 +#define INIT_HCA_DRIVER_VERSION_OFFSET 0x140 #define INIT_HCA_FS_PARAM_OFFSET 0x1d0 #define INIT_HCA_FS_BASE_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x00) #define INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x12) @@ -1227,6 +1359,8 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) #define INIT_HCA_FS_IB_NUM_ADDRS_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x26) #define INIT_HCA_TPT_OFFSET 0x0f0 #define INIT_HCA_DMPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x00) +#define INIT_HCA_TPT_MW_OFFSET (INIT_HCA_TPT_OFFSET + 0x08) +#define INIT_HCA_TPT_MW_ENABLE (1 << 31) #define INIT_HCA_LOG_MPT_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x0b) #define INIT_HCA_MTT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x10) #define INIT_HCA_CMPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x18) @@ -1244,7 +1378,7 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) *((u8 *) mailbox->buf + INIT_HCA_VERSION_OFFSET) = INIT_HCA_VERSION; *((u8 *) mailbox->buf + INIT_HCA_CACHELINE_SZ_OFFSET) = - ((ilog2(CACHE_LINE_SIZE) - 4) << 5) | (1 << 4); + ((ilog2(cache_line_size()) - 4) << 5) | (1 << 4); #if defined(__LITTLE_ENDIAN) *(inbox + INIT_HCA_FLAGS_OFFSET / 4) &= ~cpu_to_be32(1 << 1); @@ -1290,6 +1424,17 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) dev->caps.cqe_size = 32; } + if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT) + *(inbox + INIT_HCA_RECOVERABLE_ERROR_EVENT_OFFSET / 4) |= cpu_to_be32(1 << 31); + + if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW) { + strncpy((u8 *)mailbox->buf + INIT_HCA_DRIVER_VERSION_OFFSET, + DRV_NAME_FOR_FW, + INIT_HCA_DRV_NAME_FOR_FW_MAX_SIZE - 1); + mlx4_dbg(dev, "Reporting Driver Version to FW: %s\n", + (u8 *)mailbox->buf + INIT_HCA_DRIVER_VERSION_OFFSET); + } + /* QPC/EEC/CQC/EQC/RDMARC attributes */ MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET); @@ -1339,15 +1484,16 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) INIT_HCA_LOG_MC_HASH_SZ_OFFSET); MLX4_PUT(inbox, param->log_mc_table_sz, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); - if (dev->caps.steering_mode == MLX4_STEERING_MODE_B0) { + if (dev->caps.steering_mode == MLX4_STEERING_MODE_B0) MLX4_PUT(inbox, (u8) (1 << 3), INIT_HCA_UC_STEERING_OFFSET); - } } /* TPT attributes */ MLX4_PUT(inbox, param->dmpt_base, INIT_HCA_DMPT_BASE_OFFSET); + mw_enable = param->mw_enable ? INIT_HCA_TPT_MW_ENABLE : 0; + MLX4_PUT(inbox, mw_enable, INIT_HCA_TPT_MW_OFFSET); MLX4_PUT(inbox, param->log_mpt_sz, INIT_HCA_LOG_MPT_SZ_OFFSET); MLX4_PUT(inbox, param->mtt_base, INIT_HCA_MTT_BASE_OFFSET); MLX4_PUT(inbox, param->cmpt_base, INIT_HCA_CMPT_BASE_OFFSET); @@ -1373,6 +1519,7 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox; __be32 *outbox; u32 dword_field; + u32 mw_enable; int err; u8 byte_field; @@ -1414,13 +1561,12 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, param->steering_mode = MLX4_STEERING_MODE_DEVICE_MANAGED; } else { MLX4_GET(byte_field, outbox, INIT_HCA_UC_STEERING_OFFSET); - if (byte_field & 0x8) { + if (byte_field & 0x8) param->steering_mode = MLX4_STEERING_MODE_B0; - } - else { + else param->steering_mode = MLX4_STEERING_MODE_A0; - } } + /* steering attributes */ if (param->steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) { MLX4_GET(param->mc_base, outbox, INIT_HCA_FS_BASE_OFFSET); MLX4_GET(param->log_mc_entry_sz, outbox, @@ -1447,6 +1593,9 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, /* TPT attributes */ MLX4_GET(param->dmpt_base, outbox, INIT_HCA_DMPT_BASE_OFFSET); + MLX4_GET(mw_enable, outbox, INIT_HCA_TPT_MW_OFFSET); + param->mw_enable = (mw_enable & INIT_HCA_TPT_MW_ENABLE) == + INIT_HCA_TPT_MW_ENABLE; MLX4_GET(param->log_mpt_sz, outbox, INIT_HCA_LOG_MPT_SZ_OFFSET); MLX4_GET(param->mtt_base, outbox, INIT_HCA_MTT_BASE_OFFSET); MLX4_GET(param->cmpt_base, outbox, INIT_HCA_CMPT_BASE_OFFSET); @@ -1682,6 +1831,15 @@ int mlx4_query_diag_counters(struct mlx4_dev *dev, int array_length, } EXPORT_SYMBOL_GPL(mlx4_query_diag_counters); +int mlx4_MOD_STAT_CFG_wrapper(struct mlx4_dev *dev, int slave, + struct mlx4_vhcr *vhcr, + struct mlx4_cmd_mailbox *inbox, + struct mlx4_cmd_mailbox *outbox, + struct mlx4_cmd_info *cmd) +{ + return -EPERM; +} + #define MLX4_WOL_SETUP_MODE (5 << 28) int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port) { diff --git a/sys/ofed/drivers/net/mlx4/fw.h b/sys/ofed/drivers/net/mlx4/fw.h index 5fe77821aeb3..0efd047ec3ad 100644 --- a/sys/ofed/drivers/net/mlx4/fw.h +++ b/sys/ofed/drivers/net/mlx4/fw.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. * * This software is available to you under a choice of one of two @@ -143,10 +143,13 @@ struct mlx4_func_cap { u32 qp1_proxy_qpn; u8 physical_port; u8 port_flags; + u8 def_counter_index; }; struct mlx4_adapter { + u16 vsd_vendor_id; char board_id[MLX4_BOARD_ID_LEN]; + char vsd[MLX4_VSD_LEN]; u8 inta_pin; }; @@ -175,6 +178,8 @@ struct mlx4_init_hca_param { u8 log_mpt_sz; u8 log_uar_sz; u8 uar_page_sz; /* log pg sz in 4k chunks */ + u8 mw_enable; /* Enable memory windows */ + u8 fs_hash_enable_bits; u8 steering_mode; /* for QUERY_HCA */ u64 dev_cap_enabled; }; @@ -218,8 +223,6 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param); int mlx4_CLOSE_HCA(struct mlx4_dev *dev, int panic); int mlx4_map_cmd(struct mlx4_dev *dev, u16 op, struct mlx4_icm *icm, u64 virt); int mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages); -int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm); -int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev); int mlx4_NOP(struct mlx4_dev *dev); int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg); void mlx4_opreq_action(struct work_struct *work); diff --git a/sys/ofed/drivers/net/mlx4/icm.c b/sys/ofed/drivers/net/mlx4/icm.c index d18fde150daa..25ae7b7fb8cc 100644 --- a/sys/ofed/drivers/net/mlx4/icm.c +++ b/sys/ofed/drivers/net/mlx4/icm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -288,10 +289,14 @@ void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj) if (--table->icm[i]->refcount == 0) { offset = (u64) i * MLX4_TABLE_CHUNK_SIZE; - mlx4_UNMAP_ICM(dev, table->virt + offset, - MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE); - mlx4_free_icm(dev, table->icm[i], table->coherent); - table->icm[i] = NULL; + + if (!mlx4_UNMAP_ICM(dev, table->virt + offset, + MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE)) { + mlx4_free_icm(dev, table->icm[i], table->coherent); + table->icm[i] = NULL; + } else { + pr_warn("mlx4_core: mlx4_UNMAP_ICM failed.\n"); + } } mutex_unlock(&table->mutex); @@ -378,7 +383,7 @@ void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, } int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, - u64 virt, int obj_size, u32 nobj, int reserved, + u64 virt, int obj_size, u64 nobj, int reserved, int use_lowmem, int use_coherent) { int obj_per_chunk; @@ -388,7 +393,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, u64 size; obj_per_chunk = MLX4_TABLE_CHUNK_SIZE / obj_size; - num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk; + num_icm = div_u64((nobj + obj_per_chunk - 1), obj_per_chunk); table->icm = kcalloc(num_icm, sizeof *table->icm, GFP_KERNEL); if (!table->icm) @@ -431,11 +436,15 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, err: for (i = 0; i < num_icm; ++i) if (table->icm[i]) { - mlx4_UNMAP_ICM(dev, virt + i * MLX4_TABLE_CHUNK_SIZE, - MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE); - mlx4_free_icm(dev, table->icm[i], use_coherent); + if (!mlx4_UNMAP_ICM(dev, + virt + i * MLX4_TABLE_CHUNK_SIZE, + MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE)) { + mlx4_free_icm(dev, table->icm[i], use_coherent); + } else { + pr_warn("mlx4_core: mlx4_UNMAP_ICM failed.\n"); + return -ENOMEM; + } } - kfree(table->icm); return -ENOMEM; @@ -443,14 +452,22 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, void mlx4_cleanup_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table) { - int i; + int i, err = 0; for (i = 0; i < table->num_icm; ++i) if (table->icm[i]) { - mlx4_UNMAP_ICM(dev, table->virt + i * MLX4_TABLE_CHUNK_SIZE, - MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE); - mlx4_free_icm(dev, table->icm[i], table->coherent); + err = mlx4_UNMAP_ICM(dev, + table->virt + i * MLX4_TABLE_CHUNK_SIZE, + MLX4_TABLE_CHUNK_SIZE / MLX4_ICM_PAGE_SIZE); + if (!err) { + mlx4_free_icm(dev, table->icm[i], + table->coherent); + } else { + pr_warn("mlx4_core: mlx4_UNMAP_ICM failed.\n"); + break; + } } - kfree(table->icm); + if (!err) + kfree(table->icm); } diff --git a/sys/ofed/drivers/net/mlx4/icm.h b/sys/ofed/drivers/net/mlx4/icm.h index f83ad8141dc4..f7a2537bfbc0 100644 --- a/sys/ofed/drivers/net/mlx4/icm.h +++ b/sys/ofed/drivers/net/mlx4/icm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -37,6 +37,7 @@ #include #include #include +#include #define MLX4_ICM_CHUNK_LEN \ ((256 - sizeof (struct list_head) - 2 * sizeof (int)) / \ @@ -78,7 +79,7 @@ int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, void mlx4_table_put_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 start, u32 end); int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, - u64 virt, int obj_size, u32 nobj, int reserved, + u64 virt, int obj_size, u64 nobj, int reserved, int use_lowmem, int use_coherent); void mlx4_cleanup_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table); void *mlx4_table_find(struct mlx4_icm_table *table, u32 obj, dma_addr_t *dma_handle); @@ -122,5 +123,7 @@ static inline unsigned long mlx4_icm_size(struct mlx4_icm_iter *iter) return sg_dma_len(&iter->chunk->mem[iter->page_idx]); } +int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm); +int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev); #endif /* MLX4_ICM_H */ diff --git a/sys/ofed/drivers/net/mlx4/intf.c b/sys/ofed/drivers/net/mlx4/intf.c index 0f6754bc547e..141629801d2f 100644 --- a/sys/ofed/drivers/net/mlx4/intf.c +++ b/sys/ofed/drivers/net/mlx4/intf.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -32,6 +32,7 @@ */ #include +#include #include "mlx4.h" @@ -160,7 +161,7 @@ void mlx4_unregister_device(struct mlx4_dev *dev) list_for_each_entry(intf, &intf_list, list) mlx4_remove_device(intf, priv); - list_del(&priv->dev_list); + list_del_init(&priv->dev_list); mutex_unlock(&intf_mutex); } diff --git a/sys/ofed/drivers/net/mlx4/main.c b/sys/ofed/drivers/net/mlx4/main.c index 5fe77d6e8a79..12c583601714 100644 --- a/sys/ofed/drivers/net/mlx4/main.c +++ b/sys/ofed/drivers/net/mlx4/main.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -33,6 +33,11 @@ * SOFTWARE. */ +#include +/* + * kmod.h must be included before module.h since it includes (indirectly) sys/module.h + * To use the FBSD macro sys/module.h should define MODULE_VERSION before linux/module does. +*/ #include #include #include @@ -41,6 +46,7 @@ #include #include #include +#include #include #include @@ -49,11 +55,11 @@ #include "mlx4.h" #include "fw.h" #include "icm.h" +#include "mlx4_stats.h" MODULE_AUTHOR("Roland Dreier"); MODULE_DESCRIPTION("Mellanox ConnectX HCA low-level driver"); MODULE_LICENSE("Dual BSD/GPL"); -MODULE_VERSION(DRV_VERSION); struct workqueue_struct *mlx4_wq; @@ -69,7 +75,7 @@ MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0"); static int msi_x = 1; module_param(msi_x, int, 0444); -MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero"); +MODULE_PARM_DESC(msi_x, "0 - don't use MSI-X, 1 - use MSI-X, >1 - limit number of MSI-X irqs to msi_x (non-SRIOV only)"); #else /* CONFIG_PCI_MSI */ @@ -85,14 +91,60 @@ int mlx4_blck_lb = 1; module_param_named(block_loopback, mlx4_blck_lb, int, 0644); MODULE_PARM_DESC(block_loopback, "Block multicast loopback packets if > 0 " "(default: 1)"); +enum { + DEFAULT_DOMAIN = 0, + BDF_STR_SIZE = 8, /* bb:dd.f- */ + DBDF_STR_SIZE = 13 /* mmmm:bb:dd.f- */ +}; -static int num_vfs; -module_param(num_vfs, int, 0444); -MODULE_PARM_DESC(num_vfs, "enable #num_vfs functions if num_vfs > 0"); +enum { + NUM_VFS, + PROBE_VF, + PORT_TYPE_ARRAY +}; -static int probe_vf; -module_param(probe_vf, int, 0644); -MODULE_PARM_DESC(probe_vf, "number of vfs to probe by pf driver (num_vfs > 0)"); +enum { + VALID_DATA, + INVALID_DATA, + INVALID_STR +}; + +struct param_data { + int id; + struct mlx4_dbdf2val_lst dbdf2val; +}; + +static struct param_data num_vfs = { + .id = NUM_VFS, + .dbdf2val = { + .name = "num_vfs param", + .num_vals = 1, + .def_val = {0}, + .range = {0, MLX4_MAX_NUM_VF} + } +}; +module_param_string(num_vfs, num_vfs.dbdf2val.str, + sizeof(num_vfs.dbdf2val.str), 0444); +MODULE_PARM_DESC(num_vfs, + "Either single value (e.g. '5') to define uniform num_vfs value for all devices functions\n" + "\t\tor a string to map device function numbers to their num_vfs values (e.g. '0000:04:00.0-5,002b:1c:0b.a-15').\n" + "\t\tHexadecimal digits for the device function (e.g. 002b:1c:0b.a) and decimal for num_vfs value (e.g. 15)."); + +static struct param_data probe_vf = { + .id = PROBE_VF, + .dbdf2val = { + .name = "probe_vf param", + .num_vals = 1, + .def_val = {0}, + .range = {0, MLX4_MAX_NUM_VF} + } +}; +module_param_string(probe_vf, probe_vf.dbdf2val.str, + sizeof(probe_vf.dbdf2val.str), 0444); +MODULE_PARM_DESC(probe_vf, + "Either single value (e.g. '3') to define uniform number of VFs to probe by the pf driver for all devices functions\n" + "\t\tor a string to map device function numbers to their probe_vf values (e.g. '0000:04:00.0-3,002b:1c:0b.a-13').\n" + "\t\tHexadecimal digits for the device function (e.g. 002b:1c:0b.a) and decimal for probe_vf value (e.g. 13)."); int mlx4_log_num_mgm_entry_size = MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE; @@ -115,10 +167,10 @@ module_param_named(fast_drop, fast_drop, int, 0444); MODULE_PARM_DESC(fast_drop, "Enable fast packet drop when no recieve WQEs are posted"); -int mlx4_enable_64b_cqe_eqe; +int mlx4_enable_64b_cqe_eqe = 1; module_param_named(enable_64b_cqe_eqe, mlx4_enable_64b_cqe_eqe, int, 0644); MODULE_PARM_DESC(enable_64b_cqe_eqe, - "Enable 64 byte CQEs/EQEs when the the FW supports this, if nonzero"); + "Enable 64 byte CQEs/EQEs when the the FW supports this if non-zero (default: 1)"); #define HCA_GLOBAL_CAP_MASK 0 @@ -144,13 +196,23 @@ module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444); MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment " "(0-7) (default: 0)"); -static int port_type_array[2] = {MLX4_PORT_TYPE_NONE, MLX4_PORT_TYPE_NONE}; -#if 0 -static int arr_argc = 2; -module_param_array(port_type_array, int, &arr_argc, 0444); -MODULE_PARM_DESC(port_type_array, "Array of port types: HW_DEFAULT (0) is default " - "1 for IB, 2 for Ethernet"); -#endif +static struct param_data port_type_array = { + .id = PORT_TYPE_ARRAY, + .dbdf2val = { + .name = "port_type_array param", + .num_vals = 2, + .def_val = {MLX4_PORT_TYPE_ETH, MLX4_PORT_TYPE_ETH}, + .range = {MLX4_PORT_TYPE_IB, MLX4_PORT_TYPE_NA} + } +}; +module_param_string(port_type_array, port_type_array.dbdf2val.str, + sizeof(port_type_array.dbdf2val.str), 0444); +MODULE_PARM_DESC(port_type_array, + "Either pair of values (e.g. '1,2') to define uniform port1/port2 types configuration for all devices functions\n" + "\t\tor a string to map device function numbers to their pair of port types values (e.g. '0000:04:00.0-1;2,002b:1c:0b.a-1;1').\n" + "\t\tValid port types: 1-ib, 2-eth, 3-auto, 4-N/A\n" + "\t\tIn case that only one port is available use the N/A port type for port2 (e.g '1,4')."); + struct mlx4_port_config { struct list_head list; @@ -170,7 +232,7 @@ static struct mlx4_profile mod_param_profile = { .num_cq = 16, .num_mcg = 13, .num_mpt = 19, - .num_mtt = 0, /* max(20, 2*MTTs for host memory)) */ + .num_mtt_segs = 0, /* max(20, 2*MTTs for host memory)) */ }; module_param_named(log_num_qp, mod_param_profile.num_qp, int, 0444); @@ -197,7 +259,7 @@ MODULE_PARM_DESC(log_num_mpt, "log maximum number of memory protection table entries per " "HCA (default: 19)"); -module_param_named(log_num_mtt, mod_param_profile.num_mtt, int, 0444); +module_param_named(log_num_mtt, mod_param_profile.num_mtt_segs, int, 0444); MODULE_PARM_DESC(log_num_mtt, "log maximum number of memory translation table segments per " "HCA (default: max(20, 2*MTTs for register all of the host memory limited to 30))"); @@ -206,9 +268,263 @@ enum { MLX4_IF_STATE_BASIC, MLX4_IF_STATE_EXTENDED }; + +static inline u64 dbdf_to_u64(int domain, int bus, int dev, int fn) +{ + return (domain << 20) | (bus << 12) | (dev << 4) | fn; +} + +static inline void pr_bdf_err(const char *dbdf, const char *pname) +{ + pr_warn("mlx4_core: '%s' is not valid bdf in '%s'\n", dbdf, pname); +} + +static inline void pr_val_err(const char *dbdf, const char *pname, + const char *val) +{ + pr_warn("mlx4_core: value '%s' of bdf '%s' in '%s' is not valid\n" + , val, dbdf, pname); +} + +static inline void pr_out_of_range_bdf(const char *dbdf, int val, + struct mlx4_dbdf2val_lst *dbdf2val) +{ + pr_warn("mlx4_core: value %d in bdf '%s' of '%s' is out of its valid range (%d,%d)\n" + , val, dbdf, dbdf2val->name , dbdf2val->range.min, + dbdf2val->range.max); +} + +static inline void pr_out_of_range(struct mlx4_dbdf2val_lst *dbdf2val) +{ + pr_warn("mlx4_core: value of '%s' is out of its valid range (%d,%d)\n" + , dbdf2val->name , dbdf2val->range.min, dbdf2val->range.max); +} + +static inline int is_in_range(int val, struct mlx4_range *r) +{ + return (val >= r->min && val <= r->max); +} + +static int update_defaults(struct param_data *pdata) +{ + long int val[MLX4_MAX_BDF_VALS]; + int ret; + char *t, *p = pdata->dbdf2val.str; + char sval[32]; + int val_len; + + if (!strlen(p) || strchr(p, ':') || strchr(p, '.') || strchr(p, ';')) + return INVALID_STR; + + switch (pdata->id) { + case PORT_TYPE_ARRAY: + t = strchr(p, ','); + if (!t || t == p || (t - p) > sizeof(sval)) + return INVALID_STR; + + val_len = t - p; + strncpy(sval, p, val_len); + sval[val_len] = 0; + + ret = kstrtol(sval, 0, &val[0]); + if (ret == -EINVAL) + return INVALID_STR; + if (ret || !is_in_range(val[0], &pdata->dbdf2val.range)) { + pr_out_of_range(&pdata->dbdf2val); + return INVALID_DATA; + } + + ret = kstrtol(t + 1, 0, &val[1]); + if (ret == -EINVAL) + return INVALID_STR; + if (ret || !is_in_range(val[1], &pdata->dbdf2val.range)) { + pr_out_of_range(&pdata->dbdf2val); + return INVALID_DATA; + } + + pdata->dbdf2val.tbl[0].val[0] = val[0]; + pdata->dbdf2val.tbl[0].val[1] = val[1]; + break; + + case NUM_VFS: + case PROBE_VF: + ret = kstrtol(p, 0, &val[0]); + if (ret == -EINVAL) + return INVALID_STR; + if (ret || !is_in_range(val[0], &pdata->dbdf2val.range)) { + pr_out_of_range(&pdata->dbdf2val); + return INVALID_DATA; + } + pdata->dbdf2val.tbl[0].val[0] = val[0]; + break; + } + pdata->dbdf2val.tbl[1].dbdf = MLX4_ENDOF_TBL; + + return VALID_DATA; +} + +int mlx4_fill_dbdf2val_tbl(struct mlx4_dbdf2val_lst *dbdf2val_lst) +{ + int domain, bus, dev, fn; + u64 dbdf; + char *p, *t, *v; + char tmp[32]; + char sbdf[32]; + char sep = ','; + int j, k, str_size, i = 1; + int prfx_size; + + p = dbdf2val_lst->str; + + for (j = 0; j < dbdf2val_lst->num_vals; j++) + dbdf2val_lst->tbl[0].val[j] = dbdf2val_lst->def_val[j]; + dbdf2val_lst->tbl[1].dbdf = MLX4_ENDOF_TBL; + + str_size = strlen(dbdf2val_lst->str); + + if (str_size == 0) + return 0; + + while (strlen(p)) { + prfx_size = BDF_STR_SIZE; + sbdf[prfx_size] = 0; + strncpy(sbdf, p, prfx_size); + domain = DEFAULT_DOMAIN; + if (sscanf(sbdf, "%02x:%02x.%x-", &bus, &dev, &fn) != 3) { + prfx_size = DBDF_STR_SIZE; + sbdf[prfx_size] = 0; + strncpy(sbdf, p, prfx_size); + if (sscanf(sbdf, "%04x:%02x:%02x.%x-", &domain, &bus, + &dev, &fn) != 4) { + pr_bdf_err(sbdf, dbdf2val_lst->name); + goto err; + } + sprintf(tmp, "%04x:%02x:%02x.%x-", domain, bus, dev, + fn); + } else { + sprintf(tmp, "%02x:%02x.%x-", bus, dev, fn); + } + + if (strnicmp(sbdf, tmp, sizeof(tmp))) { + pr_bdf_err(sbdf, dbdf2val_lst->name); + goto err; + } + + dbdf = dbdf_to_u64(domain, bus, dev, fn); + + for (j = 1; j < i; j++) + if (dbdf2val_lst->tbl[j].dbdf == dbdf) { + pr_warn("mlx4_core: in '%s', %s appears multiple times\n" + , dbdf2val_lst->name, sbdf); + goto err; + } + + if (i >= MLX4_DEVS_TBL_SIZE) { + pr_warn("mlx4_core: Too many devices in '%s'\n" + , dbdf2val_lst->name); + goto err; + } + + p += prfx_size; + t = strchr(p, sep); + t = t ? t : p + strlen(p); + if (p >= t) { + pr_val_err(sbdf, dbdf2val_lst->name, ""); + goto err; + } + + for (k = 0; k < dbdf2val_lst->num_vals; k++) { + char sval[32]; + long int val; + int ret, val_len; + char vsep = ';'; + + v = (k == dbdf2val_lst->num_vals - 1) ? t : strchr(p, vsep); + if (!v || v > t || v == p || (v - p) > sizeof(sval)) { + pr_val_err(sbdf, dbdf2val_lst->name, p); + goto err; + } + val_len = v - p; + strncpy(sval, p, val_len); + sval[val_len] = 0; + + ret = kstrtol(sval, 0, &val); + if (ret) { + if (strchr(p, vsep)) + pr_warn("mlx4_core: too many vals in bdf '%s' of '%s'\n" + , sbdf, dbdf2val_lst->name); + else + pr_val_err(sbdf, dbdf2val_lst->name, + sval); + goto err; + } + if (!is_in_range(val, &dbdf2val_lst->range)) { + pr_out_of_range_bdf(sbdf, val, dbdf2val_lst); + goto err; + } + + dbdf2val_lst->tbl[i].val[k] = val; + p = v; + if (p[0] == vsep) + p++; + } + + dbdf2val_lst->tbl[i].dbdf = dbdf; + if (strlen(p)) { + if (p[0] != sep) { + pr_warn("mlx4_core: expect separator '%c' before '%s' in '%s'\n" + , sep, p, dbdf2val_lst->name); + goto err; + } + p++; + } + i++; + if (i < MLX4_DEVS_TBL_SIZE) + dbdf2val_lst->tbl[i].dbdf = MLX4_ENDOF_TBL; + } + + return 0; + +err: + dbdf2val_lst->tbl[1].dbdf = MLX4_ENDOF_TBL; + pr_warn("mlx4_core: The value of '%s' is incorrect. The value is discarded!\n" + , dbdf2val_lst->name); + + return -EINVAL; +} +EXPORT_SYMBOL(mlx4_fill_dbdf2val_tbl); + +int mlx4_get_val(struct mlx4_dbdf2val *tbl, struct pci_dev *pdev, int idx, + int *val) +{ + u64 dbdf; + int i = 1; + + *val = tbl[0].val[idx]; + if (!pdev) + return -EINVAL; + + if (!pdev->bus) { + return -EINVAL; + } + + dbdf = dbdf_to_u64(pci_get_domain(pdev->dev.bsddev), pci_get_bus(pdev->dev.bsddev), + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); + + while ((i < MLX4_DEVS_TBL_SIZE) && (tbl[i].dbdf != MLX4_ENDOF_TBL)) { + if (tbl[i].dbdf == dbdf) { + *val = tbl[i].val[idx]; + return 0; + } + i++; + } + + return 0; +} +EXPORT_SYMBOL(mlx4_get_val); + static void process_mod_param_profile(struct mlx4_profile *profile) { - vm_size_t hwphyssz; hwphyssz = 0; TUNABLE_ULONG_FETCH("hw.realmem", (u_long *) &hwphyssz); @@ -232,10 +548,10 @@ static void process_mod_param_profile(struct mlx4_profile *profile) * That limits us to 4TB of memory registration per HCA with * 4KB pages, which is probably OK for the next few months. */ - if (mod_param_profile.num_mtt) - profile->num_mtt = 1 << mod_param_profile.num_mtt; + if (mod_param_profile.num_mtt_segs) + profile->num_mtt_segs = 1 << mod_param_profile.num_mtt_segs; else { - profile->num_mtt = + profile->num_mtt_segs = roundup_pow_of_two(max_t(unsigned, 1 << (MLX4_LOG_NUM_MTT - log_mtts_per_seg), min(1UL << @@ -245,7 +561,7 @@ static void process_mod_param_profile(struct mlx4_profile *profile) >> log_mtts_per_seg))); /* set the actual value, so it will be reflected to the user using the sysfs */ - mod_param_profile.num_mtt = ilog2(profile->num_mtt * (1 << log_mtts_per_seg)); + mod_param_profile.num_mtt_segs = ilog2(profile->num_mtt_segs); } } @@ -406,14 +722,26 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) MLX4_PORT_TYPE_IB) dev->caps.port_type[i] = MLX4_PORT_TYPE_IB; else { - /* if IB and ETH are supported, we set the port + /* + * if IB and ETH are supported, we set the port * type according to user selection of port type; - * if user selected none, take the FW hint */ - if (port_type_array[i - 1] == MLX4_PORT_TYPE_NONE) + * if there is no user selection, take the FW hint + */ + int pta; + mlx4_get_val(port_type_array.dbdf2val.tbl, + pci_physfn(dev->pdev), i - 1, + &pta); + if (pta == MLX4_PORT_TYPE_NONE) { dev->caps.port_type[i] = dev->caps.suggested_type[i] ? MLX4_PORT_TYPE_ETH : MLX4_PORT_TYPE_IB; - else - dev->caps.port_type[i] = port_type_array[i - 1]; + } else if (pta == MLX4_PORT_TYPE_NA) { + mlx4_err(dev, "Port %d is valid port. " + "It is not allowed to configure its type to N/A(%d)\n", + i, MLX4_PORT_TYPE_NA); + return -EINVAL; + } else { + dev->caps.port_type[i] = pta; + } } } /* @@ -427,6 +755,9 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) (dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP) && (dev->caps.flags & MLX4_DEV_CAP_FLAG_SENSE_SUPPORT)); + /* Disablling auto sense for default Eth ports support */ + mlx4_priv(dev)->sense.sense_allowed[i] = 0; + /* * If "default_sense" bit is set, we move the port to "AUTO" mode * and perform sense_port FW command to try and set the correct @@ -478,9 +809,12 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH]; dev->caps.sync_qp = dev_cap->sync_qp; + if (dev->pdev->device == 0x1003) + dev->caps.cq_flags |= MLX4_DEV_CAP_CQ_FLAG_IO; + dev->caps.sqp_demux = (mlx4_is_master(dev)) ? MLX4_MAX_NUM_SLAVES : 0; - if (!mlx4_enable_64b_cqe_eqe) { + if (!mlx4_enable_64b_cqe_eqe && !mlx4_is_slave(dev)) { if (dev_cap->flags & (MLX4_DEV_CAP_FLAG_64B_CQE | MLX4_DEV_CAP_FLAG_64B_EQE)) { mlx4_warn(dev, "64B EQEs/CQEs supported by the device but not enabled\n"); @@ -494,6 +828,11 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) mlx4_is_master(dev)) dev->caps.function_caps |= MLX4_FUNC_CAP_64B_EQE_CQE; + if (!mlx4_is_slave(dev)) { + for (i = 0; i < dev->caps.num_ports; ++i) + dev->caps.def_counter_index[i] = i << 1; + } + return 0; } /*The function checks if there are live vf, return the num of them*/ @@ -634,6 +973,11 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) if (err) mlx4_err(dev, "QUERY_FW command failed: could not get FW version.\n"); + if (!hca_param.mw_enable) { + dev->caps.flags &= ~MLX4_DEV_CAP_FLAG_MEM_WINDOW; + dev->caps.bmme_flags &= ~MLX4_BMME_FLAG_TYPE_2_WIN; + } + page_size = ~dev->caps.page_size_cap + 1; mlx4_warn(dev, "HCA minimum page size:%d\n", page_size); if (page_size > PAGE_SIZE) { @@ -711,6 +1055,8 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) dev->caps.qp0_proxy[i - 1] = func_cap.qp0_proxy_qpn; dev->caps.qp1_tunnel[i - 1] = func_cap.qp1_tunnel_qpn; dev->caps.qp1_proxy[i - 1] = func_cap.qp1_proxy_qpn; + dev->caps.def_counter_index[i - 1] = func_cap.def_counter_index; + dev->caps.port_mask[i] = dev->caps.port_type[i]; err = mlx4_get_slave_pkey_gid_tbl_len(dev, i, &dev->caps.gid_table_len[i], @@ -745,6 +1091,9 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) dev->caps.cqe_size = 32; } + dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS; + mlx4_warn(dev, "Timestamping is not supported in slave mode.\n"); + slave_adjust_steering_mode(dev, &dev_cap, &hca_param); return 0; @@ -760,6 +1109,27 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) return err; } +static void mlx4_request_modules(struct mlx4_dev *dev) +{ + int port; + int has_ib_port = false; + int has_eth_port = false; +#define EN_DRV_NAME "mlx4_en" +#define IB_DRV_NAME "mlx4_ib" + + for (port = 1; port <= dev->caps.num_ports; port++) { + if (dev->caps.port_type[port] == MLX4_PORT_TYPE_IB) + has_ib_port = true; + else if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH) + has_eth_port = true; + } + + if (has_ib_port) + request_module_nowait(IB_DRV_NAME); + if (has_eth_port) + request_module_nowait(EN_DRV_NAME); +} + /* * Change the port configuration of the device. * Every user of this function must hold the port mutex. @@ -791,6 +1161,11 @@ int mlx4_change_port_types(struct mlx4_dev *dev, } mlx4_set_port_mask(dev); err = mlx4_register_device(dev); + if (err) { + mlx4_err(dev, "Failed to register device\n"); + goto out; + } + mlx4_request_modules(dev); } out: @@ -841,7 +1216,14 @@ static ssize_t set_port_type(struct device *dev, return -EINVAL; } - mlx4_stop_sense(mdev); + if ((info->tmp_type & mdev->caps.supported_type[info->port]) != + info->tmp_type) { + mlx4_err(mdev, "Requested port type for port %d is not supported on this HCA\n", + info->port); + return -EINVAL; + } + + mlx4_stop_sense(mdev); mutex_lock(&priv->port_mutex); /* Possible type is always the one that was delivered */ mdev->caps.possible_type[info->port] = info->tmp_type; @@ -984,7 +1366,7 @@ static ssize_t set_port_ib_mtu(struct device *dev, static int mlx4_load_fw(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); - int err; + int err, unmap_flag = 0; priv->fw.fw_icm = mlx4_alloc_icm(dev, priv->fw.fw_pages, GFP_HIGHUSER | __GFP_NOWARN, 0); @@ -1008,10 +1390,13 @@ static int mlx4_load_fw(struct mlx4_dev *dev) return 0; err_unmap_fa: - mlx4_UNMAP_FA(dev); + unmap_flag = mlx4_UNMAP_FA(dev); + if (unmap_flag) + pr_warn("mlx4_core: mlx4_UNMAP_FA failed.\n"); err_free: - mlx4_free_icm(dev, priv->fw.fw_icm, 0); + if (!unmap_flag) + mlx4_free_icm(dev, priv->fw.fw_icm, 0); return err; } @@ -1081,7 +1466,7 @@ static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap, struct mlx4_priv *priv = mlx4_priv(dev); u64 aux_pages; int num_eqs; - int err; + int err, unmap_flag = 0; err = mlx4_SET_ICM_SIZE(dev, icm_size, &aux_pages); if (err) { @@ -1272,10 +1657,13 @@ static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap, mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table); err_unmap_aux: - mlx4_UNMAP_ICM_AUX(dev); + unmap_flag = mlx4_UNMAP_ICM_AUX(dev); + if (unmap_flag) + pr_warn("mlx4_core: mlx4_UNMAP_ICM_AUX failed.\n"); err_free_aux: - mlx4_free_icm(dev, priv->fw.aux_icm, 0); + if (!unmap_flag) + mlx4_free_icm(dev, priv->fw.aux_icm, 0); return err; } @@ -1299,8 +1687,10 @@ static void mlx4_free_icms(struct mlx4_dev *dev) mlx4_cleanup_icm_table(dev, &priv->srq_table.cmpt_table); mlx4_cleanup_icm_table(dev, &priv->qp_table.cmpt_table); - mlx4_UNMAP_ICM_AUX(dev); - mlx4_free_icm(dev, priv->fw.aux_icm, 0); + if (!mlx4_UNMAP_ICM_AUX(dev)) + mlx4_free_icm(dev, priv->fw.aux_icm, 0); + else + pr_warn("mlx4_core: mlx4_UNMAP_ICM_AUX failed.\n"); } static void mlx4_slave_exit(struct mlx4_dev *dev) @@ -1340,13 +1730,16 @@ static void unmap_bf_area(struct mlx4_dev *dev) io_mapping_free(mlx4_priv(dev)->bf_mapping); } -cycle_t mlx4_read_clock(struct mlx4_dev *dev) +int mlx4_read_clock(struct mlx4_dev *dev) { u32 clockhi, clocklo, clockhi1; cycle_t cycles; int i; struct mlx4_priv *priv = mlx4_priv(dev); + if (!priv->clock_mapping) + return -ENOTSUPP; + for (i = 0; i < 10; i++) { clockhi = swab32(readl(priv->clock_mapping)); clocklo = swab32(readl(priv->clock_mapping + 4)); @@ -1376,6 +1769,25 @@ static int map_internal_clock(struct mlx4_dev *dev) return 0; } + +int mlx4_get_internal_clock_params(struct mlx4_dev *dev, + struct mlx4_clock_params *params) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + + if (mlx4_is_slave(dev)) + return -ENOTSUPP; + if (!params) + return -EINVAL; + + params->bar = priv->fw.clock_bar; + params->offset = priv->fw.clock_offset; + params->size = MLX4_CLOCK_SIZE; + + return 0; +} +EXPORT_SYMBOL_GPL(mlx4_get_internal_clock_params); + static void unmap_internal_clock(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); @@ -1388,13 +1800,16 @@ static void mlx4_close_hca(struct mlx4_dev *dev) { unmap_internal_clock(dev); unmap_bf_area(dev); - if (mlx4_is_slave(dev)) + if (mlx4_is_slave(dev)) { mlx4_slave_exit(dev); - else { + } else { mlx4_CLOSE_HCA(dev, 0); mlx4_free_icms(dev); - mlx4_UNMAP_FA(dev); - mlx4_free_icm(dev, mlx4_priv(dev)->fw.fw_icm, 0); + + if (!mlx4_UNMAP_FA(dev)) + mlx4_free_icm(dev, mlx4_priv(dev)->fw.fw_icm, 0); + else + pr_warn("mlx4_core: mlx4_UNMAP_FA failed.\n"); } } @@ -1497,13 +1912,9 @@ static int choose_log_fs_mgm_entry_size(int qp_per_entry) static void choose_steering_mode(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) { - // This is only valid to the integrated driver. - // The new ported mlx4_core driver is in B0 steering mode by default - // and the old mlx4_en driver is in A0 steering mode by default. - // If high_rate_steer == TRUE it means that A0 steering mode is on. - // The integration fix is to hard code high_rate_steer to TRUE. - high_rate_steer = 1; + int nvfs; + mlx4_get_val(num_vfs.dbdf2val.tbl, pci_physfn(dev->pdev), 0, &nvfs); if (high_rate_steer && !mlx4_is_mfunc(dev)) { dev->caps.flags &= ~(MLX4_DEV_CAP_FLAG_VEP_MC_STEER | MLX4_DEV_CAP_FLAG_VEP_UC_STEER); @@ -1512,9 +1923,8 @@ static void choose_steering_mode(struct mlx4_dev *dev, if (mlx4_log_num_mgm_entry_size == -1 && dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_FS_EN && - dev_cap->fs_log_max_ucast_qp_range_size == 0 && (!mlx4_is_mfunc(dev) || - (dev_cap->fs_max_num_qp_per_entry >= (num_vfs + 1))) && + (dev_cap->fs_max_num_qp_per_entry >= (nvfs + 1))) && choose_log_fs_mgm_entry_size(dev_cap->fs_max_num_qp_per_entry) >= MLX4_MIN_MGM_LOG_ENTRY_SIZE) { dev->oper_log_mgm_entry_size = @@ -1523,9 +1933,8 @@ static void choose_steering_mode(struct mlx4_dev *dev, dev->caps.num_qp_per_mgm = dev_cap->fs_max_num_qp_per_entry; } else { if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER && - dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) { + dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) dev->caps.steering_mode = MLX4_STEERING_MODE_B0; - } else { dev->caps.steering_mode = MLX4_STEERING_MODE_A0; @@ -1618,11 +2027,42 @@ static int mlx4_init_hca(struct mlx4_dev *dev) if (err) goto err_stop_fw; + init_hca.mw_enable = 1; + err = mlx4_INIT_HCA(dev, &init_hca); if (err) { mlx4_err(dev, "INIT_HCA command failed, aborting.\n"); goto err_free_icm; } + + /* + * Read HCA frequency by QUERY_HCA command + */ + if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) { + memset(&init_hca, 0, sizeof(init_hca)); + err = mlx4_QUERY_HCA(dev, &init_hca); + if (err) { + mlx4_err(dev, "QUERY_HCA command failed, disable timestamp.\n"); + dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS; + } else { + dev->caps.hca_core_clock = + init_hca.hca_core_clock; + } + + /* In case we got HCA frequency 0 - disable timestamping + * to avoid dividing by zero + */ + if (!dev->caps.hca_core_clock) { + dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS; + mlx4_err(dev, "HCA frequency is 0. Timestamping is not supported."); + } else if (map_internal_clock(dev)) { + /* Map internal clock, + * in case of failure disable timestamping + */ + dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_TS; + mlx4_err(dev, "Failed to map internal clock. Timestamping is not supported.\n"); + } + } } else { err = mlx4_init_slave(dev); if (err) { @@ -1640,39 +2080,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev) if (map_bf_area(dev)) mlx4_dbg(dev, "Failed to map blue flame area\n"); - /* - * Read HCA frequency by QUERY_HCA command - */ - if (dev->caps.cq_timestamp) { - memset(&init_hca, 0, sizeof(init_hca)); - err = mlx4_QUERY_HCA(dev, &init_hca); - if (err) { - mlx4_err(dev, "QUERY_HCA command failed, disable timestamp.\n"); - dev->caps.cq_timestamp = 0; - } else - dev->caps.hca_core_clock = init_hca.hca_core_clock; - - /* - * In case we got HCA frequency 0 - disable timestamping - * to avoid dividing by zero - */ - if (!dev->caps.hca_core_clock) { - dev->caps.cq_timestamp = 0; - mlx4_err(dev, "HCA frequency is 0. " - "Timestamping is not supported."); - } - - /* - * Map internal clock, in case of failure disable timestamping - */ - if (map_internal_clock(dev)) { - dev->caps.cq_timestamp = 0; - mlx4_err(dev, "Failed to map internal clock. " - "Timestamping is not supported.\n"); - } - } - - /*Only the master set the ports, all the rest got it from it.*/ + /* Only the master set the ports, all the rest got it from it.*/ if (!mlx4_is_slave(dev)) mlx4_set_port_mask(dev); @@ -1684,6 +2092,8 @@ static int mlx4_init_hca(struct mlx4_dev *dev) priv->eq_table.inta_pin = adapter.inta_pin; memcpy(dev->board_id, adapter.board_id, sizeof dev->board_id); + memcpy(dev->vsd, adapter.vsd, sizeof(dev->vsd)); + dev->vsd_vendor_id = adapter.vsd_vendor_id; if (!mlx4_is_slave(dev)) kfree(dev_cap); @@ -1691,7 +2101,8 @@ static int mlx4_init_hca(struct mlx4_dev *dev) return 0; unmap_bf: - unmap_internal_clock(dev); + if (!mlx4_is_slave(dev)) + unmap_internal_clock(dev); unmap_bf_area(dev); if (mlx4_is_slave(dev)) { @@ -1713,10 +2124,11 @@ static int mlx4_init_hca(struct mlx4_dev *dev) err_stop_fw: if (!mlx4_is_slave(dev)) { - mlx4_UNMAP_FA(dev); - mlx4_free_icm(dev, priv->fw.fw_icm, 0); - if (dev_cap) - kfree(dev_cap); + if (!mlx4_UNMAP_FA(dev)) + mlx4_free_icm(dev, priv->fw.fw_icm, 0); + else + pr_warn("mlx4_core: mlx4_UNMAP_FA failed.\n"); + kfree(dev_cap); } return err; } @@ -1724,92 +2136,539 @@ static int mlx4_init_hca(struct mlx4_dev *dev) static int mlx4_init_counters_table(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); - int res; - int nent_pow2; + int nent_pow2, port_indx, vf_index, num_counters; + int res, index = 0; + struct counter_index *new_counter_index; + if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) return -ENOENT; - nent_pow2 = roundup_pow_of_two(dev->caps.max_counters); - res = mlx4_bitmap_init(&priv->counters_bitmap, nent_pow2, - nent_pow2 - 1, 0, - nent_pow2 - dev->caps.max_counters); - if (res) - return res; + if (!mlx4_is_slave(dev) && + dev->caps.max_counters == dev->caps.max_extended_counters) { + res = mlx4_cmd(dev, MLX4_IF_STATE_EXTENDED, 0, 0, + MLX4_CMD_SET_IF_STAT, + MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); + if (res) { + mlx4_err(dev, "Failed to set extended counters (err=%d)\n", res); + return res; + } + } - if (dev->caps.max_counters == dev->caps.max_basic_counters) + mutex_init(&priv->counters_table.mutex); + + if (mlx4_is_slave(dev)) { + for (port_indx = 0; port_indx < dev->caps.num_ports; port_indx++) { + INIT_LIST_HEAD(&priv->counters_table.global_port_list[port_indx]); + if (dev->caps.def_counter_index[port_indx] != 0xFF) { + new_counter_index = kmalloc(sizeof(struct counter_index), GFP_KERNEL); + if (!new_counter_index) + return -ENOMEM; + new_counter_index->index = dev->caps.def_counter_index[port_indx]; + list_add_tail(&new_counter_index->list, &priv->counters_table.global_port_list[port_indx]); + } + } + mlx4_dbg(dev, "%s: slave allocated %d counters for %d ports\n", + __func__, dev->caps.num_ports, dev->caps.num_ports); return 0; + } - res = mlx4_cmd(dev, MLX4_IF_STATE_EXTENDED, 0, 0, - MLX4_CMD_SET_IF_STAT, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); + nent_pow2 = roundup_pow_of_two(dev->caps.max_counters); - if (res) - mlx4_err(dev, "Failed to set extended counters (err=%d)\n", - res); - return res; + for (port_indx = 0; port_indx < dev->caps.num_ports; port_indx++) { + INIT_LIST_HEAD(&priv->counters_table.global_port_list[port_indx]); + /* allocating 2 counters per port for PFs */ + /* For the PF, the ETH default counters are 0,2; */ + /* and the RoCE default counters are 1,3 */ + for (num_counters = 0; num_counters < 2; num_counters++, index++) { + new_counter_index = kmalloc(sizeof(struct counter_index), GFP_KERNEL); + if (!new_counter_index) + return -ENOMEM; + new_counter_index->index = index; + list_add_tail(&new_counter_index->list, + &priv->counters_table.global_port_list[port_indx]); + } + } + + if (mlx4_is_master(dev)) { + for (vf_index = 0; vf_index < dev->num_vfs; vf_index++) { + for (port_indx = 0; port_indx < dev->caps.num_ports; port_indx++) { + INIT_LIST_HEAD(&priv->counters_table.vf_list[vf_index][port_indx]); + new_counter_index = kmalloc(sizeof(struct counter_index), GFP_KERNEL); + if (!new_counter_index) + return -ENOMEM; + if (index < nent_pow2 - 2) { + new_counter_index->index = index; + index++; + } else { + new_counter_index->index = MLX4_SINK_COUNTER_INDEX; + } + + list_add_tail(&new_counter_index->list, + &priv->counters_table.vf_list[vf_index][port_indx]); + } + } + + res = mlx4_bitmap_init(&priv->counters_table.bitmap, + nent_pow2, nent_pow2 - 1, + index, 1); + mlx4_dbg(dev, "%s: master allocated %d counters for %d VFs\n", + __func__, index, dev->num_vfs); + } else { + res = mlx4_bitmap_init(&priv->counters_table.bitmap, + nent_pow2, nent_pow2 - 1, + index, 1); + mlx4_dbg(dev, "%s: native allocated %d counters for %d ports\n", + __func__, index, dev->caps.num_ports); + } + + return 0; } static void mlx4_cleanup_counters_table(struct mlx4_dev *dev) { - if (!mlx4_is_slave(dev) && - (dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) - mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap); + struct mlx4_priv *priv = mlx4_priv(dev); + int i, j; + struct counter_index *port, *tmp_port; + struct counter_index *vf, *tmp_vf; + + mutex_lock(&priv->counters_table.mutex); + + if (dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS) { + for (i = 0; i < dev->caps.num_ports; i++) { + list_for_each_entry_safe(port, tmp_port, + &priv->counters_table.global_port_list[i], + list) { + list_del(&port->list); + kfree(port); + } + } + if (!mlx4_is_slave(dev)) { + for (i = 0; i < dev->num_vfs; i++) { + for (j = 0; j < dev->caps.num_ports; j++) { + list_for_each_entry_safe(vf, tmp_vf, + &priv->counters_table.vf_list[i][j], + list) { + /* clear the counter statistic */ + if (__mlx4_clear_if_stat(dev, vf->index)) + mlx4_dbg(dev, "%s: reset counter %d failed\n", + __func__, vf->index); + list_del(&vf->list); + kfree(vf); + } + } + } + mlx4_bitmap_cleanup(&priv->counters_table.bitmap); + } + } + mutex_unlock(&priv->counters_table.mutex); } -int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx) +int __mlx4_slave_counters_free(struct mlx4_dev *dev, int slave) { struct mlx4_priv *priv = mlx4_priv(dev); + int i, first; + struct counter_index *vf, *tmp_vf; - if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) - return -ENOENT; + /* clean VF's counters for the next useg */ + if (slave > 0 && slave <= dev->num_vfs) { + mlx4_dbg(dev, "%s: free counters of slave(%d)\n" + , __func__, slave); - *idx = mlx4_bitmap_alloc(&priv->counters_bitmap); - if (*idx == -1) - return -ENOMEM; + mutex_lock(&priv->counters_table.mutex); + for (i = 0; i < dev->caps.num_ports; i++) { + first = 0; + list_for_each_entry_safe(vf, tmp_vf, + &priv->counters_table.vf_list[slave - 1][i], + list) { + /* clear the counter statistic */ + if (__mlx4_clear_if_stat(dev, vf->index)) + mlx4_dbg(dev, "%s: reset counter %d failed\n", + __func__, vf->index); + if (first++ && vf->index != MLX4_SINK_COUNTER_INDEX) { + mlx4_dbg(dev, "%s: delete counter index %d for slave %d and port %d\n" + , __func__, vf->index, slave, i + 1); + mlx4_bitmap_free(&priv->counters_table.bitmap, vf->index, MLX4_USE_RR); + list_del(&vf->list); + kfree(vf); + } else { + mlx4_dbg(dev, "%s: can't delete default counter index %d for slave %d and port %d\n" + , __func__, vf->index, slave, i + 1); + } + } + } + mutex_unlock(&priv->counters_table.mutex); + } return 0; } -int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx) +int __mlx4_counter_alloc(struct mlx4_dev *dev, int slave, int port, u32 *idx) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct counter_index *new_counter_index; + + if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) + return -ENOENT; + + if ((slave > MLX4_MAX_NUM_VF) || (slave < 0) || + (port < 0) || (port > MLX4_MAX_PORTS)) { + mlx4_dbg(dev, "%s: invalid slave(%d) or port(%d) index\n", + __func__, slave, port); + return -EINVAL; + } + + /* handle old guest request does not support request by port index */ + if (port == 0) { + *idx = MLX4_SINK_COUNTER_INDEX; + mlx4_dbg(dev, "%s: allocated default counter index %d for slave %d port %d\n" + , __func__, *idx, slave, port); + return 0; + } + + mutex_lock(&priv->counters_table.mutex); + + *idx = mlx4_bitmap_alloc(&priv->counters_table.bitmap); + /* if no resources return the default counter of the slave and port */ + if (*idx == -1) { + if (slave == 0) { /* its the ethernet counter ?????? */ + new_counter_index = list_entry(priv->counters_table.global_port_list[port - 1].next, + struct counter_index, + list); + } else { + new_counter_index = list_entry(priv->counters_table.vf_list[slave - 1][port - 1].next, + struct counter_index, + list); + } + + *idx = new_counter_index->index; + mlx4_dbg(dev, "%s: allocated defualt counter index %d for slave %d port %d\n" + , __func__, *idx, slave, port); + goto out; + } + + if (slave == 0) { /* native or master */ + new_counter_index = kmalloc(sizeof(struct counter_index), GFP_KERNEL); + if (!new_counter_index) + goto no_mem; + new_counter_index->index = *idx; + list_add_tail(&new_counter_index->list, &priv->counters_table.global_port_list[port - 1]); + } else { + new_counter_index = kmalloc(sizeof(struct counter_index), GFP_KERNEL); + if (!new_counter_index) + goto no_mem; + new_counter_index->index = *idx; + list_add_tail(&new_counter_index->list, &priv->counters_table.vf_list[slave - 1][port - 1]); + } + + mlx4_dbg(dev, "%s: allocated counter index %d for slave %d port %d\n" + , __func__, *idx, slave, port); +out: + mutex_unlock(&priv->counters_table.mutex); + return 0; + +no_mem: + mlx4_bitmap_free(&priv->counters_table.bitmap, *idx, MLX4_USE_RR); + mutex_unlock(&priv->counters_table.mutex); + *idx = MLX4_SINK_COUNTER_INDEX; + mlx4_dbg(dev, "%s: failed err (%d)\n" + , __func__, -ENOMEM); + return -ENOMEM; +} + +int mlx4_counter_alloc(struct mlx4_dev *dev, u8 port, u32 *idx) { u64 out_param; int err; + struct mlx4_priv *priv = mlx4_priv(dev); + struct counter_index *new_counter_index, *c_index; if (mlx4_is_mfunc(dev)) { - err = mlx4_cmd_imm(dev, 0, &out_param, RES_COUNTER, + err = mlx4_cmd_imm(dev, 0, &out_param, + ((u32) port) << 8 | (u32) RES_COUNTER, RES_OP_RESERVE, MLX4_CMD_ALLOC_RES, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); - if (!err) + if (!err) { *idx = get_param_l(&out_param); + if (*idx == MLX4_SINK_COUNTER_INDEX) + return -ENOSPC; + mutex_lock(&priv->counters_table.mutex); + c_index = list_entry(priv->counters_table.global_port_list[port - 1].next, + struct counter_index, + list); + mutex_unlock(&priv->counters_table.mutex); + if (c_index->index == *idx) + return -EEXIST; + + if (mlx4_is_slave(dev)) { + new_counter_index = kmalloc(sizeof(struct counter_index), GFP_KERNEL); + if (!new_counter_index) { + mlx4_counter_free(dev, port, *idx); + return -ENOMEM; + } + new_counter_index->index = *idx; + mutex_lock(&priv->counters_table.mutex); + list_add_tail(&new_counter_index->list, &priv->counters_table.global_port_list[port - 1]); + mutex_unlock(&priv->counters_table.mutex); + mlx4_dbg(dev, "%s: allocated counter index %d for port %d\n" + , __func__, *idx, port); + } + } return err; } - return __mlx4_counter_alloc(dev, idx); + return __mlx4_counter_alloc(dev, 0, port, idx); } EXPORT_SYMBOL_GPL(mlx4_counter_alloc); -void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx) +void __mlx4_counter_free(struct mlx4_dev *dev, int slave, int port, u32 idx) { - mlx4_bitmap_free(&mlx4_priv(dev)->counters_bitmap, idx); - return; + /* check if native or slave and deletes acordingly */ + struct mlx4_priv *priv = mlx4_priv(dev); + struct counter_index *pf, *tmp_pf; + struct counter_index *vf, *tmp_vf; + int first; + + + if (idx == MLX4_SINK_COUNTER_INDEX) { + mlx4_dbg(dev, "%s: try to delete default counter index %d for port %d\n" + , __func__, idx, port); + return; + } + + if ((slave > MLX4_MAX_NUM_VF) || (slave < 0) || + (port < 0) || (port > MLX4_MAX_PORTS)) { + mlx4_warn(dev, "%s: deletion failed due to invalid slave(%d) or port(%d) index\n" + , __func__, slave, idx); + return; + } + + mutex_lock(&priv->counters_table.mutex); + if (slave == 0) { + first = 0; + list_for_each_entry_safe(pf, tmp_pf, + &priv->counters_table.global_port_list[port - 1], + list) { + /* the first 2 counters are reserved */ + if (pf->index == idx) { + /* clear the counter statistic */ + if (__mlx4_clear_if_stat(dev, pf->index)) + mlx4_dbg(dev, "%s: reset counter %d failed\n", + __func__, pf->index); + if (1 < first && idx != MLX4_SINK_COUNTER_INDEX) { + list_del(&pf->list); + kfree(pf); + mlx4_dbg(dev, "%s: delete counter index %d for native device (%d) port %d\n" + , __func__, idx, slave, port); + mlx4_bitmap_free(&priv->counters_table.bitmap, idx, MLX4_USE_RR); + goto out; + } else { + mlx4_dbg(dev, "%s: can't delete default counter index %d for native device (%d) port %d\n" + , __func__, idx, slave, port); + goto out; + } + } + first++; + } + mlx4_dbg(dev, "%s: can't delete counter index %d for native device (%d) port %d\n" + , __func__, idx, slave, port); + } else { + first = 0; + list_for_each_entry_safe(vf, tmp_vf, + &priv->counters_table.vf_list[slave - 1][port - 1], + list) { + /* the first element is reserved */ + if (vf->index == idx) { + /* clear the counter statistic */ + if (__mlx4_clear_if_stat(dev, vf->index)) + mlx4_dbg(dev, "%s: reset counter %d failed\n", + __func__, vf->index); + if (first) { + list_del(&vf->list); + kfree(vf); + mlx4_dbg(dev, "%s: delete counter index %d for slave %d port %d\n", + __func__, idx, slave, port); + mlx4_bitmap_free(&priv->counters_table.bitmap, idx, MLX4_USE_RR); + goto out; + } else { + mlx4_dbg(dev, "%s: can't delete default slave (%d) counter index %d for port %d\n" + , __func__, slave, idx, port); + goto out; + } + } + first++; + } + mlx4_dbg(dev, "%s: can't delete slave (%d) counter index %d for port %d\n" + , __func__, slave, idx, port); + } + +out: + mutex_unlock(&priv->counters_table.mutex); } -void mlx4_counter_free(struct mlx4_dev *dev, u32 idx) +void mlx4_counter_free(struct mlx4_dev *dev, u8 port, u32 idx) { u64 in_param = 0; + struct mlx4_priv *priv = mlx4_priv(dev); + struct counter_index *counter, *tmp_counter; + int first = 0; if (mlx4_is_mfunc(dev)) { set_param_l(&in_param, idx); - mlx4_cmd(dev, in_param, RES_COUNTER, RES_OP_RESERVE, + mlx4_cmd(dev, in_param, + ((u32) port) << 8 | (u32) RES_COUNTER, + RES_OP_RESERVE, MLX4_CMD_FREE_RES, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + + if (mlx4_is_slave(dev) && idx != MLX4_SINK_COUNTER_INDEX) { + mutex_lock(&priv->counters_table.mutex); + list_for_each_entry_safe(counter, tmp_counter, + &priv->counters_table.global_port_list[port - 1], + list) { + if (counter->index == idx && first++) { + list_del(&counter->list); + kfree(counter); + mlx4_dbg(dev, "%s: delete counter index %d for port %d\n" + , __func__, idx, port); + mutex_unlock(&priv->counters_table.mutex); + return; + } + } + mutex_unlock(&priv->counters_table.mutex); + } + return; } - __mlx4_counter_free(dev, idx); + __mlx4_counter_free(dev, 0, port, idx); } EXPORT_SYMBOL_GPL(mlx4_counter_free); +int __mlx4_clear_if_stat(struct mlx4_dev *dev, + u8 counter_index) +{ + struct mlx4_cmd_mailbox *if_stat_mailbox = NULL; + int err = 0; + u32 if_stat_in_mod = (counter_index & 0xff) | (1 << 31); + + if (counter_index == MLX4_SINK_COUNTER_INDEX) + return -EINVAL; + + if (mlx4_is_slave(dev)) + return 0; + + if_stat_mailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(if_stat_mailbox)) { + err = PTR_ERR(if_stat_mailbox); + return err; + } + + err = mlx4_cmd_box(dev, 0, if_stat_mailbox->dma, if_stat_in_mod, 0, + MLX4_CMD_QUERY_IF_STAT, MLX4_CMD_TIME_CLASS_C, + MLX4_CMD_NATIVE); + + mlx4_free_cmd_mailbox(dev, if_stat_mailbox); + return err; +} + +u8 mlx4_get_default_counter_index(struct mlx4_dev *dev, int slave, int port) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct counter_index *new_counter_index; + + if (dev->caps.port_type[port] == MLX4_PORT_TYPE_IB) { + mlx4_dbg(dev, "%s: return counter index %d for slave %d port (MLX4_PORT_TYPE_IB) %d\n", + __func__, MLX4_SINK_COUNTER_INDEX, slave, port); + return (u8)MLX4_SINK_COUNTER_INDEX; + } + + mutex_lock(&priv->counters_table.mutex); + if (slave == 0) { + new_counter_index = list_entry(priv->counters_table.global_port_list[port - 1].next, + struct counter_index, + list); + } else { + new_counter_index = list_entry(priv->counters_table.vf_list[slave - 1][port - 1].next, + struct counter_index, + list); + } + mutex_unlock(&priv->counters_table.mutex); + + mlx4_dbg(dev, "%s: return counter index %d for slave %d port %d\n", + __func__, new_counter_index->index, slave, port); + + + return (u8)new_counter_index->index; +} + +int mlx4_get_vport_ethtool_stats(struct mlx4_dev *dev, int port, + struct mlx4_en_vport_stats *vport_stats, + int reset) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_cmd_mailbox *if_stat_mailbox = NULL; + union mlx4_counter *counter; + int err = 0; + u32 if_stat_in_mod; + struct counter_index *vport, *tmp_vport; + + if (!vport_stats) + return -EINVAL; + + if_stat_mailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(if_stat_mailbox)) { + err = PTR_ERR(if_stat_mailbox); + return err; + } + + mutex_lock(&priv->counters_table.mutex); + list_for_each_entry_safe(vport, tmp_vport, + &priv->counters_table.global_port_list[port - 1], + list) { + if (vport->index == MLX4_SINK_COUNTER_INDEX) + continue; + + memset(if_stat_mailbox->buf, 0, sizeof(union mlx4_counter)); + if_stat_in_mod = (vport->index & 0xff) | ((reset & 1) << 31); + err = mlx4_cmd_box(dev, 0, if_stat_mailbox->dma, + if_stat_in_mod, 0, + MLX4_CMD_QUERY_IF_STAT, + MLX4_CMD_TIME_CLASS_C, + MLX4_CMD_NATIVE); + if (err) { + mlx4_dbg(dev, "%s: failed to read statistics for counter index %d\n", + __func__, vport->index); + goto if_stat_out; + } + counter = (union mlx4_counter *)if_stat_mailbox->buf; + if ((counter->control.cnt_mode & 0xf) == 1) { + vport_stats->rx_broadcast_packets += be64_to_cpu(counter->ext.counters[0].IfRxBroadcastFrames); + vport_stats->rx_unicast_packets += be64_to_cpu(counter->ext.counters[0].IfRxUnicastFrames); + vport_stats->rx_multicast_packets += be64_to_cpu(counter->ext.counters[0].IfRxMulticastFrames); + vport_stats->tx_broadcast_packets += be64_to_cpu(counter->ext.counters[0].IfTxBroadcastFrames); + vport_stats->tx_unicast_packets += be64_to_cpu(counter->ext.counters[0].IfTxUnicastFrames); + vport_stats->tx_multicast_packets += be64_to_cpu(counter->ext.counters[0].IfTxMulticastFrames); + vport_stats->rx_broadcast_bytes += be64_to_cpu(counter->ext.counters[0].IfRxBroadcastOctets); + vport_stats->rx_unicast_bytes += be64_to_cpu(counter->ext.counters[0].IfRxUnicastOctets); + vport_stats->rx_multicast_bytes += be64_to_cpu(counter->ext.counters[0].IfRxMulticastOctets); + vport_stats->tx_broadcast_bytes += be64_to_cpu(counter->ext.counters[0].IfTxBroadcastOctets); + vport_stats->tx_unicast_bytes += be64_to_cpu(counter->ext.counters[0].IfTxUnicastOctets); + vport_stats->tx_multicast_bytes += be64_to_cpu(counter->ext.counters[0].IfTxMulticastOctets); + vport_stats->rx_errors += be64_to_cpu(counter->ext.counters[0].IfRxErrorFrames); + vport_stats->rx_dropped += be64_to_cpu(counter->ext.counters[0].IfRxNoBufferFrames); + vport_stats->tx_errors += be64_to_cpu(counter->ext.counters[0].IfTxDroppedFrames); + } + } + +if_stat_out: + mutex_unlock(&priv->counters_table.mutex); + mlx4_free_cmd_mailbox(dev, if_stat_mailbox); + + return err; +} +EXPORT_SYMBOL_GPL(mlx4_get_vport_ethtool_stats); + static int mlx4_setup_hca(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); @@ -1862,11 +2721,21 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) goto err_xrcd_table_free; } + if (!mlx4_is_slave(dev)) { + err = mlx4_init_mcg_table(dev); + if (err) { + mlx4_err(dev, "Failed to initialize " + "multicast group table (err=%d), aborting.\n", + err); + goto err_mr_table_free; + } + } + err = mlx4_init_eq_table(dev); if (err) { mlx4_err(dev, "Failed to initialize " "event queue table (err=%d), aborting.\n", err); - goto err_mr_table_free; + goto err_mcg_table_free; } err = mlx4_cmd_use_events(dev); @@ -1917,22 +2786,14 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) goto err_srq_table_free; } + err = mlx4_init_counters_table(dev); + if (err && err != -ENOENT) { + mlx4_err(dev, "Failed to initialize counters table (err=%d), " + "aborting.\n", err); + goto err_qp_table_free; + } + if (!mlx4_is_slave(dev)) { - err = mlx4_init_mcg_table(dev); - if (err) { - mlx4_err(dev, "Failed to initialize " - "multicast group table (err=%d), aborting.\n", - err); - goto err_qp_table_free; - } - - err = mlx4_init_counters_table(dev); - if (err && err != -ENOENT) { - mlx4_err(dev, "Failed to initialize counters table (err=%d), " - "aborting.\n", err); - goto err_mcg_table_free; - } - for (port = 1; port <= dev->caps.num_ports; port++) { ib_port_default_caps = 0; err = mlx4_get_port_ib_caps(dev, port, @@ -1954,10 +2815,7 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) } } - if (mlx4_is_mfunc(dev)) - dev->caps.port_ib_mtu[port] = IB_MTU_2048; - else - dev->caps.port_ib_mtu[port] = IB_MTU_4096; + dev->caps.port_ib_mtu[port] = IB_MTU_4096; err = mlx4_SET_PORT(dev, port, mlx4_is_master(dev) ? dev->caps.pkey_table_len[port] : -1); @@ -1974,9 +2832,6 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) err_counters_table_free: mlx4_cleanup_counters_table(dev); -err_mcg_table_free: - mlx4_cleanup_mcg_table(dev); - err_qp_table_free: mlx4_cleanup_qp_table(dev); @@ -1992,6 +2847,10 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) err_eq_table_free: mlx4_cleanup_eq_table(dev); +err_mcg_table_free: + if (!mlx4_is_slave(dev)) + mlx4_cleanup_mcg_table(dev); + err_mr_table_free: mlx4_cleanup_mr_table(dev); @@ -2026,6 +2885,9 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, nreq); + if (msi_x > 1 && !mlx4_is_mfunc(dev)) + nreq = min_t(int, nreq, msi_x); + entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); if (!entries) goto no_msi; @@ -2237,6 +3099,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) struct mlx4_dev *dev; int err; int port; + int nvfs, prb_vf; pr_info(DRV_NAME ": Initializing %s\n", pci_name(pdev)); @@ -2246,13 +3109,16 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) "aborting.\n"); return err; } - if (num_vfs > MLX4_MAX_NUM_VF) { + + mlx4_get_val(num_vfs.dbdf2val.tbl, pci_physfn(pdev), 0, &nvfs); + mlx4_get_val(probe_vf.dbdf2val.tbl, pci_physfn(pdev), 0, &prb_vf); + if (nvfs > MLX4_MAX_NUM_VF) { dev_err(&pdev->dev, "There are more VF's (%d) than allowed(%d)\n", - num_vfs, MLX4_MAX_NUM_VF); + nvfs, MLX4_MAX_NUM_VF); return -EINVAL; } - if (num_vfs < 0) { + if (nvfs < 0) { dev_err(&pdev->dev, "num_vfs module parameter cannot be negative\n"); return -EINVAL; } @@ -2315,6 +3181,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) dev = &priv->dev; dev->pdev = pdev; + INIT_LIST_HEAD(&priv->dev_list); INIT_LIST_HEAD(&priv->ctx_list); spin_lock_init(&priv->ctx_lock); @@ -2332,7 +3199,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) if (pci_dev_data & MLX4_PCI_DEV_IS_VF) { /* When acting as pf, we normally skip vfs unless explicitly * requested to probe them. */ - if (num_vfs && extended_func_num(pdev) > probe_vf) { + if (nvfs && extended_func_num(pdev) > prb_vf) { mlx4_warn(dev, "Skipping virtual function:%d\n", extended_func_num(pdev)); err = -ENODEV; @@ -2356,9 +3223,9 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) } } - if (num_vfs) { - mlx4_warn(dev, "Enabling SR-IOV with %d VFs\n", num_vfs); - err = pci_enable_sriov(pdev, num_vfs); + if (nvfs) { + mlx4_warn(dev, "Enabling SR-IOV with %d VFs\n", nvfs); + err = pci_enable_sriov(pdev, nvfs); if (err) { mlx4_err(dev, "Failed to enable SR-IOV, continuing without SR-IOV (err = %d).\n", err); @@ -2367,7 +3234,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) mlx4_warn(dev, "Running in master mode\n"); dev->flags |= MLX4_FLAG_SRIOV | MLX4_FLAG_MASTER; - dev->num_vfs = num_vfs; + dev->num_vfs = nvfs; } } @@ -2481,10 +3348,9 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) if (err) goto err_port; - err = mlx4_sense_init(dev); - if (err) - goto err_port; + mlx4_request_modules(dev); + mlx4_sense_init(dev); mlx4_start_sense(dev); priv->pci_dev_data = pci_dev_data; @@ -2497,12 +3363,12 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) mlx4_cleanup_port_info(&priv->port[port]); mlx4_cleanup_counters_table(dev); - mlx4_cleanup_mcg_table(dev); mlx4_cleanup_qp_table(dev); mlx4_cleanup_srq_table(dev); mlx4_cleanup_cq_table(dev); mlx4_cmd_use_polling(dev); mlx4_cleanup_eq_table(dev); + mlx4_cleanup_mcg_table(dev); mlx4_cleanup_mr_table(dev); mlx4_cleanup_xrcd_table(dev); mlx4_cleanup_pd_table(dev); @@ -2516,8 +3382,10 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) mlx4_free_eq_table(dev); err_master_mfunc: - if (mlx4_is_master(dev)) + if (mlx4_is_master(dev)) { + mlx4_free_resource_tracker(dev, RES_TR_FREE_STRUCTS_ONLY); mlx4_multi_func_cleanup(dev); + } if (mlx4_is_slave(dev)) { kfree(dev->caps.qp0_tunnel); @@ -2579,7 +3447,7 @@ static void mlx4_remove_one(struct pci_dev *pdev) if (mlx4_how_many_lives_vf(dev)) mlx4_err(dev, "Removing PF when there are assigned VF's !!!\n"); } - mlx4_sense_cleanup(dev); + mlx4_stop_sense(dev); mlx4_unregister_device(dev); for (p = 1; p <= dev->caps.num_ports; p++) { @@ -2592,12 +3460,12 @@ static void mlx4_remove_one(struct pci_dev *pdev) RES_TR_FREE_SLAVES_ONLY); mlx4_cleanup_counters_table(dev); - mlx4_cleanup_mcg_table(dev); mlx4_cleanup_qp_table(dev); mlx4_cleanup_srq_table(dev); mlx4_cleanup_cq_table(dev); mlx4_cmd_use_polling(dev); mlx4_cleanup_eq_table(dev); + mlx4_cleanup_mcg_table(dev); mlx4_cleanup_mr_table(dev); mlx4_cleanup_xrcd_table(dev); mlx4_cleanup_pd_table(dev); @@ -2641,15 +3509,48 @@ static void mlx4_remove_one(struct pci_dev *pdev) } } +static int restore_current_port_types(struct mlx4_dev *dev, + enum mlx4_port_type *types, + enum mlx4_port_type *poss_types) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + int err, i; + + mlx4_stop_sense(dev); + mutex_lock(&priv->port_mutex); + for (i = 0; i < dev->caps.num_ports; i++) + dev->caps.possible_type[i + 1] = poss_types[i]; + err = mlx4_change_port_types(dev, types); + mlx4_start_sense(dev); + mutex_unlock(&priv->port_mutex); + return err; +} + int mlx4_restart_one(struct pci_dev *pdev) { struct mlx4_dev *dev = pci_get_drvdata(pdev); struct mlx4_priv *priv = mlx4_priv(dev); - int pci_dev_data; + enum mlx4_port_type curr_type[MLX4_MAX_PORTS]; + enum mlx4_port_type poss_type[MLX4_MAX_PORTS]; + int pci_dev_data, err, i; pci_dev_data = priv->pci_dev_data; + for (i = 0; i < dev->caps.num_ports; i++) { + curr_type[i] = dev->caps.port_type[i + 1]; + poss_type[i] = dev->caps.possible_type[i + 1]; + } + mlx4_remove_one(pdev); - return __mlx4_init_one(pdev, pci_dev_data); + err = __mlx4_init_one(pdev, pci_dev_data); + if (err) + return err; + + dev = pci_get_drvdata(pdev); + err = restore_current_port_types(dev, curr_type, poss_type); + if (err) + mlx4_err(dev, "mlx4_restart_one: could not restore original port types (%d)\n", + err); + return 0; } static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = { @@ -2725,16 +3626,6 @@ static int suspend(struct pci_dev *pdev, pm_message_t state) { mlx4_remove_one(pdev); - if (mlx4_log_num_mgm_entry_size != -1 && - (mlx4_log_num_mgm_entry_size < MLX4_MIN_MGM_LOG_ENTRY_SIZE || - mlx4_log_num_mgm_entry_size > MLX4_MAX_MGM_LOG_ENTRY_SIZE)) { - pr_warning("mlx4_core: mlx4_log_num_mgm_entry_size (%d) not " - "in legal range (-1 or %d..%d)\n", - mlx4_log_num_mgm_entry_size, - MLX4_MIN_MGM_LOG_ENTRY_SIZE, - MLX4_MAX_MGM_LOG_ENTRY_SIZE); - return -1; - } return 0; } @@ -2745,16 +3636,47 @@ static int resume(struct pci_dev *pdev) static struct pci_driver mlx4_driver = { .name = DRV_NAME, - .id_table = (struct pci_device_id*)mlx4_pci_table, + .id_table = mlx4_pci_table, .probe = mlx4_init_one, .remove = __devexit_p(mlx4_remove_one), .suspend = suspend, .resume = resume, - .err_handler = (struct pci_error_handlers*)&mlx4_err_handler, + .err_handler = &mlx4_err_handler, }; static int __init mlx4_verify_params(void) { + int status; + + status = update_defaults(&port_type_array); + if (status == INVALID_STR) { + if (mlx4_fill_dbdf2val_tbl(&port_type_array.dbdf2val)) + return -1; + } else if (status == INVALID_DATA) { + return -1; + } + + status = update_defaults(&num_vfs); + if (status == INVALID_STR) { + if (mlx4_fill_dbdf2val_tbl(&num_vfs.dbdf2val)) + return -1; + } else if (status == INVALID_DATA) { + return -1; + } + + status = update_defaults(&probe_vf); + if (status == INVALID_STR) { + if (mlx4_fill_dbdf2val_tbl(&probe_vf.dbdf2val)) + return -1; + } else if (status == INVALID_DATA) { + return -1; + } + + if (msi_x < 0) { + pr_warn("mlx4_core: bad msi_x: %d\n", msi_x); + return -1; + } + if ((log_num_mac < 0) || (log_num_mac > 7)) { pr_warning("mlx4_core: bad num_mac: %d\n", log_num_mac); return -1; @@ -2772,12 +3694,6 @@ static int __init mlx4_verify_params(void) return -1; } - /* Check if module param for ports type has legal combination */ - if (port_type_array[0] == false && port_type_array[1] == true) { - pr_warning("mlx4_core: module parameter configuration ETH/IB is not supported. Switching to default configuration IB/IB\n"); - port_type_array[0] = true; - } - if (mlx4_log_num_mgm_entry_size != -1 && (mlx4_log_num_mgm_entry_size < MLX4_MIN_MGM_LOG_ENTRY_SIZE || mlx4_log_num_mgm_entry_size > MLX4_MAX_MGM_LOG_ENTRY_SIZE)) { @@ -2813,15 +3729,16 @@ static int __init mlx4_verify_params(void) return -1; } - if (mod_param_profile.num_mtt && mod_param_profile.num_mtt < 15) { + if (mod_param_profile.num_mtt_segs && + mod_param_profile.num_mtt_segs < 15) { pr_warning("mlx4_core: too low log_num_mtt: %d\n", - mod_param_profile.num_mtt); + mod_param_profile.num_mtt_segs); return -1; } - if (mod_param_profile.num_mtt > MLX4_MAX_LOG_NUM_MTT) { + if (mod_param_profile.num_mtt_segs > MLX4_MAX_LOG_NUM_MTT) { pr_warning("mlx4_core: too high log_num_mtt: %d\n", - mod_param_profile.num_mtt); + mod_param_profile.num_mtt_segs); return -1; } return 0; @@ -2844,10 +3761,18 @@ static int __init mlx4_init(void) sys_tune_init(); ret = pci_register_driver(&mlx4_driver); - if (ret < 0 && enable_sys_tune) + if (ret < 0) + goto err; + + return 0; + +err: + if (enable_sys_tune) sys_tune_fini(); - return ret < 0 ? ret : 0; + destroy_workqueue(mlx4_wq); + + return ret; } static void __exit mlx4_cleanup(void) @@ -2862,17 +3787,16 @@ static void __exit mlx4_cleanup(void) module_init_order(mlx4_init, SI_ORDER_MIDDLE); module_exit(mlx4_cleanup); -#undef MODULE_VERSION #include static int mlx4_evhand(module_t mod, int event, void *arg) { - return (0); + return (0); } static moduledata_t mlx4_mod = { - .name = "mlx4", - .evhand = mlx4_evhand, + .name = "mlx4", + .evhand = mlx4_evhand, }; MODULE_VERSION(mlx4, 1); DECLARE_MODULE(mlx4, mlx4_mod, SI_SUB_OFED_PREINIT, SI_ORDER_ANY); diff --git a/sys/ofed/drivers/net/mlx4/mcg.c b/sys/ofed/drivers/net/mlx4/mcg.c index 60ac9517da55..52c52f80bc11 100644 --- a/sys/ofed/drivers/net/mlx4/mcg.c +++ b/sys/ofed/drivers/net/mlx4/mcg.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -32,8 +32,10 @@ */ #include +#include #include +#include #include "mlx4.h" @@ -124,9 +126,14 @@ static struct mlx4_promisc_qp *get_promisc_qp(struct mlx4_dev *dev, u8 port, enum mlx4_steer_type steer, u32 qpn) { - struct mlx4_steer *s_steer = &mlx4_priv(dev)->steer[port - 1]; + struct mlx4_steer *s_steer; struct mlx4_promisc_qp *pqp; + if (port < 1 || port > dev->caps.num_ports) + return NULL; + + s_steer = &mlx4_priv(dev)->steer[port - 1]; + list_for_each_entry(pqp, &s_steer->promisc_qps[steer], list) { if (pqp->qpn == qpn) return pqp; @@ -153,6 +160,9 @@ static int new_steering_entry(struct mlx4_dev *dev, u8 port, u32 prot; int err; + if (port < 1 || port > dev->caps.num_ports) + return -EINVAL; + s_steer = &mlx4_priv(dev)->steer[port - 1]; new_entry = kzalloc(sizeof *new_entry, GFP_KERNEL); if (!new_entry) @@ -237,6 +247,9 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port, struct mlx4_promisc_qp *pqp; struct mlx4_promisc_qp *dqp; + if (port < 1 || port > dev->caps.num_ports) + return -EINVAL; + s_steer = &mlx4_priv(dev)->steer[port - 1]; pqp = get_promisc_qp(dev, port, steer, qpn); @@ -258,7 +271,7 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port, * we need to add it as a duplicate to this entry * for future references */ list_for_each_entry(dqp, &entry->duplicates, list) { - if (qpn == pqp->qpn) + if (qpn == dqp->qpn) return 0; /* qp is already duplicated */ } @@ -282,6 +295,9 @@ static bool check_duplicate_entry(struct mlx4_dev *dev, u8 port, struct mlx4_steer_index *tmp_entry, *entry = NULL; struct mlx4_promisc_qp *dqp, *tmp_dqp; + if (port < 1 || port > dev->caps.num_ports) + return NULL; + s_steer = &mlx4_priv(dev)->steer[port - 1]; /* if qp is not promisc, it cannot be duplicated */ @@ -309,20 +325,24 @@ static bool check_duplicate_entry(struct mlx4_dev *dev, u8 port, return true; } -/* I a steering entry contains only promisc QPs, it can be removed. */ -static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, +/* + * returns true if all the QPs != tqpn contained in this entry + * are Promisc QPs. return false otherwise. + */ +static bool promisc_steering_entry(struct mlx4_dev *dev, u8 port, enum mlx4_steer_type steer, - unsigned int index, u32 tqpn) + unsigned int index, u32 tqpn, u32 *members_count) { struct mlx4_steer *s_steer; struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm; - struct mlx4_steer_index *entry = NULL, *tmp_entry; - u32 qpn; - u32 members_count; + u32 m_count; bool ret = false; int i; + if (port < 1 || port > dev->caps.num_ports) + return false; + s_steer = &mlx4_priv(dev)->steer[port - 1]; mailbox = mlx4_alloc_cmd_mailbox(dev); @@ -332,15 +352,42 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, if (mlx4_READ_ENTRY(dev, index, mailbox)) goto out; - members_count = be32_to_cpu(mgm->members_count) & 0xffffff; - for (i = 0; i < members_count; i++) { - qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK; + m_count = be32_to_cpu(mgm->members_count) & 0xffffff; + if (members_count) + *members_count = m_count; + + for (i = 0; i < m_count; i++) { + u32 qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK; if (!get_promisc_qp(dev, port, steer, qpn) && qpn != tqpn) { /* the qp is not promisc, the entry can't be removed */ goto out; } } - /* All the qps currently registered for this entry are promiscuous, + ret = true; +out: + mlx4_free_cmd_mailbox(dev, mailbox); + return ret; +} + +/* IF a steering entry contains only promisc QPs, it can be removed. */ +static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, + enum mlx4_steer_type steer, + unsigned int index, u32 tqpn) +{ + struct mlx4_steer *s_steer; + struct mlx4_steer_index *entry = NULL, *tmp_entry; + u32 members_count; + bool ret = false; + + if (port < 1 || port > dev->caps.num_ports) + return NULL; + + s_steer = &mlx4_priv(dev)->steer[port - 1]; + + if (!promisc_steering_entry(dev, port, steer, index, tqpn, &members_count)) + goto out; + + /* All the qps currently registered for this entry are promiscuous, * Checking for duplicates */ ret = true; list_for_each_entry_safe(entry, tmp_entry, &s_steer->steer_entries[steer], list) { @@ -369,7 +416,6 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, } out: - mlx4_free_cmd_mailbox(dev, mailbox); return ret; } @@ -389,6 +435,9 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port, int err; struct mlx4_priv *priv = mlx4_priv(dev); + if (port < 1 || port > dev->caps.num_ports) + return -EINVAL; + s_steer = &mlx4_priv(dev)->steer[port - 1]; mutex_lock(&priv->mcg_table.mutex); @@ -412,43 +461,45 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port, } mgm = mailbox->buf; - /* the promisc qp needs to be added for each one of the steering - * entries, if it already exists, needs to be added as a duplicate - * for this entry */ - list_for_each_entry(entry, &s_steer->steer_entries[steer], list) { - err = mlx4_READ_ENTRY(dev, entry->index, mailbox); - if (err) - goto out_mailbox; + if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) { + /* the promisc qp needs to be added for each one of the steering + * entries, if it already exists, needs to be added as a duplicate + * for this entry */ + list_for_each_entry(entry, &s_steer->steer_entries[steer], list) { + err = mlx4_READ_ENTRY(dev, entry->index, mailbox); + if (err) + goto out_mailbox; - members_count = be32_to_cpu(mgm->members_count) & 0xffffff; - prot = be32_to_cpu(mgm->members_count) >> 30; - found = false; - for (i = 0; i < members_count; i++) { - if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) { - /* Entry already exists, add to duplicates */ - dqp = kmalloc(sizeof *dqp, GFP_KERNEL); - if (!dqp) { + members_count = be32_to_cpu(mgm->members_count) & 0xffffff; + prot = be32_to_cpu(mgm->members_count) >> 30; + found = false; + for (i = 0; i < members_count; i++) { + if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) { + /* Entry already exists, add to duplicates */ + dqp = kmalloc(sizeof *dqp, GFP_KERNEL); + if (!dqp) { + err = -ENOMEM; + goto out_mailbox; + } + dqp->qpn = qpn; + list_add_tail(&dqp->list, &entry->duplicates); + found = true; + } + } + if (!found) { + /* Need to add the qpn to mgm */ + if (members_count == dev->caps.num_qp_per_mgm) { + /* entry is full */ err = -ENOMEM; goto out_mailbox; } - dqp->qpn = qpn; - list_add_tail(&dqp->list, &entry->duplicates); - found = true; + mgm->qp[members_count++] = cpu_to_be32(qpn & MGM_QPN_MASK); + mgm->members_count = cpu_to_be32(members_count | (prot << 30)); + err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); + if (err) + goto out_mailbox; } } - if (!found) { - /* Need to add the qpn to mgm */ - if (members_count == dev->caps.num_qp_per_mgm) { - /* entry is full */ - err = -ENOMEM; - goto out_mailbox; - } - mgm->qp[members_count++] = cpu_to_be32(qpn & MGM_QPN_MASK); - mgm->members_count = cpu_to_be32(members_count | (prot << 30)); - err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); - if (err) - goto out_mailbox; - } } /* add the new qpn to list of promisc qps */ @@ -492,7 +543,7 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, struct mlx4_steer *s_steer; struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm; - struct mlx4_steer_index *entry; + struct mlx4_steer_index *entry, *tmp_entry; struct mlx4_promisc_qp *pqp; struct mlx4_promisc_qp *dqp; u32 members_count; @@ -501,6 +552,9 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, int i, loc = -1; int err; + if (port < 1 || port > dev->caps.num_ports) + return -EINVAL; + s_steer = &mlx4_priv(dev)->steer[port - 1]; mutex_lock(&priv->mcg_table.mutex); @@ -533,49 +587,58 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, if (err) goto out_mailbox; - /* remove the qp from all the steering entries*/ - list_for_each_entry(entry, &s_steer->steer_entries[steer], list) { - found = false; - list_for_each_entry(dqp, &entry->duplicates, list) { - if (dqp->qpn == qpn) { - found = true; - break; - } - } - if (found) { - /* a duplicate, no need to change the mgm, - * only update the duplicates list */ - list_del(&dqp->list); - kfree(dqp); - } else { - err = mlx4_READ_ENTRY(dev, entry->index, mailbox); - if (err) - goto out_mailbox; - members_count = be32_to_cpu(mgm->members_count) & 0xffffff; - for (i = 0; i < members_count; ++i) - if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) { - loc = i; + if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) { + /* remove the qp from all the steering entries*/ + list_for_each_entry_safe(entry, tmp_entry, &s_steer->steer_entries[steer], list) { + found = false; + list_for_each_entry(dqp, &entry->duplicates, list) { + if (dqp->qpn == qpn) { + found = true; break; } - - if (loc < 0) { - mlx4_err(dev, "QP %06x wasn't found in entry %d\n", - qpn, entry->index); - err = -EINVAL; - goto out_mailbox; } + if (found) { + /* a duplicate, no need to change the mgm, + * only update the duplicates list */ + list_del(&dqp->list); + kfree(dqp); + } else { + err = mlx4_READ_ENTRY(dev, entry->index, mailbox); + if (err) + goto out_mailbox; + members_count = be32_to_cpu(mgm->members_count) & 0xffffff; + if (!members_count) { + mlx4_warn(dev, "QP %06x wasn't found in entry %x mcount=0." + " deleting entry...\n", qpn, entry->index); + list_del(&entry->list); + kfree(entry); + continue; + } - /* copy the last QP in this MGM over removed QP */ - mgm->qp[loc] = mgm->qp[members_count - 1]; - mgm->qp[members_count - 1] = 0; - mgm->members_count = cpu_to_be32(--members_count | - (MLX4_PROT_ETH << 30)); + for (i = 0; i < members_count; ++i) + if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) { + loc = i; + break; + } - err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); - if (err) + if (loc < 0) { + mlx4_err(dev, "QP %06x wasn't found in entry %d\n", + qpn, entry->index); + err = -EINVAL; goto out_mailbox; - } + } + /* copy the last QP in this MGM over removed QP */ + mgm->qp[loc] = mgm->qp[members_count - 1]; + mgm->qp[members_count - 1] = 0; + mgm->members_count = cpu_to_be32(--members_count | + (MLX4_PROT_ETH << 30)); + + err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); + if (err) + goto out_mailbox; + } + } } out_mailbox: @@ -661,26 +724,37 @@ static int find_entry(struct mlx4_dev *dev, u8 port, return err; } +static const u8 __promisc_mode[] = { + [MLX4_FS_REGULAR] = 0x0, + [MLX4_FS_ALL_DEFAULT] = 0x1, + [MLX4_FS_MC_DEFAULT] = 0x3, + [MLX4_FS_UC_SNIFFER] = 0x4, + [MLX4_FS_MC_SNIFFER] = 0x5, +}; + +int map_sw_to_hw_steering_mode(struct mlx4_dev *dev, + enum mlx4_net_trans_promisc_mode flow_type) +{ + if (flow_type >= MLX4_FS_MODE_NUM || flow_type < 0) { + mlx4_err(dev, "Invalid flow type. type = %d\n", flow_type); + return -EINVAL; + } + return __promisc_mode[flow_type]; +} +EXPORT_SYMBOL_GPL(map_sw_to_hw_steering_mode); + static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl, struct mlx4_net_trans_rule_hw_ctrl *hw) { - static const u8 __promisc_mode[] = { - [MLX4_FS_REGULAR] = 0x0, - [MLX4_FS_ALL_DEFAULT] = 0x1, - [MLX4_FS_MC_DEFAULT] = 0x3, - [MLX4_FS_UC_SNIFFER] = 0x4, - [MLX4_FS_MC_SNIFFER] = 0x5, - }; + u8 flags = 0; - u32 dw = 0; + flags = ctrl->queue_mode == MLX4_NET_TRANS_Q_LIFO ? 1 : 0; + flags |= ctrl->exclusive ? (1 << 2) : 0; + flags |= ctrl->allow_loopback ? (1 << 3) : 0; - dw = ctrl->queue_mode == MLX4_NET_TRANS_Q_LIFO ? 1 : 0; - dw |= ctrl->exclusive ? (1 << 2) : 0; - dw |= ctrl->allow_loopback ? (1 << 3) : 0; - dw |= __promisc_mode[ctrl->promisc_mode] << 8; - dw |= ctrl->priority << 16; - - hw->ctrl = cpu_to_be32(dw); + hw->flags = flags; + hw->type = __promisc_mode[ctrl->promisc_mode]; + hw->prio = cpu_to_be16(ctrl->priority); hw->port = ctrl->port; hw->qpn = cpu_to_be32(ctrl->qpn); } @@ -694,29 +768,51 @@ const u16 __sw_id_hw[] = { [MLX4_NET_TRANS_RULE_ID_UDP] = 0xE006 }; +int map_sw_to_hw_steering_id(struct mlx4_dev *dev, + enum mlx4_net_trans_rule_id id) +{ + if (id >= MLX4_NET_TRANS_RULE_NUM || id < 0) { + mlx4_err(dev, "Invalid network rule id. id = %d\n", id); + return -EINVAL; + } + return __sw_id_hw[id]; +} +EXPORT_SYMBOL_GPL(map_sw_to_hw_steering_id); + +static const int __rule_hw_sz[] = { + [MLX4_NET_TRANS_RULE_ID_ETH] = + sizeof(struct mlx4_net_trans_rule_hw_eth), + [MLX4_NET_TRANS_RULE_ID_IB] = + sizeof(struct mlx4_net_trans_rule_hw_ib), + [MLX4_NET_TRANS_RULE_ID_IPV6] = 0, + [MLX4_NET_TRANS_RULE_ID_IPV4] = + sizeof(struct mlx4_net_trans_rule_hw_ipv4), + [MLX4_NET_TRANS_RULE_ID_TCP] = + sizeof(struct mlx4_net_trans_rule_hw_tcp_udp), + [MLX4_NET_TRANS_RULE_ID_UDP] = + sizeof(struct mlx4_net_trans_rule_hw_tcp_udp) +}; + +int hw_rule_sz(struct mlx4_dev *dev, + enum mlx4_net_trans_rule_id id) +{ + if (id >= MLX4_NET_TRANS_RULE_NUM || id < 0) { + mlx4_err(dev, "Invalid network rule id. id = %d\n", id); + return -EINVAL; + } + + return __rule_hw_sz[id]; +} +EXPORT_SYMBOL_GPL(hw_rule_sz); + static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec, struct _rule_hw *rule_hw) { - static const size_t __rule_hw_sz[] = { - [MLX4_NET_TRANS_RULE_ID_ETH] = - sizeof(struct mlx4_net_trans_rule_hw_eth), - [MLX4_NET_TRANS_RULE_ID_IB] = - sizeof(struct mlx4_net_trans_rule_hw_ib), - [MLX4_NET_TRANS_RULE_ID_IPV6] = 0, - [MLX4_NET_TRANS_RULE_ID_IPV4] = - sizeof(struct mlx4_net_trans_rule_hw_ipv4), - [MLX4_NET_TRANS_RULE_ID_TCP] = - sizeof(struct mlx4_net_trans_rule_hw_tcp_udp), - [MLX4_NET_TRANS_RULE_ID_UDP] = - sizeof(struct mlx4_net_trans_rule_hw_tcp_udp) - }; - if (spec->id >= MLX4_NET_TRANS_RULE_NUM) { - mlx4_err(dev, "Invalid network rule id. id = %d\n", spec->id); + if (hw_rule_sz(dev, spec->id) < 0) return -EINVAL; - } - memset(rule_hw, 0, __rule_hw_sz[spec->id]); + memset(rule_hw, 0, hw_rule_sz(dev, spec->id)); rule_hw->id = cpu_to_be16(__sw_id_hw[spec->id]); - rule_hw->size = __rule_hw_sz[spec->id] >> 2; + rule_hw->size = hw_rule_sz(dev, spec->id) >> 2; switch (spec->id) { case MLX4_NET_TRANS_RULE_ID_ETH: @@ -730,12 +826,12 @@ static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec, rule_hw->eth.ether_type_enable = 1; rule_hw->eth.ether_type = spec->eth.ether_type; } - rule_hw->eth.vlan_id = spec->eth.vlan_id; - rule_hw->eth.vlan_id_msk = spec->eth.vlan_id_msk; + rule_hw->eth.vlan_tag = spec->eth.vlan_id; + rule_hw->eth.vlan_tag_msk = spec->eth.vlan_id_msk; break; case MLX4_NET_TRANS_RULE_ID_IB: - rule_hw->ib.r_u_qpn = spec->ib.r_u_qpn; + rule_hw->ib.l3_qpn = spec->ib.l3_qpn; rule_hw->ib.qpn_mask = spec->ib.qpn_msk; memcpy(&rule_hw->ib.dst_gid, &spec->ib.dst_gid, 16); memcpy(&rule_hw->ib.dst_gid_msk, &spec->ib.dst_gid_msk, 16); @@ -886,7 +982,7 @@ int mlx4_flow_detach(struct mlx4_dev *dev, u64 reg_id) err = mlx4_QP_FLOW_STEERING_DETACH(dev, reg_id); if (err) mlx4_err(dev, "Fail to detach network rule. registration id = 0x%llx\n", - (long long)reg_id); + (unsigned long long)reg_id); return err; } EXPORT_SYMBOL_GPL(mlx4_flow_detach); @@ -977,8 +1073,9 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], if (err) goto out; + /* if !link, still add the new entry. */ if (!link) - goto out; + goto skip_link; err = mlx4_READ_ENTRY(dev, prev, mailbox); if (err) @@ -990,6 +1087,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], if (err) goto out; +skip_link: if (prot == MLX4_PROT_ETH) { /* manage the steering entry for promisc mode */ if (new_entry) @@ -1006,7 +1104,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], index, dev->caps.num_mgms); else mlx4_bitmap_free(&priv->mcg_table.bitmap, - index - dev->caps.num_mgms); + index - dev->caps.num_mgms, MLX4_USE_RR); } mutex_unlock(&priv->mcg_table.mutex); @@ -1045,10 +1143,14 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], goto out; } - /* if this pq is also a promisc qp, it shouldn't be removed */ + /* + if this QP is also a promisc QP, it shouldn't be removed only if + at least one none promisc QP is also attached to this MCG + */ if (prot == MLX4_PROT_ETH && - check_duplicate_entry(dev, port, steer, index, qp->qpn)) - goto out; + check_duplicate_entry(dev, port, steer, index, qp->qpn) && + !promisc_steering_entry(dev, port, steer, index, qp->qpn, NULL)) + goto out; members_count = be32_to_cpu(mgm->members_count) & 0xffffff; for (i = 0; i < members_count; ++i) @@ -1099,7 +1201,7 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], index, amgm_index, dev->caps.num_mgms); else mlx4_bitmap_free(&priv->mcg_table.bitmap, - amgm_index - dev->caps.num_mgms); + amgm_index - dev->caps.num_mgms, MLX4_USE_RR); } } else { /* Remove entry from AMGM */ @@ -1119,7 +1221,7 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], prev, index, dev->caps.num_mgms); else mlx4_bitmap_free(&priv->mcg_table.bitmap, - index - dev->caps.num_mgms); + index - dev->caps.num_mgms, MLX4_USE_RR); } out: @@ -1148,7 +1250,7 @@ static int mlx4_QP_ATTACH(struct mlx4_dev *dev, struct mlx4_qp *qp, qpn = qp->qpn; qpn |= (prot << 28); if (attach && block_loopback) - qpn |= (1U << 31); + qpn |= (1 << 31); err = mlx4_cmd(dev, mailbox->dma, qpn, attach, MLX4_CMD_QP_ATTACH, MLX4_CMD_TIME_CLASS_A, @@ -1158,28 +1260,11 @@ static int mlx4_QP_ATTACH(struct mlx4_dev *dev, struct mlx4_qp *qp, return err; } -int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], - u8 port, int block_mcast_loopback, - enum mlx4_protocol prot, u64 *reg_id) +int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, + u8 gid[16], u8 port, + int block_mcast_loopback, + enum mlx4_protocol prot, u64 *reg_id) { - - switch (dev->caps.steering_mode) { - case MLX4_STEERING_MODE_A0: - if (prot == MLX4_PROT_ETH) - return 0; - - case MLX4_STEERING_MODE_B0: - if (prot == MLX4_PROT_ETH) - gid[7] |= (MLX4_MC_STEER << 1); - - if (mlx4_is_mfunc(dev)) - return mlx4_QP_ATTACH(dev, qp, gid, 1, - block_mcast_loopback, prot); - return mlx4_qp_attach_common(dev, qp, gid, - block_mcast_loopback, prot, - MLX4_MC_STEER); - - case MLX4_STEERING_MODE_DEVICE_MANAGED: { struct mlx4_spec_list spec = { {NULL} }; __be64 mac_mask = cpu_to_be64(MLX4_MAC_MASK << 16); @@ -1213,8 +1298,35 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], list_add_tail(&spec.list, &rule.list); return mlx4_flow_attach(dev, &rule, reg_id); - } +} +int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], + u8 port, int block_mcast_loopback, + enum mlx4_protocol prot, u64 *reg_id) +{ + enum mlx4_steer_type steer; + steer = (is_valid_ether_addr(&gid[10])) ? MLX4_UC_STEER : MLX4_MC_STEER; + + switch (dev->caps.steering_mode) { + case MLX4_STEERING_MODE_A0: + if (prot == MLX4_PROT_ETH) + return 0; + + case MLX4_STEERING_MODE_B0: + if (prot == MLX4_PROT_ETH) + gid[7] |= (steer << 1); + + if (mlx4_is_mfunc(dev)) + return mlx4_QP_ATTACH(dev, qp, gid, 1, + block_mcast_loopback, prot); + return mlx4_qp_attach_common(dev, qp, gid, + block_mcast_loopback, prot, + MLX4_MC_STEER); + + case MLX4_STEERING_MODE_DEVICE_MANAGED: + return mlx4_trans_to_dmfs_attach(dev, qp, gid, port, + block_mcast_loopback, + prot, reg_id); default: return -EINVAL; } @@ -1224,6 +1336,9 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_attach); int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], enum mlx4_protocol prot, u64 reg_id) { + enum mlx4_steer_type steer; + steer = (is_valid_ether_addr(&gid[10])) ? MLX4_UC_STEER : MLX4_MC_STEER; + switch (dev->caps.steering_mode) { case MLX4_STEERING_MODE_A0: if (prot == MLX4_PROT_ETH) @@ -1231,7 +1346,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], case MLX4_STEERING_MODE_B0: if (prot == MLX4_PROT_ETH) - gid[7] |= (MLX4_MC_STEER << 1); + gid[7] |= (steer << 1); if (mlx4_is_mfunc(dev)) return mlx4_QP_ATTACH(dev, qp, gid, 0, 0, prot); @@ -1345,8 +1460,8 @@ int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave, u8 port = vhcr->in_param >> 62; enum mlx4_steer_type steer = vhcr->in_modifier; - /* Promiscuous unicast is not allowed in mfunc */ - if (mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER) + /* Promiscuous unicast is not allowed in mfunc for VFs */ + if ((slave != dev->caps.function) && (steer == MLX4_UC_STEER)) return 0; if (vhcr->op_modifier) diff --git a/sys/ofed/drivers/net/mlx4/mlx4.h b/sys/ofed/drivers/net/mlx4/mlx4.h index b342d9aee395..624a61ca2ceb 100644 --- a/sys/ofed/drivers/net/mlx4/mlx4.h +++ b/sys/ofed/drivers/net/mlx4/mlx4.h @@ -2,7 +2,7 @@ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2004 Voltaire, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -43,7 +43,7 @@ #include #include #include - +#include #include #include #include @@ -51,8 +51,12 @@ #define DRV_NAME "mlx4_core" #define PFX DRV_NAME ": " -#define DRV_VERSION "1.1" -#define DRV_RELDATE "Dec, 2011" +#define DRV_VERSION "2.1" +#define DRV_RELDATE __DATE__ + +#define DRV_STACK_NAME "Linux-MLNX_OFED" +#define DRV_STACK_VERSION "2.1" +#define DRV_NAME_FOR_FW DRV_STACK_NAME","DRV_STACK_VERSION #define MLX4_FS_UDP_UC_EN (1 << 1) #define MLX4_FS_TCP_UC_EN (1 << 2) @@ -108,10 +112,10 @@ enum { MLX4_NUM_CMPTS = MLX4_CMPT_NUM_TYPE << MLX4_CMPT_SHIFT }; -enum mlx4_mr_state { - MLX4_MR_DISABLED = 0, - MLX4_MR_EN_HW, - MLX4_MR_EN_SW +enum mlx4_mpt_state { + MLX4_MPT_DISABLED = 0, + MLX4_MPT_EN_HW, + MLX4_MPT_EN_SW }; #define MLX4_COMM_TIME 10000 @@ -139,9 +143,10 @@ enum mlx4_resource { RES_MTT, RES_MAC, RES_VLAN, - RES_EQ, + RES_NPORT_ID, RES_COUNTER, RES_FS_RULE, + RES_EQ, MLX4_NUM_OF_RESOURCE_TYPE }; @@ -180,13 +185,14 @@ struct mlx4_vhcr { struct mlx4_vhcr_cmd { __be64 in_param; __be32 in_modifier; + u32 reserved1; __be64 out_param; __be16 token; u16 reserved; u8 status; u8 flags; __be16 opcode; -}; +} __packed; struct mlx4_cmd_info { u16 opcode; @@ -194,6 +200,7 @@ struct mlx4_cmd_info { bool has_outbox; bool out_is_imm; bool encode_slave_id; + bool skip_err_print; int (*verify)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox); int (*wrapper)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, @@ -202,6 +209,10 @@ struct mlx4_cmd_info { struct mlx4_cmd_info *cmd); }; +enum { + MLX4_DEBUG_MASK_CMD_TIME = 0x100, +}; + #ifdef CONFIG_MLX4_DEBUG extern int mlx4_debug_level; #else /* CONFIG_MLX4_DEBUG */ @@ -260,6 +271,22 @@ struct mlx4_icm_table { struct mlx4_icm **icm; }; +#define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28) +#define MLX4_MPT_FLAG_FREE (0x3UL << 28) +#define MLX4_MPT_FLAG_MIO (1 << 17) +#define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15) +#define MLX4_MPT_FLAG_PHYSICAL (1 << 9) +#define MLX4_MPT_FLAG_REGION (1 << 8) + +#define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27) +#define MLX4_MPT_PD_FLAG_RAE (1 << 28) +#define MLX4_MPT_PD_FLAG_EN_INV (3 << 24) + +#define MLX4_MPT_QP_FLAG_BOUND_QP (1 << 7) + +#define MLX4_MPT_STATUS_SW 0xF0 +#define MLX4_MPT_STATUS_HW 0x00 + /* * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits. */ @@ -353,7 +380,6 @@ struct mlx4_eq { u16 irq; u16 have_irq; int nent; - int load; struct mlx4_buf_list *page_list; struct mlx4_mtt mtt; }; @@ -376,7 +402,7 @@ struct mlx4_profile { int num_cq; int num_mcg; int num_mpt; - unsigned num_mtt; + unsigned num_mtt_segs; }; struct mlx4_fw { @@ -434,6 +460,7 @@ struct mlx4_slave_state { u8 last_cmd; u8 init_port_mask; bool active; + bool old_vlan_api; u8 function; dma_addr_t vhcr_dma; u16 mtu[MLX4_MAX_PORTS + 1]; @@ -455,12 +482,14 @@ struct mlx4_slave_state { #define MLX4_VGT 4095 #define NO_INDX (-1) + struct mlx4_vport_state { u64 mac; u16 default_vlan; u8 default_qos; u32 tx_rate; bool spoofchk; + u32 link_state; }; struct mlx4_vf_admin_state { @@ -531,6 +560,7 @@ struct mlx4_mfunc_master_ctx { struct mlx4_resource_tracker res_tracker; struct workqueue_struct *comm_wq; struct work_struct comm_work; + struct work_struct arm_comm_work; struct work_struct slave_event_work; struct work_struct slave_flr_event_work; spinlock_t slave_state_lock; @@ -576,6 +606,24 @@ struct mlx4_cmd { u8 comm_toggle; }; +enum { + MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1 << 0, + MLX4_VF_IMMED_VLAN_FLAG_QOS = 1 << 1, +}; +struct mlx4_vf_immed_vlan_work { + struct work_struct work; + struct mlx4_priv *priv; + int flags; + int slave; + int vlan_ix; + int orig_vlan_ix; + u8 port; + u8 qos; + u16 vlan_id; + u16 orig_vlan_id; +}; + + struct mlx4_uar_table { struct mlx4_bitmap bitmap; }; @@ -592,6 +640,7 @@ struct mlx4_mr_table { struct mlx4_cq_table { struct mlx4_bitmap bitmap; spinlock_t lock; + rwlock_t cq_table_lock; struct radix_tree_root tree; struct mlx4_icm_table table; struct mlx4_icm_table cmpt_table; @@ -724,8 +773,6 @@ struct mlx4_sense { u8 do_sense_port[MLX4_MAX_PORTS + 1]; u8 sense_allowed[MLX4_MAX_PORTS + 1]; struct delayed_work sense_poll; - struct workqueue_struct *sense_wq; - u32 resched; }; struct mlx4_msix_ctl { @@ -738,85 +785,6 @@ struct mlx4_steer { struct list_head steer_entries[MLX4_NUM_STEERS]; }; -struct mlx4_net_trans_rule_hw_ctrl { - __be32 ctrl; - u8 rsvd1; - u8 funcid; - u8 vep; - u8 port; - __be32 qpn; - __be32 rsvd2; -}; - -struct mlx4_net_trans_rule_hw_ib { - u8 size; - u8 rsvd1; - __be16 id; - u32 rsvd2; - __be32 r_u_qpn; - __be32 qpn_mask; - u8 dst_gid[16]; - u8 dst_gid_msk[16]; -} __packed; - -struct mlx4_net_trans_rule_hw_eth { - u8 size; - u8 rsvd; - __be16 id; - u8 rsvd1[6]; - u8 dst_mac[6]; - u16 rsvd2; - u8 dst_mac_msk[6]; - u16 rsvd3; - u8 src_mac[6]; - u16 rsvd4; - u8 src_mac_msk[6]; - u8 rsvd5; - u8 ether_type_enable; - __be16 ether_type; - __be16 vlan_id_msk; - __be16 vlan_id; -} __packed; - -struct mlx4_net_trans_rule_hw_tcp_udp { - u8 size; - u8 rsvd; - __be16 id; - __be16 rsvd1[3]; - __be16 dst_port; - __be16 rsvd2; - __be16 dst_port_msk; - __be16 rsvd3; - __be16 src_port; - __be16 rsvd4; - __be16 src_port_msk; -} __packed; - -struct mlx4_net_trans_rule_hw_ipv4 { - u8 size; - u8 rsvd; - __be16 id; - __be32 rsvd1; - __be32 dst_ip; - __be32 dst_ip_msk; - __be32 src_ip; - __be32 src_ip_msk; -} __packed; - -struct _rule_hw { - union { - struct { - u8 size; - u8 rsvd; - __be16 id; - }; - struct mlx4_net_trans_rule_hw_eth eth; - struct mlx4_net_trans_rule_hw_ib ib; - struct mlx4_net_trans_rule_hw_ipv4 ipv4; - struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp; - }; -}; - enum { MLX4_PCI_DEV_IS_VF = 1 << 0, MLX4_PCI_DEV_FORCE_SENSE_PORT = 1 << 1, @@ -826,6 +794,23 @@ struct mlx4_roce_gid_entry { u8 raw[16]; }; +struct counter_index { + struct list_head list; + u32 index; +}; + +struct mlx4_counters { + struct mlx4_bitmap bitmap; + struct list_head global_port_list[MLX4_MAX_PORTS]; + struct list_head vf_list[MLX4_MAX_NUM_VF][MLX4_MAX_PORTS]; + struct mutex mutex; +}; + +enum { + MLX4_NO_RR = 0, + MLX4_USE_RR = 1, +}; + struct mlx4_priv { struct mlx4_dev dev; @@ -851,7 +836,7 @@ struct mlx4_priv { struct mlx4_srq_table srq_table; struct mlx4_qp_table qp_table; struct mlx4_mcg_table mcg_table; - struct mlx4_bitmap counters_bitmap; + struct mlx4_counters counters_table; struct mlx4_catas_err catas_err; @@ -887,10 +872,11 @@ static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev) extern struct workqueue_struct *mlx4_wq; u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap); -void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj); +void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj, int use_rr); u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align, u32 skip_mask); -void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt); +void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt, + int use_rr); u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap); int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, u32 reserved_bot, u32 resetrved_top); @@ -926,10 +912,10 @@ int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn); void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn); int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn); void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn); -int __mlx4_mr_reserve(struct mlx4_dev *dev); -void __mlx4_mr_release(struct mlx4_dev *dev, u32 index); -int __mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index); -void __mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index); +int __mlx4_mpt_reserve(struct mlx4_dev *dev); +void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index); +int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index); +void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index); u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order); void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order); @@ -969,14 +955,20 @@ int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_cmd_mailbox *outbox, struct mlx4_cmd_info *cmd); int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, - int *base, u8 bf_qp); + int *base, u8 flags); void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac); void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac); int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, int start_index, int npages, u64 *page_list); -int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx); -void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx); +int __mlx4_counter_alloc(struct mlx4_dev *dev, int slave, int port, u32 *idx); +void __mlx4_counter_free(struct mlx4_dev *dev, int slave, int port, u32 idx); + +int __mlx4_slave_counters_free(struct mlx4_dev *dev, int slave); +int __mlx4_clear_if_stat(struct mlx4_dev *dev, + u8 counter_index); +u8 mlx4_get_default_counter_index(struct mlx4_dev *dev, int slave, int port); + int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn); void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn); @@ -997,6 +989,7 @@ u64 mlx4_make_profile(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap, struct mlx4_init_hca_param *init_hca); void mlx4_master_comm_channel(struct work_struct *work); +void mlx4_master_arm_comm_channel(struct work_struct *work); void mlx4_gen_slave_eqe(struct work_struct *work); void mlx4_master_handle_slave_flr(struct work_struct *work); @@ -1164,8 +1157,7 @@ void mlx4_do_sense_ports(struct mlx4_dev *dev, enum mlx4_port_type *defaults); void mlx4_start_sense(struct mlx4_dev *dev); void mlx4_stop_sense(struct mlx4_dev *dev); -void mlx4_sense_cleanup(struct mlx4_dev *dev); -int mlx4_sense_init(struct mlx4_dev *dev); +void mlx4_sense_init(struct mlx4_dev *dev); int mlx4_check_port_params(struct mlx4_dev *dev, enum mlx4_port_type *port_type); int mlx4_change_port_types(struct mlx4_dev *dev, @@ -1238,6 +1230,10 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], int block_mcast_loopback, enum mlx4_protocol prot, enum mlx4_steer_type steer); +int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, + u8 gid[16], u8 port, + int block_mcast_loopback, + enum mlx4_protocol prot, u64 *reg_id); int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, @@ -1250,8 +1246,6 @@ int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_cmd_info *cmd); int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function, int port, void *buf); -int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod, - struct mlx4_cmd_mailbox *outbox); int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, @@ -1277,6 +1271,11 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_cmd_mailbox *inbox, struct mlx4_cmd_mailbox *outbox, struct mlx4_cmd_info *cmd); +int mlx4_MOD_STAT_CFG_wrapper(struct mlx4_dev *dev, int slave, + struct mlx4_vhcr *vhcr, + struct mlx4_cmd_mailbox *inbox, + struct mlx4_cmd_mailbox *outbox, + struct mlx4_cmd_info *cmd); int mlx4_get_mgm_entry_size(struct mlx4_dev *dev); int mlx4_get_qp_per_mgm(struct mlx4_dev *dev); @@ -1315,5 +1314,6 @@ void mlx4_init_quotas(struct mlx4_dev *dev); int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave); int mlx4_get_base_gid_ix(struct mlx4_dev *dev, int slave); +void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work); #endif /* MLX4_H */ diff --git a/sys/ofed/drivers/net/mlx4/mlx4_en.h b/sys/ofed/drivers/net/mlx4/mlx4_en.h index 0dc5fe6b3734..1cb19e3f77e8 100644 --- a/sys/ofed/drivers/net/mlx4/mlx4_en.h +++ b/sys/ofed/drivers/net/mlx4/mlx4_en.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -34,13 +34,17 @@ #ifndef _MLX4_EN_H_ #define _MLX4_EN_H_ -#include - -#include +#include #include #include #include +#include #include +#include +#include +#ifdef CONFIG_MLX4_EN_DCB +#include +#endif #include #include @@ -49,56 +53,17 @@ #include #include -#include #include #include "en_port.h" +#include "mlx4_stats.h" #define DRV_NAME "mlx4_en" -#define DRV_VERSION "1.5.2" -#define DRV_RELDATE "July 2010" - -/* XXX */ -#define NETIF_MSG_LINK 0x1 -#define NETIF_MSG_IFDOWN 0x2 -#define NETIF_MSG_HW 0x4 -#define NETIF_MSG_DRV 0x8 -#define NETIF_MSG_INTR 0x10 -#define NETIF_MSG_RX_ERR 0x20 +#define DRV_VERSION "2.1" +#define DRV_RELDATE __DATE__ #define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN) -#define en_print(level, priv, format, arg...) \ - { \ - if ((priv)->registered) \ - printk(level "%s: %s: " format, DRV_NAME, \ - (priv->dev)->if_xname, ## arg); \ - else \ - printk(level "%s: %s: Port %d: " format, \ - DRV_NAME, dev_name(&priv->mdev->pdev->dev), \ - (priv)->port, ## arg); \ - } - -#define en_dbg(mlevel, priv, format, arg...) \ - if (NETIF_MSG_##mlevel & priv->msg_enable) \ - en_print(KERN_DEBUG, priv, format, ## arg) -#define en_warn(priv, format, arg...) \ - en_print(KERN_WARNING, priv, format, ## arg) -#define en_err(priv, format, arg...) \ - en_print(KERN_ERR, priv, format, ## arg) -#define en_info(priv, format, arg...) \ - en_print(KERN_INFO, priv, format, ## arg) - -#define mlx4_err(mdev, format, arg...) \ - printk(KERN_ERR "%s %s: " format , DRV_NAME ,\ - dev_name(&mdev->pdev->dev) , ## arg) -#define mlx4_info(mdev, format, arg...) \ - printk(KERN_INFO "%s %s: " format , DRV_NAME ,\ - dev_name(&mdev->pdev->dev) , ## arg) -#define mlx4_warn(mdev, format, arg...) \ - printk(KERN_WARNING "%s %s: " format , DRV_NAME ,\ - dev_name(&mdev->pdev->dev) , ## arg) - /* * Device constants */ @@ -106,8 +71,9 @@ #define MLX4_EN_PAGE_SHIFT 12 #define MLX4_EN_PAGE_SIZE (1 << MLX4_EN_PAGE_SHIFT) -#define MAX_TX_RINGS (MLX4_EN_NUM_HASH_RINGS + 1 + MLX4_EN_NUM_PPP_RINGS) -#define MAX_RX_RINGS 16 +#define DEF_RX_RINGS 16 +#define MAX_RX_RINGS 128 +#define MIN_RX_RINGS 4 #define TXBB_SIZE 64 #define HEADROOM (2048 / TXBB_SIZE + 1) #define STAMP_STRIDE 64 @@ -115,6 +81,19 @@ #define STAMP_SHIFT 31 #define STAMP_VAL 0x7fffffff #define STATS_DELAY (HZ / 4) +#define SERVICE_TASK_DELAY (HZ / 4) +#define MAX_NUM_OF_FS_RULES 256 + +#define MLX4_EN_FILTER_HASH_SHIFT 4 +#define MLX4_EN_FILTER_EXPIRY_QUOTA 60 + +#ifdef CONFIG_NET_RX_BUSY_POLL +#define LL_EXTENDED_STATS +#endif + +/* vlan valid range */ +#define VLAN_MIN_VALUE 1 +#define VLAN_MAX_VALUE 4094 /* Typical TSO descriptor with 16 gather entries is 352 bytes... */ #define MAX_DESC_SIZE 512 @@ -126,8 +105,13 @@ #define MLX4_EN_WATCHDOG_TIMEOUT (15 * HZ) -#define MLX4_EN_MAX_LRO_DESCRIPTORS 32 -#define MLX4_EN_NUM_IPFRAG_SESSIONS 16 +#define MLX4_EN_ALLOC_SIZE PAGE_ALIGN(PAGE_SIZE) +#define MLX4_EN_ALLOC_ORDER get_order(MLX4_EN_ALLOC_SIZE) + +enum mlx4_en_alloc_type { + MLX4_EN_ALLOC_NEW = 0, + MLX4_EN_ALLOC_REPLACEMENT = 1, +}; /* Receive fragment sizes; we use at most 3 fragments (for 9600 byte MTU * and 4K allocations) */ @@ -149,29 +133,38 @@ enum { #error "Unknown PAGE_SIZE" #endif +/* Maximum ring sizes */ +#define MLX4_EN_DEF_TX_QUEUE_SIZE 4096 + +/* Minimum packet number till arming the CQ */ +#define MLX4_EN_MIN_RX_ARM 2048 +#define MLX4_EN_MIN_TX_ARM 2048 + /* Maximum ring sizes */ #define MLX4_EN_MAX_TX_SIZE 8192 #define MLX4_EN_MAX_RX_SIZE 8192 -#define MLX4_EN_MIN_RX_SIZE (128) +/* Minimum ring sizes */ +#define MLX4_EN_MIN_RX_SIZE (4096 / TXBB_SIZE) #define MLX4_EN_MIN_TX_SIZE (4096 / TXBB_SIZE) #define MLX4_EN_SMALL_PKT_SIZE 64 -#define MLX4_EN_TX_HASH_SIZE 256 -#define MLX4_EN_TX_HASH_MASK (MLX4_EN_TX_HASH_SIZE - 1) -#define MLX4_EN_NUM_HASH_RINGS 4 -#define MLX4_EN_NUM_PPP_RINGS 8 -#define MLX4_EN_DEF_TX_RING_SIZE 512 -#define MLX4_EN_DEF_TX_QUEUE_SIZE 4096 + +#define MLX4_EN_MAX_TX_RING_P_UP 32 +#define MLX4_EN_NUM_UP 1 + +#define MAX_TX_RINGS (MLX4_EN_MAX_TX_RING_P_UP * \ + (MLX4_EN_NUM_UP + 1)) + +#define MLX4_EN_DEF_TX_RING_SIZE 1024 #define MLX4_EN_DEF_RX_RING_SIZE 1024 -#define MLX4_EN_MAX_RX_POLL 1024 /* Target number of bytes to coalesce with interrupt moderation */ #define MLX4_EN_RX_COAL_TARGET 0x20000 #define MLX4_EN_RX_COAL_TIME 0x10 -#define MLX4_EN_TX_COAL_PKTS 5 -#define MLX4_EN_TX_COAL_TIME 0x80 +#define MLX4_EN_TX_COAL_PKTS 64 +#define MLX4_EN_TX_COAL_TIME 64 #define MLX4_EN_RX_RATE_LOW 400000 #define MLX4_EN_RX_COAL_TIME_LOW 0 @@ -187,14 +180,13 @@ enum { #define MLX4_EN_DEF_RX_PAUSE 1 #define MLX4_EN_DEF_TX_PAUSE 1 -/* Interval between sucessive polls in the Tx routine when polling is used +/* Interval between successive polls in the Tx routine when polling is used instead of interrupts (in per-core Tx rings) - should be power of 2 */ #define MLX4_EN_TX_POLL_MODER 16 #define MLX4_EN_TX_POLL_TIMEOUT (HZ / 4) -#define ETH_LLC_SNAP_SIZE 8 - -#define SMALL_PACKET_SIZE (MHLEN) +#define MLX4_EN_64_ALIGN (64 - NET_SKB_PAD) +#define SMALL_PACKET_SIZE (256 - NET_IP_ALIGN) #define HEADER_COPY_SIZE (128) #define MLX4_LOOPBACK_TEST_PAYLOAD (HEADER_COPY_SIZE - ETHER_HDR_LEN) @@ -208,7 +200,6 @@ enum { /* Number of samples to 'average' */ #define AVG_SIZE 128 #define AVG_FACTOR 1024 -#define NUM_PERF_STATS NUM_PERF_COUNTERS #define INC_PERF_COUNTER(cnt) (++(cnt)) #define ADD_PERF_COUNTER(cnt, add) ((cnt) += (add)) @@ -219,7 +210,6 @@ enum { #else -#define NUM_PERF_STATS 0 #define INC_PERF_COUNTER(cnt) do {} while (0) #define ADD_PERF_COUNTER(cnt, add) do {} while (0) #define AVG_PERF_COUNTER(cnt, sample) do {} while (0) @@ -244,13 +234,17 @@ enum cq_type { #define XNOR(x, y) (!(x) == !(y)) #define ILLEGAL_MAC(addr) (addr == 0xffffffffffffULL || addr == 0x0) - struct mlx4_en_tx_info { - struct mbuf *mb; - u32 nr_txbb; - u8 nr_segs; - u8 data_offset; - u8 inl; + struct mbuf *mb; + u32 nr_txbb; + u32 nr_bytes; + u8 linear; + u8 nr_segs; + u8 data_offset; + u8 inl; +#if 0 + u8 ts_requested; +#endif }; @@ -271,8 +265,14 @@ struct mlx4_en_tx_desc { #define MLX4_EN_USE_SRQ 0x01000000 +#define MLX4_EN_TX_BUDGET 64*4 //Compensate for no NAPI in freeBSD - might need some fine tunning in the future. +#define MLX4_EN_RX_BUDGET 64 + +#define MLX4_EN_CX3_LOW_ID 0x1000 +#define MLX4_EN_CX3_HIGH_ID 0x1005 + struct mlx4_en_tx_ring { - spinlock_t tx_lock; + spinlock_t tx_lock; struct mlx4_hwq_resources wqres; u32 size ; /* number of TXBBs */ u32 size_mask; @@ -285,9 +285,11 @@ struct mlx4_en_tx_ring { void *buf; u16 poll_cnt; int blocked; - struct buf_ring *br; struct mlx4_en_tx_info *tx_info; u8 *bounce_buf; + u8 queue_index; + cpuset_t affinity_mask; + struct buf_ring *br; u32 last_nr_txbb; struct mlx4_qp qp; struct mlx4_qp_context context; @@ -296,29 +298,30 @@ struct mlx4_en_tx_ring { struct mlx4_srq dummy; unsigned long bytes; unsigned long packets; - unsigned long errors; - spinlock_t comp_lock; + unsigned long tx_csum; + unsigned long queue_stopped; + unsigned long wake_queue; struct mlx4_bf bf; bool bf_enabled; + struct netdev_queue *tx_queue; + int hwtstamp_tx_type; + spinlock_t comp_lock; + int full_size; + int inline_thold; u64 watchdog_time; }; -struct mlx4_en_ipfrag { - struct mbuf *fragments; - struct mbuf *last; - __be32 saddr; - __be32 daddr; - __be16 id; - u8 protocol; - int total_len; - u16 offset; -}; - struct mlx4_en_rx_desc { /* actual number of entries depends on rx ring stride */ struct mlx4_wqe_data_seg data[0]; }; +struct mlx4_en_rx_buf { + dma_addr_t dma; + struct page *page; + unsigned int page_offset; +}; + struct mlx4_en_rx_ring { struct mlx4_hwq_resources wqres; u32 size ; /* number of Rx descs*/ @@ -330,38 +333,66 @@ struct mlx4_en_rx_ring { u32 prod; u32 cons; u32 buf_size; + u8 fcs_del; + u16 rx_alloc_order; + u32 rx_alloc_size; + u32 rx_buf_size; + u32 rx_mb_size; + int qpn; void *buf; void *rx_info; + unsigned long errors; unsigned long bytes; unsigned long packets; - unsigned long errors; +#ifdef LL_EXTENDED_STATS + unsigned long yields; + unsigned long misses; + unsigned long cleaned; +#endif + unsigned long csum_ok; + unsigned long csum_none; + int hwtstamp_rx_filter; + int numa_node; struct lro_ctrl lro; - struct mlx4_en_ipfrag ipfrag[MLX4_EN_NUM_IPFRAG_SESSIONS]; }; - static inline int mlx4_en_can_lro(__be16 status) { - return (status & cpu_to_be16(MLX4_CQE_STATUS_IPV4 | - MLX4_CQE_STATUS_IPV4F | - MLX4_CQE_STATUS_IPV6 | - MLX4_CQE_STATUS_IPV4OPT | - MLX4_CQE_STATUS_TCP | - MLX4_CQE_STATUS_UDP | - MLX4_CQE_STATUS_IPOK)) == - cpu_to_be16(MLX4_CQE_STATUS_IPV4 | - MLX4_CQE_STATUS_IPOK | - MLX4_CQE_STATUS_TCP); + static __be16 status_all; + static __be16 status_ipv4_ipok_tcp; + static __be16 status_ipv6_ipok_tcp; + + status_all = cpu_to_be16( + MLX4_CQE_STATUS_IPV4 | + MLX4_CQE_STATUS_IPV4F | + MLX4_CQE_STATUS_IPV6 | + MLX4_CQE_STATUS_IPV4OPT | + MLX4_CQE_STATUS_TCP | + MLX4_CQE_STATUS_UDP | + MLX4_CQE_STATUS_IPOK); + status_ipv4_ipok_tcp = cpu_to_be16( + MLX4_CQE_STATUS_IPV4 | + MLX4_CQE_STATUS_IPOK | + MLX4_CQE_STATUS_TCP); + status_ipv6_ipok_tcp = cpu_to_be16( + MLX4_CQE_STATUS_IPV6 | + MLX4_CQE_STATUS_IPOK | + MLX4_CQE_STATUS_TCP); + + status &= status_all; + return (status == status_ipv4_ipok_tcp || + status == status_ipv6_ipok_tcp); } + struct mlx4_en_cq { struct mlx4_cq mcq; struct mlx4_hwq_resources wqres; int ring; spinlock_t lock; struct net_device *dev; - /* Per-core Tx cq processing support */ - struct timer_list timer; + /* Per-core Tx cq processing support */ + struct timer_list timer; int size; int buf_size; unsigned vector; @@ -373,6 +404,20 @@ struct mlx4_en_cq { struct taskqueue *tq; #define MLX4_EN_OPCODE_ERROR 0x1e u32 tot_rx; + u32 tot_tx; + +#ifdef CONFIG_NET_RX_BUSY_POLL + unsigned int state; +#define MLX4_EN_CQ_STATEIDLE 0 +#define MLX4_EN_CQ_STATENAPI 1 /* NAPI owns this CQ */ +#define MLX4_EN_CQ_STATEPOLL 2 /* poll owns this CQ */ +#define MLX4_CQ_LOCKED (MLX4_EN_CQ_STATENAPI | MLX4_EN_CQ_STATEPOLL) +#define MLX4_EN_CQ_STATENAPI_YIELD 4 /* NAPI yielded this CQ */ +#define MLX4_EN_CQ_STATEPOLL_YIELD 8 /* poll yielded this CQ */ +#define CQ_YIELD (MLX4_EN_CQ_STATENAPI_YIELD | MLX4_EN_CQ_STATEPOLL_YIELD) +#define CQ_USER_PEND (MLX4_EN_CQ_STATEPOLL | MLX4_EN_CQ_STATEPOLL_YIELD) + spinlock_t poll_lock; /* protects from LLS/napi conflicts */ +#endif /* CONFIG_NET_RX_BUSY_POLL */ }; struct mlx4_en_port_profile { @@ -382,41 +427,42 @@ struct mlx4_en_port_profile { u32 tx_ring_size; u32 rx_ring_size; u8 rx_pause; + u8 rx_ppp; u8 tx_pause; - u32 rx_ppp; - u32 tx_ppp; + u8 tx_ppp; + int rss_rings; }; struct mlx4_en_profile { int rss_xor; - int num_lro; - int ip_reasm; - int tcp_rss; int udp_rss; u8 rss_mask; u32 active_ports; u32 small_pkt_int; u8 no_reset; + u8 num_tx_rings_p_up; struct mlx4_en_port_profile prof[MLX4_MAX_PORTS + 1]; }; struct mlx4_en_dev { - struct mlx4_dev *dev; + struct mlx4_dev *dev; struct pci_dev *pdev; struct mutex state_lock; - struct net_device *pndev[MLX4_MAX_PORTS + 1]; - u32 port_cnt; + struct net_device *pndev[MLX4_MAX_PORTS + 1]; + u32 port_cnt; bool device_up; - struct mlx4_en_profile profile; + struct mlx4_en_profile profile; u32 LSO_support; struct workqueue_struct *workqueue; - struct device *dma_device; - void __iomem *uar_map; - struct mlx4_uar priv_uar; + struct device *dma_device; + void __iomem *uar_map; + struct mlx4_uar priv_uar; struct mlx4_mr mr; - u32 priv_pdn; - spinlock_t uar_lock; + u32 priv_pdn; + spinlock_t uar_lock; u8 mac_removed[MLX4_MAX_PORTS + 1]; + unsigned long last_overflow_check; + unsigned long overflow_period; }; @@ -428,71 +474,76 @@ struct mlx4_en_rss_map { enum mlx4_qp_state indir_state; }; -struct mlx4_en_rss_context { - __be32 base_qpn; - __be32 default_qpn; - u16 reserved; - u8 hash_fn; - u8 flags; - __be32 rss_key[10]; - __be32 base_qpn_udp; -}; - struct mlx4_en_port_state { int link_state; int link_speed; int transciver; + int autoneg; }; -struct mlx4_en_pkt_stats { - unsigned long broadcast; - unsigned long rx_prio[8]; - unsigned long tx_prio[8]; -#define NUM_PKT_STATS 17 +enum mlx4_en_mclist_act { + MCLIST_NONE, + MCLIST_REM, + MCLIST_ADD, }; -struct mlx4_en_port_stats { - unsigned long tso_packets; - unsigned long queue_stopped; - unsigned long wake_queue; - unsigned long tx_timeout; - unsigned long rx_alloc_failed; - unsigned long rx_chksum_good; - unsigned long rx_chksum_none; - unsigned long tx_chksum_offload; +struct mlx4_en_mc_list { + struct list_head list; + enum mlx4_en_mclist_act action; + u8 addr[ETH_ALEN]; + u64 reg_id; }; -struct mlx4_en_perf_stats { - u32 tx_poll; - u64 tx_pktsz_avg; - u32 inflight_avg; - u32 tx_coal_avg; - u32 rx_coal_avg; +#ifdef CONFIG_MLX4_EN_DCB +/* Minimal TC BW - setting to 0 will block traffic */ +#define MLX4_EN_BW_MIN 1 +#define MLX4_EN_BW_MAX 100 /* Utilize 100% of the line */ + +#define MLX4_EN_TC_ETS 7 + +#endif + + +enum { + MLX4_EN_FLAG_PROMISC = (1 << 0), + MLX4_EN_FLAG_MC_PROMISC = (1 << 1), + /* whether we need to enable hardware loopback by putting dmac + * in Tx WQE + */ + MLX4_EN_FLAG_ENABLE_HW_LOOPBACK = (1 << 2), + /* whether we need to drop packets that hardware loopback-ed */ + MLX4_EN_FLAG_RX_FILTER_NEEDED = (1 << 3), + MLX4_EN_FLAG_FORCE_PROMISC = (1 << 4), +#ifdef CONFIG_MLX4_EN_DCB + MLX4_EN_FLAG_DCB_ENABLED = (1 << 5) +#endif +}; + +#define MLX4_EN_MAC_HASH_SIZE (1 << BITS_PER_BYTE) +#define MLX4_EN_MAC_HASH_IDX 5 + +struct en_port { + struct kobject kobj; + struct mlx4_dev *dev; + u8 port_num; + u8 vport_num; }; struct mlx4_en_frag_info { - u16 frag_size; - u16 frag_prefix_size; + u16 frag_size; + u16 frag_prefix_size; }; -struct mlx4_en_tx_hash_entry { - u8 cnt; - unsigned int small_pkts; - unsigned int big_pkts; - unsigned int ring; -}; struct mlx4_en_priv { struct mlx4_en_dev *mdev; struct mlx4_en_port_profile *prof; struct net_device *dev; - bool vlgrp_modified; - u32 vlan_register[VLAN_FLTR_SIZE]; - u32 vlan_unregister[VLAN_FLTR_SIZE]; - u32 vlans[VLAN_FLTR_SIZE]; - spinlock_t vlan_lock; + unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; struct mlx4_en_port_state port_state; spinlock_t stats_lock; + /* To allow rules removal while port is going down */ + struct list_head ethtool_list; unsigned long last_moder_packets[MAX_RX_RINGS]; unsigned long last_moder_tx_packets; @@ -520,139 +571,381 @@ struct mlx4_en_priv { int port; int registered; int allocated; - int rx_csum; - u64 mac; + int stride; + unsigned char current_mac[ETH_ALEN + 2]; + u64 mac; int mac_index; unsigned max_mtu; int base_qpn; + int cqe_factor; struct mlx4_en_rss_map rss_map; - u16 tx_prio_map[8]; + __be32 ctrl_flags; u32 flags; -#define MLX4_EN_FLAG_PROMISC 0x1 + u8 num_tx_rings_p_up; u32 tx_ring_num; u32 rx_ring_num; u32 rx_mb_size; - struct mlx4_en_frag_info frag_info[MLX4_EN_MAX_RX_FRAGS]; - u16 num_frags; + struct mlx4_en_frag_info frag_info[MLX4_EN_MAX_RX_FRAGS]; + u16 rx_alloc_order; + u32 rx_alloc_size; + u32 rx_buf_size; + u16 num_frags; u16 log_rx_info; - int ip_reasm; - bool wol; - struct mlx4_en_tx_ring tx_ring[MAX_TX_RINGS]; - struct mlx4_en_rx_ring rx_ring[MAX_RX_RINGS]; - struct mlx4_en_cq tx_cq[MAX_TX_RINGS]; - struct mlx4_en_cq rx_cq[MAX_RX_RINGS]; - struct mlx4_en_tx_hash_entry tx_hash[MLX4_EN_TX_HASH_SIZE]; - struct work_struct mcast_task; - struct work_struct start_port_task; - struct work_struct stop_port_task; + struct mlx4_en_tx_ring **tx_ring; + struct mlx4_en_rx_ring *rx_ring[MAX_RX_RINGS]; + struct mlx4_en_cq **tx_cq; + struct mlx4_en_cq *rx_cq[MAX_RX_RINGS]; + struct mlx4_qp drop_qp; + struct work_struct rx_mode_task; struct work_struct watchdog_task; struct work_struct linkstate_task; struct delayed_work stats_task; + struct delayed_work service_task; struct mlx4_en_perf_stats pstats; struct mlx4_en_pkt_stats pkstats; + struct mlx4_en_pkt_stats pkstats_last; + struct mlx4_en_flow_stats flowstats[MLX4_NUM_PRIORITIES]; struct mlx4_en_port_stats port_stats; + struct mlx4_en_vport_stats vport_stats; + struct mlx4_en_vf_stats vf_stats; + DECLARE_BITMAP(stats_bitmap, NUM_ALL_STATS); + struct list_head mc_list; + struct list_head curr_list; + u64 broadcast_id; struct mlx4_en_stat_out_mbox hw_stats; - struct ifmedia media; + int vids[128]; + bool wol; + struct device *ddev; + struct dentry *dev_root; + u32 counter_index; eventhandler_tag vlan_attach; eventhandler_tag vlan_detach; struct callout watchdog_timer; + struct ifmedia media; volatile int blocked; struct sysctl_oid *sysctl; struct sysctl_ctx_list conf_ctx; struct sysctl_ctx_list stat_ctx; +#define MLX4_EN_MAC_HASH_IDX 5 + struct hlist_head mac_hash[MLX4_EN_MAC_HASH_SIZE]; + +#ifdef CONFIG_MLX4_EN_DCB + struct ieee_ets ets; + u16 maxrate[IEEE_8021QAZ_MAX_TCS]; + u8 dcbx_cap; +#endif +#ifdef CONFIG_RFS_ACCEL + spinlock_t filters_lock; + int last_filter_id; + struct list_head filters; + struct hlist_head filter_hash[1 << MLX4_EN_FILTER_HASH_SHIFT]; +#endif + struct en_port *vf_ports[MLX4_MAX_NUM_VF]; + unsigned long last_ifq_jiffies; + u64 if_counters_rx_errors; + u64 if_counters_rx_no_buffer; + }; enum mlx4_en_wol { MLX4_EN_WOL_MAGIC = (1ULL << 61), MLX4_EN_WOL_ENABLED = (1ULL << 62), - MLX4_EN_WOL_DO_MODIFY = (1ULL << 63), }; -int mlx4_en_transmit(struct net_device *dev, struct mbuf *mb); -void mlx4_en_qflush(struct net_device *dev); +struct mlx4_mac_entry { + struct hlist_node hlist; + unsigned char mac[ETH_ALEN + 2]; + u64 reg_id; +}; + +#ifdef CONFIG_NET_RX_BUSY_POLL +static inline void mlx4_en_cq_init_lock(struct mlx4_en_cq *cq) +{ + spin_lock_init(&cq->poll_lock); + cq->state = MLX4_EN_CQ_STATEIDLE; +} + +/* called from the device poll rutine to get ownership of a cq */ +static inline bool mlx4_en_cq_lock_napi(struct mlx4_en_cq *cq) +{ + int rc = true; + spin_lock(&cq->poll_lock); + if (cq->state & MLX4_CQ_LOCKED) { + WARN_ON(cq->state & MLX4_EN_CQ_STATENAPI); + cq->state |= MLX4_EN_CQ_STATENAPI_YIELD; + rc = false; + } else + /* we don't care if someone yielded */ + cq->state = MLX4_EN_CQ_STATENAPI; + spin_unlock(&cq->poll_lock); + return rc; +} + +/* returns true is someone tried to get the cq while napi had it */ +static inline bool mlx4_en_cq_unlock_napi(struct mlx4_en_cq *cq) +{ + int rc = false; + spin_lock(&cq->poll_lock); + WARN_ON(cq->state & (MLX4_EN_CQ_STATEPOLL | + MLX4_EN_CQ_STATENAPI_YIELD)); + + if (cq->state & MLX4_EN_CQ_STATEPOLL_YIELD) + rc = true; + cq->state = MLX4_EN_CQ_STATEIDLE; + spin_unlock(&cq->poll_lock); + return rc; +} + +/* called from mlx4_en_low_latency_poll() */ +static inline bool mlx4_en_cq_lock_poll(struct mlx4_en_cq *cq) +{ + int rc = true; + spin_lock_bh(&cq->poll_lock); + if ((cq->state & MLX4_CQ_LOCKED)) { + struct net_device *dev = cq->dev; + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_rx_ring *rx_ring = priv->rx_ring[cq->ring]; + + cq->state |= MLX4_EN_CQ_STATEPOLL_YIELD; + rc = false; +#ifdef LL_EXTENDED_STATS + rx_ring->yields++; +#endif + } else + /* preserve yield marks */ + cq->state |= MLX4_EN_CQ_STATEPOLL; + spin_unlock_bh(&cq->poll_lock); + return rc; +} + +/* returns true if someone tried to get the cq while it was locked */ +static inline bool mlx4_en_cq_unlock_poll(struct mlx4_en_cq *cq) +{ + int rc = false; + spin_lock_bh(&cq->poll_lock); + WARN_ON(cq->state & (MLX4_EN_CQ_STATENAPI)); + + if (cq->state & MLX4_EN_CQ_STATEPOLL_YIELD) + rc = true; + cq->state = MLX4_EN_CQ_STATEIDLE; + spin_unlock_bh(&cq->poll_lock); + return rc; +} + +/* true if a socket is polling, even if it did not get the lock */ +static inline bool mlx4_en_cq_ll_polling(struct mlx4_en_cq *cq) +{ + WARN_ON(!(cq->state & MLX4_CQ_LOCKED)); + return cq->state & CQ_USER_PEND; +} +#else +static inline void mlx4_en_cq_init_lock(struct mlx4_en_cq *cq) +{ +} + +static inline bool mlx4_en_cq_lock_napi(struct mlx4_en_cq *cq) +{ + return true; +} + +static inline bool mlx4_en_cq_unlock_napi(struct mlx4_en_cq *cq) +{ + return false; +} + +static inline bool mlx4_en_cq_lock_poll(struct mlx4_en_cq *cq) +{ + return false; +} + +static inline bool mlx4_en_cq_unlock_poll(struct mlx4_en_cq *cq) +{ + return false; +} + +static inline bool mlx4_en_cq_ll_polling(struct mlx4_en_cq *cq) +{ + return false; +} +#endif /* CONFIG_NET_RX_BUSY_POLL */ + +#define MLX4_EN_WOL_DO_MODIFY (1ULL << 63) -int mlx4_en_rx_frags(struct mlx4_en_priv *priv, struct mlx4_en_rx_ring *ring, - struct mbuf *mb, struct mlx4_cqe *cqe); -void mlx4_en_flush_frags(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring); void mlx4_en_destroy_netdev(struct net_device *dev); int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, struct mlx4_en_port_profile *prof); -int mlx4_en_do_start_port(struct net_device *dev); -void mlx4_en_do_stop_port(struct net_device *dev); +int mlx4_en_start_port(struct net_device *dev); +void mlx4_en_stop_port(struct net_device *dev); void mlx4_en_free_resources(struct mlx4_en_priv *priv); int mlx4_en_alloc_resources(struct mlx4_en_priv *priv); -int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, - int entries, int ring, enum cq_type mode); -void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq); -int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq); +int mlx4_en_pre_config(struct mlx4_en_priv *priv); +int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq, + int entries, int ring, enum cq_type mode, int node); +void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq); +int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, + int cq_idx); void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq); int mlx4_en_set_cq_moder(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq); int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq); -void mlx4_en_poll_tx_cq(unsigned long data); void mlx4_en_tx_irq(struct mlx4_cq *mcq); u16 mlx4_en_select_queue(struct net_device *dev, struct mbuf *mb); -int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring, - u32 size, u16 stride); -void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring); +int mlx4_en_transmit(struct ifnet *dev, struct mbuf *m); +int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, + struct mlx4_en_tx_ring **pring, + u32 size, u16 stride, int node, int queue_idx); +void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, + struct mlx4_en_tx_ring **pring); int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring, - int cq); + int cq, int user_prio); void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring); +void mlx4_en_qflush(struct ifnet *dev); int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring, u32 size); + struct mlx4_en_rx_ring **pring, + u32 size, int node); void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring); + struct mlx4_en_rx_ring **pring, + u32 size, u16 stride); +void mlx4_en_tx_que(void *context, int pending); +void mlx4_en_rx_que(void *context, int pending); int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv); void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv, struct mlx4_en_rx_ring *ring); int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget); -int mlx4_en_process_rx_cq_mb(struct net_device *dev, - struct mlx4_en_cq *cq, - int budget); -void mlx4_en_tx_que(void *context, int pending); -void mlx4_en_rx_que(void *context, int pending); +void mlx4_en_poll_tx_cq(unsigned long data); void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride, - int is_tx, int rss, int qpn, int cqn, - struct mlx4_qp_context *context); + int is_tx, int rss, int qpn, int cqn, int user_prio, + struct mlx4_qp_context *context); void mlx4_en_sqp_event(struct mlx4_qp *qp, enum mlx4_event event); int mlx4_en_map_buffer(struct mlx4_buf *buf); void mlx4_en_unmap_buffer(struct mlx4_buf *buf); - void mlx4_en_calc_rx_buf(struct net_device *dev); -void mlx4_en_set_prio_map(struct mlx4_en_priv *priv, u16 *prio_map, u32 ring_num); + int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv); void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv); +int mlx4_en_create_drop_qp(struct mlx4_en_priv *priv); +void mlx4_en_destroy_drop_qp(struct mlx4_en_priv *priv); int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring); void mlx4_en_rx_irq(struct mlx4_cq *mcq); -//int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode); -int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, u32 *vlans); -//int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, -// u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); -//int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, -// u8 promisc); +int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode); +int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv); int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset); int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port); +int mlx4_en_get_vport_stats(struct mlx4_en_dev *mdev, u8 port); +void mlx4_en_create_debug_files(struct mlx4_en_priv *priv); +void mlx4_en_delete_debug_files(struct mlx4_en_priv *priv); +int mlx4_en_register_debugfs(void); +void mlx4_en_unregister_debugfs(void); + +#ifdef CONFIG_MLX4_EN_DCB +extern const struct dcbnl_rtnl_ops mlx4_en_dcbnl_ops; +extern const struct dcbnl_rtnl_ops mlx4_en_dcbnl_pfc_ops; +#endif + +int mlx4_en_setup_tc(struct net_device *dev, u8 up); + +#ifdef CONFIG_RFS_ACCEL +void mlx4_en_cleanup_filters(struct mlx4_en_priv *priv, + struct mlx4_en_rx_ring *rx_ring); +#endif #define MLX4_EN_NUM_SELF_TEST 5 void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf); -u64 mlx4_en_mac_to_u64(u8 *addr); +void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev); + +/* + * Functions for time stamping + */ +#define SKBTX_HW_TSTAMP (1 << 0) +#define SKBTX_IN_PROGRESS (1 << 2) + +u64 mlx4_en_get_cqe_ts(struct mlx4_cqe *cqe); + +/* Functions for caching and restoring statistics */ +int mlx4_en_get_sset_count(struct net_device *dev, int sset); +void mlx4_en_restore_ethtool_stats(struct mlx4_en_priv *priv, + u64 *data); /* * Globals */ extern const struct ethtool_ops mlx4_en_ethtool_ops; + +/* + * Defines for link speed - needed by selftest + */ +#define MLX4_EN_LINK_SPEED_1G 1000 +#define MLX4_EN_LINK_SPEED_10G 10000 +#define MLX4_EN_LINK_SPEED_40G 40000 + +enum { + NETIF_MSG_DRV = 0x0001, + NETIF_MSG_PROBE = 0x0002, + NETIF_MSG_LINK = 0x0004, + NETIF_MSG_TIMER = 0x0008, + NETIF_MSG_IFDOWN = 0x0010, + NETIF_MSG_IFUP = 0x0020, + NETIF_MSG_RX_ERR = 0x0040, + NETIF_MSG_TX_ERR = 0x0080, + NETIF_MSG_TX_QUEUED = 0x0100, + NETIF_MSG_INTR = 0x0200, + NETIF_MSG_TX_DONE = 0x0400, + NETIF_MSG_RX_STATUS = 0x0800, + NETIF_MSG_PKTDATA = 0x1000, + NETIF_MSG_HW = 0x2000, + NETIF_MSG_WOL = 0x4000, +}; + + +/* + * printk / logging functions + */ + +#define en_print(level, priv, format, arg...) \ + { \ + if ((priv)->registered) \ + printk(level "%s: %s: " format, DRV_NAME, \ + (priv->dev)->if_xname, ## arg); \ + else \ + printk(level "%s: %s: Port %d: " format, \ + DRV_NAME, dev_name(&priv->mdev->pdev->dev), \ + (priv)->port, ## arg); \ + } + + +#define en_dbg(mlevel, priv, format, arg...) \ +do { \ + if (NETIF_MSG_##mlevel & priv->msg_enable) \ + en_print(KERN_DEBUG, priv, format, ##arg); \ +} while (0) +#define en_warn(priv, format, arg...) \ + en_print(KERN_WARNING, priv, format, ##arg) +#define en_err(priv, format, arg...) \ + en_print(KERN_ERR, priv, format, ##arg) +#define en_info(priv, format, arg...) \ + en_print(KERN_INFO, priv, format, ## arg) + +#define mlx4_err(mdev, format, arg...) \ + pr_err("%s %s: " format, DRV_NAME, \ + dev_name(&mdev->pdev->dev), ##arg) +#define mlx4_info(mdev, format, arg...) \ + pr_info("%s %s: " format, DRV_NAME, \ + dev_name(&mdev->pdev->dev), ##arg) +#define mlx4_warn(mdev, format, arg...) \ + pr_warning("%s %s: " format, DRV_NAME, \ + dev_name(&mdev->pdev->dev), ##arg) + #endif diff --git a/sys/ofed/drivers/net/mlx4/mlx4_stats.h b/sys/ofed/drivers/net/mlx4/mlx4_stats.h new file mode 100644 index 000000000000..0270cefd0ec4 --- /dev/null +++ b/sys/ofed/drivers/net/mlx4/mlx4_stats.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2014 Mellanox Technologies Ltd. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - 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. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _MLX4_STATS_ +#define _MLX4_STATS_ + + +#ifdef MLX4_EN_PERF_STAT +#define NUM_PERF_STATS NUM_PERF_COUNTERS +#else +#define NUM_PERF_STATS 0 +#endif + +#define NUM_PRIORITIES 9 +#define NUM_PRIORITY_STATS 2 + +struct mlx4_en_pkt_stats { + unsigned long rx_packets; + unsigned long rx_bytes; + unsigned long rx_multicast_packets; + unsigned long rx_broadcast_packets; + unsigned long rx_errors; + unsigned long rx_dropped; + unsigned long rx_length_errors; + unsigned long rx_over_errors; + unsigned long rx_crc_errors; + unsigned long rx_jabbers; + unsigned long rx_in_range_length_error; + unsigned long rx_out_range_length_error; + unsigned long rx_lt_64_bytes_packets; + unsigned long rx_127_bytes_packets; + unsigned long rx_255_bytes_packets; + unsigned long rx_511_bytes_packets; + unsigned long rx_1023_bytes_packets; + unsigned long rx_1518_bytes_packets; + unsigned long rx_1522_bytes_packets; + unsigned long rx_1548_bytes_packets; + unsigned long rx_gt_1548_bytes_packets; + unsigned long tx_packets; + unsigned long tx_bytes; + unsigned long tx_multicast_packets; + unsigned long tx_broadcast_packets; + unsigned long tx_errors; + unsigned long tx_dropped; + unsigned long tx_lt_64_bytes_packets; + unsigned long tx_127_bytes_packets; + unsigned long tx_255_bytes_packets; + unsigned long tx_511_bytes_packets; + unsigned long tx_1023_bytes_packets; + unsigned long tx_1518_bytes_packets; + unsigned long tx_1522_bytes_packets; + unsigned long tx_1548_bytes_packets; + unsigned long tx_gt_1548_bytes_packets; + unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; + unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; +#define NUM_PKT_STATS 72 +}; + +struct mlx4_en_vf_stats { + unsigned long rx_packets; + unsigned long rx_bytes; + unsigned long rx_multicast_packets; + unsigned long rx_broadcast_packets; + unsigned long rx_errors; + unsigned long rx_dropped; + unsigned long tx_packets; + unsigned long tx_bytes; + unsigned long tx_multicast_packets; + unsigned long tx_broadcast_packets; + unsigned long tx_errors; +#define NUM_VF_STATS 11 +}; + +struct mlx4_en_vport_stats { + unsigned long rx_unicast_packets; + unsigned long rx_unicast_bytes; + unsigned long rx_multicast_packets; + unsigned long rx_multicast_bytes; + unsigned long rx_broadcast_packets; + unsigned long rx_broadcast_bytes; + unsigned long rx_dropped; + unsigned long rx_errors; + unsigned long tx_unicast_packets; + unsigned long tx_unicast_bytes; + unsigned long tx_multicast_packets; + unsigned long tx_multicast_bytes; + unsigned long tx_broadcast_packets; + unsigned long tx_broadcast_bytes; + unsigned long tx_errors; +#define NUM_VPORT_STATS 15 +}; + +struct mlx4_en_port_stats { + unsigned long tso_packets; + unsigned long queue_stopped; + unsigned long wake_queue; + unsigned long tx_timeout; + unsigned long rx_alloc_failed; + unsigned long rx_chksum_good; + unsigned long rx_chksum_none; + unsigned long tx_chksum_offload; +#define NUM_PORT_STATS 8 +}; + +struct mlx4_en_perf_stats { + u32 tx_poll; + u64 tx_pktsz_avg; + u32 inflight_avg; + u16 tx_coal_avg; + u16 rx_coal_avg; + u32 napi_quota; +#define NUM_PERF_COUNTERS 6 +}; + +struct mlx4_en_flow_stats { + u64 rx_pause; + u64 rx_pause_duration; + u64 rx_pause_transition; + u64 tx_pause; + u64 tx_pause_duration; + u64 tx_pause_transition; +}; +#define MLX4_NUM_PRIORITIES 8 +#define NUM_FLOW_PRIORITY_STATS 6 +#define NUM_FLOW_STATS (NUM_FLOW_PRIORITY_STATS*MLX4_NUM_PRIORITIES) + + +struct mlx4_en_stat_out_flow_control_mbox { + /* Total number of PAUSE frames received from the far-end port */ + __be64 rx_pause; + /* Total number of microseconds that far-end port requested to pause + * transmission of packets + */ + __be64 rx_pause_duration; + /* Number of received transmission from XOFF state to XON state */ + __be64 rx_pause_transition; + /* Total number of PAUSE frames sent from the far-end port */ + __be64 tx_pause; + /* Total time in microseconds that transmission of packets has been + * paused + */ + __be64 tx_pause_duration; + /* Number of transmitter transitions from XOFF state to XON state */ + __be64 tx_pause_transition; + /* Reserverd */ + __be64 reserved[2]; +}; + +int mlx4_get_vport_ethtool_stats(struct mlx4_dev *dev, int port, + struct mlx4_en_vport_stats *vport_stats, + int reset); + +#define NUM_ALL_STATS (NUM_PKT_STATS + NUM_FLOW_STATS + NUM_VPORT_STATS + \ + NUM_VF_STATS + NUM_PORT_STATS + NUM_PERF_STATS) +#endif diff --git a/sys/ofed/drivers/net/mlx4/mr.c b/sys/ofed/drivers/net/mlx4/mr.c index 69a0abd922e6..876d16dba1a3 100644 --- a/sys/ofed/drivers/net/mlx4/mr.c +++ b/sys/ofed/drivers/net/mlx4/mr.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2004 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -32,30 +32,20 @@ * SOFTWARE. */ +#include #include +#include #include #include #include #include +#include + #include "mlx4.h" #include "icm.h" -#define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28) -#define MLX4_MPT_FLAG_FREE (0x3UL << 28) -#define MLX4_MPT_FLAG_MIO (1 << 17) -#define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15) -#define MLX4_MPT_FLAG_PHYSICAL (1 << 9) -#define MLX4_MPT_FLAG_REGION (1 << 8) - -#define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27) -#define MLX4_MPT_PD_FLAG_RAE (1 << 28) -#define MLX4_MPT_PD_FLAG_EN_INV (3 << 24) - -#define MLX4_MPT_STATUS_SW 0xF0 -#define MLX4_MPT_STATUS_HW 0x00 - static u32 mlx4_buddy_alloc(struct mlx4_buddy *buddy, int order) { int o; @@ -129,9 +119,8 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order) for (i = 0; i <= buddy->max_order; ++i) { s = BITS_TO_LONGS(1 << (buddy->max_order - i)); buddy->bits[i] = kcalloc(s, sizeof (long), GFP_KERNEL | __GFP_NOWARN); - if (!buddy->bits[i]) { - goto err_out_free; - } + if (!buddy->bits[i]) + goto err_out_free; } set_bit(0, buddy->bits[buddy->max_order]); @@ -141,8 +130,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order) err_out_free: for (i = 0; i <= buddy->max_order; ++i) - if ( buddy->bits[i] ) - kfree(buddy->bits[i]); + kfree(buddy->bits[i]); err_out: kfree(buddy->bits); @@ -156,7 +144,7 @@ static void mlx4_buddy_cleanup(struct mlx4_buddy *buddy) int i; for (i = 0; i <= buddy->max_order; ++i) - kfree(buddy->bits[i]); + kfree(buddy->bits[i]); kfree(buddy->bits); kfree(buddy->num_free); @@ -315,7 +303,7 @@ static int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, mr->size = size; mr->pd = pd; mr->access = access; - mr->enabled = MLX4_MR_DISABLED; + mr->enabled = MLX4_MPT_DISABLED; mr->key = hw_index_to_key(mridx); return mlx4_mtt_init(dev, npages, page_shift, &mr->mtt); @@ -329,14 +317,14 @@ static int mlx4_WRITE_MTT(struct mlx4_dev *dev, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); } -int __mlx4_mr_reserve(struct mlx4_dev *dev) +int __mlx4_mpt_reserve(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); return mlx4_bitmap_alloc(&priv->mr_table.mpt_bitmap); } -static int mlx4_mr_reserve(struct mlx4_dev *dev) +static int mlx4_mpt_reserve(struct mlx4_dev *dev) { u64 out_param; @@ -347,17 +335,17 @@ static int mlx4_mr_reserve(struct mlx4_dev *dev) return -1; return get_param_l(&out_param); } - return __mlx4_mr_reserve(dev); + return __mlx4_mpt_reserve(dev); } -void __mlx4_mr_release(struct mlx4_dev *dev, u32 index) +void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index) { struct mlx4_priv *priv = mlx4_priv(dev); - mlx4_bitmap_free(&priv->mr_table.mpt_bitmap, index); + mlx4_bitmap_free(&priv->mr_table.mpt_bitmap, index, MLX4_NO_RR); } -static void mlx4_mr_release(struct mlx4_dev *dev, u32 index) +static void mlx4_mpt_release(struct mlx4_dev *dev, u32 index) { u64 in_param = 0; @@ -370,17 +358,17 @@ static void mlx4_mr_release(struct mlx4_dev *dev, u32 index) index); return; } - __mlx4_mr_release(dev, index); + __mlx4_mpt_release(dev, index); } -int __mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index) +int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index) { struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table; return mlx4_table_get(dev, &mr_table->dmpt_table, index); } -static int mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index) +static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index) { u64 param = 0; @@ -391,17 +379,17 @@ static int mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index) MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); } - return __mlx4_mr_alloc_icm(dev, index); + return __mlx4_mpt_alloc_icm(dev, index); } -void __mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index) +void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index) { struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table; mlx4_table_put(dev, &mr_table->dmpt_table, index); } -static void mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index) +static void mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index) { u64 in_param = 0; @@ -414,7 +402,7 @@ static void mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index) index); return; } - return __mlx4_mr_free_icm(dev, index); + return __mlx4_mpt_free_icm(dev, index); } int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access, @@ -423,41 +411,52 @@ int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access, u32 index; int err; - index = mlx4_mr_reserve(dev); + index = mlx4_mpt_reserve(dev); if (index == -1) return -ENOMEM; err = mlx4_mr_alloc_reserved(dev, index, pd, iova, size, access, npages, page_shift, mr); if (err) - mlx4_mr_release(dev, index); + mlx4_mpt_release(dev, index); return err; } EXPORT_SYMBOL_GPL(mlx4_mr_alloc); -static void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) +static int mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) { int err; - if (mr->enabled == MLX4_MR_EN_HW) { + if (mr->enabled == MLX4_MPT_EN_HW) { err = mlx4_HW2SW_MPT(dev, NULL, key_to_hw_index(mr->key) & (dev->caps.num_mpts - 1)); - if (err) - mlx4_warn(dev, "xxx HW2SW_MPT failed (%d)\n", err); + if (err) { + mlx4_warn(dev, "HW2SW_MPT failed (%d).", err); + mlx4_warn(dev, "Most likely the MR has MWs bound to it.\n"); + return err; + } - mr->enabled = MLX4_MR_EN_SW; + mr->enabled = MLX4_MPT_EN_SW; } mlx4_mtt_cleanup(dev, &mr->mtt); + + return 0; } -void mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr) +int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr) { - mlx4_mr_free_reserved(dev, mr); + int ret; + + ret = mlx4_mr_free_reserved(dev, mr); + if (ret) + return ret; if (mr->enabled) - mlx4_mr_free_icm(dev, key_to_hw_index(mr->key)); - mlx4_mr_release(dev, key_to_hw_index(mr->key)); + mlx4_mpt_free_icm(dev, key_to_hw_index(mr->key)); + mlx4_mpt_release(dev, key_to_hw_index(mr->key)); + + return 0; } EXPORT_SYMBOL_GPL(mlx4_mr_free); @@ -467,7 +466,7 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) struct mlx4_mpt_entry *mpt_entry; int err; - err = mlx4_mr_alloc_icm(dev, key_to_hw_index(mr->key)); + err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mr->key)); if (err) return err; @@ -514,7 +513,7 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) mlx4_warn(dev, "SW2HW_MPT failed (%d)\n", err); goto err_cmd; } - mr->enabled = MLX4_MR_EN_HW; + mr->enabled = MLX4_MPT_EN_HW; mlx4_free_cmd_mailbox(dev, mailbox); @@ -524,7 +523,7 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) mlx4_free_cmd_mailbox(dev, mailbox); err_table: - mlx4_mr_free_icm(dev, key_to_hw_index(mr->key)); + mlx4_mpt_free_icm(dev, key_to_hw_index(mr->key)); return err; } EXPORT_SYMBOL_GPL(mlx4_mr_enable); @@ -651,6 +650,95 @@ int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, } EXPORT_SYMBOL_GPL(mlx4_buf_write_mtt); +int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type, + struct mlx4_mw *mw) +{ + u32 index; + + index = mlx4_mpt_reserve(dev); + if (index == -1) + return -ENOMEM; + + mw->key = hw_index_to_key(index); + mw->pd = pd; + mw->type = type; + mw->enabled = MLX4_MPT_DISABLED; + + return 0; +} +EXPORT_SYMBOL_GPL(mlx4_mw_alloc); + +int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw) +{ + struct mlx4_cmd_mailbox *mailbox; + struct mlx4_mpt_entry *mpt_entry; + int err; + + err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mw->key)); + if (err) + return err; + + mailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(mailbox)) { + err = PTR_ERR(mailbox); + goto err_table; + } + mpt_entry = mailbox->buf; + + memset(mpt_entry, 0, sizeof(*mpt_entry)); + + /* Note that the MLX4_MPT_FLAG_REGION bit in mpt_entry->flags is turned + * off, thus creating a memory window and not a memory region. + */ + mpt_entry->key = cpu_to_be32(key_to_hw_index(mw->key)); + mpt_entry->pd_flags = cpu_to_be32(mw->pd); + if (mw->type == MLX4_MW_TYPE_2) { + mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_FREE); + mpt_entry->qpn = cpu_to_be32(MLX4_MPT_QP_FLAG_BOUND_QP); + mpt_entry->pd_flags |= cpu_to_be32(MLX4_MPT_PD_FLAG_EN_INV); + } + + err = mlx4_SW2HW_MPT(dev, mailbox, + key_to_hw_index(mw->key) & + (dev->caps.num_mpts - 1)); + if (err) { + mlx4_warn(dev, "SW2HW_MPT failed (%d)\n", err); + goto err_cmd; + } + mw->enabled = MLX4_MPT_EN_HW; + + mlx4_free_cmd_mailbox(dev, mailbox); + + return 0; + +err_cmd: + mlx4_free_cmd_mailbox(dev, mailbox); + +err_table: + mlx4_mpt_free_icm(dev, key_to_hw_index(mw->key)); + return err; +} +EXPORT_SYMBOL_GPL(mlx4_mw_enable); + +void mlx4_mw_free(struct mlx4_dev *dev, struct mlx4_mw *mw) +{ + int err; + + if (mw->enabled == MLX4_MPT_EN_HW) { + err = mlx4_HW2SW_MPT(dev, NULL, + key_to_hw_index(mw->key) & + (dev->caps.num_mpts - 1)); + if (err) + mlx4_warn(dev, "xxx HW2SW_MPT failed (%d)\n", err); + + mw->enabled = MLX4_MPT_EN_SW; + } + if (mw->enabled) + mlx4_mpt_free_icm(dev, key_to_hw_index(mw->key)); + mlx4_mpt_release(dev, key_to_hw_index(mw->key)); +} +EXPORT_SYMBOL_GPL(mlx4_mw_free); + int mlx4_init_mr_table(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); @@ -671,8 +759,8 @@ int mlx4_init_mr_table(struct mlx4_dev *dev) return err; err = mlx4_buddy_init(&mr_table->mtt_buddy, - ilog2((u32)dev->caps.num_mtts / - (1 << log_mtts_per_seg))); + ilog2(div_u64(dev->caps.num_mtts, + (1 << log_mtts_per_seg)))); if (err) goto err_buddy; @@ -791,7 +879,7 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, int max_maps, u8 page_shift, struct mlx4_fmr *fmr) { struct mlx4_priv *priv = mlx4_priv(dev); - int err = -ENOMEM; + int err = -ENOMEM, ret; if (max_maps > dev->caps.max_fmr_maps) return -EINVAL; @@ -825,7 +913,9 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, return 0; err_free: - mlx4_mr_free(dev, &fmr->mr); + ret = mlx4_mr_free(dev, &fmr->mr); + if (ret) + mlx4_err(dev, "Error deregistering MR. The system may have become unstable."); return err; } EXPORT_SYMBOL_GPL(mlx4_fmr_alloc); @@ -851,40 +941,48 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_enable); void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u32 *lkey, u32 *rkey) { - struct mlx4_cmd_mailbox *mailbox; - int err; + u32 key; if (!fmr->maps) return; + key = key_to_hw_index(fmr->mr.key) & (dev->caps.num_mpts - 1); + + *(u8 *)fmr->mpt = MLX4_MPT_STATUS_SW; + + /* Make sure MPT status is visible before changing MPT fields */ + wmb(); + + fmr->mr.key = hw_index_to_key(key); + + fmr->mpt->key = cpu_to_be32(key); + fmr->mpt->lkey = cpu_to_be32(key); + fmr->mpt->length = 0; + fmr->mpt->start = 0; + + /* Make sure MPT data is visible before changing MPT status */ + wmb(); + + *(u8 *)fmr->mpt = MLX4_MPT_STATUS_HW; + + /* Make sure MPT satus is visible */ + wmb(); + fmr->maps = 0; - - mailbox = mlx4_alloc_cmd_mailbox(dev); - if (IS_ERR(mailbox)) { - err = PTR_ERR(mailbox); - mlx4_warn(dev, "mlx4_alloc_cmd_mailbox failed (%d)\n", err); - return; - } - - err = mlx4_HW2SW_MPT(dev, NULL, - key_to_hw_index(fmr->mr.key) & - (dev->caps.num_mpts - 1)); - mlx4_free_cmd_mailbox(dev, mailbox); - if (err) { - mlx4_warn(dev, "mlx4_HW2SW_MPT failed (%d)\n", err); - return; - } - fmr->mr.enabled = MLX4_MR_EN_SW; } EXPORT_SYMBOL_GPL(mlx4_fmr_unmap); int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr) { + int ret; + if (fmr->maps) return -EBUSY; - mlx4_mr_free(dev, &fmr->mr); - fmr->mr.enabled = MLX4_MR_DISABLED; + ret = mlx4_mr_free(dev, &fmr->mr); + if (ret) + return ret; + fmr->mr.enabled = MLX4_MPT_DISABLED; return 0; } diff --git a/sys/ofed/drivers/net/mlx4/pd.c b/sys/ofed/drivers/net/mlx4/pd.c index 2c525aad130d..5162a47d5b48 100644 --- a/sys/ofed/drivers/net/mlx4/pd.c +++ b/sys/ofed/drivers/net/mlx4/pd.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -32,6 +32,7 @@ */ #include +#include #include #include @@ -57,7 +58,7 @@ EXPORT_SYMBOL_GPL(mlx4_pd_alloc); void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn) { - mlx4_bitmap_free(&mlx4_priv(dev)->pd_bitmap, pdn); + mlx4_bitmap_free(&mlx4_priv(dev)->pd_bitmap, pdn, MLX4_USE_RR); } EXPORT_SYMBOL_GPL(mlx4_pd_free); @@ -94,7 +95,7 @@ EXPORT_SYMBOL_GPL(mlx4_xrcd_alloc); void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn) { - mlx4_bitmap_free(&mlx4_priv(dev)->xrcd_bitmap, xrcdn); + mlx4_bitmap_free(&mlx4_priv(dev)->xrcd_bitmap, xrcdn, MLX4_USE_RR); } void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn) @@ -162,7 +163,7 @@ EXPORT_SYMBOL_GPL(mlx4_uar_alloc); void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar) { - mlx4_bitmap_free(&mlx4_priv(dev)->uar_table.bitmap, uar->index); + mlx4_bitmap_free(&mlx4_priv(dev)->uar_table.bitmap, uar->index, MLX4_USE_RR); } EXPORT_SYMBOL_GPL(mlx4_uar_free); diff --git a/sys/ofed/drivers/net/mlx4/port.c b/sys/ofed/drivers/net/mlx4/port.c index 2a009ead879e..c653d4ba35c2 100644 --- a/sys/ofed/drivers/net/mlx4/port.c +++ b/sys/ofed/drivers/net/mlx4/port.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -32,10 +32,14 @@ #include #include +#include +#include #include #include #include "mlx4.h" +#include "mlx4_stats.h" + int mlx4_set_4k_mtu = -1; module_param_named(set_4k_mtu, mlx4_set_4k_mtu, int, 0444); @@ -48,12 +52,6 @@ MODULE_PARM_DESC(set_4k_mtu, #define MLX4_VLAN_VALID (1u << 31) #define MLX4_VLAN_MASK 0xfff -#define MLX4_STATS_TRAFFIC_COUNTERS_MASK 0xfULL -#define MLX4_STATS_TRAFFIC_DROPS_MASK 0xc0ULL -#define MLX4_STATS_ERROR_COUNTERS_MASK 0x1ffc30ULL -#define MLX4_STATS_PORT_COUNTERS_MASK 0x1fe00000ULL -#define MLX4_STATS_IF_RX_ERRORS_COUNTERS_MASK 0x8010ULL - void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table) { int i; @@ -85,7 +83,7 @@ static int validate_index(struct mlx4_dev *dev, { int err = 0; - if (index < 0 || index >= table->max || !table->entries[index]) { + if (index < 0 || index >= table->max || !table->refs[index]) { mlx4_warn(dev, "No valid Mac entry for the given index\n"); err = -EINVAL; } @@ -140,14 +138,15 @@ int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac) mutex_lock(&table->mutex); for (i = 0; i < MLX4_MAX_MAC_NUM; i++) { - if (free < 0 && !table->entries[i]) { + if (free < 0 && !table->refs[i]) { free = i; continue; } - if (mac == (MLX4_MAC_MASK & be64_to_cpu(table->entries[i]))) { + if ((mac == (MLX4_MAC_MASK & be64_to_cpu(table->entries[i]))) && + table->refs[i]) { /* MAC already registered, Must not have duplicates */ - err = i; + err = i; ++table->refs[i]; goto out; } @@ -184,13 +183,24 @@ EXPORT_SYMBOL_GPL(__mlx4_register_mac); int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac) { u64 out_param = 0; - int err; + int err = -EINVAL; if (mlx4_is_mfunc(dev)) { - err = mlx4_cmd_imm(dev, mac, &out_param, - ((u32) port) << 8 | (u32) RES_MAC, - RES_OP_RESERVE_AND_MAP, MLX4_CMD_ALLOC_RES, - MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + if (!(dev->flags & MLX4_FLAG_OLD_REG_MAC)) { + err = mlx4_cmd_imm(dev, mac, &out_param, + ((u32) port) << 8 | (u32) RES_MAC, + RES_OP_RESERVE_AND_MAP, MLX4_CMD_ALLOC_RES, + MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + } + if (err && err == -EINVAL && mlx4_is_slave(dev)) { + /* retry using old REG_MAC format */ + set_param_l(&out_param, port); + err = mlx4_cmd_imm(dev, mac, &out_param, RES_MAC, + RES_OP_RESERVE_AND_MAP, MLX4_CMD_ALLOC_RES, + MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + if (!err) + dev->flags |= MLX4_FLAG_OLD_REG_MAC; + } if (err) return err; @@ -245,10 +255,18 @@ void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac) u64 out_param = 0; if (mlx4_is_mfunc(dev)) { - (void) mlx4_cmd_imm(dev, mac, &out_param, - ((u32) port) << 8 | (u32) RES_MAC, - RES_OP_RESERVE_AND_MAP, MLX4_CMD_FREE_RES, - MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + if (!(dev->flags & MLX4_FLAG_OLD_REG_MAC)) { + (void) mlx4_cmd_imm(dev, mac, &out_param, + ((u32) port) << 8 | (u32) RES_MAC, + RES_OP_RESERVE_AND_MAP, MLX4_CMD_FREE_RES, + MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + } else { + /* use old unregister mac format */ + set_param_l(&out_param, port); + (void) mlx4_cmd_imm(dev, mac, &out_param, RES_MAC, + RES_OP_RESERVE_AND_MAP, MLX4_CMD_FREE_RES, + MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); + } return; } __mlx4_unregister_mac(dev, port, mac); @@ -535,17 +553,21 @@ static int mlx4_common_set_port(struct mlx4_dev *dev, int slave, u32 in_mod, __be32 new_cap_mask; port = in_mod & 0xff; - in_modifier = in_mod >> 8; + in_modifier = (in_mod >> 8) & 0xff; is_eth = op_mod; port_info = &priv->port[port]; + if (op_mod > 1) + return -EINVAL; + /* Slaves cannot perform SET_PORT operations except changing MTU */ if (is_eth) { if (slave != dev->caps.function && in_modifier != MLX4_SET_PORT_GENERAL && in_modifier != MLX4_SET_PORT_GID_TABLE) { - mlx4_warn(dev, "denying SET_PORT for slave:%d\n", - slave); + mlx4_warn(dev, "denying SET_PORT for slave:%d," + "port %d, config_select 0x%x\n", + slave, port, in_modifier); return -EINVAL; } switch (in_modifier) { @@ -570,7 +592,8 @@ static int mlx4_common_set_port(struct mlx4_dev *dev, int slave, u32 in_mod, /* Mtu is configured as the max MTU among all the * the functions on the port. */ mtu = be16_to_cpu(gen_context->mtu); - mtu = min_t(int, mtu, dev->caps.eth_mtu_cap[port]); + mtu = min_t(int, mtu, dev->caps.eth_mtu_cap[port] + + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); prev_mtu = slave_st->mtu[port]; slave_st->mtu[port] = mtu; if (mtu > master->max_mtu[port]) @@ -650,7 +673,7 @@ static int mlx4_common_set_port(struct mlx4_dev *dev, int slave, u32 in_mod, break; } - return mlx4_cmd(dev, inbox->dma, in_mod, op_mod, + return mlx4_cmd(dev, inbox->dma, in_mod & 0xffff, op_mod, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); } @@ -727,19 +750,10 @@ enum { MLX4_CHANGE_PORT_MTU_CAP = 22, }; -#define CX3_PPF_DEV_ID 0x1003 -static int vl_cap_start(struct mlx4_dev *dev) -{ - /* for non CX3 devices, start with 4 VLs to avoid errors in syslog */ - if (dev->pdev->device != CX3_PPF_DEV_ID) - return 4; - return 8; -} - int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz) { struct mlx4_cmd_mailbox *mailbox; - int err, vl_cap, pkey_tbl_flag = 0; + int err = -EINVAL, vl_cap, pkey_tbl_flag = 0; u32 in_mod; if (dev->caps.port_type[port] == MLX4_PORT_TYPE_NONE) @@ -765,7 +779,8 @@ int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz) } /* IB VL CAP enum isn't used by the firmware, just numerical values */ - for (vl_cap = vl_cap_start(dev); vl_cap >= 1; vl_cap >>= 1) { + for (vl_cap = dev->caps.vl_cap[port]; + vl_cap >= 1; vl_cap >>= 1) { ((__be32 *) mailbox->buf)[0] = cpu_to_be32( (1 << MLX4_CHANGE_PORT_MTU_CAP) | (1 << MLX4_CHANGE_PORT_VL_CAP) | @@ -822,10 +837,9 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, u32 in_mod; u32 m_promisc = (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) ? MCAST_DIRECT : MCAST_DEFAULT; -/* + if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) return 0; -*/ mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) @@ -834,10 +848,7 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, memset(context, 0, sizeof *context); context->base_qpn = cpu_to_be32(base_qpn); - /* - * This assignment breaks vlan support - I don't know why. Probablya an A0 issue - shahar Klein - * context->n_mac = dev->caps.log_num_macs; - */ + context->n_mac = dev->caps.log_num_macs; context->promisc = cpu_to_be32(promisc << SET_PORT_PROMISC_SHIFT | base_qpn); context->mcast = cpu_to_be32(m_promisc << SET_PORT_MC_PROMISC_SHIFT | @@ -960,40 +971,44 @@ int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave, return err; } -int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, - u32 in_mod, struct mlx4_cmd_mailbox *outbox) -{ - return mlx4_cmd_box(dev, 0, outbox->dma, in_mod, 0, - MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B, - MLX4_CMD_NATIVE); -} - int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, struct mlx4_cmd_mailbox *outbox, struct mlx4_cmd_info *cmd) { - if (slave != dev->caps.function) - return 0; - return mlx4_common_dump_eth_stats(dev, slave, - vhcr->in_modifier, outbox); + return 0; } -void mlx4_set_stats_bitmap(struct mlx4_dev *dev, u64 *stats_bitmap) +void mlx4_set_stats_bitmap(struct mlx4_dev *dev, unsigned long *stats_bitmap) { - if (!mlx4_is_mfunc(dev)) { - *stats_bitmap = 0; - return; + int last_i = 0; + + bitmap_zero(stats_bitmap, NUM_ALL_STATS); + + if (mlx4_is_slave(dev)) { + last_i = dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN ? + NUM_PKT_STATS + NUM_FLOW_STATS : NUM_PKT_STATS; + } else { + bitmap_set(stats_bitmap, last_i, NUM_PKT_STATS); + last_i = NUM_PKT_STATS; + + if (dev->caps.flags2 & + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) { + bitmap_set(stats_bitmap, last_i, NUM_FLOW_STATS); + last_i += NUM_FLOW_STATS; + } } - *stats_bitmap = (MLX4_STATS_TRAFFIC_COUNTERS_MASK | - MLX4_STATS_TRAFFIC_DROPS_MASK | - MLX4_STATS_PORT_COUNTERS_MASK | - MLX4_STATS_IF_RX_ERRORS_COUNTERS_MASK); + if (mlx4_is_slave(dev)) + bitmap_set(stats_bitmap, last_i, NUM_VF_STATS); + last_i += NUM_VF_STATS; if (mlx4_is_master(dev)) - *stats_bitmap |= MLX4_STATS_ERROR_COUNTERS_MASK; + bitmap_set(stats_bitmap, last_i, NUM_VPORT_STATS); + last_i += NUM_VPORT_STATS; + + bitmap_set(stats_bitmap, last_i, NUM_PORT_STATS); } EXPORT_SYMBOL(mlx4_set_stats_bitmap); diff --git a/sys/ofed/drivers/net/mlx4/profile.c b/sys/ofed/drivers/net/mlx4/profile.c index d3042f012146..aa5f957feccd 100644 --- a/sys/ofed/drivers/net/mlx4/profile.c +++ b/sys/ofed/drivers/net/mlx4/profile.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -76,7 +76,7 @@ u64 mlx4_make_profile(struct mlx4_dev *dev, u64 size; u64 start; int type; - u32 num; + u64 num; int log_num; }; @@ -112,7 +112,8 @@ u64 mlx4_make_profile(struct mlx4_dev *dev, min_t(unsigned, dev_cap->max_eqs, MAX_MSIX); profile[MLX4_RES_DMPT].num = request->num_mpt; profile[MLX4_RES_CMPT].num = MLX4_NUM_CMPTS; - profile[MLX4_RES_MTT].num = request->num_mtt * (1 << log_mtts_per_seg); + profile[MLX4_RES_MTT].num = ((u64)request->num_mtt_segs) * + (1 << log_mtts_per_seg); profile[MLX4_RES_MCG].num = request->num_mcg; for (i = 0; i < MLX4_RES_NUM; ++i) { diff --git a/sys/ofed/drivers/net/mlx4/qp.c b/sys/ofed/drivers/net/mlx4/qp.c index 2e2033d92815..fe8d3c2de07f 100644 --- a/sys/ofed/drivers/net/mlx4/qp.c +++ b/sys/ofed/drivers/net/mlx4/qp.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * Copyright (c) 2004 Voltaire, Inc. All rights reserved. * * This software is available to you under a choice of one of two @@ -33,6 +33,10 @@ * SOFTWARE. */ +#include +#include +#include + #include #include @@ -210,13 +214,18 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt, EXPORT_SYMBOL_GPL(mlx4_qp_modify); int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, - int *base, u8 bf_qp) + int *base, u8 flags) { + int bf_qp = !!(flags & (u8) MLX4_RESERVE_BF_QP); + struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_qp_table *qp_table = &priv->qp_table; + /* Only IPoIB uses a large cnt. In this case, just allocate + * as usual, ignoring bf skipping, since IPoIB does not run over RoCE + */ if (cnt > MLX4_MAX_BF_QP_RANGE && bf_qp) - return -ENOMEM; + bf_qp = 0; *base = mlx4_bitmap_alloc_range(&qp_table->bitmap, cnt, align, bf_qp ? MLX4_BF_QP_SKIP_MASK : 0); @@ -227,14 +236,14 @@ int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, } int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, - int *base, u8 bf_qp) + int *base, u8 flags) { u64 in_param = 0; u64 out_param; int err; if (mlx4_is_mfunc(dev)) { - set_param_l(&in_param, (((!!bf_qp) << 31) | (u32)cnt)); + set_param_l(&in_param, (((u32) flags) << 24) | (u32) cnt); set_param_h(&in_param, align); err = mlx4_cmd_imm(dev, in_param, &out_param, RES_QP, RES_OP_RESERVE, @@ -246,7 +255,7 @@ int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, *base = get_param_l(&out_param); return 0; } - return __mlx4_qp_reserve_range(dev, cnt, align, base, bf_qp); + return __mlx4_qp_reserve_range(dev, cnt, align, base, flags); } EXPORT_SYMBOL_GPL(mlx4_qp_reserve_range); @@ -257,7 +266,7 @@ void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt) if (mlx4_is_qp_reserved(dev, (u32) base_qpn)) return; - mlx4_bitmap_free_range(&qp_table->bitmap, base_qpn, cnt); + mlx4_bitmap_free_range(&qp_table->bitmap, base_qpn, cnt, MLX4_USE_RR); } void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt) diff --git a/sys/ofed/drivers/net/mlx4/reset.c b/sys/ofed/drivers/net/mlx4/reset.c index 43b15411bec0..44ec1e12b898 100644 --- a/sys/ofed/drivers/net/mlx4/reset.c +++ b/sys/ofed/drivers/net/mlx4/reset.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -77,7 +77,7 @@ int mlx4_reset(struct mlx4_dev *dev) goto out; } - pcie_cap = pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); + pcie_cap = pci_pcie_cap(dev->pdev); for (i = 0; i < 64; ++i) { if (i == 22 || i == 23) @@ -119,8 +119,8 @@ int mlx4_reset(struct mlx4_dev *dev) writel(MLX4_RESET_VALUE, reset + MLX4_RESET_OFFSET); iounmap(reset); - /* Docs say to wait one second before accessing device */ - msleep(2000); + /* wait half a second before accessing device */ + msleep(500); end = jiffies + MLX4_RESET_TIMEOUT_JIFFIES; do { @@ -138,11 +138,10 @@ int mlx4_reset(struct mlx4_dev *dev) goto out; } - /* Now restore the PCI headers */ if (pcie_cap) { devctl = hca_header[(pcie_cap + PCI_EXP_DEVCTL) / 4]; - if (pci_write_config_word(dev->pdev, pcie_cap + PCI_EXP_DEVCTL, + if (pcie_capability_write_word(dev->pdev, PCI_EXP_DEVCTL, devctl)) { err = -ENODEV; mlx4_err(dev, "Couldn't restore HCA PCI Express " @@ -150,7 +149,7 @@ int mlx4_reset(struct mlx4_dev *dev) goto out; } linkctl = hca_header[(pcie_cap + PCI_EXP_LNKCTL) / 4]; - if (pci_write_config_word(dev->pdev, pcie_cap + PCI_EXP_LNKCTL, + if (pcie_capability_write_word(dev->pdev, PCI_EXP_LNKCTL, linkctl)) { err = -ENODEV; mlx4_err(dev, "Couldn't restore HCA PCI Express " diff --git a/sys/ofed/drivers/net/mlx4/resource_tracker.c b/sys/ofed/drivers/net/mlx4/resource_tracker.c index 65fc1dd21213..743c8871fcaf 100644 --- a/sys/ofed/drivers/net/mlx4/resource_tracker.c +++ b/sys/ofed/drivers/net/mlx4/resource_tracker.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. + * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. * All rights reserved. * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. * @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include "mlx4.h" #include "fw.h" @@ -85,6 +85,7 @@ struct res_gid { u8 gid[16]; enum mlx4_protocol prot; enum mlx4_steer_type steer; + u64 reg_id; }; enum res_qp_states { @@ -109,6 +110,16 @@ struct res_qp { struct list_head mcg_list; spinlock_t mcg_spl; int local_qpn; + atomic_t ref_count; + u32 qpc_flags; + /* saved qp params before VST enforcement in order to restore on VGT */ + u8 sched_queue; + __be32 param3; + u8 vlan_control; + u8 fvl_rx; + u8 pri_path_fl; + u8 vlan_index; + u8 feup; }; enum res_mtt_states { @@ -207,6 +218,7 @@ enum res_fs_rule_states { struct res_fs_rule { struct res_common com; + int qpn; }; static int mlx4_is_eth(struct mlx4_dev *dev, int port) @@ -622,9 +634,33 @@ static void update_gid(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *inbox, } } +static int check_counter_index_validity(struct mlx4_dev *dev, int slave, int port, int idx) +{ + struct mlx4_priv *priv = mlx4_priv(dev); + struct counter_index *counter, *tmp_counter; + + if (slave == 0) { + list_for_each_entry_safe(counter, tmp_counter, + &priv->counters_table.global_port_list[port - 1], + list) { + if (counter->index == idx) + return 0; + } + return -EINVAL; + } else { + list_for_each_entry_safe(counter, tmp_counter, + &priv->counters_table.vf_list[slave - 1][port - 1], + list) { + if (counter->index == idx) + return 0; + } + return -EINVAL; + } +} + static int update_vport_qp_param(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *inbox, - u8 slave) + u8 slave, u32 qpn) { struct mlx4_qp_context *qpc = inbox->buf + 8; struct mlx4_vport_oper_state *vp_oper; @@ -635,31 +671,63 @@ static int update_vport_qp_param(struct mlx4_dev *dev, port = (qpc->pri_path.sched_queue & 0x40) ? 2 : 1; priv = mlx4_priv(dev); vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; + qp_type = (be32_to_cpu(qpc->flags) >> 16) & 0xff; + + if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH && + qpc->pri_path.counter_index != MLX4_SINK_COUNTER_INDEX) { + if (check_counter_index_validity(dev, slave, port, + qpc->pri_path.counter_index)) + return -EINVAL; + } + + mlx4_dbg(dev, "%s: QP counter_index %d for slave %d port %d\n", + __func__, qpc->pri_path.counter_index, slave, port); + + if ((dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_LB_SRC_CHK) && + dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH && + !mlx4_is_qp_reserved(dev, qpn) && + qp_type == MLX4_QP_ST_MLX && + qpc->pri_path.counter_index != 0xFF) { + /* disable multicast loopback to qp with same counter */ + qpc->pri_path.fl |= MLX4_FL_ETH_SRC_CHECK_MC_LB; + qpc->pri_path.vlan_control |= + MLX4_VLAN_CTRL_ETH_SRC_CHECK_IF_COUNTER; + } if (MLX4_VGT != vp_oper->state.default_vlan) { - qp_type = (be32_to_cpu(qpc->flags) >> 16) & 0xff; - if (MLX4_QP_ST_RC == qp_type) - return -EINVAL; + /* the reserved QPs (special, proxy, tunnel) + * do not operate over vlans + */ + if (mlx4_is_qp_reserved(dev, qpn)) + return 0; - qpc->srqn |= cpu_to_be32(1 << 25); /*set cqe vlan mask */ + /* force strip vlan by clear vsd */ + qpc->param3 &= ~cpu_to_be32(MLX4_STRIP_VLAN); + /* preserve IF_COUNTER flag */ + qpc->pri_path.vlan_control &= + MLX4_VLAN_CTRL_ETH_SRC_CHECK_IF_COUNTER; + if (MLX4_QP_ST_RC != qp_type) { + if (0 != vp_oper->state.default_vlan) { + qpc->pri_path.vlan_control |= + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED | + MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED | + MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED; + } else { /* priority tagged */ + qpc->pri_path.vlan_control |= + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED | + MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED; + } + } + qpc->pri_path.fvl_rx |= MLX4_FVL_RX_FORCE_ETH_VLAN; qpc->pri_path.vlan_index = vp_oper->vlan_idx; - qpc->pri_path.fl = 1 << 6; /* set cv bit*/ - qpc->pri_path.feup |= 1 << 3; /* set fvl bit */ + qpc->pri_path.fl |= MLX4_FL_CV | MLX4_FL_ETH_HIDE_CQE_VLAN; + qpc->pri_path.feup |= MLX4_FEUP_FORCE_ETH_UP | MLX4_FVL_FORCE_ETH_VLAN; qpc->pri_path.sched_queue &= 0xC7; qpc->pri_path.sched_queue |= (vp_oper->state.default_qos) << 3; - mlx4_dbg(dev, "qp %d port %d Q 0x%x set vlan to %d vidx %d feup %x fl %x\n", - be32_to_cpu(qpc->local_qpn) & 0xffffff, port, - (int)(qpc->pri_path.sched_queue), vp_oper->state.default_vlan, - vp_oper->vlan_idx, (int)(qpc->pri_path.feup), - (int)(qpc->pri_path.fl)); } if (vp_oper->state.spoofchk) { - qpc->pri_path.feup |= 1 << 5; /* set fsm bit */; + qpc->pri_path.feup |= MLX4_FSM_FORCE_ETH_SRC_MAC; qpc->pri_path.grh_mylmc = (0x80 & qpc->pri_path.grh_mylmc) + vp_oper->mac_idx; - mlx4_dbg(dev, "spoof qp %d port %d feup 0x%x, myLmc 0x%x mindx %d\n", - be32_to_cpu(qpc->local_qpn) & 0xffffff, port, - (int)qpc->pri_path.feup, (int)qpc->pri_path.grh_mylmc, - vp_oper->mac_idx); } return 0; } @@ -669,7 +737,7 @@ static int mpt_mask(struct mlx4_dev *dev) return dev->caps.num_mpts - 1; } -static void *find_res(struct mlx4_dev *dev, int res_id, +static void *find_res(struct mlx4_dev *dev, u64 res_id, enum mlx4_resource type) { struct mlx4_priv *priv = mlx4_priv(dev); @@ -688,7 +756,7 @@ static int get_res(struct mlx4_dev *dev, int slave, u64 res_id, spin_lock_irq(mlx4_tlock(dev)); r = find_res(dev, res_id, type); if (!r) { - err = -ENOENT; + err = -ENONET; goto exit; } @@ -761,6 +829,7 @@ static struct res_common *alloc_qp_tr(int id) ret->local_qpn = id; INIT_LIST_HEAD(&ret->mcg_list); spin_lock_init(&ret->mcg_spl); + atomic_set(&ret->ref_count, 0); return &ret->com; } @@ -868,7 +937,7 @@ static struct res_common *alloc_xrcdn_tr(int id) return &ret->com; } -static struct res_common *alloc_fs_rule_tr(u64 id) +static struct res_common *alloc_fs_rule_tr(u64 id, int qpn) { struct res_fs_rule *ret; @@ -878,7 +947,7 @@ static struct res_common *alloc_fs_rule_tr(u64 id) ret->com.res_id = id; ret->com.state = RES_FS_RULE_ALLOCATED; - + ret->qpn = qpn; return &ret->com; } @@ -916,7 +985,7 @@ static struct res_common *alloc_tr(u64 id, enum mlx4_resource type, int slave, ret = alloc_xrcdn_tr(id); break; case RES_FS_RULE: - ret = alloc_fs_rule_tr(id); + ret = alloc_fs_rule_tr(id, extra); break; default: return NULL; @@ -970,8 +1039,10 @@ static int add_res_range(struct mlx4_dev *dev, int slave, u64 base, int count, return 0; undo: - for (--i; i >= base; --i) + for (--i; i >= 0; --i) { rb_erase(&res_arr[i]->node, root); + list_del_init(&res_arr[i]->list); + } spin_unlock_irq(mlx4_tlock(dev)); @@ -985,10 +1056,14 @@ static int add_res_range(struct mlx4_dev *dev, int slave, u64 base, int count, static int remove_qp_ok(struct res_qp *res) { - if (res->com.state == RES_QP_BUSY) + if (res->com.state == RES_QP_BUSY || atomic_read(&res->ref_count) || + !list_empty(&res->mcg_list)) { + pr_err("resource tracker: fail to remove qp, state %d, ref_count %d\n", + res->com.state, atomic_read(&res->ref_count)); return -EBUSY; - else if (res->com.state != RES_QP_RESERVED) + } else if (res->com.state != RES_QP_RESERVED) { return -EPERM; + } return 0; } @@ -1166,7 +1241,7 @@ static int qp_res_start_move_to(struct mlx4_dev *dev, int slave, int qpn, switch (state) { case RES_QP_BUSY: mlx4_dbg(dev, "%s: failed RES_QP, 0x%llx\n", - __func__, (long long)r->com.res_id); + __func__, (unsigned long long)r->com.res_id); err = -EBUSY; break; @@ -1174,7 +1249,7 @@ static int qp_res_start_move_to(struct mlx4_dev *dev, int slave, int qpn, if (r->com.state == RES_QP_MAPPED && !alloc) break; - mlx4_dbg(dev, "failed RES_QP, 0x%llx\n", (long long)r->com.res_id); + mlx4_dbg(dev, "failed RES_QP, 0x%llx\n", (unsigned long long)r->com.res_id); err = -EINVAL; break; @@ -1184,7 +1259,7 @@ static int qp_res_start_move_to(struct mlx4_dev *dev, int slave, int qpn, break; else { mlx4_dbg(dev, "failed RES_QP, 0x%llx\n", - (long long)r->com.res_id); + (unsigned long long)r->com.res_id); err = -EINVAL; } @@ -1464,18 +1539,18 @@ static int qp_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, int align; int base; int qpn; - u8 bf_qp; + u8 flags; switch (op) { case RES_OP_RESERVE: count = get_param_l(&in_param) & 0xffffff; - bf_qp = get_param_l(&in_param) >> 31; + flags = get_param_l(&in_param) >> 24; align = get_param_h(&in_param); err = mlx4_grant_resource(dev, slave, RES_QP, count, 0); if (err) return err; - err = __mlx4_qp_reserve_range(dev, count, align, &base, bf_qp); + err = __mlx4_qp_reserve_range(dev, count, align, &base, flags); if (err) { mlx4_release_resource(dev, slave, RES_QP, count, 0); return err; @@ -1566,7 +1641,7 @@ static int mpt_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, if (err) break; - index = __mlx4_mr_reserve(dev); + index = __mlx4_mpt_reserve(dev); if (index == -1) { mlx4_release_resource(dev, slave, RES_MPT, 1, 0); break; @@ -1576,7 +1651,7 @@ static int mpt_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, err = add_res_range(dev, slave, id, 1, RES_MPT, index); if (err) { mlx4_release_resource(dev, slave, RES_MPT, 1, 0); - __mlx4_mr_release(dev, index); + __mlx4_mpt_release(dev, index); break; } set_param_l(out_param, index); @@ -1589,7 +1664,7 @@ static int mpt_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, if (err) return err; - err = __mlx4_mr_alloc_icm(dev, mpt->key); + err = __mlx4_mpt_alloc_icm(dev, mpt->key); if (err) { res_abort_move(dev, slave, RES_MPT, id); return err; @@ -1867,11 +1942,16 @@ static void rem_slave_vlans(struct mlx4_dev *dev, int slave) } static int vlan_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, - u64 in_param, u64 *out_param, int port) + u64 in_param, u64 *out_param, int in_port) { + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_slave_state *slave_state = priv->mfunc.master.slave_state; int err = -EINVAL; u16 vlan; int vlan_index; + int port; + + port = !in_port ? get_param_l(out_param) : in_port; if (!port) return err; @@ -1879,6 +1959,12 @@ static int vlan_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, if (op != RES_OP_RESERVE_AND_MAP) return err; + /* upstream kernels had NOP for reg/unreg vlan. Continue this. */ + if (!in_port && port > 0 && port <= dev->caps.num_ports) { + slave_state[slave].old_vlan_api = true; + return 0; + } + vlan = (u16) in_param; err = __mlx4_register_vlan(dev, port, vlan, &vlan_index); @@ -1892,7 +1978,7 @@ static int vlan_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, } static int counter_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, - u64 in_param, u64 *out_param) + u64 in_param, u64 *out_param, int port) { u32 index; int err; @@ -1900,23 +1986,9 @@ static int counter_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, if (op != RES_OP_RESERVE) return -EINVAL; - err = mlx4_grant_resource(dev, slave, RES_COUNTER, 1, 0); - if (err) - return err; - - err = __mlx4_counter_alloc(dev, &index); - if (err) { - mlx4_release_resource(dev, slave, RES_COUNTER, 1, 0); - return err; - } - - err = add_res_range(dev, slave, index, 1, RES_COUNTER, 0); - if (err) { - __mlx4_counter_free(dev, index); - mlx4_release_resource(dev, slave, RES_COUNTER, 1, 0); - } else { + err = __mlx4_counter_alloc(dev, slave, port, &index); + if (!err) set_param_l(out_param, index); - } return err; } @@ -1992,7 +2064,8 @@ int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave, case RES_COUNTER: err = counter_alloc_res(dev, slave, vhcr->op_modifier, alop, - vhcr->in_param, &vhcr->out_param); + vhcr->in_param, &vhcr->out_param, + (vhcr->in_modifier >> 8) & 0xFF); break; case RES_XRCD: @@ -2090,7 +2163,7 @@ static int mpt_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, if (err) break; mlx4_release_resource(dev, slave, RES_MPT, 1, 0); - __mlx4_mr_release(dev, index); + __mlx4_mpt_release(dev, index); break; case RES_OP_MAP_ICM: index = get_param_l(&in_param); @@ -2100,7 +2173,7 @@ static int mpt_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, if (err) return err; - __mlx4_mr_free_icm(dev, mpt->key); + __mlx4_mpt_free_icm(dev, mpt->key); res_end_move(dev, slave, RES_MPT, id); return err; break; @@ -2185,10 +2258,14 @@ static int mac_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, static int vlan_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, u64 in_param, u64 *out_param, int port) { + struct mlx4_priv *priv = mlx4_priv(dev); + struct mlx4_slave_state *slave_state = priv->mfunc.master.slave_state; int err = 0; switch (op) { case RES_OP_RESERVE_AND_MAP: + if (slave_state[slave].old_vlan_api == true) + return 0; if (!port) return -EINVAL; vlan_del_from_slave(dev, slave, in_param, port); @@ -2203,23 +2280,18 @@ static int vlan_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, } static int counter_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, - u64 in_param, u64 *out_param) + u64 in_param, u64 *out_param, int port) { int index; - int err; if (op != RES_OP_RESERVE) return -EINVAL; index = get_param_l(&in_param); - err = rem_res_range(dev, slave, index, 1, RES_COUNTER, 0); - if (err) - return err; - __mlx4_counter_free(dev, index); - mlx4_release_resource(dev, slave, RES_COUNTER, 1, 0); + __mlx4_counter_free(dev, slave, port, index); - return err; + return 0; } static int xrcdn_free_res(struct mlx4_dev *dev, int slave, int op, int cmd, @@ -2290,7 +2362,8 @@ int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave, case RES_COUNTER: err = counter_free_res(dev, slave, vhcr->op_modifier, alop, - vhcr->in_param, &vhcr->out_param); + vhcr->in_param, &vhcr->out_param, + (vhcr->in_modifier >> 8) & 0xFF); break; case RES_XRCD: @@ -2319,6 +2392,26 @@ static int mr_get_mtt_size(struct mlx4_mpt_entry *mpt) return be32_to_cpu(mpt->mtt_sz); } +static u32 mr_get_pd(struct mlx4_mpt_entry *mpt) +{ + return be32_to_cpu(mpt->pd_flags) & 0x00ffffff; +} + +static int mr_is_fmr(struct mlx4_mpt_entry *mpt) +{ + return be32_to_cpu(mpt->pd_flags) & MLX4_MPT_PD_FLAG_FAST_REG; +} + +static int mr_is_bind_enabled(struct mlx4_mpt_entry *mpt) +{ + return be32_to_cpu(mpt->flags) & MLX4_MPT_FLAG_BIND_ENABLE; +} + +static int mr_is_region(struct mlx4_mpt_entry *mpt) +{ + return be32_to_cpu(mpt->flags) & MLX4_MPT_FLAG_REGION; +} + static int qp_get_mtt_addr(struct mlx4_qp_context *qpc) { return be32_to_cpu(qpc->mtt_base_addr_l) & 0xfffffff8; @@ -2338,7 +2431,8 @@ static int qp_get_mtt_size(struct mlx4_qp_context *qpc) int log_rq_stride = qpc->rq_size_stride & 7; int srq = (be32_to_cpu(qpc->srqn) >> 24) & 1; int rss = (be32_to_cpu(qpc->flags) >> 13) & 1; - int xrc = (be32_to_cpu(qpc->local_qpn) >> 23) & 1; + u32 ts = (be32_to_cpu(qpc->flags) >> 16) & 0xff; + int xrc = (ts == MLX4_QP_ST_XRC) ? 1 : 0; int sq_size; int rq_size; int total_pages; @@ -2379,12 +2473,43 @@ int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave, int mtt_base = mr_get_mtt_addr(inbox->buf) / dev->caps.mtt_entry_sz; int phys; int id; + u32 pd; + int pd_slave; id = index & mpt_mask(dev); err = mr_res_start_move_to(dev, slave, id, RES_MPT_HW, &mpt); if (err) return err; + /* Currently disable memory windows since this feature isn't tested yet + * under virtualization. + */ + if (!mr_is_region(inbox->buf)) { + err = -ENOSYS; + goto ex_abort; + } + + /* Make sure that the PD bits related to the slave id are zeros. */ + pd = mr_get_pd(inbox->buf); + pd_slave = (pd >> 17) & 0x7f; + if (pd_slave != 0 && pd_slave != slave) { + err = -EPERM; + goto ex_abort; + } + + if (mr_is_fmr(inbox->buf)) { + /* FMR and Bind Enable are forbidden in slave devices. */ + if (mr_is_bind_enabled(inbox->buf)) { + err = -EPERM; + goto ex_abort; + } + /* FMR and Memory Windows are also forbidden. */ + if (!mr_is_region(inbox->buf)) { + err = -EPERM; + goto ex_abort; + } + } + phys = mr_phys_mpt(inbox->buf); if (!phys) { err = get_res(dev, slave, mtt_base, RES_MTT, &mtt); @@ -2534,6 +2659,14 @@ int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave, if (err) return err; qp->local_qpn = local_qpn; + qp->sched_queue = 0; + qp->param3 = 0; + qp->vlan_control = 0; + qp->fvl_rx = 0; + qp->pri_path_fl = 0; + qp->vlan_index = 0; + qp->feup = 0; + qp->qpc_flags = be32_to_cpu(qpc->flags); err = get_res(dev, slave, mtt_base, RES_MTT, &mtt); if (err) @@ -2851,6 +2984,12 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe) if (!priv->mfunc.master.slave_state) return -EINVAL; + /* check for slave valid, slave not PF, and slave active */ + if (slave < 0 || slave >= dev->num_slaves || + slave == dev->caps.function || + !priv->mfunc.master.slave_state[slave].active) + return 0; + event_eq = &priv->mfunc.master.slave_state[slave].event_eq[eqe->type]; /* Create the event only if the slave is registered */ @@ -3288,6 +3427,15 @@ int mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave, { int err; struct mlx4_qp_context *qpc = inbox->buf + 8; + int qpn = vhcr->in_modifier & 0x7fffff; + struct res_qp *qp; + u8 orig_sched_queue; + __be32 orig_param3 = qpc->param3; + u8 orig_vlan_control = qpc->pri_path.vlan_control; + u8 orig_fvl_rx = qpc->pri_path.fvl_rx; + u8 orig_pri_path_fl = qpc->pri_path.fl; + u8 orig_vlan_index = qpc->pri_path.vlan_index; + u8 orig_feup = qpc->pri_path.feup; err = verify_qp_parameters(dev, inbox, QP_TRANS_INIT2RTR, slave); if (err) @@ -3299,11 +3447,40 @@ int mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave, update_pkey_index(dev, slave, inbox); update_gid(dev, inbox, (u8)slave); adjust_proxy_tun_qkey(dev, vhcr, qpc); - err = update_vport_qp_param(dev, inbox, slave); + orig_sched_queue = qpc->pri_path.sched_queue; + + err = get_res(dev, slave, qpn, RES_QP, &qp); if (err) return err; + if (qp->com.from_state != RES_QP_HW) { + err = -EBUSY; + goto out; + } - return mlx4_GEN_QP_wrapper(dev, slave, vhcr, inbox, outbox, cmd); + /* do not modify vport QP params for RSS QPs */ + if (!(qp->qpc_flags & (1 << MLX4_RSS_QPC_FLAG_OFFSET))) { + err = update_vport_qp_param(dev, inbox, slave, qpn); + if (err) + goto out; + } + + err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd); +out: + /* if no error, save sched queue value passed in by VF. This is + * essentially the QOS value provided by the VF. This will be useful + * if we allow dynamic changes from VST back to VGT + */ + if (!err) { + qp->sched_queue = orig_sched_queue; + qp->param3 = orig_param3; + qp->vlan_control = orig_vlan_control; + qp->fvl_rx = orig_fvl_rx; + qp->pri_path_fl = orig_pri_path_fl; + qp->vlan_index = orig_vlan_index; + qp->feup = orig_feup; + } + put_res(dev, slave, qpn, RES_QP); + return err; } int mlx4_RTR2RTS_QP_wrapper(struct mlx4_dev *dev, int slave, @@ -3439,7 +3616,7 @@ static struct res_gid *find_gid(struct mlx4_dev *dev, int slave, static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, u8 *gid, enum mlx4_protocol prot, - enum mlx4_steer_type steer) + enum mlx4_steer_type steer, u64 reg_id) { struct res_gid *res; int err; @@ -3456,6 +3633,7 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, memcpy(res->gid, gid, 16); res->prot = prot; res->steer = steer; + res->reg_id = reg_id; list_add_tail(&res->list, &rqp->mcg_list); err = 0; } @@ -3466,7 +3644,7 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, static int rem_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, u8 *gid, enum mlx4_protocol prot, - enum mlx4_steer_type steer) + enum mlx4_steer_type steer, u64 *reg_id) { struct res_gid *res; int err; @@ -3476,6 +3654,7 @@ static int rem_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, if (!res || res->prot != prot || res->steer != steer) err = -EINVAL; else { + *reg_id = res->reg_id; list_del(&res->list); kfree(res); err = 0; @@ -3485,6 +3664,37 @@ static int rem_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, return err; } +static int qp_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], + int block_loopback, enum mlx4_protocol prot, + enum mlx4_steer_type type, u64 *reg_id) +{ + switch (dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + return mlx4_trans_to_dmfs_attach(dev, qp, gid, gid[5], + block_loopback, prot, + reg_id); + case MLX4_STEERING_MODE_B0: + return mlx4_qp_attach_common(dev, qp, gid, + block_loopback, prot, type); + default: + return -EINVAL; + } +} + +static int qp_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], + enum mlx4_protocol prot, enum mlx4_steer_type type, + u64 reg_id) +{ + switch (dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + return mlx4_flow_detach(dev, reg_id); + case MLX4_STEERING_MODE_B0: + return mlx4_qp_detach_common(dev, qp, gid, prot, type); + default: + return -EINVAL; + } +} + int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, @@ -3497,6 +3707,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, int err; int qpn; struct res_qp *rqp; + u64 reg_id = 0; int attach = vhcr->op_modifier; int block_loopback = vhcr->in_modifier >> 31; u8 steer_type_mask = 2; @@ -3509,30 +3720,32 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, qp.qpn = qpn; if (attach) { - err = add_mcg_res(dev, slave, rqp, gid, prot, type); - if (err) + err = qp_attach(dev, &qp, gid, block_loopback, prot, + type, ®_id); + if (err) { + pr_err("Fail to attach rule to qp 0x%x\n", qpn); goto ex_put; - - err = mlx4_qp_attach_common(dev, &qp, gid, - block_loopback, prot, type); + } + err = add_mcg_res(dev, slave, rqp, gid, prot, type, reg_id); if (err) - goto ex_rem; + goto ex_detach; } else { - err = rem_mcg_res(dev, slave, rqp, gid, prot, type); + err = rem_mcg_res(dev, slave, rqp, gid, prot, type, ®_id); if (err) goto ex_put; - err = mlx4_qp_detach_common(dev, &qp, gid, prot, type); + + err = qp_detach(dev, &qp, gid, prot, type, reg_id); + if (err) + pr_err("Fail to detach rule from qp 0x%x reg_id = 0x%llx\n", + qpn, (unsigned long long)reg_id); } - put_res(dev, slave, qpn, RES_QP); - return 0; + return err; -ex_rem: - /* ignore error return below, already in error */ - (void) rem_mcg_res(dev, slave, rqp, gid, prot, type); +ex_detach: + qp_detach(dev, &qp, gid, prot, type, reg_id); ex_put: put_res(dev, slave, qpn, RES_QP); - return err; } @@ -3540,7 +3753,6 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, * MAC validation for Flow Steering rules. * VF can attach rules only with a mac address which is assigned to it. */ - static int validate_eth_header_mac(int slave, struct _rule_hw *eth_header, struct list_head *rlist) { @@ -3633,6 +3845,8 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_resource_tracker *tracker = &priv->mfunc.master.res_tracker; struct list_head *rlist = &tracker->slave_list[slave].res_list[RES_MAC]; int err; + int qpn; + struct res_qp *rqp; struct mlx4_net_trans_rule_hw_ctrl *ctrl; struct _rule_hw *rule_header; int header_id; @@ -3642,13 +3856,21 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, return -EOPNOTSUPP; ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf; + qpn = be32_to_cpu(ctrl->qpn) & 0xffffff; + err = get_res(dev, slave, qpn, RES_QP, &rqp); + if (err) { + pr_err("Steering rule with qpn 0x%x rejected.\n", qpn); + return err; + } rule_header = (struct _rule_hw *)(ctrl + 1); header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id)); switch (header_id) { case MLX4_NET_TRANS_RULE_ID_ETH: - if (validate_eth_header_mac(slave, rule_header, rlist)) - return -EINVAL; + if (validate_eth_header_mac(slave, rule_header, rlist)) { + err = -EINVAL; + goto err_put; + } break; case MLX4_NET_TRANS_RULE_ID_IB: break; @@ -3656,14 +3878,17 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, case MLX4_NET_TRANS_RULE_ID_TCP: case MLX4_NET_TRANS_RULE_ID_UDP: pr_warn("Can't attach FS rule without L2 headers, adding L2 header.\n"); - if (add_eth_header(dev, slave, inbox, rlist, header_id)) - return -EINVAL; + if (add_eth_header(dev, slave, inbox, rlist, header_id)) { + err = -EINVAL; + goto err_put; + } vhcr->in_modifier += sizeof(struct mlx4_net_trans_rule_hw_eth) >> 2; break; default: pr_err("Corrupted mailbox.\n"); - return -EINVAL; + err = -EINVAL; + goto err_put; } err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param, @@ -3671,16 +3896,20 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); if (err) - return err; + goto err_put; - err = add_res_range(dev, slave, vhcr->out_param, 1, RES_FS_RULE, 0); + err = add_res_range(dev, slave, vhcr->out_param, 1, RES_FS_RULE, qpn); if (err) { mlx4_err(dev, "Fail to add flow steering resources.\n "); /* detach rule*/ mlx4_cmd(dev, vhcr->out_param, 0, 0, - MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A, + MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); + goto err_put; } + atomic_inc(&rqp->ref_count); +err_put: + put_res(dev, slave, qpn, RES_QP); return err; } @@ -3691,20 +3920,38 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_cmd_info *cmd) { int err; + struct res_qp *rqp; + struct res_fs_rule *rrule; if (dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED) return -EOPNOTSUPP; - err = rem_res_range(dev, slave, vhcr->in_param, 1, RES_FS_RULE, 0); - if (err) { - mlx4_err(dev, "Fail to remove flow steering resources.\n "); + err = get_res(dev, slave, vhcr->in_param, RES_FS_RULE, &rrule); + if (err) + return err; + /* Release the rule form busy state before removal */ + put_res(dev, slave, vhcr->in_param, RES_FS_RULE); + err = get_res(dev, slave, rrule->qpn, RES_QP, &rqp); + if (err) return err; - } err = mlx4_cmd(dev, vhcr->in_param, 0, 0, MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); + if (!err) { + err = rem_res_range(dev, slave, vhcr->in_param, 1, RES_FS_RULE, + 0); + atomic_dec(&rqp->ref_count); + + if (err) { + mlx4_err(dev, "Fail to remove flow steering resources.\n "); + goto out; + } + } + +out: + put_res(dev, slave, rrule->qpn, RES_QP); return err; } @@ -3719,14 +3966,9 @@ int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_cmd_info *cmd) { int err; - int index = vhcr->in_modifier & 0xffff; - - err = get_res(dev, slave, index, RES_COUNTER, NULL); - if (err) - return err; err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd); - put_res(dev, slave, index, RES_COUNTER); + return err; } @@ -3737,9 +3979,16 @@ static void detach_qp(struct mlx4_dev *dev, int slave, struct res_qp *rqp) struct mlx4_qp qp; /* dummy for calling attach/detach */ list_for_each_entry_safe(rgid, tmp, &rqp->mcg_list, list) { - qp.qpn = rqp->local_qpn; - (void) mlx4_qp_detach_common(dev, &qp, rgid->gid, rgid->prot, - rgid->steer); + switch (dev->caps.steering_mode) { + case MLX4_STEERING_MODE_DEVICE_MANAGED: + mlx4_flow_detach(dev, rgid->reg_id); + break; + case MLX4_STEERING_MODE_B0: + qp.qpn = rqp->local_qpn; + (void) mlx4_qp_detach_common(dev, &qp, rgid->gid, + rgid->prot, rgid->steer); + break; + } list_del(&rgid->list); kfree(rgid); } @@ -3766,7 +4015,7 @@ static int _move_all_busy(struct mlx4_dev *dev, int slave, mlx4_dbg(dev, "%s id 0x%llx is busy\n", ResourceType(type), - (long long)r->res_id); + (unsigned long long)r->res_id); ++busy; } else { r->from_state = r->state; @@ -3834,6 +4083,11 @@ static void rem_slave_qps(struct mlx4_dev *dev, int slave) &tracker->res_tree[RES_QP]); list_del(&qp->com.list); spin_unlock_irq(mlx4_tlock(dev)); + if (!valid_reserved(dev, slave, qpn)) { + __mlx4_qp_release_range(dev, qpn, 1); + mlx4_release_resource(dev, slave, + RES_QP, 1, 0); + } kfree(qp); state = 0; break; @@ -3905,6 +4159,8 @@ static void rem_slave_srqs(struct mlx4_dev *dev, int slave) &tracker->res_tree[RES_SRQ]); list_del(&srq->com.list); spin_unlock_irq(mlx4_tlock(dev)); + mlx4_release_resource(dev, slave, + RES_SRQ, 1, 0); kfree(srq); state = 0; break; @@ -3971,6 +4227,8 @@ static void rem_slave_cqs(struct mlx4_dev *dev, int slave) &tracker->res_tree[RES_CQ]); list_del(&cq->com.list); spin_unlock_irq(mlx4_tlock(dev)); + mlx4_release_resource(dev, slave, + RES_CQ, 1, 0); kfree(cq); state = 0; break; @@ -4028,18 +4286,20 @@ static void rem_slave_mrs(struct mlx4_dev *dev, int slave) while (state != 0) { switch (state) { case RES_MPT_RESERVED: - __mlx4_mr_release(dev, mpt->key); + __mlx4_mpt_release(dev, mpt->key); spin_lock_irq(mlx4_tlock(dev)); rb_erase(&mpt->com.node, &tracker->res_tree[RES_MPT]); list_del(&mpt->com.list); spin_unlock_irq(mlx4_tlock(dev)); + mlx4_release_resource(dev, slave, + RES_MPT, 1, 0); kfree(mpt); state = 0; break; case RES_MPT_MAPPED: - __mlx4_mr_free_icm(dev, mpt->key); + __mlx4_mpt_free_icm(dev, mpt->key); state = RES_MPT_RESERVED; break; @@ -4103,6 +4363,8 @@ static void rem_slave_mtts(struct mlx4_dev *dev, int slave) &tracker->res_tree[RES_MTT]); list_del(&mtt->com.list); spin_unlock_irq(mlx4_tlock(dev)); + mlx4_release_resource(dev, slave, RES_MTT, + 1 << mtt->order, 0); kfree(mtt); state = 0; break; @@ -4238,32 +4500,7 @@ static void rem_slave_eqs(struct mlx4_dev *dev, int slave) static void rem_slave_counters(struct mlx4_dev *dev, int slave) { - struct mlx4_priv *priv = mlx4_priv(dev); - struct mlx4_resource_tracker *tracker = &priv->mfunc.master.res_tracker; - struct list_head *counter_list = - &tracker->slave_list[slave].res_list[RES_COUNTER]; - struct res_counter *counter; - struct res_counter *tmp; - int err; - int index; - - err = move_all_busy(dev, slave, RES_COUNTER); - if (err) - mlx4_warn(dev, "rem_slave_counters: Could not move all counters to " - "busy for slave %d\n", slave); - - spin_lock_irq(mlx4_tlock(dev)); - list_for_each_entry_safe(counter, tmp, counter_list, com.list) { - if (counter->com.owner == slave) { - index = counter->com.res_id; - rb_erase(&counter->com.node, - &tracker->res_tree[RES_COUNTER]); - list_del(&counter->com.list); - kfree(counter); - __mlx4_counter_free(dev, index); - } - } - spin_unlock_irq(mlx4_tlock(dev)); + __mlx4_slave_counters_free(dev, slave); } static void rem_slave_xrcdns(struct mlx4_dev *dev, int slave) @@ -4302,6 +4539,7 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave) mutex_lock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex); rem_slave_macs(dev, slave); rem_slave_vlans(dev, slave); + rem_slave_fs_rule(dev, slave); rem_slave_qps(dev, slave); rem_slave_srqs(dev, slave); rem_slave_cqs(dev, slave); @@ -4310,6 +4548,139 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave) rem_slave_mtts(dev, slave); rem_slave_counters(dev, slave); rem_slave_xrcdns(dev, slave); - rem_slave_fs_rule(dev, slave); mutex_unlock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex); } + +void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work) +{ + struct mlx4_vf_immed_vlan_work *work = + container_of(_work, struct mlx4_vf_immed_vlan_work, work); + struct mlx4_cmd_mailbox *mailbox; + struct mlx4_update_qp_context *upd_context; + struct mlx4_dev *dev = &work->priv->dev; + struct mlx4_resource_tracker *tracker = + &work->priv->mfunc.master.res_tracker; + struct list_head *qp_list = + &tracker->slave_list[work->slave].res_list[RES_QP]; + struct res_qp *qp; + struct res_qp *tmp; + u64 qp_path_mask_vlan_ctrl = + ((1ULL << MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_UNTAGGED) | + (1ULL << MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_1P) | + (1ULL << MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_TAGGED) | + (1ULL << MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_UNTAGGED) | + (1ULL << MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_1P) | + (1ULL << MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_TAGGED)); + + u64 qp_path_mask = ((1ULL << MLX4_UPD_QP_PATH_MASK_VLAN_INDEX) | + (1ULL << MLX4_UPD_QP_PATH_MASK_FVL) | + (1ULL << MLX4_UPD_QP_PATH_MASK_CV) | + (1ULL << MLX4_UPD_QP_PATH_MASK_ETH_HIDE_CQE_VLAN) | + (1ULL << MLX4_UPD_QP_PATH_MASK_FEUP) | + (1ULL << MLX4_UPD_QP_PATH_MASK_FVL_RX) | + (1ULL << MLX4_UPD_QP_PATH_MASK_SCHED_QUEUE)); + + int err; + int port, errors = 0; + u8 vlan_control; + + if (mlx4_is_slave(dev)) { + mlx4_warn(dev, "Trying to update-qp in slave %d\n", + work->slave); + goto out; + } + + mailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(mailbox)) + goto out; + + if (!work->vlan_id) + vlan_control = MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED | + MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED; + else + vlan_control = MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED | + MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED | + MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED; + + upd_context = mailbox->buf; + upd_context->qp_mask = cpu_to_be64(MLX4_UPD_QP_MASK_VSD); + + spin_lock_irq(mlx4_tlock(dev)); + list_for_each_entry_safe(qp, tmp, qp_list, com.list) { + spin_unlock_irq(mlx4_tlock(dev)); + if (qp->com.owner == work->slave) { + if (qp->com.from_state != RES_QP_HW || + !qp->sched_queue || /* no INIT2RTR trans yet */ + mlx4_is_qp_reserved(dev, qp->local_qpn) || + qp->qpc_flags & (1 << MLX4_RSS_QPC_FLAG_OFFSET)) { + spin_lock_irq(mlx4_tlock(dev)); + continue; + } + port = (qp->sched_queue >> 6 & 1) + 1; + if (port != work->port) { + spin_lock_irq(mlx4_tlock(dev)); + continue; + } + if (MLX4_QP_ST_RC == ((qp->qpc_flags >> 16) & 0xff)) + upd_context->primary_addr_path_mask = cpu_to_be64(qp_path_mask); + else + upd_context->primary_addr_path_mask = + cpu_to_be64(qp_path_mask | qp_path_mask_vlan_ctrl); + if (work->vlan_id == MLX4_VGT) { + upd_context->qp_context.param3 = qp->param3; + upd_context->qp_context.pri_path.vlan_control = qp->vlan_control; + upd_context->qp_context.pri_path.fvl_rx = qp->fvl_rx; + upd_context->qp_context.pri_path.vlan_index = qp->vlan_index; + upd_context->qp_context.pri_path.fl = qp->pri_path_fl; + upd_context->qp_context.pri_path.feup = qp->feup; + upd_context->qp_context.pri_path.sched_queue = + qp->sched_queue; + } else { + upd_context->qp_context.param3 = qp->param3 & ~cpu_to_be32(MLX4_STRIP_VLAN); + upd_context->qp_context.pri_path.vlan_control = vlan_control; + upd_context->qp_context.pri_path.vlan_index = work->vlan_ix; + upd_context->qp_context.pri_path.fvl_rx = + qp->fvl_rx | MLX4_FVL_RX_FORCE_ETH_VLAN; + upd_context->qp_context.pri_path.fl = + qp->pri_path_fl | MLX4_FL_CV | MLX4_FL_ETH_HIDE_CQE_VLAN; + upd_context->qp_context.pri_path.feup = + qp->feup | MLX4_FEUP_FORCE_ETH_UP | MLX4_FVL_FORCE_ETH_VLAN; + upd_context->qp_context.pri_path.sched_queue = + qp->sched_queue & 0xC7; + upd_context->qp_context.pri_path.sched_queue |= + ((work->qos & 0x7) << 3); + } + + err = mlx4_cmd(dev, mailbox->dma, + qp->local_qpn & 0xffffff, + 0, MLX4_CMD_UPDATE_QP, + MLX4_CMD_TIME_CLASS_C, MLX4_CMD_NATIVE); + if (err) { + mlx4_info(dev, "UPDATE_QP failed for slave %d, " + "port %d, qpn %d (%d)\n", + work->slave, port, qp->local_qpn, + err); + errors++; + } + } + spin_lock_irq(mlx4_tlock(dev)); + } + spin_unlock_irq(mlx4_tlock(dev)); + mlx4_free_cmd_mailbox(dev, mailbox); + + if (errors) + mlx4_err(dev, "%d UPDATE_QP failures for slave %d, port %d\n", + errors, work->slave, work->port); + + /* unregister previous vlan_id if needed and we had no errors + * while updating the QPs + */ + if (work->flags & MLX4_VF_IMMED_VLAN_FLAG_VLAN && !errors && + NO_INDX != work->orig_vlan_ix) + __mlx4_unregister_vlan(&work->priv->dev, work->port, + work->orig_vlan_id); +out: + kfree(work); + return; +} + diff --git a/sys/ofed/drivers/net/mlx4/sense.c b/sys/ofed/drivers/net/mlx4/sense.c index 5e1665e15227..3615e6513e9f 100644 --- a/sys/ofed/drivers/net/mlx4/sense.c +++ b/sys/ofed/drivers/net/mlx4/sense.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -53,7 +53,7 @@ int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port, } if (out_param > 2) { - mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", (long long)out_param); + mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", (unsigned long long)out_param); return -EINVAL; } @@ -108,9 +108,8 @@ static void mlx4_sense_port(struct work_struct *work) sense_again: mutex_unlock(&priv->port_mutex); - if (sense->resched) - queue_delayed_work(sense->sense_wq , &sense->sense_poll, - round_jiffies(MLX4_SENSE_RANGE)); + queue_delayed_work(mlx4_wq , &sense->sense_poll, + round_jiffies_relative(MLX4_SENSE_RANGE)); } void mlx4_start_sense(struct mlx4_dev *dev) @@ -121,40 +120,24 @@ void mlx4_start_sense(struct mlx4_dev *dev) if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) return; - sense->resched = 1; - queue_delayed_work(sense->sense_wq , &sense->sense_poll, - round_jiffies(MLX4_SENSE_RANGE)); + queue_delayed_work(mlx4_wq , &sense->sense_poll, + round_jiffies_relative(MLX4_SENSE_RANGE)); } void mlx4_stop_sense(struct mlx4_dev *dev) { - mlx4_priv(dev)->sense.resched = 0; + cancel_delayed_work_sync(&mlx4_priv(dev)->sense.sense_poll); } -void mlx4_sense_cleanup(struct mlx4_dev *dev) -{ - mlx4_stop_sense(dev); - cancel_delayed_work(&mlx4_priv(dev)->sense.sense_poll); - destroy_workqueue(mlx4_priv(dev)->sense.sense_wq); -} - - -int mlx4_sense_init(struct mlx4_dev *dev) +void mlx4_sense_init(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_sense *sense = &priv->sense; int port; - sense->dev = dev; - sense->sense_wq = create_singlethread_workqueue("mlx4_sense"); - if (!sense->sense_wq) - return -ENOMEM; - for (port = 1; port <= dev->caps.num_ports; port++) sense->do_sense_port[port] = 1; INIT_DEFERRABLE_WORK(&sense->sense_poll, mlx4_sense_port); - - return 0; } diff --git a/sys/ofed/drivers/net/mlx4/srq.c b/sys/ofed/drivers/net/mlx4/srq.c index c37f68286565..fcb6255c7e62 100644 --- a/sys/ofed/drivers/net/mlx4/srq.c +++ b/sys/ofed/drivers/net/mlx4/srq.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. + * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -32,6 +32,8 @@ */ #include +#include +#include #include #include "mlx4.h" @@ -113,7 +115,7 @@ int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn) mlx4_table_put(dev, &srq_table->table, *srqn); err_out: - mlx4_bitmap_free(&srq_table->bitmap, *srqn); + mlx4_bitmap_free(&srq_table->bitmap, *srqn, MLX4_NO_RR); return err; } @@ -141,7 +143,7 @@ void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn) mlx4_table_put(dev, &srq_table->cmpt_table, srqn); mlx4_table_put(dev, &srq_table->table, srqn); - mlx4_bitmap_free(&srq_table->bitmap, srqn); + mlx4_bitmap_free(&srq_table->bitmap, srqn, MLX4_NO_RR); } static void mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn) @@ -295,3 +297,18 @@ void mlx4_cleanup_srq_table(struct mlx4_dev *dev) return; mlx4_bitmap_cleanup(&mlx4_priv(dev)->srq_table.bitmap); } + +struct mlx4_srq *mlx4_srq_lookup(struct mlx4_dev *dev, u32 srqn) +{ + struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table; + struct mlx4_srq *srq; + unsigned long flags; + + spin_lock_irqsave(&srq_table->lock, flags); + srq = radix_tree_lookup(&srq_table->tree, + srqn & (dev->caps.num_srqs - 1)); + spin_unlock_irqrestore(&srq_table->lock, flags); + + return srq; +} +EXPORT_SYMBOL_GPL(mlx4_srq_lookup); diff --git a/sys/ofed/drivers/net/mlx4/sys_tune.c b/sys/ofed/drivers/net/mlx4/sys_tune.c index 0675e90eacf5..87eb30e6ccfe 100644 --- a/sys/ofed/drivers/net/mlx4/sys_tune.c +++ b/sys/ofed/drivers/net/mlx4/sys_tune.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Mellanox Technologies. All rights reserved. + * Copyright (c) 2010, 2014 Mellanox Technologies. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -39,8 +39,6 @@ #if defined(CONFIG_X86) && defined(CONFIG_APM_MODULE) - - /* Each CPU is put into a group. In most cases, the group number is * equal to the CPU number of one of the CPUs in the group. The * exception is group NR_CPUS which is the default group. This is diff --git a/sys/ofed/drivers/net/mlx4/utils.c b/sys/ofed/drivers/net/mlx4/utils.c new file mode 100644 index 000000000000..2444ec5961c9 --- /dev/null +++ b/sys/ofed/drivers/net/mlx4/utils.c @@ -0,0 +1,189 @@ +/* $OpenBSD: if_trunk.c,v 1.30 2007/01/31 06:20:19 reyk Exp $ */ + +/* + * Copyright (c) 2005, 2006 Reyk Floeter + * Copyright (c) 2007 Andrew Thompson + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet.h" +#include "opt_inet6.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 + +#if defined(INET) || defined(INET6) +#include +#endif +#ifdef INET +#include +#include +#include +#endif + +#ifdef INET6 +#include +#include +#include +#endif + +#include + +#include "utils.h" + +/* XXX this code should be factored out */ +/* XXX copied from if_lagg.c */ + +static const void * +mlx4_en_gethdr(struct mbuf *m, u_int off, u_int len, void *buf) +{ + if (m->m_pkthdr.len < (off + len)) { + return (NULL); + } else if (m->m_len < (off + len)) { + m_copydata(m, off, len, buf); + return (buf); + } + return (mtod(m, char *) + off); +} + +uint32_t +mlx4_en_hashmbuf(uint32_t flags, struct mbuf *m, uint32_t key) +{ + uint16_t etype; + uint32_t p = key; + int off; + struct ether_header *eh; + const struct ether_vlan_header *vlan; +#ifdef INET + const struct ip *ip; + const uint32_t *ports; + int iphlen; +#endif +#ifdef INET6 + const struct ip6_hdr *ip6; + uint32_t flow; +#endif + union { +#ifdef INET + struct ip ip; +#endif +#ifdef INET6 + struct ip6_hdr ip6; +#endif + struct ether_vlan_header vlan; + uint32_t port; + } buf; + + + off = sizeof(*eh); + if (m->m_len < off) + goto out; + eh = mtod(m, struct ether_header *); + etype = ntohs(eh->ether_type); + if (flags & MLX4_F_HASHL2) { + p = hash32_buf(&eh->ether_shost, ETHER_ADDR_LEN, p); + p = hash32_buf(&eh->ether_dhost, ETHER_ADDR_LEN, p); + } + + /* Special handling for encapsulating VLAN frames */ + if ((m->m_flags & M_VLANTAG) && (flags & MLX4_F_HASHL2)) { + p = hash32_buf(&m->m_pkthdr.ether_vtag, + sizeof(m->m_pkthdr.ether_vtag), p); + } else if (etype == ETHERTYPE_VLAN) { + vlan = mlx4_en_gethdr(m, off, sizeof(*vlan), &buf); + if (vlan == NULL) + goto out; + + if (flags & MLX4_F_HASHL2) + p = hash32_buf(&vlan->evl_tag, sizeof(vlan->evl_tag), p); + etype = ntohs(vlan->evl_proto); + off += sizeof(*vlan) - sizeof(*eh); + } + + switch (etype) { +#ifdef INET + case ETHERTYPE_IP: + ip = mlx4_en_gethdr(m, off, sizeof(*ip), &buf); + if (ip == NULL) + goto out; + + if (flags & MLX4_F_HASHL3) { + p = hash32_buf(&ip->ip_src, sizeof(struct in_addr), p); + p = hash32_buf(&ip->ip_dst, sizeof(struct in_addr), p); + } + if (!(flags & MLX4_F_HASHL4)) + break; + switch (ip->ip_p) { + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_SCTP: + iphlen = ip->ip_hl << 2; + if (iphlen < sizeof(*ip)) + break; + off += iphlen; + ports = mlx4_en_gethdr(m, off, sizeof(*ports), &buf); + if (ports == NULL) + break; + p = hash32_buf(ports, sizeof(*ports), p); + break; + } + break; +#endif +#ifdef INET6 + case ETHERTYPE_IPV6: + if (!(flags & MLX4_F_HASHL3)) + break; + ip6 = mlx4_en_gethdr(m, off, sizeof(*ip6), &buf); + if (ip6 == NULL) + goto out; + + p = hash32_buf(&ip6->ip6_src, sizeof(struct in6_addr), p); + p = hash32_buf(&ip6->ip6_dst, sizeof(struct in6_addr), p); + flow = ip6->ip6_flow & IPV6_FLOWLABEL_MASK; + p = hash32_buf(&flow, sizeof(flow), p); /* IPv6 flow label */ + break; +#endif + } +out: + return (p); +} diff --git a/sys/ofed/drivers/net/mlx4/utils.h b/sys/ofed/drivers/net/mlx4/utils.h new file mode 100644 index 000000000000..51a654ccb1cc --- /dev/null +++ b/sys/ofed/drivers/net/mlx4/utils.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 Mellanox Technologies Ltd. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - 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. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _MLX4_UTILS_H_ +#define _MLX4_UTILS_H_ + +/* Lagg flags */ +#define MLX4_F_HASHL2 0x00000001 /* hash layer 2 */ +#define MLX4_F_HASHL3 0x00000002 /* hash layer 3 */ +#define MLX4_F_HASHL4 0x00000004 /* hash layer 4 */ +#define MLX4_F_HASHMASK 0x00000007 + +uint32_t mlx4_en_hashmbuf(uint32_t flags, struct mbuf *m, uint32_t key); + +#endif /* _MLX4_UTILS_H_ */ diff --git a/sys/ofed/include/linux/linux_compat.c b/sys/ofed/include/linux/linux_compat.c index e8e73c065403..c2fb4d7d7abf 100644 --- a/sys/ofed/include/linux/linux_compat.c +++ b/sys/ofed/include/linux/linux_compat.c @@ -568,14 +568,35 @@ linux_file_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *cred, return (error); } +static int +linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, + struct thread *td) +{ + + return (EOPNOTSUPP); +} + +static int +linux_file_fill_kinfo(struct file *fp, struct kinfo_file *kif, + struct filedesc *fdp) +{ + + return (0); +} + struct fileops linuxfileops = { .fo_read = linux_file_read, - .fo_poll = linux_file_poll, - .fo_close = linux_file_close, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, .fo_ioctl = linux_file_ioctl, + .fo_poll = linux_file_poll, + .fo_kqfilter = invfo_kqfilter, + .fo_stat = linux_file_stat, + .fo_close = linux_file_close, .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = linux_file_fill_kinfo, }; /* diff --git a/sys/ofed/include/linux/mlx4/cmd.h b/sys/ofed/include/linux/mlx4/cmd.h index d83ee3a53453..e2d41bcf417a 100644 --- a/sys/ofed/include/linux/mlx4/cmd.h +++ b/sys/ofed/include/linux/mlx4/cmd.h @@ -34,6 +34,7 @@ #define MLX4_CMD_H #include +#include enum { /* initialization and general commands */ @@ -111,6 +112,7 @@ enum { MLX4_CMD_INIT2INIT_QP = 0x2d, MLX4_CMD_SUSPEND_QP = 0x32, MLX4_CMD_UNSUSPEND_QP = 0x33, + MLX4_CMD_UPDATE_QP = 0x61, /* special QP and management commands */ MLX4_CMD_CONF_SPECIAL_QP = 0x23, MLX4_CMD_MAD_IFC = 0x24, @@ -152,10 +154,6 @@ enum { MLX4_CMD_QUERY_IF_STAT = 0X54, MLX4_CMD_SET_IF_STAT = 0X55, - /* set port opcode modifiers */ - MLX4_SET_PORT_PRIO2TC = 0x8, - MLX4_SET_PORT_SCHEDULER = 0x9, - /* register/delete flow steering network rules */ MLX4_QP_FLOW_STEERING_ATTACH = 0x65, MLX4_QP_FLOW_STEERING_DETACH = 0x66, @@ -175,12 +173,14 @@ enum { enum { /* set port opcode modifiers */ - MLX4_SET_PORT_GENERAL = 0x0, - MLX4_SET_PORT_RQP_CALC = 0x1, - MLX4_SET_PORT_MAC_TABLE = 0x2, - MLX4_SET_PORT_VLAN_TABLE = 0x3, - MLX4_SET_PORT_PRIO_MAP = 0x4, - MLX4_SET_PORT_GID_TABLE = 0x5, + MLX4_SET_PORT_GENERAL = 0x0, + MLX4_SET_PORT_RQP_CALC = 0x1, + MLX4_SET_PORT_MAC_TABLE = 0x2, + MLX4_SET_PORT_VLAN_TABLE = 0x3, + MLX4_SET_PORT_PRIO_MAP = 0x4, + MLX4_SET_PORT_GID_TABLE = 0x5, + MLX4_SET_PORT_PRIO2TC = 0x8, + MLX4_SET_PORT_SCHEDULER = 0x9 }; enum { @@ -237,7 +237,21 @@ u32 mlx4_comm_get_version(void); int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u8 *mac); int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos); int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting); +int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int link_state); +int mlx4_get_vf_link_state(struct mlx4_dev *dev, int port, int vf); +/* + * mlx4_get_slave_default_vlan - + * retrun true if VST ( default vlan) + * if VST will fill vlan & qos (if not NULL) + */ +bool mlx4_get_slave_default_vlan(struct mlx4_dev *dev, int port, int slave, u16 *vlan, u8 *qos); +enum { + IFLA_VF_LINK_STATE_AUTO, /* link state of the uplink */ + IFLA_VF_LINK_STATE_ENABLE, /* link always up */ + IFLA_VF_LINK_STATE_DISABLE, /* link always down */ + __IFLA_VF_LINK_STATE_MAX, +}; #define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8) diff --git a/sys/ofed/include/linux/mlx4/cq.h b/sys/ofed/include/linux/mlx4/cq.h index 08216692452e..ed6bec188edb 100644 --- a/sys/ofed/include/linux/mlx4/cq.h +++ b/sys/ofed/include/linux/mlx4/cq.h @@ -42,17 +42,31 @@ struct mlx4_cqe { __be32 vlan_my_qpn; __be32 immed_rss_invalid; __be32 g_mlpath_rqpn; - __be16 sl_vid; - __be16 rlid; - __be16 status; - u8 ipv6_ext_mask; - u8 badfcs_enc; + union { + struct { + union { + struct { + __be16 sl_vid; + __be16 rlid; + }; + __be32 timestamp_16_47; + }; + __be16 status; + u8 ipv6_ext_mask; + u8 badfcs_enc; + }; + struct { + __be16 reserved1; + u8 smac[6]; + }; + }; __be32 byte_cnt; __be16 wqe_index; __be16 checksum; - u8 reserved[3]; + u8 reserved2[1]; + __be16 timestamp_0_15; u8 owner_sr_opcode; -}; +} __packed; struct mlx4_err_cqe { __be32 my_qpn; @@ -83,6 +97,7 @@ struct mlx4_ts_cqe { enum { MLX4_CQE_VLAN_PRESENT_MASK = 1 << 29, MLX4_CQE_QPN_MASK = 0xffffff, + MLX4_CQE_VID_MASK = 0xfff, }; enum { diff --git a/sys/ofed/include/linux/mlx4/device.h b/sys/ofed/include/linux/mlx4/device.h index 2828ef073120..a1beedbc092f 100644 --- a/sys/ofed/include/linux/mlx4/device.h +++ b/sys/ofed/include/linux/mlx4/device.h @@ -36,11 +36,12 @@ #include #include #include -//#include /* XXX SK Probably not needed in freeBSD XXX */ - +#include +#include +#include #include -#include /* XXX SK ported to freeBSD */ +#include #define MAX_MSIX_P_PORT 17 #define MAX_MSIX 64 @@ -61,9 +62,7 @@ #define MLX4_RATELIMIT_1G_UNITS 4 /* 1 Gbps */ #define MLX4_RATELIMIT_DEFAULT 0x00ff - - -#define MLX4_LEAST_ATTACHED_VECTOR 0xffffffff +#define CORE_CLOCK_MASK 0xffffffffffffULL enum { MLX4_FLAG_MSI_X = 1 << 0, @@ -71,6 +70,8 @@ enum { MLX4_FLAG_MASTER = 1 << 2, MLX4_FLAG_SLAVE = 1 << 3, MLX4_FLAG_SRIOV = 1 << 4, + MLX4_FLAG_DEV_NUM_STR = 1 << 5, + MLX4_FLAG_OLD_REG_MAC = 1 << 6, }; enum { @@ -91,7 +92,8 @@ enum { #define MLX4_RESERVED_QKEY_MASK (0xFFFF0000) enum { - MLX4_BOARD_ID_LEN = 64 + MLX4_BOARD_ID_LEN = 64, + MLX4_VSD_LEN = 208 }; enum { @@ -159,13 +161,13 @@ enum { MLX4_DEV_CAP_FLAG_UDP_RSS = 1LL << 40, MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41, MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42, + MLX4_DEV_CAP_FLAG_CROSS_CHANNEL = 1LL << 44, MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48, MLX4_DEV_CAP_FLAG_COUNTERS_EXT = 1LL << 49, MLX4_DEV_CAP_FLAG_SET_PORT_ETH_SCHED = 1LL << 53, MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55, MLX4_DEV_CAP_FLAG_FAST_DROP = 1LL << 57, MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59, - MLX4_DEV_CAP_FLAG_ESWITCH_SUPPORT = 1LL << 60, MLX4_DEV_CAP_FLAG_64B_EQE = 1LL << 61, MLX4_DEV_CAP_FLAG_64B_CQE = 1LL << 62 }; @@ -174,7 +176,34 @@ enum { MLX4_DEV_CAP_FLAG2_RSS = 1LL << 0, MLX4_DEV_CAP_FLAG2_RSS_TOP = 1LL << 1, MLX4_DEV_CAP_FLAG2_RSS_XOR = 1LL << 2, - MLX4_DEV_CAP_FLAG2_FS_EN = 1LL << 3 + MLX4_DEV_CAP_FLAG2_FS_EN = 1LL << 3, + MLX4_DEV_CAP_FLAG2_FSM = 1LL << 4, + MLX4_DEV_CAP_FLAG2_VLAN_CONTROL = 1LL << 5, + MLX4_DEV_CAP_FLAG2_UPDATE_QP = 1LL << 6, + MLX4_DEV_CAP_FLAG2_LB_SRC_CHK = 1LL << 7, + MLX4_DEV_CAP_FLAG2_DMFS_IPOIB = 1LL << 8, + MLX4_DEV_CAP_FLAG2_ETS_CFG = 1LL << 9, + MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP = 1LL << 10, + MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN = 1LL << 11, + MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 12, + MLX4_DEV_CAP_FLAG2_TS = 1LL << 13, + MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW = 1LL << 14 +}; + +/* bit enums for an 8-bit flags field indicating special use + * QPs which require special handling in qp_reserve_range. + * Currently, this only includes QPs used by the ETH interface, + * where we expect to use blueflame. These QPs must not have + * bits 6 and 7 set in their qp number. + * + * This enum may use only bits 0..7. + */ +enum { + MLX4_RESERVE_BF_QP = 1 << 7, +}; + +enum { + MLX4_DEV_CAP_CQ_FLAG_IO = 1 << 0 }; enum { @@ -190,22 +219,11 @@ enum { MLX4_FUNC_CAP_64B_EQE_CQE = 1L << 0 }; -/* bit enums for an 8-bit flags field indicating special use - * QPs which require special handling in qp_reserve_range. - * Currently, this only includes QPs used by the ETH interface, - * where we expect to use blueflame. These QPs must not have - * bits 6 and 7 set in their qp number. - * - * This enum may use only bits 0..7. - */ -enum { - MLX4_RESERVE_BF_QP = 1 << 7, -}; - #define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90) enum { + MLX4_BMME_FLAG_WIN_TYPE_2B = 1 << 1, MLX4_BMME_FLAG_LOCAL_INV = 1 << 6, MLX4_BMME_FLAG_REMOTE_INV = 1 << 7, MLX4_BMME_FLAG_TYPE_2_WIN = 1 << 9, @@ -238,6 +256,7 @@ enum mlx4_event { MLX4_EVENT_TYPE_FATAL_WARNING = 0x1b, MLX4_EVENT_TYPE_FLR_EVENT = 0x1c, MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT = 0x1d, + MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT = 0x3e, MLX4_EVENT_TYPE_NONE = 0xff, }; @@ -246,6 +265,11 @@ enum { MLX4_PORT_CHANGE_SUBTYPE_ACTIVE = 4 }; +enum { + MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_BAD_CABLE = 1, + MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_UNSUPPORTED_CABLE = 2, +}; + enum { MLX4_FATAL_WARNING_SUBTYPE_WARMING = 0, }; @@ -274,7 +298,8 @@ enum { MLX4_PERM_LOCAL_WRITE = 1 << 11, MLX4_PERM_REMOTE_READ = 1 << 12, MLX4_PERM_REMOTE_WRITE = 1 << 13, - MLX4_PERM_ATOMIC = 1 << 14 + MLX4_PERM_ATOMIC = 1 << 14, + MLX4_PERM_BIND_MW = 1 << 15, }; enum { @@ -335,7 +360,8 @@ enum mlx4_port_type { MLX4_PORT_TYPE_NONE = 0, MLX4_PORT_TYPE_IB = 1, MLX4_PORT_TYPE_ETH = 2, - MLX4_PORT_TYPE_AUTO = 3 + MLX4_PORT_TYPE_AUTO = 3, + MLX4_PORT_TYPE_NA = 4 }; enum mlx4_special_vlan_idx { @@ -435,7 +461,7 @@ struct mlx4_caps { int comp_pool; int num_mpts; int max_fmr_maps; - int num_mtts; + u64 num_mtts; int fmr_reserved_mtts; int reserved_mtts; int reserved_mrws; @@ -476,6 +502,7 @@ struct mlx4_caps { u8 port_ib_mtu[MLX4_MAX_PORTS + 1]; u16 sqp_demux; u32 sync_qp; + u32 cq_flags; u32 eqe_size; u32 cqe_size; u8 eqe_factor; @@ -485,6 +512,7 @@ struct mlx4_caps { u16 hca_core_clock; u32 max_basic_counters; u32 max_extended_counters; + u8 def_counter_index[MLX4_MAX_PORTS + 1]; }; struct mlx4_buf_list { @@ -548,6 +576,18 @@ struct mlx4_mr { int enabled; }; +enum mlx4_mw_type { + MLX4_MW_TYPE_1 = 1, + MLX4_MW_TYPE_2 = 2, +}; + +struct mlx4_mw { + u32 key; + u32 pd; + enum mlx4_mw_type type; + int enabled; +}; + struct mlx4_fmr { struct mlx4_mr mr; struct mlx4_mpt_entry *mpt; @@ -641,7 +681,8 @@ struct mlx4_eth_av { u8 hop_limit; __be32 sl_tclass_flowlabel; u8 dgid[16]; - u32 reserved4[2]; + u8 s_mac[6]; + u8 reserved4[2]; __be16 vlan; u8 mac[6]; }; @@ -731,6 +772,8 @@ struct mlx4_dev { struct radix_tree_root qp_table_tree; u8 rev_id; char board_id[MLX4_BOARD_ID_LEN]; + u16 vsd_vendor_id; + char vsd[MLX4_VSD_LEN]; int num_vfs; int numa_node; int oper_log_mgm_entry_size; @@ -738,6 +781,12 @@ struct mlx4_dev { u64 regid_allmulti_array[MLX4_MAX_PORTS + 1]; }; +struct mlx4_clock_params { + u64 offset; + u8 bar; + u8 size; +}; + struct mlx4_eqe { u8 reserved1; u8 type; @@ -807,6 +856,11 @@ struct mlx4_eqe { } __packed tbl_change_info; } params; } __packed port_mgmt_change; + struct { + u8 reserved[3]; + u8 port; + u32 reserved1[5]; + } __packed bad_cable; } event; u8 slave_id; u8 reserved3[2]; @@ -842,6 +896,8 @@ struct mlx4_init_port_param { #define MLX4_INVALID_SLAVE_ID 0xFF +#define MLX4_SINK_COUNTER_INDEX 0xff + void handle_port_mgmt_change_event(struct work_struct *work); static inline int mlx4_master_func_num(struct mlx4_dev *dev) @@ -915,8 +971,12 @@ u64 mlx4_mtt_addr(struct mlx4_dev *dev, struct mlx4_mtt *mtt); int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access, int npages, int page_shift, struct mlx4_mr *mr); -void mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr); +int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr); int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr); +int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type, + struct mlx4_mw *mw); +void mlx4_mw_free(struct mlx4_dev *dev, struct mlx4_mw *mw); +int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw); int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, int start_index, int npages, u64 *page_list); int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, @@ -936,7 +996,7 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, - int *base, u8 bf_qp); + int *base, u8 flags); void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp); @@ -990,12 +1050,14 @@ static inline int map_hw_to_sw_id(u16 header_id) } return -EINVAL; } + enum mlx4_net_trans_promisc_mode { - MLX4_FS_REGULAR = 0, - MLX4_FS_ALL_DEFAULT = 1, - MLX4_FS_MC_DEFAULT = 3, - MLX4_FS_UC_SNIFFER = 4, - MLX4_FS_MC_SNIFFER = 5, + MLX4_FS_REGULAR = 1, + MLX4_FS_ALL_DEFAULT, + MLX4_FS_MC_DEFAULT, + MLX4_FS_UC_SNIFFER, + MLX4_FS_MC_SNIFFER, + MLX4_FS_MODE_NUM, /* should be last */ }; struct mlx4_spec_eth { @@ -1024,7 +1086,7 @@ struct mlx4_spec_ipv4 { }; struct mlx4_spec_ib { - __be32 r_u_qpn; + __be32 l3_qpn; __be32 qpn_msk; u8 dst_gid[16]; u8 dst_gid_msk[16]; @@ -1057,6 +1119,87 @@ struct mlx4_net_trans_rule { u32 qpn; }; +struct mlx4_net_trans_rule_hw_ctrl { + __be16 prio; + u8 type; + u8 flags; + u8 rsvd1; + u8 funcid; + u8 vep; + u8 port; + __be32 qpn; + __be32 rsvd2; +}; + +struct mlx4_net_trans_rule_hw_ib { + u8 size; + u8 rsvd1; + __be16 id; + u32 rsvd2; + __be32 l3_qpn; + __be32 qpn_mask; + u8 dst_gid[16]; + u8 dst_gid_msk[16]; +} __packed; + +struct mlx4_net_trans_rule_hw_eth { + u8 size; + u8 rsvd; + __be16 id; + u8 rsvd1[6]; + u8 dst_mac[6]; + u16 rsvd2; + u8 dst_mac_msk[6]; + u16 rsvd3; + u8 src_mac[6]; + u16 rsvd4; + u8 src_mac_msk[6]; + u8 rsvd5; + u8 ether_type_enable; + __be16 ether_type; + __be16 vlan_tag_msk; + __be16 vlan_tag; +} __packed; + +struct mlx4_net_trans_rule_hw_tcp_udp { + u8 size; + u8 rsvd; + __be16 id; + __be16 rsvd1[3]; + __be16 dst_port; + __be16 rsvd2; + __be16 dst_port_msk; + __be16 rsvd3; + __be16 src_port; + __be16 rsvd4; + __be16 src_port_msk; +} __packed; + +struct mlx4_net_trans_rule_hw_ipv4 { + u8 size; + u8 rsvd; + __be16 id; + __be32 rsvd1; + __be32 dst_ip; + __be32 dst_ip_msk; + __be32 src_ip; + __be32 src_ip_msk; +} __packed; + +struct _rule_hw { + union { + struct { + u8 size; + u8 rsvd; + __be16 id; + }; + struct mlx4_net_trans_rule_hw_eth eth; + struct mlx4_net_trans_rule_hw_ib ib; + struct mlx4_net_trans_rule_hw_ipv4 ipv4; + struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp; + }; +}; + int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, u32 qpn, enum mlx4_net_trans_promisc_mode mode); int mlx4_flow_steer_promisc_remove(struct mlx4_dev *dev, u8 port, @@ -1071,7 +1214,7 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac); void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac); int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port); int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac); -void mlx4_set_stats_bitmap(struct mlx4_dev *dev, u64 *stats_bitmap); +void mlx4_set_stats_bitmap(struct mlx4_dev *dev, unsigned long *stats_bitmap); int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, @@ -1097,18 +1240,23 @@ int mlx4_query_diag_counters(struct mlx4_dev *mlx4_dev, int array_length, u32 counter_out[]); int mlx4_test_interrupts(struct mlx4_dev *dev); -int mlx4_assign_eq(struct mlx4_dev *dev, char *name, int *vector); +int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector); void mlx4_release_eq(struct mlx4_dev *dev, int vec); int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port); int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port); -int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx); -void mlx4_counter_free(struct mlx4_dev *dev, u32 idx); +int mlx4_counter_alloc(struct mlx4_dev *dev, u8 port, u32 *idx); +void mlx4_counter_free(struct mlx4_dev *dev, u8 port, u32 idx); int mlx4_flow_attach(struct mlx4_dev *dev, struct mlx4_net_trans_rule *rule, u64 *reg_id); int mlx4_flow_detach(struct mlx4_dev *dev, u64 reg_id); +int map_sw_to_hw_steering_mode(struct mlx4_dev *dev, + enum mlx4_net_trans_promisc_mode flow_type); +int map_sw_to_hw_steering_id(struct mlx4_dev *dev, + enum mlx4_net_trans_rule_id id); +int hw_rule_sz(struct mlx4_dev *dev, enum mlx4_net_trans_rule_id id); void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port, int i, int val); @@ -1118,7 +1266,7 @@ int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey); int mlx4_is_slave_active(struct mlx4_dev *dev, int slave); int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port); int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port); -int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr); +int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr, u16 lid, u8 sl); int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port, u8 port_subtype_change); enum slave_port_state mlx4_get_slave_port_state(struct mlx4_dev *dev, int slave, u8 port); int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave, u8 port, int event, enum slave_port_gen_event *gen_event); @@ -1130,6 +1278,8 @@ int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id, u int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, u32 max_range_qpn); -cycle_t mlx4_read_clock(struct mlx4_dev *dev); +int mlx4_read_clock(struct mlx4_dev *dev); +int mlx4_get_internal_clock_params(struct mlx4_dev *dev, + struct mlx4_clock_params *params); #endif /* MLX4_DEVICE_H */ diff --git a/sys/ofed/include/linux/mlx4/driver.h b/sys/ofed/include/linux/mlx4/driver.h index 8235a97d0244..2a7fd21ed4d9 100644 --- a/sys/ofed/include/linux/mlx4/driver.h +++ b/sys/ofed/include/linux/mlx4/driver.h @@ -51,32 +51,72 @@ enum mlx4_dev_event { MLX4_DEV_EVENT_SLAVE_SHUTDOWN, }; -enum mlx4_query_reply { - MLX4_QUERY_NOT_MINE = -1, - MLX4_QUERY_MINE_NOPORT = 0 -}; - -enum mlx4_mcast_prot { - MLX4_MCAST_PROT_IB = 0, - MLX4_MCAST_PROT_EN = 1, -}; - struct mlx4_interface { void * (*add) (struct mlx4_dev *dev); void (*remove)(struct mlx4_dev *dev, void *context); void (*event) (struct mlx4_dev *dev, void *context, enum mlx4_dev_event event, unsigned long param); void * (*get_dev)(struct mlx4_dev *dev, void *context, u8 port); - - enum mlx4_query_reply (*query) (void *context, void *); struct list_head list; enum mlx4_protocol protocol; }; +enum { + MLX4_MAX_DEVICES = 32, + MLX4_DEVS_TBL_SIZE = MLX4_MAX_DEVICES + 1, + MLX4_DBDF2VAL_STR_SIZE = 512, + MLX4_STR_NAME_SIZE = 64, + MLX4_MAX_BDF_VALS = 2, + MLX4_ENDOF_TBL = -1LL +}; + +struct mlx4_dbdf2val { + u64 dbdf; + int val[MLX4_MAX_BDF_VALS]; +}; + +struct mlx4_range { + int min; + int max; +}; + +/* + * mlx4_dbdf2val_lst struct holds all the data needed to convert + * dbdf-to-value-list string into dbdf-to-value table. + * dbdf-to-value-list string is a comma separated list of dbdf-to-value strings. + * the format of dbdf-to-value string is: "[mmmm:]bb:dd.f-v1[;v2]" + * mmmm - Domain number (optional) + * bb - Bus number + * dd - device number + * f - Function number + * v1 - First value related to the domain-bus-device-function. + * v2 - Second value related to the domain-bus-device-function (optional). + * bb, dd - Two hexadecimal digits without preceding 0x. + * mmmm - Four hexadecimal digits without preceding 0x. + * f - One hexadecimal without preceding 0x. + * v1,v2 - Number with normal convention (e.g 100, 0xd3). + * dbdf-to-value-list string format: + * "[mmmm:]bb:dd.f-v1[;v2],[mmmm:]bb:dd.f-v1[;v2],..." + * + */ +struct mlx4_dbdf2val_lst { + char name[MLX4_STR_NAME_SIZE]; /* String name */ + char str[MLX4_DBDF2VAL_STR_SIZE]; /* dbdf2val list str */ + struct mlx4_dbdf2val tbl[MLX4_DEVS_TBL_SIZE];/* dbdf to value table */ + int num_vals; /* # of vals per dbdf */ + int def_val[MLX4_MAX_BDF_VALS]; /* Default values */ + struct mlx4_range range; /* Valid values range */ +}; + +int mlx4_fill_dbdf2val_tbl(struct mlx4_dbdf2val_lst *dbdf2val_lst); +int mlx4_get_val(struct mlx4_dbdf2val *tbl, struct pci_dev *pdev, int idx, + int *val); + int mlx4_register_interface(struct mlx4_interface *intf); void mlx4_unregister_interface(struct mlx4_interface *intf); -void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port); +void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, + int port); #ifndef ETH_ALEN #define ETH_ALEN 6 diff --git a/sys/ofed/include/linux/mlx4/qp.h b/sys/ofed/include/linux/mlx4/qp.h index 2d45a9d624fe..8ab9bb4722c6 100644 --- a/sys/ofed/include/linux/mlx4/qp.h +++ b/sys/ofed/include/linux/mlx4/qp.h @@ -104,9 +104,9 @@ enum { MLX4_QP_BIT_RWE = 1 << 14, MLX4_QP_BIT_RAE = 1 << 13, MLX4_QP_BIT_RIC = 1 << 4, - MLX4_QP_BIT_COLL_SYNC_RQ = 1 << 2, - MLX4_QP_BIT_COLL_SYNC_SQ = 1 << 1, - MLX4_QP_BIT_COLL_MASTER = 1 << 0 + MLX4_QP_BIT_COLL_SYNC_RQ = 1 << 2, + MLX4_QP_BIT_COLL_SYNC_SQ = 1 << 1, + MLX4_QP_BIT_COLL_MASTER = 1 << 0 }; enum { @@ -138,7 +138,7 @@ struct mlx4_rss_context { struct mlx4_qp_path { u8 fl; - u8 reserved1[1]; + u8 vlan_control; u8 disable_pkey_check; u8 pkey_index; u8 counter_index; @@ -153,11 +153,35 @@ struct mlx4_qp_path { u8 sched_queue; u8 vlan_index; u8 feup; - u8 reserved3; + u8 fvl_rx; u8 reserved4[2]; u8 dmac[6]; }; +enum { /* fl */ + MLX4_FL_CV = 1 << 6, + MLX4_FL_ETH_HIDE_CQE_VLAN = 1 << 2, + MLX4_FL_ETH_SRC_CHECK_MC_LB = 1 << 1, + MLX4_FL_ETH_SRC_CHECK_UC_LB = 1 << 0, +}; +enum { /* vlan_control */ + MLX4_VLAN_CTRL_ETH_SRC_CHECK_IF_COUNTER = 1 << 7, + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED = 1 << 6, + MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED = 1 << 2, + MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED = 1 << 1,/* 802.1p priorty tag*/ + MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED = 1 << 0 +}; + +enum { /* feup */ + MLX4_FEUP_FORCE_ETH_UP = 1 << 6, /* force Eth UP */ + MLX4_FSM_FORCE_ETH_SRC_MAC = 1 << 5, /* force Source MAC */ + MLX4_FVL_FORCE_ETH_VLAN = 1 << 3 /* force Eth vlan */ +}; + +enum { /* fvl_rx */ + MLX4_FVL_RX_FORCE_ETH_VLAN = 1 << 0 /* enforce Eth rx vlan */ +}; + struct mlx4_qp_context { __be32 flags; __be32 pd; @@ -197,6 +221,45 @@ struct mlx4_qp_context { u32 reserved5[10]; }; +struct mlx4_update_qp_context { + __be64 qp_mask; + __be64 primary_addr_path_mask; + __be64 secondary_addr_path_mask; + u64 reserved1; + struct mlx4_qp_context qp_context; + u64 reserved2[58]; +}; + +enum { + MLX4_UPD_QP_MASK_PM_STATE = 32, + MLX4_UPD_QP_MASK_VSD = 33, +}; + +enum { + MLX4_UPD_QP_PATH_MASK_PKEY_INDEX = 0 + 32, + MLX4_UPD_QP_PATH_MASK_FSM = 1 + 32, + MLX4_UPD_QP_PATH_MASK_MAC_INDEX = 2 + 32, + MLX4_UPD_QP_PATH_MASK_FVL = 3 + 32, + MLX4_UPD_QP_PATH_MASK_CV = 4 + 32, + MLX4_UPD_QP_PATH_MASK_VLAN_INDEX = 5 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_HIDE_CQE_VLAN = 6 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_UNTAGGED = 7 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_1P = 8 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_TX_BLOCK_TAGGED = 9 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_UNTAGGED = 10 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_1P = 11 + 32, + MLX4_UPD_QP_PATH_MASK_ETH_RX_BLOCK_TAGGED = 12 + 32, + MLX4_UPD_QP_PATH_MASK_FEUP = 13 + 32, + MLX4_UPD_QP_PATH_MASK_SCHED_QUEUE = 14 + 32, + MLX4_UPD_QP_PATH_MASK_IF_COUNTER_INDEX = 15 + 32, + MLX4_UPD_QP_PATH_MASK_FVL_RX = 16 + 32, +}; + +enum { /* param3 */ + MLX4_STRIP_VLAN = 1 << 30 +}; + + /* Which firmware version adds support for NEC (NoErrorCompletion) bit */ #define MLX4_FW_VER_WQE_CTRL_NEC mlx4_fw_ver(2, 2, 232) @@ -277,6 +340,11 @@ struct mlx4_wqe_lso_seg { __be32 header[0]; }; +enum mlx4_wqe_bind_seg_flags2 { + MLX4_WQE_BIND_TYPE_2 = (1<<31), + MLX4_WQE_BIND_ZERO_BASED = (1<<30), +}; + struct mlx4_wqe_bind_seg { __be32 flags1; __be32 flags2; @@ -289,9 +357,9 @@ struct mlx4_wqe_bind_seg { enum { MLX4_WQE_FMR_PERM_LOCAL_READ = 1 << 27, MLX4_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28, - MLX4_WQE_FMR_PERM_REMOTE_READ = 1 << 29, - MLX4_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30, - MLX4_WQE_FMR_PERM_ATOMIC = 1 << 31 + MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_READ = 1 << 29, + MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_WRITE = 1 << 30, + MLX4_WQE_FMR_AND_BIND_PERM_ATOMIC = 1 << 31 }; struct mlx4_wqe_fmr_seg { @@ -316,12 +384,10 @@ struct mlx4_wqe_fmr_ext_seg { }; struct mlx4_wqe_local_inval_seg { - __be32 flags; - u32 reserved1; + u64 reserved1; __be32 mem_key; - u32 reserved2[2]; - __be32 guest_id; - __be64 pa; + u32 reserved2; + u64 reserved3[2]; }; struct mlx4_wqe_raddr_seg { diff --git a/sys/ofed/include/linux/mlx4/srq.h b/sys/ofed/include/linux/mlx4/srq.h index 799a0697a383..192e0f7784f2 100644 --- a/sys/ofed/include/linux/mlx4/srq.h +++ b/sys/ofed/include/linux/mlx4/srq.h @@ -39,4 +39,6 @@ struct mlx4_wqe_srq_next_seg { u32 reserved2[3]; }; +struct mlx4_srq *mlx4_srq_lookup(struct mlx4_dev *dev, u32 srqn); + #endif /* MLX4_SRQ_H */ diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 4d16833cf0f1..bf461381cfbd 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -281,30 +282,27 @@ struct fcrypt { int sesn; }; -static int cryptof_rw(struct file *fp, struct uio *uio, - struct ucred *cred, int flags, struct thread *); -static int cryptof_truncate(struct file *, off_t, struct ucred *, - struct thread *); static int cryptof_ioctl(struct file *, u_long, void *, struct ucred *, struct thread *); -static int cryptof_poll(struct file *, int, struct ucred *, struct thread *); -static int cryptof_kqfilter(struct file *, struct knote *); static int cryptof_stat(struct file *, struct stat *, struct ucred *, struct thread *); static int cryptof_close(struct file *, struct thread *); +static int cryptof_fill_kinfo(struct file *, struct kinfo_file *, + struct filedesc *); static struct fileops cryptofops = { - .fo_read = cryptof_rw, - .fo_write = cryptof_rw, - .fo_truncate = cryptof_truncate, + .fo_read = invfo_rdwr, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, .fo_ioctl = cryptof_ioctl, - .fo_poll = cryptof_poll, - .fo_kqfilter = cryptof_kqfilter, + .fo_poll = invfo_poll, + .fo_kqfilter = invfo_kqfilter, .fo_stat = cryptof_stat, .fo_close = cryptof_close, .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_fill_kinfo = cryptof_fill_kinfo, }; static struct csession *csefind(struct fcrypt *, u_int); @@ -320,29 +318,6 @@ static int cryptodev_op(struct csession *, struct crypt_op *, static int cryptodev_key(struct crypt_kop *); static int cryptodev_find(struct crypt_find_op *); -static int -cryptof_rw( - struct file *fp, - struct uio *uio, - struct ucred *active_cred, - int flags, - struct thread *td) -{ - - return (EIO); -} - -static int -cryptof_truncate( - struct file *fp, - off_t length, - struct ucred *active_cred, - struct thread *td) -{ - - return (EINVAL); -} - /* * Check a crypto identifier to see if it requested * a software device/driver. This can be done either @@ -959,26 +934,6 @@ cryptodev_find(struct crypt_find_op *find) return (0); } -/* ARGSUSED */ -static int -cryptof_poll( - struct file *fp, - int events, - struct ucred *active_cred, - struct thread *td) -{ - - return (0); -} - -/* ARGSUSED */ -static int -cryptof_kqfilter(struct file *fp, struct knote *kn) -{ - - return (0); -} - /* ARGSUSED */ static int cryptof_stat( @@ -1007,6 +962,14 @@ cryptof_close(struct file *fp, struct thread *td) return 0; } +static int +cryptof_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + + kif->kf_type = KF_TYPE_CRYPTO; + return (0); +} + static struct csession * csefind(struct fcrypt *fcr, u_int ses) { diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c deleted file mode 100644 index fd65d7247e46..000000000000 --- a/sys/pc98/cbus/fdc.c +++ /dev/null @@ -1,2596 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Don Ahn. - * - * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu) - * aided by the Linux floppy driver modifications from David Bateman - * (dbateman@eng.uts.edu.au). - * - * Copyright (c) 1993, 1994 by - * jc@irbs.UUCP (John Capo) - * vak@zebub.msk.su (Serge Vakulenko) - * ache@astral.msk.su (Andrew A. Chernov) - * - * Copyright (c) 1993, 1994, 1995 by - * joerg_wunsch@uriah.sax.de (Joerg Wunsch) - * dufault@hda.com (Peter Dufault) - * - * Copyright (c) 2001 Joerg Wunsch, - * joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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. - * - * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 - * $FreeBSD$ - */ - -#include "opt_fdc.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef PC98 -#include -#include -#include -#include -#else -#include -#include -#include -#include -#include -#endif - -#define FDBIO_FORMAT BIO_CMD2 - -/* configuration flags for fdc */ -#define FDC_NO_FIFO (1 << 2) /* do not enable FIFO */ - -/* - * Stop retrying after this many DMA overruns. Since each retry takes - * one revolution, with 300 rpm., 25 retries take approximately 5 - * seconds which the read attempt will block in case the DMA overrun - * is persistent. - */ -#define FDC_DMAOV_MAX 25 - -/* - * Timeout value for the PIO loops to wait until the FDC main status - * register matches our expectations (request for master, direction - * bit). This is supposed to be a number of microseconds, although - * timing might actually not be very accurate. - * - * Timeouts of 100 msec are believed to be required for some broken - * (old) hardware. - */ -#define FDSTS_TIMEOUT 100000 - -/* - * Number of subdevices that can be used for different density types. - */ -#ifdef PC98 -#define NUMDENS 12 -#else -#define NUMDENS 16 -#endif - -#define FDBIO_RDSECTID BIO_CMD1 - -/* - * List of native drive densities. Order must match enum fd_drivetype - * in . Upon attaching the drive, each of the - * programmable subdevices is initialized with the native density - * definition. - */ -#ifdef PC98 -static struct fd_type fd_native_types[] = -{ -{ 0 }, /* FDT_NONE */ -{ 0 }, /* FDT_360K */ -{ 15,2,0xFF,0x1B,80,2400,0,2,0x54,1,0,FL_MFM }, /* FDT_12M */ -{ 0 }, /* FDT_720K */ -{ 18,2,0xFF,0x1B,80,2880,2,2,0x54,1,0,FL_MFM }, /* FDT_144M */ -{ 0 }, /* FDT_288M */ -}; - -static struct fd_type fd_searchlist_12m[] = { -{ 15,2,0xFF,0x1B,80,2400,0,2,0x54,1,0,FL_MFM }, /* 1.2M */ -#if 0 -{ 10,2,0xFF,0x10,82,1640,1,2,0x30,1,0,FL_MFM }, /* 820K */ -{ 10,2,0xFF,0x10,80,1600,1,2,0x30,1,0,FL_MFM }, /* 800K */ -#endif -{ 9,2,0xFF,0x20,80,1440,1,2,0x50,1,0,FL_MFM }, /* 720K */ -{ 9,2,0xFF,0x20,40, 720,1,2,0x50,1,0,FL_MFM|FL_2STEP },/* 360K */ -{ 8,2,0xFF,0x2A,80,1280,1,2,0x50,1,0,FL_MFM }, /* 640K */ -{ 8,3,0xFF,0x35,77,1232,0,2,0x74,1,0,FL_MFM }, /* 1.23M 1024/sec */ -#if 0 -{ 8,3,0xFF,0x35,80,1280,0,2,0x74,1,0,FL_MFM }, /* 1.28M 1024/sec */ -#endif -}; -static struct fd_type fd_searchlist_144m[] = { -#if 0 -{ 21,2,0xFF,0x04,82,3444,2,2,0x0C,2,0,FL_MFM }, /* 1.72M in 3mode */ -{ 18,2,0xFF,0x1B,82,2952,2,2,0x54,1,0,FL_MFM }, /* 1.48M in 3mode */ -#endif -{ 18,2,0xFF,0x1B,80,2880,2,2,0x54,1,0,FL_MFM }, /* 1.44M in 3mode */ -{ 15,2,0xFF,0x1B,80,2400,0,2,0x54,1,0,FL_MFM }, /* 1.2M */ -#if 0 -{ 10,2,0xFF,0x10,82,1640,1,2,0x30,1,0,FL_MFM }, /* 820K */ -{ 10,2,0xFF,0x10,80,1600,1,2,0x30,1,0,FL_MFM }, /* 800K */ -#endif -{ 9,2,0xFF,0x20,80,1440,1,2,0x50,1,0,FL_MFM }, /* 720K */ -{ 9,2,0xFF,0x20,40, 720,1,2,0x50,1,0,FL_MFM|FL_2STEP },/* 360K */ -{ 8,2,0xFF,0x2A,80,1280,1,2,0x50,1,0,FL_MFM }, /* 640K */ -{ 8,3,0xFF,0x35,77,1232,0,2,0x74,1,0,FL_MFM }, /* 1.23M 1024/sec */ -#if 0 -{ 8,3,0xFF,0x35,80,1280,0,2,0x74,1,0,FL_MFM }, /* 1.28M 1024/sec */ -{ 9,3,0xFF,0x35,82,1476,0,2,0x47,1,0,FL_MFM }, /* 1.48M 1024/sec 9sec */ -{ 10,3,0xFF,0x1B,82,1640,2,2,0x54,1,0,FL_MFM }, /* 1.64M in 3mode - Reserve */ -#endif -}; -#else /* PC98 */ -static struct fd_type fd_native_types[] = -{ -{ 0 }, /* FDT_NONE */ -{ 9,2,0xFF,0x2A,40, 720,FDC_250KBPS,2,0x50,1,0,FL_MFM }, /* FDT_360K */ -{ 15,2,0xFF,0x1B,80,2400,FDC_500KBPS,2,0x54,1,0,FL_MFM }, /* FDT_12M */ -{ 9,2,0xFF,0x20,80,1440,FDC_250KBPS,2,0x50,1,0,FL_MFM }, /* FDT_720K */ -{ 18,2,0xFF,0x1B,80,2880,FDC_500KBPS,2,0x6C,1,0,FL_MFM }, /* FDT_144M */ -#if 0 /* we currently don't handle 2.88 MB */ -{ 36,2,0xFF,0x1B,80,5760,FDC_1MBPS, 2,0x4C,1,1,FL_MFM|FL_PERPND } /*FDT_288M*/ -#else -{ 18,2,0xFF,0x1B,80,2880,FDC_500KBPS,2,0x6C,1,0,FL_MFM }, /* FDT_144M */ -#endif -}; - -/* - * 360 KB 5.25" and 720 KB 3.5" drives don't have automatic density - * selection, they just start out with their native density (or lose). - * So 1.2 MB 5.25", 1.44 MB 3.5", and 2.88 MB 3.5" drives have their - * respective lists of densities to search for. - */ -static struct fd_type fd_searchlist_12m[] = { -{ 15,2,0xFF,0x1B,80,2400,FDC_500KBPS,2,0x54,1,0,FL_MFM }, /* 1.2M */ -{ 9,2,0xFF,0x23,40, 720,FDC_300KBPS,2,0x50,1,0,FL_MFM|FL_2STEP }, /* 360K */ -{ 9,2,0xFF,0x20,80,1440,FDC_300KBPS,2,0x50,1,0,FL_MFM }, /* 720K */ -}; - -static struct fd_type fd_searchlist_144m[] = { -{ 18,2,0xFF,0x1B,80,2880,FDC_500KBPS,2,0x6C,1,0,FL_MFM }, /* 1.44M */ -{ 9,2,0xFF,0x20,80,1440,FDC_250KBPS,2,0x50,1,0,FL_MFM }, /* 720K */ -}; - -/* We search for 1.44M first since this is the most common case. */ -static struct fd_type fd_searchlist_288m[] = { -{ 18,2,0xFF,0x1B,80,2880,FDC_500KBPS,2,0x6C,1,0,FL_MFM }, /* 1.44M */ -#if 0 -{ 36,2,0xFF,0x1B,80,5760,FDC_1MBPS, 2,0x4C,1,1,FL_MFM|FL_PERPND } /* 2.88M */ -#endif -{ 9,2,0xFF,0x20,80,1440,FDC_250KBPS,2,0x50,1,0,FL_MFM }, /* 720K */ -}; -#endif /* PC98 */ - -#define MAX_SEC_SIZE (128 << 3) -#define MAX_CYLINDER 85 /* some people really stress their drives - * up to cyl 82 */ -#define MAX_HEAD 1 - -devclass_t fdc_devclass; - -/* - * Per drive structure (softc). - */ -struct fd_data { - struct fdc_data *fdc; /* pointer to controller structure */ - int fdsu; /* this units number on this controller */ - enum fd_drivetype type; /* drive type */ - struct fd_type *ft; /* pointer to current type descriptor */ - struct fd_type fts[NUMDENS]; /* type descriptors */ - int flags; -#define FD_OPEN 0x01 /* it's open */ -#define FD_NONBLOCK 0x02 /* O_NONBLOCK set */ -#define FD_ACTIVE 0x04 /* it's active */ -#define FD_MOTOR 0x08 /* motor should be on */ -#define FD_MOTOR_WAIT 0x10 /* motor coming up */ -#define FD_UA 0x20 /* force unit attention */ - int skip; - int hddrv; -#define FD_NO_TRACK -2 - int track; /* where we think the head is */ - int options; /* user configurable options, see fdcio.h */ - struct callout_handle toffhandle; - struct callout_handle tohandle; - struct devstat *device_stats; - struct cdev *masterdev; - device_t dev; - fdu_t fdu; -#ifdef PC98 - int pc98_trans; -#endif -}; - -struct fdc_ivars { - int fdunit; - int fdtype; -}; - -static devclass_t fd_devclass; - -/* configuration flags for fd */ -#define FD_TYPEMASK 0x0f /* drive type, matches enum - * fd_drivetype; on i386 machines, if - * given as 0, use RTC type for fd0 - * and fd1 */ -#define FD_DTYPE(flags) ((flags) & FD_TYPEMASK) -#define FD_NO_CHLINE 0x10 /* drive does not support changeline - * aka. unit attention */ -#define FD_NO_PROBE 0x20 /* don't probe drive (seek test), just - * assume it is there */ - -/* - * Throughout this file the following conventions will be used: - * - * fd is a pointer to the fd_data struct for the drive in question - * fdc is a pointer to the fdc_data struct for the controller - * fdu is the floppy drive unit number - * fdcu is the floppy controller unit number - * fdsu is the floppy drive unit number on that controller. (sub-unit) - */ - -/* - * Function declarations, same (chaotic) order as they appear in the - * file. Re-ordering is too late now, it would only obfuscate the - * diffs against old and offspring versions (like the PC98 one). - * - * Anyone adding functions here, please keep this sequence the same - * as below -- makes locating a particular function in the body much - * easier. - */ -static u_int8_t fdsts_rd(fdc_p); -static void fddata_wr(fdc_p, u_int8_t); -static u_int8_t fddata_rd(fdc_p); -static int fdc_err(struct fdc_data *, const char *); -static int enable_fifo(fdc_p fdc); -static int fd_sense_drive_status(fdc_p, int *); -static int fd_sense_int(fdc_p, int *, int *); -static int fd_read_status(fdc_p); -static int fd_probe(device_t); -static int fd_attach(device_t); -static int fd_detach(device_t); -static void set_motor(struct fdc_data *, int, int); -# define TURNON 1 -# define TURNOFF 0 -static timeout_t fd_turnoff; -static timeout_t fd_motor_on; -static void fd_turnon(struct fd_data *); -static void fdc_reset(fdc_p); -static int fd_in(struct fdc_data *, int *); -static int out_fdc(struct fdc_data *, int); -static d_open_t fdopen; -static d_close_t fdclose; -static d_strategy_t fdstrategy; -static void fdstart(struct fdc_data *); -static timeout_t fd_iotimeout; -static timeout_t fd_pseudointr; -static driver_intr_t fdc_intr; -static int fdcpio(fdc_p, long, caddr_t, u_int); -static int fdautoselect(struct cdev *); -static int fdstate(struct fdc_data *); -static int retrier(struct fdc_data *); -static void fdbiodone(struct bio *); -static int fdmisccmd(struct cdev *, u_int, void *); -static d_ioctl_t fdioctl; - -static int fifo_threshold = 8; /* XXX: should be accessible via sysctl */ - -#ifdef FDC_DEBUG -/* CAUTION: fd_debug causes huge amounts of logging output */ -static int volatile fd_debug = 0; -#define TRACE0(arg) do { if (fd_debug) printf(arg); } while (0) -#define TRACE1(arg1, arg2) do { if (fd_debug) printf(arg1, arg2); } while (0) -#else /* FDC_DEBUG */ -#define TRACE0(arg) do { } while (0) -#define TRACE1(arg1, arg2) do { } while (0) -#endif /* FDC_DEBUG */ - -/* - * Bus space handling (access to low-level IO). - */ -#ifndef PC98 -void -fdout_wr(fdc_p fdc, u_int8_t v) -{ - bus_space_write_1(fdc->portt, fdc->porth, FDOUT+fdc->port_off, v); -} -#endif - -static u_int8_t -fdsts_rd(fdc_p fdc) -{ - return bus_space_read_1(fdc->portt, fdc->porth, FDSTS+fdc->port_off); -} - -static void -fddata_wr(fdc_p fdc, u_int8_t v) -{ - bus_space_write_1(fdc->portt, fdc->porth, FDDATA+fdc->port_off, v); -} - -static u_int8_t -fddata_rd(fdc_p fdc) -{ - return bus_space_read_1(fdc->portt, fdc->porth, FDDATA+fdc->port_off); -} - -#ifdef PC98 -static void -fdctl_wr(fdc_p fdc, u_int8_t v) -{ - bus_space_write_1(fdc->portt, fdc->porth, FDCTL, v); -} -#endif - -#ifndef PC98 -static u_int8_t -fdin_rd(fdc_p fdc) -{ - return bus_space_read_1(fdc->portt, fdc->porth, FDIN); -} -#endif /* PC98 */ - -static struct cdevsw fd_cdevsw = { - .d_version = D_VERSION, - .d_open = fdopen, - .d_close = fdclose, - .d_read = physread, - .d_write = physwrite, - .d_ioctl = fdioctl, - .d_strategy = fdstrategy, - .d_name = "fd", - .d_flags = D_DISK | D_NEEDGIANT, -}; - -/* - * Auxiliary functions. Well, some only. Others are scattered - * throughout the entire file. - */ -static int -fdc_err(struct fdc_data *fdc, const char *s) -{ - fdc->fdc_errs++; - if (s) { - if (fdc->fdc_errs < FDC_ERRMAX) - device_printf(fdc->fdc_dev, "%s", s); - else if (fdc->fdc_errs == FDC_ERRMAX) - device_printf(fdc->fdc_dev, "too many errors, not " - "logging any more\n"); - } - - return FD_FAILED; -} - -/* - * fd_cmd: Send a command to the chip. Takes a varargs with this structure: - * Unit number, - * # of output bytes, output bytes as ints ..., - * # of input bytes, input bytes as ints ... - */ -int -fd_cmd(struct fdc_data *fdc, int n_out, ...) -{ - u_char cmd; - int n_in; - int n; - va_list ap; - - va_start(ap, n_out); - cmd = (u_char)(va_arg(ap, int)); - va_end(ap); - va_start(ap, n_out); - for (n = 0; n < n_out; n++) - { - if (out_fdc(fdc, va_arg(ap, int)) < 0) - { - char msg[50]; - snprintf(msg, sizeof(msg), - "cmd %x failed at out byte %d of %d\n", - cmd, n + 1, n_out); - return fdc_err(fdc, msg); - } - } - n_in = va_arg(ap, int); - for (n = 0; n < n_in; n++) - { - int *ptr = va_arg(ap, int *); - if (fd_in(fdc, ptr) < 0) - { - char msg[50]; - snprintf(msg, sizeof(msg), - "cmd %02x failed at in byte %d of %d\n", - cmd, n + 1, n_in); - return fdc_err(fdc, msg); - } - } - - return 0; -} - -static int -enable_fifo(fdc_p fdc) -{ - int i, j; - - if ((fdc->flags & FDC_HAS_FIFO) == 0) { - - /* - * Cannot use fd_cmd the normal way here, since - * this might be an invalid command. Thus we send the - * first byte, and check for an early turn of data directon. - */ - - if (out_fdc(fdc, I8207X_CONFIG) < 0) - return fdc_err(fdc, "Enable FIFO failed\n"); - - /* If command is invalid, return */ - j = FDSTS_TIMEOUT; - while ((i = fdsts_rd(fdc) & (NE7_DIO | NE7_RQM)) - != NE7_RQM && j-- > 0) { - if (i == (NE7_DIO | NE7_RQM)) { - fdc_reset(fdc); - return FD_FAILED; - } - DELAY(1); - } - if (j<0 || - fd_cmd(fdc, 3, - 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0) { - fdc_reset(fdc); - return fdc_err(fdc, "Enable FIFO failed\n"); - } - fdc->flags |= FDC_HAS_FIFO; - return 0; - } - if (fd_cmd(fdc, 4, - I8207X_CONFIG, 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0) - return fdc_err(fdc, "Re-enable FIFO failed\n"); - return 0; -} - -static int -fd_sense_drive_status(fdc_p fdc, int *st3p) -{ - int st3; - - if (fd_cmd(fdc, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3)) - { - return fdc_err(fdc, "Sense Drive Status failed\n"); - } - if (st3p) - *st3p = st3; - - return 0; -} - -static int -fd_sense_int(fdc_p fdc, int *st0p, int *cylp) -{ - int cyl, st0, ret; - - ret = fd_cmd(fdc, 1, NE7CMD_SENSEI, 1, &st0); - if (ret) { - (void)fdc_err(fdc, - "sense intr err reading stat reg 0\n"); - return ret; - } - - if (st0p) - *st0p = st0; - - if ((st0 & NE7_ST0_IC) == NE7_ST0_IC_IV) { - /* - * There doesn't seem to have been an interrupt. - */ - return FD_NOT_VALID; - } - - if (fd_in(fdc, &cyl) < 0) { - return fdc_err(fdc, "can't get cyl num\n"); - } - - if (cylp) - *cylp = cyl; - - return 0; -} - - -static int -fd_read_status(fdc_p fdc) -{ - int i, ret; - - for (i = ret = 0; i < 7; i++) { - /* - * XXX types are poorly chosen. Only bytes can be read - * from the hardware, but fdc->status[] wants u_ints and - * fd_in() gives ints. - */ - int status; - - ret = fd_in(fdc, &status); - fdc->status[i] = status; - if (ret != 0) - break; - } - - if (ret == 0) - fdc->flags |= FDC_STAT_VALID; - else - fdc->flags &= ~FDC_STAT_VALID; - - return ret; -} - -#ifdef PC98 -static int pc98_trans = 0; /* 0 : HD , 1 : DD , 2 : 1.44 */ -static int pc98_trans_prev = -1; - -static void set_density(fdc_p fdc) -{ - /* always motor on */ - bus_space_write_1(fdc->sc_fdsiot, fdc->sc_fdsioh, 0, - (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC); - DELAY(100); - fdctl_wr(fdc, FDC_RST | FDC_DMAE); - /* in the case of note W, always inhibit 100ms timer */ -} - -static int pc98_fd_check_ready(fdu_t fdu) -{ - fd_p fd = devclass_get_softc(fd_devclass, fdu); - struct fdc_data *fdc = fd->fdc; - int retry = 0, status; - - while (retry++ < 30000) { - set_motor(fdc, fd->fdsu, TURNON); - out_fdc(fdc, NE7CMD_SENSED); /* Sense Drive Status */ - DELAY(100); - out_fdc(fdc, fdu); /* Drive number */ - DELAY(100); - if ((fd_in(fdc, &status) == 0) && (status & NE7_ST3_RD)) { - fdctl_wr(fdc, FDC_DMAE | FDC_MTON); - DELAY(10); - return 0; - } - } - return -1; -} - -static void pc98_fd_check_type(struct fd_data *fd) -{ - struct fdc_data *fdc; - - if (fd->type != FDT_NONE || fd->fdu < 0 || fd->fdu > 3) - return; - - fdc = fd->fdc; - - /* Look up what the BIOS thinks we have. */ - if (!((PC98_SYSTEM_PARAMETER(0x55c) >> fd->fdu) & 0x01)) { - fd->type = FDT_NONE; - return; - } - if ((PC98_SYSTEM_PARAMETER(0x5ae) >> fd->fdu) & 0x01) { - /* Check 3mode I/F */ - fd->pc98_trans = 0; - bus_space_write_1(fdc->sc_fdemsiot, fdc->sc_fdemsioh, 0, - (fd->fdu << 5) | 0x10); - if (!(bus_space_read_1(fdc->sc_fdemsiot, fdc->sc_fdemsioh, 0) & - 0x01)) { - fd->type = FDT_144M; - return; - } - device_printf(fd->dev, - "Warning: can't control 3mode I/F, fallback to 2mode.\n"); - } - - fd->type = FDT_12M; -} -#endif /* PC98 */ - -void -fdc_release_resources(struct fdc_data *fdc) -{ - device_t dev; - - dev = fdc->fdc_dev; - if (fdc->fdc_intr) { - bus_teardown_intr(dev, fdc->res_irq, fdc->fdc_intr); - fdc->fdc_intr = NULL; - } - if (fdc->res_irq != 0) { - bus_release_resource(dev, SYS_RES_IRQ, fdc->rid_irq, - fdc->res_irq); - fdc->res_irq = NULL; - } -#ifndef PC98 - if (fdc->res_ctl != 0) { - bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl, - fdc->res_ctl); - fdc->res_ctl = NULL; - } -#endif -#ifdef PC98 - if (fdc->res_fdsio != 0) { - bus_release_resource(dev, SYS_RES_IOPORT, 3, fdc->res_fdsio); - fdc->res_fdsio = NULL; - } - if (fdc->res_fdemsio != 0) { - bus_release_resource(dev, SYS_RES_IOPORT, 4, fdc->res_fdemsio); - fdc->res_fdemsio = NULL; - } -#endif - if (fdc->res_ioport != 0) { - bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport, - fdc->res_ioport); - fdc->res_ioport = NULL; - } - if (fdc->res_drq != 0) { - bus_release_resource(dev, SYS_RES_DRQ, fdc->rid_drq, - fdc->res_drq); - fdc->res_drq = NULL; - } -} - -/* - * Configuration/initialization stuff, per controller. - */ - -int -fdc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct fdc_ivars *ivars = device_get_ivars(child); - - switch (which) { - case FDC_IVAR_FDUNIT: - *result = ivars->fdunit; - break; - case FDC_IVAR_FDTYPE: - *result = ivars->fdtype; - break; - default: - return (ENOENT); - } - return (0); -} - -int -fdc_write_ivar(device_t dev, device_t child, int which, uintptr_t value) -{ - struct fdc_ivars *ivars = device_get_ivars(child); - - switch (which) { - case FDC_IVAR_FDUNIT: - ivars->fdunit = value; - break; - case FDC_IVAR_FDTYPE: - ivars->fdtype = value; - break; - default: - return (ENOENT); - } - return (0); -} - -int -fdc_initial_reset(struct fdc_data *fdc) -{ -#ifdef PC98 - /* see if it can handle a command */ - if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(4, 240), - NE7_SPEC_2(2, 0), 0)) - return (ENXIO); -#else - /* First, reset the floppy controller. */ - fdout_wr(fdc, 0); - DELAY(100); - fdout_wr(fdc, FDO_FRST); - - /* Then, see if it can handle a command. */ - if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(3, 240), - NE7_SPEC_2(2, 0), 0)) - return (ENXIO); -#endif - return (0); -} - -int -fdc_detach(device_t dev) -{ - struct fdc_data *fdc; - int error; - - fdc = device_get_softc(dev); - - /* have our children detached first */ - if ((error = bus_generic_detach(dev))) - return (error); - -#ifdef PC98 - /* reset controller, turn motor off */ - fdc_reset(fdc); -#else - /* reset controller, turn motor off */ - fdout_wr(fdc, 0); -#endif - - fdc_release_resources(fdc); - return (0); -} - -/* - * Add a child device to the fdc controller. It will then be probed etc. - */ -device_t -fdc_add_child(device_t dev, const char *name, int unit) -{ - struct fdc_ivars *ivar; - device_t child; - - ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT | M_ZERO); - if (ivar == NULL) - return (NULL); - child = device_add_child(dev, name, unit); - if (child == NULL) { - free(ivar, M_DEVBUF); - return (NULL); - } - device_set_ivars(child, ivar); - ivar->fdunit = unit; - ivar->fdtype = FDT_NONE; - if (resource_disabled(name, unit)) - device_disable(child); - return (child); -} - -int -fdc_attach(device_t dev) -{ - struct fdc_data *fdc; - int error; - - fdc = device_get_softc(dev); - fdc->fdc_dev = dev; - error = bus_setup_intr(dev, fdc->res_irq, - INTR_TYPE_BIO | INTR_ENTROPY, NULL, fdc_intr, fdc, - &fdc->fdc_intr); - if (error) { - device_printf(dev, "cannot setup interrupt\n"); - return error; - } - fdc->fdcu = device_get_unit(dev); - fdc->flags |= FDC_NEEDS_RESET; - - fdc->state = DEVIDLE; - -#ifdef PC98 - /* reset controller, turn motor off, clear fdout mirror reg */ - fdc_reset(fdc); -#else - /* reset controller, turn motor off, clear fdout mirror reg */ - fdout_wr(fdc, fdc->fdout = 0); -#endif - bioq_init(&fdc->head); - - return (0); -} - -int -fdc_hints_probe(device_t dev) -{ - const char *name, *dname; - int i, error, dunit; - - /* - * Probe and attach any children. We should probably detect - * devices from the BIOS unless overridden. - */ - name = device_get_nameunit(dev); - i = 0; - while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0) { - resource_int_value(dname, dunit, "drive", &dunit); - fdc_add_child(dev, dname, dunit); - } - - if ((error = bus_generic_attach(dev)) != 0) - return (error); - return (0); -} - -int -fdc_print_child(device_t me, device_t child) -{ - int retval = 0, flags; - - retval += bus_print_child_header(me, child); - retval += printf(" on %s drive %d", device_get_nameunit(me), - fdc_get_fdunit(child)); - if ((flags = device_get_flags(me)) != 0) - retval += printf(" flags %#x", flags); - retval += printf("\n"); - - return (retval); -} - -/* - * Configuration/initialization, per drive. - */ -static int -fd_probe(device_t dev) -{ - int i; -#ifndef PC98 - u_int st0, st3; -#endif - struct fd_data *fd; - struct fdc_data *fdc; - fdsu_t fdsu; - int flags, type; - - fdsu = fdc_get_fdunit(dev); - fd = device_get_softc(dev); - fdc = device_get_softc(device_get_parent(dev)); - flags = device_get_flags(dev); - - fd->dev = dev; - fd->fdc = fdc; - fd->fdsu = fdsu; - fd->fdu = device_get_unit(dev); - - /* Auto-probe if fdinfo is present, but always allow override. */ - type = FD_DTYPE(flags); - if (type == FDT_NONE && (type = fdc_get_fdtype(dev)) != FDT_NONE) { - fd->type = type; - goto done; - } else { - /* make sure fdautoselect() will be called */ - fd->flags = FD_UA; - fd->type = type; - } - -#ifdef PC98 - pc98_fd_check_type(fd); -#else -/* - * XXX I think using __i386__ is wrong here since we actually want to probe - * for the machine type, not the CPU type (so non-PC arch's like the PC98 will - * fail the probe). - */ -#ifdef __i386__ - if (fd->type == FDT_NONE && (fd->fdu == 0 || fd->fdu == 1)) { - /* Look up what the BIOS thinks we have. */ - if (fd->fdu == 0) { - if ((fdc->flags & FDC_ISPCMCIA)) - /* - * Somewhat special. No need to force the - * user to set device flags, since the Y-E - * Data PCMCIA floppy is always a 1.44 MB - * device. - */ - fd->type = FDT_144M; - else - fd->type = (rtcin(RTC_FDISKETTE) & 0xf0) >> 4; - } else { - fd->type = rtcin(RTC_FDISKETTE) & 0x0f; - } - if (fd->type == FDT_288M_1) - fd->type = FDT_288M; - } -#endif /* __i386__ */ -#endif /* PC98 */ - - /* is there a unit? */ - if (fd->type == FDT_NONE) - return (ENXIO); - -#ifndef PC98 - /* select it */ - set_motor(fdc, fdsu, TURNON); - fdc_reset(fdc); /* XXX reset, then unreset, etc. */ - DELAY(1000000); /* 1 sec */ - - if ((flags & FD_NO_PROBE) == 0) { - /* If we're at track 0 first seek inwards. */ - if ((fd_sense_drive_status(fdc, &st3) == 0) && - (st3 & NE7_ST3_T0)) { - /* Seek some steps... */ - if (fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) { - /* ...wait a moment... */ - DELAY(300000); - /* make ctrlr happy: */ - fd_sense_int(fdc, 0, 0); - } - } - - for (i = 0; i < 2; i++) { - /* - * we must recalibrate twice, just in case the - * heads have been beyond cylinder 76, since - * most FDCs still barf when attempting to - * recalibrate more than 77 steps - */ - /* go back to 0: */ - if (fd_cmd(fdc, 2, NE7CMD_RECAL, fdsu, 0) == 0) { - /* a second being enough for full stroke seek*/ - DELAY(i == 0 ? 1000000 : 300000); - - /* anything responding? */ - if (fd_sense_int(fdc, &st0, 0) == 0 && - (st0 & NE7_ST0_EC) == 0) - break; /* already probed succesfully */ - } - } - } - - set_motor(fdc, fdsu, TURNOFF); - - if ((flags & FD_NO_PROBE) == 0 && - (st0 & NE7_ST0_EC) != 0) /* no track 0 -> no drive present */ - return (ENXIO); -#endif /* PC98 */ - -done: -#ifndef PC98 - /* This doesn't work before the first reset. */ - if ((fdc->flags & FDC_HAS_FIFO) == 0 && - fdc->fdct == FDC_ENHANCED && - (device_get_flags(fdc->fdc_dev) & FDC_NO_FIFO) == 0 && - enable_fifo(fdc) == 0) { - device_printf(device_get_parent(dev), - "FIFO enabled, %d bytes threshold\n", fifo_threshold); - } -#endif /* PC98 */ - -#ifdef PC98 - switch (fd->type) { - case FDT_144M: - device_set_desc(dev, "1.44M FDD"); - break; - case FDT_12M: - device_set_desc(dev, "1M/640K FDD"); - break; - default: - return (ENXIO); - } -#else - switch (fd->type) { - case FDT_12M: - device_set_desc(dev, "1200-KB 5.25\" drive"); - break; - case FDT_144M: - device_set_desc(dev, "1440-KB 3.5\" drive"); - break; - case FDT_288M: - device_set_desc(dev, "2880-KB 3.5\" drive (in 1440-KB mode)"); - break; - case FDT_360K: - device_set_desc(dev, "360-KB 5.25\" drive"); - break; - case FDT_720K: - device_set_desc(dev, "720-KB 3.5\" drive"); - break; - default: - return (ENXIO); - } -#endif - fd->track = FD_NO_TRACK; - fd->fdc = fdc; - fd->fdsu = fdsu; - fd->options = 0; -#ifdef PC98 - fd->pc98_trans = 0; -#endif - callout_handle_init(&fd->toffhandle); - callout_handle_init(&fd->tohandle); - - /* initialize densities for subdevices */ -#ifdef PC98 - for (i = 0; i < NUMDENS; i++) - memcpy(fd->fts + i, fd_searchlist_144m + i, - sizeof(struct fd_type)); -#else - for (i = 0; i < NUMDENS; i++) - memcpy(fd->fts + i, fd_native_types + fd->type, - sizeof(struct fd_type)); -#endif - return (0); -} - -static int -fd_attach(device_t dev) -{ - struct fd_data *fd; - - fd = device_get_softc(dev); - fd->masterdev = make_dev(&fd_cdevsw, fd->fdu, - UID_ROOT, GID_OPERATOR, 0640, "fd%d", fd->fdu); - fd->masterdev->si_drv1 = fd; - fd->device_stats = devstat_new_entry(device_get_name(dev), - device_get_unit(dev), 0, DEVSTAT_NO_ORDERED_TAGS, - DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_OTHER, - DEVSTAT_PRIORITY_FD); - return (0); -} - -static int -fd_detach(device_t dev) -{ - struct fd_data *fd; - - fd = device_get_softc(dev); - untimeout(fd_turnoff, fd, fd->toffhandle); - devstat_remove_entry(fd->device_stats); - destroy_dev(fd->masterdev); - - return (0); -} - -static device_method_t fd_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, fd_probe), - DEVMETHOD(device_attach, fd_attach), - DEVMETHOD(device_detach, fd_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), /* XXX */ - DEVMETHOD(device_resume, bus_generic_resume), /* XXX */ - - { 0, 0 } -}; - -static driver_t fd_driver = { - "fd", - fd_methods, - sizeof(struct fd_data) -}; - -DRIVER_MODULE(fd, fdc, fd_driver, fd_devclass, 0, 0); - -/* - * More auxiliary functions. - */ -/* - * Motor control stuff. - * Remember to not deselect the drive we're working on. - */ -static void -set_motor(struct fdc_data *fdc, int fdsu, int turnon) -{ -#ifdef PC98 - bus_space_write_1(fdc->sc_fdsiot, fdc->sc_fdsioh, 0, - (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC); - DELAY(10); - fdctl_wr(fdc, FDC_DMAE | FDC_MTON); -#else - int fdout; - - fdout = fdc->fdout; - if (turnon) { - fdout &= ~FDO_FDSEL; - fdout |= (FDO_MOEN0 << fdsu) | FDO_FDMAEN | FDO_FRST | fdsu; - } else - fdout &= ~(FDO_MOEN0 << fdsu); - fdc->fdout = fdout; - fdout_wr(fdc, fdout); - TRACE1("[0x%x->FDOUT]", fdout); -#endif -} - -static void -fd_turnoff(void *xfd) -{ - int s; - fd_p fd = xfd; - - TRACE1("[fd%d: turnoff]", fd->fdu); - - s = splbio(); - /* - * Don't turn off the motor yet if the drive is active. - * - * If we got here, this could only mean we missed an interrupt. - * This can e. g. happen on the Y-E Date PCMCIA floppy controller - * after a controller reset. Just schedule a pseudo-interrupt - * so the state machine gets re-entered. - */ - if (fd->fdc->state != DEVIDLE && fd->fdc->fdu == fd->fdu) { - fdc_intr(fd->fdc); - splx(s); - return; - } - - fd->flags &= ~FD_MOTOR; - set_motor(fd->fdc, fd->fdsu, TURNOFF); - splx(s); -} - -static void -fd_motor_on(void *xfd) -{ - int s; - fd_p fd = xfd; - - s = splbio(); - fd->flags &= ~FD_MOTOR_WAIT; - if((fd->fdc->fd == fd) && (fd->fdc->state == MOTORWAIT)) - { - fdc_intr(fd->fdc); - } - splx(s); -} - -static void -fd_turnon(fd_p fd) -{ - if(!(fd->flags & FD_MOTOR)) - { - fd->flags |= (FD_MOTOR + FD_MOTOR_WAIT); - set_motor(fd->fdc, fd->fdsu, TURNON); - timeout(fd_motor_on, fd, hz); /* in 1 sec its ok */ - } -} - -static void -fdc_reset(fdc_p fdc) -{ - /* Try a reset, keep motor on */ -#ifdef PC98 - set_density(fdc); - if (pc98_machine_type & M_EPSON_PC98) - fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DD | FDC_MTON); - else - fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DMAE | FDC_MTON); - DELAY(200); - fdctl_wr(fdc, FDC_DMAE | FDC_MTON); - DELAY(10); -#else - fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN)); - TRACE1("[0x%x->FDOUT]", fdc->fdout & ~(FDO_FRST|FDO_FDMAEN)); - DELAY(100); - /* enable FDC, but defer interrupts a moment */ - fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN); - TRACE1("[0x%x->FDOUT]", fdc->fdout & ~FDO_FDMAEN); - DELAY(100); - fdout_wr(fdc, fdc->fdout); - TRACE1("[0x%x->FDOUT]", fdc->fdout); -#endif - - /* XXX after a reset, silently believe the FDC will accept commands */ -#ifdef PC98 - (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY, - NE7_SPEC_1(4, 240), NE7_SPEC_2(2, 0), - 0); -#else - (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY, - NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0), - 0); -#endif - if (fdc->flags & FDC_HAS_FIFO) - (void) enable_fifo(fdc); -} - -/* - * FDC IO functions, take care of the main status register, timeout - * in case the desired status bits are never set. - * - * These PIO loops initially start out with short delays between - * each iteration in the expectation that the required condition - * is usually met quickly, so it can be handled immediately. After - * about 1 ms, stepping is increased to achieve a better timing - * accuracy in the calls to DELAY(). - */ -static int -fd_in(struct fdc_data *fdc, int *ptr) -{ - int i, j, step; - - for (j = 0, step = 1; - (i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM)) != (NE7_DIO|NE7_RQM) && - j < FDSTS_TIMEOUT; - j += step) { - if (i == NE7_RQM) - return (fdc_err(fdc, "ready for output in input\n")); - if (j == 1000) - step = 1000; - DELAY(step); - } - if (j >= FDSTS_TIMEOUT) - return (fdc_err(fdc, bootverbose? "input ready timeout\n": 0)); -#ifdef FDC_DEBUG - i = fddata_rd(fdc); - TRACE1("[FDDATA->0x%x]", (unsigned char)i); - *ptr = i; - return (0); -#else /* !FDC_DEBUG */ - i = fddata_rd(fdc); - if (ptr) - *ptr = i; - return (0); -#endif /* FDC_DEBUG */ -} - -static int -out_fdc(struct fdc_data *fdc, int x) -{ - int i, j, step; - - for (j = 0, step = 1; - (i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM)) != NE7_RQM && - j < FDSTS_TIMEOUT; - j += step) { - if (i == (NE7_DIO|NE7_RQM)) - return (fdc_err(fdc, "ready for input in output\n")); - if (j == 1000) - step = 1000; - DELAY(step); - } - if (j >= FDSTS_TIMEOUT) - return (fdc_err(fdc, bootverbose? "output ready timeout\n": 0)); - - /* Send the command and return */ - fddata_wr(fdc, x); - TRACE1("[0x%x->FDDATA]", x); - return (0); -} - -/* - * Block device driver interface functions (interspersed with even more - * auxiliary functions). - */ -static int -fdopen(struct cdev *dev, int flags, int mode, struct thread *td) -{ - fd_p fd; - fdc_p fdc; -#ifdef PC98 - fdu_t fdu; -#endif - int rv, unitattn, dflags; - - fd = dev->si_drv1; - if (fd == NULL) - return (ENXIO); - fdc = fd->fdc; - if ((fdc == NULL) || (fd->type == FDT_NONE)) - return (ENXIO); -#ifdef PC98 - fdu = fd->fdu; -#endif - dflags = device_get_flags(fd->dev); - /* - * This is a bit bogus. It's still possible that e. g. a - * descriptor gets inherited to a child, but then it's at - * least for the same subdevice. By checking FD_OPEN here, we - * can ensure that a device isn't attempted to be opened with - * different densities at the same time where the second open - * could clobber the settings from the first one. - */ - if (fd->flags & FD_OPEN) - return (EBUSY); - -#ifdef PC98 - if (pc98_fd_check_ready(fdu) == -1) - return(EIO); -#endif - - if (flags & FNONBLOCK) { - /* - * Unfortunately, physio(9) discards its ioflag - * argument, thus preventing us from seeing the - * O_NONBLOCK bit. So we need to keep track - * ourselves. - */ - fd->flags |= FD_NONBLOCK; - fd->ft = 0; - } else { - /* - * Figure out a unit attention condition. - * - * If UA has been forced, proceed. - * - * If the drive has no changeline support, - * or if the drive parameters have been lost - * due to previous non-blocking access, - * assume a forced UA condition. - * - * If motor is off, turn it on for a moment - * and select our drive, in order to read the - * UA hardware signal. - * - * If motor is on, and our drive is currently - * selected, just read the hardware bit. - * - * If motor is on, but active for another - * drive on that controller, we are lost. We - * cannot risk to deselect the other drive, so - * we just assume a forced UA condition to be - * on the safe side. - */ - unitattn = 0; - if ((dflags & FD_NO_CHLINE) != 0 || - (fd->flags & FD_UA) != 0 || - fd->ft == 0) { - unitattn = 1; - fd->flags &= ~FD_UA; -#ifndef PC98 - } else if (fdc->fdout & (FDO_MOEN0 | FDO_MOEN1 | - FDO_MOEN2 | FDO_MOEN3)) { - if ((fdc->fdout & FDO_FDSEL) == fd->fdsu) - unitattn = fdin_rd(fdc) & FDI_DCHG; - else - unitattn = 1; - } else { - set_motor(fdc, fd->fdsu, TURNON); - unitattn = fdin_rd(fdc) & FDI_DCHG; - set_motor(fdc, fd->fdsu, TURNOFF); -#endif /* PC98 */ - } - if (unitattn && (rv = fdautoselect(dev)) != 0) - return (rv); - } - fd->flags |= FD_OPEN; - - if ((fdc->flags & FDC_NODMA) == 0) { - if (fdc->dmacnt++ == 0) { - isa_dma_acquire(fdc->dmachan); - isa_dmainit(fdc->dmachan, MAX_SEC_SIZE); - } - } - - /* - * Clearing the DMA overrun counter at open time is a bit messy. - * Since we're only managing one counter per controller, opening - * the second drive could mess it up. Anyway, if the DMA overrun - * condition is really persistent, it will eventually time out - * still. OTOH, clearing it here will ensure we'll at least start - * trying again after a previous (maybe even long ago) failure. - * Also, this is merely a stop-gap measure only that should not - * happen during normal operation, so we can tolerate it to be a - * bit sloppy about this. - */ - fdc->dma_overruns = 0; - - return 0; -} - -static int -fdclose(struct cdev *dev, int flags, int mode, struct thread *td) -{ - struct fd_data *fd; - fdc_p fdc; - - fd = dev->si_drv1; - fdc = fd->fdc; - fd->flags &= ~(FD_OPEN | FD_NONBLOCK); - fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR); - - if ((fdc->flags & FDC_NODMA) == 0) - if (--fdc->dmacnt == 0) - isa_dma_release(fdc->dmachan); - - return (0); -} - -static void -fdstrategy(struct bio *bp) -{ - long blknum, nblocks; - int s; - fdu_t fdu; - fdc_p fdc; - fd_p fd; - size_t fdblk; - - fd = bp->bio_dev->si_drv1; - fdu = fd->fdu; - fdc = fd->fdc; - bp->bio_resid = bp->bio_bcount; - if (fd->type == FDT_NONE || fd->ft == 0) { - if (fd->type != FDT_NONE && (fd->flags & FD_NONBLOCK)) - bp->bio_error = EAGAIN; - else - bp->bio_error = ENXIO; - bp->bio_flags |= BIO_ERROR; - goto bad; - } - fdblk = 128 << (fd->ft->secsize); - if (bp->bio_cmd != FDBIO_FORMAT && bp->bio_cmd != FDBIO_RDSECTID) { - if (fd->flags & FD_NONBLOCK) { - bp->bio_error = EAGAIN; - bp->bio_flags |= BIO_ERROR; - goto bad; - } - if (bp->bio_offset < 0) { - printf( - "fd%d: fdstrat: bad request offset = %ju, bcount = %ld\n", - fdu, (intmax_t)bp->bio_offset, bp->bio_bcount); - bp->bio_error = EINVAL; - bp->bio_flags |= BIO_ERROR; - goto bad; - } - if ((bp->bio_bcount % fdblk) != 0) { - bp->bio_error = EINVAL; - bp->bio_flags |= BIO_ERROR; - goto bad; - } - } - - /* - * Set up block calculations. - */ -#ifndef PC98 - if (bp->bio_offset >= ((off_t)128 << fd->ft->secsize) * fd->ft->size) { - bp->bio_error = EINVAL; - bp->bio_flags |= BIO_ERROR; - goto bad; - } -#endif - blknum = bp->bio_offset / fdblk; - nblocks = fd->ft->size; - if (blknum + bp->bio_bcount / fdblk > nblocks) { - if (blknum >= nblocks) { - if (bp->bio_cmd != BIO_READ) { - bp->bio_error = ENOSPC; - bp->bio_flags |= BIO_ERROR; - } - goto bad; /* not always bad, but EOF */ - } - bp->bio_bcount = (nblocks - blknum) * fdblk; - } - bp->bio_pblkno = blknum; - s = splbio(); - bioq_disksort(&fdc->head, bp); - untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */ - devstat_start_transaction_bio(fd->device_stats, bp); - device_busy(fd->dev); - fdstart(fdc); - splx(s); - return; - -bad: - biodone(bp); -} - -/* - * fdstart - * - * We have just queued something. If the controller is not busy - * then simulate the case where it has just finished a command - * So that it (the interrupt routine) looks on the queue for more - * work to do and picks up what we just added. - * - * If the controller is already busy, we need do nothing, as it - * will pick up our work when the present work completes. - */ -static void -fdstart(struct fdc_data *fdc) -{ - int s; - - s = splbio(); - if(fdc->state == DEVIDLE) - { - fdc_intr(fdc); - } - splx(s); -} - -static void -fd_iotimeout(void *xfdc) -{ - fdc_p fdc; - int s; - - fdc = xfdc; - TRACE1("fd%d[fd_iotimeout()]", fdc->fdu); - - /* - * Due to IBM's brain-dead design, the FDC has a faked ready - * signal, hardwired to ready == true. Thus, any command - * issued if there's no diskette in the drive will _never_ - * complete, and must be aborted by resetting the FDC. - * Many thanks, Big Blue! - * The FDC must not be reset directly, since that would - * interfere with the state machine. Instead, pretend that - * the command completed but was invalid. The state machine - * will reset the FDC and retry once. - */ - s = splbio(); - fdc->status[0] = NE7_ST0_IC_IV; - fdc->flags &= ~FDC_STAT_VALID; - fdc->state = IOTIMEDOUT; - fdc_intr(fdc); - splx(s); -} - -/* Just ensure it has the right spl. */ -static void -fd_pseudointr(void *xfdc) -{ - int s; - - s = splbio(); - fdc_intr(xfdc); - splx(s); -} - -/* - * fdc_intr - * - * Keep calling the state machine until it returns a 0. - * Always called at splbio. - */ -static void -fdc_intr(void *xfdc) -{ - fdc_p fdc = xfdc; - while(fdstate(fdc)) - ; -} - -/* - * Magic pseudo-DMA initialization for YE FDC. Sets count and - * direction. - */ -#define SET_BCDR(fdc,wr,cnt,port) \ - bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port, \ - ((cnt)-1) & 0xff); \ - bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port + 1, \ - ((wr ? 0x80 : 0) | ((((cnt)-1) >> 8) & 0x7f))); - -/* - * fdcpio(): perform programmed IO read/write for YE PCMCIA floppy. - */ -static int -fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count) -{ - u_char *cptr = (u_char *)addr; - - if (flags == BIO_READ) { - if (fdc->state != PIOREAD) { - fdc->state = PIOREAD; - return(0); - } - SET_BCDR(fdc, 0, count, 0); - bus_space_read_multi_1(fdc->portt, fdc->porth, fdc->port_off + - FDC_YE_DATAPORT, cptr, count); - } else { - bus_space_write_multi_1(fdc->portt, fdc->porth, fdc->port_off + - FDC_YE_DATAPORT, cptr, count); - SET_BCDR(fdc, 0, count, 0); - } - return(1); -} - -/* - * Try figuring out the density of the media present in our device. - */ -static int -fdautoselect(struct cdev *dev) -{ - fd_p fd; - struct fd_type *fdtp; - struct fdc_readid id; - int i, n, oopts, rv; - - fd = dev->si_drv1; - - switch (fd->type) { - default: - return (ENXIO); - -#ifndef PC98 - case FDT_360K: - case FDT_720K: - /* no autoselection on those drives */ - fd->ft = fd_native_types + fd->type; - return (0); -#endif - - case FDT_12M: - fdtp = fd_searchlist_12m; - n = sizeof fd_searchlist_12m / sizeof(struct fd_type); - break; - - case FDT_144M: - fdtp = fd_searchlist_144m; - n = sizeof fd_searchlist_144m / sizeof(struct fd_type); - break; - -#ifndef PC98 - case FDT_288M: - fdtp = fd_searchlist_288m; - n = sizeof fd_searchlist_288m / sizeof(struct fd_type); - break; -#endif - } - - /* - * Try reading sector ID fields, first at cylinder 0, head 0, - * then at cylinder 2, head N. We don't probe cylinder 1, - * since for 5.25in DD media in a HD drive, there are no data - * to read (2 step pulses per media cylinder required). For - * two-sided media, the second probe always goes to head 1, so - * we can tell them apart from single-sided media. As a - * side-effect this means that single-sided media should be - * mentioned in the search list after two-sided media of an - * otherwise identical density. Media with a different number - * of sectors per track but otherwise identical parameters - * cannot be distinguished at all. - * - * If we successfully read an ID field on both cylinders where - * the recorded values match our expectation, we are done. - * Otherwise, we try the next density entry from the table. - * - * Stepping to cylinder 2 has the side-effect of clearing the - * unit attention bit. - */ - oopts = fd->options; - fd->options |= FDOPT_NOERRLOG | FDOPT_NORETRY; - for (i = 0; i < n; i++, fdtp++) { - fd->ft = fdtp; - - id.cyl = id.head = 0; - rv = fdmisccmd(dev, FDBIO_RDSECTID, &id); - if (rv != 0) - continue; - if (id.cyl != 0 || id.head != 0 || - id.secshift != fdtp->secsize) - continue; - id.cyl = 2; - id.head = fd->ft->heads - 1; - rv = fdmisccmd(dev, FDBIO_RDSECTID, &id); - if (id.cyl != 2 || id.head != fdtp->heads - 1 || - id.secshift != fdtp->secsize) - continue; - if (rv == 0) - break; - } - - fd->options = oopts; - if (i == n) { - if (bootverbose) - device_printf(fd->dev, "autoselection failed\n"); - fd->ft = 0; - return (EIO); - } else { - if (bootverbose) - device_printf(fd->dev, "autoselected %d KB medium\n", -#ifdef PC98 - (128 << (fd->ft->secsize)) * - fd->ft->size / 1024); -#else - fd->ft->size / 2); -#endif - return (0); - } -} - - -/* - * The controller state machine. - * - * If it returns a non zero value, it should be called again immediately. - */ -static int -fdstate(fdc_p fdc) -{ - struct fdc_readid *idp; - int read, format, rdsectid, cylinder, head, i, sec = 0, sectrac; - int st0, cyl, st3, idf, ne7cmd, mfm, steptrac; - unsigned long blknum; - fdu_t fdu = fdc->fdu; - fd_p fd; - register struct bio *bp; - struct fd_formb *finfo = NULL; - size_t fdblk; - - bp = fdc->bp; - if (bp == NULL) { - bp = bioq_takefirst(&fdc->head); - if (bp != NULL) - fdc->bp = bp; - } - if (bp == NULL) { - /* - * Nothing left for this controller to do, - * force into the IDLE state. - */ - fdc->state = DEVIDLE; - if (fdc->fd) { - device_printf(fdc->fdc_dev, - "unexpected valid fd pointer\n"); - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - } - TRACE1("[fdc%d IDLE]", fdc->fdcu); - return (0); - } - fd = bp->bio_dev->si_drv1; - fdu = fd->fdu; - fdblk = 128 << fd->ft->secsize; - if (fdc->fd && (fd != fdc->fd)) - device_printf(fd->dev, "confused fd pointers\n"); - read = bp->bio_cmd == BIO_READ; - mfm = (fd->ft->flags & FL_MFM)? NE7CMD_MFM: 0; - steptrac = (fd->ft->flags & FL_2STEP)? 2: 1; - if (read) - idf = ISADMA_READ; - else - idf = ISADMA_WRITE; - format = bp->bio_cmd == FDBIO_FORMAT; - rdsectid = bp->bio_cmd == FDBIO_RDSECTID; - if (format) - finfo = (struct fd_formb *)bp->bio_data; - TRACE1("fd%d", fdu); - TRACE1("[%s]", fdstates[fdc->state]); - TRACE1("(0x%x)", fd->flags); - untimeout(fd_turnoff, fd, fd->toffhandle); - fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz); - switch (fdc->state) - { - case DEVIDLE: - case FINDWORK: /* we have found new work */ - fdc->retry = 0; - fd->skip = 0; - fdc->fd = fd; - fdc->fdu = fdu; -#ifdef PC98 - pc98_trans = fd->ft->trans; - if (pc98_trans_prev != pc98_trans) { - int i; - set_density(fdc); - for (i = 0; i < 10; i++) { - outb(0x5f, 0); - outb(0x5f, 0); - } - pc98_trans_prev = pc98_trans; - } - if (pc98_trans != fd->pc98_trans) { - if (fd->type == FDT_144M) { - bus_space_write_1(fdc->sc_fdemsiot, - fdc->sc_fdemsioh, - 0, - (fdu << 5) | 0x10 | - (pc98_trans >> 1)); - outb(0x5f, 0); - outb(0x5f, 0); - } - fd->pc98_trans = pc98_trans; - } -#else - fdc->fdctl_wr(fdc, fd->ft->trans); -#endif - TRACE1("[0x%x->FDCTL]", fd->ft->trans); - /* - * If the next drive has a motor startup pending, then - * it will start up in its own good time. - */ - if(fd->flags & FD_MOTOR_WAIT) { - fdc->state = MOTORWAIT; - return (0); /* will return later */ - } - /* - * Maybe if it's not starting, it SHOULD be starting. - */ - if (!(fd->flags & FD_MOTOR)) - { - fdc->state = MOTORWAIT; - fd_turnon(fd); - return (0); /* will return later */ - } - else /* at least make sure we are selected */ - { - set_motor(fdc, fd->fdsu, TURNON); - } - if (fdc->flags & FDC_NEEDS_RESET) { - fdc->state = RESETCTLR; - fdc->flags &= ~FDC_NEEDS_RESET; - } else - fdc->state = DOSEEK; - return (1); /* will return immediately */ - - case DOSEEK: - blknum = bp->bio_pblkno + fd->skip / fdblk; - cylinder = blknum / (fd->ft->sectrac * fd->ft->heads); - if (cylinder == fd->track) - { - fdc->state = SEEKCOMPLETE; - return (1); /* will return immediately */ - } -#ifdef PC98 - pc98_fd_check_ready(fdu); -#endif - if (fd_cmd(fdc, 3, NE7CMD_SEEK, - fd->fdsu, cylinder * steptrac, 0)) - { - /* - * Seek command not accepted, looks like - * the FDC went off to the Saints... - */ - fdc->retry = 6; /* try a reset */ - return(retrier(fdc)); - } - fd->track = FD_NO_TRACK; - fdc->state = SEEKWAIT; - return(0); /* will return later */ - - case SEEKWAIT: - /* allow heads to settle */ - timeout(fd_pseudointr, fdc, hz / 16); - fdc->state = SEEKCOMPLETE; - return(0); /* will return later */ - - case SEEKCOMPLETE : /* seek done, start DMA */ - blknum = bp->bio_pblkno + fd->skip / fdblk; - cylinder = blknum / (fd->ft->sectrac * fd->ft->heads); - - /* Make sure seek really happened. */ - if(fd->track == FD_NO_TRACK) { - int descyl = cylinder * steptrac; - do { - /* - * This might be a "ready changed" interrupt, - * which cannot really happen since the - * RDY pin is hardwired to + 5 volts. This - * generally indicates a "bouncing" intr - * line, so do one of the following: - * - * When running on an enhanced FDC that is - * known to not go stuck after responding - * with INVALID, fetch all interrupt states - * until seeing either an INVALID or a - * real interrupt condition. - * - * When running on a dumb old NE765, give - * up immediately. The controller will - * provide up to four dummy RC interrupt - * conditions right after reset (for the - * corresponding four drives), so this is - * our only chance to get notice that it - * was not the FDC that caused the interrupt. - */ - if (fd_sense_int(fdc, &st0, &cyl) - == FD_NOT_VALID) - return (0); /* will return later */ - if(fdc->fdct == FDC_NE765 - && (st0 & NE7_ST0_IC) == NE7_ST0_IC_RC) - return (0); /* hope for a real intr */ - } while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC); - - if (0 == descyl) { - int failed = 0; - /* - * seek to cyl 0 requested; make sure we are - * really there - */ - if (fd_sense_drive_status(fdc, &st3)) - failed = 1; - if ((st3 & NE7_ST3_T0) == 0) { - printf( - "fd%d: Seek to cyl 0, but not really there (ST3 = %b)\n", - fdu, st3, NE7_ST3BITS); - failed = 1; - } - - if (failed) { - if(fdc->retry < 3) - fdc->retry = 3; - return (retrier(fdc)); - } - } - - if (cyl != descyl) { - printf( - "fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n", - fdu, descyl, cyl, st0); - if (fdc->retry < 3) - fdc->retry = 3; - return (retrier(fdc)); - } - } - - fd->track = cylinder; - if (format) - fd->skip = (char *)&(finfo->fd_formb_cylno(0)) - - (char *)finfo; - if (!rdsectid && !(fdc->flags & FDC_NODMA)) - isa_dmastart(idf, bp->bio_data+fd->skip, - format ? bp->bio_bcount : fdblk, fdc->dmachan); - blknum = bp->bio_pblkno + fd->skip / fdblk; - sectrac = fd->ft->sectrac; - sec = blknum % (sectrac * fd->ft->heads); - head = sec / sectrac; - sec = sec % sectrac + 1; - if (head != 0 && fd->ft->offset_side2 != 0) - sec += fd->ft->offset_side2; - fd->hddrv = ((head&1)<<2)+fdu; - - if(format || !(read || rdsectid)) - { - /* make sure the drive is writable */ - if(fd_sense_drive_status(fdc, &st3) != 0) - { - /* stuck controller? */ - if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(idf, - bp->bio_data + fd->skip, - format ? bp->bio_bcount : fdblk, - fdc->dmachan); - fdc->retry = 6; /* reset the beast */ - return (retrier(fdc)); - } - if(st3 & NE7_ST3_WP) - { - /* - * XXX YES! this is ugly. - * in order to force the current operation - * to fail, we will have to fake an FDC - * error - all error handling is done - * by the retrier() - */ - fdc->status[0] = NE7_ST0_IC_AT; - fdc->status[1] = NE7_ST1_NW; - fdc->status[2] = 0; - fdc->status[3] = fd->track; - fdc->status[4] = head; - fdc->status[5] = sec; - fdc->retry = 8; /* break out immediately */ - fdc->state = IOTIMEDOUT; /* not really... */ - return (1); /* will return immediately */ - } - } - - if (format) { - ne7cmd = NE7CMD_FORMAT | mfm; - if (fdc->flags & FDC_NODMA) { - /* - * This seems to be necessary for - * whatever obscure reason; if we omit - * it, we end up filling the sector ID - * fields of the newly formatted track - * entirely with garbage, causing - * `wrong cylinder' errors all over - * the place when trying to read them - * back. - * - * Umpf. - */ - SET_BCDR(fdc, 1, bp->bio_bcount, 0); - - (void)fdcpio(fdc,bp->bio_cmd, - bp->bio_data+fd->skip, - bp->bio_bcount); - - } - /* formatting */ - if(fd_cmd(fdc, 6, ne7cmd, head << 2 | fdu, - finfo->fd_formb_secshift, - finfo->fd_formb_nsecs, - finfo->fd_formb_gaplen, - finfo->fd_formb_fillbyte, 0)) { - /* controller fell over */ - if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(idf, - bp->bio_data + fd->skip, - format ? bp->bio_bcount : fdblk, - fdc->dmachan); - fdc->retry = 6; - return (retrier(fdc)); - } - } else if (rdsectid) { - ne7cmd = NE7CMD_READID | mfm; - if (fd_cmd(fdc, 2, ne7cmd, head << 2 | fdu, 0)) { - /* controller jamming */ - fdc->retry = 6; - return (retrier(fdc)); - } - } else { - /* read or write operation */ - ne7cmd = (read ? NE7CMD_READ | NE7CMD_SK : NE7CMD_WRITE) | mfm; - if (fdc->flags & FDC_NODMA) { - /* - * This seems to be necessary even when - * reading data. - */ - SET_BCDR(fdc, 1, fdblk, 0); - - /* - * Perform the write pseudo-DMA before - * the WRITE command is sent. - */ - if (!read) - (void)fdcpio(fdc,bp->bio_cmd, - bp->bio_data+fd->skip, - fdblk); - } - if (fd_cmd(fdc, 9, - ne7cmd, - head << 2 | fdu, /* head & unit */ - fd->track, /* track */ - head, - sec, /* sector + 1 */ - fd->ft->secsize, /* sector size */ - sectrac, /* sectors/track */ - fd->ft->gap, /* gap size */ - fd->ft->datalen, /* data length */ - 0)) { - /* the beast is sleeping again */ - if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(idf, - bp->bio_data + fd->skip, - format ? bp->bio_bcount : fdblk, - fdc->dmachan); - fdc->retry = 6; - return (retrier(fdc)); - } - } - if (!rdsectid && (fdc->flags & FDC_NODMA)) - /* - * If this is a read, then simply await interrupt - * before performing PIO. - */ - if (read && !fdcpio(fdc,bp->bio_cmd, - bp->bio_data+fd->skip,fdblk)) { - fd->tohandle = timeout(fd_iotimeout, fdc, hz); - return(0); /* will return later */ - } - - /* - * Write (or format) operation will fall through and - * await completion interrupt. - */ - fdc->state = IOCOMPLETE; - fd->tohandle = timeout(fd_iotimeout, fdc, hz); - return (0); /* will return later */ - - case PIOREAD: - /* - * Actually perform the PIO read. The IOCOMPLETE case - * removes the timeout for us. - */ - (void)fdcpio(fdc,bp->bio_cmd,bp->bio_data+fd->skip,fdblk); - fdc->state = IOCOMPLETE; - /* FALLTHROUGH */ - case IOCOMPLETE: /* IO done, post-analyze */ - untimeout(fd_iotimeout, fdc, fd->tohandle); - - if (fd_read_status(fdc)) { - if (!rdsectid && !(fdc->flags & FDC_NODMA)) - isa_dmadone(idf, bp->bio_data + fd->skip, - format ? bp->bio_bcount : fdblk, - fdc->dmachan); - if (fdc->retry < 6) - fdc->retry = 6; /* force a reset */ - return (retrier(fdc)); - } - - fdc->state = IOTIMEDOUT; - - /* FALLTHROUGH */ - case IOTIMEDOUT: - if (!rdsectid && !(fdc->flags & FDC_NODMA)) - isa_dmadone(idf, bp->bio_data + fd->skip, - format ? bp->bio_bcount : fdblk, fdc->dmachan); - if (fdc->status[0] & NE7_ST0_IC) { - if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT - && fdc->status[1] & NE7_ST1_OR) { - /* - * DMA overrun. Someone hogged the bus and - * didn't release it in time for the next - * FDC transfer. - * - * We normally restart this without bumping - * the retry counter. However, in case - * something is seriously messed up (like - * broken hardware), we rather limit the - * number of retries so the IO operation - * doesn't block indefinately. - */ - if (fdc->dma_overruns++ < FDC_DMAOV_MAX) { - fdc->state = SEEKCOMPLETE; - return (1);/* will return immediately */ - } /* else fall through */ - } - if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_IV - && fdc->retry < 6) - fdc->retry = 6; /* force a reset */ - else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT - && fdc->status[2] & NE7_ST2_WC - && fdc->retry < 3) - fdc->retry = 3; /* force recalibrate */ - return (retrier(fdc)); - } - /* All OK */ - if (rdsectid) { - /* copy out ID field contents */ - idp = (struct fdc_readid *)bp->bio_data; - idp->cyl = fdc->status[3]; - idp->head = fdc->status[4]; - idp->sec = fdc->status[5]; - idp->secshift = fdc->status[6]; - } - /* Operation successful, retry DMA overruns again next time. */ - fdc->dma_overruns = 0; - fd->skip += fdblk; - if (!rdsectid && !format && fd->skip < bp->bio_bcount) { - /* set up next transfer */ - fdc->state = DOSEEK; - } else { - /* ALL DONE */ - fd->skip = 0; - bp->bio_resid = 0; - fdc->bp = NULL; - device_unbusy(fd->dev); - biofinish(bp, fd->device_stats, 0); - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - fdc->state = FINDWORK; - } - return (1); /* will return immediately */ - - case RESETCTLR: - fdc_reset(fdc); - fdc->retry++; - fdc->state = RESETCOMPLETE; - return (0); /* will return later */ - - case RESETCOMPLETE: - /* - * Discard all the results from the reset so that they - * can't cause an unexpected interrupt later. - */ - for (i = 0; i < 4; i++) - (void)fd_sense_int(fdc, &st0, &cyl); - fdc->state = STARTRECAL; - /* FALLTHROUGH */ - case STARTRECAL: -#ifdef PC98 - pc98_fd_check_ready(fdu); -#endif - if(fd_cmd(fdc, 2, NE7CMD_RECAL, fdu, 0)) { - /* arrgl */ - fdc->retry = 6; - return (retrier(fdc)); - } - fdc->state = RECALWAIT; - return (0); /* will return later */ - - case RECALWAIT: - /* allow heads to settle */ - timeout(fd_pseudointr, fdc, hz / 8); - fdc->state = RECALCOMPLETE; - return (0); /* will return later */ - - case RECALCOMPLETE: - do { - /* - * See SEEKCOMPLETE for a comment on this: - */ - if (fd_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID) - return (0); /* will return later */ - if(fdc->fdct == FDC_NE765 - && (st0 & NE7_ST0_IC) == NE7_ST0_IC_RC) - return (0); /* hope for a real intr */ - } while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC); - if ((st0 & NE7_ST0_IC) != NE7_ST0_IC_NT || cyl != 0) - { - if(fdc->retry > 3) - /* - * A recalibrate from beyond cylinder 77 - * will "fail" due to the FDC limitations; - * since people used to complain much about - * the failure message, try not logging - * this one if it seems to be the first - * time in a line. - */ - printf("fd%d: recal failed ST0 %b cyl %d\n", - fdu, st0, NE7_ST0BITS, cyl); - if(fdc->retry < 3) fdc->retry = 3; - return (retrier(fdc)); - } - fd->track = 0; - /* Seek (probably) necessary */ - fdc->state = DOSEEK; - return (1); /* will return immediately */ - - case MOTORWAIT: - if(fd->flags & FD_MOTOR_WAIT) - { - return (0); /* time's not up yet */ - } - if (fdc->flags & FDC_NEEDS_RESET) { - fdc->state = RESETCTLR; - fdc->flags &= ~FDC_NEEDS_RESET; - } else - fdc->state = DOSEEK; - return (1); /* will return immediately */ - - default: - device_printf(fdc->fdc_dev, "unexpected FD int->"); - if (fd_read_status(fdc) == 0) - printf("FDC status :%x %x %x %x %x %x %x ", - fdc->status[0], - fdc->status[1], - fdc->status[2], - fdc->status[3], - fdc->status[4], - fdc->status[5], - fdc->status[6] ); - else - printf("No status available "); - if (fd_sense_int(fdc, &st0, &cyl) != 0) - { - printf("[controller is dead now]\n"); - return (0); /* will return later */ - } - printf("ST0 = %x, PCN = %x\n", st0, cyl); - return (0); /* will return later */ - } - /* noone should ever get here */ -} - -static int -retrier(struct fdc_data *fdc) -{ - struct bio *bp; - struct fd_data *fd; - int fdu; - - bp = fdc->bp; - - /* XXX shouldn't this be cached somewhere? */ - fd = bp->bio_dev->si_drv1; - fdu = fd->fdu; - if (fd->options & FDOPT_NORETRY) - goto fail; - - switch (fdc->retry) { - case 0: case 1: case 2: - fdc->state = SEEKCOMPLETE; - break; - case 3: case 4: case 5: - fdc->state = STARTRECAL; - break; - case 6: - fdc->state = RESETCTLR; - break; - case 7: - break; - default: - fail: - if ((fd->options & FDOPT_NOERRLOG) == 0) { - disk_err(bp, "hard error", - fdc->fd->skip / DEV_BSIZE, 0); - if (fdc->flags & FDC_STAT_VALID) { - printf( - " (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n", - fdc->status[0], NE7_ST0BITS, - fdc->status[1], NE7_ST1BITS, - fdc->status[2], NE7_ST2BITS, - fdc->status[3], fdc->status[4], - fdc->status[5]); - } - else - printf(" (No status)\n"); - } - if ((fd->options & FDOPT_NOERROR) == 0) { - bp->bio_flags |= BIO_ERROR; - bp->bio_error = EIO; - bp->bio_resid = bp->bio_bcount - fdc->fd->skip; - } else - bp->bio_resid = 0; - fdc->bp = NULL; - fdc->fd->skip = 0; - device_unbusy(fd->dev); - biofinish(bp, fdc->fd->device_stats, 0); - fdc->state = FINDWORK; - fdc->flags |= FDC_NEEDS_RESET; - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - return (1); - } - fdc->retry++; - return (1); -} - -static void -fdbiodone(struct bio *bp) -{ - wakeup(bp); -} - -static int -fdmisccmd(struct cdev *dev, u_int cmd, void *data) -{ - fdu_t fdu; - fd_p fd; - struct bio *bp; - struct fd_formb *finfo; - struct fdc_readid *idfield; - size_t fdblk; - int error; - - fd = dev->si_drv1; - fdu = fd->fdu; - fdblk = 128 << fd->ft->secsize; - finfo = (struct fd_formb *)data; - idfield = (struct fdc_readid *)data; - - bp = malloc(sizeof(struct bio), M_TEMP, M_WAITOK | M_ZERO); - - /* - * Set up a bio request for fdstrategy(). bio_offset is faked - * so that fdstrategy() will seek to the requested - * cylinder, and use the desired head. - */ - bp->bio_cmd = cmd; - if (cmd == FDBIO_FORMAT) { - bp->bio_offset = - (finfo->cyl * (fd->ft->sectrac * fd->ft->heads) + - finfo->head * fd->ft->sectrac) * fdblk; - bp->bio_bcount = sizeof(struct fd_idfield_data) * - finfo->fd_formb_nsecs; - } else if (cmd == FDBIO_RDSECTID) { - bp->bio_offset = - (idfield->cyl * (fd->ft->sectrac * fd->ft->heads) + - idfield->head * fd->ft->sectrac) * fdblk; - bp->bio_bcount = sizeof(struct fdc_readid); - } else - panic("wrong cmd in fdmisccmd()"); - bp->bio_data = data; - bp->bio_dev = dev; - bp->bio_done = fdbiodone; - bp->bio_flags = 0; - - /* Now run the command. */ - fdstrategy(bp); - error = biowait(bp, "fdcmd"); - - free(bp, M_TEMP); - return (error); -} - -static int -fdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) -{ - fdu_t fdu; - fd_p fd; - struct fdc_status *fsp; - struct fdc_readid *rid; - int error; - - fd = dev->si_drv1; - fdu = fd->fdu; - -#ifdef PC98 - pc98_fd_check_ready(fdu); -#endif - - /* - * First, handle everything that could be done with - * FD_NONBLOCK still being set. - */ - switch (cmd) { - - case DIOCGMEDIASIZE: - if (fd->ft == 0) - return ((fd->flags & FD_NONBLOCK) ? EAGAIN : ENXIO); - *(off_t *)addr = (128 << (fd->ft->secsize)) * fd->ft->size; - return (0); - - case DIOCGSECTORSIZE: - if (fd->ft == 0) - return ((fd->flags & FD_NONBLOCK) ? EAGAIN : ENXIO); - *(u_int *)addr = 128 << (fd->ft->secsize); - return (0); - - case FIONBIO: - if (*(int *)addr != 0) - fd->flags |= FD_NONBLOCK; - else { - if (fd->ft == 0) { - /* - * No drive type has been selected yet, - * cannot turn FNONBLOCK off. - */ - return (EINVAL); - } - fd->flags &= ~FD_NONBLOCK; - } - return (0); - - case FIOASYNC: - /* keep the generic fcntl() code happy */ - return (0); - - case FD_GTYPE: /* get drive type */ - if (fd->ft == 0) - /* no type known yet, return the native type */ - *(struct fd_type *)addr = fd_native_types[fd->type]; - else - *(struct fd_type *)addr = *fd->ft; - return (0); - - case FD_STYPE: /* set drive type */ - /* - * Allow setting drive type temporarily iff - * currently unset. Used for fdformat so any - * user can set it, and then start formatting. - */ - if (fd->ft) - return (EINVAL); /* already set */ - fd->fts[0] = *(struct fd_type *)addr; - fd->ft = &fd->fts[0]; - fd->flags |= FD_UA; - return (0); - - case FD_GOPTS: /* get drive options */ - *(int *)addr = fd->options + FDOPT_AUTOSEL; - return (0); - - case FD_SOPTS: /* set drive options */ - fd->options = *(int *)addr & ~FDOPT_AUTOSEL; - return (0); - -#ifdef FDC_DEBUG - case FD_DEBUG: - if ((fd_debug != 0) != (*(int *)addr != 0)) { - fd_debug = (*(int *)addr != 0); - printf("fd%d: debugging turned %s\n", - fd->fdu, fd_debug ? "on" : "off"); - } - return (0); -#endif - - case FD_CLRERR: - if (priv_check(td, PRIV_DRIVER) != 0) - return (EPERM); - fd->fdc->fdc_errs = 0; - return (0); - - case FD_GSTAT: - fsp = (struct fdc_status *)addr; - if ((fd->fdc->flags & FDC_STAT_VALID) == 0) - return (EINVAL); - memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int)); - return (0); - - case FD_GDTYPE: - *(enum fd_drivetype *)addr = fd->type; - return (0); - } - - /* - * Now handle everything else. Make sure we have a valid - * drive type. - */ - if (fd->flags & FD_NONBLOCK) - return (EAGAIN); - if (fd->ft == 0) - return (ENXIO); - error = 0; - - switch (cmd) { - - case FD_FORM: - if ((flag & FWRITE) == 0) - return (EBADF); /* must be opened for writing */ - if (((struct fd_formb *)addr)->format_version != - FD_FORMAT_VERSION) - return (EINVAL); /* wrong version of formatting prog */ - error = fdmisccmd(dev, FDBIO_FORMAT, addr); - break; - - case FD_GTYPE: /* get drive type */ - *(struct fd_type *)addr = *fd->ft; - break; - - case FD_STYPE: /* set drive type */ - /* this is considered harmful; only allow for superuser */ - if (priv_check(td, PRIV_DRIVER) != 0) - return (EPERM); - *fd->ft = *(struct fd_type *)addr; - break; - - case FD_GOPTS: /* get drive options */ - *(int *)addr = fd->options; - break; - - case FD_SOPTS: /* set drive options */ - fd->options = *(int *)addr; - break; - -#ifdef FDC_DEBUG - case FD_DEBUG: - if ((fd_debug != 0) != (*(int *)addr != 0)) { - fd_debug = (*(int *)addr != 0); - printf("fd%d: debugging turned %s\n", - fd->fdu, fd_debug ? "on" : "off"); - } - break; -#endif - - case FD_CLRERR: - if (priv_check(td, PRIV_DRIVER) != 0) - return (EPERM); - fd->fdc->fdc_errs = 0; - break; - - case FD_GSTAT: - fsp = (struct fdc_status *)addr; - if ((fd->fdc->flags & FDC_STAT_VALID) == 0) - return (EINVAL); - memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int)); - break; - - case FD_READID: - rid = (struct fdc_readid *)addr; - if (rid->cyl > MAX_CYLINDER || rid->head > MAX_HEAD) - return (EINVAL); - error = fdmisccmd(dev, FDBIO_RDSECTID, addr); - break; - - default: - error = ENOTTY; - break; - } - return (error); -} diff --git a/sys/pc98/cbus/fdcreg.h b/sys/pc98/cbus/fdcreg.h deleted file mode 100644 index 6d8e7e115d0d..000000000000 --- a/sys/pc98/cbus/fdcreg.h +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 1991 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. - * 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. - * - * from: @(#)fdreg.h 7.1 (Berkeley) 5/9/91 - * $FreeBSD$ - */ - -/* - * AT floppy controller registers and bitfields - */ - -/* uses NEC765 controller */ -#include - -#ifdef PC98 -/* registers */ -#define FDSTS 0 /* NEC 765 Main Status Register (R) */ -#define FDDATA 1 /* NEC 765 Data Register (R/W) */ -#define FDCTL 2 /* FD Control Register */ -#define FDC_RST 0x80 /* FDC RESET */ -#define FDC_RDY 0x40 /* force READY */ -#define FDC_DD 0x20 /* FDD Mode Exchange 0:1M 1:640K */ -#define FDC_DMAE 0x10 /* enable floppy DMA */ -#define FDC_MTON 0x08 /* MOTOR ON (when EMTON=1)*/ -#define FDC_TMSK 0x04 /* TIMER MASK */ -#define FDC_TTRG 0x01 /* TIMER TRIGER */ - -#define FDP_EMTON 0x04 /* enable MTON */ -#define FDP_FDDEXC 0x02 /* FDD Mode Exchange 1:1M 0:640K */ -#define FDP_PORTEXC 0x01 /* PORT Exchane 1:1M 0:640K */ - -#else -/* registers */ -#define FDOUT 2 /* Digital Output Register (W) */ -#define FDO_FDSEL 0x03 /* floppy device select */ -#define FDO_FRST 0x04 /* floppy controller reset */ -#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */ -#define FDO_MOEN0 0x10 /* motor enable drive 0 */ -#define FDO_MOEN1 0x20 /* motor enable drive 1 */ -#define FDO_MOEN2 0x40 /* motor enable drive 2 */ -#define FDO_MOEN3 0x80 /* motor enable drive 3 */ - -#define FDSTS 4 /* NEC 765 Main Status Register (R) */ -#define FDDATA 5 /* NEC 765 Data Register (R/W) */ -#define FDCTL 7 /* Control Register (W) */ -#endif /* PC98 */ - -/* - * The definitions for FDC_500KBPS etc. have been moved out to - * since they need to be visible in userland. They cover the lower two bits - * of FDCTL when used for output. - */ -/* - * this is the secret PIO data port (offset from base) - */ -#define FDC_YE_DATAPORT 6 - -#ifndef PC98 -#define FDIN 7 /* Digital Input Register (R) */ -#define FDI_DCHG 0x80 /* diskette has been changed */ - /* requires drive and motor being selected */ - /* is cleared by any step pulse to drive */ -#endif diff --git a/sys/pc98/cbus/fdcvar.h b/sys/pc98/cbus/fdcvar.h deleted file mode 100644 index 4ae53d95ac59..000000000000 --- a/sys/pc98/cbus/fdcvar.h +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * Copyright (c) 2004 M. Warner Losh. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following 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. 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$ - */ - -/* XXX should audit this file to see if additional copyrights needed */ - -enum fdc_type -{ - FDC_NE765, FDC_ENHANCED, FDC_UNKNOWN = -1 -}; - -enum fdc_states { - DEVIDLE, - FINDWORK, - DOSEEK, - SEEKCOMPLETE , - IOCOMPLETE, - RECALCOMPLETE, - STARTRECAL, - RESETCTLR, - SEEKWAIT, - RECALWAIT, - MOTORWAIT, - IOTIMEDOUT, - RESETCOMPLETE, - PIOREAD -}; - -#ifdef FDC_DEBUG -static char const * const fdstates[] = { - "DEVIDLE", - "FINDWORK", - "DOSEEK", - "SEEKCOMPLETE", - "IOCOMPLETE", - "RECALCOMPLETE", - "STARTRECAL", - "RESETCTLR", - "SEEKWAIT", - "RECALWAIT", - "MOTORWAIT", - "IOTIMEDOUT", - "RESETCOMPLETE", - "PIOREAD" -}; -#endif - -/* - * Per controller structure (softc). - */ -struct fdc_data -{ - int fdcu; /* our unit number */ - int dmacnt; - int dmachan; - int flags; -#define FDC_STAT_VALID 0x08 -#define FDC_HAS_FIFO 0x10 -#define FDC_NEEDS_RESET 0x20 -#define FDC_NODMA 0x40 -#define FDC_ISPNP 0x80 -#define FDC_ISPCMCIA 0x100 - struct fd_data *fd; - int fdu; /* the active drive */ - enum fdc_states state; - int retry; -#ifndef PC98 - int fdout; /* mirror of the w/o digital output reg */ -#endif - u_int status[7]; /* copy of the registers */ - enum fdc_type fdct; /* chip version of FDC */ - int fdc_errs; /* number of logged errors */ - int dma_overruns; /* number of DMA overruns */ - struct bio_queue_head head; - struct bio *bp; /* active buffer */ -#ifdef PC98 - struct resource *res_ioport, *res_fdsio, *res_fdemsio; - struct resource *res_irq, *res_drq; - int rid_ioport, rid_irq, rid_drq; -#else - struct resource *res_ioport, *res_ctl, *res_irq, *res_drq; - int rid_ioport, rid_ctl, rid_irq, rid_drq; -#endif - int port_off; - bus_space_tag_t portt; - bus_space_handle_t porth; -#ifdef PC98 - bus_space_tag_t sc_fdsiot; - bus_space_handle_t sc_fdsioh; - bus_space_tag_t sc_fdemsiot; - bus_space_handle_t sc_fdemsioh; -#else - bus_space_tag_t ctlt; - bus_space_handle_t ctlh; -#endif - void *fdc_intr; - struct device *fdc_dev; -#ifndef PC98 - void (*fdctl_wr)(struct fdc_data *fdc, u_int8_t v); -#endif -}; - -typedef int fdu_t; -typedef int fdcu_t; -typedef int fdsu_t; -typedef struct fd_data *fd_p; -typedef struct fdc_data *fdc_p; -typedef enum fdc_type fdc_t; - -/* error returns for fd_cmd() */ -#define FD_FAILED -1 -#define FD_NOT_VALID -2 -#define FDC_ERRMAX 100 /* do not log more */ - -extern devclass_t fdc_devclass; - -enum fdc_device_ivars { - FDC_IVAR_FDUNIT, - FDC_IVAR_FDTYPE, -}; - -__BUS_ACCESSOR(fdc, fdunit, FDC, FDUNIT, int); -__BUS_ACCESSOR(fdc, fdtype, FDC, FDTYPE, int); - -int fdc_alloc_resources(struct fdc_data *); -#ifndef PC98 -void fdout_wr(fdc_p, u_int8_t); -#endif -int fd_cmd(struct fdc_data *, int, ...); -void fdc_release_resources(struct fdc_data *); -int fdc_attach(device_t); -int fdc_hints_probe(device_t); -int fdc_detach(device_t dev); -device_t fdc_add_child(device_t, const char *, int); -int fdc_initial_reset(struct fdc_data *); -int fdc_print_child(device_t, device_t); -int fdc_read_ivar(device_t, device_t, int, uintptr_t *); -int fdc_write_ivar(device_t, device_t, int, uintptr_t); -#ifndef PC98 -int fdc_isa_alloc_resources(device_t, struct fdc_data *); -#endif diff --git a/sys/pc98/cbus/olpt.c b/sys/pc98/cbus/olpt.c index 2423d6e86e24..9aa821271c8e 100644 --- a/sys/pc98/cbus/olpt.c +++ b/sys/pc98/cbus/olpt.c @@ -140,6 +140,7 @@ struct lpt_softc { struct resource *res_port; struct resource *res_irq; void *sc_ih; + struct callout timer; int sc_port; short sc_state; @@ -319,6 +320,7 @@ lpt_attach(device_t dev) unit = device_get_unit(dev); sc = device_get_softc(dev); + callout_init(&sc->timer, 0); rid = 0; sc->res_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, @@ -418,8 +420,8 @@ lptopen (struct cdev *dev, int flags, int fmt, struct thread *td) lprintf(("irq %x\n", sc->sc_irq)); if (sc->sc_irq & LP_USE_IRQ) { sc->sc_state |= TOUT; - timeout (lptout, (caddr_t)sc, - (sc->sc_backoff = hz/LPTOUTINITIAL)); + sc->sc_backoff = hz / LPTOUTINITIAL;; + callout_reset(&sc->timer, sc->sc_backoff, lptout, sc); } lprintf(("opened.\n")); @@ -437,7 +439,7 @@ lptout (void *arg) sc->sc_backoff++; if (sc->sc_backoff > hz/LPTOUTMAX) sc->sc_backoff = sc->sc_backoff > hz/LPTOUTMAX; - timeout (lptout, (caddr_t)sc, sc->sc_backoff); + callout_reset(&sc->timer, sc->sc_backoff, lptout, sc); } else sc->sc_state &= ~TOUT; diff --git a/sys/pc98/cbus/pckbd.c b/sys/pc98/cbus/pckbd.c index e424294f0e75..92331b6a7a87 100644 --- a/sys/pc98/cbus/pckbd.c +++ b/sys/pc98/cbus/pckbd.c @@ -52,6 +52,19 @@ /* device configuration flags */ #define KB_CONF_FAIL_IF_NO_KBD (1 << 0) /* don't install if no kbd is found */ +typedef caddr_t KBDC; + +typedef struct pckbd_state { + KBDC kbdc; /* keyboard controller */ + int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ + int ks_flags; /* flags */ +#define COMPOSE (1 << 0) + int ks_state; /* shift/lock key state */ + int ks_accents; /* accent key index (> 0) */ + u_int ks_composed_char; /* composed char code (> 0) */ + struct callout ks_timer; +} pckbd_state_t; + static devclass_t pckbd_devclass; static int pckbdprobe(device_t dev); @@ -186,6 +199,7 @@ static int pckbd_attach_unit(device_t dev, keyboard_t **kbd, int port, int irq, int flags) { keyboard_switch_t *sw; + pckbd_state_t *state; int args[2]; int error; int unit; @@ -218,6 +232,8 @@ pckbd_attach_unit(device_t dev, keyboard_t **kbd, int port, int irq, int flags) * This is a kludge to compensate for lost keyboard interrupts. * A similar code used to be in syscons. See below. XXX */ + state = (pckbd_state_t *)(*kbd)->kb_data; + callout_init(&state->ks_timer, 0); pckbd_timeout(*kbd); if (bootverbose) @@ -229,6 +245,7 @@ pckbd_attach_unit(device_t dev, keyboard_t **kbd, int port, int irq, int flags) static void pckbd_timeout(void *arg) { + pckbd_state_t *state; keyboard_t *kbd; int s; @@ -259,7 +276,8 @@ pckbd_timeout(void *arg) kbdd_intr(kbd, NULL); } splx(s); - timeout(pckbd_timeout, arg, hz/10); + state = (pckbd_state_t *)kbd->kb_data; + callout_reset(&state->ks_timer, hz / 10, pckbd_timeout, arg); } /* LOW-LEVEL */ @@ -268,18 +286,6 @@ pckbd_timeout(void *arg) #define PC98KBD_DEFAULT 0 -typedef caddr_t KBDC; - -typedef struct pckbd_state { - KBDC kbdc; /* keyboard controller */ - int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ - int ks_flags; /* flags */ -#define COMPOSE (1 << 0) - int ks_state; /* shift/lock key state */ - int ks_accents; /* accent key index (> 0) */ - u_int ks_composed_char; /* composed char code (> 0) */ -} pckbd_state_t; - /* keyboard driver declaration */ static int pckbd_configure(int flags); static kbd_probe_t pckbd_probe; @@ -486,7 +492,10 @@ pckbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) static int pckbd_term(keyboard_t *kbd) { + pckbd_state_t *state = (pckbd_state_t *)kbd->kb_data; + kbd_unregister(kbd); + callout_drain(&state->ks_timer); return 0; } diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC index 7386c1f737d3..9882bc4b1bbf 100644 --- a/sys/pc98/conf/GENERIC +++ b/sys/pc98/conf/GENERIC @@ -35,6 +35,7 @@ options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists options UFS_DIRHASH # Improve performance on big directories options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options QUOTA # Enable disk quotas for UFS options MD_ROOT # MD is a potential root device options NFSCL # New Network Filesystem Client options NFSD # New Network Filesystem Server @@ -60,15 +61,18 @@ options SYSVSHM # SYSV-style shared memory options SYSVMSG # SYSV-style message queues options SYSVSEM # SYSV-style semaphores options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. options KBD_INSTALL_CDEV # install a CDEV entry in /dev options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) options AUDIT # Security event auditing options CAPABILITY_MODE # Capsicum capability mode options CAPABILITIES # Capsicum capabilities options MAC # TrustedBSD MAC Framework -options INCLUDE_CONFIG_FILE # Include this file in kernel -options KDB # Kernel debugger related code -options KDB_TRACE # Print a stack trace for a panic +options INCLUDE_CONFIG_FILE # Include this file in kernel + +# Debugging support. Always need this: +options KDB # Enable kernel debugger support. +options KDB_TRACE # Print a stack trace for a panic. # To make an SMP kernel, the next two lines are needed #options SMP # Symmetric MultiProcessor Kernel @@ -81,47 +85,48 @@ device pci device fdc # ATA controllers -device ahci # AHCI-compatible SATA controllers -device ata # Legacy ATA/SATA controllers -options ATA_STATIC_ID # Static device numbering -device mvs # Marvell 88SX50XX/88SX60XX/88SX70XX/SoC SATA -device siis # SiliconImage SiI3124/SiI3132/SiI3531 SATA +device ahci # AHCI-compatible SATA controllers +device ata # Legacy ATA/SATA controllers +options ATA_STATIC_ID # Static device numbering +device mvs # Marvell 88SX50XX/88SX60XX/88SX70XX/SoC SATA +device siis # SiliconImage SiI3124/SiI3132/SiI3531 SATA # SCSI Controllers -device adv # Advansys SCSI adapters -device ahc # AHA2940 and onboard AIC7xxx devices -device esp # AMD Am53C974 (Tekram DC-390(T)) -device isp # Qlogic family -#device ncr # NCR/Symbios Logic -device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') +device ahc # AHA2940 and onboard AIC7xxx devices +device esp # AMD Am53C974 (Tekram DC-390(T)) +device isp # Qlogic family +#device ncr # NCR/Symbios Logic +device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') -device aic # PC-9801-100 -device ct # host adapter using WD33C93[ABC] chip (C bus) +device adv # Advansys SCSI adapters +device aic # PC-9801-100 +device ct # host adapter using WD33C93[ABC] chip -device ncv # NCR 53C500 -device nsp # Workbit Ninja SCSI-3 -device stg # TMC 18C30/18C50 +device ncv # NCR 53C500 +device nsp # Workbit Ninja SCSI-3 +device stg # TMC 18C30/18C50 # ATA/SCSI peripherals -device scbus # SCSI bus (required for ATA/SCSI) -device ch # SCSI media changers -device da # Direct Access (disks) -device sa # Sequential Access (tape etc) -device cd # CD -device pass # Passthrough device (direct ATA/SCSI access) -device ses # Enclosure Services (SES and SAF-TE) +device scbus # SCSI bus (required for ATA/SCSI) +device ch # SCSI media changers +device da # Direct Access (disks) +device sa # Sequential Access (tape etc) +device cd # CD +device pass # Passthrough device (direct ATA/SCSI access) +device ses # Enclosure Services (SES and SAF-TE) +#device ctl # CAM Target Layer # keyboard driver -device pckbd # PC98 keyboard +device pckbd # PC98 keyboard -device gdc # GDC screen +device gdc # GDC screen -device splash # Splash screen and screen saver support +device splash # Splash screen and screen saver support # syscons is the default console driver, resembling an SCO console device sc -#device agp # support several AGP chipsets +#device agp # support several AGP chipsets # Power management support (see NOTES for more options) #device apm @@ -133,114 +138,116 @@ device sc # PCCARD (PCMCIA) support # PCMCIA and cardbus bridge support -device cbb # cardbus (yenta) bridge -device pccard # PC Card (16-bit) bus -device cardbus # CardBus (32-bit) bus +device cbb # cardbus (yenta) bridge +device pccard # PC Card (16-bit) bus +device cardbus # CardBus (32-bit) bus # Serial (COM) ports #options COM_MULTIPORT -#options COM_ESP # ESP98 -#device sio # 8250, 16[45]50, 8251 based serial ports -device uart # Generic UART driver +#options COM_ESP # ESP98 +#device sio # 8250, 16[45]50, 8251 based serial ports +device uart # Generic UART driver device mse #device joy -# NEW Parallel port +# Parallel port device ppc -device ppbus # Parallel port bus (required) -device lpt # Printer -device ppi # Parallel port interface device -#device vpo # Requires scbus and da +device ppbus # Parallel port bus (required) +device lpt # Printer +device ppi # Parallel port interface device +#device vpo # Requires scbus and da # OLD Parallel port #device olpt +device puc # Multi I/O cards and multi-channel UARTs + # PCI Ethernet NICs. -device de # DEC/Intel DC21x4x (``Tulip'') -#device em # Intel PRO/1000 adapter Gigabit Ethernet Card -device le # AMD Am7900 LANCE and Am79C9xx PCnet -#device ti # Alteon Networks Tigon I/II gigabit Ethernet -device txp # 3Com 3cR990 (``Typhoon'') -device vx # 3Com 3c590, 3c595 (``Vortex'') +device de # DEC/Intel DC21x4x (``Tulip'') +#device em # Intel PRO/1000 Gigabit Ethernet Family +device le # AMD Am7900 LANCE and Am79C9xx PCnet +#device ti # Alteon Networks Tigon I/II gigabit Ethernet +device txp # 3Com 3cR990 (``Typhoon'') +device vx # 3Com 3c590, 3c595 (``Vortex'') # PCI Ethernet NICs that use the common MII bus controller code. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! -device miibus # MII bus support -device bfe # Broadcom BCM440x 10/100 Ethernet -#device bge # Broadcom BCM570xx Gigabit Ethernet -device dc # DEC/Intel 21143 and various workalikes -device fxp # Intel EtherExpress PRO/100B (82557, 82558) -#device lge # Level 1 LXT1001 gigabit Ethernet -#device nge # NatSemi DP83820 gigabit Ethernet -device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') -device re # RealTek 8139C+/8169/8169S/8110S -device rl # RealTek 8129/8139 -device sf # Adaptec AIC-6915 (``Starfire'') -device sis # Silicon Integrated Systems SiS 900/SiS 7016 -#device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet -device ste # Sundance ST201 (D-Link DFE-550TX) -device tl # Texas Instruments ThunderLAN -device tx # SMC EtherPower II (83c170 ``EPIC'') -#device vge # VIA VT612x gigabit Ethernet -device vr # VIA Rhine, Rhine II -device wb # Winbond W89C840F -device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') +device miibus # MII bus support +device bfe # Broadcom BCM440x 10/100 Ethernet +#device bge # Broadcom BCM570xx Gigabit Ethernet +device dc # DEC/Intel 21143 and various workalikes +device fxp # Intel EtherExpress PRO/100B (82557, 82558) +#device lge # Level 1 LXT1001 gigabit Ethernet +#device nge # NatSemi DP83820 gigabit Ethernet +device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') +device re # RealTek 8139C+/8169/8169S/8110S +device rl # RealTek 8129/8139 +device sf # Adaptec AIC-6915 (``Starfire'') +device sis # Silicon Integrated Systems SiS 900/SiS 7016 +#device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet +device ste # Sundance ST201 (D-Link DFE-550TX) +device tl # Texas Instruments ThunderLAN +device tx # SMC EtherPower II (83c170 ``EPIC'') +#device vge # VIA VT612x gigabit Ethernet +device vr # VIA Rhine, Rhine II +device wb # Winbond W89C840F +device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') # ISA Ethernet NICs. pccard NICs included. # 'device ed' requires 'device miibus' -device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards -device ep # Etherlink III based cards -device fe # Fujitsu MB8696x based cards -device sn # SMC's 9000 series of Ethernet chips +device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards +device ep # Etherlink III based cards +device fe # Fujitsu MB8696x based cards +device sn # SMC's 9000 series of Ethernet chips device snc -device xe # Xircom pccard Ethernet +device xe # Xircom pccard Ethernet # Wireless NIC cards -#device wlan # 802.11 support -#options IEEE80211_DEBUG # enable debug msgs +#device wlan # 802.11 support +#options IEEE80211_DEBUG # enable debug msgs #options IEEE80211_AMPDU_AGE # age frames in AMPDU reorder q's options IEEE80211_SUPPORT_MESH # enable 802.11s draft support -#device wlan_wep # 802.11 WEP support -#device wlan_ccmp # 802.11 CCMP support -#device wlan_tkip # 802.11 TKIP support -#device wlan_amrr # AMRR transmit rate control algorithm -#device an # Aironet 4500/4800 802.11 wireless NICs. -#device ath # Atheros NICs -#device ath_pci # Atheros pci/cardbus glue -#device ath_hal # pci/cardbus chip support +#device wlan_wep # 802.11 WEP support +#device wlan_ccmp # 802.11 CCMP support +#device wlan_tkip # 802.11 TKIP support +#device wlan_amrr # AMRR transmit rate control algorithm +#device an # Aironet 4500/4800 802.11 wireless NICs. +#device ath # Atheros NICs +#device ath_pci # Atheros pci/cardbus glue +#device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors -#device ath_rate_sample # SampleRate tx rate control for ath -#device ral # Ralink Technology RT2500 wireless NICs. -#device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. -#device wl # Older non 802.11 Wavelan wireless NIC. +#device ath_rate_sample # SampleRate tx rate control for ath +#device ral # Ralink Technology RT2500 wireless NICs. +#device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. +#device wl # Older non 802.11 Wavelan wireless NIC. # Pseudo devices. -device loop # Network loopback -device random # Entropy device -device ether # Ethernet support -device vlan # 802.1Q VLAN support -device tun # Packet tunnel. -device md # Memory "disks" -device gif # IPv6 and IPv4 tunneling -device faith # IPv6-to-IPv4 relaying (translation) -device firmware # firmware assist module +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device vlan # 802.1Q VLAN support +device tun # Packet tunnel. +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) +device firmware # firmware assist module # The `bpf' device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! # Note that 'bpf' is required for DHCP. -device bpf # Berkeley packet filter +device bpf # Berkeley packet filter # USB support -#options USB_DEBUG # enable debug msgs -#device uhci # UHCI PCI->USB interface -#device ohci # OHCI PCI->USB interface -#device ehci # EHCI PCI->USB interface (USB 2.0) -#device usb # USB Bus (required) -#device ukbd # Keyboard -#device umass # Disks/Mass storage - Requires scbus and da +#options USB_DEBUG # enable debug msgs +#device uhci # UHCI PCI->USB interface +#device ohci # OHCI PCI->USB interface +#device ehci # EHCI PCI->USB interface (USB 2.0) +#device usb # USB Bus (required) +#device ukbd # Keyboard +#device umass # Disks/Mass storage - Requires scbus and da # Sound support -#device sound # Generic sound driver (required) -#device snd_mss # Microsoft Sound System -#device "snd_sb16" # Sound Blaster 16 -#device snd_sbc # Sound Blaster +#device sound # Generic sound driver (required) +#device snd_mss # Microsoft Sound System +#device "snd_sb16" # Sound Blaster 16 +#device snd_sbc # Sound Blaster diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c deleted file mode 100644 index 4ae80ae5eada..000000000000 --- a/sys/pc98/pc98/machdep.c +++ /dev/null @@ -1,3003 +0,0 @@ -/*- - * Copyright (c) 1992 Terrence R. Lambert. - * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that 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. - * - * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_apic.h" -#include "opt_atpic.h" -#include "opt_compat.h" -#include "opt_cpu.h" -#include "opt_ddb.h" -#include "opt_inet.h" -#include "opt_isa.h" -#include "opt_kstack_pages.h" -#include "opt_maxmem.h" -#include "opt_mp_watchdog.h" -#include "opt_npx.h" -#include "opt_perfmon.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 -#ifdef SMP -#include -#endif -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DDB -#ifndef KDB -#error KDB must be enabled in order for DDB to work! -#endif -#include -#include -#endif - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef PERFMON -#include -#endif -#ifdef SMP -#include -#endif - -#ifdef DEV_APIC -#include -#endif - -#ifdef DEV_ISA -#include -#endif - -/* Sanity check for __curthread() */ -CTASSERT(offsetof(struct pcpu, pc_curthread) == 0); - -extern void init386(int first); -extern void dblfault_handler(void); - -#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) -#define EFL_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) - -#if !defined(CPU_DISABLE_SSE) && defined(I686_CPU) -#define CPU_ENABLE_SSE -#endif - -static void cpu_startup(void *); -static void fpstate_drop(struct thread *td); -static void get_fpcontext(struct thread *td, mcontext_t *mcp); -static int set_fpcontext(struct thread *td, const mcontext_t *mcp); -#ifdef CPU_ENABLE_SSE -static void set_fpregs_xmm(struct save87 *, struct savexmm *); -static void fill_fpregs_xmm(struct savexmm *, struct save87 *); -#endif /* CPU_ENABLE_SSE */ -SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); - -int need_pre_dma_flush; /* If 1, use wbinvd befor DMA transfer. */ -int need_post_dma_flush; /* If 1, use invd after DMA transfer. */ - -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif - -int _udatasel, _ucodesel; -u_int basemem; - -static int ispc98 = 1; -SYSCTL_INT(_machdep, OID_AUTO, ispc98, CTLFLAG_RD, &ispc98, 0, ""); - -int cold = 1; - -#ifdef COMPAT_43 -static void osendsig(sig_t catcher, ksiginfo_t *, sigset_t *mask); -#endif -#ifdef COMPAT_FREEBSD4 -static void freebsd4_sendsig(sig_t catcher, ksiginfo_t *, sigset_t *mask); -#endif - -long Maxmem = 0; -long realmem = 0; - -/* - * The number of PHYSMAP entries must be one less than the number of - * PHYSSEG entries because the PHYSMAP entry that spans the largest - * physical address that is accessible by ISA DMA is split into two - * PHYSSEG entries. - */ -#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1)) - -vm_paddr_t phys_avail[PHYSMAP_SIZE + 2]; -vm_paddr_t dump_avail[PHYSMAP_SIZE + 2]; - -/* must be 2 less so 0 0 can signal end of chunks */ -#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(phys_avail[0])) - 2) -#define DUMP_AVAIL_ARRAY_END ((sizeof(dump_avail) / sizeof(dump_avail[0])) - 2) - -struct kva_md_info kmi; - -static struct trapframe proc0_tf; -struct pcpu __pcpu[MAXCPU]; - -struct mtx icu_lock; - -struct mem_range_softc mem_range_softc; - - /* Default init_ops implementation. */ - struct init_ops init_ops = { - .early_clock_source_init = i8254_init, - .early_delay = i8254_delay, - }; - -static void -cpu_startup(dummy) - void *dummy; -{ - uintmax_t memsize; - - /* - * Good {morning,afternoon,evening,night}. - */ - startrtclock(); - printcpuinfo(); - panicifcpuunsupported(); -#ifdef PERFMON - perfmon_init(); -#endif - realmem = Maxmem; - - /* - * Display physical memory. - */ - memsize = ptoa((uintmax_t)Maxmem); - printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20); - - /* - * Display any holes after the first chunk of extended memory. - */ - if (bootverbose) { - int indx; - - printf("Physical memory chunk(s):\n"); - for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) { - vm_paddr_t size; - - size = phys_avail[indx + 1] - phys_avail[indx]; - printf( - "0x%016jx - 0x%016jx, %ju bytes (%ju pages)\n", - (uintmax_t)phys_avail[indx], - (uintmax_t)phys_avail[indx + 1] - 1, - (uintmax_t)size, (uintmax_t)size / PAGE_SIZE); - } - } - - vm_ksubmap_init(&kmi); - - printf("avail memory = %ju (%ju MB)\n", - ptoa((uintmax_t)vm_cnt.v_free_count), - ptoa((uintmax_t)vm_cnt.v_free_count) / 1048576); - - /* - * Set up buffers, so they can be used to read disk labels. - */ - bufinit(); - vm_pager_bufferinit(); - cpu_setregs(); -} - -/* - * Send an interrupt to process. - * - * Stack is set up to allow sigcode stored - * at top to call routine, followed by kcall - * to sigreturn routine below. After sigreturn - * resets the signal mask, the stack, and the - * frame pointer, it returns to the user - * specified pc, psl. - */ -#ifdef COMPAT_43 -static void -osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) -{ - struct osigframe sf, *fp; - struct proc *p; - struct thread *td; - struct sigacts *psp; - struct trapframe *regs; - int sig; - int oonstack; - - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - sig = ksi->ksi_signo; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); - regs = td->td_frame; - oonstack = sigonstack(regs->tf_esp); - - /* Allocate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - fp = (struct osigframe *)(td->td_sigstk.ss_sp + - td->td_sigstk.ss_size - sizeof(struct osigframe)); -#if defined(COMPAT_43) - td->td_sigstk.ss_flags |= SS_ONSTACK; -#endif - } else - fp = (struct osigframe *)regs->tf_esp - 1; - - /* Translate the signal if appropriate. */ - if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - - /* Build the argument list for the signal handler. */ - sf.sf_signum = sig; - sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; - bzero(&sf.sf_siginfo, sizeof(sf.sf_siginfo)); - if (SIGISMEMBER(psp->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - sf.sf_arg2 = (register_t)&fp->sf_siginfo; - sf.sf_siginfo.si_signo = sig; - sf.sf_siginfo.si_code = ksi->ksi_code; - sf.sf_ahu.sf_action = (__osiginfohandler_t *)catcher; - sf.sf_addr = 0; - } else { - /* Old FreeBSD-style arguments. */ - sf.sf_arg2 = ksi->ksi_code; - sf.sf_addr = (register_t)ksi->ksi_addr; - sf.sf_ahu.sf_handler = catcher; - } - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(p); - - /* Save most if not all of trap frame. */ - sf.sf_siginfo.si_sc.sc_eax = regs->tf_eax; - sf.sf_siginfo.si_sc.sc_ebx = regs->tf_ebx; - sf.sf_siginfo.si_sc.sc_ecx = regs->tf_ecx; - sf.sf_siginfo.si_sc.sc_edx = regs->tf_edx; - sf.sf_siginfo.si_sc.sc_esi = regs->tf_esi; - sf.sf_siginfo.si_sc.sc_edi = regs->tf_edi; - sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; - sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; - sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; - sf.sf_siginfo.si_sc.sc_es = regs->tf_es; - sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; - sf.sf_siginfo.si_sc.sc_gs = rgs(); - sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp; - - /* Build the signal context to be used by osigreturn(). */ - sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0; - SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); - sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp; - sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp; - sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip; - sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags; - sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; - sf.sf_siginfo.si_sc.sc_err = regs->tf_err; - - /* - * If we're a vm86 process, we want to save the segment registers. - * We also change eflags to be our emulated eflags, not the actual - * eflags. - */ - if (regs->tf_eflags & PSL_VM) { - /* XXX confusing names: `tf' isn't a trapframe; `regs' is. */ - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; - - sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; - sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; - sf.sf_siginfo.si_sc.sc_es = tf->tf_vm86_es; - sf.sf_siginfo.si_sc.sc_ds = tf->tf_vm86_ds; - - if (vm86->vm86_has_vme == 0) - sf.sf_siginfo.si_sc.sc_ps = - (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) | - (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); - - /* See sendsig() for comments. */ - tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); - } - - /* - * Copy the sigframe out to the user's stack. - */ - if (copyout(&sf, fp, sizeof(*fp)) != 0) { -#ifdef DEBUG - printf("process %ld has trashed its stack\n", (long)p->p_pid); -#endif - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - regs->tf_esp = (int)fp; - if (p->p_sysent->sv_sigcode_base != 0) { - regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode - - szosigcode; - } else { - /* a.out sysentvec does not use shared page */ - regs->tf_eip = p->p_sysent->sv_psstrings - szosigcode; - } - regs->tf_eflags &= ~(PSL_T | PSL_D); - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _udatasel; - load_gs(_udatasel); - regs->tf_ss = _udatasel; - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} -#endif /* COMPAT_43 */ - -#ifdef COMPAT_FREEBSD4 -static void -freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) -{ - struct sigframe4 sf, *sfp; - struct proc *p; - struct thread *td; - struct sigacts *psp; - struct trapframe *regs; - int sig; - int oonstack; - - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - sig = ksi->ksi_signo; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); - regs = td->td_frame; - oonstack = sigonstack(regs->tf_esp); - - /* Save user context. */ - bzero(&sf, sizeof(sf)); - sf.sf_uc.uc_sigmask = *mask; - sf.sf_uc.uc_stack = td->td_sigstk; - sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) - ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; - sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; - sf.sf_uc.uc_mcontext.mc_gs = rgs(); - bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs)); - bzero(sf.sf_uc.uc_mcontext.mc_fpregs, - sizeof(sf.sf_uc.uc_mcontext.mc_fpregs)); - bzero(sf.sf_uc.uc_mcontext.__spare__, - sizeof(sf.sf_uc.uc_mcontext.__spare__)); - bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__)); - - /* Allocate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - sfp = (struct sigframe4 *)(td->td_sigstk.ss_sp + - td->td_sigstk.ss_size - sizeof(struct sigframe4)); -#if defined(COMPAT_43) - td->td_sigstk.ss_flags |= SS_ONSTACK; -#endif - } else - sfp = (struct sigframe4 *)regs->tf_esp - 1; - - /* Translate the signal if appropriate. */ - if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - - /* Build the argument list for the signal handler. */ - sf.sf_signum = sig; - sf.sf_ucontext = (register_t)&sfp->sf_uc; - bzero(&sf.sf_si, sizeof(sf.sf_si)); - if (SIGISMEMBER(psp->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - sf.sf_siginfo = (register_t)&sfp->sf_si; - sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher; - - /* Fill in POSIX parts */ - sf.sf_si.si_signo = sig; - sf.sf_si.si_code = ksi->ksi_code; - sf.sf_si.si_addr = ksi->ksi_addr; - } else { - /* Old FreeBSD-style arguments. */ - sf.sf_siginfo = ksi->ksi_code; - sf.sf_addr = (register_t)ksi->ksi_addr; - sf.sf_ahu.sf_handler = catcher; - } - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(p); - - /* - * If we're a vm86 process, we want to save the segment registers. - * We also change eflags to be our emulated eflags, not the actual - * eflags. - */ - if (regs->tf_eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; - - sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; - sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; - sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es; - sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds; - - if (vm86->vm86_has_vme == 0) - sf.sf_uc.uc_mcontext.mc_eflags = - (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) | - (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); - - /* - * Clear PSL_NT to inhibit T_TSSFLT faults on return from - * syscalls made by the signal handler. This just avoids - * wasting time for our lazy fixup of such faults. PSL_NT - * does nothing in vm86 mode, but vm86 programs can set it - * almost legitimately in probes for old cpu types. - */ - tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); - } - - /* - * Copy the sigframe out to the user's stack. - */ - if (copyout(&sf, sfp, sizeof(*sfp)) != 0) { -#ifdef DEBUG - printf("process %ld has trashed its stack\n", (long)p->p_pid); -#endif - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - regs->tf_esp = (int)sfp; - regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode - - szfreebsd4_sigcode; - regs->tf_eflags &= ~(PSL_T | PSL_D); - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _udatasel; - regs->tf_ss = _udatasel; - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} -#endif /* COMPAT_FREEBSD4 */ - -void -sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) -{ - struct sigframe sf, *sfp; - struct proc *p; - struct thread *td; - struct sigacts *psp; - char *sp; - struct trapframe *regs; - struct segment_descriptor *sdp; - int sig; - int oonstack; - - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - sig = ksi->ksi_signo; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); -#ifdef COMPAT_FREEBSD4 - if (SIGISMEMBER(psp->ps_freebsd4, sig)) { - freebsd4_sendsig(catcher, ksi, mask); - return; - } -#endif -#ifdef COMPAT_43 - if (SIGISMEMBER(psp->ps_osigset, sig)) { - osendsig(catcher, ksi, mask); - return; - } -#endif - regs = td->td_frame; - oonstack = sigonstack(regs->tf_esp); - - /* Save user context. */ - bzero(&sf, sizeof(sf)); - sf.sf_uc.uc_sigmask = *mask; - sf.sf_uc.uc_stack = td->td_sigstk; - sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) - ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; - sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; - sf.sf_uc.uc_mcontext.mc_gs = rgs(); - bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs)); - sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); /* magic */ - get_fpcontext(td, &sf.sf_uc.uc_mcontext); - fpstate_drop(td); - /* - * Unconditionally fill the fsbase and gsbase into the mcontext. - */ - sdp = &td->td_pcb->pcb_fsd; - sf.sf_uc.uc_mcontext.mc_fsbase = sdp->sd_hibase << 24 | - sdp->sd_lobase; - sdp = &td->td_pcb->pcb_gsd; - sf.sf_uc.uc_mcontext.mc_gsbase = sdp->sd_hibase << 24 | - sdp->sd_lobase; - sf.sf_uc.uc_mcontext.mc_flags = 0; - bzero(sf.sf_uc.uc_mcontext.mc_spare2, - sizeof(sf.sf_uc.uc_mcontext.mc_spare2)); - bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__)); - - /* Allocate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - sp = td->td_sigstk.ss_sp + - td->td_sigstk.ss_size - sizeof(struct sigframe); -#if defined(COMPAT_43) - td->td_sigstk.ss_flags |= SS_ONSTACK; -#endif - } else - sp = (char *)regs->tf_esp - sizeof(struct sigframe); - /* Align to 16 bytes. */ - sfp = (struct sigframe *)((unsigned int)sp & ~0xF); - - /* Translate the signal if appropriate. */ - if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - - /* Build the argument list for the signal handler. */ - sf.sf_signum = sig; - sf.sf_ucontext = (register_t)&sfp->sf_uc; - bzero(&sf.sf_si, sizeof(sf.sf_si)); - if (SIGISMEMBER(psp->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - sf.sf_siginfo = (register_t)&sfp->sf_si; - sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher; - - /* Fill in POSIX parts */ - sf.sf_si = ksi->ksi_info; - sf.sf_si.si_signo = sig; /* maybe a translated signal */ - } else { - /* Old FreeBSD-style arguments. */ - sf.sf_siginfo = ksi->ksi_code; - sf.sf_addr = (register_t)ksi->ksi_addr; - sf.sf_ahu.sf_handler = catcher; - } - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(p); - - /* - * If we're a vm86 process, we want to save the segment registers. - * We also change eflags to be our emulated eflags, not the actual - * eflags. - */ - if (regs->tf_eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; - - sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; - sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; - sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es; - sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds; - - if (vm86->vm86_has_vme == 0) - sf.sf_uc.uc_mcontext.mc_eflags = - (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) | - (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); - - /* - * Clear PSL_NT to inhibit T_TSSFLT faults on return from - * syscalls made by the signal handler. This just avoids - * wasting time for our lazy fixup of such faults. PSL_NT - * does nothing in vm86 mode, but vm86 programs can set it - * almost legitimately in probes for old cpu types. - */ - tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); - } - - /* - * Copy the sigframe out to the user's stack. - */ - if (copyout(&sf, sfp, sizeof(*sfp)) != 0) { -#ifdef DEBUG - printf("process %ld has trashed its stack\n", (long)p->p_pid); -#endif - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - regs->tf_esp = (int)sfp; - regs->tf_eip = p->p_sysent->sv_sigcode_base; - if (regs->tf_eip == 0) - regs->tf_eip = p->p_sysent->sv_psstrings - szsigcode; - regs->tf_eflags &= ~(PSL_T | PSL_D); - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _udatasel; - regs->tf_ss = _udatasel; - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} - -/* - * System call to cleanup state after a signal - * has been taken. Reset signal mask and - * stack state from context left by sendsig (above). - * Return to previous pc and psl as specified by - * context left by sendsig. Check carefully to - * make sure that the user has not modified the - * state to gain improper privileges. - * - * MPSAFE - */ -#ifdef COMPAT_43 -int -osigreturn(td, uap) - struct thread *td; - struct osigreturn_args /* { - struct osigcontext *sigcntxp; - } */ *uap; -{ - struct osigcontext sc; - struct trapframe *regs; - struct osigcontext *scp; - int eflags, error; - ksiginfo_t ksi; - - regs = td->td_frame; - error = copyin(uap->sigcntxp, &sc, sizeof(sc)); - if (error != 0) - return (error); - scp = ≻ - eflags = scp->sc_ps; - if (eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86; - - /* - * if pcb_ext == 0 or vm86_inited == 0, the user hasn't - * set up the vm86 area, and we can't enter vm86 mode. - */ - if (td->td_pcb->pcb_ext == 0) - return (EINVAL); - vm86 = &td->td_pcb->pcb_ext->ext_vm86; - if (vm86->vm86_inited == 0) - return (EINVAL); - - /* Go back to user mode if both flags are set. */ - if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_addr = (void *)regs->tf_eip; - trapsignal(td, &ksi); - } - - if (vm86->vm86_has_vme) { - eflags = (tf->tf_eflags & ~VME_USERCHANGE) | - (eflags & VME_USERCHANGE) | PSL_VM; - } else { - vm86->vm86_eflags = eflags; /* save VIF, VIP */ - eflags = (tf->tf_eflags & ~VM_USERCHANGE) | - (eflags & VM_USERCHANGE) | PSL_VM; - } - tf->tf_vm86_ds = scp->sc_ds; - tf->tf_vm86_es = scp->sc_es; - tf->tf_vm86_fs = scp->sc_fs; - tf->tf_vm86_gs = scp->sc_gs; - tf->tf_ds = _udatasel; - tf->tf_es = _udatasel; - tf->tf_fs = _udatasel; - } else { - /* - * Don't allow users to change privileged or reserved flags. - */ - if (!EFL_SECURE(eflags, regs->tf_eflags)) { - return (EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ - if (!CS_SECURE(scp->sc_cs)) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_trapno = T_PROTFLT; - ksi.ksi_addr = (void *)regs->tf_eip; - trapsignal(td, &ksi); - return (EINVAL); - } - regs->tf_ds = scp->sc_ds; - regs->tf_es = scp->sc_es; - regs->tf_fs = scp->sc_fs; - } - - /* Restore remaining registers. */ - regs->tf_eax = scp->sc_eax; - regs->tf_ebx = scp->sc_ebx; - regs->tf_ecx = scp->sc_ecx; - regs->tf_edx = scp->sc_edx; - regs->tf_esi = scp->sc_esi; - regs->tf_edi = scp->sc_edi; - regs->tf_cs = scp->sc_cs; - regs->tf_ss = scp->sc_ss; - regs->tf_isp = scp->sc_isp; - regs->tf_ebp = scp->sc_fp; - regs->tf_esp = scp->sc_sp; - regs->tf_eip = scp->sc_pc; - regs->tf_eflags = eflags; - -#if defined(COMPAT_43) - if (scp->sc_onstack & 1) - td->td_sigstk.ss_flags |= SS_ONSTACK; - else - td->td_sigstk.ss_flags &= ~SS_ONSTACK; -#endif - kern_sigprocmask(td, SIG_SETMASK, (sigset_t *)&scp->sc_mask, NULL, - SIGPROCMASK_OLD); - return (EJUSTRETURN); -} -#endif /* COMPAT_43 */ - -#ifdef COMPAT_FREEBSD4 -/* - * MPSAFE - */ -int -freebsd4_sigreturn(td, uap) - struct thread *td; - struct freebsd4_sigreturn_args /* { - const ucontext4 *sigcntxp; - } */ *uap; -{ - struct ucontext4 uc; - struct trapframe *regs; - struct ucontext4 *ucp; - int cs, eflags, error; - ksiginfo_t ksi; - - error = copyin(uap->sigcntxp, &uc, sizeof(uc)); - if (error != 0) - return (error); - ucp = &uc; - regs = td->td_frame; - eflags = ucp->uc_mcontext.mc_eflags; - if (eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86; - - /* - * if pcb_ext == 0 or vm86_inited == 0, the user hasn't - * set up the vm86 area, and we can't enter vm86 mode. - */ - if (td->td_pcb->pcb_ext == 0) - return (EINVAL); - vm86 = &td->td_pcb->pcb_ext->ext_vm86; - if (vm86->vm86_inited == 0) - return (EINVAL); - - /* Go back to user mode if both flags are set. */ - if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_addr = (void *)regs->tf_eip; - trapsignal(td, &ksi); - } - if (vm86->vm86_has_vme) { - eflags = (tf->tf_eflags & ~VME_USERCHANGE) | - (eflags & VME_USERCHANGE) | PSL_VM; - } else { - vm86->vm86_eflags = eflags; /* save VIF, VIP */ - eflags = (tf->tf_eflags & ~VM_USERCHANGE) | - (eflags & VM_USERCHANGE) | PSL_VM; - } - bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe)); - tf->tf_eflags = eflags; - tf->tf_vm86_ds = tf->tf_ds; - tf->tf_vm86_es = tf->tf_es; - tf->tf_vm86_fs = tf->tf_fs; - tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs; - tf->tf_ds = _udatasel; - tf->tf_es = _udatasel; - tf->tf_fs = _udatasel; - } else { - /* - * Don't allow users to change privileged or reserved flags. - */ - if (!EFL_SECURE(eflags, regs->tf_eflags)) { - uprintf("pid %d (%s): freebsd4_sigreturn eflags = 0x%x\n", - td->td_proc->p_pid, td->td_name, eflags); - return (EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ - cs = ucp->uc_mcontext.mc_cs; - if (!CS_SECURE(cs)) { - uprintf("pid %d (%s): freebsd4_sigreturn cs = 0x%x\n", - td->td_proc->p_pid, td->td_name, cs); - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_trapno = T_PROTFLT; - ksi.ksi_addr = (void *)regs->tf_eip; - trapsignal(td, &ksi); - return (EINVAL); - } - - bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs)); - } - -#if defined(COMPAT_43) - if (ucp->uc_mcontext.mc_onstack & 1) - td->td_sigstk.ss_flags |= SS_ONSTACK; - else - td->td_sigstk.ss_flags &= ~SS_ONSTACK; -#endif - kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0); - return (EJUSTRETURN); -} -#endif /* COMPAT_FREEBSD4 */ - -/* - * MPSAFE - */ -int -sys_sigreturn(td, uap) - struct thread *td; - struct sigreturn_args /* { - const struct __ucontext *sigcntxp; - } */ *uap; -{ - ucontext_t uc; - struct trapframe *regs; - ucontext_t *ucp; - int cs, eflags, error, ret; - ksiginfo_t ksi; - - error = copyin(uap->sigcntxp, &uc, sizeof(uc)); - if (error != 0) - return (error); - ucp = &uc; - regs = td->td_frame; - eflags = ucp->uc_mcontext.mc_eflags; - if (eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86; - - /* - * if pcb_ext == 0 or vm86_inited == 0, the user hasn't - * set up the vm86 area, and we can't enter vm86 mode. - */ - if (td->td_pcb->pcb_ext == 0) - return (EINVAL); - vm86 = &td->td_pcb->pcb_ext->ext_vm86; - if (vm86->vm86_inited == 0) - return (EINVAL); - - /* Go back to user mode if both flags are set. */ - if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) { - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_addr = (void *)regs->tf_eip; - trapsignal(td, &ksi); - } - - if (vm86->vm86_has_vme) { - eflags = (tf->tf_eflags & ~VME_USERCHANGE) | - (eflags & VME_USERCHANGE) | PSL_VM; - } else { - vm86->vm86_eflags = eflags; /* save VIF, VIP */ - eflags = (tf->tf_eflags & ~VM_USERCHANGE) | - (eflags & VM_USERCHANGE) | PSL_VM; - } - bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe)); - tf->tf_eflags = eflags; - tf->tf_vm86_ds = tf->tf_ds; - tf->tf_vm86_es = tf->tf_es; - tf->tf_vm86_fs = tf->tf_fs; - tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs; - tf->tf_ds = _udatasel; - tf->tf_es = _udatasel; - tf->tf_fs = _udatasel; - } else { - /* - * Don't allow users to change privileged or reserved flags. - */ - if (!EFL_SECURE(eflags, regs->tf_eflags)) { - uprintf("pid %d (%s): sigreturn eflags = 0x%x\n", - td->td_proc->p_pid, td->td_name, eflags); - return (EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ - cs = ucp->uc_mcontext.mc_cs; - if (!CS_SECURE(cs)) { - uprintf("pid %d (%s): sigreturn cs = 0x%x\n", - td->td_proc->p_pid, td->td_name, cs); - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = SIGBUS; - ksi.ksi_code = BUS_OBJERR; - ksi.ksi_trapno = T_PROTFLT; - ksi.ksi_addr = (void *)regs->tf_eip; - trapsignal(td, &ksi); - return (EINVAL); - } - - ret = set_fpcontext(td, &ucp->uc_mcontext); - if (ret != 0) - return (ret); - bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs)); - } - -#if defined(COMPAT_43) - if (ucp->uc_mcontext.mc_onstack & 1) - td->td_sigstk.ss_flags |= SS_ONSTACK; - else - td->td_sigstk.ss_flags &= ~SS_ONSTACK; -#endif - - kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0); - return (EJUSTRETURN); -} - -/* - * Machine dependent boot() routine - * - * I haven't seen anything to put here yet - * Possibly some stuff might be grafted back here from boot() - */ -void -cpu_boot(int howto) -{ -} - -/* - * Flush the D-cache for non-DMA I/O so that the I-cache can - * be made coherent later. - */ -void -cpu_flush_dcache(void *ptr, size_t len) -{ - /* Not applicable */ -} - -/* Get current clock frequency for the given cpu id. */ -int -cpu_est_clockrate(int cpu_id, uint64_t *rate) -{ - uint64_t tsc1, tsc2; - register_t reg; - - if (pcpu_find(cpu_id) == NULL || rate == NULL) - return (EINVAL); - if ((cpu_feature & CPUID_TSC) == 0) - return (EOPNOTSUPP); - -#ifdef SMP - if (smp_cpus > 1) { - /* Schedule ourselves on the indicated cpu. */ - thread_lock(curthread); - sched_bind(curthread, cpu_id); - thread_unlock(curthread); - } -#endif - - /* Calibrate by measuring a short delay. */ - reg = intr_disable(); - tsc1 = rdtsc(); - DELAY(1000); - tsc2 = rdtsc(); - intr_restore(reg); - *rate = (tsc2 - tsc1) * 1000; - -#ifdef SMP - if (smp_cpus > 1) { - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); - } -#endif - - return (0); -} - - -/* - * Shutdown the CPU as much as possible - */ -void -cpu_halt(void) -{ - for (;;) - halt(); -} - -static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, - 0, "Use MONITOR/MWAIT for short idle"); - -#define STATE_RUNNING 0x0 -#define STATE_MWAIT 0x1 -#define STATE_SLEEPING 0x2 - -static void -cpu_idle_hlt(sbintime_t sbt) -{ - int *state; - - state = (int *)PCPU_PTR(monitorbuf); - *state = STATE_SLEEPING; - - /* - * Since we may be in a critical section from cpu_idle(), if - * an interrupt fires during that critical section we may have - * a pending preemption. If the CPU halts, then that thread - * may not execute until a later interrupt awakens the CPU. - * To handle this race, check for a runnable thread after - * disabling interrupts and immediately return if one is - * found. Also, we must absolutely guarentee that hlt is - * the next instruction after sti. This ensures that any - * interrupt that fires after the call to disable_intr() will - * immediately awaken the CPU from hlt. Finally, please note - * that on x86 this works fine because of interrupts enabled only - * after the instruction following sti takes place, while IF is set - * to 1 immediately, allowing hlt instruction to acknowledge the - * interrupt. - */ - disable_intr(); - if (sched_runnable()) - enable_intr(); - else - __asm __volatile("sti; hlt"); - *state = STATE_RUNNING; -} - -/* - * MWAIT cpu power states. Lower 4 bits are sub-states. - */ -#define MWAIT_C0 0xf0 -#define MWAIT_C1 0x00 -#define MWAIT_C2 0x10 -#define MWAIT_C3 0x20 -#define MWAIT_C4 0x30 - -static void -cpu_idle_mwait(sbintime_t sbt) -{ - int *state; - - state = (int *)PCPU_PTR(monitorbuf); - *state = STATE_MWAIT; - - /* See comments in cpu_idle_hlt(). */ - disable_intr(); - if (sched_runnable()) { - enable_intr(); - *state = STATE_RUNNING; - return; - } - cpu_monitor(state, 0, 0); - if (*state == STATE_MWAIT) - __asm __volatile("sti; mwait" : : "a" (MWAIT_C1), "c" (0)); - else - enable_intr(); - *state = STATE_RUNNING; -} - -static void -cpu_idle_spin(sbintime_t sbt) -{ - int *state; - int i; - - state = (int *)PCPU_PTR(monitorbuf); - *state = STATE_RUNNING; - - /* - * The sched_runnable() call is racy but as long as there is - * a loop missing it one time will have just a little impact if any - * (and it is much better than missing the check at all). - */ - for (i = 0; i < 1000; i++) { - if (sched_runnable()) - return; - cpu_spinwait(); - } -} - -void (*cpu_idle_fn)(sbintime_t) = cpu_idle_hlt; - -void -cpu_idle(int busy) -{ - sbintime_t sbt = -1; - - CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", - busy, curcpu); -#if defined(MP_WATCHDOG) - ap_watchdog(PCPU_GET(cpuid)); -#endif - /* If we are busy - try to use fast methods. */ - if (busy) { - if ((cpu_feature2 & CPUID2_MON) && idle_mwait) { - cpu_idle_mwait(busy); - goto out; - } - } - - /* If we have time - switch timers into idle mode. */ - if (!busy) { - critical_enter(); - sbt = cpu_idleclock(); - } - - /* Call main idle method. */ - cpu_idle_fn(sbt); - - /* Switch timers back into active mode. */ - if (!busy) { - cpu_activeclock(); - critical_exit(); - } -out: - CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done", - busy, curcpu); -} - -int -cpu_idle_wakeup(int cpu) -{ - struct pcpu *pcpu; - int *state; - - pcpu = pcpu_find(cpu); - state = (int *)pcpu->pc_monitorbuf; - /* - * This doesn't need to be atomic since missing the race will - * simply result in unnecessary IPIs. - */ - if (*state == STATE_SLEEPING) - return (0); - if (*state == STATE_MWAIT) - *state = STATE_RUNNING; - return (1); -} - -/* - * Ordered by speed/power consumption. - */ -struct { - void *id_fn; - char *id_name; -} idle_tbl[] = { - { cpu_idle_spin, "spin" }, - { cpu_idle_mwait, "mwait" }, - { cpu_idle_hlt, "hlt" }, - { NULL, NULL } -}; - -static int -idle_sysctl_available(SYSCTL_HANDLER_ARGS) -{ - char *avail, *p; - int error; - int i; - - avail = malloc(256, M_TEMP, M_WAITOK); - p = avail; - for (i = 0; idle_tbl[i].id_name != NULL; i++) { - if (strstr(idle_tbl[i].id_name, "mwait") && - (cpu_feature2 & CPUID2_MON) == 0) - continue; - p += sprintf(p, "%s%s", p != avail ? ", " : "", - idle_tbl[i].id_name); - } - error = sysctl_handle_string(oidp, avail, 0, req); - free(avail, M_TEMP); - return (error); -} - -SYSCTL_PROC(_machdep, OID_AUTO, idle_available, CTLTYPE_STRING | CTLFLAG_RD, - 0, 0, idle_sysctl_available, "A", "list of available idle functions"); - -static int -idle_sysctl(SYSCTL_HANDLER_ARGS) -{ - char buf[16]; - int error; - char *p; - int i; - - p = "unknown"; - for (i = 0; idle_tbl[i].id_name != NULL; i++) { - if (idle_tbl[i].id_fn == cpu_idle_fn) { - p = idle_tbl[i].id_name; - break; - } - } - strncpy(buf, p, sizeof(buf)); - error = sysctl_handle_string(oidp, buf, sizeof(buf), req); - if (error != 0 || req->newptr == NULL) - return (error); - for (i = 0; idle_tbl[i].id_name != NULL; i++) { - if (strstr(idle_tbl[i].id_name, "mwait") && - (cpu_feature2 & CPUID2_MON) == 0) - continue; - if (strcmp(idle_tbl[i].id_name, buf)) - continue; - cpu_idle_fn = idle_tbl[i].id_fn; - return (0); - } - return (EINVAL); -} - -SYSCTL_PROC(_machdep, OID_AUTO, idle, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, - idle_sysctl, "A", "currently selected idle function"); - -/* - * Reset registers to default values on exec. - */ -void -exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) -{ - struct trapframe *regs = td->td_frame; - struct pcb *pcb = td->td_pcb; - - /* Reset pc->pcb_gs and %gs before possibly invalidating it. */ - pcb->pcb_gs = _udatasel; - load_gs(_udatasel); - - mtx_lock_spin(&dt_lock); - if (td->td_proc->p_md.md_ldt) - user_ldt_free(td); - else - mtx_unlock_spin(&dt_lock); - - bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_eip = imgp->entry_addr; - regs->tf_esp = stack; - regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T); - regs->tf_ss = _udatasel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _udatasel; - regs->tf_cs = _ucodesel; - - /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */ - regs->tf_ebx = imgp->ps_strings; - - /* - * Reset the hardware debug registers if they were in use. - * They won't have any meaning for the newly exec'd process. - */ - if (pcb->pcb_flags & PCB_DBREGS) { - pcb->pcb_dr0 = 0; - pcb->pcb_dr1 = 0; - pcb->pcb_dr2 = 0; - pcb->pcb_dr3 = 0; - pcb->pcb_dr6 = 0; - pcb->pcb_dr7 = 0; - if (pcb == curpcb) { - /* - * Clear the debug registers on the running - * CPU, otherwise they will end up affecting - * the next process we switch to. - */ - reset_dbregs(); - } - pcb->pcb_flags &= ~PCB_DBREGS; - } - - /* - * Initialize the math emulator (if any) for the current process. - * Actually, just clear the bit that says that the emulator has - * been initialized. Initialization is delayed until the process - * traps to the emulator (if it is done at all) mainly because - * emulators don't provide an entry point for initialization. - */ - td->td_pcb->pcb_flags &= ~FP_SOFTFP; - pcb->pcb_initial_npxcw = __INITIAL_NPXCW__; - - /* - * Drop the FP state if we hold it, so that the process gets a - * clean FP state if it uses the FPU again. - */ - fpstate_drop(td); - - /* - * XXX - Linux emulator - * Make sure sure edx is 0x0 on entry. Linux binaries depend - * on it. - */ - td->td_retval[1] = 0; -} - -void -cpu_setregs(void) -{ - unsigned int cr0; - - cr0 = rcr0(); - - /* - * CR0_MP, CR0_NE and CR0_TS are set for NPX (FPU) support: - * - * Prepare to trap all ESC (i.e., NPX) instructions and all WAIT - * instructions. We must set the CR0_MP bit and use the CR0_TS - * bit to control the trap, because setting the CR0_EM bit does - * not cause WAIT instructions to trap. It's important to trap - * WAIT instructions - otherwise the "wait" variants of no-wait - * control instructions would degenerate to the "no-wait" variants - * after FP context switches but work correctly otherwise. It's - * particularly important to trap WAITs when there is no NPX - - * otherwise the "wait" variants would always degenerate. - * - * Try setting CR0_NE to get correct error reporting on 486DX's. - * Setting it should fail or do nothing on lesser processors. - */ - cr0 |= CR0_MP | CR0_NE | CR0_TS | CR0_WP | CR0_AM; - load_cr0(cr0); - load_gs(_udatasel); -} - -u_long bootdev; /* not a struct cdev *- encoding is different */ -SYSCTL_ULONG(_machdep, OID_AUTO, guessed_bootdev, - CTLFLAG_RD, &bootdev, 0, "Maybe the Boot device (not in struct cdev *format)"); - -/* - * Initialize 386 and configure to run kernel - */ - -/* - * Initialize segments & interrupt table - */ - -int _default_ldt; - -union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */ -union descriptor ldt[NLDT]; /* local descriptor table */ -static struct gate_descriptor idt0[NIDT]; -struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ -struct region_descriptor r_gdt, r_idt; /* table descriptors */ -struct mtx dt_lock; /* lock for GDT and LDT */ - -#if defined(I586_CPU) && !defined(NO_F00F_HACK) -extern int has_f00f_bug; -#endif - -static struct i386tss dblfault_tss; -static char dblfault_stack[PAGE_SIZE]; - -extern vm_offset_t proc0kstack; - - -/* - * software prototypes -- in more palatable form. - * - * GCODE_SEL through GUDATA_SEL must be in this order for syscall/sysret - * GUFS_SEL and GUGS_SEL must be in this order (swtch.s knows it) - */ -struct soft_segment_descriptor gdt_segs[] = { -/* GNULL_SEL 0 Null Descriptor */ -{ .ssd_base = 0x0, - .ssd_limit = 0x0, - .ssd_type = 0, - .ssd_dpl = SEL_KPL, - .ssd_p = 0, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, -/* GPRIV_SEL 1 SMP Per-Processor Private Data Descriptor */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_KPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GUFS_SEL 2 %fs Descriptor for user */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GUGS_SEL 3 %gs Descriptor for user */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GCODE_SEL 4 Code Descriptor for kernel */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMERA, - .ssd_dpl = SEL_KPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GDATA_SEL 5 Data Descriptor for kernel */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_KPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GUCODE_SEL 6 Code Descriptor for user */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMERA, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GUDATA_SEL 7 Data Descriptor for user */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GBIOSLOWMEM_SEL 8 BIOS access to realmode segment 0x40, must be #8 in GDT */ -{ .ssd_base = 0x400, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_KPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GPROC0_SEL 9 Proc 0 Tss Descriptor */ -{ - .ssd_base = 0x0, - .ssd_limit = sizeof(struct i386tss)-1, - .ssd_type = SDT_SYS386TSS, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, -/* GLDT_SEL 10 LDT Descriptor */ -{ .ssd_base = (int) ldt, - .ssd_limit = sizeof(ldt)-1, - .ssd_type = SDT_SYSLDT, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, -/* GUSERLDT_SEL 11 User LDT Descriptor per process */ -{ .ssd_base = (int) ldt, - .ssd_limit = (512 * sizeof(union descriptor)-1), - .ssd_type = SDT_SYSLDT, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, -/* GPANIC_SEL 12 Panic Tss Descriptor */ -{ .ssd_base = (int) &dblfault_tss, - .ssd_limit = sizeof(struct i386tss)-1, - .ssd_type = SDT_SYS386TSS, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, -/* GBIOSCODE32_SEL 13 BIOS 32-bit interface (32bit Code) */ -{ .ssd_base = 0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMERA, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 1 }, -/* GBIOSCODE16_SEL 14 BIOS 32-bit interface (16bit Code) */ -{ .ssd_base = 0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMERA, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 1 }, -/* GBIOSDATA_SEL 15 BIOS 32-bit interface (Data) */ -{ .ssd_base = 0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -/* GBIOSUTIL_SEL 16 BIOS 16-bit interface (Utility) */ -{ .ssd_base = 0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 1 }, -/* GBIOSARGS_SEL 17 BIOS 16-bit interface (Arguments) */ -{ .ssd_base = 0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = 0, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 1 }, -/* GNDIS_SEL 18 NDIS Descriptor */ -{ .ssd_base = 0x0, - .ssd_limit = 0x0, - .ssd_type = 0, - .ssd_dpl = 0, - .ssd_p = 0, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, -}; - -static struct soft_segment_descriptor ldt_segs[] = { - /* Null Descriptor - overwritten by call gate */ -{ .ssd_base = 0x0, - .ssd_limit = 0x0, - .ssd_type = 0, - .ssd_dpl = 0, - .ssd_p = 0, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, - /* Null Descriptor - overwritten by call gate */ -{ .ssd_base = 0x0, - .ssd_limit = 0x0, - .ssd_type = 0, - .ssd_dpl = 0, - .ssd_p = 0, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, - /* Null Descriptor - overwritten by call gate */ -{ .ssd_base = 0x0, - .ssd_limit = 0x0, - .ssd_type = 0, - .ssd_dpl = 0, - .ssd_p = 0, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, - /* Code Descriptor for user */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMERA, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, - /* Null Descriptor - overwritten by call gate */ -{ .ssd_base = 0x0, - .ssd_limit = 0x0, - .ssd_type = 0, - .ssd_dpl = 0, - .ssd_p = 0, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 0, - .ssd_gran = 0 }, - /* Data Descriptor for user */ -{ .ssd_base = 0x0, - .ssd_limit = 0xfffff, - .ssd_type = SDT_MEMRWA, - .ssd_dpl = SEL_UPL, - .ssd_p = 1, - .ssd_xx = 0, .ssd_xx1 = 0, - .ssd_def32 = 1, - .ssd_gran = 1 }, -}; - -void -setidt(idx, func, typ, dpl, selec) - int idx; - inthand_t *func; - int typ; - int dpl; - int selec; -{ - struct gate_descriptor *ip; - - ip = idt + idx; - ip->gd_looffset = (int)func; - ip->gd_selector = selec; - ip->gd_stkcpy = 0; - ip->gd_xx = 0; - ip->gd_type = typ; - ip->gd_dpl = dpl; - ip->gd_p = 1; - ip->gd_hioffset = ((int)func)>>16 ; -} - -extern inthand_t - IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl), - IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(fpusegm), - IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot), - IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align), - IDTVEC(xmm), -#ifdef KDTRACE_HOOKS - IDTVEC(dtrace_ret), -#endif - IDTVEC(lcall_syscall), IDTVEC(int0x80_syscall); - -#ifdef DDB -/* - * Display the index and function name of any IDT entries that don't use - * the default 'rsvd' entry point. - */ -DB_SHOW_COMMAND(idt, db_show_idt) -{ - struct gate_descriptor *ip; - int idx; - uintptr_t func; - - ip = idt; - for (idx = 0; idx < NIDT && !db_pager_quit; idx++) { - func = (ip->gd_hioffset << 16 | ip->gd_looffset); - if (func != (uintptr_t)&IDTVEC(rsvd)) { - db_printf("%3d\t", idx); - db_printsym(func, DB_STGY_PROC); - db_printf("\n"); - } - ip++; - } -} - -/* Show privileged registers. */ -DB_SHOW_COMMAND(sysregs, db_show_sysregs) -{ - uint64_t idtr, gdtr; - - idtr = ridt(); - db_printf("idtr\t0x%08x/%04x\n", - (u_int)(idtr >> 16), (u_int)idtr & 0xffff); - gdtr = rgdt(); - db_printf("gdtr\t0x%08x/%04x\n", - (u_int)(gdtr >> 16), (u_int)gdtr & 0xffff); - db_printf("ldtr\t0x%04x\n", rldt()); - db_printf("tr\t0x%04x\n", rtr()); - db_printf("cr0\t0x%08x\n", rcr0()); - db_printf("cr2\t0x%08x\n", rcr2()); - db_printf("cr3\t0x%08x\n", rcr3()); - db_printf("cr4\t0x%08x\n", rcr4()); -} -#endif - -void -sdtossd(sd, ssd) - struct segment_descriptor *sd; - struct soft_segment_descriptor *ssd; -{ - ssd->ssd_base = (sd->sd_hibase << 24) | sd->sd_lobase; - ssd->ssd_limit = (sd->sd_hilimit << 16) | sd->sd_lolimit; - ssd->ssd_type = sd->sd_type; - ssd->ssd_dpl = sd->sd_dpl; - ssd->ssd_p = sd->sd_p; - ssd->ssd_def32 = sd->sd_def32; - ssd->ssd_gran = sd->sd_gran; -} - -static void -basemem_setup(void) -{ - vm_paddr_t pa; - pt_entry_t *pte; - int i; - - if (basemem > 640) { - printf("Preposterous BIOS basemem of %uK, truncating to 640K\n", - basemem); - basemem = 640; - } - - /* - * XXX if biosbasemem is now < 640, there is a `hole' - * between the end of base memory and the start of - * ISA memory. The hole may be empty or it may - * contain BIOS code or data. Map it read/write so - * that the BIOS can write to it. (Memory from 0 to - * the physical end of the kernel is mapped read-only - * to begin with and then parts of it are remapped. - * The parts that aren't remapped form holes that - * remain read-only and are unused by the kernel. - * The base memory area is below the physical end of - * the kernel and right now forms a read-only hole. - * The part of it from PAGE_SIZE to - * (trunc_page(biosbasemem * 1024) - 1) will be - * remapped and used by the kernel later.) - * - * This code is similar to the code used in - * pmap_mapdev, but since no memory needs to be - * allocated we simply change the mapping. - */ - for (pa = trunc_page(basemem * 1024); - pa < ISA_HOLE_START; pa += PAGE_SIZE) - pmap_kenter(KERNBASE + pa, pa); - - /* - * Map pages between basemem and ISA_HOLE_START, if any, r/w into - * the vm86 page table so that vm86 can scribble on them using - * the vm86 map too. XXX: why 2 ways for this and only 1 way for - * page 0, at least as initialized here? - */ - pte = (pt_entry_t *)vm86paddr; - for (i = basemem / 4; i < 160; i++) - pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U; -} - -/* - * Populate the (physmap) array with base/bound pairs describing the - * available physical memory in the system, then test this memory and - * build the phys_avail array describing the actually-available memory. - * - * If we cannot accurately determine the physical memory map, then use - * value from the 0xE801 call, and failing that, the RTC. - * - * Total memory size may be set by the kernel environment variable - * hw.physmem or the compile-time define MAXMEM. - * - * XXX first should be vm_paddr_t. - */ -static void -getmemsize(int first) -{ - int off, physmap_idx, pa_indx, da_indx; - u_long physmem_tunable, memtest; - vm_paddr_t physmap[PHYSMAP_SIZE]; - pt_entry_t *pte; - quad_t dcons_addr, dcons_size; - int i; - int pg_n; - u_int extmem; - u_int under16; - vm_paddr_t pa; - - bzero(physmap, sizeof(physmap)); - - /* XXX - some of EPSON machines can't use PG_N */ - pg_n = PG_N; - if (pc98_machine_type & M_EPSON_PC98) { - switch (epson_machine_id) { -#ifdef WB_CACHE - default: -#endif - case EPSON_PC486_HX: - case EPSON_PC486_HG: - case EPSON_PC486_HA: - pg_n = 0; - break; - } - } - - under16 = pc98_getmemsize(&basemem, &extmem); - basemem_setup(); - - physmap[0] = 0; - physmap[1] = basemem * 1024; - physmap_idx = 2; - physmap[physmap_idx] = 0x100000; - physmap[physmap_idx + 1] = physmap[physmap_idx] + extmem * 1024; - - /* - * Now, physmap contains a map of physical memory. - */ - -#ifdef SMP - /* make hole for AP bootstrap code */ - physmap[1] = mp_bootaddress(physmap[1]); -#endif - - /* - * Maxmem isn't the "maximum memory", it's one larger than the - * highest page of the physical address space. It should be - * called something like "Maxphyspage". We may adjust this - * based on ``hw.physmem'' and the results of the memory test. - */ - Maxmem = atop(physmap[physmap_idx + 1]); - -#ifdef MAXMEM - Maxmem = MAXMEM / 4; -#endif - - if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable)) - Maxmem = atop(physmem_tunable); - - /* - * By default keep the memtest enabled. Use a general name so that - * one could eventually do more with the code than just disable it. - */ - memtest = 1; - TUNABLE_ULONG_FETCH("hw.memtest.tests", &memtest); - - if (atop(physmap[physmap_idx + 1]) != Maxmem && - (boothowto & RB_VERBOSE)) - printf("Physical memory use set to %ldK\n", Maxmem * 4); - - /* - * If Maxmem has been increased beyond what the system has detected, - * extend the last memory segment to the new limit. - */ - if (atop(physmap[physmap_idx + 1]) < Maxmem) - physmap[physmap_idx + 1] = ptoa((vm_paddr_t)Maxmem); - - /* - * We need to divide chunk if Maxmem is larger than 16MB and - * under 16MB area is not full of memory. - * (1) system area (15-16MB region) is cut off - * (2) extended memory is only over 16MB area (ex. Melco "HYPERMEMORY") - */ - if ((under16 != 16 * 1024) && (extmem > 15 * 1024)) { - /* 15M - 16M region is cut off, so need to divide chunk */ - physmap[physmap_idx + 1] = under16 * 1024; - physmap_idx += 2; - physmap[physmap_idx] = 0x1000000; - physmap[physmap_idx + 1] = physmap[2] + extmem * 1024; - } - - /* call pmap initialization to make new kernel address space */ - pmap_bootstrap(first); - - /* - * Size up each available chunk of physical memory. - */ - physmap[0] = PAGE_SIZE; /* mask off page 0 */ - pa_indx = 0; - da_indx = 1; - phys_avail[pa_indx++] = physmap[0]; - phys_avail[pa_indx] = physmap[0]; - dump_avail[da_indx] = physmap[0]; - pte = CMAP3; - - /* - * Get dcons buffer address - */ - if (getenv_quad("dcons.addr", &dcons_addr) == 0 || - getenv_quad("dcons.size", &dcons_size) == 0) - dcons_addr = 0; - - /* - * physmap is in bytes, so when converting to page boundaries, - * round up the start address and round down the end address. - */ - for (i = 0; i <= physmap_idx; i += 2) { - vm_paddr_t end; - - end = ptoa((vm_paddr_t)Maxmem); - if (physmap[i + 1] < end) - end = trunc_page(physmap[i + 1]); - for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) { - int tmp, page_bad, full; - int *ptr = (int *)CADDR3; - - full = FALSE; - /* - * block out kernel memory as not available. - */ - if (pa >= KERNLOAD && pa < first) - goto do_dump_avail; - - /* - * block out dcons buffer - */ - if (dcons_addr > 0 - && pa >= trunc_page(dcons_addr) - && pa < dcons_addr + dcons_size) - goto do_dump_avail; - - page_bad = FALSE; - if (memtest == 0) - goto skip_memtest; - - /* - * map page into kernel: valid, read/write,non-cacheable - */ - *pte = pa | PG_V | PG_RW | pg_n; - invltlb(); - - tmp = *(int *)ptr; - /* - * Test for alternating 1's and 0's - */ - *(volatile int *)ptr = 0xaaaaaaaa; - if (*(volatile int *)ptr != 0xaaaaaaaa) - page_bad = TRUE; - /* - * Test for alternating 0's and 1's - */ - *(volatile int *)ptr = 0x55555555; - if (*(volatile int *)ptr != 0x55555555) - page_bad = TRUE; - /* - * Test for all 1's - */ - *(volatile int *)ptr = 0xffffffff; - if (*(volatile int *)ptr != 0xffffffff) - page_bad = TRUE; - /* - * Test for all 0's - */ - *(volatile int *)ptr = 0x0; - if (*(volatile int *)ptr != 0x0) - page_bad = TRUE; - /* - * Restore original value. - */ - *(int *)ptr = tmp; - -skip_memtest: - /* - * Adjust array of valid/good pages. - */ - if (page_bad == TRUE) - continue; - /* - * If this good page is a continuation of the - * previous set of good pages, then just increase - * the end pointer. Otherwise start a new chunk. - * Note that "end" points one higher than end, - * making the range >= start and < end. - * If we're also doing a speculative memory - * test and we at or past the end, bump up Maxmem - * so that we keep going. The first bad page - * will terminate the loop. - */ - if (phys_avail[pa_indx] == pa) { - phys_avail[pa_indx] += PAGE_SIZE; - } else { - pa_indx++; - if (pa_indx == PHYS_AVAIL_ARRAY_END) { - printf( - "Too many holes in the physical address space, giving up\n"); - pa_indx--; - full = TRUE; - goto do_dump_avail; - } - phys_avail[pa_indx++] = pa; /* start */ - phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */ - } - physmem++; -do_dump_avail: - if (dump_avail[da_indx] == pa) { - dump_avail[da_indx] += PAGE_SIZE; - } else { - da_indx++; - if (da_indx == DUMP_AVAIL_ARRAY_END) { - da_indx--; - goto do_next; - } - dump_avail[da_indx++] = pa; /* start */ - dump_avail[da_indx] = pa + PAGE_SIZE; /* end */ - } -do_next: - if (full) - break; - } - } - *pte = 0; - invltlb(); - - /* - * XXX - * The last chunk must contain at least one page plus the message - * buffer to avoid complicating other code (message buffer address - * calculation, etc.). - */ - while (phys_avail[pa_indx - 1] + PAGE_SIZE + - round_page(msgbufsize) >= phys_avail[pa_indx]) { - physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]); - phys_avail[pa_indx--] = 0; - phys_avail[pa_indx--] = 0; - } - - Maxmem = atop(phys_avail[pa_indx]); - - /* Trim off space for the message buffer. */ - phys_avail[pa_indx] -= round_page(msgbufsize); - - /* Map the message buffer. */ - for (off = 0; off < round_page(msgbufsize); off += PAGE_SIZE) - pmap_kenter((vm_offset_t)msgbufp + off, phys_avail[pa_indx] + - off); - - PT_UPDATES_FLUSH(); -} - -void -init386(first) - int first; -{ - struct gate_descriptor *gdp; - int gsel_tss, metadata_missing, x, pa; - size_t kstack0_sz; - struct pcpu *pc; - - thread0.td_kstack = proc0kstack; - thread0.td_kstack_pages = KSTACK_PAGES; - kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE; - thread0.td_pcb = (struct pcb *)(thread0.td_kstack + kstack0_sz) - 1; - - /* - * This may be done better later if it gets more high level - * components in it. If so just link td->td_proc here. - */ - proc_linkup0(&proc0, &thread0); - - /* - * Initialize DMAC - */ - pc98_init_dmac(); - - metadata_missing = 0; - if (bootinfo.bi_modulep) { - preload_metadata = (caddr_t)bootinfo.bi_modulep + KERNBASE; - preload_bootstrap_relocate(KERNBASE); - } else { - metadata_missing = 1; - } - if (envmode == 1) - kern_envp = static_env; - else if (bootinfo.bi_envp) - kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE; - - /* Init basic tunables, hz etc */ - init_param1(); - - /* - * Make gdt memory segments. All segments cover the full 4GB - * of address space and permissions are enforced at page level. - */ - gdt_segs[GCODE_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GDATA_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GUCODE_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GUDATA_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GUFS_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GUGS_SEL].ssd_limit = atop(0 - 1); - - pc = &__pcpu[0]; - gdt_segs[GPRIV_SEL].ssd_limit = atop(0 - 1); - gdt_segs[GPRIV_SEL].ssd_base = (int) pc; - gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss; - - for (x = 0; x < NGDT; x++) - ssdtosd(&gdt_segs[x], &gdt[x].sd); - - r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; - r_gdt.rd_base = (int) gdt; - mtx_init(&dt_lock, "descriptor tables", NULL, MTX_SPIN); - lgdt(&r_gdt); - - pcpu_init(pc, 0, sizeof(struct pcpu)); - for (pa = first; pa < first + DPCPU_SIZE; pa += PAGE_SIZE) - pmap_kenter(pa + KERNBASE, pa); - dpcpu_init((void *)(first + KERNBASE), 0); - first += DPCPU_SIZE; - PCPU_SET(prvspace, pc); - PCPU_SET(curthread, &thread0); - PCPU_SET(curpcb, thread0.td_pcb); - - /* - * Initialize mutexes. - * - * icu_lock: in order to allow an interrupt to occur in a critical - * section, to set pcpu->ipending (etc...) properly, we - * must be able to get the icu lock, so it can't be - * under witness. - */ - mutex_init(); - mtx_init(&icu_lock, "icu", NULL, MTX_SPIN | MTX_NOWITNESS | MTX_NOPROFILE); - - /* make ldt memory segments */ - ldt_segs[LUCODE_SEL].ssd_limit = atop(0 - 1); - ldt_segs[LUDATA_SEL].ssd_limit = atop(0 - 1); - for (x = 0; x < sizeof ldt_segs / sizeof ldt_segs[0]; x++) - ssdtosd(&ldt_segs[x], &ldt[x].sd); - - _default_ldt = GSEL(GLDT_SEL, SEL_KPL); - lldt(_default_ldt); - PCPU_SET(currentldt, _default_ldt); - - /* exceptions */ - for (x = 0; x < NIDT; x++) - setidt(x, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_DE, &IDTVEC(div), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_DB, &IDTVEC(dbg), SDT_SYS386IGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_NMI, &IDTVEC(nmi), SDT_SYS386IGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_BP, &IDTVEC(bpt), SDT_SYS386IGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_OF, &IDTVEC(ofl), SDT_SYS386TGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_BR, &IDTVEC(bnd), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_UD, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_NM, &IDTVEC(dna), SDT_SYS386TGT, SEL_KPL - , GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_DF, 0, SDT_SYSTASKGT, SEL_KPL, GSEL(GPANIC_SEL, SEL_KPL)); - setidt(IDT_FPUGP, &IDTVEC(fpusegm), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_TS, &IDTVEC(tss), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_NP, &IDTVEC(missing), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_SS, &IDTVEC(stk), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_PF, &IDTVEC(page), SDT_SYS386IGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_MF, &IDTVEC(fpu), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_AC, &IDTVEC(align), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_MC, &IDTVEC(mchk), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_XF, &IDTVEC(xmm), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_SYSCALL, &IDTVEC(int0x80_syscall), SDT_SYS386TGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); -#ifdef KDTRACE_HOOKS - setidt(IDT_DTRACE_RET, &IDTVEC(dtrace_ret), SDT_SYS386TGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); -#endif - - r_idt.rd_limit = sizeof(idt0) - 1; - r_idt.rd_base = (int) idt; - lidt(&r_idt); - - /* - * Initialize the i8254 before the console so that console - * initialization can use DELAY(). - */ - clock_init(); - - /* - * Initialize the console before we print anything out. - */ - cninit(); - - if (metadata_missing) - printf("WARNING: loader(8) metadata is missing!\n"); - -#ifdef DEV_ISA -#ifdef DEV_ATPIC - atpic_startup(); -#else - /* Reset and mask the atpics and leave them shut down. */ - atpic_reset(); - - /* - * Point the ICU spurious interrupt vectors at the APIC spurious - * interrupt handler. - */ - setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); -#endif -#endif - -#ifdef DDB - ksym_start = bootinfo.bi_symtab; - ksym_end = bootinfo.bi_esymtab; -#endif - - kdb_init(); - -#ifdef KDB - if (boothowto & RB_KDB) - kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); -#endif - - finishidentcpu(); /* Final stage of CPU initialization */ - setidt(IDT_UD, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - initializecpu(); /* Initialize CPU registers */ - - /* make an initial tss so cpu can get interrupt stack on syscall! */ - /* Note: -16 is so we can grow the trapframe if we came from vm86 */ - PCPU_SET(common_tss.tss_esp0, thread0.td_kstack + - kstack0_sz - sizeof(struct pcb) - 16); - PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL)); - gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); - PCPU_SET(tss_gdt, &gdt[GPROC0_SEL].sd); - PCPU_SET(common_tssd, *PCPU_GET(tss_gdt)); - PCPU_SET(common_tss.tss_ioopt, (sizeof (struct i386tss)) << 16); - ltr(gsel_tss); - - /* pointer to selector slot for %fs/%gs */ - PCPU_SET(fsgs_gdt, &gdt[GUFS_SEL].sd); - - dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 = - dblfault_tss.tss_esp2 = (int)&dblfault_stack[sizeof(dblfault_stack)]; - dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 = - dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL); - dblfault_tss.tss_cr3 = (int)IdlePTD; - dblfault_tss.tss_eip = (int)dblfault_handler; - dblfault_tss.tss_eflags = PSL_KERNEL; - dblfault_tss.tss_ds = dblfault_tss.tss_es = - dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL); - dblfault_tss.tss_fs = GSEL(GPRIV_SEL, SEL_KPL); - dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL); - dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL); - - vm86_initialize(); - getmemsize(first); - init_param2(physmem); - - /* now running on new page tables, configured,and u/iom is accessible */ - - msgbufinit(msgbufp, msgbufsize); - - /* make a call gate to reenter kernel with */ - gdp = &ldt[LSYS5CALLS_SEL].gd; - - x = (int) &IDTVEC(lcall_syscall); - gdp->gd_looffset = x; - gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL); - gdp->gd_stkcpy = 1; - gdp->gd_type = SDT_SYS386CGT; - gdp->gd_dpl = SEL_UPL; - gdp->gd_p = 1; - gdp->gd_hioffset = x >> 16; - - /* XXX does this work? */ - /* XXX yes! */ - ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL]; - ldt[LSOL26CALLS_SEL] = ldt[LSYS5CALLS_SEL]; - - /* transfer to user mode */ - - _ucodesel = GSEL(GUCODE_SEL, SEL_UPL); - _udatasel = GSEL(GUDATA_SEL, SEL_UPL); - - /* setup proc 0's pcb */ - thread0.td_pcb->pcb_flags = 0; - thread0.td_pcb->pcb_cr3 = (int)IdlePTD; - thread0.td_pcb->pcb_ext = 0; - thread0.td_frame = &proc0_tf; -} - -void -cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) -{ - -} - -void -spinlock_enter(void) -{ - struct thread *td; - register_t flags; - - td = curthread; - if (td->td_md.md_spinlock_count == 0) { - flags = intr_disable(); - td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_flags = flags; - } else - td->td_md.md_spinlock_count++; - critical_enter(); -} - -void -spinlock_exit(void) -{ - struct thread *td; - register_t flags; - - td = curthread; - critical_exit(); - flags = td->td_md.md_saved_flags; - td->td_md.md_spinlock_count--; - if (td->td_md.md_spinlock_count == 0) - intr_restore(flags); -} - -#if defined(I586_CPU) && !defined(NO_F00F_HACK) -static void f00f_hack(void *unused); -SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL); - -static void -f00f_hack(void *unused) -{ - struct gate_descriptor *new_idt; - vm_offset_t tmp; - - if (!has_f00f_bug) - return; - - GIANT_REQUIRED; - - printf("Intel Pentium detected, installing workaround for F00F bug\n"); - - tmp = kmem_malloc(kernel_arena, PAGE_SIZE * 2, M_WAITOK | M_ZERO); - if (tmp == 0) - panic("kmem_alloc returned 0"); - - /* Put the problematic entry (#6) at the end of the lower page. */ - new_idt = (struct gate_descriptor*) - (tmp + PAGE_SIZE - 7 * sizeof(struct gate_descriptor)); - bcopy(idt, new_idt, sizeof(idt0)); - r_idt.rd_base = (u_int)new_idt; - lidt(&r_idt); - idt = new_idt; - pmap_protect(kernel_pmap, tmp, tmp + PAGE_SIZE, VM_PROT_READ); -} -#endif /* defined(I586_CPU) && !NO_F00F_HACK */ - -/* - * Construct a PCB from a trapframe. This is called from kdb_trap() where - * we want to start a backtrace from the function that caused us to enter - * the debugger. We have the context in the trapframe, but base the trace - * on the PCB. The PCB doesn't have to be perfect, as long as it contains - * enough for a backtrace. - */ -void -makectx(struct trapframe *tf, struct pcb *pcb) -{ - - pcb->pcb_edi = tf->tf_edi; - pcb->pcb_esi = tf->tf_esi; - pcb->pcb_ebp = tf->tf_ebp; - pcb->pcb_ebx = tf->tf_ebx; - pcb->pcb_eip = tf->tf_eip; - pcb->pcb_esp = (ISPL(tf->tf_cs)) ? tf->tf_esp : (int)(tf + 1) - 8; -} - -int -ptrace_set_pc(struct thread *td, u_long addr) -{ - - td->td_frame->tf_eip = addr; - return (0); -} - -int -ptrace_single_step(struct thread *td) -{ - td->td_frame->tf_eflags |= PSL_T; - return (0); -} - -int -ptrace_clear_single_step(struct thread *td) -{ - td->td_frame->tf_eflags &= ~PSL_T; - return (0); -} - -int -fill_regs(struct thread *td, struct reg *regs) -{ - struct pcb *pcb; - struct trapframe *tp; - - tp = td->td_frame; - pcb = td->td_pcb; - regs->r_gs = pcb->pcb_gs; - return (fill_frame_regs(tp, regs)); -} - -int -fill_frame_regs(struct trapframe *tp, struct reg *regs) -{ - regs->r_fs = tp->tf_fs; - regs->r_es = tp->tf_es; - regs->r_ds = tp->tf_ds; - regs->r_edi = tp->tf_edi; - regs->r_esi = tp->tf_esi; - regs->r_ebp = tp->tf_ebp; - regs->r_ebx = tp->tf_ebx; - regs->r_edx = tp->tf_edx; - regs->r_ecx = tp->tf_ecx; - regs->r_eax = tp->tf_eax; - regs->r_eip = tp->tf_eip; - regs->r_cs = tp->tf_cs; - regs->r_eflags = tp->tf_eflags; - regs->r_esp = tp->tf_esp; - regs->r_ss = tp->tf_ss; - return (0); -} - -int -set_regs(struct thread *td, struct reg *regs) -{ - struct pcb *pcb; - struct trapframe *tp; - - tp = td->td_frame; - if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) || - !CS_SECURE(regs->r_cs)) - return (EINVAL); - pcb = td->td_pcb; - tp->tf_fs = regs->r_fs; - tp->tf_es = regs->r_es; - tp->tf_ds = regs->r_ds; - tp->tf_edi = regs->r_edi; - tp->tf_esi = regs->r_esi; - tp->tf_ebp = regs->r_ebp; - tp->tf_ebx = regs->r_ebx; - tp->tf_edx = regs->r_edx; - tp->tf_ecx = regs->r_ecx; - tp->tf_eax = regs->r_eax; - tp->tf_eip = regs->r_eip; - tp->tf_cs = regs->r_cs; - tp->tf_eflags = regs->r_eflags; - tp->tf_esp = regs->r_esp; - tp->tf_ss = regs->r_ss; - pcb->pcb_gs = regs->r_gs; - return (0); -} - -#ifdef CPU_ENABLE_SSE -static void -fill_fpregs_xmm(sv_xmm, sv_87) - struct savexmm *sv_xmm; - struct save87 *sv_87; -{ - register struct env87 *penv_87 = &sv_87->sv_env; - register struct envxmm *penv_xmm = &sv_xmm->sv_env; - int i; - - bzero(sv_87, sizeof(*sv_87)); - - /* FPU control/status */ - penv_87->en_cw = penv_xmm->en_cw; - penv_87->en_sw = penv_xmm->en_sw; - penv_87->en_tw = penv_xmm->en_tw; - penv_87->en_fip = penv_xmm->en_fip; - penv_87->en_fcs = penv_xmm->en_fcs; - penv_87->en_opcode = penv_xmm->en_opcode; - penv_87->en_foo = penv_xmm->en_foo; - penv_87->en_fos = penv_xmm->en_fos; - - /* FPU registers */ - for (i = 0; i < 8; ++i) - sv_87->sv_ac[i] = sv_xmm->sv_fp[i].fp_acc; -} - -static void -set_fpregs_xmm(sv_87, sv_xmm) - struct save87 *sv_87; - struct savexmm *sv_xmm; -{ - register struct env87 *penv_87 = &sv_87->sv_env; - register struct envxmm *penv_xmm = &sv_xmm->sv_env; - int i; - - /* FPU control/status */ - penv_xmm->en_cw = penv_87->en_cw; - penv_xmm->en_sw = penv_87->en_sw; - penv_xmm->en_tw = penv_87->en_tw; - penv_xmm->en_fip = penv_87->en_fip; - penv_xmm->en_fcs = penv_87->en_fcs; - penv_xmm->en_opcode = penv_87->en_opcode; - penv_xmm->en_foo = penv_87->en_foo; - penv_xmm->en_fos = penv_87->en_fos; - - /* FPU registers */ - for (i = 0; i < 8; ++i) - sv_xmm->sv_fp[i].fp_acc = sv_87->sv_ac[i]; -} -#endif /* CPU_ENABLE_SSE */ - -int -fill_fpregs(struct thread *td, struct fpreg *fpregs) -{ - - KASSERT(td == curthread || TD_IS_SUSPENDED(td) || - P_SHOULDSTOP(td->td_proc), - ("not suspended thread %p", td)); -#ifdef DEV_NPX - npxgetregs(td); -#else - bzero(fpregs, sizeof(*fpregs)); -#endif -#ifdef CPU_ENABLE_SSE - if (cpu_fxsr) - fill_fpregs_xmm(&td->td_pcb->pcb_user_save.sv_xmm, - (struct save87 *)fpregs); - else -#endif /* CPU_ENABLE_SSE */ - bcopy(&td->td_pcb->pcb_user_save.sv_87, fpregs, - sizeof(*fpregs)); - return (0); -} - -int -set_fpregs(struct thread *td, struct fpreg *fpregs) -{ - -#ifdef CPU_ENABLE_SSE - if (cpu_fxsr) - set_fpregs_xmm((struct save87 *)fpregs, - &td->td_pcb->pcb_user_save.sv_xmm); - else -#endif /* CPU_ENABLE_SSE */ - bcopy(fpregs, &td->td_pcb->pcb_user_save.sv_87, - sizeof(*fpregs)); -#ifdef DEV_NPX - npxuserinited(td); -#endif - return (0); -} - -/* - * Get machine context. - */ -int -get_mcontext(struct thread *td, mcontext_t *mcp, int flags) -{ - struct trapframe *tp; - struct segment_descriptor *sdp; - - tp = td->td_frame; - - PROC_LOCK(curthread->td_proc); - mcp->mc_onstack = sigonstack(tp->tf_esp); - PROC_UNLOCK(curthread->td_proc); - mcp->mc_gs = td->td_pcb->pcb_gs; - mcp->mc_fs = tp->tf_fs; - mcp->mc_es = tp->tf_es; - mcp->mc_ds = tp->tf_ds; - mcp->mc_edi = tp->tf_edi; - mcp->mc_esi = tp->tf_esi; - mcp->mc_ebp = tp->tf_ebp; - mcp->mc_isp = tp->tf_isp; - mcp->mc_eflags = tp->tf_eflags; - if (flags & GET_MC_CLEAR_RET) { - mcp->mc_eax = 0; - mcp->mc_edx = 0; - mcp->mc_eflags &= ~PSL_C; - } else { - mcp->mc_eax = tp->tf_eax; - mcp->mc_edx = tp->tf_edx; - } - mcp->mc_ebx = tp->tf_ebx; - mcp->mc_ecx = tp->tf_ecx; - mcp->mc_eip = tp->tf_eip; - mcp->mc_cs = tp->tf_cs; - mcp->mc_esp = tp->tf_esp; - mcp->mc_ss = tp->tf_ss; - mcp->mc_len = sizeof(*mcp); - get_fpcontext(td, mcp); - sdp = &td->td_pcb->pcb_fsd; - mcp->mc_fsbase = sdp->sd_hibase << 24 | sdp->sd_lobase; - sdp = &td->td_pcb->pcb_gsd; - mcp->mc_gsbase = sdp->sd_hibase << 24 | sdp->sd_lobase; - mcp->mc_flags = 0; - bzero(mcp->mc_spare2, sizeof(mcp->mc_spare2)); - return (0); -} - -/* - * Set machine context. - * - * However, we don't set any but the user modifiable flags, and we won't - * touch the cs selector. - */ -int -set_mcontext(struct thread *td, const mcontext_t *mcp) -{ - struct trapframe *tp; - int eflags, ret; - - tp = td->td_frame; - if (mcp->mc_len != sizeof(*mcp)) - return (EINVAL); - eflags = (mcp->mc_eflags & PSL_USERCHANGE) | - (tp->tf_eflags & ~PSL_USERCHANGE); - if ((ret = set_fpcontext(td, mcp)) == 0) { - tp->tf_fs = mcp->mc_fs; - tp->tf_es = mcp->mc_es; - tp->tf_ds = mcp->mc_ds; - tp->tf_edi = mcp->mc_edi; - tp->tf_esi = mcp->mc_esi; - tp->tf_ebp = mcp->mc_ebp; - tp->tf_ebx = mcp->mc_ebx; - tp->tf_edx = mcp->mc_edx; - tp->tf_ecx = mcp->mc_ecx; - tp->tf_eax = mcp->mc_eax; - tp->tf_eip = mcp->mc_eip; - tp->tf_eflags = eflags; - tp->tf_esp = mcp->mc_esp; - tp->tf_ss = mcp->mc_ss; - td->td_pcb->pcb_gs = mcp->mc_gs; - ret = 0; - } - return (ret); -} - -static void -get_fpcontext(struct thread *td, mcontext_t *mcp) -{ - -#ifndef DEV_NPX - mcp->mc_fpformat = _MC_FPFMT_NODEV; - mcp->mc_ownedfp = _MC_FPOWNED_NONE; - bzero(mcp->mc_fpstate, sizeof(mcp->mc_fpstate)); -#else - mcp->mc_ownedfp = npxgetregs(td); - bcopy(&td->td_pcb->pcb_user_save, &mcp->mc_fpstate[0], - sizeof(mcp->mc_fpstate)); - mcp->mc_fpformat = npxformat(); -#endif -} - -static int -set_fpcontext(struct thread *td, const mcontext_t *mcp) -{ - - if (mcp->mc_fpformat == _MC_FPFMT_NODEV) - return (0); - else if (mcp->mc_fpformat != _MC_FPFMT_387 && - mcp->mc_fpformat != _MC_FPFMT_XMM) - return (EINVAL); - else if (mcp->mc_ownedfp == _MC_FPOWNED_NONE) - /* We don't care what state is left in the FPU or PCB. */ - fpstate_drop(td); - else if (mcp->mc_ownedfp == _MC_FPOWNED_FPU || - mcp->mc_ownedfp == _MC_FPOWNED_PCB) { -#ifdef DEV_NPX -#ifdef CPU_ENABLE_SSE - if (cpu_fxsr) - ((union savefpu *)&mcp->mc_fpstate)->sv_xmm.sv_env. - en_mxcsr &= cpu_mxcsr_mask; -#endif - npxsetregs(td, (union savefpu *)&mcp->mc_fpstate); -#endif - } else - return (EINVAL); - return (0); -} - -static void -fpstate_drop(struct thread *td) -{ - - KASSERT(PCB_USER_FPU(td->td_pcb), ("fpstate_drop: kernel-owned fpu")); - critical_enter(); -#ifdef DEV_NPX - if (PCPU_GET(fpcurthread) == td) - npxdrop(); -#endif - /* - * XXX force a full drop of the npx. The above only drops it if we - * owned it. npxgetregs() has the same bug in the !cpu_fxsr case. - * - * XXX I don't much like npxgetregs()'s semantics of doing a full - * drop. Dropping only to the pcb matches fnsave's behaviour. - * We only need to drop to !PCB_INITDONE in sendsig(). But - * sendsig() is the only caller of npxgetregs()... perhaps we just - * have too many layers. - */ - curthread->td_pcb->pcb_flags &= ~(PCB_NPXINITDONE | - PCB_NPXUSERINITDONE); - critical_exit(); -} - -int -fill_dbregs(struct thread *td, struct dbreg *dbregs) -{ - struct pcb *pcb; - - if (td == NULL) { - dbregs->dr[0] = rdr0(); - dbregs->dr[1] = rdr1(); - dbregs->dr[2] = rdr2(); - dbregs->dr[3] = rdr3(); - dbregs->dr[4] = rdr4(); - dbregs->dr[5] = rdr5(); - dbregs->dr[6] = rdr6(); - dbregs->dr[7] = rdr7(); - } else { - pcb = td->td_pcb; - dbregs->dr[0] = pcb->pcb_dr0; - dbregs->dr[1] = pcb->pcb_dr1; - dbregs->dr[2] = pcb->pcb_dr2; - dbregs->dr[3] = pcb->pcb_dr3; - dbregs->dr[4] = 0; - dbregs->dr[5] = 0; - dbregs->dr[6] = pcb->pcb_dr6; - dbregs->dr[7] = pcb->pcb_dr7; - } - return (0); -} - -int -set_dbregs(struct thread *td, struct dbreg *dbregs) -{ - struct pcb *pcb; - int i; - - if (td == NULL) { - load_dr0(dbregs->dr[0]); - load_dr1(dbregs->dr[1]); - load_dr2(dbregs->dr[2]); - load_dr3(dbregs->dr[3]); - load_dr4(dbregs->dr[4]); - load_dr5(dbregs->dr[5]); - load_dr6(dbregs->dr[6]); - load_dr7(dbregs->dr[7]); - } else { - /* - * Don't let an illegal value for dr7 get set. Specifically, - * check for undefined settings. Setting these bit patterns - * result in undefined behaviour and can lead to an unexpected - * TRCTRAP. - */ - for (i = 0; i < 4; i++) { - if (DBREG_DR7_ACCESS(dbregs->dr[7], i) == 0x02) - return (EINVAL); - if (DBREG_DR7_LEN(dbregs->dr[7], i) == 0x02) - return (EINVAL); - } - - pcb = td->td_pcb; - - /* - * Don't let a process set a breakpoint that is not within the - * process's address space. If a process could do this, it - * could halt the system by setting a breakpoint in the kernel - * (if ddb was enabled). Thus, we need to check to make sure - * that no breakpoints are being enabled for addresses outside - * process's address space. - * - * XXX - what about when the watched area of the user's - * address space is written into from within the kernel - * ... wouldn't that still cause a breakpoint to be generated - * from within kernel mode? - */ - - if (DBREG_DR7_ENABLED(dbregs->dr[7], 0)) { - /* dr0 is enabled */ - if (dbregs->dr[0] >= VM_MAXUSER_ADDRESS) - return (EINVAL); - } - - if (DBREG_DR7_ENABLED(dbregs->dr[7], 1)) { - /* dr1 is enabled */ - if (dbregs->dr[1] >= VM_MAXUSER_ADDRESS) - return (EINVAL); - } - - if (DBREG_DR7_ENABLED(dbregs->dr[7], 2)) { - /* dr2 is enabled */ - if (dbregs->dr[2] >= VM_MAXUSER_ADDRESS) - return (EINVAL); - } - - if (DBREG_DR7_ENABLED(dbregs->dr[7], 3)) { - /* dr3 is enabled */ - if (dbregs->dr[3] >= VM_MAXUSER_ADDRESS) - return (EINVAL); - } - - pcb->pcb_dr0 = dbregs->dr[0]; - pcb->pcb_dr1 = dbregs->dr[1]; - pcb->pcb_dr2 = dbregs->dr[2]; - pcb->pcb_dr3 = dbregs->dr[3]; - pcb->pcb_dr6 = dbregs->dr[6]; - pcb->pcb_dr7 = dbregs->dr[7]; - - pcb->pcb_flags |= PCB_DBREGS; - } - - return (0); -} - -/* - * Return > 0 if a hardware breakpoint has been hit, and the - * breakpoint was in user space. Return 0, otherwise. - */ -int -user_dbreg_trap(void) -{ - u_int32_t dr7, dr6; /* debug registers dr6 and dr7 */ - u_int32_t bp; /* breakpoint bits extracted from dr6 */ - int nbp; /* number of breakpoints that triggered */ - caddr_t addr[4]; /* breakpoint addresses */ - int i; - - dr7 = rdr7(); - if ((dr7 & 0x000000ff) == 0) { - /* - * all GE and LE bits in the dr7 register are zero, - * thus the trap couldn't have been caused by the - * hardware debug registers - */ - return 0; - } - - nbp = 0; - dr6 = rdr6(); - bp = dr6 & 0x0000000f; - - if (!bp) { - /* - * None of the breakpoint bits are set meaning this - * trap was not caused by any of the debug registers - */ - return 0; - } - - /* - * at least one of the breakpoints were hit, check to see - * which ones and if any of them are user space addresses - */ - - if (bp & 0x01) { - addr[nbp++] = (caddr_t)rdr0(); - } - if (bp & 0x02) { - addr[nbp++] = (caddr_t)rdr1(); - } - if (bp & 0x04) { - addr[nbp++] = (caddr_t)rdr2(); - } - if (bp & 0x08) { - addr[nbp++] = (caddr_t)rdr3(); - } - - for (i = 0; i < nbp; i++) { - if (addr[i] < (caddr_t)VM_MAXUSER_ADDRESS) { - /* - * addr[i] is in user space - */ - return nbp; - } - } - - /* - * None of the breakpoints are in user space. - */ - return 0; -} - -#ifdef KDB - -/* - * Provide inb() and outb() as functions. They are normally only available as - * inline functions, thus cannot be called from the debugger. - */ - -/* silence compiler warnings */ -u_char inb_(u_short); -void outb_(u_short, u_char); - -u_char -inb_(u_short port) -{ - return inb(port); -} - -void -outb_(u_short port, u_char data) -{ - outb(port, data); -} - -#endif /* KDB */ diff --git a/sys/powerpc/aim/locore64.S b/sys/powerpc/aim/locore64.S index 65c4999a1e2d..0c26e01125b3 100644 --- a/sys/powerpc/aim/locore64.S +++ b/sys/powerpc/aim/locore64.S @@ -160,6 +160,7 @@ ASENTRY_NOPROF(__start) li 8,1 insrdi 9,8,1,0 mtmsrd 9 + isync bl OF_initial_setup nop diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c index 16b22904075e..17fc452f55e7 100644 --- a/sys/powerpc/aim/machdep.c +++ b/sys/powerpc/aim/machdep.c @@ -129,10 +129,6 @@ __FBSDID("$FreeBSD$"); #include -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif - int cold = 1; #ifdef __powerpc64__ extern int n_slbs; @@ -268,6 +264,10 @@ powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel, #ifndef __powerpc64__ int ppc64; #endif +#ifdef DDB + vm_offset_t ksym_start; + vm_offset_t ksym_end; +#endif kmdp = NULL; trap_offset = 0; @@ -302,6 +302,7 @@ powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel, #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); + db_fetch_ksymtab(ksym_start, ksym_end); #endif } } diff --git a/sys/powerpc/booke/machdep.c b/sys/powerpc/booke/machdep.c index fc98ed6e1ef7..d3de34c81434 100644 --- a/sys/powerpc/booke/machdep.c +++ b/sys/powerpc/booke/machdep.c @@ -142,7 +142,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef DDB -extern vm_offset_t ksym_start, ksym_end; +#include #endif #ifdef DEBUG @@ -300,6 +300,10 @@ booke_init(uint32_t arg1, uint32_t arg2) struct pcpu *pc; void *kmdp, *mdp; vm_offset_t dtbp, end; +#ifdef DDB + vm_offset_t ksym_start; + vm_offset_t ksym_end; +#endif kmdp = NULL; @@ -360,6 +364,7 @@ booke_init(uint32_t arg1, uint32_t arg2) #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); + db_fetch_ksymtab(ksym_start, ksym_end); #endif } } else { diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c index aa943ac11f8e..66fa34163b68 100644 --- a/sys/powerpc/ofw/ofw_pcibus.c +++ b/sys/powerpc/ofw/ofw_pcibus.c @@ -200,29 +200,8 @@ ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno) * interrupts property, so add that value to the device's * resource list. */ - if (dinfo->opd_dinfo.cfg.intpin == 0) { - ofw_pci_intr_t intr[2]; - phandle_t iparent; - int icells; - - if (OF_getprop(child, "interrupts", &intr, - sizeof(intr)) > 0) { - iparent = 0; - icells = 1; - OF_getprop(child, "interrupt-parent", &iparent, - sizeof(iparent)); - if (iparent != 0) { - OF_getprop(OF_node_from_xref(iparent), - "#interrupt-cells", &icells, - sizeof(icells)); - intr[0] = ofw_bus_map_intr(dev, iparent, - icells, intr); - } - - resource_list_add(&dinfo->opd_dinfo.resources, - SYS_RES_IRQ, 0, intr[0], intr[0], 1); - } - } + if (dinfo->opd_dinfo.cfg.intpin == 0) + ofw_bus_intr_to_rl(dev, child, &dinfo->opd_dinfo.resources); } } diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c index af3fec884aa5..cc7624f61e4d 100644 --- a/sys/powerpc/powerpc/intr_machdep.c +++ b/sys/powerpc/powerpc/intr_machdep.c @@ -293,7 +293,7 @@ powerpc_intr_post_ithread(void *arg) } static int -powerpc_assign_intr_cpu(void *arg, u_char cpu) +powerpc_assign_intr_cpu(void *arg, int cpu) { #ifdef SMP struct powerpc_intr *i = arg; diff --git a/sys/powerpc/ps3/if_glc.c b/sys/powerpc/ps3/if_glc.c index 3b34f1832e4c..a22429744158 100644 --- a/sys/powerpc/ps3/if_glc.c +++ b/sys/powerpc/ps3/if_glc.c @@ -731,7 +731,7 @@ glc_rxintr(struct glc_softc *sc) restart_rxdma = 1; if (sc->sc_rxdmadesc[i].rxerror & GELIC_RXERRORS) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto requeue; } @@ -747,11 +747,11 @@ glc_rxintr(struct glc_softc *sc) } if (glc_add_rxbuf(sc, i)) { - ifp->if_ierrors++; + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); goto requeue; } - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); m->m_pkthdr.rcvif = ifp; m->m_len = sc->sc_rxdmadesc[i].valid_size; m->m_pkthdr.len = m->m_len; @@ -810,7 +810,7 @@ glc_txintr(struct glc_softc *sc) != 0) { lv1_net_stop_tx_dma(sc->sc_bus, sc->sc_dev, 0); kickstart = 1; - ifp->if_oerrors++; + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); } if (sc->sc_txdmadesc[txs->txs_lastdesc].cmd_stat & @@ -818,7 +818,7 @@ glc_txintr(struct glc_softc *sc) kickstart = 1; STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); progress = 1; } diff --git a/sys/powerpc/ps3/ps3_syscons.c b/sys/powerpc/ps3/ps3_syscons.c index 1c4f4d850bc4..1b669aa3866a 100644 --- a/sys/powerpc/ps3/ps3_syscons.c +++ b/sys/powerpc/ps3/ps3_syscons.c @@ -78,6 +78,8 @@ static struct vt_driver vt_ps3fb_driver = { .vd_blank = vt_fb_blank, .vd_bitblt_text = vt_fb_bitblt_text, .vd_bitblt_bmp = vt_fb_bitblt_bitmap, + .vd_drawrect = vt_fb_drawrect, + .vd_setpixel = vt_fb_setpixel, .vd_fb_ioctl = vt_fb_ioctl, .vd_fb_mmap = vt_fb_mmap, /* Better than VGA, but still generic driver. */ diff --git a/sys/powerpc/pseries/phyp_llan.c b/sys/powerpc/pseries/phyp_llan.c index 51f2bb14fd3d..0b25f398fb83 100644 --- a/sys/powerpc/pseries/phyp_llan.c +++ b/sys/powerpc/pseries/phyp_llan.c @@ -345,13 +345,13 @@ llan_intr(void *xsc) /* llan_add_rxbuf does DMA sync and unload as well as requeue */ if (llan_add_rxbuf(sc, rx) != 0) { - sc->ifp->if_ierrors++; + if_inc_counter(sc->ifp, IFCOUNTER_IERRORS, 1); phyp_hcall(H_ADD_LOGICAL_LAN_BUFFER, sc->unit, rx->rx_bufdesc); continue; } - sc->ifp->if_ipackets++; + if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); m_adj(m, sc->rx_buf[sc->rx_dma_slot].offset); m->m_len = sc->rx_buf[sc->rx_dma_slot].length; m->m_pkthdr.rcvif = sc->ifp; diff --git a/sys/powerpc/pseries/vdevice.c b/sys/powerpc/pseries/vdevice.c index d2c399b9581d..8dadd630a196 100644 --- a/sys/powerpc/pseries/vdevice.c +++ b/sys/powerpc/pseries/vdevice.c @@ -128,8 +128,6 @@ vdevice_attach(device_t dev) { phandle_t root, child; device_t cdev; - int icells, i, nintr, *intr; - phandle_t iparent; struct vdevice_devinfo *dinfo; root = ofw_bus_get_node(dev); @@ -144,25 +142,7 @@ vdevice_attach(device_t dev) } resource_list_init(&dinfo->mdi_resources); - if (OF_searchprop(child, "#interrupt-cells", &icells, - sizeof(icells)) <= 0) - icells = 2; - if (OF_getprop(child, "interrupt-parent", &iparent, - sizeof(iparent)) <= 0) - iparent = -1; - nintr = OF_getprop_alloc(child, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - for (i = 0; i < nintr; i += icells) { - u_int irq = intr[i]; - if (iparent != -1) - irq = ofw_bus_map_intr(dev, iparent, - icells, &intr[i]); - - resource_list_add(&dinfo->mdi_resources, - SYS_RES_IRQ, i, irq, irq, i); - } - } + ofw_bus_intr_to_rl(dev, child, &dinfo->mdi_resources); cdev = device_add_child(dev, NULL, -1); if (cdev == NULL) { diff --git a/sys/sparc64/sparc64/intr_machdep.c b/sys/sparc64/sparc64/intr_machdep.c index dab11c2d50ef..fe467f0e03d6 100644 --- a/sys/sparc64/sparc64/intr_machdep.c +++ b/sys/sparc64/sparc64/intr_machdep.c @@ -116,7 +116,7 @@ static void intr_assign_next_cpu(struct intr_vector *iv); static void intr_shuffle_irqs(void *arg __unused); #endif -static int intr_assign_cpu(void *arg, u_char cpu); +static int intr_assign_cpu(void *arg, int cpu); static void intr_execute_handlers(void *); static void intr_stray_level(struct trapframe *); static void intr_stray_vector(void *); @@ -256,7 +256,7 @@ intr_init2() } static int -intr_assign_cpu(void *arg, u_char cpu) +intr_assign_cpu(void *arg, int cpu) { #ifdef SMP struct pcpu *pc; diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index 587c90899a7b..0ee6de3a5131 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -114,10 +114,6 @@ __FBSDID("$FreeBSD$"); typedef int ofw_vec_t(void *); -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif - int dtlb_slots; int itlb_slots; struct tlb_entry *kernel_tlbs; diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 86bd40af7de0..f4579055a0dc 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -339,6 +339,7 @@ int bus_generic_read_ivar(device_t dev, device_t child, int which, int bus_generic_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r); int bus_generic_resume(device_t dev); +int bus_generic_resume_child(device_t dev, device_t child); int bus_generic_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *intr, @@ -357,6 +358,7 @@ int bus_generic_rl_release_resource (device_t, device_t, int, int, int bus_generic_shutdown(device_t dev); int bus_generic_suspend(device_t dev); +int bus_generic_suspend_child(device_t dev, device_t child); int bus_generic_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie); int bus_generic_write_ivar(device_t dev, device_t child, int which, diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index e1ad341d3b24..ba2b7ceaa98a 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -118,7 +118,7 @@ struct cpuset *cpuset_thread0(void); struct cpuset *cpuset_ref(struct cpuset *); void cpuset_rel(struct cpuset *); int cpuset_setthread(lwpid_t id, cpuset_t *); -int cpuset_setithread(lwpid_t id, u_char cpu); +int cpuset_setithread(lwpid_t id, int cpu); int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); char *cpusetobj_strprint(char *, const cpuset_t *); diff --git a/sys/sys/fdcio.h b/sys/sys/fdcio.h index e3ffc249cb7c..c4d39c2af31e 100644 --- a/sys/sys/fdcio.h +++ b/sys/sys/fdcio.h @@ -181,27 +181,17 @@ enum fd_drivetype { * XXX: should have been done 20 years ago to make sense. */ #ifdef PC98 -#define FDF_3_1722 21,2,0xFF,0x04,82,0,2,2,0x0C,2,0,FL_MFM -#define FDF_3_1476 18,2,0xFF,0x1B,82,0,2,2,0x54,1,0,FL_MFM #define FDF_3_1440 18,2,0xFF,0x1B,80,0,2,2,0x54,1,0,FL_MFM #define FDF_3_1200 15,2,0xFF,0x1B,80,0,0,2,0x54,1,0,FL_MFM -#define FDF_3_820 10,2,0xFF,0x10,82,0,1,2,0x30,1,0,FL_MFM -#define FDF_3_800 10,2,0xFF,0x10,80,0,1,2,0x30,1,0,FL_MFM #define FDF_3_720 9,2,0xFF,0x20,80,0,1,2,0x50,1,0,FL_MFM #define FDF_3_360 9,2,0xFF,0x20,40,0,1,2,0x50,1,0,FL_MFM|FL_2STEP #define FDF_3_640 8,2,0xFF,0x2A,80,0,1,2,0x50,1,0,FL_MFM #define FDF_3_1230 8,3,0xFF,0x35,77,0,0,2,0x74,1,0,FL_MFM -#define FDF_3_1280 8,3,0xFF,0x35,80,0,0,2,0x74,1,0,FL_MFM -#define FDF_3_1480 9,3,0xFF,0x35,82,0,0,2,0x47,1,0,FL_MFM -#define FDF_3_1640 10,3,0xFF,0x1B,82,0,2,2,0x54,1,0,FL_MFM #define FDF_5_1200 15,2,0xFF,0x1B,80,0,0,2,0x54,1,0,FL_MFM -#define FDF_5_820 10,2,0xFF,0x10,82,0,1,2,0x30,1,0,FL_MFM -#define FDF_5_800 10,2,0xFF,0x10,80,0,1,2,0x30,1,0,FL_MFM #define FDF_5_720 9,2,0xFF,0x20,80,0,1,2,0x50,1,0,FL_MFM #define FDF_5_360 9,2,0xFF,0x20,40,0,1,2,0x50,1,0,FL_MFM|FL_2STEP #define FDF_5_640 8,2,0xFF,0x2A,80,0,1,2,0x50,1,0,FL_MFM #define FDF_5_1230 8,3,0xFF,0x35,77,0,0,2,0x74,1,0,FL_MFM -#define FDF_5_1280 8,3,0xFF,0x35,80,0,0,2,0x74,1,0,FL_MFM #else /* PC98 */ #define FDF_3_2880 36,2,0xFF,0x1B,80,0,FDC_1MBPS,002,0x4C,1,1,FL_MFM|FL_PERPND #define FDF_3_1722 21,2,0xFF,0x04,82,0,FDC_500KBPS,2,0x0C,2,0,FL_MFM diff --git a/sys/sys/file.h b/sys/sys/file.h index 63072e0a03cf..e593d4326240 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -43,6 +43,7 @@ #include #include +struct filedesc; struct stat; struct thread; struct uio; @@ -70,6 +71,7 @@ struct socket; struct file; struct filecaps; +struct kinfo_file; struct ucred; #define FOF_OFFSET 0x01 /* Use the offset in uio argument */ @@ -114,6 +116,8 @@ typedef int fo_sendfile_t(struct file *fp, int sockfd, struct uio *hdr_uio, struct sendfile_sync *sfs, struct thread *td); typedef int fo_seek_t(struct file *fp, off_t offset, int whence, struct thread *td); +typedef int fo_fill_kinfo_t(struct file *fp, struct kinfo_file *kif, + struct filedesc *fdp); typedef int fo_flags_t; struct fileops { @@ -129,6 +133,7 @@ struct fileops { fo_chown_t *fo_chown; fo_sendfile_t *fo_sendfile; fo_seek_t *fo_seek; + fo_fill_kinfo_t *fo_fill_kinfo; fo_flags_t fo_flags; /* DFLAG_* below */ }; @@ -231,13 +236,19 @@ int fget_write(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp); int _fdrop(struct file *fp, struct thread *td); +fo_rdwr_t invfo_rdwr; +fo_truncate_t invfo_truncate; +fo_ioctl_t invfo_ioctl; +fo_poll_t invfo_poll; +fo_kqfilter_t invfo_kqfilter; fo_chmod_t invfo_chmod; fo_chown_t invfo_chown; fo_sendfile_t invfo_sendfile; -fo_truncate_t invfo_truncate; fo_sendfile_t vn_sendfile; fo_seek_t vn_seek; +fo_fill_kinfo_t vn_fill_kinfo; +int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif); void finit(struct file *, u_int, short, void *, struct fileops *); int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp, @@ -374,6 +385,13 @@ fo_seek(struct file *fp, off_t offset, int whence, struct thread *td) return ((*fp->f_ops->fo_seek)(fp, offset, whence, td)); } +static __inline int +fo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) +{ + + return ((*fp->f_ops->fo_fill_kinfo)(fp, kif, fdp)); +} + #endif /* _KERNEL */ #endif /* !SYS_FILE_H */ diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index d407cd20f44b..cda6c4ec7303 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -33,11 +33,14 @@ #ifndef _SYS_FILEDESC_H_ #define _SYS_FILEDESC_H_ +#include "opt_capsicum.h" + #include #include #include #include #include +#include #include #include @@ -50,6 +53,9 @@ struct filecaps { }; struct filedescent { +#ifdef CAPABILITIES + seq_t fde_seq; /* if you need fde_file and fde_caps in sync */ +#endif struct file *fde_file; /* file structure for open file */ struct filecaps fde_caps; /* per-descriptor rights */ uint8_t fde_flags; /* per-process open file flags */ @@ -58,6 +64,13 @@ struct filedescent { #define fde_fcntls fde_caps.fc_fcntls #define fde_ioctls fde_caps.fc_ioctls #define fde_nioctls fde_caps.fc_nioctls +#ifdef CAPABILITIES +#define fde_change(fde) ((char *)(fde) + sizeof(seq_t)) +#define fde_change_size (sizeof(struct filedescent) - sizeof(seq_t)) +#else +#define fde_change(fde) ((fde)) +#define fde_change_size (sizeof(struct filedescent)) +#endif /* * This structure is used for the management of descriptors. It may be @@ -82,6 +95,9 @@ struct filedesc { int fd_holdleaderscount; /* block fdfree() for shared close() */ int fd_holdleaderswakeup; /* fdfree() needs wakeup */ }; +#ifdef CAPABILITIES +#define fd_seq(fdp, fd) (&(fdp)->fd_ofiles[(fd)].fde_seq) +#endif /* * Structure to keep track of (process leader, struct fildedesc) tuples. @@ -109,11 +125,6 @@ struct filedesc_to_leader { #ifdef _KERNEL -/* Flags for do_dup() */ -#define DUP_FIXED 0x1 /* Force fixed allocation. */ -#define DUP_FCNTL 0x2 /* fcntl()-style errors. */ -#define DUP_CLOEXEC 0x4 /* Atomically set FD_CLOEXEC. */ - /* Lock a file descriptor table. */ #define FILEDESC_LOCK_INIT(fdp) sx_init(&(fdp)->fd_sx, "filedesc structure") #define FILEDESC_LOCK_DESTROY(fdp) sx_destroy(&(fdp)->fd_sx) @@ -137,8 +148,6 @@ void filecaps_move(struct filecaps *src, struct filecaps *dst); void filecaps_free(struct filecaps *fcaps); int closef(struct file *fp, struct thread *td); -int do_dup(struct thread *td, int flags, int old, int new, - register_t *retval); int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, int openerror, int *indxp); int falloc(struct thread *td, struct file **resultfp, int *resultfd, diff --git a/sys/sys/interrupt.h b/sys/sys/interrupt.h index 3dace82ed3b4..c320e5fc8f12 100644 --- a/sys/sys/interrupt.h +++ b/sys/sys/interrupt.h @@ -112,13 +112,13 @@ struct intr_event { void (*ie_pre_ithread)(void *); void (*ie_post_ithread)(void *); void (*ie_post_filter)(void *); - int (*ie_assign_cpu)(void *, u_char); + int (*ie_assign_cpu)(void *, int); int ie_flags; int ie_count; /* Loop counter. */ int ie_warncnt; /* Rate-check interrupt storm warns. */ struct timeval ie_warntm; int ie_irq; /* Physical irq number if !SOFT. */ - u_char ie_cpu; /* CPU this event is bound to. */ + int ie_cpu; /* CPU this event is bound to. */ }; /* Interrupt event flags kept in ie_flags. */ @@ -161,11 +161,11 @@ u_char intr_priority(enum intr_type flags); int intr_event_add_handler(struct intr_event *ie, const char *name, driver_filter_t filter, driver_intr_t handler, void *arg, u_char pri, enum intr_type flags, void **cookiep); -int intr_event_bind(struct intr_event *ie, u_char cpu); +int intr_event_bind(struct intr_event *ie, int cpu); int intr_event_create(struct intr_event **event, void *source, int flags, int irq, void (*pre_ithread)(void *), void (*post_ithread)(void *), void (*post_filter)(void *), - int (*assign_cpu)(void *, u_char), const char *fmt, ...) + int (*assign_cpu)(void *, int), const char *fmt, ...) __printflike(9, 10); int intr_event_describe_handler(struct intr_event *ie, void *cookie, const char *descr); diff --git a/sys/sys/ksem.h b/sys/sys/ksem.h index c11c8656b64d..b337a2bfb6fb 100644 --- a/sys/sys/ksem.h +++ b/sys/sys/ksem.h @@ -63,9 +63,4 @@ struct ksem { #define KS_ANONYMOUS 0x0001 /* Anonymous (unnamed) semaphore. */ #define KS_DEAD 0x0002 /* No new waiters allowed. */ -#ifdef _KERNEL -extern void (*ksem_info)(struct ksem *ks, char *path, size_t size, - uint32_t *value); -#endif - #endif /* !_POSIX4_KSEM_H_ */ diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 5f850fb2da85..ec5f761e7a86 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -103,6 +103,7 @@ int locc(int, char *, u_int); void *memchr(const void *s, int c, size_t n); void *memcchr(const void *s, int c, size_t n); int memcmp(const void *b1, const void *b2, size_t len); +void *memmem(const void *l, size_t l_len, const void *s, size_t s_len); void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 1a64eb037aee..d3e6ce080e1e 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -672,7 +672,7 @@ m_clget(struct mbuf *m, int how) { if (m->m_flags & M_EXT) - printf("%s: %p mbuf already has cluster\n", __func__, m); + printf("%s: %p mbuf already has external storage\n", __func__, m); m->m_ext.ext_buf = (char *)NULL; uma_zalloc_arg(zone_clust, m, how); /* @@ -698,7 +698,7 @@ m_cljget(struct mbuf *m, int how, int size) uma_zone_t zone; if (m && m->m_flags & M_EXT) - printf("%s: %p mbuf already has cluster\n", __func__, m); + printf("%s: %p mbuf already has external storage\n", __func__, m); if (m != NULL) m->m_ext.ext_buf = NULL; @@ -842,30 +842,51 @@ m_last(struct mbuf *m) ~(sizeof(long) - 1); \ } while (0) +/* + * Return the address of the start of the buffer associated with an mbuf, + * handling external storage, packet-header mbufs, and regular data mbufs. + */ +#define M_START(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_buf : \ + ((m)->m_flags & M_PKTHDR) ? &(m)->m_pktdat[0] : \ + &(m)->m_dat[0]) + +/* + * Return the size of the buffer associated with an mbuf, handling external + * storage, packet-header mbufs, and regular data mbufs. + */ +#define M_SIZE(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \ + ((m)->m_flags & M_PKTHDR) ? MHLEN : \ + MLEN) + /* * Compute the amount of space available before the current start of data in * an mbuf. * * The M_WRITABLE() is a temporary, conservative safety measure: the burden * of checking writability of the mbuf data area rests solely with the caller. + * + * NB: In previous versions, M_LEADINGSPACE() would only check M_WRITABLE() + * for mbufs with external storage. We now allow mbuf-embedded data to be + * read-only as well. */ #define M_LEADINGSPACE(m) \ - ((m)->m_flags & M_EXT ? \ - (M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \ - (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \ - (m)->m_data - (m)->m_dat) + (M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0) /* * Compute the amount of space available after the end of data in an mbuf. * * The M_WRITABLE() is a temporary, conservative safety measure: the burden * of checking writability of the mbuf data area rests solely with the caller. + * + * NB: In previous versions, M_TRAILINGSPACE() would only check M_WRITABLE() + * for mbufs with external storage. We now allow mbuf-embedded data to be + * read-only as well. */ #define M_TRAILINGSPACE(m) \ - ((m)->m_flags & M_EXT ? \ - (M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size \ - - ((m)->m_data + (m)->m_len) : 0) : \ - &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len)) + (M_WRITABLE(m) ? \ + ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0) /* * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be diff --git a/sys/sys/mman.h b/sys/sys/mman.h index a13e3d1612d5..f0e01b696bb3 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -234,7 +234,6 @@ int shm_mmap(struct shmfd *shmfd, vm_size_t objsize, vm_ooffset_t foff, vm_object_t *obj); int shm_map(struct file *fp, size_t size, off_t offset, void **memp); int shm_unmap(struct file *fp, void *mem, size_t size); -void shm_path(struct shmfd *shmfd, char *path, size_t size); #else /* !_KERNEL */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 50be879486d4..18d92b270108 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100030 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100036 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, @@ -80,6 +80,7 @@ #define P_OSREL_SIGWAIT 700000 #define P_OSREL_SIGSEGV 700004 #define P_OSREL_MAP_ANON 800104 +#define P_OSREL_MAP_FSTRICT 1100036 #define P_OSREL_MAJOR(x) ((x) / 100000) #endif diff --git a/sys/sys/seq.h b/sys/sys/seq.h new file mode 100644 index 000000000000..ba6e80295a48 --- /dev/null +++ b/sys/sys/seq.h @@ -0,0 +1,139 @@ +/*- + * Copyright (c) 2014 Mateusz Guzik + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 _SYS_SEQ_H_ +#define _SYS_SEQ_H_ + +#ifdef _KERNEL + +/* + * Typical usage: + * + * writers: + * lock_exclusive(&obj->lock); + * seq_write_begin(&obj->seq); + * ..... + * seq_write_end(&obj->seq); + * unlock_exclusive(&obj->unlock); + * + * readers: + * obj_t lobj; + * seq_t seq; + * + * for (;;) { + * seq = seq_read(&gobj->seq); + * lobj = gobj; + * if (seq_consistent(&gobj->seq, seq)) + * break; + * cpu_spinwait(); + * } + * foo(lobj); + */ + +typedef uint32_t seq_t; + +/* A hack to get MPASS macro */ +#include +#include + +#include + +/* + * This is a temporary hack until memory barriers are cleaned up. + * + * atomic_load_acq_int at least on amd64 provides a full memory barrier, + * in a way which affects perforance. + * + * Hack below covers all architectures and avoids most of the penalty at least + * on amd64. + */ +static __inline int +atomic_load_acq_rmb_int(volatile u_int *p) +{ + volatile u_int v; + + v = *p; + atomic_load_acq_int(&v); + return (v); +} + +static __inline bool +seq_in_modify(seq_t seqp) +{ + + return (seqp & 1); +} + +static __inline void +seq_write_begin(seq_t *seqp) +{ + + MPASS(!seq_in_modify(*seqp)); + atomic_add_acq_int(seqp, 1); +} + +static __inline void +seq_write_end(seq_t *seqp) +{ + + atomic_add_rel_int(seqp, 1); + MPASS(!seq_in_modify(*seqp)); +} + +static __inline seq_t +seq_read(seq_t *seqp) +{ + seq_t ret; + + for (;;) { + ret = atomic_load_acq_rmb_int(seqp); + if (seq_in_modify(ret)) { + cpu_spinwait(); + continue; + } + break; + } + + return (ret); +} + +static __inline seq_t +seq_consistent(seq_t *seqp, seq_t oldseq) +{ + + return (atomic_load_acq_rmb_int(seqp) == oldseq); +} + +static __inline seq_t +seq_consistent_nomb(seq_t *seqp, seq_t oldseq) +{ + + return (*seqp == oldseq); +} + +#endif /* _KERNEL */ +#endif /* _SYS_SEQ_H_ */ diff --git a/sys/sys/sleepqueue.h b/sys/sys/sleepqueue.h index dcb1b48141c4..cdb7a3985f2a 100644 --- a/sys/sys/sleepqueue.h +++ b/sys/sys/sleepqueue.h @@ -46,13 +46,6 @@ * call sleepq_set_timeout() after sleepq_add() to setup a timeout. It * should then use one of the sleepq_timedwait() functions to block. * - * If the thread wants the sleep to be interruptible by signals, it can - * call sleepq_catch_signals() after sleepq_add(). It should then use - * one of the sleepq_wait_sig() functions to block. After the thread has - * been resumed, it should call sleepq_calc_signal_retval() to determine - * if it should return EINTR or ERESTART passing in the value returned from - * the earlier call to sleepq_catch_signals(). - * * A thread is normally resumed from a sleep queue by either the * sleepq_signal() or sleepq_broadcast() functions. Sleepq_signal() wakes * the thread with the highest priority that is sleeping on the specified diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index 877b5307ee2e..ef80e9c14571 100644 --- a/sys/sys/sockbuf.h +++ b/sys/sys/sockbuf.h @@ -158,6 +158,8 @@ int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so, struct thread *td); struct mbuf * sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff); +struct mbuf * + sbsndmbuf(struct sockbuf *sb, u_int off, u_int *moff); void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb); int sbwait(struct sockbuf *sb); int sblock(struct sockbuf *sb, int flags); diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index bc447ab3bda5..05e9be832f24 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -97,6 +97,7 @@ int kern_fchmodat(struct thread *td, int fd, char *path, int kern_fchownat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int uid, int gid, int flag); int kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg); +int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg); int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf); int kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf); int kern_fstat(struct thread *td, int fd, struct stat *sbp); diff --git a/sys/sys/timex.h b/sys/sys/timex.h index d9d13a812756..4b75fcc77e62 100644 --- a/sys/sys/timex.h +++ b/sys/sys/timex.h @@ -2,6 +2,7 @@ *********************************************************************** * * * Copyright (c) David L. Mills 1993-2001 * + * Copyright (c) Poul-Henning Kamp 2000-2001 * * * * Permission to use, copy, modify, and distribute this software and * * its documentation for any purpose and without fee is hereby * @@ -15,94 +16,30 @@ * purpose. It is provided "as is" without express or implied * * warranty. * * * - **********************************************************************/ - -/* - * Modification history timex.h - * - * 16 Aug 00 David L. Mills - * API Version 4. Added MOD_TAI and tai member of ntptimeval - * structure. - * - * 17 Nov 98 David L. Mills - * Revised for nanosecond kernel and user interface. - * - * 26 Sep 94 David L. Mills - * Added defines for hybrid phase/frequency-lock loop. - * - * 19 Mar 94 David L. Mills - * Moved defines from kernel routines to header file and added new - * defines for PPS phase-lock loop. - * - * 20 Feb 94 David L. Mills - * Revised status codes and structures for external clock and PPS - * signal discipline. - * - * 28 Nov 93 David L. Mills - * Adjusted parameters to improve stability and increase poll - * interval. - * - * 17 Sep 93 David L. Mills - * Created file + *********************************************************************** * * $FreeBSD$ - */ -/* + * * This header file defines the Network Time Protocol (NTP) interfaces - * for user and daemon application programs. These are implemented using - * defined syscalls and data structures and require specific kernel - * support. + * for user and daemon application programs. * - * The original precision time kernels developed from 1993 have an - * ultimate resolution of one microsecond; however, the most recent - * kernels have an ultimate resolution of one nanosecond. In these - * kernels, a ntp_adjtime() syscalls can be used to determine which - * resolution is in use and to select either one at any time. The - * resolution selected affects the scaling of certain fields in the - * ntp_gettime() and ntp_adjtime() syscalls, as described below. + * This file was originally created 17 Sep 93 by David L. Mills, Professor + * of University of Delaware, building on work which had already been ongoing + * for a decade and a half at that point in time. * - * NAME - * ntp_gettime - NTP user application interface + * In 2000 the APIs got a upgrade from microseconds to nanoseconds, + * a joint work between Poul-Henning Kamp and David L. Mills. * - * SYNOPSIS - * #include - * - * int ntp_gettime(struct ntptimeval *ntv); - * - * DESCRIPTION - * The time returned by ntp_gettime() is in a timespec structure, - * but may be in either microsecond (seconds and microseconds) or - * nanosecond (seconds and nanoseconds) format. The particular - * format in use is determined by the STA_NANO bit of the status - * word returned by the ntp_adjtime() syscall. - * - * NAME - * ntp_adjtime - NTP daemon application interface - * - * SYNOPSIS - * #include - * #include - * - * int syscall(SYS_ntp_adjtime, tptr); - * int SYS_ntp_adjtime; - * struct timex *tptr; - * - * DESCRIPTION - * Certain fields of the timex structure are interpreted in either - * microseconds or nanoseconds according to the state of the - * STA_NANO bit in the status word. See the description below for - * further information. */ + #ifndef _SYS_TIMEX_H_ #define _SYS_TIMEX_H_ 1 -#define NTP_API 4 /* NTP API version */ + +#define NTP_API 4 /* NTP API version */ #ifdef __FreeBSD__ #include #endif /* __FreeBSD__ */ -#ifndef MSDOS /* Microsoft specific */ -#include -#endif /* MSDOS */ /* * The following defines establish the performance envelope of the @@ -113,112 +50,107 @@ * mode. Between these two limits the operating mode is selected by the * STA_FLL bit in the status word. */ -#define MAXPHASE 500000000L /* max phase error (ns) */ -#define MAXFREQ 500000L /* max freq error (ns/s) */ -#define MINSEC 256 /* min FLL update interval (s) */ -#define MAXSEC 2048 /* max PLL update interval (s) */ -#define NANOSECOND 1000000000L /* nanoseconds in one second */ -#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */ -#define MAXTC 10 /* max time constant */ + +#define MAXPHASE 500000000L /* max phase error (ns) */ +#define MAXFREQ 500000L /* max freq error (ns/s) */ +#define MINSEC 256 /* min FLL update interval (s) */ +#define MAXSEC 2048 /* max PLL update interval (s) */ +#define NANOSECOND 1000000000L /* nanoseconds in one second */ +#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */ +#define MAXTC 10 /* max time constant */ /* - * The following defines and structures define the user interface for - * the ntp_gettime() and ntp_adjtime() syscalls. - * * Control mode codes (timex.modes) */ -#define MOD_OFFSET 0x0001 /* set time offset */ -#define MOD_FREQUENCY 0x0002 /* set frequency offset */ -#define MOD_MAXERROR 0x0004 /* set maximum time error */ -#define MOD_ESTERROR 0x0008 /* set estimated time error */ -#define MOD_STATUS 0x0010 /* set clock status bits */ -#define MOD_TIMECONST 0x0020 /* set PLL time constant */ -#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */ -#define MOD_TAI 0x0080 /* set TAI offset */ -#define MOD_MICRO 0x1000 /* select microsecond resolution */ -#define MOD_NANO 0x2000 /* select nanosecond resolution */ -#define MOD_CLKB 0x4000 /* select clock B */ -#define MOD_CLKA 0x8000 /* select clock A */ +#define MOD_OFFSET 0x0001 /* set time offset */ +#define MOD_FREQUENCY 0x0002 /* set frequency offset */ +#define MOD_MAXERROR 0x0004 /* set maximum time error */ +#define MOD_ESTERROR 0x0008 /* set estimated time error */ +#define MOD_STATUS 0x0010 /* set clock status bits */ +#define MOD_TIMECONST 0x0020 /* set PLL time constant */ +#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */ +#define MOD_TAI 0x0080 /* set TAI offset */ +#define MOD_MICRO 0x1000 /* select microsecond resolution */ +#define MOD_NANO 0x2000 /* select nanosecond resolution */ +#define MOD_CLKB 0x4000 /* select clock B */ +#define MOD_CLKA 0x8000 /* select clock A */ /* * Status codes (timex.status) */ -#define STA_PLL 0x0001 /* enable PLL updates (rw) */ -#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ -#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ -#define STA_FLL 0x0008 /* enable FLL mode (rw) */ -#define STA_INS 0x0010 /* insert leap (rw) */ -#define STA_DEL 0x0020 /* delete leap (rw) */ -#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ -#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ -#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ -#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ -#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ -#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ -#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ -#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ -#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ -#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ +#define STA_FLL 0x0008 /* enable FLL mode (rw) */ +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ +#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ +#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ +#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ +#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) /* - * Clock states (time_state) + * Clock states (ntptimeval.time_state) */ -#define TIME_OK 0 /* no leap second warning */ -#define TIME_INS 1 /* insert leap second warning */ -#define TIME_DEL 2 /* delete leap second warning */ -#define TIME_OOP 3 /* leap second in progress */ -#define TIME_WAIT 4 /* leap second has occured */ -#define TIME_ERROR 5 /* error (see status word) */ +#define TIME_OK 0 /* no leap second warning */ +#define TIME_INS 1 /* insert leap second warning */ +#define TIME_DEL 2 /* delete leap second warning */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occured */ +#define TIME_ERROR 5 /* error (see status word) */ /* - * NTP user interface (ntp_gettime()) - used to read kernel clock values - * - * Note: The time member is in microseconds if STA_NANO is zero and - * nanoseconds if not. + * NTP user interface -- ntp_gettime(2) - used to read kernel clock values */ struct ntptimeval { - struct timespec time; /* current time (ns) (ro) */ - long maxerror; /* maximum error (us) (ro) */ - long esterror; /* estimated error (us) (ro) */ - long tai; /* TAI offset */ - int time_state; /* time status */ + struct timespec time; /* current time (ns) (ro) */ + long maxerror; /* maximum error (us) (ro) */ + long esterror; /* estimated error (us) (ro) */ + long tai; /* TAI offset */ + int time_state; /* time status */ }; /* - * NTP daemon interface (ntp_adjtime()) - used to discipline CPU clock - * oscillator and determine status. + * NTP daemon interface -- ntp_adjtime(2) -- used to discipline CPU clock + * oscillator and control/determine status. * * Note: The offset, precision and jitter members are in microseconds if * STA_NANO is zero and nanoseconds if not. */ struct timex { - unsigned int modes; /* clock mode bits (wo) */ - long offset; /* time offset (ns/us) (rw) */ - long freq; /* frequency offset (scaled PPM) (rw) */ - long maxerror; /* maximum error (us) (rw) */ - long esterror; /* estimated error (us) (rw) */ - int status; /* clock status bits (rw) */ - long constant; /* poll interval (log2 s) (rw) */ - long precision; /* clock precision (ns/us) (ro) */ - long tolerance; /* clock frequency tolerance (scaled - * PPM) (ro) */ + unsigned int modes; /* clock mode bits (wo) */ + long offset; /* time offset (ns/us) (rw) */ + long freq; /* frequency offset (scaled PPM) (rw) */ + long maxerror; /* maximum error (us) (rw) */ + long esterror; /* estimated error (us) (rw) */ + int status; /* clock status bits (rw) */ + long constant; /* poll interval (log2 s) (rw) */ + long precision; /* clock precision (ns/us) (ro) */ + long tolerance; /* clock frequency tolerance (scaled + * PPM) (ro) */ /* * The following read-only structure members are implemented * only if the PPS signal discipline is configured in the * kernel. They are included in all configurations to insure * portability. */ - long ppsfreq; /* PPS frequency (scaled PPM) (ro) */ - long jitter; /* PPS jitter (ns/us) (ro) */ - int shift; /* interval duration (s) (shift) (ro) */ - long stabil; /* PPS stability (scaled PPM) (ro) */ - long jitcnt; /* jitter limit exceeded (ro) */ - long calcnt; /* calibration intervals (ro) */ - long errcnt; /* calibration errors (ro) */ - long stbcnt; /* stability limit exceeded (ro) */ + long ppsfreq; /* PPS frequency (scaled PPM) (ro) */ + long jitter; /* PPS jitter (ns/us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long stabil; /* PPS stability (scaled PPM) (ro) */ + long jitcnt; /* jitter limit exceeded (ro) */ + long calcnt; /* calibration intervals (ro) */ + long errcnt; /* calibration errors (ro) */ + long stbcnt; /* stability limit exceeded (ro) */ }; #ifdef __FreeBSD__ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index acddfc089da8..6b0729510bc1 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -503,7 +503,9 @@ extern struct vnodeop_desc *vnodeop_descs[]; * reliable since if the thread sleeps between changing the lock * state and checking it with the assert, some other thread could * change the state. They are good enough for debugging a single - * filesystem using a single-threaded test. + * filesystem using a single-threaded test. Note that the unreliability is + * limited to false negatives; efforts were made to ensure that false + * positives cannot occur. */ void assert_vi_locked(struct vnode *vp, const char *str); void assert_vi_unlocked(struct vnode *vp, const char *str); diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 423d811689f6..0dd4d1691c0d 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -104,7 +104,6 @@ extern int ffs_rawread(struct vnode *vp, struct uio *uio, int *workdone); #endif static vop_fsync_t ffs_fsync; static vop_lock1_t ffs_lock; -static vop_getpages_t ffs_getpages; static vop_read_t ffs_read; static vop_write_t ffs_write; static int ffs_extread(struct vnode *vp, struct uio *uio, int ioflag); @@ -124,7 +123,7 @@ static vop_vptofh_t ffs_vptofh; struct vop_vector ffs_vnodeops1 = { .vop_default = &ufs_vnodeops, .vop_fsync = ffs_fsync, - .vop_getpages = ffs_getpages, + .vop_getpages = vnode_pager_local_getpages, .vop_lock1 = ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, @@ -143,7 +142,7 @@ struct vop_vector ffs_fifoops1 = { struct vop_vector ffs_vnodeops2 = { .vop_default = &ufs_vnodeops, .vop_fsync = ffs_fsync, - .vop_getpages = ffs_getpages, + .vop_getpages = vnode_pager_local_getpages, .vop_lock1 = ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, @@ -846,48 +845,6 @@ ffs_write(ap) return (error); } -/* - * get page routine - */ -static int -ffs_getpages(ap) - struct vop_getpages_args *ap; -{ - int i; - vm_page_t mreq; - int pcount; - - pcount = round_page(ap->a_count) / PAGE_SIZE; - mreq = ap->a_m[ap->a_reqpage]; - - /* - * if ANY DEV_BSIZE blocks are valid on a large filesystem block, - * then the entire page is valid. Since the page may be mapped, - * user programs might reference data beyond the actual end of file - * occuring within the page. We have to zero that data. - */ - VM_OBJECT_WLOCK(mreq->object); - if (mreq->valid) { - if (mreq->valid != VM_PAGE_BITS_ALL) - vm_page_zero_invalid(mreq, TRUE); - for (i = 0; i < pcount; i++) { - if (i != ap->a_reqpage) { - vm_page_lock(ap->a_m[i]); - vm_page_free(ap->a_m[i]); - vm_page_unlock(ap->a_m[i]); - } - } - VM_OBJECT_WUNLOCK(mreq->object); - return VM_PAGER_OK; - } - VM_OBJECT_WUNLOCK(mreq->object); - - return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, - ap->a_count, - ap->a_reqpage); -} - - /* * Extended attribute area reading. */ diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 68ae0d2f4829..b8d67bd30a3e 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -133,6 +133,8 @@ static void _vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t min, static void vm_map_entry_deallocate(vm_map_entry_t entry, boolean_t system_map); static void vm_map_entry_dispose(vm_map_t map, vm_map_entry_t entry); static void vm_map_entry_unwire(vm_map_t map, vm_map_entry_t entry); +static void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, + vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags); #ifdef INVARIANTS static void vm_map_zdtor(void *mem, int size, void *arg); static void vmspace_zdtor(void *mem, int size, void *arg); @@ -1809,7 +1811,7 @@ vm_map_submap( * being created speculatively, cached pages are not reactivated and * mapped. */ -void +static void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags) { @@ -2195,7 +2197,14 @@ vm_map_madvise( vm_object_madvise(current->object.vm_object, pstart, pend, behav); - if (behav == MADV_WILLNEED) { + + /* + * Pre-populate paging structures in the + * WILLNEED case. For wired entries, the + * paging structures are already populated. + */ + if (behav == MADV_WILLNEED && + current->wired_count == 0) { vm_map_pmap_enter(map, useStart, current->protection, diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 8cced057ea12..3bf7a6719ad8 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -302,9 +302,8 @@ long vmspace_resident_count(struct vmspace *vmspace); #endif /* _KERNEL */ -/* XXX: number of kernel maps and entries to statically allocate */ +/* XXX: number of kernel maps to statically allocate */ #define MAX_KMAP 10 -#define MAX_KMAPENT 128 /* * Copy-on-write flags for vm_map operations @@ -380,15 +379,13 @@ int vm_map_lookup_locked(vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, v vm_pindex_t *, vm_prot_t *, boolean_t *); void vm_map_lookup_done (vm_map_t, vm_map_entry_t); boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *); -void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, - vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags); int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t); int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t); +void vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry); void vm_map_startup (void); int vm_map_submap (vm_map_t, vm_offset_t, vm_offset_t, vm_map_t); int vm_map_sync(vm_map_t, vm_offset_t, vm_offset_t, boolean_t, boolean_t); int vm_map_madvise (vm_map_t, vm_offset_t, vm_offset_t, int); -void vm_map_simplify_entry (vm_map_t, vm_map_entry_t); int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); int vm_map_growstack (struct proc *p, vm_offset_t addr); int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 1ae7189b97ca..9506efedf385 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -203,17 +203,17 @@ sys_mmap(td, uap) struct vnode *vp; vm_offset_t addr; vm_size_t size, pageoff; - vm_prot_t cap_maxprot, prot, maxprot; + vm_prot_t cap_maxprot, maxprot; void *handle; objtype_t handle_type; - int align, error, flags; + int align, error, flags, prot; off_t pos; struct vmspace *vms = td->td_proc->p_vmspace; cap_rights_t rights; addr = (vm_offset_t) uap->addr; size = uap->len; - prot = uap->prot & VM_PROT_ALL; + prot = uap->prot; flags = uap->flags; pos = uap->pos; @@ -244,8 +244,21 @@ sys_mmap(td, uap) flags |= MAP_ANON; pos = 0; } + if ((flags & ~(MAP_SHARED | MAP_PRIVATE | MAP_FIXED | MAP_RENAME | + MAP_NORESERVE | MAP_HASSEMAPHORE | MAP_STACK | MAP_NOSYNC | + MAP_ANON | MAP_EXCL | MAP_NOCORE | MAP_PREFAULT_READ | +#ifdef MAP_32BIT + MAP_32BIT | +#endif + MAP_ALIGNMENT_MASK)) != 0) + return (EINVAL); if ((flags & (MAP_EXCL | MAP_FIXED)) == MAP_EXCL) return (EINVAL); + if ((flags & (MAP_SHARED | MAP_PRIVATE)) == (MAP_SHARED | MAP_PRIVATE)) + return (EINVAL); + if (prot != PROT_NONE && + (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0) + return (EINVAL); /* * Align the file position to a page boundary, @@ -342,6 +355,11 @@ sys_mmap(td, uap) error = fget_mmap(td, uap->fd, &rights, &cap_maxprot, &fp); if (error != 0) goto done; + if ((flags & (MAP_SHARED | MAP_PRIVATE)) == 0 && + td->td_proc->p_osrel >= P_OSREL_MAP_FSTRICT) { + error = EINVAL; + goto done; + } if (fp->f_type == DTYPE_SHM) { handle = fp->f_data; handle_type = OBJT_SWAP; @@ -415,6 +433,8 @@ sys_mmap(td, uap) map: td->td_fpop = fp; maxprot &= cap_maxprot; + + /* This relies on VM_PROT_* matching PROT_*. */ error = vm_mmap(&vms->vm_map, &addr, size, prot, maxprot, flags, handle_type, handle, pos); td->td_fpop = NULL; diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 48ba743bf2ec..ab3c7d3af30f 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -199,7 +199,7 @@ struct vm_object { #define OBJPC_SYNC 0x1 /* sync I/O */ #define OBJPC_INVAL 0x2 /* invalidate */ -#define OBJPC_NOSYNC 0x4 /* skip if PG_NOSYNC */ +#define OBJPC_NOSYNC 0x4 /* skip if VPO_NOSYNC */ /* * The following options are supported by vm_object_page_remove(). diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 9835d8d60c58..ca9d7f9a3b5b 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include "opt_vm.h" +#include "opt_kdtrace.h" #include #include #include @@ -89,6 +90,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -133,6 +135,10 @@ static struct kproc_desc page_kp = { SYSINIT(pagedaemon, SI_SUB_KTHREAD_PAGE, SI_ORDER_SECOND, kproc_start, &page_kp); +SDT_PROVIDER_DEFINE(vm); +SDT_PROBE_DEFINE(vm, , , vm__lowmem_cache); +SDT_PROBE_DEFINE(vm, , , vm__lowmem_scan); + #if !defined(NO_SWAPPING) /* the kernel process "vm_daemon"*/ static void vm_daemon(void); @@ -667,6 +673,7 @@ vm_pageout_grow_cache(int tries, vm_paddr_t low, vm_paddr_t high) * may acquire locks and/or sleep, so they can only be invoked * when "tries" is greater than zero. */ + SDT_PROBE0(vm, , , vm__lowmem_cache); EVENTHANDLER_INVOKE(vm_lowmem, 0); /* @@ -916,10 +923,11 @@ vm_pageout_scan(struct vm_domain *vmd, int pass) * some. We rate limit to avoid thrashing. */ if (vmd == &vm_dom[0] && pass > 0 && - lowmem_ticks + (lowmem_period * hz) < ticks) { + (ticks - lowmem_ticks) / hz >= lowmem_period) { /* * Decrease registered cache sizes. */ + SDT_PROBE0(vm, , , vm__lowmem_scan); EVENTHANDLER_INVOKE(vm_lowmem, 0); /* * We do this explicitly after the caches have been diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index c7d038b090ec..65193c3d31a7 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -281,6 +281,33 @@ vm_pager_object_lookup(struct pagerlst *pg_list, void *handle) return (object); } +/* + * Free the non-requested pages from the given array. + */ +void +vm_pager_free_nonreq(vm_object_t object, vm_page_t ma[], int reqpage, + int npages) +{ + int i; + boolean_t object_locked; + + VM_OBJECT_ASSERT_UNLOCKED(object); + object_locked = FALSE; + for (i = 0; i < npages; ++i) { + if (i != reqpage) { + if (!object_locked) { + VM_OBJECT_WLOCK(object); + object_locked = TRUE; + } + vm_page_lock(ma[i]); + vm_page_free(ma[i]); + vm_page_unlock(ma[i]); + } + } + if (object_locked) + VM_OBJECT_WUNLOCK(object); +} + /* * initialize a physical buffer */ diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 62265a23d277..e3d292d745af 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -106,6 +106,8 @@ static __inline int vm_pager_get_pages(vm_object_t, vm_page_t *, int, int); static __inline boolean_t vm_pager_has_page(vm_object_t, vm_pindex_t, int *, int *); void vm_pager_init(void); vm_object_t vm_pager_object_lookup(struct pagerlst *, void *); +void vm_pager_free_nonreq(vm_object_t object, vm_page_t ma[], int reqpage, + int npages); /* * vm_page_get_pages: diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 2a38d0175207..4d35a4f53aa9 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -364,7 +364,7 @@ vm_reserv_populate(vm_reserv_t rv, int index) /* * Allocates a contiguous set of physical pages of the given size "npages" - * from an existing or newly-created reservation. All of the physical pages + * from existing or newly created reservations. All of the physical pages * must be at or above the given physical address "low" and below the given * physical address "high". The given value "alignment" determines the * alignment of the first physical page in the set. If the given value @@ -436,8 +436,8 @@ vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, /* * Could at least one reservation fit between the first index to the - * left that can be used and the first index to the right that cannot - * be used? + * left that can be used ("leftcap") and the first index to the right + * that cannot be used ("rightcap")? */ first = pindex - VM_RESERV_INDEX(object, pindex); if (mpred != NULL) { @@ -459,6 +459,13 @@ vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, if (first + maxpages > rightcap) { if (maxpages == VM_LEVEL_0_NPAGES) return (NULL); + + /* + * At least one reservation will fit between "leftcap" + * and "rightcap". However, a reservation for the + * last of the requested pages will not fit. Reduce + * the size of the upcoming allocation accordingly. + */ allocpages = minpages; } } @@ -482,16 +489,23 @@ vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, } /* - * Allocate and populate the new reservations. The alignment and - * boundary specified for this allocation may be different from the - * alignment and boundary specified for the requested pages. For - * instance, the specified index may not be the first page within the - * first new reservation. + * Allocate the physical pages. The alignment and boundary specified + * for this allocation may be different from the alignment and + * boundary specified for the requested pages. For instance, the + * specified index may not be the first page within the first new + * reservation. */ m = vm_phys_alloc_contig(allocpages, low, high, ulmax(alignment, VM_LEVEL_0_SIZE), boundary > VM_LEVEL_0_SIZE ? boundary : 0); if (m == NULL) return (NULL); + + /* + * The allocated physical pages always begin at a reservation + * boundary, but they do not always end at a reservation boundary. + * Initialize every reservation that is completely covered by the + * allocated physical pages. + */ m_ret = NULL; index = VM_RESERV_INDEX(object, pindex); do { @@ -525,7 +539,7 @@ vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, m += VM_LEVEL_0_NPAGES; first += VM_LEVEL_0_NPAGES; allocpages -= VM_LEVEL_0_NPAGES; - } while (allocpages > 0); + } while (allocpages >= VM_LEVEL_0_NPAGES); return (m_ret); /* diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 8058bdb4279c..050f1b0a8196 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -83,7 +83,7 @@ static int vnode_pager_input_smlfs(vm_object_t object, vm_page_t m); static int vnode_pager_input_old(vm_object_t object, vm_page_t m); static void vnode_pager_dealloc(vm_object_t); static int vnode_pager_getpages(vm_object_t, vm_page_t *, int, int); -static void vnode_pager_putpages(vm_object_t, vm_page_t *, int, boolean_t, int *); +static void vnode_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); static boolean_t vnode_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); static vm_object_t vnode_pager_alloc(void *, vm_ooffset_t, vm_prot_t, vm_ooffset_t, struct ucred *cred); @@ -657,13 +657,46 @@ vnode_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) vp = object->handle; VM_OBJECT_WUNLOCK(object); - rtval = VOP_GETPAGES(vp, m, bytes, reqpage, 0); + rtval = VOP_GETPAGES(vp, m, bytes, reqpage); KASSERT(rtval != EOPNOTSUPP, ("vnode_pager: FS getpages not implemented\n")); VM_OBJECT_WLOCK(object); return rtval; } +/* + * The implementation of VOP_GETPAGES() for local filesystems, where + * partially valid pages can only occur at the end of file. + */ +int +vnode_pager_local_getpages(struct vop_getpages_args *ap) +{ + vm_page_t mreq; + + mreq = ap->a_m[ap->a_reqpage]; + + /* + * Since the caller has busied the requested page, that page's valid + * field will not be changed by other threads. + */ + vm_page_assert_xbusied(mreq); + + /* + * The requested page has valid blocks. Invalid part can only + * exist at the end of file, and the page is made fully valid + * by zeroing in vm_pager_getpages(). Free non-requested + * pages, since no i/o is done to read its content. + */ + if (mreq->valid != 0) { + vm_pager_free_nonreq(mreq->object, ap->a_m, ap->a_reqpage, + round_page(ap->a_count) / PAGE_SIZE); + return (VM_PAGER_OK); + } + + return (vnode_pager_generic_getpages(ap->a_vp, ap->a_m, + ap->a_count, ap->a_reqpage)); +} + /* * This is now called from local media FS's to operate against their * own vnodes if they fail to implement VOP_GETPAGES. @@ -722,14 +755,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, VM_OBJECT_WUNLOCK(object); return (error); } else if (error != 0) { - VM_OBJECT_WLOCK(object); - for (i = 0; i < count; i++) - if (i != reqpage) { - vm_page_lock(m[i]); - vm_page_free(m[i]); - vm_page_unlock(m[i]); - } - VM_OBJECT_WUNLOCK(object); + vm_pager_free_nonreq(object, m, reqpage, count); return (VM_PAGER_ERROR); /* @@ -739,38 +765,31 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, */ } else if ((PAGE_SIZE / bsize) > 1 && (vp->v_mount->mnt_stat.f_type != nfs_mount_type)) { - VM_OBJECT_WLOCK(object); - for (i = 0; i < count; i++) - if (i != reqpage) { - vm_page_lock(m[i]); - vm_page_free(m[i]); - vm_page_unlock(m[i]); - } - VM_OBJECT_WUNLOCK(object); + vm_pager_free_nonreq(object, m, reqpage, count); PCPU_INC(cnt.v_vnodein); PCPU_INC(cnt.v_vnodepgsin); return vnode_pager_input_smlfs(object, m[reqpage]); } + /* + * Since the caller has busied the requested page, that page's valid + * field will not be changed by other threads. + */ + vm_page_assert_xbusied(m[reqpage]); + /* * If we have a completely valid page available to us, we can * clean up and return. Otherwise we have to re-read the * media. */ - VM_OBJECT_WLOCK(object); if (m[reqpage]->valid == VM_PAGE_BITS_ALL) { - for (i = 0; i < count; i++) - if (i != reqpage) { - vm_page_lock(m[i]); - vm_page_free(m[i]); - vm_page_unlock(m[i]); - } - VM_OBJECT_WUNLOCK(object); - return VM_PAGER_OK; + vm_pager_free_nonreq(object, m, reqpage, count); + return (VM_PAGER_OK); } else if (reqblock == -1) { pmap_zero_page(m[reqpage]); KASSERT(m[reqpage]->dirty == 0, ("vnode_pager_generic_getpages: page %p is dirty", m)); + VM_OBJECT_WLOCK(object); m[reqpage]->valid = VM_PAGE_BITS_ALL; for (i = 0; i < count; i++) if (i != reqpage) { @@ -780,9 +799,11 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, } VM_OBJECT_WUNLOCK(object); return (VM_PAGER_OK); + } else if (m[reqpage]->valid != 0) { + VM_OBJECT_WLOCK(object); + m[reqpage]->valid = 0; + VM_OBJECT_WUNLOCK(object); } - m[reqpage]->valid = 0; - VM_OBJECT_WUNLOCK(object); /* * here on direct device I/O @@ -1008,7 +1029,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, */ static void vnode_pager_putpages(vm_object_t object, vm_page_t *m, int count, - boolean_t sync, int *rtvals) + int flags, int *rtvals) { int rtval; struct vnode *vp; @@ -1026,16 +1047,16 @@ vnode_pager_putpages(vm_object_t object, vm_page_t *m, int count, * daemon up. This should be probably be addressed XXX. */ - if ((vm_cnt.v_free_count + vm_cnt.v_cache_count) < + if (vm_cnt.v_free_count + vm_cnt.v_cache_count < vm_cnt.v_pageout_free_min) - sync |= OBJPC_SYNC; + flags |= VM_PAGER_PUT_SYNC; /* * Call device-specific putpages function */ vp = object->handle; VM_OBJECT_WUNLOCK(object); - rtval = VOP_PUTPAGES(vp, m, bytes, sync, rtvals, 0); + rtval = VOP_PUTPAGES(vp, m, bytes, flags, rtvals); KASSERT(rtval != EOPNOTSUPP, ("vnode_pager: stale FS putpages\n")); VM_OBJECT_WLOCK(object); diff --git a/sys/vm/vnode_pager.h b/sys/vm/vnode_pager.h index 02cf4c31453d..b6b85f45e308 100644 --- a/sys/vm/vnode_pager.h +++ b/sys/vm/vnode_pager.h @@ -45,6 +45,7 @@ int vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int vnode_pager_generic_putpages(struct vnode *vp, vm_page_t *m, int count, boolean_t sync, int *rtvals); +int vnode_pager_local_getpages(struct vop_getpages_args *ap); void vnode_pager_release_writecount(vm_object_t object, vm_offset_t start, vm_offset_t end); diff --git a/sys/x86/acpica/acpi_wakeup.c b/sys/x86/acpica/acpi_wakeup.c index fb4698396db8..3d5e1fe37a77 100644 --- a/sys/x86/acpica/acpi_wakeup.c +++ b/sys/x86/acpica/acpi_wakeup.c @@ -75,10 +75,10 @@ extern int acpi_resume_beep; extern int acpi_reset_video; #ifdef SMP -extern struct pcb **susppcbs; +extern struct susppcb **susppcbs; static cpuset_t suspcpus; #else -static struct pcb **susppcbs; +static struct susppcb **susppcbs; #endif static void *acpi_alloc_wakeup_handler(void); @@ -117,14 +117,15 @@ acpi_stop_beep(void *arg) static int acpi_wakeup_ap(struct acpi_softc *sc, int cpu) { + struct pcb *pcb; int vector = (WAKECODE_PADDR(sc) >> 12) & 0xff; int apic_id = cpu_apic_ids[cpu]; int ms; - WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[cpu]); - WAKECODE_FIXUP(wakeup_gdt, uint16_t, susppcbs[cpu]->pcb_gdt.rd_limit); - WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t, - susppcbs[cpu]->pcb_gdt.rd_base); + pcb = &susppcbs[cpu]->sp_pcb; + WAKECODE_FIXUP(wakeup_pcb, struct pcb *, pcb); + WAKECODE_FIXUP(wakeup_gdt, uint16_t, pcb->pcb_gdt.rd_limit); + WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t, pcb->pcb_gdt.rd_base); ipi_startup(apic_id, vector); @@ -188,6 +189,7 @@ int acpi_sleep_machdep(struct acpi_softc *sc, int state) { ACPI_STATUS status; + struct pcb *pcb; if (sc->acpi_wakeaddr == 0ul) return (-1); /* couldn't alloc wake memory */ @@ -204,11 +206,12 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) intr_suspend(); - if (savectx(susppcbs[0])) { + pcb = &susppcbs[0]->sp_pcb; + if (savectx(pcb)) { #ifdef __amd64__ - fpususpend(susppcbs[0]->pcb_fpususpend); + fpususpend(susppcbs[0]->sp_fpususpend); #elif defined(DEV_NPX) - npxsuspend(&susppcbs[0]->pcb_fpususpend); + npxsuspend(&susppcbs[0]->sp_fpususpend); #endif #ifdef SMP if (!CPU_EMPTY(&suspcpus) && suspend_cpus(suspcpus) == 0) { @@ -221,13 +224,11 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0)); #ifndef __amd64__ - WAKECODE_FIXUP(wakeup_cr4, register_t, susppcbs[0]->pcb_cr4); + WAKECODE_FIXUP(wakeup_cr4, register_t, pcb->pcb_cr4); #endif - WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[0]); - WAKECODE_FIXUP(wakeup_gdt, uint16_t, - susppcbs[0]->pcb_gdt.rd_limit); - WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t, - susppcbs[0]->pcb_gdt.rd_base); + WAKECODE_FIXUP(wakeup_pcb, struct pcb *, pcb); + WAKECODE_FIXUP(wakeup_gdt, uint16_t, pcb->pcb_gdt.rd_limit); + WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t, pcb->pcb_gdt.rd_base); /* Call ACPICA to enter the desired sleep state */ if (state == ACPI_STATE_S4 && sc->acpi_s4bios) @@ -244,8 +245,10 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) for (;;) ia32_pause(); } else { -#ifdef DEV_NPX - npxresume(&susppcbs[0]->pcb_fpususpend); +#ifdef __amd64__ + fpuresume(susppcbs[0]->sp_fpususpend); +#elif defined(DEV_NPX) + npxresume(&susppcbs[0]->sp_fpususpend); #endif } @@ -325,7 +328,7 @@ acpi_alloc_wakeup_handler(void) for (i = 0; i < mp_ncpus; i++) { susppcbs[i] = malloc(sizeof(**susppcbs), M_DEVBUF, M_WAITOK); #ifdef __amd64__ - susppcbs[i]->pcb_fpususpend = alloc_fpusave(M_WAITOK); + susppcbs[i]->sp_fpususpend = alloc_fpusave(M_WAITOK); #endif } diff --git a/sys/x86/include/fpu.h b/sys/x86/include/fpu.h index ddb17c2ab2ea..73af34c4fd20 100644 --- a/sys/x86/include/fpu.h +++ b/sys/x86/include/fpu.h @@ -150,9 +150,11 @@ struct savefpu { struct xstate_hdr { uint64_t xstate_bv; - uint8_t xstate_rsrv0[16]; + uint64_t xstate_xcomp_bv; + uint8_t xstate_rsrv0[8]; uint8_t xstate_rsrv[40]; }; +#define XSTATE_XCOMP_BV_COMPACT (1ULL << 63) struct savexmm_xstate { struct xstate_hdr sx_hd; diff --git a/sys/x86/include/init.h b/sys/x86/include/init.h index 47dc4f5839e8..7cc679827e23 100644 --- a/sys/x86/include/init.h +++ b/sys/x86/include/init.h @@ -41,6 +41,7 @@ struct init_ops { void (*parse_memmap)(caddr_t, vm_paddr_t *, int *); u_int (*mp_bootaddress)(u_int); int (*start_all_aps)(void); + void (*msi_init)(void); }; extern struct init_ops init_ops; diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h index bdc16e7fcb74..96bdf2b32fc8 100644 --- a/sys/x86/include/specialreg.h +++ b/sys/x86/include/specialreg.h @@ -296,6 +296,9 @@ * CPUID instruction 0xd Processor Extended State Enumeration Sub-leaf 1 */ #define CPUID_EXTSTATE_XSAVEOPT 0x00000001 +#define CPUID_EXTSTATE_XSAVEC 0x00000002 +#define CPUID_EXTSTATE_XINUSE 0x00000004 +#define CPUID_EXTSTATE_XSAVES 0x00000008 /* * AMD extended function 8000_0007h edx info @@ -434,6 +437,10 @@ #define MSR_MC4_STATUS 0x411 #define MSR_MC4_ADDR 0x412 #define MSR_MC4_MISC 0x413 +#define MSR_PKG_ENERGY_STATUS 0x611 +#define MSR_DRAM_ENERGY_STATUS 0x619 +#define MSR_PP0_ENERGY_STATUS 0x639 +#define MSR_PP1_ENERGY_STATUS 0x641 /* * VMX MSRs @@ -487,6 +494,8 @@ #define MSR_APIC_DCR_TIMER 0x83e #define MSR_APIC_SELF_IPI 0x83f +#define MSR_IA32_XSS 0xda0 + /* * Constants related to MSR's. */ diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index e33ab8a2fe71..8d4b5d7760c0 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -405,30 +405,11 @@ printcpuinfo(void) break; case 0x5a0: strcat(cpu_model, "Geode LX"); - /* - * Make sure the TSC runs through suspension, - * otherwise we can't use it as timecounter - */ - wrmsr(0x1900, rdmsr(0x1900) | 0x20ULL); break; default: strcat(cpu_model, "Unknown"); break; } -#if defined(I586_CPU) && defined(CPU_WT_ALLOC) - if ((cpu_id & 0xf00) == 0x500) { - if (((cpu_id & 0x0f0) > 0) - && ((cpu_id & 0x0f0) < 0x60) - && ((cpu_id & 0x00f) > 3)) - enable_K5_wt_alloc(); - else if (((cpu_id & 0x0f0) > 0x80) - || (((cpu_id & 0x0f0) == 0x80) - && (cpu_id & 0x00f) > 0x07)) - enable_K6_2_wt_alloc(); - else if ((cpu_id & 0x0f0) > 0x50) - enable_K6_wt_alloc(); - } -#endif #else if ((cpu_id & 0xf00) == 0xf00) strcat(cpu_model, "AMD64 Processor"); @@ -932,6 +913,19 @@ printcpuinfo(void) ); } + if ((cpu_feature2 & CPUID2_XSAVE) != 0) { + cpuid_count(0xd, 0x1, regs); + if (regs[0] != 0) { + printf("\n XSAVE Features=0x%b", + regs[0], + "\020" + "\001XSAVEOPT" + "\002XSAVEC" + "\003XINUSE" + "\004XSAVES"); + } + } + if (via_feature_rng != 0 || via_feature_xcrypt != 0) print_via_padlock_info(); diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c index 448494da040a..7241b123e529 100644 --- a/sys/x86/x86/intr_machdep.c +++ b/sys/x86/x86/intr_machdep.c @@ -86,7 +86,7 @@ char intrnames[INTRCNT_COUNT * (MAXCOMLEN + 1)]; size_t sintrcnt = sizeof(intrcnt); size_t sintrnames = sizeof(intrnames); -static int intr_assign_cpu(void *arg, u_char cpu); +static int intr_assign_cpu(void *arg, int cpu); static void intr_disable_src(void *arg); static void intr_init(void *__dummy); static int intr_pic_registered(struct pic *pic); @@ -305,7 +305,7 @@ intr_suspend(void) } static int -intr_assign_cpu(void *arg, u_char cpu) +intr_assign_cpu(void *arg, int cpu) { #ifdef SMP struct intsrc *isrc; diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index a9b8c442724d..2aa18f57aeca 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -64,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef DDB #include @@ -1331,9 +1331,6 @@ static void apic_init(void *dummy __unused) { struct apic_enumerator *enumerator; -#ifndef __amd64__ - uint64_t apic_base; -#endif int retval, best; /* We only support built in local APICs. */ @@ -1375,12 +1372,7 @@ apic_init(void *dummy __unused) * CPUs during early startup. We need to turn the local APIC back * on on such CPUs now. */ - if (cpu == CPU_686 && cpu_vendor_id == CPU_VENDOR_INTEL && - (cpu_id & 0xff0) == 0x610) { - apic_base = rdmsr(MSR_APICBASE); - apic_base |= APICBASE_ENABLED; - wrmsr(MSR_APICBASE, apic_base); - } + ppro_reenable_apic(); #endif /* Probe the CPU's in the system. */ @@ -1447,7 +1439,7 @@ apic_setup_io(void *dummy __unused) lapic_dump("BSP"); /* Enable the MSI "pic". */ - msi_init(); + init_ops.msi_init(); } SYSINIT(apic_setup_io, SI_SUB_INTR, SI_ORDER_THIRD, apic_setup_io, NULL); diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index c98c8bc912cd..140d13ff4f83 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2004 Christian Limpach. * Copyright (c) 2004-2006,2008 Kip Macy + * Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2013 Roger Pau Monné * All rights reserved. * @@ -29,12 +30,15 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ddb.h" + #include #include #include #include #include #include +#include #include #include #include @@ -56,16 +60,22 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +#include #include #include +#ifdef DDB +#include +#endif + /* Native initial function */ extern u_int64_t hammer_time(u_int64_t, u_int64_t); /* Xen initial function */ @@ -93,6 +103,12 @@ extern int bootAP; extern char *bootSTK; #endif +/* + * Placed by the linker at the end of the bss section, which is the last + * section loaded by Xen before loading the symtab and strtab. + */ +extern uint32_t end; + /*-------------------------------- Global Data -------------------------------*/ /* Xen init_ops implementation. */ struct init_ops xen_init_ops = { @@ -103,6 +119,7 @@ struct init_ops xen_init_ops = { #ifdef SMP .start_all_aps = xen_pv_start_all_aps, #endif + .msi_init = xen_msi_init, }; static struct bios_smap xen_smap[MAX_E820_ENTRIES]; @@ -297,6 +314,68 @@ xen_pv_set_boothowto(void) } } +#ifdef DDB +/* + * The way Xen loads the symtab is different from the native boot loader, + * because it's tailored for NetBSD. So we have to adapt and use the same + * method as NetBSD. Portions of the code below have been picked from NetBSD: + * sys/kern/kern_ksyms.c CVS Revision 1.71. + */ +static void +xen_pv_parse_symtab(void) +{ + Elf_Ehdr *ehdr; + Elf_Shdr *shdr; + vm_offset_t sym_end; + uint32_t size; + int i, j; + + size = end; + sym_end = HYPERVISOR_start_info->mod_start != 0 ? + HYPERVISOR_start_info->mod_start : + HYPERVISOR_start_info->mfn_list; + + /* + * Make sure the size is right headed, sym_end is just a + * high boundary, but at least allows us to fail earlier. + */ + if ((vm_offset_t)&end + size > sym_end) { + xc_printf("Unable to load ELF symtab: size mismatch\n"); + return; + } + + ehdr = (Elf_Ehdr *)(&end + 1); + if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) || + ehdr->e_ident[EI_CLASS] != ELF_TARG_CLASS || + ehdr->e_version > 1) { + xc_printf("Unable to load ELF symtab: invalid symbol table\n"); + return; + } + + shdr = (Elf_Shdr *)((uint8_t *)ehdr + ehdr->e_shoff); + /* Find the symbol table and the corresponding string table. */ + for (i = 1; i < ehdr->e_shnum; i++) { + if (shdr[i].sh_type != SHT_SYMTAB) + continue; + if (shdr[i].sh_offset == 0) + continue; + ksymtab = (uintptr_t)((uint8_t *)ehdr + shdr[i].sh_offset); + ksymtab_size = shdr[i].sh_size; + j = shdr[i].sh_link; + if (shdr[j].sh_offset == 0) + continue; /* Can this happen? */ + kstrtab = (uintptr_t)((uint8_t *)ehdr + shdr[j].sh_offset); + break; + } + + if (ksymtab == 0 || kstrtab == 0) { + xc_printf( + "Unable to load ELF symtab: could not find symtab or strtab\n"); + return; + } +} +#endif + static caddr_t xen_pv_parse_preload_data(u_int64_t modulep) { @@ -304,6 +383,10 @@ xen_pv_parse_preload_data(u_int64_t modulep) xen_pv_set_env(); xen_pv_set_boothowto(); +#ifdef DDB + xen_pv_parse_symtab(); +#endif + return (NULL); } diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index a4318c140b1a..83f1db30fa0e 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -63,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifdef DDB #include @@ -179,8 +181,6 @@ struct pic xen_intr_pirq_pic = { .pic_disable_intr = xen_intr_pirq_disable_intr, .pic_vector = xen_intr_vector, .pic_source_pending = xen_intr_source_pending, - .pic_suspend = xen_intr_suspend, - .pic_resume = xen_intr_resume, .pic_config_intr = xen_intr_pirq_config_intr, .pic_assign_cpu = xen_intr_assign_cpu }; @@ -1374,6 +1374,64 @@ xen_register_pirq(int vector, enum intr_trigger trig, enum intr_polarity pol) return (0); } +int +xen_register_msi(device_t dev, int vector, int count) +{ + struct physdev_map_pirq msi_irq; + struct xenisrc *isrc; + int ret; + + memset(&msi_irq, 0, sizeof(msi_irq)); + msi_irq.domid = DOMID_SELF; + msi_irq.type = count == 1 ? + MAP_PIRQ_TYPE_MSI_SEG : MAP_PIRQ_TYPE_MULTI_MSI; + msi_irq.index = -1; + msi_irq.pirq = -1; + msi_irq.bus = pci_get_bus(dev) | (pci_get_domain(dev) << 16); + msi_irq.devfn = (pci_get_slot(dev) << 3) | pci_get_function(dev); + msi_irq.entry_nr = count; + + ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &msi_irq); + if (ret != 0) + return (ret); + if (count != msi_irq.entry_nr) { + panic("unable to setup all requested MSI vectors " + "(expected %d got %d)", count, msi_irq.entry_nr); + } + + mtx_lock(&xen_intr_isrc_lock); + for (int i = 0; i < count; i++) { + isrc = xen_intr_alloc_isrc(EVTCHN_TYPE_PIRQ, vector + i); + KASSERT(isrc != NULL, + ("xen: unable to allocate isrc for interrupt")); + isrc->xi_pirq = msi_irq.pirq + i; + } + mtx_unlock(&xen_intr_isrc_lock); + + return (0); +} + +int +xen_release_msi(int vector) +{ + struct physdev_unmap_pirq unmap; + struct xenisrc *isrc; + int ret; + + isrc = (struct xenisrc *)intr_lookup_source(vector); + if (isrc == NULL) + return (ENXIO); + + unmap.pirq = isrc->xi_pirq; + ret = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap); + if (ret != 0) + return (ret); + + xen_intr_release_isrc(isrc); + + return (0); +} + int xen_intr_describe(xen_intr_handle_t port_handle, const char *fmt, ...) { diff --git a/sys/x86/xen/xen_msi.c b/sys/x86/xen/xen_msi.c new file mode 100644 index 000000000000..0f678b164344 --- /dev/null +++ b/sys/x86/xen/xen_msi.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2014 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 + +static struct mtx msi_lock; +static int msi_last_irq; + +void +xen_msi_init(void) +{ + + mtx_init(&msi_lock, "msi", NULL, MTX_DEF); +} + +/* + * Try to allocate 'count' interrupt sources with contiguous IDT values. + */ +int +xen_msi_alloc(device_t dev, int count, int maxcount, int *irqs) +{ + int i, ret = 0; + + mtx_lock(&msi_lock); + + /* If we would exceed the max, give up. */ + if ((msi_last_irq + count) > NUM_MSI_INTS) { + mtx_unlock(&msi_lock); + return (ENXIO); + } + + /* Allocate MSI vectors */ + for (i = 0; i < count; i++) + irqs[i] = FIRST_MSI_INT + msi_last_irq++; + + mtx_unlock(&msi_lock); + + ret = xen_register_msi(dev, irqs[0], count); + if (ret != 0) + return (ret); + + for (i = 0; i < count; i++) + nexus_add_irq(irqs[i]); + + return (0); +} + +int +xen_msi_release(int *irqs, int count) +{ + int i, ret; + + for (i = 0; i < count; i++) { + ret = xen_release_msi(irqs[i]); + if (ret != 0) + return (ret); + } + + return (0); +} + +int +xen_msi_map(int irq, uint64_t *addr, uint32_t *data) +{ + + return (0); +} + +int +xen_msix_alloc(device_t dev, int *irq) +{ + + return (ENXIO); +} + +int +xen_msix_release(int irq) +{ + + return (ENOENT); +} diff --git a/sys/x86/xen/xen_nexus.c b/sys/x86/xen/xen_nexus.c index e4634f93ae36..1baeb7d9391f 100644 --- a/sys/x86/xen/xen_nexus.c +++ b/sys/x86/xen/xen_nexus.c @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include + +#include "pcib_if.h" /* * Xen nexus(4) driver. @@ -111,6 +114,41 @@ nexus_xen_config_intr(device_t dev, int irq, enum intr_trigger trig, return (intr_config_intr(irq, trig, pol)); } +static int +nexus_xen_alloc_msix(device_t pcib, device_t dev, int *irq) +{ + + return (xen_msix_alloc(dev, irq)); +} + +static int +nexus_xen_release_msix(device_t pcib, device_t dev, int irq) +{ + + return (xen_msix_release(irq)); +} + +static int +nexus_xen_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) +{ + + return (xen_msi_alloc(dev, count, maxcount, irqs)); +} + +static int +nexus_xen_release_msi(device_t pcib, device_t dev, int count, int *irqs) +{ + + return (xen_msi_release(irqs, count)); +} + +static int +nexus_xen_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data) +{ + + return (xen_msi_map(irq, addr, data)); +} + static device_method_t nexus_xen_methods[] = { /* Device interface */ DEVMETHOD(device_probe, nexus_xen_probe), @@ -119,6 +157,13 @@ static device_method_t nexus_xen_methods[] = { /* INTR */ DEVMETHOD(bus_config_intr, nexus_xen_config_intr), + /* MSI */ + DEVMETHOD(pcib_alloc_msi, nexus_xen_alloc_msi), + DEVMETHOD(pcib_release_msi, nexus_xen_release_msi), + DEVMETHOD(pcib_alloc_msix, nexus_xen_alloc_msix), + DEVMETHOD(pcib_release_msix, nexus_xen_release_msix), + DEVMETHOD(pcib_map_msi, nexus_xen_map_msi), + { 0, 0 } }; diff --git a/sys/x86/xen/xen_pci.c b/sys/x86/xen/xen_pci.c new file mode 100644 index 000000000000..d4a427d4cf96 --- /dev/null +++ b/sys/x86/xen/xen_pci.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014 Roger Pau Monné + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 "pcib_if.h" +#include "pci_if.h" + +static int xen_pci_probe(device_t dev); + +static void xen_pci_enable_msi_method(device_t dev, device_t child, + uint64_t address, uint16_t data); +static void xen_pci_disable_msi_method(device_t dev, device_t child); +static void xen_pci_child_added_method(device_t dev, device_t child); + +static device_method_t xen_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, xen_pci_probe), + + /* PCI interface overwrites */ + DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), + DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), + DEVMETHOD(pci_child_added, xen_pci_child_added_method), + + DEVMETHOD_END +}; + +static devclass_t pci_devclass; + +DECLARE_CLASS(acpi_pci_driver); +DEFINE_CLASS_1(pci, xen_pci_driver, xen_pci_methods, sizeof(struct pci_softc), + acpi_pci_driver); +DRIVER_MODULE(xen_pci, pcib, xen_pci_driver, pci_devclass, 0, 0); +MODULE_DEPEND(xen_pci, pci, 1, 1, 1); +MODULE_DEPEND(xen_pci, acpi, 1, 1, 1); +MODULE_VERSION(xen_pci, 1); + +static int +xen_pci_probe(device_t dev) +{ + + device_set_desc(dev, "Xen PCI bus"); + + if (!xen_pv_domain()) + return (ENXIO); + + return (BUS_PROBE_SPECIFIC); +} + +static void +xen_pci_enable_msi_method(device_t dev, device_t child, uint64_t address, + uint16_t data) +{ + struct pci_devinfo *dinfo = device_get_ivars(child); + struct pcicfg_msi *msi = &dinfo->cfg.msi; + + /* Enable MSI in the control register. */ + msi->msi_ctrl |= PCIM_MSICTRL_MSI_ENABLE; + pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, + msi->msi_ctrl, 2); +} + +static void +xen_pci_disable_msi_method(device_t dev, device_t child) +{ + struct pci_devinfo *dinfo = device_get_ivars(child); + struct pcicfg_msi *msi = &dinfo->cfg.msi; + + msi->msi_ctrl &= ~PCIM_MSICTRL_MSI_ENABLE; + pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, + msi->msi_ctrl, 2); +} + +static void +xen_pci_child_added_method(device_t dev, device_t child) +{ + struct pci_devinfo *dinfo; + struct physdev_pci_device_add add_pci; + int error; + + dinfo = device_get_ivars(child); + KASSERT((dinfo != NULL), + ("xen_pci_add_child_method called with NULL dinfo")); + + bzero(&add_pci, sizeof(add_pci)); + add_pci.seg = dinfo->cfg.domain; + add_pci.bus = dinfo->cfg.bus; + add_pci.devfn = (dinfo->cfg.slot << 3) | dinfo->cfg.func; + error = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add_pci); + if (error) + panic("unable to add device bus %u devfn %u error: %d\n", + add_pci.bus, add_pci.devfn, error); +} diff --git a/sys/xen/interface/physdev.h b/sys/xen/interface/physdev.h index b78eeba9ca4a..56b8be045d5e 100644 --- a/sys/xen/interface/physdev.h +++ b/sys/xen/interface/physdev.h @@ -151,6 +151,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_irq_t); #define MAP_PIRQ_TYPE_GSI 0x1 #define MAP_PIRQ_TYPE_UNKNOWN 0x2 #define MAP_PIRQ_TYPE_MSI_SEG 0x3 +#define MAP_PIRQ_TYPE_MULTI_MSI 0x4 #define PHYSDEVOP_map_pirq 13 struct physdev_map_pirq { diff --git a/sys/xen/xen_intr.h b/sys/xen/xen_intr.h index a1ff6666b17a..a29414d9a3ee 100644 --- a/sys/xen/xen_intr.h +++ b/sys/xen/xen_intr.h @@ -224,4 +224,26 @@ void xen_intr_signal(xen_intr_handle_t handle); */ evtchn_port_t xen_intr_port(xen_intr_handle_t handle); +/** + * Setup MSI vector interrupt(s). + * + * \param dev The device that requests the binding. + * + * \param vector Requested initial vector to bind the MSI interrupt(s) to. + * + * \param count Number of vectors to allocate. + * + * \returns 0 on success, otherwise an errno. + */ +int xen_register_msi(device_t dev, int vector, int count); + +/** + * Teardown a MSI vector interrupt. + * + * \param vector Requested vector to release. + * + * \returns 0 on success, otherwise an errno. + */ +int xen_release_msi(int vector); + #endif /* _XEN_INTR_H_ */ diff --git a/sys/amd64/vmm/vmm_msr.h b/sys/xen/xen_msi.h similarity index 66% rename from sys/amd64/vmm/vmm_msr.h rename to sys/xen/xen_msi.h index e07003771f21..baec4c1afda5 100644 --- a/sys/amd64/vmm/vmm_msr.h +++ b/sys/xen/xen_msi.h @@ -1,5 +1,5 @@ -/*- - * Copyright (c) 2011 NetApp, Inc. +/* + * Copyright (c) 2014 Roger Pau Monné * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,10 +11,10 @@ * 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 NETAPP, INC ``AS IS'' AND + * 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 NETAPP, INC OR CONTRIBUTORS BE LIABLE + * 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) @@ -26,19 +26,14 @@ * $FreeBSD$ */ -#ifndef _VMM_MSR_H_ -#define _VMM_MSR_H_ +#ifndef __XEN_MSI_H__ +#define __XEN_MSI_H__ -#define VMM_MSR_NUM 16 -struct vm; +void xen_msi_init(void); +int xen_msi_map(int irq, uint64_t *addr, uint32_t *data); +int xen_msi_alloc(device_t dev, int count, int maxcount, int *irqs); +int xen_msi_release(int *irqs, int count); +int xen_msix_alloc(device_t dev, int *irq); +int xen_msix_release(int irq); -void vmm_msr_init(void); -int emulate_wrmsr(struct vm *vm, int vcpu, u_int msr, uint64_t val, - bool *retu); -int emulate_rdmsr(struct vm *vm, int vcpu, u_int msr, bool *retu); -void guest_msrs_init(struct vm *vm, int cpu); -void guest_msr_valid(int msr); -void restore_host_msrs(struct vm *vm, int cpu); -void restore_guest_msrs(struct vm *vm, int cpu); - -#endif +#endif /* !__XEN_MSI_H__ */ \ No newline at end of file diff --git a/sys/xen/xenstore/xenstore_internal.h b/sys/xen/xenstore/xenstore_internal.h index 0398aef708aa..3355c2789413 100644 --- a/sys/xen/xenstore/xenstore_internal.h +++ b/sys/xen/xenstore/xenstore_internal.h @@ -32,8 +32,5 @@ * $FreeBSD$ */ -/* Initialize support for userspace access to the XenStore. */ -void xs_dev_init(void); - /* Used by the XenStore character device to borrow kernel's store connection. */ int xs_dev_request_and_reply(struct xsd_sockmsg *msg, void **result); diff --git a/tests/sys/kern/unix_seqpacket_test.c b/tests/sys/kern/unix_seqpacket_test.c index c009e6892d8c..ccbacafbd7a1 100644 --- a/tests/sys/kern/unix_seqpacket_test.c +++ b/tests/sys/kern/unix_seqpacket_test.c @@ -397,7 +397,7 @@ ATF_TC_BODY(create_socket, tc) int s; s = socket(PF_LOCAL, SOCK_SEQPACKET, 0); - ATF_CHECK(s >= 0); + ATF_REQUIRE(s >= 0); close(s); } diff --git a/tests/sys/netinet/fibs_test.sh b/tests/sys/netinet/fibs_test.sh index 72ebcfca1dbc..2dc316950cd6 100755 --- a/tests/sys/netinet/fibs_test.sh +++ b/tests/sys/netinet/fibs_test.sh @@ -366,7 +366,6 @@ udp_dontroute_head() udp_dontroute_body() { - atf_expect_fail "kern/187553 Source address selection for UDP packets with SO_DONTROUTE uses the default FIB" # Configure the TAP interface to use an RFC5737 nonrouteable address # and a non-default fib ADDR0="192.0.2.2" diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 78878c2ea459..a12775b8b083 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -3510,9 +3510,9 @@ OLD_FILES+=usr/libexec/ssh-pkcs11-helper OLD_FILES+=usr/sbin/sshd .endif -#.if ${MK_OPENSSL} == no -# to be filled in -#.endif +.if ${MK_OPENSSL} == no +OLD_FILES+=etc/rc.d/keyserv +.endif .if ${MK_PC_SYSINSTALL} == no # backend-partmanager @@ -3606,6 +3606,7 @@ OLD_DIRS+=usr/share/examples/pc-sysinstall .if ${MK_PF} == no OLD_FILES+=etc/periodic/security/520.pfdenied OLD_FILES+=etc/pf.os +OLD_FILES+=etc/rc.d/ftp-proxy OLD_FILES+=sbin/pfctl OLD_FILES+=sbin/pflogd OLD_FILES+=usr/libexec/tftp-proxy @@ -3766,6 +3767,7 @@ OLD_FILES+=usr/lib/private/libssh_p.a .if ${MK_RCMDS} == no OLD_FILES+=bin/rcp +OLD_FILES+=etc/rc.d/rwho OLD_FILES+=etc/periodic/daily/140.clean-rwho OLD_FILES+=etc/periodic/daily/430.status-rwho OLD_FILES+=rescue/rcp @@ -3797,6 +3799,7 @@ OLD_FILES+=usr/bin/rcsdiff OLD_FILES+=usr/bin/rcsfreeze OLD_FILES+=usr/bin/rcsmerge OLD_FILES+=usr/bin/rlog +OLD_FILES+=usr/sbin/etcupdate OLD_FILES+=usr/share/man/man1/ci.1.gz OLD_FILES+=usr/share/man/man1/co.1.gz OLD_FILES+=usr/share/man/man1/ident.1.gz @@ -3809,6 +3812,7 @@ OLD_FILES+=usr/share/man/man1/rcsintro.1.gz OLD_FILES+=usr/share/man/man1/rcsmerge.1.gz OLD_FILES+=usr/share/man/man1/rlog.1.gz OLD_FILES+=usr/share/man/man5/rcsfile.5.gz +OLD_FILES+=usr/share/man/man8/etcupdate.8.gz .endif #.if ${MK_RESCUE} == no @@ -4764,3 +4768,11 @@ OLD_FILES+=usr/libexec/dma-mbox-create OLD_FILES+=usr/share/man/man8/dma.8.gz OLD_FILES+=usr/share/examples/dma/mailer.conf .endif + +.if ${MK_HYPERV} == no +OLD_FILES+=etc/devd/hyperv.conf +OLD_FILES+=usr/libexec/hyperv/hv_set_ifconfig +OLD_FILES+=usr/libexec/hyperv/hv_get_dns_info +OLD_FILES+=usr/libexec/hyperv/hv_get_dhcp_info +OLD_FILES+=usr/sbin/hv_kvpd +.endif diff --git a/tools/build/options/WITHOUT_HYPERV b/tools/build/options/WITHOUT_HYPERV new file mode 100644 index 000000000000..ef63f70ea80e --- /dev/null +++ b/tools/build/options/WITHOUT_HYPERV @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to not build or install HyperV utilities. diff --git a/tools/build/options/WITHOUT_RCS b/tools/build/options/WITHOUT_RCS index 2a4ddecab440..e21e0270d52d 100644 --- a/tools/build/options/WITHOUT_RCS +++ b/tools/build/options/WITHOUT_RCS @@ -1,4 +1,6 @@ .\" $FreeBSD$ Set to not build .Xr rcs 1 -and related utilities. +, +.Xr etcupdate 8 +, and related utilities. diff --git a/tools/build/options/WITH_HYPERV b/tools/build/options/WITH_HYPERV new file mode 100644 index 000000000000..a6bdf72ff3e3 --- /dev/null +++ b/tools/build/options/WITH_HYPERV @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build and install HyperV utilities. diff --git a/tools/make_libdeps.sh b/tools/make_libdeps.sh index dcd1c208698c..84bf895efeb7 100644 --- a/tools/make_libdeps.sh +++ b/tools/make_libdeps.sh @@ -89,12 +89,12 @@ main() fi prebuild_libs=$( - awk -F"${FS}" '{ print $2 }' ${LIBDEPENDS} |rs 0 1 |sort -u + awk -F"${FS}" '{ print $2 }' ${LIBDEPENDS} | tr ' ' '\n' | + sort -u ) echo "Libraries with dependents:" echo - echo ${prebuild_libs} | - rs 0 1 + echo ${prebuild_libs} | tr ' ' '\n' echo echo "List of interdependencies:" diff --git a/tools/regression/acltools/01.t b/tools/regression/acltools/01.t index 00004afece8b..f84e0a98b463 100644 --- a/tools/regression/acltools/01.t +++ b/tools/regression/acltools/01.t @@ -51,7 +51,7 @@ TESTDIR=$(dirname $(realpath $0)) # Set up the test filesystem. MD=`mdconfig -at swap -s 64m` MNT=`mktemp -dt acltools` -zpool create -R $MNT acltools /dev/$MD +zpool create -m $MNT acltools /dev/$MD if [ $? -ne 0 ]; then echo "not ok 1 - 'zpool create' failed." exit 1 diff --git a/tools/regression/acltools/03.t b/tools/regression/acltools/03.t index a577b7a0541f..a0b4199c2bf2 100644 --- a/tools/regression/acltools/03.t +++ b/tools/regression/acltools/03.t @@ -48,7 +48,7 @@ MNTROOT=`mktemp -dt acltools` MD1=`mdconfig -at swap -s 64m` MNT1=$MNTROOT/nfs4 mkdir $MNT1 -zpool create -R $MNT1 acltools /dev/$MD1 +zpool create -m $MNT1 acltools /dev/$MD1 if [ $? -ne 0 ]; then echo "not ok 1 - 'zpool create' failed." exit 1 diff --git a/tools/regression/acltools/04.t b/tools/regression/acltools/04.t index ccb992803ba1..1a13183475fe 100644 --- a/tools/regression/acltools/04.t +++ b/tools/regression/acltools/04.t @@ -43,7 +43,7 @@ TESTDIR=$(dirname $(realpath $0)) # Set up the test filesystem. MD=`mdconfig -at swap -s 64m` MNT=`mktemp -dt acltools` -zpool create -R $MNT acltools /dev/$MD +zpool create -m $MNT acltools /dev/$MD if [ $? -ne 0 ]; then echo "not ok 1 - 'zpool create' failed." exit 1 diff --git a/tools/regression/lib/msun/test-cexp.c b/tools/regression/lib/msun/test-cexp.c index 78c3f1a32044..69897d32155e 100644 --- a/tools/regression/lib/msun/test-cexp.c +++ b/tools/regression/lib/msun/test-cexp.c @@ -117,6 +117,7 @@ test_nan() /* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */ /* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */ for (i = 0; i < N(finites); i++) { + printf("# Run %d..\n", i); testall(CMPLXL(finites[i], NAN), CMPLXL(NAN, NAN), ALL_STD_EXCEPT & ~FE_INVALID, 0, 0); if (finites[i] == 0.0) @@ -148,6 +149,7 @@ test_inf(void) /* cexp(x + inf i) = NaN + NaNi and raises invalid */ for (i = 0; i < N(finites); i++) { + printf("# Run %d..\n", i); testall(CMPLXL(finites[i], INFINITY), CMPLXL(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 1); } @@ -189,6 +191,7 @@ test_reals(void) for (i = 0; i < N(finites); i++) { /* XXX could check exceptions more meticulously */ + printf("# Run %d..\n", i); test(cexp, CMPLXL(finites[i], 0.0), CMPLXL(exp(finites[i]), 0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); @@ -210,6 +213,7 @@ test_imaginaries(void) int i; for (i = 0; i < N(finites); i++) { + printf("# Run %d..\n", i); test(cexp, CMPLXL(0.0, finites[i]), CMPLXL(cos(finites[i]), sin(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); @@ -241,6 +245,7 @@ test_small(void) int i; for (i = 0; i < N(tests); i += 4) { + printf("# Run %d..\n", i); a = tests[i]; b = tests[i + 1]; x = tests[i + 2]; @@ -297,8 +302,12 @@ main(int argc, char *argv[]) test_inf(); printf("ok 3 - cexp inf\n"); +#if defined(__i386__) + printf("not ok 4 - cexp reals # TODO: PR # 191676 fails assertion on i386\n"); +#else test_reals(); printf("ok 4 - cexp reals\n"); +#endif test_imaginaries(); printf("ok 5 - cexp imaginaries\n"); diff --git a/tools/regression/lib/msun/test-conj.c b/tools/regression/lib/msun/test-conj.c index c261f60160b7..7426f9eccf2c 100644 --- a/tools/regression/lib/msun/test-conj.c +++ b/tools/regression/lib/msun/test-conj.c @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include "test-utils.h" -#pragma STDC CX_LIMITED_RANGE off +#pragma STDC CX_LIMITED_RANGE OFF /* Make sure gcc doesn't use builtin versions of these or honor __pure2. */ static float complex (*libconjf)(float complex) = conjf; diff --git a/tools/regression/lib/msun/test-csqrt.c b/tools/regression/lib/msun/test-csqrt.c index 39176eb68e51..bc1817f5ae5c 100644 --- a/tools/regression/lib/msun/test-csqrt.c +++ b/tools/regression/lib/msun/test-csqrt.c @@ -62,7 +62,7 @@ _csqrt(long double complex d) return (csqrt((double complex)d)); } -#pragma STDC CX_LIMITED_RANGE off +#pragma STDC CX_LIMITED_RANGE OFF /* * Compare d1 and d2 using special rules: NaN == NaN and +0 != -0. diff --git a/tools/regression/lib/msun/test-invctrig.c b/tools/regression/lib/msun/test-invctrig.c index e78c26b7423f..78b11197e814 100644 --- a/tools/regression/lib/msun/test-invctrig.c +++ b/tools/regression/lib/msun/test-invctrig.c @@ -315,25 +315,20 @@ test_small(void) * asin(z) = Pi/4 + i ln(2)/2 * atan(z) = atan(4)/2 + i ln(17/9)/4 */ - static const struct { - complex long double z; - complex long double acos_z; - complex long double asin_z; - complex long double atan_z; - } tests[] = { - { CMPLXL(0.75L, 0.25L), - CMPLXL(pi / 4, -0.34657359027997265470861606072908828L), - CMPLXL(pi / 4, 0.34657359027997265470861606072908828L), - CMPLXL(0.66290883183401623252961960521423782L, - 0.15899719167999917436476103600701878L) }, - }; - int i; + complex long double z; + complex long double acos_z; + complex long double asin_z; + complex long double atan_z; - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { - testall_tol(cacos, tests[i].z, tests[i].acos_z, 2); - testall_odd_tol(casin, tests[i].z, tests[i].asin_z, 2); - testall_odd_tol(catan, tests[i].z, tests[i].atan_z, 2); - } + z = CMPLXL(0.75L, 0.25L); + acos_z = CMPLXL(pi / 4, -0.34657359027997265470861606072908828L); + asin_z = CMPLXL(pi / 4, 0.34657359027997265470861606072908828L); + atan_z = CMPLXL(0.66290883183401623252961960521423782L, + 0.15899719167999917436476103600701878L); + + testall_tol(cacos, z, acos_z, 2); + testall_odd_tol(casin, z, asin_z, 2); + testall_odd_tol(catan, z, atan_z, 2); } /* Test inputs that might cause overflow in a sloppy implementation. */ diff --git a/tools/regression/pjdfstest/tests/open/16.t b/tools/regression/pjdfstest/tests/open/16.t deleted file mode 100644 index a15cd9b3c07f..000000000000 --- a/tools/regression/pjdfstest/tests/open/16.t +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -desc="open returns ELOOP when O_NOFOLLOW was specified and the target is a symbolic link" - -dir=`dirname $0` -. ${dir}/../misc.sh - -echo "1..6" - -n0=`namegen` -n1=`namegen` - -expect 0 symlink ${n0} ${n1} -expect ELOOP open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 -expect ELOOP open ${n1} O_RDONLY,O_NOFOLLOW -expect ELOOP open ${n1} O_WRONLY,O_NOFOLLOW -expect ELOOP open ${n1} O_RDWR,O_NOFOLLOW -expect 0 unlink ${n1} diff --git a/tools/sched/schedgraph.py b/tools/sched/schedgraph.py index 4335574972e5..e5925141e69c 100644 --- a/tools/sched/schedgraph.py +++ b/tools/sched/schedgraph.py @@ -856,7 +856,7 @@ def ysize(self): return (Y_EVENTSOURCE) def eventat(self, i): - if (i >= len(self.events)): + if (i >= len(self.events) or i < 0): return (None) event = self.events[i] return (event) diff --git a/tools/test/dtrace/Makefile b/tools/test/dtrace/Makefile index 012a116097f6..405d536b36fa 100644 --- a/tools/test/dtrace/Makefile +++ b/tools/test/dtrace/Makefile @@ -85,7 +85,8 @@ IGNORE= \ ${TESTSRCDIR}/tst/common/ip/tst.localtcpstate.ksh \ ${TESTSRCDIR}/tst/common/ip/tst.remotetcpstate.ksh \ ${TESTSRCDIR}/tst/common/scripting/tst.projid.ksh \ - ${TESTSRCDIR}/tst/common/scripting/tst.taskid.ksh + ${TESTSRCDIR}/tst/common/scripting/tst.taskid.ksh \ + ${TESTSRCDIR}/tst/common/json/tst.usdt.c diff --git a/tools/tools/ath/athalq/ar9300_ds.c b/tools/tools/ath/athalq/ar9300_ds.c index d303351e708d..a554929f28e1 100644 --- a/tools/tools/ath/athalq/ar9300_ds.c +++ b/tools/tools/ath/athalq/ar9300_ds.c @@ -317,6 +317,80 @@ ar9300_decode_rxstatus(struct if_ath_alq_payload *a) (unsigned int) be32toh(a->hdr.tstamp_sec), (unsigned int) be32toh(a->hdr.tstamp_usec), (unsigned long long) be64toh(a->hdr.threadid)); + + /* status1 */ + /* .. and status5 */ + printf(" RSSI %d/%d/%d / %d/%d/%d; combined: %d; rate=0x%02x\n", + MS(rxs.status1, AR_rx_rssi_ant00), + MS(rxs.status1, AR_rx_rssi_ant01), + MS(rxs.status1, AR_rx_rssi_ant02), + MS(rxs.status5, AR_rx_rssi_ant10), + MS(rxs.status5, AR_rx_rssi_ant11), + MS(rxs.status5, AR_rx_rssi_ant12), + MS(rxs.status5, AR_rx_rssi_combined), + MS(rxs.status1, AR_rx_rate)); + + /* status2 */ + printf(" Len: %d; more=%d, delim=%d, upload=%d\n", + MS(rxs.status2, AR_data_len), + MF(rxs.status2, AR_rx_more), + MS(rxs.status2, AR_num_delim), + MS(rxs.status2, AR_hw_upload_data)); + + /* status3 */ + printf(" RX timestamp: %d\n", rxs.status3); + + /* status4 */ + printf(" GI: %d, 2040: %d, parallel40: %d, stbc=%d\n", + MF(rxs.status4, AR_gi), + MF(rxs.status4, AR_2040), + MF(rxs.status4, AR_parallel40), + MF(rxs.status4, AR_rx_stbc)); + printf(" Not sounding: %d, ness: %d, upload_valid: %d\n", + MF(rxs.status4, AR_rx_not_sounding), + MS(rxs.status4, AR_rx_ness), + MS(rxs.status4, AR_hw_upload_data_valid)); + printf(" RX antenna: 0x%08x\n", + MS(rxs.status4, AR_rx_antenna)); + + /* EVM */ + /* status6 - 9 */ + printf(" EVM: 0x%08x; 0x%08x; 0x%08x; 0x%08x\n", + rxs.status6, + rxs.status7, + rxs.status8, + rxs.status9); + + /* status10 - ? */ + + /* status11 */ + printf(" RX done: %d, RX frame ok: %d, CRC error: %d\n", + MF(rxs.status11, AR_rx_done), + MF(rxs.status11, AR_rx_frame_ok), + MF(rxs.status11, AR_crc_err)); + printf(" Decrypt CRC err: %d, PHY err: %d, MIC err: %d\n", + MF(rxs.status11, AR_decrypt_crc_err), + MF(rxs.status11, AR_phyerr), + MF(rxs.status11, AR_michael_err)); + printf(" Pre delim CRC err: %d, uAPSD Trig: %d\n", + MF(rxs.status11, AR_pre_delim_crc_err), + MF(rxs.status11, AR_apsd_trig)); + printf(" RXKeyIdxValid: %d, KeyIdx: %d, PHY error: %d\n", + MF(rxs.status11, AR_rx_key_idx_valid), + MS(rxs.status11, AR_key_idx), + MS(rxs.status11, AR_phy_err_code)); + printf(" RX more Aggr: %d, RX aggr %d, post delim CRC err: %d\n", + MF(rxs.status11, AR_rx_more_aggr), + MF(rxs.status11, AR_rx_aggr), + MF(rxs.status11, AR_post_delim_crc_err)); + printf(" hw upload data type: %d; position bit: %d\n", + MS(rxs.status11, AR_hw_upload_data_type), + MF(rxs.status11, AR_position_bit)); + printf(" Hi RX chain: %d, RxFirstAggr: %d, DecryptBusy: %d, KeyMiss: %d\n", + MF(rxs.status11, AR_hi_rx_chain), + MF(rxs.status11, AR_rx_first_aggr), + MF(rxs.status11, AR_decrypt_busy_err), + MF(rxs.status11, AR_key_miss)); } void diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index 5f4500ba343b..6e072d65d006 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -367,6 +367,7 @@ writefile(time_t runtimer, char queue) if (export) { + (void)fputs("export ", fp); fwrite(*atenv, sizeof(char), eqp-*atenv, fp); for(ap = eqp;*ap != '\0'; ap++) { @@ -389,8 +390,6 @@ writefile(time_t runtimer, char queue) fputc(*ap, fp); } } - fputs("; export ", fp); - fwrite(*atenv, sizeof(char), eqp-*atenv -1, fp); fputc('\n', fp); } diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd index 9205bd9f23f3..fc6df82b921c 100644 --- a/usr.bin/calendar/calendars/calendar.freebsd +++ b/usr.bin/calendar/calendars/calendar.freebsd @@ -52,6 +52,7 @@ 02/03 Jason Helfman born in Royal Oak, Michigan, United States, 1972 02/04 Eitan Adler born in West Hempstead, New York, United States, 1991 02/05 Frank Laszlo born in Howell, Michigan, United States, 1983 +02/06 Julien Charbon born in Saint Etienne, Loire, France, 1978 02/10 David Greenman born in Portland, Oregon, United States, 1968 02/10 Paul Richards born in Ammanford, Carmarthenshire, United Kingdom, 1968 02/10 Simon Barner born in Rosenheim, Bayern, Germany, 1980 diff --git a/usr.bin/elfdump/elfdump.1 b/usr.bin/elfdump/elfdump.1 index dbb3171213ee..a549d5391934 100644 --- a/usr.bin/elfdump/elfdump.1 +++ b/usr.bin/elfdump/elfdump.1 @@ -50,7 +50,7 @@ The options are as follows: .It Fl a Dump all information. .It Fl c -Dump shared headers. +Dump section headers. .It Fl d Dump dynamic symbols. .It Fl e diff --git a/usr.bin/grep/Makefile b/usr.bin/grep/Makefile index c0c24dc27c17..a4c614f2f499 100644 --- a/usr.bin/grep/Makefile +++ b/usr.bin/grep/Makefile @@ -11,7 +11,7 @@ PROG= bsdgrep CLEANFILES+= bsdgrep.1 bsdgrep.1: grep.1 - cp ${.ALLSRC} ${.TARGET} + cp -f ${.ALLSRC} ${.TARGET} .endif SRCS= file.c grep.c queue.c util.c diff --git a/usr.bin/grep/regex/tre-fastmatch.c b/usr.bin/grep/regex/tre-fastmatch.c index eddab2631473..0881c557ecff 100644 --- a/usr.bin/grep/regex/tre-fastmatch.c +++ b/usr.bin/grep/regex/tre-fastmatch.c @@ -727,7 +727,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, for (unsigned int i = 0; i < fg->len; i++) if (fg->pattern[i] == '\\') escaped = !escaped; - else if (fg->pattern[i] == '.' && escaped) + else if (fg->pattern[i] == '.' && fg->escmap && escaped) { fg->escmap[i] = true; escaped = false; diff --git a/usr.bin/iscsictl/iscsictl.8 b/usr.bin/iscsictl/iscsictl.8 index 845718beada3..93bf7ed18f87 100644 --- a/usr.bin/iscsictl/iscsictl.8 +++ b/usr.bin/iscsictl/iscsictl.8 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 18, 2014 +.Dd September 12, 2014 .Dt ISCSICTL 8 .Os .Sh NAME @@ -171,6 +171,7 @@ Attach to target iqn.2012-06.com.example:target0, served by 192.168.1.1: Disconnect all iSCSI sessions: .Dl Nm Fl Ra .Sh SEE ALSO +.Xr iscsi 4 , .Xr iscsi.conf 5 , .Xr iscsid 8 .Sh HISTORY @@ -181,6 +182,6 @@ command appeared in .Sh AUTHORS The .Nm -was developed by +utility was developed by .An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org under sponsorship from the FreeBSD Foundation. diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 index 4763cc624f6e..7517a64cb21c 100644 --- a/usr.bin/man/man.1 +++ b/usr.bin/man/man.1 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 3, 2011 +.Dd September 26, 2014 .Dt MAN 1 .Os .Sh NAME @@ -58,6 +58,28 @@ is provided, .Nm restricts the search to the specific section of the manual. .Pp +The sections of the manual are: +.Bl -enum -offset indent -compact +.It +.Fx General Commands Manual +.It +.Fx System Calls Manual +.It +.Fx Library Functions Manual +.It +.Fx Kernel Interfaces Manual +.It +.Fx File Formats Manual +.It +.Fx Games Manual +.It +.Fx Miscellaneous Information Manual +.It +.Fx System Manager's Manual +.It +.Fx Kernel Developer's Manual +.El +.Pp Options that .Nm understands: @@ -318,6 +340,14 @@ Local configuration files. .Sh SEE ALSO .Xr apropos 1 , .Xr intro 1 , +.Xr intro 2 , +.Xr intro 3 , +.Xr intro 4 , +.Xr intro 5 , +.Xr intro 6 , +.Xr intro 7 , +.Xr intro 8 , +.Xr intro 9 , .Xr locale 1 , .Xr manpath 1 , .Xr nroff 1 , diff --git a/usr.bin/mkimg/Makefile b/usr.bin/mkimg/Makefile index b802799f96ed..28aac7ded9db 100644 --- a/usr.bin/mkimg/Makefile +++ b/usr.bin/mkimg/Makefile @@ -1,13 +1,20 @@ # $FreeBSD$ +.include + PROG= mkimg SRCS= format.c image.c mkimg.c scheme.c MAN= mkimg.1 +MKIMG_VERSION=20141003 +mkimg.o: Makefile + +CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION} CFLAGS+=-DSPARSE_WRITE # List of formats to support SRCS+= \ + qcow.c \ raw.c \ vhd.c \ vmdk.c @@ -29,4 +36,8 @@ LDADD= -lutil WARNS?= 6 +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include diff --git a/usr.bin/mkimg/apm.c b/usr.bin/mkimg/apm.c index 12add8e4cb8a..de92cc0e9b92 100644 --- a/usr.bin/mkimg/apm.c +++ b/usr.bin/mkimg/apm.c @@ -57,13 +57,12 @@ static struct mkimg_alias apm_aliases[] = { { ALIAS_NONE, 0 } }; -static u_int -apm_metadata(u_int where) +static lba_t +apm_metadata(u_int where, lba_t blk) { - u_int secs; - secs = (where == SCHEME_META_IMG_START) ? nparts + 2 : 0; - return (secs); + blk += (where == SCHEME_META_IMG_START) ? nparts + 2 : 0; + return (round_block(blk)); } static int diff --git a/usr.bin/mkimg/bsd.c b/usr.bin/mkimg/bsd.c index 03af5cd2e863..75e554f39b4f 100644 --- a/usr.bin/mkimg/bsd.c +++ b/usr.bin/mkimg/bsd.c @@ -52,13 +52,17 @@ static struct mkimg_alias bsd_aliases[] = { { ALIAS_NONE, 0 } }; -static u_int -bsd_metadata(u_int where) +static lba_t +bsd_metadata(u_int where, lba_t blk) { - u_int secs; - secs = BBSIZE / secsz; - return ((where == SCHEME_META_IMG_START) ? secs : 0); + if (where == SCHEME_META_IMG_START) + blk += BBSIZE / secsz; + else if (where == SCHEME_META_IMG_END) + blk = round_cylinder(blk); + else + blk = round_block(blk); + return (blk); } static int @@ -68,7 +72,7 @@ bsd_write(lba_t imgsz, void *bootcode) struct disklabel *d; struct partition *dp; struct part *part; - int error, n; + int bsdparts, error, n; uint16_t checksum; buf = malloc(BBSIZE); @@ -76,16 +80,13 @@ bsd_write(lba_t imgsz, void *bootcode) return (ENOMEM); if (bootcode != NULL) { memcpy(buf, bootcode, BBSIZE); - memset(buf + secsz, 0, secsz); + memset(buf + secsz, 0, sizeof(struct disklabel)); } else memset(buf, 0, BBSIZE); - imgsz = (lba_t)ncyls * nheads * nsecs; - error = image_set_size(imgsz); - if (error) { - free(buf); - return (error); - } + bsdparts = nparts + 1; /* Account for c partition */ + if (bsdparts < MAXPARTITIONS) + bsdparts = MAXPARTITIONS; d = (void *)(buf + secsz); le32enc(&d->d_magic, DISKMAGIC); @@ -97,7 +98,7 @@ bsd_write(lba_t imgsz, void *bootcode) le32enc(&d->d_secperunit, imgsz); le16enc(&d->d_rpm, 3600); le32enc(&d->d_magic2, DISKMAGIC); - le16enc(&d->d_npartitions, (8 > nparts + 1) ? 8 : nparts + 1); + le16enc(&d->d_npartitions, bsdparts); le32enc(&d->d_bbsize, BBSIZE); dp = &d->d_partitions[RAW_PART]; @@ -107,12 +108,15 @@ bsd_write(lba_t imgsz, void *bootcode) dp = &d->d_partitions[n]; le32enc(&dp->p_size, part->size); le32enc(&dp->p_offset, part->block); + le32enc(&dp->p_fsize, 0); dp->p_fstype = ALIAS_TYPE2INT(part->type); + dp->p_frag = 0; + le16enc(&dp->p_cpg, 0); } - dp = &d->d_partitions[nparts + 1]; + dp = &d->d_partitions[bsdparts]; checksum = 0; - for (p = buf; p < (u_char *)dp; p += 2) + for (p = (void *)d; p < (u_char *)dp; p += 2) checksum ^= le16dec(p); le16enc(&d->d_checksum, checksum); diff --git a/usr.bin/mkimg/ebr.c b/usr.bin/mkimg/ebr.c index 77204d70e813..28931ea4de8c 100644 --- a/usr.bin/mkimg/ebr.c +++ b/usr.bin/mkimg/ebr.c @@ -49,22 +49,23 @@ static struct mkimg_alias ebr_aliases[] = { { ALIAS_NONE, 0 } }; -static u_int -ebr_metadata(u_int where) +static lba_t +ebr_metadata(u_int where, lba_t blk) { - u_int secs; - secs = (where == SCHEME_META_PART_BEFORE) ? nsecs : 0; - return (secs); + blk += (where == SCHEME_META_PART_BEFORE) ? 1 : 0; + return (round_track(blk)); } static void -ebr_chs(u_char *cyl, u_char *hd, u_char *sec, uint32_t lba __unused) +ebr_chs(u_char *cylp, u_char *hdp, u_char *secp, lba_t lba) { + u_int cyl, hd, sec; - *cyl = 0xff; /* XXX */ - *hd = 0xff; /* XXX */ - *sec = 0xff; /* XXX */ + mkimg_chs(lba, 1023, &cyl, &hd, &sec); + *cylp = cyl; + *hdp = hd; + *secp = (sec & 0x3f) | ((cyl >> 2) & 0xc0); } static int @@ -73,7 +74,7 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unused) u_char *ebr; struct dos_partition *dp; struct part *part, *next; - lba_t block; + lba_t block, size; int error; ebr = malloc(secsz); @@ -85,24 +86,26 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unused) error = 0; STAILQ_FOREACH_SAFE(part, &partlist, link, next) { block = part->block - nsecs; + size = round_track(part->size); dp = (void *)(ebr + DOSPARTOFF); ebr_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, nsecs); dp->dp_typ = ALIAS_TYPE2INT(part->type); ebr_chs(&dp->dp_ecyl, &dp->dp_ehd, &dp->dp_esect, - part->block + part->size - 1); + part->block + size - 1); le32enc(&dp->dp_start, nsecs); - le32enc(&dp->dp_size, part->size); + le32enc(&dp->dp_size, size); /* Add link entry */ if (next != NULL) { + size = round_track(next->size); dp++; ebr_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, next->block - nsecs); dp->dp_typ = DOSPTYP_EXT; ebr_chs(&dp->dp_ecyl, &dp->dp_ehd, &dp->dp_esect, - next->block + next->size - 1); + next->block + size - 1); le32enc(&dp->dp_start, next->block - nsecs); - le32enc(&dp->dp_size, next->size + nsecs); + le32enc(&dp->dp_size, size + nsecs); } error = image_write(block, ebr, 1); diff --git a/usr.bin/mkimg/gpt.c b/usr.bin/mkimg/gpt.c index 959deb37bc0d..5773a6a612f7 100644 --- a/usr.bin/mkimg/gpt.c +++ b/usr.bin/mkimg/gpt.c @@ -153,17 +153,15 @@ gpt_tblsz(void) return ((nparts + ents - 1) / ents); } -static u_int -gpt_metadata(u_int where) +static lba_t +gpt_metadata(u_int where, lba_t blk) { - u_int secs; - if (where != SCHEME_META_IMG_START && where != SCHEME_META_IMG_END) - return (0); - - secs = gpt_tblsz(); - secs += (where == SCHEME_META_IMG_START) ? 2 : 1; - return (secs); + if (where == SCHEME_META_IMG_START || where == SCHEME_META_IMG_END) { + blk += gpt_tblsz(); + blk += (where == SCHEME_META_IMG_START) ? 2 : 1; + } + return (round_block(blk)); } static int diff --git a/usr.bin/mkimg/image.c b/usr.bin/mkimg/image.c index f448d98f0f92..3e7c7d2945a5 100644 --- a/usr.bin/mkimg/image.c +++ b/usr.bin/mkimg/image.c @@ -27,70 +27,461 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include #include #include #include #include +#include #include #include +#include #include #include "image.h" #include "mkimg.h" -#define BUFFER_SIZE (1024*1024) +struct chunk { + STAILQ_ENTRY(chunk) ch_list; + size_t ch_size; /* Size of chunk in bytes. */ + lba_t ch_block; /* Block address in image. */ + union { + struct { + off_t ofs; /* Offset in backing file. */ + int fd; /* FD of backing file. */ + } file; + struct { + void *ptr; /* Pointer to data in memory */ + } mem; + } ch_u; + u_int ch_type; +#define CH_TYPE_ZEROES 0 /* Chunk is a gap (no data). */ +#define CH_TYPE_FILE 1 /* File-backed chunk. */ +#define CH_TYPE_MEMORY 2 /* Memory-backed chunk */ +}; + +static STAILQ_HEAD(chunk_head, chunk) image_chunks; +static u_int image_nchunks; + +static char image_swap_file[PATH_MAX]; +static int image_swap_fd = -1; +static u_int image_swap_pgsz; +static off_t image_swap_size; -static char image_tmpfile[PATH_MAX]; -static int image_fd = -1; static lba_t image_size; -static void -cleanup(void) +static int +is_empty_sector(void *buf) { + uint64_t *p = buf; + size_t n, max; - if (image_fd != -1) - close(image_fd); - unlink(image_tmpfile); + assert(((uintptr_t)p & 3) == 0); + + max = secsz / sizeof(uint64_t); + for (n = 0; n < max; n++) { + if (p[n] != 0UL) + return (0); + } + return (1); +} + +/* + * Swap file handlng. + */ + +static off_t +image_swap_alloc(size_t size) +{ + off_t ofs; + size_t unit; + + unit = (secsz > image_swap_pgsz) ? secsz : image_swap_pgsz; + assert((unit & (unit - 1)) == 0); + + size = (size + unit - 1) & ~(unit - 1); + + ofs = image_swap_size; + image_swap_size += size; + if (ftruncate(image_swap_fd, image_swap_size) == -1) { + image_swap_size = ofs; + ofs = -1LL; + } + return (ofs); +} + +/* + * Image chunk handling. + */ + +static struct chunk * +image_chunk_find(lba_t blk) +{ + static struct chunk *last = NULL; + struct chunk *ch; + + ch = (last != NULL && last->ch_block <= blk) + ? last : STAILQ_FIRST(&image_chunks); + while (ch != NULL) { + if (ch->ch_block <= blk && + (lba_t)(ch->ch_block + (ch->ch_size / secsz)) > blk) { + last = ch; + break; + } + ch = STAILQ_NEXT(ch, ch_list); + } + return (ch); +} + +static size_t +image_chunk_grow(struct chunk *ch, size_t sz) +{ + size_t dsz, newsz; + + newsz = ch->ch_size + sz; + if (newsz > ch->ch_size) { + ch->ch_size = newsz; + return (0); + } + /* We would overflow -- create new chunk for remainder. */ + dsz = SIZE_MAX - ch->ch_size; + assert(dsz < sz); + ch->ch_size = SIZE_MAX; + return (sz - dsz); +} + +static struct chunk * +image_chunk_memory(struct chunk *ch, lba_t blk) +{ + struct chunk *new; + void *ptr; + + ptr = calloc(1, secsz); + if (ptr == NULL) + return (NULL); + + if (ch->ch_block < blk) { + new = malloc(sizeof(*new)); + if (new == NULL) { + free(ptr); + return (NULL); + } + memcpy(new, ch, sizeof(*new)); + ch->ch_size = (blk - ch->ch_block) * secsz; + new->ch_block = blk; + new->ch_size -= ch->ch_size; + STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + image_nchunks++; + ch = new; + } + + if (ch->ch_size > secsz) { + new = malloc(sizeof(*new)); + if (new == NULL) { + free(ptr); + return (NULL); + } + memcpy(new, ch, sizeof(*new)); + ch->ch_size = secsz; + new->ch_block++; + new->ch_size -= secsz; + STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + image_nchunks++; + } + + ch->ch_type = CH_TYPE_MEMORY; + ch->ch_u.mem.ptr = ptr; + return (ch); +} + +static int +image_chunk_skipto(lba_t to) +{ + struct chunk *ch; + lba_t from; + size_t sz; + + ch = STAILQ_LAST(&image_chunks, chunk, ch_list); + from = (ch != NULL) ? ch->ch_block + (ch->ch_size / secsz) : 0LL; + + assert(from <= to); + + /* Nothing to do? */ + if (from == to) + return (0); + /* Avoid bugs due to overflows. */ + if ((uintmax_t)(to - from) > (uintmax_t)(SIZE_MAX / secsz)) + return (EFBIG); + sz = (to - from) * secsz; + if (ch != NULL && ch->ch_type == CH_TYPE_ZEROES) { + sz = image_chunk_grow(ch, sz); + if (sz == 0) + return (0); + from = ch->ch_block + (ch->ch_size / secsz); + } + ch = malloc(sizeof(*ch)); + if (ch == NULL) + return (ENOMEM); + memset(ch, 0, sizeof(*ch)); + ch->ch_block = from; + ch->ch_size = sz; + ch->ch_type = CH_TYPE_ZEROES; + STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + image_nchunks++; + return (0); +} + +static int +image_chunk_append(lba_t blk, size_t sz, off_t ofs, int fd) +{ + struct chunk *ch; + + ch = STAILQ_LAST(&image_chunks, chunk, ch_list); + if (ch != NULL && ch->ch_type == CH_TYPE_FILE) { + if (fd == ch->ch_u.file.fd && + blk == (lba_t)(ch->ch_block + (ch->ch_size / secsz)) && + ofs == (off_t)(ch->ch_u.file.ofs + ch->ch_size)) { + sz = image_chunk_grow(ch, sz); + if (sz == 0) + return (0); + blk = ch->ch_block + (ch->ch_size / secsz); + ofs = ch->ch_u.file.ofs + ch->ch_size; + } + } + ch = malloc(sizeof(*ch)); + if (ch == NULL) + return (ENOMEM); + memset(ch, 0, sizeof(*ch)); + ch->ch_block = blk; + ch->ch_size = sz; + ch->ch_type = CH_TYPE_FILE; + ch->ch_u.file.ofs = ofs; + ch->ch_u.file.fd = fd; + STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + image_nchunks++; + return (0); +} + +static int +image_chunk_copyin(lba_t blk, void *buf, size_t sz, off_t ofs, int fd) +{ + uint8_t *p = buf; + int error; + + error = 0; + sz = (sz + secsz - 1) & ~(secsz - 1); + while (!error && sz > 0) { + if (is_empty_sector(p)) + error = image_chunk_skipto(blk + 1); + else + error = image_chunk_append(blk, secsz, ofs, fd); + blk++; + p += secsz; + sz -= secsz; + ofs += secsz; + } + return (error); +} + +/* + * File mapping support. + */ + +static void * +image_file_map(int fd, off_t ofs, size_t sz) +{ + void *ptr; + size_t unit; + int flags, prot; + + unit = (secsz > image_swap_pgsz) ? secsz : image_swap_pgsz; + assert((unit & (unit - 1)) == 0); + + flags = MAP_NOCORE | MAP_NOSYNC | MAP_SHARED; + /* Allow writing to our swap file only. */ + prot = PROT_READ | ((fd == image_swap_fd) ? PROT_WRITE : 0); + sz = (sz + unit - 1) & ~(unit - 1); + ptr = mmap(NULL, sz, prot, flags, fd, ofs); + return ((ptr == MAP_FAILED) ? NULL : ptr); +} + +static int +image_file_unmap(void *buffer, size_t sz) +{ + size_t unit; + + unit = (secsz > image_swap_pgsz) ? secsz : image_swap_pgsz; + sz = (sz + unit - 1) & ~(unit - 1); + munmap(buffer, sz); + return (0); +} + +/* + * Input/source file handling. + */ + +static int +image_copyin_stream(lba_t blk, int fd, uint64_t *sizep) +{ + char *buffer; + uint64_t bytesize; + off_t swofs; + size_t iosz; + ssize_t rdsz; + int error; + + /* + * This makes sure we're doing I/O in multiples of the page + * size as well as of the sector size. 2MB is the minimum + * by virtue of secsz at least 512 bytes and the page size + * at least 4K bytes. + */ + iosz = secsz * image_swap_pgsz; + + bytesize = 0; + do { + swofs = image_swap_alloc(iosz); + if (swofs == -1LL) + return (errno); + buffer = image_file_map(image_swap_fd, swofs, iosz); + if (buffer == NULL) + return (errno); + rdsz = read(fd, buffer, iosz); + if (rdsz > 0) + error = image_chunk_copyin(blk, buffer, rdsz, swofs, + image_swap_fd); + else if (rdsz < 0) + error = errno; + else + error = 0; + image_file_unmap(buffer, iosz); + /* XXX should we relinguish unused swap space? */ + if (error) + return (error); + + bytesize += rdsz; + blk += (rdsz + secsz - 1) / secsz; + } while (rdsz > 0); + + if (sizep != NULL) + *sizep = bytesize; + return (0); +} + +static int +image_copyin_mapped(lba_t blk, int fd, uint64_t *sizep) +{ + off_t cur, data, end, hole, pos; + void *buf; + uint64_t bytesize; + size_t iosz, sz; + int error; + + /* + * We'd like to know the size of the file and we must + * be able to seek in order to mmap(2). If this isn't + * possible, then treat the file as a stream/pipe. + */ + end = lseek(fd, 0L, SEEK_END); + if (end == -1L) + return (image_copyin_stream(blk, fd, sizep)); + + /* + * We need the file opened for the duration and our + * caller is going to close the file. Make a dup(2) + * so that control the faith of the descriptor. + */ + fd = dup(fd); + if (fd == -1) + return (errno); + + iosz = secsz * image_swap_pgsz; + + bytesize = 0; + cur = pos = 0; + error = 0; + while (!error && cur < end) { + hole = lseek(fd, cur, SEEK_HOLE); + data = lseek(fd, cur, SEEK_DATA); + + /* + * Treat the entire file as data if sparse files + * are not supported by the underlying file system. + */ + if (hole == -1 && data == -1) { + data = cur; + hole = end; + } + + if (cur == hole && data > hole) { + hole = pos; + pos = data & ~((uint64_t)secsz - 1); + + blk += (pos - hole) / secsz; + error = image_chunk_skipto(blk); + + bytesize += pos - hole; + cur = data; + } else if (cur == data && hole > data) { + data = pos; + pos = (hole + secsz - 1) & ~((uint64_t)secsz - 1); + + while (data < pos) { + sz = (pos - data > (off_t)iosz) + ? iosz : (size_t)(pos - data); + + buf = image_file_map(fd, data, sz); + if (buf != NULL) { + error = image_chunk_copyin(blk, buf, + sz, data, fd); + image_file_unmap(buf, sz); + } else + error = errno; + + blk += sz / secsz; + bytesize += sz; + data += sz; + } + cur = hole; + } else { + /* + * I don't know what this means or whether it + * can happen at all... + */ + error = EDOOFUS; + break; + } + } + if (error) + close(fd); + if (!error && sizep != NULL) + *sizep = bytesize; + return (error); } int image_copyin(lba_t blk, int fd, uint64_t *sizep) { - char *buffer; - uint64_t bytesize; - ssize_t bcnt, rdsz; - int error, partial; + struct stat sb; + int error; - assert(BUFFER_SIZE % secsz == 0); - - buffer = malloc(BUFFER_SIZE); - if (buffer == NULL) - return (ENOMEM); - bytesize = 0; - partial = 0; - while (1) { - rdsz = read(fd, buffer, BUFFER_SIZE); - if (rdsz <= 0) { - error = (rdsz < 0) ? errno : 0; - break; - } - if (partial) - abort(); - bytesize += rdsz; - bcnt = (rdsz + secsz - 1) / secsz; - error = image_write(blk, buffer, bcnt); - if (error) - break; - blk += bcnt; - partial = ((ssize_t)(bcnt * secsz) != rdsz) ? 1 : 0; + error = image_chunk_skipto(blk); + if (!error) { + if (fstat(fd, &sb) == -1 || !S_ISREG(sb.st_mode)) + error = image_copyin_stream(blk, fd, sizep); + else + error = image_copyin_mapped(blk, fd, sizep); } - free(buffer); - if (sizep != NULL) - *sizep = bytesize; return (error); } +/* + * Output/sink file handling. + */ + int image_copyout(int fd) { @@ -115,71 +506,124 @@ image_copyout_done(int fd) return (error); } +static int +image_copyout_memory(int fd, size_t size, void *ptr) +{ + + if (write(fd, ptr, size) == -1) + return (errno); + return (0); +} + +static int +image_copyout_zeroes(int fd, size_t size) +{ + static uint8_t *zeroes = NULL; + size_t sz; + int error; + + if (lseek(fd, (off_t)size, SEEK_CUR) != -1) + return (0); + + /* + * If we can't seek, we must write. + */ + + if (zeroes == NULL) { + zeroes = calloc(1, secsz); + if (zeroes == NULL) + return (ENOMEM); + } + + while (size > 0) { + sz = (size > secsz) ? secsz : size; + error = image_copyout_memory(fd, sz, zeroes); + if (error) + return (error); + size -= sz; + } + return (0); +} + +static int +image_copyout_file(int fd, size_t size, int ifd, off_t iofs) +{ + void *buf; + size_t iosz, sz; + int error; + + iosz = secsz * image_swap_pgsz; + + while (size > 0) { + sz = (size > iosz) ? iosz : size; + buf = image_file_map(ifd, iofs, sz); + if (buf == NULL) + return (errno); + error = image_copyout_memory(fd, sz, buf); + image_file_unmap(buf, sz); + if (error) + return (error); + size -= sz; + iofs += sz; + } + return (0); +} + int image_copyout_region(int fd, lba_t blk, lba_t size) { - char *buffer; - off_t ofs; - size_t sz; - ssize_t rdsz, wrsz; + struct chunk *ch; + size_t ofs, sz; int error; - ofs = lseek(fd, 0L, SEEK_CUR); - - blk *= secsz; - if (lseek(image_fd, blk, SEEK_SET) != blk) - return (errno); - buffer = malloc(BUFFER_SIZE); - if (buffer == NULL) - return (errno); - error = 0; size *= secsz; + while (size > 0) { - sz = (BUFFER_SIZE < size) ? BUFFER_SIZE : size; - rdsz = read(image_fd, buffer, sz); - if (rdsz <= 0) { - error = (rdsz < 0) ? errno : 0; + ch = image_chunk_find(blk); + if (ch == NULL) + return (EINVAL); + ofs = (blk - ch->ch_block) * secsz; + sz = ch->ch_size - ofs; + sz = ((lba_t)sz < size) ? sz : (size_t)size; + switch (ch->ch_type) { + case CH_TYPE_ZEROES: + error = image_copyout_zeroes(fd, sz); break; - } - wrsz = (ofs == -1) ? - write(fd, buffer, rdsz) : - sparse_write(fd, buffer, rdsz); - if (wrsz < 0) { - error = errno; + case CH_TYPE_FILE: + error = image_copyout_file(fd, sz, ch->ch_u.file.fd, + ch->ch_u.file.ofs + ofs); break; + case CH_TYPE_MEMORY: + error = image_copyout_memory(fd, sz, ch->ch_u.mem.ptr); + break; + default: + return (EDOOFUS); } - assert(wrsz == rdsz); - size -= rdsz; + size -= sz; + blk += sz / secsz; } - free(buffer); - return (error); + return (0); } int image_data(lba_t blk, lba_t size) { - char *buffer, *p; + struct chunk *ch; + lba_t lim; - blk *= secsz; - if (lseek(image_fd, blk, SEEK_SET) != blk) - return (1); - - size *= secsz; - buffer = malloc(size); - if (buffer == NULL) - return (1); - - if (read(image_fd, buffer, size) != (ssize_t)size) { - free(buffer); - return (1); + while (1) { + ch = image_chunk_find(blk); + if (ch == NULL) + return (0); + if (ch->ch_type != CH_TYPE_ZEROES) + return (1); + lim = ch->ch_block + (ch->ch_size / secsz); + if (lim >= blk + size) + return (0); + size -= lim - blk; + blk = lim; } - - p = buffer; - while (size > 0 && *p == '\0') - size--, p++; - - free(buffer); - return ((size == 0) ? 0 : 1); + /*NOTREACHED*/ } lba_t @@ -192,39 +636,87 @@ image_get_size(void) int image_set_size(lba_t blk) { + int error; - image_size = blk; - if (ftruncate(image_fd, blk * secsz) == -1) - return (errno); - return (0); + error = image_chunk_skipto(blk); + if (!error) + image_size = blk; + return (error); } int image_write(lba_t blk, void *buf, ssize_t len) { + struct chunk *ch; - blk *= secsz; - if (lseek(image_fd, blk, SEEK_SET) != blk) - return (errno); - len *= secsz; - if (sparse_write(image_fd, buf, len) != len) - return (errno); + while (len > 0) { + if (!is_empty_sector(buf)) { + ch = image_chunk_find(blk); + if (ch == NULL) + return (ENXIO); + /* We may not be able to write to files. */ + if (ch->ch_type == CH_TYPE_FILE) + return (EINVAL); + if (ch->ch_type == CH_TYPE_ZEROES) { + ch = image_chunk_memory(ch, blk); + if (ch == NULL) + return (ENOMEM); + } + assert(ch->ch_type == CH_TYPE_MEMORY); + memcpy(ch->ch_u.mem.ptr, buf, secsz); + } + blk++; + buf = (char *)buf + secsz; + len--; + } return (0); } +static void +image_cleanup(void) +{ + struct chunk *ch; + + while ((ch = STAILQ_FIRST(&image_chunks)) != NULL) { + switch (ch->ch_type) { + case CH_TYPE_FILE: + /* We may be closing the same file multiple times. */ + if (ch->ch_u.file.fd != -1) + close(ch->ch_u.file.fd); + break; + case CH_TYPE_MEMORY: + free(ch->ch_u.mem.ptr); + break; + default: + break; + } + STAILQ_REMOVE_HEAD(&image_chunks, ch_list); + free(ch); + } + if (image_swap_fd != -1) + close(image_swap_fd); + unlink(image_swap_file); +} + int image_init(void) { const char *tmpdir; - if (atexit(cleanup) == -1) + STAILQ_INIT(&image_chunks); + image_nchunks = 0; + + image_swap_size = 0; + image_swap_pgsz = getpagesize(); + + if (atexit(image_cleanup) == -1) return (errno); if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0') tmpdir = _PATH_TMP; - snprintf(image_tmpfile, sizeof(image_tmpfile), "%s/mkimg-XXXXXX", + snprintf(image_swap_file, sizeof(image_swap_file), "%s/mkimg-XXXXXX", tmpdir); - image_fd = mkstemp(image_tmpfile); - if (image_fd == -1) + image_swap_fd = mkstemp(image_swap_file); + if (image_swap_fd == -1) return (errno); return (0); } diff --git a/usr.bin/mkimg/mbr.c b/usr.bin/mkimg/mbr.c index 4b0f24262dbb..c1b7822efe30 100644 --- a/usr.bin/mkimg/mbr.c +++ b/usr.bin/mkimg/mbr.c @@ -50,22 +50,23 @@ static struct mkimg_alias mbr_aliases[] = { { ALIAS_NONE, 0 } /* Keep last! */ }; -static u_int -mbr_metadata(u_int where) +static lba_t +mbr_metadata(u_int where, lba_t blk) { - u_int secs; - secs = (where == SCHEME_META_IMG_START) ? nsecs : 0; - return (secs); + blk += (where == SCHEME_META_IMG_START) ? 1 : 0; + return (round_track(blk)); } static void -mbr_chs(u_char *cyl, u_char *hd, u_char *sec, uint32_t lba __unused) +mbr_chs(u_char *cylp, u_char *hdp, u_char *secp, lba_t lba) { + u_int cyl, hd, sec; - *cyl = 0xff; /* XXX */ - *hd = 0xff; /* XXX */ - *sec = 0xff; /* XXX */ + mkimg_chs(lba, 1023, &cyl, &hd, &sec); + *cylp = cyl; + *hdp = hd; + *secp = (sec & 0x3f) | ((cyl >> 2) & 0xc0); } static int @@ -74,6 +75,7 @@ mbr_write(lba_t imgsz __unused, void *bootcode) u_char *mbr; struct dos_partition *dpbase, *dp; struct part *part; + lba_t size; int error; mbr = malloc(secsz); @@ -87,15 +89,16 @@ mbr_write(lba_t imgsz __unused, void *bootcode) le16enc(mbr + DOSMAGICOFFSET, DOSMAGIC); dpbase = (void *)(mbr + DOSPARTOFF); STAILQ_FOREACH(part, &partlist, link) { + size = round_track(part->size); dp = dpbase + part->index; dp->dp_flag = (part->index == 0 && bootcode != NULL) ? 0x80 : 0; mbr_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, part->block); dp->dp_typ = ALIAS_TYPE2INT(part->type); mbr_chs(&dp->dp_ecyl, &dp->dp_ehd, &dp->dp_esect, - part->block + part->size - 1); + part->block + size - 1); le32enc(&dp->dp_start, part->block); - le32enc(&dp->dp_size, part->size); + le32enc(&dp->dp_size, size); } error = image_write(0, mbr, 1); free(mbr); diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1 index ed14cc8f9f74..bfe05c01cc09 100644 --- a/usr.bin/mkimg/mkimg.1 +++ b/usr.bin/mkimg/mkimg.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 4, 2014 +.Dd September 27, 2014 .Dt MKIMG 1 .Os .Sh NAME @@ -44,6 +44,8 @@ .Fl s Ar scheme .Fl p Ar partition .Op Fl p Ar partition ... +.Nm +.Ar --formats | --schemes | --version .Sh DESCRIPTION The .Nm @@ -122,10 +124,32 @@ utility will generate predictable values for Universally Unique Identifiers .Nm utility will create images that are identical. .Pp -For a complete list of supported partitioning schemes or supported output -format, or for a detailed description of how to specify partitions, run the +A set of long options exist to query about the +.Nm +utilty itself. +Options in this set should be given by themselves because the +.Nm +utility exits immediately after providing the requested information. +The version of the +.Nm +utility is printed when the +.Ar --version +option is given. +The list of supported output formats is printed when the +.Ar --formats +option is given and the list of supported partitioning schemes is printed +when the +.Ar --schemes +option is given. +Both the format and scheme lists a space-separated lists for easy handling +in scripts. +.Pp +For a more descriptive list of supported partitioning schemes or supported +output format, or for a detailed description of how to specify partitions, +run the .Nm utility without any arguments. +This will print a usage message with all the necessary details. .Sh ENVIRONMENT .Bl -tag -width "TMPDIR" -compact .It Ev TMPDIR @@ -171,6 +195,25 @@ utility as follows: .Dl % mkimg -s mbr -b /boot/mbr -p freebsd:-'mkimg -s bsd -b /boot/boot \ -p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G' -o mbr-bsd.img .Pp +To accomodate the need to have partitions named or numbered in a certain +way, the +.Nm +utility allows for the specification of empty partitions. +For example, to create an image that is compatible with partition layouts +found in +.Pa /etc/disktab , +the 'd' partition often needs to be skipped. +This is accomplished by inserting an unused partition after the first 2 +partition specifications. +It is worth noting at this time that the BSD scheme will automatically +skip the 'c' partition by virtue of it referring to the entire disk. +To create an image that is compatible with the qp120at disk, use the +.Nm +utility as follows: +.Dl % mkimg -s bsd -b /boot/boot -p freebsd-ufs:=root-file-system.ufs \ +-p freebsd-swap::20M -p- -p- -p- -p- -p freebsd-ufs:=usr-file-system.ufs \ +-o bsd.img +.Pp For partitioning schemes that feature partition labels, the .Nm utility supports assigning labels to the partitions specified. diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c index 4513e665e443..b55ee7e8fdaa 100644 --- a/usr.bin/mkimg/mkimg.c +++ b/usr.bin/mkimg/mkimg.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -48,6 +49,17 @@ __FBSDID("$FreeBSD$"); #include "mkimg.h" #include "scheme.h" +#define LONGOPT_FORMATS 0x01000001 +#define LONGOPT_SCHEMES 0x01000002 +#define LONGOPT_VERSION 0x01000003 + +static struct option longopts[] = { + { "formats", no_argument, NULL, LONGOPT_FORMATS }, + { "schemes", no_argument, NULL, LONGOPT_SCHEMES }, + { "version", no_argument, NULL, LONGOPT_VERSION }, + { NULL, 0, NULL, 0 } +}; + struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist); u_int nparts = 0; @@ -61,15 +73,79 @@ u_int secsz = 512; u_int blksz = 0; static void -usage(const char *why) +print_formats(int usage) { struct mkimg_format *f, **f_iter; + const char *sep; + + if (usage) { + fprintf(stderr, " formats:\n"); + SET_FOREACH(f_iter, formats) { + f = *f_iter; + fprintf(stderr, "\t%s\t- %s\n", f->name, + f->description); + } + } else { + sep = ""; + SET_FOREACH(f_iter, formats) { + f = *f_iter; + printf("%s%s", sep, f->name); + sep = " "; + } + putchar('\n'); + } +} + +static void +print_schemes(int usage) +{ struct mkimg_scheme *s, **s_iter; + const char *sep; + + if (usage) { + fprintf(stderr, " schemes:\n"); + SET_FOREACH(s_iter, schemes) { + s = *s_iter; + fprintf(stderr, "\t%s\t- %s\n", s->name, + s->description); + } + } else { + sep = ""; + SET_FOREACH(s_iter, schemes) { + s = *s_iter; + printf("%s%s", sep, s->name); + sep = " "; + } + putchar('\n'); + } +} + +static void +print_version(void) +{ + u_int width; + +#ifdef __LP64__ + width = 64; +#else + width = 32; +#endif + printf("mkimg %u (%u-bit)\n", MKIMG_VERSION, width); +} + +static void +usage(const char *why) +{ warnx("error: %s", why); - fprintf(stderr, "\nusage: %s \n", getprogname()); + fputc('\n', stderr); + fprintf(stderr, "usage: %s \n", getprogname()); fprintf(stderr, " options:\n"); + fprintf(stderr, "\t--formats\t- list image formats\n"); + fprintf(stderr, "\t--schemes\t- list partition schemes\n"); + fprintf(stderr, "\t--version\t- show version information\n"); + fputc('\n', stderr); fprintf(stderr, "\t-b \t- file containing boot code\n"); fprintf(stderr, "\t-f \n"); fprintf(stderr, "\t-o \t- file to write image into\n"); @@ -81,26 +157,19 @@ usage(const char *why) fprintf(stderr, "\t-P \t- physical sector size\n"); fprintf(stderr, "\t-S \t- logical sector size\n"); fprintf(stderr, "\t-T \t- number of tracks to simulate\n"); - - fprintf(stderr, "\n formats:\n"); - SET_FOREACH(f_iter, formats) { - f = *f_iter; - fprintf(stderr, "\t%s\t- %s\n", f->name, f->description); - } - - fprintf(stderr, "\n schemes:\n"); - SET_FOREACH(s_iter, schemes) { - s = *s_iter; - fprintf(stderr, "\t%s\t- %s\n", s->name, s->description); - } - - fprintf(stderr, "\n partition specification:\n"); + fputc('\n', stderr); + print_formats(1); + fputc('\n', stderr); + print_schemes(1); + fputc('\n', stderr); + fprintf(stderr, " partition specification:\n"); fprintf(stderr, "\t[/]::\t- empty partition of given " "size\n"); fprintf(stderr, "\t[/]:=\t- partition content and size " "are determined\n\t\t\t\t by the named file\n"); fprintf(stderr, "\t[/]:-\t- partition content and size " "are taken from\n\t\t\t\t the output of the command to run\n"); + fprintf(stderr, "\t-\t\t\t- unused partition entry\n"); fprintf(stderr, "\t where:\n"); fprintf(stderr, "\t\t\t- scheme neutral partition type\n"); fprintf(stderr, "\t\t\t- optional scheme-dependent partition " @@ -140,6 +209,9 @@ pwr_of_two(u_int nr) * '-' contents holds a command to run; the output of * which is the contents of the partition. * contents the specification of a partition's contents + * + * A specification that is a single dash indicates an unused partition + * entry. */ static int parse_part(const char *spec) @@ -149,6 +221,11 @@ parse_part(const char *spec) size_t len; int error; + if (strcmp(spec, "-") == 0) { + nparts++; + return (0); + } + part = calloc(1, sizeof(struct part)); if (part == NULL) return (ENOMEM); @@ -262,6 +339,27 @@ sparse_write(int fd, const void *ptr, size_t sz) } #endif /* SPARSE_WRITE */ +void +mkimg_chs(lba_t lba, u_int maxcyl, u_int *cylp, u_int *hdp, u_int *secp) +{ + u_int hd, sec; + + *cylp = *hdp = *secp = ~0U; + if (nsecs == 1 || nheads == 1) + return; + + sec = lba % nsecs + 1; + lba /= nsecs; + hd = lba % nheads; + lba /= nheads; + if (lba > maxcyl) + return; + + *cylp = lba; + *hdp = hd; + *secp = sec; +} + void mkimg_uuid(struct uuid *uuid) { @@ -357,7 +455,8 @@ main(int argc, char *argv[]) bcfd = -1; outfd = 1; /* Write to stdout by default */ - while ((c = getopt(argc, argv, "b:f:o:p:s:vyH:P:S:T:")) != -1) { + while ((c = getopt_long(argc, argv, "b:f:o:p:s:vyH:P:S:T:", + longopts, NULL)) != -1) { switch (c) { case 'b': /* BOOT CODE */ if (bcfd != -1) @@ -423,6 +522,18 @@ main(int argc, char *argv[]) if (error) errc(EX_DATAERR, error, "track size"); break; + case LONGOPT_FORMATS: + print_formats(0); + exit(EX_OK); + /*NOTREACHED*/ + case LONGOPT_SCHEMES: + print_schemes(0); + exit(EX_OK); + /*NOTREACHED*/ + case LONGOPT_VERSION: + print_version(); + exit(EX_OK); + /*NOTREACHED*/ default: usage("unknown option"); } diff --git a/usr.bin/mkimg/mkimg.h b/usr.bin/mkimg/mkimg.h index 9558b863d36d..281beebc9dcb 100644 --- a/usr.bin/mkimg/mkimg.h +++ b/usr.bin/mkimg/mkimg.h @@ -66,12 +66,29 @@ round_block(lba_t n) return ((n + b - 1) & ~(b - 1)); } +static inline lba_t +round_cylinder(lba_t n) +{ + u_int cyl = nsecs * nheads; + u_int r = n % cyl; + return ((r == 0) ? n : n + cyl - r); +} + +static inline lba_t +round_track(lba_t n) +{ + u_int r = n % nsecs; + return ((r == 0) ? n : n + nsecs - r); +} + #if !defined(SPARSE_WRITE) #define sparse_write write #else ssize_t sparse_write(int, const void *, size_t); #endif +void mkimg_chs(lba_t, u_int, u_int *, u_int *, u_int *); + struct uuid; void mkimg_uuid(struct uuid *); diff --git a/usr.bin/mkimg/pc98.c b/usr.bin/mkimg/pc98.c index 24b9156bf09c..2db0394fb296 100644 --- a/usr.bin/mkimg/pc98.c +++ b/usr.bin/mkimg/pc98.c @@ -59,22 +59,23 @@ static struct mkimg_alias pc98_aliases[] = { { ALIAS_NONE, 0 } }; -static u_int -pc98_metadata(u_int where) +static lba_t +pc98_metadata(u_int where, lba_t blk) { - u_int secs; - - secs = PC98_BOOTCODESZ / secsz; - return ((where == SCHEME_META_IMG_START) ? secs : 0); + if (where == SCHEME_META_IMG_START) + blk += PC98_BOOTCODESZ / secsz; + return (round_track(blk)); } static void -pc98_chs(u_short *cyl, u_char *hd, u_char *sec, uint32_t lba __unused) +pc98_chs(u_short *cylp, u_char *hdp, u_char *secp, lba_t lba) { + u_int cyl, hd, sec; - *cyl = 0xffff; /* XXX */ - *hd = 0xff; /* XXX */ - *sec = 0xff; /* XXX */ + mkimg_chs(lba, 0xffff, &cyl, &hd, &sec); + le16enc(cylp, cyl); + *hdp = hd; + *secp = sec; } static int @@ -83,6 +84,7 @@ pc98_write(lba_t imgsz __unused, void *bootcode) struct part *part; struct pc98_partition *dpbase, *dp; u_char *buf; + lba_t size; int error, ptyp; buf = malloc(PC98_BOOTCODESZ); @@ -96,6 +98,7 @@ pc98_write(lba_t imgsz __unused, void *bootcode) le16enc(buf + PC98_MAGICOFS, PC98_MAGIC); dpbase = (void *)(buf + secsz); STAILQ_FOREACH(part, &partlist, link) { + size = round_track(part->size); dp = dpbase + part->index; ptyp = ALIAS_TYPE2INT(part->type); dp->dp_mid = ptyp; @@ -103,7 +106,7 @@ pc98_write(lba_t imgsz __unused, void *bootcode) pc98_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, part->block); pc98_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, - part->block + part->size - 1); + part->block + size - 1); if (part->label != NULL) memcpy(dp->dp_name, part->label, strlen(part->label)); } diff --git a/usr.bin/mkimg/qcow.c b/usr.bin/mkimg/qcow.c new file mode 100644 index 000000000000..5033286821b3 --- /dev/null +++ b/usr.bin/mkimg/qcow.c @@ -0,0 +1,369 @@ +/*- + * Copyright (c) 2014 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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 "image.h" +#include "format.h" +#include "mkimg.h" + +/* Default cluster sizes. */ +#define QCOW1_CLSTR_LOG2SZ 12 /* 4KB */ +#define QCOW2_CLSTR_LOG2SZ 16 /* 64KB */ + +/* Flag bits in cluster offsets */ +#define QCOW_CLSTR_COMPRESSED (1ULL << 62) +#define QCOW_CLSTR_COPIED (1ULL << 63) + +struct qcow_header { + uint32_t magic; +#define QCOW_MAGIC 0x514649fb + uint32_t version; +#define QCOW_VERSION_1 1 +#define QCOW_VERSION_2 2 + uint64_t path_offset; + uint32_t path_length; + uint32_t clstr_log2sz; /* v2 only */ + uint64_t disk_size; + union { + struct { + uint8_t clstr_log2sz; + uint8_t l2_log2sz; + uint16_t _pad; + uint32_t encryption; + uint64_t l1_offset; + } v1; + struct { + uint32_t encryption; + uint32_t l1_entries; + uint64_t l1_offset; + uint64_t refcnt_offset; + uint32_t refcnt_entries; + uint32_t snapshot_count; + uint64_t snapshot_offset; + } v2; + } u; +}; + +static u_int clstr_log2sz; + +static uint64_t +round_clstr(uint64_t ofs) +{ + uint64_t clstrsz; + + clstrsz = 1UL << clstr_log2sz; + return ((ofs + clstrsz - 1) & ~(clstrsz - 1)); +} + +static int +qcow_resize(lba_t imgsz, u_int version) +{ + uint64_t imagesz; + + switch (version) { + case QCOW_VERSION_1: + clstr_log2sz = QCOW1_CLSTR_LOG2SZ; + break; + case QCOW_VERSION_2: + clstr_log2sz = QCOW2_CLSTR_LOG2SZ; + break; + default: + return (EDOOFUS); + } + + imagesz = round_clstr(imgsz * secsz); + + if (verbose) + fprintf(stderr, "QCOW: image size = %ju, cluster size = %u\n", + (uintmax_t)imagesz, (u_int)(1U << clstr_log2sz)); + + return (image_set_size(imagesz / secsz)); +} + +static int +qcow1_resize(lba_t imgsz) +{ + + return (qcow_resize(imgsz, QCOW_VERSION_1)); +} + +static int +qcow2_resize(lba_t imgsz) +{ + + return (qcow_resize(imgsz, QCOW_VERSION_2)); +} + +static int +qcow_write(int fd, u_int version) +{ + struct qcow_header *hdr; + uint64_t *l1tbl, *l2tbl, *rctbl; + uint16_t *rcblk; + uint64_t clstr_imgsz, clstr_l2tbls, clstr_l1tblsz; + uint64_t clstr_rcblks, clstr_rctblsz; + uint64_t n, imagesz, nclstrs, ofs, ofsflags; + lba_t blk, blkofs, blk_imgsz; + u_int l1clno, l2clno, rcclno; + u_int blk_clstrsz; + u_int clstrsz, l1idx, l2idx; + int error; + + if (clstr_log2sz == 0) + return (EDOOFUS); + + clstrsz = 1U << clstr_log2sz; + blk_clstrsz = clstrsz / secsz; + blk_imgsz = image_get_size(); + imagesz = blk_imgsz * secsz; + clstr_imgsz = imagesz >> clstr_log2sz; + clstr_l2tbls = round_clstr(clstr_imgsz * 8) >> clstr_log2sz; + clstr_l1tblsz = round_clstr(clstr_l2tbls * 8) >> clstr_log2sz; + nclstrs = clstr_imgsz + clstr_l2tbls + clstr_l1tblsz + 1; + clstr_rcblks = clstr_rctblsz = 0; + do { + n = clstr_rcblks + clstr_rctblsz; + clstr_rcblks = round_clstr((nclstrs + n) * 2) >> clstr_log2sz; + clstr_rctblsz = round_clstr(clstr_rcblks * 8) >> clstr_log2sz; + } while (n < (clstr_rcblks + clstr_rctblsz)); + + /* + * We got all the sizes in clusters. Start the layout. + * 0 - header + * 1 - L1 table + * 2 - RC table (v2 only) + * 3 - L2 tables + * 4 - RC block (v2 only) + * 5 - data + */ + + l1clno = 1; + rcclno = 0; + rctbl = l2tbl = l1tbl = NULL; + rcblk = NULL; + + hdr = calloc(1, clstrsz); + if (hdr == NULL) + return (errno); + + be32enc(&hdr->magic, QCOW_MAGIC); + be32enc(&hdr->version, version); + be64enc(&hdr->disk_size, imagesz); + switch (version) { + case QCOW_VERSION_1: + ofsflags = 0; + l2clno = l1clno + clstr_l1tblsz; + hdr->u.v1.clstr_log2sz = clstr_log2sz; + hdr->u.v1.l2_log2sz = clstr_log2sz - 3; + be64enc(&hdr->u.v1.l1_offset, clstrsz * l1clno); + break; + case QCOW_VERSION_2: + ofsflags = QCOW_CLSTR_COPIED; + rcclno = l1clno + clstr_l1tblsz; + l2clno = rcclno + clstr_rctblsz; + be32enc(&hdr->clstr_log2sz, clstr_log2sz); + be32enc(&hdr->u.v2.l1_entries, clstr_l2tbls); + be64enc(&hdr->u.v2.l1_offset, clstrsz * l1clno); + be64enc(&hdr->u.v2.refcnt_offset, clstrsz * rcclno); + be32enc(&hdr->u.v2.refcnt_entries, clstr_rcblks); + break; + default: + return (EDOOFUS); + } + + if (sparse_write(fd, hdr, clstrsz) < 0) { + error = errno; + goto out; + } + + free(hdr); + hdr = NULL; + + ofs = clstrsz * l2clno; + nclstrs = 1 + clstr_l1tblsz + clstr_rctblsz; + + l1tbl = calloc(1, clstrsz * clstr_l1tblsz); + if (l1tbl == NULL) { + error = ENOMEM; + goto out; + } + + for (n = 0; n < clstr_imgsz; n++) { + blk = n * blk_clstrsz; + if (image_data(blk, blk_clstrsz)) { + nclstrs++; + l1idx = n >> (clstr_log2sz - 3); + if (l1tbl[l1idx] == 0) { + be64enc(l1tbl + l1idx, ofs + ofsflags); + ofs += clstrsz; + nclstrs++; + } + } + } + + if (sparse_write(fd, l1tbl, clstrsz * clstr_l1tblsz) < 0) { + error = errno; + goto out; + } + + clstr_rcblks = 0; + do { + n = clstr_rcblks; + clstr_rcblks = round_clstr((nclstrs + n) * 2) >> clstr_log2sz; + } while (n < clstr_rcblks); + + if (rcclno > 0) { + rctbl = calloc(1, clstrsz * clstr_rctblsz); + if (rctbl == NULL) { + error = ENOMEM; + goto out; + } + for (n = 0; n < clstr_rcblks; n++) { + be64enc(rctbl + n, ofs); + ofs += clstrsz; + nclstrs++; + } + if (sparse_write(fd, rctbl, clstrsz * clstr_rctblsz) < 0) { + error = errno; + goto out; + } + free(rctbl); + rctbl = NULL; + } + + l2tbl = malloc(clstrsz); + if (l2tbl == NULL) { + error = ENOMEM; + goto out; + } + + for (l1idx = 0; l1idx < clstr_l2tbls; l1idx++) { + if (l1tbl[l1idx] == 0) + continue; + memset(l2tbl, 0, clstrsz); + blkofs = (lba_t)l1idx * blk_clstrsz * (clstrsz >> 3); + for (l2idx = 0; l2idx < (clstrsz >> 3); l2idx++) { + blk = blkofs + (lba_t)l2idx * blk_clstrsz; + if (blk >= blk_imgsz) + break; + if (image_data(blk, blk_clstrsz)) { + be64enc(l2tbl + l2idx, ofs + ofsflags); + ofs += clstrsz; + } + } + if (sparse_write(fd, l2tbl, clstrsz) < 0) { + error = errno; + goto out; + } + } + + free(l2tbl); + l2tbl = NULL; + free(l1tbl); + l1tbl = NULL; + + if (rcclno > 0) { + rcblk = calloc(1, clstrsz * clstr_rcblks); + if (rcblk == NULL) { + error = ENOMEM; + goto out; + } + for (n = 0; n < nclstrs; n++) + be16enc(rcblk + n, 1); + if (sparse_write(fd, rcblk, clstrsz * clstr_rcblks) < 0) { + error = errno; + goto out; + } + free(rcblk); + rcblk = NULL; + } + + error = 0; + for (n = 0; n < clstr_imgsz; n++) { + blk = n * blk_clstrsz; + if (image_data(blk, blk_clstrsz)) { + error = image_copyout_region(fd, blk, blk_clstrsz); + if (error) + break; + } + } + if (!error) + error = image_copyout_done(fd); + + out: + if (rcblk != NULL) + free(rcblk); + if (l2tbl != NULL) + free(l2tbl); + if (rctbl != NULL) + free(rctbl); + if (l1tbl != NULL) + free(l1tbl); + if (hdr != NULL) + free(hdr); + return (error); +} + +static int +qcow1_write(int fd) +{ + + return (qcow_write(fd, QCOW_VERSION_1)); +} + +static int +qcow2_write(int fd) +{ + + return (qcow_write(fd, QCOW_VERSION_2)); +} + +static struct mkimg_format qcow1_format = { + .name = "qcow", + .description = "QEMU Copy-On-Write, version 1", + .resize = qcow1_resize, + .write = qcow1_write, +}; +FORMAT_DEFINE(qcow1_format); + +static struct mkimg_format qcow2_format = { + .name = "qcow2", + .description = "QEMU Copy-On-Write, version 2", + .resize = qcow2_resize, + .write = qcow2_write, +}; +FORMAT_DEFINE(qcow2_format); diff --git a/usr.bin/mkimg/scheme.c b/usr.bin/mkimg/scheme.c index 7546ae289f34..ff5e2014a7e5 100644 --- a/usr.bin/mkimg/scheme.c +++ b/usr.bin/mkimg/scheme.c @@ -171,10 +171,8 @@ scheme_max_secsz(void) lba_t scheme_metadata(u_int where, lba_t start) { - lba_t secs; - secs = scheme->metadata(where); - return (round_block(start + secs)); + return (scheme->metadata(where, start)); } int diff --git a/usr.bin/mkimg/scheme.h b/usr.bin/mkimg/scheme.h index 8224930d8d28..d594a1917d67 100644 --- a/usr.bin/mkimg/scheme.h +++ b/usr.bin/mkimg/scheme.h @@ -62,7 +62,7 @@ struct mkimg_scheme { const char *name; const char *description; struct mkimg_alias *aliases; - u_int (*metadata)(u_int); + lba_t (*metadata)(u_int, lba_t); #define SCHEME_META_IMG_START 1 #define SCHEME_META_IMG_END 2 #define SCHEME_META_PART_BEFORE 3 diff --git a/usr.bin/mkimg/tests/Makefile b/usr.bin/mkimg/tests/Makefile new file mode 100644 index 000000000000..144b4fc83ae3 --- /dev/null +++ b/usr.bin/mkimg/tests/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/usr.bin/mkimg + +ATF_TESTS_SH= mkimg + +SOURCES!= cd ${.CURDIR}; echo *.uu +FILES= ${SOURCES:S,.gz.uu,,g} +FILESDIR= ${TESTSDIR} + +${FILES}: + uudecode -p ${.CURDIR}/${.TARGET}.gz.uu | gunzip -c > ${.TARGET} + +CLEANFILES+= ${FILES} + +rebase: + (cd ${.CURDIR}; atf-sh mkimg.sh rebase) + +.include diff --git a/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow.gz.uu new file mode 100644 index 000000000000..0f8ec4e03c34 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-apm.qcow.gz +M'XL("*DS(E0``VEM9RTQ>#$M-#`Y-BUA<&TN<6-O=RYO=70`K9W9CAW9<47? +M^RLN9[(XW8C(D;,$N0$_&&A;T+.4(R!`MA.R`+_PXUW%.D-5W+T9E+NI0H-$ +M(3>R3BTN":W%P_/Y]L?IU,JIZ4[->-KGT_6OTX><[OSB_L?IZ[___*]O[O[X +M^M/MF)R_\Y3[=:,G27/WMGY?Y_3FJ>5T'G]@[OH#SMUY._LGWN[.%WLY=_73 +M[1>+GU,V:/<&3VGNG-Y/R.DU/_9^7]R7*[>G]]M]N4J^W)8-=O<&?TES?TGO +MI^3+[=G<<&_N<%^NDB]W9'/3=V%1`LO,YI9@KH%/K6QN"^9:^-2.Y^0[W]O; +MN0X^)6Q.X=RIS/7P*6-SS;VY\YL,=)X;X%.$.PFY&^%3A#L)N9O@4X0[";F; +MX5.$.PFY6^!3A#L)N5OA4X0[#;G;X%.$.PVYV^%3A#N-N!/\%.%.(^X$^4X9 +M=QIQ)\AWRKC3B#M!OE/&G4;<"?*=,NXTXDZ0[Y1Q9Q%W@GQGC#N+N!/D.V/< +M6<@=\ITQ[BSD#OG.&'<6*GR+<-1%WBGS7,.Z:B#M%OFL8=TW$G2+?-8R[)N). +MD>\:QET3<:?(=PWCKHVX4^2[EG'71MPI\EW+N&M#[I#O6L9=&W*'?-XZR+N +M##]%N.LB[@SYKF/<=1%WAGS7,>ZZB#M#ONL8=UW$G2'?=8R[+N+.D.\ZQET? +M<6?(=SWCKH^X,^2[GG'7A]PAW_6,NS[D#OFN9]SU(7?(=SWCK@^Y0[[K&7=] +MR!WR7<^XZT/ND.]ZQMT0*N0[Y;&'=+Q%V'?+ZVB+L>^6YCW&T1=SWRW<:XVR+N>N2[C7&W1=SUR'<;XVZ/ +MN.N1[W;&W1YQUR/?[8R[/>0.^6YGW.TA=\AW.^-N#[E#OML9=WO('?+=SKC; +M0^Z0[W;&W1YRAWRW$^XD_X3/`=_)F7`GYY`[X#LY$^[D''$WX*LOY.POQN`[X3U=Q+V=P/PG;#^3L+^;@"^$];?2=C?#OO).SO9OP4X2[L[V;D.];?2=C?S]8?R=A?SOO).SO9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYN1KYC_9V$ +M_=V,?,?Z.PG[NQGYCO5W$O9W"WZ*OO).SO%N0[UM])V-\MR'>L +MOY.POUN0[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W$O9W +M"_(=Z^\D[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W(-^Q_D["_FY!OF/] +MG83]W8)\Q_H["?N[%3]%N`O[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6WTG8WZW( +M=ZR_D["_6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83]W8I\Q_H["?N[%?F.]7<2 +M]G]8?R=A?[OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_)V%_MR'?L?Y.POYN +MQT\1[L+^;D>^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V=SOR'>OO).SO=N0[UM]) +MV-_MR'>LOY.PO]N1[UA_)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.PG[NQWY +MCO5W$O9W._(=Z^\D[.]VY#O6WVG^B9L[U3G@N^NG,'?J^KM\G]ZI<@=\IZR_ +M4]??G1)WI\R=G?%3F#MU_=TI<7?Z2YD#OE/6WZGK[TZ'.SM#]]\IZ^_4]7?E +M[.H<\)VR_DY=?P?F@.^4]7?J^CLP!WRGK+]3U]_EN0=U#OA.67^GKK][D.=. +M90[X3EE_IZZ_>Y"X>U"Y`[Y3UM^IZ^\>).X>5.Z`[Y3U=^KZNP?'Q=D!WRGK +M[]3U=^7LZASPG;+^3EU_!^:`[Y3U=^KZ.S`'?*>LOU/7W^6YAW4.^8[U=^KZ +MNX=YKG*'?,?Z.W7]WYBX>UBX0_??*>OOU/5W#P]_ +M=NC^.V7]G;K^KIQ=G4.^8_V=NOX.S"'?L?Y.77\'YI#O6'^GKK_+/\ESA#MU_IZR_4]??/4KHNOP-SR'>LOU/7WX$YY#O6WZGK[_+,\5[E#OF/]G;K^[G'B[G'A#MU_IZR_4]??/4[:YPA^Z_4];?J>OOGB3NGE3ND.]8?Z>NOWN2N'M2N4.^ +M8_V=NO[NR7%Q=LAWK+]3U]^5LZMSR'>LOU/7WX$YY#O6WZGK[\`<\AWK[]3U +M=WGN:9U#OF/]G;K^[FF>J]PAW['^3EU_]S1Q][1PA^Z_4];?J>OOGB;NGA;N +MT/UWROH[=?W=T\.?';K_3EE_IZZ_*V=7YY#O6'^GKK\#<\AWK+]3U]^!.>0[ +MUM^IZ^_RW+,ZAWS'^CMU_=VS/%>X0_??*>OOU/5WSQ)WSRIWR'>LOU/7WSU+ +MW#VKW"'?L?Y.77_W[+@X.^0[UM^IZ^_*V=4YY#O6WZGK[\`<\AWK[]3U=V`. +M^8[U=^KZNSSWO,XAW['^3EU_]SS/5>Z0[UA_IZZ_>YZX>UZX0_??*>OOU/5W +MSQ-WSPMWZ/X[9?V=NO[N^>'/#MU_IZR_4]??E;.K<\AWK+]3U]^!.>0[UM^I +MZ^_`'/(=Z^_4]7=Y[D6=0[YC_9VZ_NY%GBO6YRAWR'>OOU/5W5XF[J\(=NO]. +M67^GKK^[2MQ=%>[0_7?*^CMU_=W5X<\.W7^GK+]3U]^5LZMSR'>LOU/7WX$Y +MY#O6WZGK[\`<\AWK[]3U=WGN99U#OF/]G;K^[F6>*]RA^^^4]7?J^KN7B;N7 +ME3OD.];?J>OO7B;N7E;ND.]8?Z>NOWMY7)P=\AWK[]3U=^7LZASR'>OOU/5W +M8`[YCO5WZOH[,(=\Q_H[=?U=GGM5YY#O6'^GKK][E>'[K]3UM^IZ^_*V=4YY#O6 +MWZGK[\`<\AWK[]3U=V`.^8[U=^KZNSSWNLXAW['^3EU_]SK/%>[0_7?*^CMU +M_=WKQ-WKRAWR'>OOU/5WKQ-WKRMWR'>LOU/7W[T^+LX.^8[U=^KZNW)V=0[Y +MCO5WZOH[,(=\Q_H[=?T=F$.^8_V=NOXNS[VI<\AWK+_3J+\S=/^=LOY.H_[. +MT/UWROH[C?H[0_??*>OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ.XWZ +M.T/WWRGK[Y3T=V_K'/(=Z^_4]7=O\USA#MU_IZR_4]??O4WVNOP-SR'>LOU/7 +MWX$YY#O6WUG^B9L[USG@.V/]W?4G[G&7_72NW`'?&>OOS/5WY[1W+MRA^^^, +M]7?F^KMSXNYNORMG5^>`[XSU=^;Z.S`' +M?&>LOS/7WX$YX#MC_9VY_B[/29T#OC/6WYGK[R3/%>[0_7?&^CMS_9VDUY/* +M'?"=L?[.7'\GB3NIW`'?&>OOS/5W5 +M.^0[UM^9Z^\L<6>5.^0[UM^9Z^_LN#@[Y#O6WYGK[\K9U3GD.];?F>OOP!SR +M'>OOS/5W8`[YCO5WYOJ[/-?4.>0[UM^9Z^^:/%>Y0[YC_9VY_JY)W#6%.W3_ +MG;'^SEQ_UR3NFL(=NO_.6']GKK]K#G]VZ/X[8_V=N?ZNG%V=0[YC_9VY_@[, +M(=^Q_LYNO\MS;9U#OF/]G;G^KLUSA3MT_YVQ_LYZ.H=\Q_H[<_U=E^X0_??&>OOS/5WW>'/#MU_9ZR_,]??E;.K<\AWK+\SU]^! +M.>0[UM^9Z^_`'/(=Z^_,]7=YKJ]SR'>LOS/7W_5YKG"'[K\SUM^9Z^_ZQ%U? +MN4.^8_V=N?ZN3]SUE3OD.];?F>OO^N/B[)#O6']GKK\K9U?GD.]8?V>NOP-S +MR'>LOS/7WX$YY#O6WYGK[_+<4.>0[UA_9ZZ_&_)OOS/5WY>SJ'/(=Z^_,]7=@ +M#OF.]7?F^CLPAWS'^CMS_5V>>U?GD.]8?V>NOWN7YRIWR'>LOS/7W[U+W+TK +MW*'[[XSU=^;ZNW>)NW>%.W3_G;'^SEQ_]^[P9X?NOS/6WYGK[\K9U3GD.];? +MF>OOP!SR'>OOS/5W8`[YCO5WYOJ[//>^SB'?L?[.7'_W/L\5[M#]=\;Z.W/] +MW?O$W?O*'?(=Z^_,]7?O$W?O*W?(=ZR_,]??O3\NS@[YCO5WYOJ[LOS/7WWW(OOS/5W8`[YCO5WYOH[,(=\Q_H[<_U=GOM8YY#O6']GKK_[F.<*=^C^ +M.V/]G;G^[F/B[F/E#OF.]7?F^KN/B;N/E3OD.];?F>OO/AX79X=\Q_H[<_U= +M.;LZAWS'^CMS_1V80[YC_9VY_@[,(=^Q_LYOOS/5WGX^+LT.^ +M8_V=N?ZNG%V=0[YC_9VY_@[,(=^Q_LY:YR!WQW_13FKG']W9?$W9?,77/&3Y&_]]A]L5]R;_RFS*&_;[L\%#MW\W[-MW#L^J.[_M_3[0^]W^^.XV\;F$-_7_G_Z\N] +MG;/+MVN_6:63TZG74]^[YX?^ +M./BO>K_N!\Y/[YS?[6^2N^=WNOM^Z,]N_;KW^^[Y]7;J>\!F/;__^=];$//[ +C_<;GUYW3^9TG\$_^B:^_O+G_G]O!YMO@3_\'*;=.DB.F```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow2.gz.uu new file mode 100644 index 000000000000..0caab8bdc681 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-apm.qcow2.gz +M'XL(")T[(U0``VEM9RTQ>#$M-#`Y-BUA<&TN<6-O=S(N;W5T`*V826_;,!!& +M[_D53/>F32K.D)35/9N!'@JD#7H.O,A`@"Y&&J`7__A2ULB4J1DQ-N0(1@SB +M>Q@/GT>FLZQ^*&6U,DZ90BVFRK^F"U3KQ?:E5M_&7T[:C]5!#=.9D&(6#&YP +M6ZSS@`,)E^GN@N9QK>J0P4&3ZH)2."-6U[?`X(X.UJU;;\8H2N`^P!HG;L9> +M]4%=7YPP>]8'0]>'?/]LDXL77']]6-<7IW()-TKB@$D5$FZ2Q"&3FDJX61)G +MF-1Z;1W4R8E>:?3WLV8E.2=3GLW9U*2=R!XIP*N9%*2=Q!Y=TBX1P&W8%*2 +M=Q!Y]YAP3S8XS:4D[R#R[BGAG@4<,^]`\@XB[YX3[D7`,?,.).\@\NXEX8X" +MCIEW('D'D7>O"/8>2=QAY9PGG`HZ9=RAYAY%W.>%&`8>2=QAY]X%P'P..F76X4YW*[/#GT@L+4P?C*; +M>2>'TH'/+ZRNOC+]L[4P_N/@IZF_W$PY^Z#Z3I?+GR6#DT^WNQ^G/`Z[U=G% +M^G\O2PXJ-\H5].P6RI75,E5WLYSW_[Y?=/@JANDFU?A?)?J?DV6;'5V +MX+TU#]S;YGX!!-S>6]749X9VSZRWPU6-]QOA+S\N+593SG_-4-96:Q:[P/%= +M69Y=7QS_&%^W^V>&_;'!^A-5NG_0ZE_](6GW3[7K5YXR;H7]_ +J_]4B-O4-W#^=4?_\2;W[+"^LKDZV_VJ@(>!@%1I73>>#_Z4*H1'E$P`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-apm.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-apm.raw.gz.uu new file mode 100644 index 000000000000..3f148c01beb4 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-apm.raw.gz.uu @@ -0,0 +1,12 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-apm.raw.gz +M'XL(".W%'50``VEM9RTQ>#$M-#`Y-BUA<&TN6#-2,^JH4 +MR/L%LWH;`CW.Z2,.S5RJ3R@Y2]]3UWVU$SB1ZW,]KAJKD]OS.P>T@":HQW"J +M+53KRD'=IJN/I]UI=]AO(HXL3C6N6?]'W7?=3:J3F6=+,V>[B$L9@/W9(NJC +MW+M'YW$H9[P=A$T2D!6((!HK7+J:O8^`RV/;/J]?'CZ6Z]0_HLSZU`S_1.*? +M_TE2_Y#J4[G]4S?]TQ6TGMC-BW\_OWX1H[[,_G$6_&/UQ'F]8%9E__%`"L!L +."DDX8/$'F8$ZXZ<%```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-apm.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-apm.vhd.gz.uu new file mode 100644 index 000000000000..324579020e61 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-apm.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-apm.vhd.gz +M'XL(".W%'50``VEM9RTQ>#$M-#`Y-BUA<&TN=FAD+F]U=`"M5EUOVR`4?<^O +MN-+>*BT"#+A[7-7F;5*U:L\M#N=^ +M`"'N`9`-R!ZD!BEPW'*0WZ"]!C"3OC';4_\*A^[M57?[S%`Z,DM1J: +MHSUK@)M%6F`*%Y%K',,AP"R_W#U?;5Z>`QSS<&%A+H$S$`:$3]:1Y,@.D58W +M#[<6\BFR:Z;LHI7Y_^9`.%":?-$$=D]'CD\[ +M/>+'"J$BC_SH9*XI;Y?Y4&'A8\^`8SC/;1'P,<%BHLM1;Q='8O:IME)RK[5I_HV^LD3\C$ +MMQ#XZ=JQIZT[)`J/)Z2(9Q!;&^("Y\S[!'#UKK4YA;[^6CVD^FE>EQ\E)^C' +M$OU'29N)S:C?[J\+Q,"OMG[*ZT=4IB]/'.Z7PY\# +M9+Z85JO.+%:_.@RY!ZS&D,<NJ*WW)JG351;B*5UV$JWK5E;:@+OX!7ZN]MA\-```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdf.gz.uu new file mode 100644 index 000000000000..3e83de7755bf --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-apm.vhdf.gz +M'XL(".W%'50``VEM9RTQ>#$M-#`Y-BUA<&TN=FAD9BYO=70`K571:L(P%'WW +M*R[L35A)DYM;][@Q?1O(9,]:;2N%J<4)VT,_?DF3V-16<2/I)23,NXEZ_G8):.`T/XPA83IH`R3OXO=<59_Y`!P/M5T#)_KL9-&,8X"$0X)` +M3[:G`BC7:G/R%W2ZM!MG)P-[BG=Y.[(!;P*ZW +MX/AAZ+.'C1VDA5=&J$`.4@`B\$P1ESJGYCW`V3'/7Q:OCQ^SA:\?8F!^=(=^ +MW-//7!)?/_#Y46C]Z*9^B8`D&3B;K7Y?W^8@.GZ!]8N9U8^E`_WU1#V/NH\! +M1`L8C"'9ZDS"WG4MHG`U8.(#\M;>!G!SV.>;4_GCWV"RU;DHAD.OYT+_"R@! +MGC8E)M-CC]_#=#LN=UL'YZJ?^[#R^FSQY2ZIN]V9,KB!7+7L1%\D\M5;(S"$ +M..YLW+);^>H9.#QO-B]@+1N:+CJ33F*P-FNXIOKY+__76P-'@8^*^E&.?@&@ +'6R\`T@<````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-apm.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-apm.vmdk.gz.uu new file mode 100644 index 000000000000..4b6923a8c6ff --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-apm.vmdk.gz.uu @@ -0,0 +1,82 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-apm.vmdk.gz +M'XL(".[%'50``VEM9RTQ>#$M-#`Y-BUA<&TN=FUD:RYO=70`K9Q;;]S($87? +M_2L([\LB0`2>X?W!0-:1#03!`L9ZDSQN>(V%V)8@"4D,S(\/F^S3.I1$-[$J +M[V@YY:FJZ:X>E>2O#IBFZY\DR;LDSY-\2(HR29',?[4^DC1[,.;'J>8+Y[]> +M_OSW"_[Y\>+B_&I-!AF!^G:+K,175/`GVZ +MT\X+N^GR^<73UN]GNK^\,K7SRWOLRM83[> +MLDFJ+"D[;R9EL=A94IV6U]*DFIVF.>$/R>75W;^3R_&NO[VZN;_VZSNYLYV= +M\]+YE[W+,&^L*MT3]X)+U[@4Y9AD0Y+!O9R<;]]??1XO_C/>WEU=?WT#;O?D +MSC;/DKQQRW'^Z<-C8[@W29,2[CV2\Y__ +MLDSDR).J29;E%"[W:7YY\%M>:M?? +MCNW]^.NWF_'-ZR_77T/MW-FZDC5+HGHI5)84F4OEM^;*5[B,[F.SG%IR_GQU +M_^FJ_SAO\VY\??%#PG2EJ]U\@+5?U[KK.:3=W_[N?]YL,_F2OF&Y9 +MQ+*)^;V+4U)4+M=\@,M1G)(L=\_FOYH7/.\DAW-*SM=?+W[YQ_PM[HKU\<-/ +MOS!=/4?-GO,"YY!Y0YL]%>O^B\M\G;]FZ\^.'R\FTXV=9M-E\>\])&EZ5<4[O/ +M]U+.N7#K2:\'O1S%,'07[=#>W(^W[GC#472N1(/?J3O6_.$8M^]3+2'JBUY[WRZ +M+/4M(/.M;%.BL)SU#:6!COW]]>VZL-?2C[/'/\M>VH_S)S]2J]^9<$UGO;XR +M??3S+-.X7(QBD]#]%$OGKS_-7Q\>UE>Z]97B66E4+4:S2??/.<7-T^V6[KNP +M%<].HWHQAB/5*UUK&\5S>EP]_JH!>;Z?CK\+T#/3J%R,8I-NKW:%KQT]*XVJ +MQ6@VZ?9J5_K:T;/3J%Z,X=!F*U\[>DX:Y2[\50KI@5_+RMK7CIZ91N5B%)MT +M>[5K?.WH66E4+4:S2;=7N];7CIZ=1O5B#(-F4;D8Q2;=7NW8[^A9:50M1K-)MU<[ +M]CMZ=AK5BS$IK1\],HW(QBDVZG=K5['?TK#2J +M%J/9I-NI7F8:E8M1;-+MU8[] +MCIZ51M5B-)MT>[5COZ-GIU&]&,.AS;+?T7/2*'?AOY\@S_?3L=_1,].H7(QB +MDVZO=NQW]*PTJA:CV:3;JQW['3T[C>K%&`YMEOV.GI-&N0OY(^3Y?CKV.WIF +M&I6+46S2[=6._8Z>E4;58C2;='NU8[^C9Z=1O1C#H_H.6F4 +MNPQ2NR&:COV.GIE&Y6(4FW1[M6._HV>E4;48S2;=7NW8[^C9:50OQG!HL^QW +M])PTREU&J=T83<=^1\],HW(QBDVZO=JQW]&STJA:C&:3;J]V['?T[#2J%V,X +MM%GV.WI.&N4ND]1NBJ9COZ-GIE&Y&,4FW5[MV._H66E4+4:S2;=7._8[>G8: +MU8LQ'-HL^QT])XU*97H&>;Z;KDW7V@7/3*-R,8I-NIW:M;[?!<]*HVHQFDVZ +MG=JUOM\%STZC>C&&0YOU_2YX3AKE2B;\#E&DU?I^!^%W4'X'X7>(\KO6]SL( +MOX/R.PB_0Y3?M;[?0?@=E-]!^-V!S?I^!^%W4'X'X7>((JW6]SL(OX/R.PB_ +M0Y3?M;[?0?@=E-]!^!VB_*[U_0["[Z#\#L+O#FS6]SL(OX/R.PB_0Q1IM;[? +M0?@=E-]!^!VB_*[U_0["[Z#\#L+O$.5WK>]W$'X'Y7<0?G=@L[[?0?@=E-]! +M^!VB2*M+?>V$WT'Y'83?(^$WT'Y'83?(8JT.O8[X7=0?@?A=XCRNX[]3O@=E-]!^!VB_*YCOQ-^ +M!^5W$'YW8+/L=\+OH/P.PN\015H=^YWP.RB_@_`[1/E=QWXG_`[*[R#\#E%^ +MU['?";^#\CL(OSNP6?8[X7=0?@?A=X@BK3[UM1-^!^5W$'Z'*+_KV>^$WT'Y +M'83?(O8[X7=0?@?A=P^$WT'Y'83? +M(O8[X7=0?@?A=XCRNY[]3O@=E-]!^-V!S;+?";^#\CL(OT,4:?7L=\+O +MH/P.PN\0Y7<]^YWP.RB_@_`[1/E=SWXG_`[*[R#\[L!FV>^$WT'Y'83?(8JT +MAM373O@=E-]!^!VB_&Y@OQ-^!^5W$'Z'*+\;V.^$WT'Y'83?'=@L^YWP.RB_ +M@_`[1)'6P'XG_`[*[R#\#E%^-[#?";^#\CL(OT.4WPWL=\+OH/P.PN\.;);] +M3O@=E-]!^!VB2&M@OQ-^!^5W$'Z'*+\;V.^$WT'Y'83?(2[IDO7+IQO3M7;/2LJ?^:M0N^39U8W&^D`L +M^L`P4UAW]?L2KNFLUQ?FVWR\2+^(,-_FXT7Z183Y-A\OTB\BS+?Y>)%^$6&^ +M;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%A +MOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X1 +M8;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^ +M$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X1G&_;Z!?!^;:-?A&<;]OH%\'YMHU^ +M$9QOV^@7P?FVC7X1G&_;Z!?!^;:-?A&<;]OH%\'YMHU^$9QOV^@7P?FVC7X1 +MG&_;Z!?!^;:-?A&<;]OH%\'YMHU^$9QOV^@7P?FVC7X1G&_;Z!?!^;:-?A&< +M;]OH%\'YMHU^$9QOV^@7P?FVC7X1G&_;Z!?!^;:-?A&<;]OH%\'YMHU^$9QO +MV^@7P?FVC7X1G&_;Z!?!^;:-?A%AODW/%^D7$>;;]'R1?A%AODW/%^D7$>;; +M]'R1?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI% +MA/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z +M183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF +M^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$9QOV^@7,9KJ%S&:ZAP@?3/=WLJ@_, +ME_7EA;MWJ=[K=[VK\7<2OOO%I?GQT?IR\_4M]^MUMU<=GL1EFA#;%\X??GZN +M?OERO]Y\N:VINXWI>K_>`^O[Z>;F\_A,NB?W8OZ]VUW394]75TS^1K_+G3MS +MWBV7]Q0N)J[NMYOV]O[J_NKZZV],M]RO=_"W<3V^NB_MS;.K,[X7?+<92\WW'A[J);+'?4/0WSP@OW6I$]3?C^=AS??KS\ +MX]_>?]3ZY;GQ^LH#]5-IR/I-HO5+='W6VN.\_&[]JBRIJF<^FP_UN_OO^D'D +J^HSK5Z2^?N[^SD_^O__"^X3FJTP=S>?35_]'S/@3HZ37@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow.gz.uu new file mode 100644 index 000000000000..e9033f43a71f --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow.gz.uu @@ -0,0 +1,125 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-bsd.qcow.gz +M'XL("*LS(E0``VEM9RTQ>#$M-#`Y-BUB87<]F9EM\KOD!^OA1*2/=Z??=MM=K8:MBNAFEU.:R^_WK^;JN??G'_^^K;__S7?[_]^=NW/^[& +M;/V+I]*O!U_Y/'=OZQ^K-N=_/75W/7]'9=O-U)S>U_"8L+6`YJ[EC,#?C42<6=\5.".Z^X +M,_*=*^Z\XL[(=ZZX\XH[(]^YXLXK[HQ\YXH[K[@S\ITK[J+BSLAWH;B+BCLC +MWX7B+DKNR'>AN(N2._)=*.ZBY(Y\%XJ[*+DCWX7B+DKNR'>AN(N2._)=*.Z& +MDCORW:"X&TKNR'>#XFZHN'-^2G`W5-PY^6Y0W`T5=TZ^&Q1W0\6=D^\&Q=U0 +M<>?DNT%Q-U3<.?EN4-QM*NZ6W)'O1L7=6'$W\%."N['B;B#? +MC8J[L>)N(-^-BKNQXFX@WXV*N['B;B#?C8J[L>)N(-^-BKOEK[_U'/EN4MQ- +M%7<#^6Y2W$TE=^2[27$WE=R1[R;%W51R1[Z;%'=3R1WY;E+<325WY+M)<3>5 +MW)'O)L7=ON2.?+=7W.U+[LAW>\7=ON)NPT\)[O85=QORW5YQMZ^XVY#O]HJ[ +M?<7=AGRW5]SM*^XVY+N]XFY?<;2 +M._+=07%W*+DCWQT4=X>2._+=07%W*+DCWQT4=X>2._+=07%W*+DCWQT4=\>2 +M._+=47%W++DCWQT5=\>*NRT_);@[5MQMR7='Q=VQXFY+OCLJ[HX5=UORW5%Q +M=ZRXVY+OCHJ[8\7=EGQW5-R=*NZVY+N3XNY4<;2._+=27%W*KDC +MWYT4=Z>2._+=27%W*KDCWYT4=Z>2._+=27%W*KDCWYT4=^>2._+=67%W+KDC +MWYT5=^>*NQT_);@[5]SMR'=GQ=VYXFY'OCLK[LX5=SORW5EQ=ZZXVY'OSHJ[ +M<\7=CGQW5MQ=*NYVY+N+XNY2<;2._+=17%W*;DCWUT4=Y>2._+= +M17%W*;DCWUT4=Y>2._+=17%W*;DCWUT$=[;\1,^![VPMN+-UR1WXSM:".UM7 +MW(W\%'-G97\W@N],]7=6]G"[TSU=U;V=R/XSE1_9V5_-X+O +M3/5W5O9W(_C.5']G97\W@N],]7=6]G"[TSU=U;V=R/XSE1_ +M9V5_-X+O3/5W5O9W(_C.5']G97\W@N],]7=6]GKOK.SO]N0[U=]9V=_MR7>JO[.RO]N3[U1_9V5_MR??J?[. +MROYN3[Y3_9V5_=V>?*?Z.RO[NSWY3O5W5O9W>_*=ZN^L[._VY#O5WUG9W^W) +M=ZJ_L[*_VY/O5']G97^W)]^I_L[*_FY/OE/]G97]W8&?$MR5_=V!?*?Z.RO[ +MNP/Y3O5W5O9W!_*=ZN^L[.\.Y#O5WUG9WQW(=ZJ_L[*_.Y#O5']G97]W(-^I +M_L[*_NY`OE/]G97]W8%\I_H[*_N[`_E.]7=6]G<'\IWJ[ZSL[P[D.]7?6=G? +M'[*_NY(OE/]G97]W9%\I_H[ +M*_N[(_E.]7=6]G='\IWJ[ZSL[X[D.]7?6=G?'KOK.SOCN0[U=]9 +MV=\=R7>JO[.ROSN2[U1_9V5_=^*G!'=E?WKOK.SO3N0[U=]9V=^=R'>JO[.ROSN1[U1_9V5_ +M=R+?J?[.RO[N1+Y3_9V5_=V)?*?Z.RO[NQ/Y3O5W5O9W)_*=ZN^L[.].Y#O5 +MWUG9WYW(=ZJ_L[*_._-3@KNROSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9 +M?*?Z.RO[NS/Y3O5W5O9W9_*=ZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_.Y/O5']G +M97]W)M^I_L[*_NY,OE/]G97]W9E\I_H[*_N[,_E.]7=6]G=G\IWJ[ZSL[\[D +M.]7?6=G?7?@IP5W9WUW(=ZJ_L[*_NY#O5']G97]W(=^I_L[*_NY"OE/]G97] +MW85\I_H[*_N["_E.]7=6]G<7\IWJ[ZSL[R[D.]7?6=G?7;.4W^WW*>W +MZMR![USU=Y[ZN]7,W6KA+M;\%'/GJ;];S=RM_FQSX#M7_9VG_FYU36<7=/^= +MJ_[.4W_7SJ[/@>]<]7>>^CN8`]^YZN\\]7]"Y`]^YZN\\]7=.[`=Z[Z.T_]W8/K +MS=F![USU=Y[ZNW9V?0Y\YZJ_\]3?P1SXSE5_YZF_@SGPG:O^SE-_M\P]['/D +M.]7?>>KO'BYSG3ORG>KO//5W#V?N'C;NZ/X[5_V=I_[NX]4?^>IOX,Y\IWJ[SSU=\O< +MHSY'OE/]G:?^[M$RU[BC^^]<]7>>^KM',W>/.G?D.]7?>>KO'LWK]4 +M?^>IOWMTO3D[\IWJ[SSU=^WL^ASY3O5WGOH[F"/?J?[.4W\'<^0[U=]YZN^6 +MN<=]CGRG^CM/_=WC9:YS1[Y3_9VG_N[QS-WCQAW=?^>JO_/4WSV>N7OKO//5W,$>^4_V= +MI_YNF7O2Y\AWJK_SU-\]6>8:=W3_G:O^SE-_]V3F[DGGCGRG^CM/_=V3F;LG +MG3ORG>KO//5W3ZXW9T>^4_V=I_ZNG5V?(]^I_LY3?P=SY#O5WWGJ[V".?*?Z +M.T_]W3+WM,^1[U1_YZF_>[K,=>[(=ZJ_\]3?/9VY>]JXH_OO7/5WGOJ[IS-W +M3QMW=/^=J_[.4W_W])K/CNZ_<]7?>>KOVMGU.?*=ZN\\]7JO_/4WRUSS_H<^4[U=Y[ZNV?+7...[K]SU=]YZN^>S=P]Z]R1[U1_YZF_ +M>S9S]ZQS1[Y3_9VG_N[9]>;LR'>JO_/4W[6SZW/D.]7?>>KO8(Y\I_H[3_T= +MS)'O5'_GJ;];YI[W.?*=ZN\\]7?/E[G.'?E.]7>>^KOG,W?/&W=T_YVK_LY3 +M?_=\YNYYXX[NOW/5WWGJ[YY?\]G1_7>N^CM/_5T[NSY'OE/]G:?^#N;(=ZJ_ +M\]3?P1SY3O5WGOJ[9>Y%GR/?J?[.4W_W8IEKW-']=Z[Z.T_]W8N9NQ>=._*= +MZN\\]7=.[(=ZJ_\]3?O;C>G!WY3O5WGOJ[=G9]CGRG^CM/_1W,D>]4 +M?^>IOX,Y\IWJ[SSU=\O>KO7L[>^CN8(]^I_LY3?[?,O>ISY#O5WWGJ[UXM>^KM7UYNS(]^I_LY3?]?.KL^1[U1_YZF_ +M@SGRG>KO//5W,$>^4_V=I_YNF7O=Y\AWJK_SU-^]7N8Z=^0[U=]YZN]>S]R] +M;MS1_7>N^CM/_=WKF;O7C3NZ_\Y5?^>IOWM]S6=']]^YZN\\]7?M[/H<^4[U +M=Y[Z.Y@CWZG^SE-_!W/D.]7?>>KOEKDW?8Y\I_H[3_W=FV6N<4?WW[GJ[SSU +M=V]F[MYT[LAWJK_SU-^]F;E[T[DCWZG^SE-_]^9Z>KOVMGU.?*= +MZN\\]7JO_/4WRUS;_L<^4[U=U[U=T'WW[GJ[[SJ[X+N +MOW/5WWG5WP7=?^>JO_.JOPNZ_\Y5?^=5?Q=T_YVK_LZK_B[H_CM7_9U7_5W0 +M_7>N^CL7_=V[/D>^4_V=I_[NW3+7N*/[[USU=Y[ZNW +MS=R]Z]R1[U1_YZF_>W>].3ORG>KO//5W[>SZ'/E.]7>>^CN8(]^I_LY3?P=S +MY#O5W\7RDS2W[G/@NU#]W?^"]7?1>KOUO/>NG%']]^%ZN\B +M]7?KF;MUXX[NOPO5WT7J[];7?'9T_UVH_BY2?]?.KL^![T+U=Y'Z.Y@#WX7J +M[R+U=S`'O@O5WT7J[Y8YZW/@NU#]7:3^SI:YQAW=?Q>JOXO4W]G\\JQS![X+ +MU=]%ZN]LYLXZ=^"[4/U=I/[.KC=G![X+U=]%ZN_:V?4Y\%VH_BY2?P=SX+M0 +M_5VD_@[FP'>A^KM(_=TRYWV.?*?ZNTC]G2]SG3ORG>KO(O5W/G/GC3NZ_RY4 +M?Q>IO_.9.V_J +MOXO4W\$<^4[U=Y'ZNV4N^ASY3O5WD?J[6.8:=W3_7:C^+E)_%S-WT;DCWZG^ +M+E)_%S-WT;DCWZG^+E)_%]>;LR/?J?XN4G_7SJ[/D>]4?Q>IOX,Y\IWJ[R+U +M=S!'OE/]7:3^;ID;^ASY3O5WD?J[89GKW)'O5'\7J;\;9NZ&QAW=?Q>JOXO4 +MWPTS=T/CCNZ_"]7?1>KOAFL^.[K_+E1_%ZF_:V?7Y\AWJK^+U-_!'/E.]7>1 +M^CN8(]^I_BY2?[?,;?H<^4[U=Y'ZN\TRU[BC^^]"]7>1^KO-S-VF^4_U= +MI/YN,W.WZ=R1[U1_%ZF_VUQOSHY\I_J[2/U=.[L^1[Y3_5VD_@[FR'>JOXO4 +MW\$<^4[U=Y'ZNV5NV^?(=ZJ_B]3?;9>YSAWY3O5WD?J[[KO +M(O5W,$>^4_U=I/YNF=OU.?*=ZN\B]7>[9:YQ1_??A>KO(O5WNYF[7>>.?*?Z +MNTC]W6[F;M>Y(]^I_BY2?[>[WIP=^4[U=Y'ZNW9V?8Y\I_J[2/T=S)'O5'\7 +MJ;^#.?*=ZN\B]7?+W-CGR'>JOXO4WXW+7.>.?*?ZNTC]W3AS-S;NZ/Z[4/U= +MI/YNG+D;&W=T_UVH_BY2?S=>\]G1_7>A^KM(_5T[NSY'OE/]7:3^#N;(=ZJ_ +MB]3?P1SY3O5WD?J[96[J<^0[U=]%ZN^F9:YQ1_??A>KO(O5WT\S=U+DCWZG^ +M+E)_-\W<39T[\IWJ[R+U=]/UYNS(=ZJ_B]3?M;/K<^0[U=]%ZN]@CGRG^KM( +M_1W,D>]4?Q>IOUOFWOKOWE_SV=']=Z'ZNTC]73N[/D>^4_U=I/X.YLAW +MJK^+U-_!'/E.]7>1^KME[D.?(]^I_BY2?_=AF6O1^KMV=GV.?*?ZNTC]'KO(O5WR]S'/D>^4_U=I/[NXS+7N2/?J?XN4G_W<>;N8^.. +M[K\+U=]%ZN\^SMQ];-S1_7>A^KM(_=W':SX[NO\N5'\7J;]K9]?GR'>JOXO4 +MW\$<^4[U=Y'Z.Y@CWZG^+E)_M\Q]ZG/D.]7?1>KO/BUSC3NZ_RY4?Q>IO_LT +M<_>I^4_U=I/[NT\S=I\X=^4[U=Y'ZNT_7F[,CWZG^+E)_U\ZNSY'O5'\7 +MJ;^#.?*=ZN\B]7JOXO4WWU>YCIWY#O5WT7J[S[/ +MW'UNW-']=Z'ZNTC]W>>9N\^-.[K_+E1_%ZF_^WS-9T?WWX7J[R+U=^WL^ASY +M3O5WD?H[F"/?J?XN4G\'<^0[U=]%ZN^6N2]]CGRG^KM(_=V79:YQ1_??A>KO +M(O5W7V;NOG3NR'>JOXO4WWV9N?O2N2/?J?XN4G_WY7IS=N0[U=]%ZN_:V?4Y +M\IWJ[R+U=S!'OE/]7:3^#N;(=ZJ_&Y:?I+FO?0Y\-ZC^;DC]W==EKG,'OOO^ +M%',WI/[NZ\S=UX6[8Q6PV:UV:Y&_]U7^'___-_T"N_F_K8W +M?#='7V#\WEQ[P?8[?/\X\O4?[]O\:6OW!/-U>VS^^JOSZ*F.^]W5^\OM7MV_TA +MT=W]WV\_S7GQ=E?WYPZ__-S^^M4]N'UU]$6\_Y-/QLW5(;_Y)_>OD?M_Z'6?[RW!Y^U!_X]J^W]_^Y&QQ^#/[Q_[+N5S>!I0`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow2.gz.uu new file mode 100644 index 000000000000..34b715e64dc3 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-bsd.qcow2.gz +M'XL(")X[(U0``VEM9RTQ>#$M-#`Y-BUBS)=F +M0E'$EW.E=Z%RH7'[C7O\+`>YWH?AX0Z_?_Q<]E^'183Y`J2,@<`=;L"Z2SA" +MN,*/![R-ZU7'!HY.J3$HAPNPNJD!`W>].%ZZXV+4*L&7`",.+L9%]5&L3R?" +MA?71W/6Q??W*4TX/5-/U<:Q/IU8(5V=Q9*0:A%MG<6RD-@BWS>*"D7I`N%T6 +M5QJI/<#YC"J/N,I(>82C+&YEI!CA0A97&RGDG<][UQ@IY)W/>[]\WKL'(X6\(^"=2[B=D4+>D?+N2G!/$FYOI)!WI+Q[*KAG +M'0=*>^>"^Y%PAG]CI!WI+Q[*;A7"6?T.T+>D?+NM>"N$\[H=X2\(^7= +M&\&]33BCWQ'RCI1W[T;>>:/?$?*.E7?OA54DG-'O&'G'RCLO.$HXH]\Q\HZ5 +M=RRXD'!&OV/D'2OO2L%5"6?T.T;>L?)N);@ZX8Q^Q\@[5MXU@ON0<$:_8^0= +M*^\^"NY3PAG]CI%WK+S[++B;A#/Z'2/O@O+NB^"^)IS1[P+R+BCOO@GN-N&, +M?A>0=T%Y=R>X[QV.K%3G75'8A^#N1_1D#Q?ZFB_=;XC`<.OY;#=P0&`#$M-#`Y-BUB)W-9:9S8V(RC/=PB6![!-2XK +MB+1J22ZXE&/"U9Y5KSB54V<1^/ZK6%WJ[N;>=IN\L,^`'\`!L/,^XL"EO[#J +MN\0RB)6;T0=QN;W#M3Q>!CC:*1CV4[&P#$M-#`Y-BUB?T)1?GU5Y/EY6^FD6'8PSV\HU)WM, +M0*A),L"")I%[:D-C,*N'S6%Y_#@8'&J1X:P3?-V]3ZUL& +MTN6/NZ/$:[A>,+\%E^B]:U&2`1?JZ'!,L]B`$W/J*&>JNYQ-(R=SF8_L['4& +M7@/?`\NMK+:`_?K"H._1EX&.NS/ZP'>W(%SFCN<6#J^X"RYN-[NV\^J8KZZ, +MO!C[\<2Q-VY'0[C'@38GBPJ`]4HOPYW-"\K]^V`J(^J:&)`D7\2))N*@7 +02:G^(C"V^`74/'YQ?0P````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-bsd.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-bsd.vhdf.gz.uu new file mode 100644 index 000000000000..66607656c3de --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-bsd.vhdf.gz.uu @@ -0,0 +1,13 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-bsd.vhdf.gz +M'XL("._%'50``VEM9RTQ>#$M-#`Y-BUBJW6G2=-VJX%"E4/W2X[[)`?OQ@"Q'RUFPA1!'+\\-I.+$0[ +M`+0"D<^LRP9[B/ECHUW4T!0!30K:@$'(W'8Q3/;!#/;C^!Z'PWJ<7/-:QL6C +MT>'4/5PO6#Z"2\A+,DHRX)8,+4YXEAAP>DV=RX2H_A2LV2IW76VSD5]89Y`U +MR#.(S-L4!_;UA4'??BI#L7!7],$TW)QP*=\O`YRZ$RYP7+%:VW5U8JJNW+@8 +MR?AF/'AS"<)O;HM3VS8"U706=P+=KNFZ;+"O,7]:H/;`S3*(OO=A`E@#5H"& +MWE,-N('MND*=!73)-$H;9*S0(#5*RP+VZ$S_. +IA--]L%4-A6ED=I-],,-LJR*<$2.O_]:VQ>'&1\4=ON@7D=A:0S`'```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-bsd.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-bsd.vmdk.gz.uu new file mode 100644 index 000000000000..ac4864b37817 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-bsd.vmdk.gz.uu @@ -0,0 +1,81 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-bsd.vmdk.gz +M'XL("._%'50``VEM9RTQ>#$M-#`Y-BUB[P^'\9@D&YR4N2#6<+%;/JP>FVS$:+G->[86C#W?< +M>&`S7#X]>'S.A;L[S0_W[D+")2%0L@I7/)/39K(O[>Y/;WSQW/XRMX?I>,LF +MJ;*D;/TR*8MYG275<7XL3:K):)P"ODVN;^[_DUP/]]W=S8^'6[^_HSO;R3@O +MG7W9N0A38E7I+MP#+ESC0I1#DO5)!O=P[^YO;[>S#=HSO; +M/$ORQFW'V:>/M]7"/4F:E'#/D9S_^O?K]_Z5FQY^G.X8SGE-&YF>>\I#XY9E +MXKXO;_/NAN\/+N+HO\+NW-GZXA3S<^?NHLB3JDGF[10N]G%ZN/RF4\M.7^]>?AR +MTWV>TKP?K@YO$X8K7>VF`ZS]OI:L)Y=R\V2G;9\__N]ARC?I_,-R\B3F) +MZ;F+8U)4+M9T@/-1'),L=U?3/TT;GC+)X8R2\^WWPR^_3V]Q5ZS/G_[R"\/5 +MD]=D.6UPWW](9SLR26;S[=I:X.+4BZAW>M[+N=4 +MN.6DEX.>CZ+OV\.I/_UX&.[<\8:C:%V)>I^I.];\\1C7SU/-)S6Z5TQR?I]< +MW?33F;JP_QYNOS%X?JE=M-VEM-\/,SI`*<=/KO!J797\ZF&[3'VT_SB]^I%9_,.`2SGI_9?KDYUFF +M?KDLBE5`]U,LG;[_/'U_>MQ?Z?97BF6E7K4LFE6X?TTA?ERF6[IWX4DL6_7J +M9-'OJ5[I6ML@EN/3ZO%7#.EJUZ=;+H=R7;^MK1#M?YVM$R4Z]< +M%L4JW%;M>E\[6E;J5[RZ5V>2Q< +ME?K:T3)3KUP6Q2K<1NTJ]CM:5NI5RZ)9A=NH7<5^1\M6O3I9]+N29;^CY:A> +M[JZ0VA71<.QWM,S4*Y=%L0JW53OV.UI6ZE7+HEF%VZH=^QTM6_7J9-'O2I;] +MCI:C>KF[4FI71L.QW]$R4Z]<%L4JW%;MV.]H6:E7+8MF%6ZK=NQWM&S5JY-% +MORM9]CM:CNKE[OA+$.1Z.QS['2TS]#L=^1\M,O7)9%*MP +M6[5COZ-EI5ZU+)I5N*W:L=_1LE6O3A;]KF39[V@YJI>[(W^$7&^'8[^C9:9> +MN2R*5;BMVK'?T;)2KUH6S2K<5NW8[VC9JEUHF:E7+HMB%6ZC=@W['2TK]:IET:S";=2N8;^C9:M>G2SZ7G6RZ'+?E>R['>T'-4KE>D9Y'HSW"E=:A^$WT'Y'83?[4B6 +M_4[X'93?0?@=HDBK9;\3?@?E=Q!^ARB_:]GOA-]!^1V$WR'*[UKV.^%W4'X' +MX7<[DF6_$WX'Y7<0?H^$WT'Y'83?(8JT6O8[X7=0?@?A=XCRNY;]3O@=E-]!^!VB +M_*YEOQ-^!^5W$'ZW(UGV.^%W4'X'X7>((JTN];43?@?E=Q!^ARB_Z]COA-]! +M^1V$WR'*[SKV.^%W4'X'X7<[DF6_$WX'Y7<0?H^$WT'Y'83?(8JT.O8[X7=0?@?A +M=XCRNX[]3O@=E-]!^!VB_*YCOQ-^!^5W$'ZW(UGV.^%W4'X'X7>((JV._4[X +M'93?0?@=HORN8[\3?@?E=Q!^ARB_Z]COA-]!^1V$W^U(EOU.^!V4WT'X':)( +MJT]][83?0?D=A-\ARN]Z]COA=U!^!^%WB/*[GOU.^!V4WT'XW8YDV>^$WT'Y +M'83?(8JT>O8[X7=0?@?A=XCRNY[]3O@=E-]!^!VB_*YGOQ-^!^5W$'ZW(UGV +M.^%W4'X'X7>((JV>_4[X'93?0?@=HORN9[\3?@?E=Q!^ARB_Z]GOA-]!^1V$ +MW^U(EOU.^!V4WT'X':)(JV>_$WX'Y7<0?H7/_%.H7?+L[@9C?2!F +M?6"8*2Q9_;&`2SCK_87Y-F^OTB\BS+=Y>Y5^$6&^S=NK](L(\VW>7J5?1)AO +MF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28 +M;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$ +MF&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)? +M1)AOF^@7$>;;)OI%A/FVB7X18;YMHE\$Y]LV^D5POFVC7P3GVS;Z17"^;:-? +M!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$ +MY]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3G +MVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?; +M-OI%<+YMHU\$Y]LV^D5POFVC7T28;]/R5?I%A/DV+5^E7T28;]/R5?I%A/DV +M+5^E7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X1 +M8;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^ +M$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:) +M?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?!.?;-OI%#*;Z10RF^D4, +MIOI%#*;Z10RF^D4,IOI%#*;Z10RF^D4,IOI%#*;Z10RF^D4,IOI%#*;Z10RF +M^D4,IOI%C&EJJ%_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7\1H +MJE_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7\1HJE\\IFEJJ%\\7GR6\,YPE\DN^L!\ +MWM_RZ:"7?V\_6<.]\K'>/X?*7=J=SBGW)&G]X^ +M>+8O[^[=Y>XZX\.X^"C6G>]<%V3]SEW"'6T;03EWEF7X?_GW]@/G3X?UGR5@ +-/@=\\W^I>^KAH%T````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow.gz.uu new file mode 100644 index 000000000000..0dfdc6cfba53 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-ebr.qcow.gz +M'XL("*TS(E0``VEM9RTQ>#$M-#`Y-BUE8G(N<6-O=RYO=70`K9W9CAS728K(K*J,CGC`C;@M^L'VZ^WQN?Z`'Z\.62>TQVU-D.V1#4$$F1N5)U> +M6H2DQ=/K]:]OJ]7&5L-V-4RKRV'U_KHG3&_[+L;-;B]-_C/>>Y?\^MS +M\79W:FZ\-W=-;]?%VYW4W/ZWL+B`Y:#FCL7<@$^=U-RYF-O@4Q>>L]]\;G_- +M;?$I4W..@E[D1GQ+<6ZLY.Z` +M3PGNK.3NB$\)[JSD[H1/">Z\Y.Z,3PGNO.3N@D\)[KSBSO@IP9U7W!GYSA5W +M7G%GY#M7W'G%G9'O7''G%7=&OG/%G5?<&?G.%7=1<6?DNU#<1<6=D>]"<1]"<1)N4W)'OMLH[C8E=^2[ +MC>)N4W)'OMLH[C8E=^2[C>)N4W)'OMLH[K8E=^2[K>)N6W)'OMLJ[K85=\%/ +M">ZV%7=!OMLJ[K85=T&^VRKNMA5W0;[;*NZV%7=!OMLJ[K85=T&^VRKN=A5W +M0;[;*>YV%7=!OMLI[G8E=^2[G>)N5W)'OMLI[G8E=^2[G>)N5W)'OMLI[G8E +M=^2[G>)N5W)'OMLI[L:2._+=J+@;2^[(=Z/B;JRX&_@IP=U8<3>0[T;%W5AQ +M-Y#O1L7=6'$WD.]&Q=U8<3>0[T;%W5AQ-Y#O1L7=\I^_]1SY;E+<315W`_EN +M4MQ-)7?DNTEQ-Y7\FQ=U4^FQ1W4\D=^6Y2W$TE=^2[27$WE=R1[R;% +MW;[DCGRW5]SM2^[(=WO%W;[B;L-/">[V%7<;\MU><;>ON-N0[_:*NWW%W89\ +MMU?<[2ON-N2[O>)N7W&W(=_M%7?+_X;4<^2[@^+N4'&W(=\=%'>'DCORW4%Q +M=RBY(]\=%'>'DCORW4%Q=RBY(]\=%'>'DCORW4%Q=RBY(]\=%'?'DCORW5%Q +M=RRY(]\=%7?'BKLM/R6X.U;<;)N2[X[*NZ.%7=;\MU1<7>LN-N2 +M[XZ*NV/%W99\=U3GDCORW4EQ=RJY(]^=%'>G +MDCORW4EQ=RJY(]^=%'>GDCORW4EQ=RJY(]^=%'?GDCORW5EQ=RZY(]^=%7?G +MBKL=/R6X.U?<[)N1[X[*^[.%7<[\MU9<7>NN-N1[\Z*NW/%W8Y\ +M=U;<72KN=N2[B^+N4G&W(]]=%'>7DCORW45Q=RFY(]]=%'>7DCORW45Q=RFY +M(]]=%'>7DCORW45Q=RFY(]]=!'>V?$?/@>]L+;BS="[TSU=U;V +M=R/XSE1_9V5_-X+O3/5W5O9W(_C.5']G97\W@N],]7=6]G" +M[TSU=U;V=R/XSE1_9V5_-X+O3/5W5O9W(_E.]7=6]GKOK.SO]N0[U=]9V=_MR7>JO[.R +MO]N3[U1_9V5_MR??J?[.ROYN3[Y3_9V5_=V!GQ+KOK.SO#N0[U=]9V=\=R'>JO[.ROSN0[U1_9V5_=R#?J?[.RO[N +M0+Y3_9V5_=V!?*?Z.RO[NP/Y3O5W5O9W!_*=ZN^L[.\.Y#O5WUG9WQW(=ZJ_ +ML[*_.Y#O5']G97]W(-^I_L[*_N[(3PGNRO[N2+Y3_9V5_=V1?*?Z.RO[NR/Y +M3O5W5O9W1_*=ZN^L[.^.Y#O5WUG9WQW)=ZJ_L[*_.Y+O5']G97]W)-^I_L[* +M_NY(OE/]G97]W9%\I_H[*_N[(_E.]7=6]G='\IWJ[ZSL[X[D.]7?6=G?']4?V=E?WKOK.SO3N0[U=]9V=^= +MR'>JO[.ROSOS4X*[LK\[D^]4?V=E?WKOK.SOSN0[U=]9V=^=R7>JO[.ROSN3[U1_9V5_=R;? +MJ?[.RO[N3+Y3_9V5_=V9?*?Z.RO[NS/Y3O5W5O9W9_*=ZN^L[._.Y#O5WUG9 +MWUWX*<%=V=]=R'>JO[.RO[N0[U1_9V5_=R'?J?[.RO[N0KY3_9V5_=V%?*?Z +M.RO[NPOY3O5W5O9W%_*=ZN^L[.\NY#O5WUG9WUW(=ZJ_L[*_NY#O5']G97]W +M(=^I_L[*_NY"OE/]G97]W85\I_H[7[Z3YE9]#GSW_2GFSE-_M]RGM^K<@>]< +M]7>>^KO5S-UJX2[6_!1SYZF_6\WKO//5W,`>^<]7?>>KO8`Y\YZJ_\]3?+7,/^ASXSE5_YZF_>[#, +MK=H<^,Y5?^>IOWLP<_>@

^<]7?>>KO'LSC<@>]<]7>>^KL'UYNS`]^Y +MZN\\]7?M[/H<^,Y5?^>IOX,Y\)VK_LY3?P=SX#M7_9VG_FZ9>]CGR'>JO_/4 +MWSU-.[K_SE5_YZF_>WC- +M9T?WW[GJ[SSU=^WL^ASY3O5WGOH[F"/?J?[.4W\'<^0[U=]YZN^6N4=]CGRG +M^CM/_=VC9:YQ1_??N>KO//5WCV;N'G7NR'>JO_/4WSV:N7O4N2/?J?[.4W_W +MZ'IS=N0[U=]YZN_:V?4Y\IWJ[SSU=S!'OE/]G:?^#N;(=ZJ_\]3?+7./^QSY +M3O5WGOJ[Q\M/K_GLZ/X[5_V=I_ZNG5V?(]^I_LY3?P=SY#O5WWGJ[V".?*?Z.T_]W3+W +MI,^1[U1_YZF_>[+,->[H_CM7_9VG_N[)S-V3SAWY3O5WGOJ[)S-W3SIWY#O5 +MWWGJ[YY<;\Z.?*?Z.T_]73N[/D>^4_V=I_X.YLAWJK_SU-_!'/E.]7>>^KME +M[FF?(]^I_LY3?_=TF>O]4?^>IOWLZ<_>T<4?WW[GJ[SSU=T]G[IXV[NC^ +M.U?]G:?^[NDUGQW=?^>JO_/4W[6SZW/D.]7?>>KO8(Y\I_H[3_T=S)'O5'_G +MJ;];YI[U.?*=ZN\\]7?/EKG&'=U_YZJ_\]3?/9NY>]:Y(]^I_LY3?_=LYNY9 +MYXY\I_H[3_W=L^O-V9'O5'_GJ;]K9]?GR'>JO_/4W\$<^4[U=Y[Z.Y@CWZG^ +MSE-_M\P][W/D.]7?>>KOGB]SG3ORG>KO//5WSV?NGC?NZ/X[5_V=I_[N^]4?^>IOX,Y +M\IWJ[SSU=\O>^KL7,W>KO +M7LSC]4?^>IOWMQO3D[\IWJ[SSU=^WL^ASY3O5WGOH[F"/?J?[.4W\' +M<^0[U=]YZN^6N9=]CGRG^CM/_=W+9:YS1[Y3_9VG_N[ES-W+QAW=?^>JO_/4 +MW[VKO +M//5W,$>^4_V=I_YNF7O5Y\AWJK_SU-^]6N8:=W3_G:O^SE-_]VKF[E7GCGRG +M^CM/_=VKF;M7G3ORG>KO//5WKZXW9T>^4_V=I_ZNG5V?(]^I_LY3?P=SY#O5 +MWWGJ[V".?*?Z.T_]W3+WNL^1[U1_YZF_>[W,=>[(=ZJ_\]3?O9ZY>]VXH_OO +M7/5WGOJ[US-WKQMW=/^=J_[.4W_W^IK/CNZ_<]7?>>KOVMGU.?*=ZN\\]7

JO_/4WRUS;_H<^4[U=Y[ZNS?+7...[K]SU=]YZN_>S-R] +MZ=R1[U1_YZF_>S-S]Z9S1[Y3_9VG_N[-]>;LR'>JO_/4W[6SZW/D.]7?>>KO +M8(Y\I_H[3_T=S)'O5'_GJ;];YM[V.?*=ZN^\ZN^"[K]SU=]YU=\%W7_GJK_S +MJK\+NO_.57_G57\7=/^=J_[.J_XNZ/X[5_V=5_U=T/UWKOH[K_J[H/OO7/5W +M+OJ[=WV.?*?Z.T_]W;MEKG%']]^YZN\\]7?O9N[>=>[(=ZJ_\]3?O9NY>]>Y +M(]^I_LY3?_?N>G-VY#O5WWGJ[]K9]3GRG>KO//5W,$>^4_V=I_X.YLAWJK^+ +MY3MI;MWGP'>A^KOO/W&/N\5/Z\X=^"Y4?Q>IOUO/>^O&'=U_%ZJ_B]3?K6?N +MUHT[NO\N5'\7J;];7_/9T?UWH?J[2/U=.[L^![X+U=]%ZN]@#GP7JK^+U-_! +M'/@N5'\7J;];YJS/@>]"]7>1^CM;YAIW=/]=J/XN4G]G\\NSSAWX+E1_%ZF_ +MLYD[Z]R![T+U=Y'Z.[O>G!WX+E1_%ZF_:V?7Y\!WH?J[2/T=S('O0O5WD?H[ +MF`/?A>KO(O5WRYSW.?*=ZN\B]7>^S'7NR'>JOXO4W_G,G3?NZ/Z[4/U=I/[. +M9^Z\<4?WWX7J[R+U=W[-9T?WWX7J[R+U=^WL^ASY3O5WD?H[F"/?J?XN4G\' +M<^0[U=]%ZN^6N>ASY#O5WT7J[V*9:]S1_7>A^KM(_5W,W$7GCGRG^KM(_5W, +MW$7GCGRG^KM(_5U<;\Z.?*?ZNTC]73N[/D>^4_U=I/X.YLAWJK^+U-_!'/E. +M]7>1^KME;NASY#O5WT7J[X9EKG-'OE/]7:3^;IBY&QIW=/]=J/XN4G\WS-P- +MC3NZ_RY4?Q>IOQNN^>SH_KM0_5VD_JZ=79\CWZG^+E)_!W/D.]7?1>KO8(Y\ +MI_J[2/W=,K?I<^0[U=]%ZN\VRUSCCNZ_"]7?1>KO-C-WF\X=^4[U=Y'ZN\W, +MW:9S1[Y3_5VD_FYSO3D[\IWJ[R+U=^WL^ASY3O5WD?H[F"/?J?XN4G\'<^0[ +MU=]%ZN^6N6V?(]^I_BY2?[==YCIWY#O5WT7J[[8S=]O&'=U_%ZJ_B]3?;6?N +MMHT[NO\N5'\7J;_;7O/9T?UWH?J[2/U=.[L^1[Y3_5VD_@[FR'>JOXO4W\$< +M^4[U=Y'ZNV5NU^?(=ZJ_B]3?[9:YQAW=?Q>JOXO4W^UF[G:=._*=ZN\B]7>[ +MF;M=YXY\I_J[2/W=[GIS=N0[U=]%ZN_:V?4Y\IWJ[R+U=S!'OE/]7:3^#N;( +M=ZJ_B]3?+7-CGR/?J?XN4G\W+G.=._*=ZN\B]7?CS-W8N*/[[T+U=Y'ZNW'F +M;FS,UG1_??A>KO(O5W[>SZ'/E.]7>1^CN8(]^I_BY2?P=S +MY#O5WT7J[Y:YJ<^1[U1_%ZF_FY:YQAW=?Q>JOXO4WTTS=U/GCGRG^KM(_=TT +MKO(O5W,$>^ +M4_U=I/YNF7O?Y\AWJK^+U-^]7^8Z=^0[U=]%ZN_>S]R];]S1_7>A^KM(_=W[ +MF;OWC3NZ_RY4?Q>IOWM_S6=']]^%ZN\B]7?M[/H<^4[U=Y'Z.Y@CWZG^+E)_ +M!W/D.]7?1>KOEKD/?8Y\I_J[2/W=AV6N<4?WWX7J[R+U=Q]F[CYT[LAWJK^+ +MU-]]F+G[T+DCWZG^+E)_]^%ZKOVMGU.?*=ZN\B]7JOXO4WRUS'_L<^4[U=Y'ZNX_+7.>.?*?ZNTC]W<>9NX^-.[K_+E1_ +M%ZF_^SAS][%Q1_??A>KO(O5W'Z_Y[.C^NU#]7:3^KIU=GR/?J?XN4G\'<^0[ +MU=]%ZN]@CGRG^KM(_=TR]ZG/D>]4?Q>IO_NTS#7NZ/Z[4/U=I/[NT\S=I\X= +M^4[U=Y'ZNT\S=Y\Z=^0[U=]%ZN\^76_.CGRG^KM(_5T[NSY'OE/]7:3^#N;( +M=ZJ_B]3?P1SY3O5WD?J[9>YSGR/?J?XN4G_W>9GKW)'O5'\7J;_[/'/WN7%' +M]]^%ZN\B]7>?9^X^-^[H_KM0_5VD_N[S-9\=W7\7JK^+U-^UL^MSY#O5WT7J +M[V".?*?ZNTC]'KO(O5W7Y:YQAW=?Q>JOXO4WWV9 +MN?O2N2/?J?XN4G_W9>;N2^>.?*?ZNTC]W9?KS=F1[U1_%ZF_:V?7Y\AWJK^+ +MU-_!'/E.]7>1^CN8(]^I_FY8OI/FOO8Y\-V@^KLA]7=?E[G.'?CN^U/,W9#Z +MNZ\S=U\7[H8U/\7<#:F_^SIS]_5?;0Y\-ZC^KGTL<[DW'NC^N_Y4,7?GV[<_ +M7OXKOTQ=E_,[C9K/;[F\'_6E[?S\MT!E^M]_!W_1/?_O'V_E_M]?W\T]N;W6K8 +MK#;;U>A_]@W_S[_]-WTZZ$]O___.[]=<25][P?9GYG[^;GOG5]XE0__$MX[) +MVSO7UFWH3V_W%_%#+V?Z"?GJZ*N]_Q7V;OZ$]-W/\\^O%__]7XV7__N1KA%M +MG]]5?WU4E-][N[]Y?:O;M_OS=[3=_5]O=^:\>+NK^W.'WWYN?__J'MR^.OJ* +MZG_EDW'SYWS_Y#^Y/T;N_Y/[:\[_7A'L?IKEQV\Z>_B[_HEO_WQ[_Z]?@\,\ +4^+>=X+`>O[_*/_X7*6^YQ%^G```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow2.gz.uu new file mode 100644 index 000000000000..426de83180ed --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-ebr.qcow2.gz +M'XL("*`[(U0``VEM9RTQ>#$M-#`Y-BUE8G(N<6-O=S(N;W5T`*V76[/2,!#' +MW_D4PBS.^Z8/Z7"[]%'QXVV9IVNUN`TRAP\"$_V\VY)>E +MR;+P,,9;XW+C-J;:FOHS76!Z'X:7.?[^\7/5?QP7`68S)24,..QP`]9#Q(&& +MR^QXP,JX7G4HX."4&H-2.*=6-S4@X&X7[4_7+D;!$G@-,.#4Q;BJ/@CU\82[ +MLCZ8NSZ4?S]_RO&!?+H^#/7QU%K#%4D<"*F-ABN3.!126PVW2^*!L0I4:EPLIJ^$@B5L+*=1P+HDKA)3FG4U[MQ%2FG?2!6%G%"OT/-.V3>6<)!Q`G]#C7O +MD'F'A',1)_0[U+Q#YITG7!YQ0K]#S3MDWJT)5T2^0>?>%<'<1)_0[U+QSS+NOA/L6<4*_]47^AODI/;^HK3(_RMO<'+-2W[./V;>3$\ +MWQEG[MP&,MRY`0?S-@)H.TMM8/VM\:L^(_(V[D +%[($4```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-ebr.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-ebr.raw.gz.uu new file mode 100644 index 000000000000..bbf68364ea1b --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-ebr.raw.gz.uu @@ -0,0 +1,11 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-ebr.raw.gz +M'XL("._%'50``VEM9RTQ>#$M-#`Y-BUE8G(N8PL.M6@1;7DA<=H*7D\$&+<0?'&2"/ZSNYN&_N<+MC0"E!J0#X&O6A +M\1((3*WL<8.^E_Z<]`D#E!4("?(*->X-^/-XKZ5#\%S_S^)P"S<)YGMP%^/E +MG'0K(V[0K"A#YSR"[.^6R@# +MO7`3^B`,5QE#$M-#`Y-BUE8G(N=FAD+F]U=`"METU3PR`0AN_] +M%>MX\]"!#6S:JZ.>G7'4JVE,'`]^C'KPD!\O!$@@"=@H34J3@7WR[K)L*&/F +M`T`%4`O4`$E]70J@/90[`-5I3^Q;;F^AJ]]>F_KK^7MK/]W&P#CSK4)S;8\% +M"/60$K#2#Z%'?0V=PVQ/+Y_.GE^>'`XMSCU8$`@$J2!B]AQB@SI-NCJ_N>B1 +M#Z.Z8JYNM%+?@P`F@'-O1.'4/0P:!YQ05FW;GR5452_3G<%-T#$Z.\%)-K'R +M9"X%U7-V"4>SC\Q5T(<8?DW*;5G#$M-#`Y-BUE8G(N=FAD9BYO=70`K96Q;H,P$(;W +M/,5%W3)$MK$/LD9-YTI5VS5`(,J0=NG0@8>OC3'Q82"D,A@P.M_'?[ZS8

+M`/H:;=.&9CLXFM5FU=)X\3"PKD>!%E=J+SU`MUQU'=T8]W"<@>#3^M8^[A0[ +MW/HQH%*0YP'PW>D3QDL*8/G(?=K0[+?T[/5)`U0I2`4*(1-+`_X\?(RE0_)8 +M\V=QXAZN%\R7X!+CY8WT*V/:T-S*Q#X=3LZITPA6/12LBEQ[,AOX^7D&IE=) +M"2SK;(("^_S"3=\NE"%(N#/Z(`PW-[B4CN<>3MP)%RBNF,WMO+IUJ*Z,G`PU +M7!D+5ZZ!T)5K<2+N1B#:G457H!X5WJ<-S>N6GA8H.V"T&<3N5X0)8`U8`2K3 +M3R7@#M+,!PI:24WY_565/Y=?/\,&Q_L_1]B,OTC,:L$41&X^@B?3]_0]'#$M-#`Y-BUE8G(N=FUD:RYO=70`K5Q=C]S&$7SW +MKZ"EER`/"]:27)(/`A+G'"`(`AB68[^&G]$AMB2<#D$,[(\/AYR:*]YJ-+2O +M3SR1+7;W3O=PZT[5AC.4X-[QQ_?O= +M/WX\\>L/I]/UJRT97)2$(-=T8NQ>YWIZ]L5TYR]%[6XLQSF9KG!1_4V@3W>. +MW(BF*Y>;Y\^%<'7=>GMT%Y(N"XFR7;KJ,S5%B_W2ZO[XE6^>6U_AUK!L[Z7- +MZB*[]-[,+M5J%UE]7N_E6;TXS4O"U]G=_:?_9'?3I^'A_N/C![^^L]O;Q;F\ +M./_+X#(LA=47=^%NN'2M2W&9LF+,"KC;V?7AK_<_3Z?_3@^?[C^\?P.6>W9[ +M6Q99V;KE./_\Z=@9[D7R[`+W&MGU+W^[>^.?W/STL7M@.A>U+&1Y[:4.S7NY +M9.[[]EA7-[U_=!EG_Q56Y_;6-Z=:7[MT%U69U6VV+J=RN<_+[=&7O/9N>)BZ +MQ^F'7S].;U[]\N%]Z)W;6]>R=DW4K(TJLJIPJ7QIKGV5R^@>FW77LNO/]X_O +M[H>W2YF?IE>GUQG375SOE@UL_+JVJI>02W1GEV5?O_W?XU)O-OJ=O6>Z=1%K +M$LJEVN90/7K3AG1>FNEG]:%KQ44L(Y9=0Z=KM;>:_:EMZ!6.ENK#N;W76/7?9-]VDZO;Z[^R;L;.>*+==C6=KDLERVU.[Y7MNY +M-&[;Z6VCUZT8Q_[4C=W'Q^G!;6_8BMZU:/25NFTMG[9Q_SKUNE.S>V*RZYOL +MU?VX[*E+^^_IPR],-VR/\;(.]TBT:V#A+I:G9TT_^5?8GABW32[=]/CPZVGX +M]>?[]^/R1LO>,-VX]6Y9SK:;3YNY;."RPL\N<.G=JW57P_*8;G*K&V\6N.ZG +M;V185'C9[/K+NKQW4SR78O"%\]_EKT4C\N;'ZGU[TRXI;->WR5_]O.L +MT+A2C&J7T/T4RY?O/RW?WSVM[^+6=Q'/6J,:,=I=NG\M*3[>EGMQ[\)./'N- +M&L08CW3OXJ!M$L_Y>??XJP;D.IZ.OPO0L]"H4HQJER[6N\KWCIZU1C5BM+MT +ML=Y=?._HV6O4(,9XJ-C:]XZ>LT:Y$W^50G[@U[)+XWM'ST*C2C&J7;I8[UK? +M.WK6&M6(T>[2Q7K7^=[1L]>H08SQ4+&][QT]9XUR)P($Y#J>;O"]HV>A4:48 +MU2Y=K'>C[QT]:XUJQ&AWZ6*]FWSOZ-EKU"#&>*C8V?>.GK-&N5,IO2M3Z>K< +M]XZ>A4:58E2[=)'>U<0[>M8:U8C1[M)%>E<3[^C9:]0@QGBH6.(=/6>-E- +M+].Z23$>\HV>A4:48U2Y=K'?$.WK6&M6(T>[2Q7I'O*-GKU&#&..A8HEW +M])PURIWX2Q#D.IZ.>$?/0J-*,:I=NECOB'?TK#6J$:/=I8OUCGA'SUZC!C'& +M0\42[^@Y:Y0[D9"!7$?3-;GO'3T+C2K%J';I(KUKB'?TK#6J$:/=I8OTKB'> +MT;/7J$&,\5"QQ#MZSAKE3JWTKDVF(][1L]"H4HQJER[6.^(=/6N-:L1H=^EB +MO2/>T;/7J$&,\5"QQ#MZSAKE3OS_$^0ZGHYX1\]"HTHQJEVZ6.^(=_2L-:H1 +MH]VEB_6.>$?/7J,&,<9#Q1+OZ#EKE#N1?X1 +MM48U8K2[=+'>$>_HV6O4(,9XJ%CB'3UGC7*G07HWI-*UN>\=/0N-*L6H=NDB +MO6N)=_2L-:H1H]VEB_2N)=[1L]>H08SQ4+'$.WK.&N5.H_1N3*8CWM&ST*A2 +MC&J7+M8[XAT]:XUJQ&AWZ6*](][1L]>H08SQ4+'$.WK.&N5.D_1N2J8CWM&S +MT*A2C&J7+M8[XAT]:XUJQ&AWZ6*](][1L]>H08SQ4+'$.WK.&N5.L_1N3J8C +MWM&ST*A2C&J7+M8[XAT]:XUJQ&AWZ6*](][1L]>H08SQ4+'$.WK.&I7+]`QR +M'4W7Y5OO@F>A4:48U2Y=I'>=Q[O@66M4(T:[2Q?I7>?Q+GCV&C6(,1XJUN-= +M\)PURK5,^#LD*:W.XQV$OX/R=Q#^#DG^KO-X!^'OH/P=A+]#DK_K/-Y!^#LH +M?P?A[PX4Z_$.PM]!^3L(?X=QSL(?P?E[R#\W8%B/=Y!^#LH?P?A[Y"DM#J/=Q#^#LK?0?@[)/F[SN,= +MA+^#\G<0_@Y)_J[S>`?A[Z#\'82_.U"LQSL(?P?E[R#\'9*45I_[W@E_!^7O +M(/P=DOQ=3[P3_@[*WT'X.R3YNYYX)_P=E+^#\'<'BB7>"7\'Y>\@_!V2E%9/ +MO!/^#LK?0?@[)/F[GG@G_!V4OX/P=TCR=SWQ3O@[*'\'X>\.%$N\$_X.RM]! +M^#LD*:V>>"?\'92_@_!W2/)W/?%.^#LH?P?A[Y#D[WKBG?!W4/X.PM\=*)9X +M)_P=E+^#\'=(4EH]\4[X.RA_!^'OD.3O>N*=\'=0_@["WR')W_7$.^'OH/P= +MA+\[4"SQ3O@[*'\'X>^0I+2&W/=.^#LH?P?A[Y#D[P;BG?!W4/X.PM\AR=\- +MQ#OA[Z#\'82_.U`L\4[X.RA_!^'OD*2T!N*=\'=0_@["WR')WPW$.^'OH/P= +MA+]#DK\;B'?"WT'Y.PA_=Z!8XIWP=U#^#L+?(4EI#<0[X>^@_!V$OT.2OQN( +M=\+?0?D["'^')'\W$.^$OX/R=Q#^[D"QQ#OA[Z#\'82_0Y+2&HAWPM]!^3L( +M?X:^ +M=\+?0?D["'^')'\W$N^$OX/R=Q#^#DG^;B3>"7\'Y>\@_-V!8HEWPM]!^3L( +M?X"7\'Y>\@_!V2E-9(O!/^#LK?0?@[)/F[D7@G_!V4OX/P=TCR=R/Q +M3O@[*'\'X>\.%$N\$_X.RM\%,1WD6M)EV[=/-^5;[X)GH5%Y_OECZ=V2(L]N +M5C<9ZP.QZ@/#3&&KZO+](L( +M\VT>+](O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2\BS+=-](L(\VT3_2+"?-M$ +MOX@PWS;1+R+,MTWTBPCS;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M$_TBPGS; +M1+^(,-\VT2\BS+=-](L(\VT3_2+"?-M$OX@PWS;1+R+,MTWTBPCS;1/](L)\ +MVT2_B##?-M$O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2^"\VT;_2(XW[;1+X+S +M;1O](CC?MM$O@O-M&_TB.-^VT2^"\VT;_2(XW[;1+X+S;1O](CC?MM$O@O-M +M&_TB.-^VT2^"\VT;_2(XW[;1+X+S;1O](CC?MM$O@O-M&_TB.-^VT2^"\VT; +M_2(XW[;1+X+S;1O](CC?MM$O@O-M&_TB.-^VT2^"\VT;_2(XW[;1+X+S;1O] +M(CC?MM$O@O-M&_TB.-^VT2^"\VT;_2(XW[;1+R+,M^GY(OTBPGR;GB_2+R+, +MM^GY(OTBPGR;GB_2+R+,MTWTBPCS;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M +M$_TBPGS;1+^(,-\VT2\BS+=-](L(\VT3_2+"?-M$OX@PWS;1+R+,MTWTBPCS +M;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2\BS+=-](L( +M\VT3_2+"?-M$OX@PWS;1+R+,MTWTBPCS;1/](L)\VT2_B##?-M$O@O-M&_TB +M)E/](B93_2(F4_TB)E/](B93_2(F4_TB)E/](B93_2(F4_TB)E/](B93_2(F +M4_TB)E/](B93_2(F4_TBYCPWU"]B-M4O8C;5+V(VU2]B-M4O8C;5+V(VU2]B +M-M4O8C;5+V(VU2]B-M4O8C;5+V(VU2]B-M4O8C;5+V(VU2^>\SPWU"^>;SY+ +M>!<53W=;[*8/+-'_YH3S'.U>"?>H+`[+T57^8CDV(9GT#?'U?:WI1NMRY]^6 +ML*JRKKM)^$^N;_TTX>VS56__CM^X?G/:_PGK6S\.LZK=Q\16EZPY'RWXIV]_ +M?%;PEL[L<=G2W7ST]/-T8<$'/LFZ+->/GA9/?3+B-ZY/C\EV9KKR2ZO3*<^Q +M8HT_>KHLFV=QNL_KC&!X4C,\0Y:PO]G3^MK;99QWY7YA?3?(4I;N1Y!^^*KN +MX@[K(N5F^W3]%_?VRZO[^G9U@_%F5,_?&0??N2[)_IV[I3O;`L%E199-.G'[ +>=_S&];O3_L^6L/0)S3I8N@].R[_Z/_V4$^TO7P`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu new file mode 100644 index 000000000000..a67e3ebeb5af --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu @@ -0,0 +1,132 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-gpt.qcow.gz +M'XL("*XS(E0``VEM9RTQ>#$M-#`Y-BUG<'0N<6-O=RYO=70`K9W;;AS7M47? +M_16ENT1)5*^UJJJK=$^`!,B;$YSS=@Z0NCX&G7=]?-CDOI"KY]2*(=J$(4.H +MB>ZMP4'9'MX\'.[^:)I.FK9OVK'9Y^;F[].'-/?^YN%'\^/O?_W;]?T_?OQV +M-R:'GSSE_K[51M/<@ZT_-V5.ST\MS6'\+^9N/@3-W7MU]@=>W;TW>SEW]=O= +MF\7/*1NT!X--FCNDUR?D]-K_[O5]=V]7[D[O\=ZNDK?;L<'^P>#O:>Z?Z?4I +M>;M'-C<\F#NYMZOD[8YL;OHI+$I@F=G<$LRU\*F5S6W!7`>?VO&<_.37]FZN +MAT\)FX.?M]=-F3O"IXS-M0_F#M<9Z#PWP*<(=Q)R-\*G"'<2,.PNY0[XSQIV%W"'?&>/.0NZ0[XQQ9R%WR'?&N+.0.^0[8]RU +M(7?(=RWCK@VY0[YK&7=MQ)WBIPAW;<2=(M^UC+LVXDZ1[UK&71MQI\AW+>.N +MC;A3Y+N6<==&W"GR7*?-XZT/ND.]ZQET?.NC[@SY+N> +M<7>,N#/DNR/C[AAQ9\AW1\;=,>0.^>[(N#N&W"'?'1EWQY`[Y+LCX^X8ZFB+L.^6YB +MW$T1=QWRW<2XFR+N.N2[B7$W1=QUR'<3XR[_9T@^AWPW,^[FB+L.^6YFW,TA +M=\AW,^-N#KE#OIL9=W/('?+=S+B;0^Z0[V;&W1QRAWPW,^[FD#ODNYEQMX3< +M(=\MC+LEY`[Y;F'<+1%W/7Z*<+=$W/7(=POC;HFXZY'O%L;=$G'7(]\MC+LE +MXJY'OEL8=TO$78]\MS#NUHB['OEN9=RM$7<]\MW*N%M#[I#O5L;=&G*'?+\VQMT6<7=$ +MOML8=WO$W1'Y;F?<[1%W1^2[G7&WA]PAW^V,NSWD#OEN9]SM(7?(=SOC;@^Y +M0[[;&7=[R!WRWLOY.POQN`[X3U=Q+V=P/PG;#^3L+^;@"^$];?2=C?#OO).SO1N0[UM])V-^-R'>LOY.POQN1[UA_)V%_-R+?L?Y.POYN +M1+YC_9V$_=V(?,?Z.PG[NQ'YCO5W$O9W(_(=Z^\D[.]&Y#O6WTG8WXW(=ZR_ +MD["_&Y'O6'\G87\W(M^Q_D["_FY$OF/]G83]W8A\Q_H["?N["3]%N`O[NPGY +MCO5W$O9W$_(=Z^\D[.\FY#O6WTG8WTW(=ZR_D["_FY#O6'\G87\W(=^Q_D[" +M_FY"OF/]G83]W81\Q_H["?N["?F.]7<2]G<3\AWK[R3L[R;D.];?2=C?3]8?R=A?SOO).SO9N0[UM])V-_- +MR'>LOY.POYN1[UA_)V%_-R/?L?Y.POYNP4\1[L+^;D&^8_V=A/W=@GS'^CL) +M^[L%^8[U=Q+V=POR'>OO).SO%N0[UM])V-\MR'>LOY.POUN0[UA_)V%_MR#? +ML?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W$O9W"_(=Z^\D[.\6Y#O6WTG8 +MWRW(=ZR_D["_6Y#O6'\G87^WXJ<(=V%_MR+?L?Y.POYN1;YC_9V$_=V*?,?Z +M.PG[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6WTG8WZW(=ZR_D["_6Y'O6'\G87^W +M(M^Q_D["_FY%OF/]G83]W8I\Q_H["?N[%?F.]7<2]GOO).SO-N0[ +MUM])V-_M^"G"7=C?[]8?R=A?[^8_V=A/W= +MCGS'^CL)^[L=^8[U=Q+V=SOR'>OO).SO=N0[UM])V-_MR'>LOY.PO]N1[UA_ +M)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.\T_<'--G0.^NWD*NO\OWZ365 +M.^`[9?V=NOZN2=PUF3L[X*OOU/5WSLOU/7 +MWSW)).Z>5.Z`[Y3U=^KZNR>)NR>5.^`[9?V=NO[NR>GB +M[(#OE/5WZOJ[OO\MS3.H=\ +MQ_H[=?W=TSQ7N4.^8_V=NO[N:>+N:>$.W7^GK+]3U]\]3=P]+=RA^^^4]7?J +M^KNG)W]VZ/X[9?V=NOZNG%V=0[YC_9VZ_@[,(=^Q_DY=?P?FD.]8?Z>NO\MS +MS^H<\AWK[]3U=\_R7.$.W7^GK+]3U]\]2]P]J]PAW['^3EU_]RQQ]ZQRAWS' +M^CMU_=VST\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/(=ZR_4]?? +MY;GG=0[YCO5WZOJ[YWFNOOU/5W+_-GOS9H?OOE/5WZOJ[LOU/7W[W*O3A=GAWS'^CMU_5TYNSJ'?,?Z.W7]'9A#OF/] +MG;K^#LPAW['^3EU_E^=>USGD.];?J>OO7N>YRAWR'>OOU/5WKQ-WKPMWZ/X[ +M9?V=NO[N=>+N=>$.W7^GK+]3U]^]/OFS0_??*>OOU/5WY>SJ'/(=Z^_4]7=@ +M#OF.]7?J^CLPAWS'^CMU_5V>>U/GD.]8?Z>NOWN3YPIWZ/X[9?V=NO[N3>+N +M3>4.^8[U=^KZNS>)NS>5.^0[UM^IZ^_>G"[.#OF.]7?J^KMR=G4.^8[U=^KZ +M.S"'?,?Z.W7]'9A#OF/]G;K^+L]=U3GD.];?J>OOKO)$.W7^GK+]3U]]=)>ZN"G?H_CME_9VZ_N[JY,\.W7^GK+]3U]^5LZMSR'>L +MOU/7WX$YY#O6WZGK[\`<\AWK[]3U=WGN;9U#OF/]G;K^[FV>*]RA^^^4]7?J +M^KNWB;NWE3OD.];?J>OOWB;NWE;ND.]8?Z>NOWM[NC@[Y#O6WZGK[\K9U3GD +M.];?J>OOP!SR'>OOU/5W8`[YCO5WZOJ[//>NSB'?L?Y.77_W+L]5[I#O6'^G +MKK][E[A[5[A#]]\IZ^_4]7?O$G?O"G?H_CME_9VZ_N[=R9\=NO].67^GKK\K +M9U?GD.]8?Z>NOP-SR'>LOU/7WX$YY#O6WZGK[_+<^SJ'?,?Z.W7]W?L\5[A# +M]]\IZ^_4]7?O$W?O*W?(=ZR_4]??O4_LOU/7 +MWY6SJW/(=ZR_4]??@3GD.];?J>OOP!SR'>OOU/5W>>ZZSB'?L?Y.H_[.T/UW +MROH[C?H[0_??*>OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ.XWZ.T/W +MWRGK[S3J[PS=?Z>LOU/2WWVH<\AWK+]3U]]]R'.%.W3_G;+^3EU_]R%Q]Z%R +MAWS'^CMU_=V'Q-V'RAWR'>OOU/5W'TX79X=\Q_H[=?U=.;LZAWS'^CMU_1V8 +M0[YC_9VZ_@[,(=^Q_L[R#]S).*G?`=\;Z.W/]G9PNS@[XSEA_9ZZ_*V=7YX#O +MC/5WYOH[,`=\9ZR_,]??@3G@.V/]G;G^+L]IG4.^8_V=N?Y.\USE#OF.]7?F +M^CM-W&GA#MU_9ZR_,]??:>)."W?H_CMC_9VY_DY/_NS0_7?&^CMS_5TYNSJ' +M?,?Z.W/]'9A#OF/]G;G^#LPAW['^SEQ_E^>LSB'?L?[.7']G>:YPA^Z_,];? +MF>OO+'%GE3OD.];?F>OO+'%GE3OD.];?F>OO['1Q=LAWK+\SU]^5LZMSR'>L +MOS/7WX$YY#O6WYGK[\`<\AWK[\SU=WFNK7/(=ZR_,]??M7FNZ.#OD.];?F>OORMG5.>0[ +MUM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\U]NO^M/_NS0_7?&^CMS_5TYNSJ' +M?,?Z.W/]'9A#OF/]G;G^#LPAW['^SEQ_E^>.=0[YCO5WYOJ[8YXKW*'[[XSU +M=^;ZNV/B[EBY0[YC_9VY_NZ8N#M6[I#O6']GKK\[GB[.#OF.]7?F^KMR=G4. +M^8[U=^;Z.S"'?,?Z.W/]'9A#OF/]G;G^+L\-=0[YCO5WYOJ[(<]5[I#O6']G +MKK\;$G=#X0[=?V>LOS/7WPV)NZ%PA^Z_,];?F>OOAI,_.W3_G;'^SEQ_5\ZN +MSB'?L?[.7'\'YI#O6']GKK\#<\AWK+\SU]_EN;'.(=^Q_LYOOS/5W8`[YCO5WYOH[,(=\Q_H[<_U=GOM4YY#O6']GKK_[E.<* +M=^C^.V/]G;G^[E/B[E/E#OF.]7?F^KM/B;M/E3OD.];?F>OO/ITNS@[YCO5W +MYOJ[LOS/7WWW. +M?$W>?"';K_SEA_9ZZ_^WSR9X?N +MOS/6WYGK[\K9U3GD.];?F>OOP!SR'>OOS/5W8`[YCO5WYOJ[//>ESB'?L?[. +M7'_W)<\5[M#]=\;Z.W/]W9?$W9?*'?(=Z^_,]7=?$G=?*G?(=ZR_,]???3E= +MG!WR'>OOS/5WY>SJ'/(=Z^_,]7=@#OF.]7?F^CLPAWS'^CMS_5V>^UKGD.]8 +M?V>NO_N:YRIWR'>LOS/7WWU-W'TMW*'[[XSU=^;ZNZ^)NZ^%.W3_G;'^SEQ_ +M]_7DSP[=?V>LOS/7WY6SJW/(=ZR_,]??@3GD.];?F>OOP!SR'>OOS/5W>>Y; +MG4.^8_V=N?[N6YXKW*'[[XSU=^;ZNV^)NV^5.^0[UM^9Z^^^)>Z^5>Z0[UA_ +M9ZZ_^W:Z.#OD.];?F>OORMG5.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7=M_H&; +M^U[G@.]:UM^UKK_[GNWYM=H<)O!7 +M_A,__GS]\,\R>'MWT!\8S*_PX5S^!>GN[@ZZC::V&W?NZ>,@]][P^9L>"W_# +M3Z[OS:'OS?PKYX>N^_G98-]]-V3=LW[9@N^>?[FMW#6;.Z0#D+?[O_[MWLW +M=_OE>_>GG>>,SCW!<[=?OM>?S*$//M?^[*F#TE=W\6M[-]<='CXUW'_J_-L, +M:_:IF58R]]7-H6\?_RODW=X<,/?-\>8?6F]^@R?-LI]_L/;G;[[;##>?)G?_ +M:49O_U^FL3G*^?^RNQG\\:^_7__K;NS]];_?IM=W=W.`X`_^$^ST[FX.&-C; +MS?]YD;_=YN$<^)W>KYW>^?M/=Z>%#.I\>_)3YU7C?/7V`G\E?_$C]^O'_YY-]BFP4=[A3>#RR-^=ISG'O&S +MXSSWB)\=Y[E'_>PX#S[B9\=Y[A$_.\YSC_C9<9Y[U,^.F\';?^?X2%_$SW-R +M]V5R7YM!F\W_AV[_Z=(_O2_Y,OXO@78WO$+^+GN9]_$=_^Z)M] +8Q"_BY[E'_2+>'HXWWOOM/_VP*B?UK``` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu new file mode 100644 index 000000000000..c9d99d14fb7e --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu @@ -0,0 +1,26 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-gpt.qcow2.gz +M'XL("*([(U0``VEM9RTQ>#$M-#`Y-BUG<'0N<6-O=S(N;W5T`*V92V_4,!"` +M[_T5+F]:6.)7DN51:$LK]=8BN'')\UB)*PK\=N+8B9/)3-PNWK6BKJSY9#O? +MC)TT2>R',$)$(1U*3K@%Z]+C +M!(5+^+J#X[C9Z"2"$V/4&A3"*7)T6QT([N1H6+KA9N0@0AX"M#CR9APT/F'' +M!R/4@>,3L<PI7!'$2B2HI7!7$*22J +MIG!-$*>1J);`\8`J/2Y%HCB%$T%"N!R)HKSC8>_V2!3E'0][5R!1 +ME'<\[%V)1%'>\;!W%1)%>B +MA]0[07DG@'>G#O?&XY!Z)RCO!/#N[2X=Y['%+O).6=!-Y]<+B/'H?4.TEY)X%WGQSNS..0>B4^)-6-L)&ZL*Y$IW=!>[Y7<"#KG[ +M".`XPB7.35C;W+4/C$W#VM8UNU(N.)\=$)`)'^]FN#KR^@WI]@B@UJPH5L`? +MX_B&=.OSR[X;Z.W60S'0@FDUX8:YZFH^OJOK&W9[_NV[@?WTTQW2+2M8Q5F1 +MLP*.CE/3_8W9IVVZ92U<[1$G*=QT+`,X<[S(Z@TRV +M+88SUIYEW)S=>F!W?[>[M["WNU^G;GR*.R.P1G=0JZ>&RIQ3T\W\@P`Q7;;$ +M8:^1_FOU3%TN=;35VSM9L$9WD*M7V-7#%\FL'IHRW;AJ8\*-N#+NZG'["C,Q +M]7M]I3NZV]WR:X'*`:.-4*5M%3$[#"YB=AA(&9]PK,E8+\YRX^'_!UG;<#8^/Z^DV8FOKW]C$\9O11-S$ +B#6YS$\\:>K+V\Q=,-N(F;G!1-W&5F>/WT3\!FKQU%1H````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu new file mode 100644 index 000000000000..c8adeb3c699a --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-gpt.raw.gz +M'XL("/#%'50``VEM9RTQ>#$M-#`Y-BUG<'0NU52W;V`262JW42MW2JMW:@3]FC-2=#U\?A@2(C1KIP$)(Q_UR]_#C(F4X +M`*,AJ\@U'>B?Q?+L=W>[@:;JVX#^]ZF$%5!X8,`U/B@U/>,3SAQ.?9BAFO/6=K7-O+Z7US<VLL(>^M^[#3@KEUG%/"MSJ#-T%:HV@7MG&12+VH +M9?I)M7^I;M.KTU +F^C>&>/QE.,8A3KCM(>YN;99QB!..=8@;_W]*RMT?5F[7A(@+```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu new file mode 100644 index 000000000000..6936b1379dc6 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-gpt.vhd.gz +M'XL("/'%'50``VEM9RTQ>#$M-#`Y-BUG<'0N=FAD+F]U=`"MF$MOVS`,Q^_Y +M%!QVZS#7DB79N0Q8L1;8K7O==JCER$4/RQ[IH1C\X2?*\D.VY"$M$]5(H/#G +M/RF*8IWG_0M`%:!:4`:4Q,^E`+6'L@*PDWYP=V7^*W3-SZ-I'A^>,O_J=CV, +MY7.KT!SM>0'"WJ0$7N--U`$_0S=@LM?7]QXX<9"@>`@+42L[J/R +M41V2;JZ^?'#(NTE=L58W6=D_+2`7P-CL%\6@[F[4..*$M6I;-THH:[0=1_`E +MF$#LK@U"+H<)[MP/HS>A8*Y/L7PCYNG%2.JK49_=6WD=N:8GNJLL?(]`K<\# +M#A$,<:/#NL'XN3IBS.11GR138(N-!`1+ADT[BP_*#S(H++;I'(0#MQ*M`>[/84U`KOCI^S8 +MP]YFO]]X?8;YC(B-]$0J>L;5Y2KE;CD5[(2[$.*HZ[*I,'J2+'I[GRRQD9Y( +M1J_NHQR#WQQ#9N<9] +M(253*#R03*'P^Y=0(3.;BWGN*BN_*$05!G&$%09QA!4&<:05!H&$%09QA!4& +M<805!G&D%4;1-D+*-T)%!8;A/RXZS)IT2]-5V:D7=AFXZQJA9/NTT0C%%X.R +M$5+_:X1:DW)VY"R<)6R$%'4CI'PA)7J6H89&:*WA.<\RU-`(S6[\@F<9*MX( +>/?=9!N((GV4@CO!9!N*(4X79WF7W#]HOQ!D`$P`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu new file mode 100644 index 000000000000..0c18ed8876e1 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu @@ -0,0 +1,19 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-gpt.vhdf.gz +M'XL("/'%'50``VEM9RTQ>#$M-#`Y-BUG<'0N=FAD9BYO=70`K9<[;]PP#(#W +M^Q4LNJ6HH_?IE@`-F@#=TD>V#O%#"C+DBJ(=.OC'5Y3LL^23C%XAFS!TH/F9 +MI$G11T@X``0#TF:N9<5XVZ3GN+O:>1KM+@.ZYZ,+*V#C@`'7.R5A>(\Q8.TD +MA'JK8.R$DV7M<=CEWWLW]W])WCX\.4;PKXOX3+JE`,#W4-_`-NMO*/_'F[` +M.8QQ$W;.!R4L:)+:M00Y<$*TEJI6,K;J#C8%MHAP+N9H53 +ME2M/H+I3L.]!&9`4>HN+00&E`-JUB?80!LRY>(`]!=8A<#Q^;HX!]K[Y^6[R +M3]"I(G)25I2R)[!4B"Z%N\?:W@P74AROG3V-V9/5LG>8BB4G944Q>VW(7CY) +MF+UP'*M92.@6RI&0_L?QQ-__OE3YP]Y7=F6#Z25X+VC&-A*MN33XEUFFU)Q]CH!1.`6 +M$P<^>?>4EHKR7T!SL,:"EFA[DN1'HL@6,N)\J<0W_^^[#;C:I>+^&NS^`N3M +&#A:S#0`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu new file mode 100644 index 000000000000..782cb6c93c80 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu @@ -0,0 +1,87 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-gpt.vmdk.gz +M'XL("/'%'50``VEM9RTQ>#$M-#`Y-BUG<'0N=FUD:RYO=70`K5Q=C]S&$7SW +MKYC(#S829,%:DLOE@X+8D1T800!%=I*7/(2?\2&VI)P.A@WLCP^'G)HKWNT< +M*5^?]K3;8G?M=,^RN:HN,,N6'^>*UA6%*WI7GEP&-_W3\G!9?F],C^.9!RY_ +M>?77?QSX\_GAS5\Z&YOWM^]"^L[^KV=G(N3 +M]S]U'F%*K#KY%_Z`AZL]Q&EP>>]R^,/N9.\._A+G_ZYM7+\,G-#N^;6\+YJ&DATWM/>2CNZ>3\ +M[^/'O+KA[9U'',-/7)W?VU"<#R]?_/CN;:R=WUM?LGH&.L^%REV9>ZB0FB]?Z1']QV;>-7?YX>;N^YON +MVRG-#\.+PZ>.<"=?NVD#SV%=2]93R"FYL].R+U_]?#?EZ_JPLS>$FQ6QI@V_',ZQ7VQOGW]Q1O"G:>H +MR7-:X!0R);3*J5SR+Q]^+-WEVZ_<"Y_D=]\/\R>0:=&_XEQEY?NQ4T_ +M[:F'_<_P[D?"=%J'_TC4[VET/WRP\W +M;_OI1',O"=_%G8B&>K49T8_9[J +MG7QK&\1S?%@]?M6`O$[#\;L`/7.-*L0H5W"IVI6A=O2L-.HL1KV"2]7N%&I' +MSU:C.C'Z7N8:58A1KN!2M:M#[>A9:=19 +MC'H%EZI=$VI'SU:C.C'Z7JW1!J1\]6HSHQ^EW)CJ%V]!PURC\54KMB"Z[*0NWHF6M4 +M(4:Y@DO4KF*_HV>E46E4:=Q:A7<*G:L=_1L]6H3HQ^5[+L=_0<-N4848Y0HN53OV.WI6&G46HU[!I6K'?D?/5J,Z,?I=R;+? +MT7/4*/]$0@;R.@EWSD+MZ)EK5"%&N8)+U.[,?D?/2J/.8M0KN$3MSNQW]&PU +MJA.CWY4L^QT]1XWR3[74KMZ$8[^C9ZY1A1CE"BY5._8[>E8:=1:C7L&E:L=^ +M1\]6HSHQ^EW)LM_1<]0H_\3_/T%>I^'8[^B9:U0A1KF"2]6._8Z>E4:=Q:A7 +M<*G:L=_1L]6H3HQ^5[+L=_0<-H0HQR!9>J'?L=/2N- +M.HM1K^!2M6._HV>K49T8_:YDV>_H.6J4?^JD=MT67)V%VM$SUZA"C'(%EZA= +MS7Y'STJCSF+4*[A$[6KV.WJV&M6)T>]*EOV.GJ-&^:=>:M=OPK'?T3/7J$*, +M<@67JAW['3TKC3J+4:_@4K5COZ-GJU&=&/VN9-GOZ#EJE'\:I';#)AS['3US +MC2K$*%=PJ=JQW]&STJBS&/4*+E4[]CMZMAK5B='O2I;]CIZC1OFG46HW;L*Q +MW]$SUZA"C'(%EZH=^QT]*XTZBU&OX%*U8[^C9ZM1G1C]KF39[^@Y:E0FTS/( +MZR1^@_!V$O\,F?]>$?@?A[Z#\'82_PR9_UX1^!^'O +MH/P=A+_;D6SH=Q#^#LK?0?@[;%):3>AW$/X.RM]!^#ML\G=-Z'<0_@[*WT'X +M.VSR=TWH=Q#^#LK?0?B['^@_!V$O\,F?]>$?@?A[Z#\'82_VY%LZ'<0_@[*WT'X.VQ26FT6:B?\ +M'92_@_!WV.3O6O8[X>^@_!V$O\,F?]>RWPE_!^7O(/S=CF39[X2_@_)W$/X. +MFY16RWXG_!V4OX/P=]CD[UKV.^'OH/P=A+_#)G_7LM\)?P?E[R#\W8YDV>^$ +MOX/R=Q#^#IN45LM^)_P=E+^#\'?8Y.]:]COA[Z#\'82_PR9_U[+?"7\'Y>\@ +M_-V.9-GOA+^#\G<0_@Z;E%;+?B?\'92_@_!WV.3O6O8[X>^@_!V$O\,F?]>R +MWPE_!^7O(/S=CF39[X2_@_)W$/X.FY16EX7:"7\'Y>\@_!TV^;N._4[X.RA_ +M!^'OL,G?=>QWPM]!^3L(?[^@_!V$O\,FI=6QWPE_!^7O(/P=-OF[ +MCOU.^#LH?P?A[[#)WW7L=\+?0?D["'^W(UGV.^'OH/P=A+_#)J75L=\)?P?E +M[R#\'3;YNX[]3O@[*'\'X>^PR=]U['?"WT'Y.PA_MR-9]COA[Z#\'82_PR:E +MU;'?"7\'Y>\@_!TV^;N._4[X.RA_!^'OL,G?=>QWPM]!^3L(?[^@ +M_!V$O\,FI=5GH7;"WT'Y.PA_ATW^KF>_$_X.RM]!^#ML\G<]^YWP=U#^#L+? +M[4B6_4[X.RA_!^'OL$EI]>QWPM]!^3L(?X=-_JYGOQ/^#LK?0?@[;/)W/?N= +M\'=0_@["W^U(EOU.^#LH?P?A[[!):?7L=\+?0?D["'^'3?ZN9[\3_@[*WT'X +M.VSR=SW[G?!W4/X.PM_M2);]3O@[*'\'X>^P26GU['?"WT'Y.PA_ATW^KF>_ +M$_X.RM]!^#ML\G<]^YWP=U#^#L+?[4B6_4[X.RA_%\5TD-<"YY;?`#=D2^VN +M2LJO_%.LG;NZNL%:'SB.>P'SZ^GZ/8[I(GMR&1^_/LSZQ3CS6*K^ZP`7../Z +M(<[?I4SW<1^KKT2+\W41?B3A_-]%7(L[?3?25 +MB/-W$WTEXOS=1%^).'\WT5+\W41?B3A_-]%7(L[?3?25B/-W$WTEXOS=1%^).'\WT5#\W49?"<[?;?25X/S=1E\)SM]M])7@_-U& +M7PG.WVWTE>#\W49?"<[?;?25X/S=1E\)SM]M])7@_-U&7PG.WVWTE>#\W49? +M"<[?;?25X/S=1E\)SM]M])7@_-U&7PG.WVWTE>#\W49?"<[?;?25X/S=1E\) +MSM]M])7@_-U&7PG.WVWTE>#\W49?"<[?;?25X/S=1E\)SM]M])7@_-U&7PG. +MWVWTE>#\W49?B3A_I^>S])6(\W=Z/DM?B3A_I^>S])6(\W=Z/DM?B3A_-]%7 +M(L[?3?25B/-W$WTEXOS=1%^).'\WT5+\W41?B3A_-]%7(L[?3?25B/-W$WTEXOS=1%^).'\W +MT5+\W41?B3A_ +M-]%7(L[?3?25B/-W$WTEXOS=1%\)SM]M])483/65&$SUE1A,]9483/65&$SU +ME1A,]9483/65&$SUE1A,]9483/65&$SUE1A,]9483/65&$SUE1A,]948L\Q0 +M7XG15%^)T51?B=%47XG15%^)T51?B=%47XG15%^)T51?B=%47XG15%^)T51? +MB=%47XG15%^)T51?B=%47WG,LLQ07WE\=*_CG7"/DUWT@4>8ZBN/QR>7\?'K +M*^;Z+7=7??QW^L#ER\/Z3P1$^W&`7.$:C@D7\.?&HO4:!C>.X;$HY^XSC'>Q +MOI+PYP>!ZXWKMW]_ET=9NJ9Y!/AWKF_>WZ+T]V,NZOGFO+PS;UE$N#GWLM/U +M??7U-^[U%V^^\V#_ND]WOKUSEWNRK:@\RGIU2*?[YS>/SXYBOKWS5/UC=379 +M/`GWV;63K9AO[SSV3\!=>Z3ABJ>B/O9.X,5\>V>-4O6MRP?7YFYL7-,GX/[P +M`.YD_,F;[SS;GES5^?L'EW#=?+/G_N1I:7>>3I/EG#BZ8^^5"!7!X5?O-&JZUK5XY7S46X'9X.-.S +MH_`WC+2[B'LX+-^8JY,;*_\%8K6,Y.7XN; +G,1A>Q#WQ#V#$M-#`Y-BUM8G(N<6-O=RYO=70`K9W+CAM)DD7W +M]174^RW1S()DA-YH8`:87<]B9K;%YYH?H(\?E13AGFD\5U;=5:I$08(4%Z3G +MT1&ZZ\ASO?[Y;;7:V&K8KH9I=3FLOO]X_K#5G1_<_UA]^^___*^W=[]]^^WG +MF*U_\53Z\>"KF.?N;?UCW>;\CZ>.J_7T)^:^?QC-W7EU\2^\NCMO]G;NY6\_ +MWRP_YVKP_MM=S7/+VS5Q>L.?>WU?T]NUGZ?W][U=%V]WHP:W]P;_.<_]/K\^ +M%V]WI^;&>W/7]'9=O-U)S>U_"8L+6`YJ[EC,#?C42ID;\2G!G97<3?B4X,Y*[O;XE.#.2NX. +M^)3@SDKNCOB4X,Y*[D[XE.#.2^[.^)3@SDON+OB4X,XK[HR?$MQYQ9V1[UQQ +MYQ5W1KYSQ9U7W!GYSA5W7G%GY#M7W'G%G9'O7'$7%7=&O@O%753<&?DN%'=1 +M^"\5=E-R1[T)Q%R5WY+M0W$7)'?DN%'=1^"\5=E-R1[T)Q-Y3\& +MQ=U0^&Q1W0\6=\U."NZ'BSLEW@^)NJ+AS\MV@N!LJ[IQ\-RCNAHH[)]\- +MBKNAXL[)=X/B;E-QY^2[C>)N4W'GY+N-XFY3^VRCN-B5WY+N-XFY3^ +MVRCN-B5WY+N-XFY3^VRCN-B5WY+N-XFY;^VRKNMB5WY+NMXFY;<1?\ +ME.!N6W$7Y+NMXFY;<1?DNZWB;EMQ%^2[K>)N6W$7Y+NMXFY;<1?DNZWB;E=Q +M%^2[G>)N5W$7Y+N=XFY7^VRGN=B5WY+N=XFY7^VRGN=B5WY+N=XFY7 +M^VRGN=B5WY+N=XFXLN2/?C8J[L>2.?#2.?#<;>ON-N0 +M[_:*NWW%W89\MU?<[2ON-N2[O>)N^<^0>HY\=U#<'2KN-N2[@^+N4')'OCLH +M[@XE=^2[@^+N4')'OCLH[@XE=^2[@^+N4')'OCLH[@XE=^2[@^+N6')'OCLJ +M[HXE=^2[H^+N6'&WY:<$=\>*NRWY[JBX.U;<;)N2[X[*NZ.%7=; +M\MU1<7>LN-N2[XZ*NU/%W99\=U+*NQWY[JRX.U?<[)N1[X[*^[.%7<[\MU9<7>NN-N1 +M[\Z*NTO%W8Y\=U'<72KN=N2[B^+N4G)'OKLH[BXE=^2[B^+N4G)'OKLH[BXE +M=^2[B^+N4G)'OKLH[BXE=^2[B^#.EN_H.?"=K05WMBZY`]_96G!GZXJ[D9]B +M[JSL[T;PG:G^SLK^;@3?F>KOK.SO1O"=J?[.ROYN!-^9ZN^L[.]&\)VI_L[* +M_FX$WYGJ[ZSL[T;PG:G^SLK^;@3?F>KOK.SO1O"=J?[.ROYN!-^9ZN^L[.]& +M\)VI_L[*_FX$WYGJ[ZSL[T;PG:G^SLK^;B3?J?[.ROYN)-^I_L[*_F[BIP1W +M97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O +M5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_ +M-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97^WYZ<$=V5_MR??J?[. +MROYN3[Y3_9V5_=V>?*?Z.RO[NSWY3O5W5O9W>_*=ZN^L[._VY#O5WUG9W^W) +M=ZJ_L[*_VY/O5']G97^W)]^I_L[*_FY/OE/]G97]W9Y\I_H[*_N[/?E.]7=6 +M]G=[\IWJ[ZSL[_;D.]7?6=G?[KOK.SO#N0[U=]9V=\=^2G!7=G?'KOK.SOCN0[U=]9 +MV=\=R7>JO[.ROSN2[U1_9V5_=R3?J?[.RO[N2+Y3_9V5_=V1?*?Z.RO[NR/Y +M3O5W5O9W1_*=ZN^L[.]._)3@KNSO3N0[U=]9V=^=R'>JO[.ROSN1[U1_9V5_ +M=R+?J?[.RO[N1+Y3_9V5_=V)?*?Z.RO[NQ/Y3O5W5O9W)_*=ZN^L[.].Y#O5 +MWUG9WYW(=ZJ_L[*_.Y'O5']G97]W(M^I_L[*_NY$OE/]G97]W8E\I_H[*_N[ +M$_E.]7=6]G=G?DIP5_9W9_*=ZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_.Y/O5']G +M97]W)M^I_L[*_NY,OE/]G97]W9E\I_H[*_N[,_E.]7=6]G=G\IWJ[ZSL[\[D +M.]7?6=G?GKOK.SO +M+N0[U=]9V=]=R'>JO[.RO[N0[U1_Y\MWTMRJSX'OOC_%W'GJ[Y;[]%:=._"= +MJ_[.4W^WFKE;+=S%FI]B[CSU=ZN9N]7O;0Y\YZJ_\]3?K:[I[(+NOW/5WWGJ +M[]K9]3GPG:O^SE-_!W/@.U?]G:?^#N;`=Z[Z.T_]W3+WH,^![USU=Y[ZNP?+ +MW*K-@>]<]7>>^KL',W]<]7>>^CN8`]^YZN\\]7JO_/4WSVKO//5W,$>^4_V=I_YNF7O4Y\AW +MJK_SU-\]6N8:=W3_G:O^SE-_]VCF[E'GCGRG^CM/_=VCF;M'G3ORG>KO//5W +MCZXW9T>^4_V=I_ZNG5V?(]^I_LY3?P=SY#O5WWGJ[V".?*?Z.T_]W3+WN,^1 +M[U1_YZF_>[S,=>[(=ZJ_\]3?/9ZY>]RXH_OO7/5WGOJ[QS-WCQMW=/^=J_[. +M4W_W^)K/CNZ_<]7?>>KOVMGU.?*=ZN\\]7JO_/4WRUS +M3_H<^4[U=Y[ZNR?+7...[K]SU=]YZN^>S-P]Z=R1[U1_YZF_>S)S]Z1S1[Y3 +M_9VG_N[)]>;LR'>JO_/4W[6SZW/D.]7?>>KO8(Y\I_H[3_T=S)'O5'_GJ;]; +MYI[V.?*=ZN\\]7=/E[G.'?E.]7>>^KNG,W=/&W=T_YVK_LY3?_=TYNYIXX[N +MOW/5WWGJ[YY>\]G1_7>N^CM/_5T[NSY'OE/]G:?^#N;(=ZJ_\]3?P1SY3O5W +MGOJ[9>Y9GR/?J?[.4W_W;)EKW-']=Z[Z.T_]W;.9NV>=._*=ZN\\]7?/9NZ> +M=>[(=ZJ_\]3?/;O>G!WY3O5WGOJ[=G9]CGRG^CM/_1W,D>]4?^>IOX,Y\IWJ +M[SSU=\O<\SY'OE/]G:?^[ODRU[DCWZG^SE-_]WSF[GGCCNZ_<]7?>>KOGL_< +M/6_>^CN8 +M(]^I_LY3?[?,O>ASY#O5WWGJ[UXL>^KL7UYNS(]^I_LY3?]?.KL^1[U1_YZF_@SGRG>KO//5W +M,$>^4_V=I_YNF7O9Y\AWJK_SU-^]7.8Z=^0[U=]YZN]>SMR];-S1_7>N^CM/ +M_=W+F;N7C3NZ_\Y5?^>IOWMYS6=']]^YZN\\]7?M[/H<^4[U=Y[Z.Y@CWZG^ +MSE-_!W/D.]7?>>KOEKE7?8Y\I_H[3_W=JV6N<4?WW[GJ[SSU=Z]F[EYU[LAW +MJK_SU-^]FKE[U;DCWZG^SE-_]^IZ>KOVMGU.?*=ZN\\]7JO_/4WRUSK_L<^4[U=Y[ZN]?+7.>.?*?Z.T_]W>N9N]>-.[K_ +MSE5_YZF_>SUS][IQ1_??N>KO//5WKZ_Y[.C^.U?]G:?^KIU=GR/?J?[.4W\' +M<^0[U=]YZN]@CGRG^CM/_=TR]Z;/D>]4?^>IOWNSS#7NZ/X[5_V=I_[NS7&_.CGRG^CM/_5T[NSY'OE/]G:?^ +M#N;(=ZJ_\]3?P1SY3O5WGOJ[9>YMGR/?J?[.J_XNZ/X[5_V=5_U=T/UWKOH[ +MK_J[H/OO7/5W7O5W0???N>KOO.KO@NZ_<]7?>=7?!=U_YZJ_\ZJ_"[K_SE5_ +MYZ*_>]?GR'>JO_/4W[U;YAIW=/^=J_[.4W_W;N;N7>>.?*?Z.T_]W;N9NW>= +M._*=ZN\\]7?OKC=G1[Y3_9VG_JZ=79\CWZG^SE-_!W/D.]7?>>KO8(Y\I_J[ +M6+Z3YM9]#GP7JK_[_A/WN%O\M.[<@>]"]7>1^KOUO+=NW-']=Z'ZNTC]W7KF +M;MVXH_OO0O5WD?J[]36?'=U_%ZJ_B]3?M;/K<^"[4/U=I/X.YL!WH?J[2/T= +MS('O0O5WD?J[9<[Z'/@N5'\7J;^S9:YQ1_??A>KO(O5W-K\\Z]R![T+U=Y'Z +M.YNYL\X=^"Y4?Q>IO[/KS=F![T+U=Y'ZNW9V?0Y\%ZJ_B]3?P1SX+E1_%ZF_ +M@SGP7:C^+E)_M\QYGR/?J?XN4G_GRUSGCGRG^KM(_9W/W'GCCNZ_"]7?1>KO +M?.;.&W=T_UVH_BY2?^?7?'9T_UVH_BY2?]?.KL^1[U1_%ZF_@SGRG>KO(O5W +M,$>^4_U=I/YNF8L^1[Y3_5VD_BZ6N<8=W7\7JK^+U-_%S%UT[LAWJK^+U-_% +MS%UT[LAWJK^+U-_%]>;LR'>JOXO4W[6SZW/D.]7?1>KO8(Y\I_J[2/T=S)'O +M5'\7J;];YH8^1[Y3_5VD_FY8YCIWY#O5WT7J[X:9NZ%Q1_??A>KO(O5WP\S= +MT+BC^^]"]7>1^KOAFL^.[K\+U=]%ZN_:V?4Y\IWJ[R+U=S!'OE/]7:3^#N;( +M=ZJ_B]3?+7.;/D>^4_U=I/YNL\PU[NC^NU#]7:3^;C-SM^G]4?Q>IO]O, +MW&TZ=^0[U=]%ZN\VUYNS(]^I_BY2?]?.KL^1[U1_%ZF_@SGRG>KO(O5W,$>^ +M4_U=I/YNF=OV.?*=ZN\B]7?;9:YS1[Y3_5VD_FX[<[=MW-']=Z'ZNTC]W7;F +M;MNXH_OO0O5WD?J[[36?'=U_%ZJ_B]3?M;/K<^0[U=]%ZN]@CGRG^KM(_1W, +MD>]4?Q>IOUOF=GV.?*?ZNTC]W6Z9:]S1_7>A^KM(_=UNYF[7N2/?J?XN4G^W +MF[G;=>[(=ZJ_B]3?[:XW9T>^4_U=I/ZNG5V?(]^I_BY2?P=SY#O5WT7J[V". +M?*?ZNTC]W3(W]CGRG>KO(O5WXS+7N2/?J?XN4G\WSMR-C3NZ_RY4?Q>IOQMG +M[L;&'=U_%ZJ_B]3?C==\=G3_7:C^+E)_U\ZNSY'O5'\7J;^#.?*=ZN\B]7

A^KM(_=TTKOEKGW?8Y\I_J[2/W=^V6N^4_U=I/[N_1^KOWUWQV=/]=J/XN4G_7SJ[/D>]4?Q>IOX,Y\IWJ[R+U +M=S!'OE/]7:3^;IG[T.?(=ZJ_B]3??5CF&G=T_UVH_BY2?_=AYNY#YXY\I_J[ +M2/W=AYF[#YT[\IWJ[R+U=Q^N-V='OE/]7:3^KIU=GR/?J?XN4G\'<^0[U=]% +MZN]@CGRG^KM(_=TR]['/D>]4?Q>IO_NXS'7NR'>JOXO4WWVKO(O5W,$>^ +M4_U=I/X.YLAWJK^+U-\M1^KM/RUSCCNZ_"]7?1>KO/LWK< +MD>]4?Q>IO_LT<_>I^4_U=I/[NT_7F[,AWJK^+U-^UL^MSY#O5WT7J[V". +M?*?ZNTC]'KO(O5WGY>YSAWY3O5WD?J[SS-WGQMW +M=/]=J/XN4G_W>>;N<^..[K\+U=]%ZN\^7_/9T?UWH?J[2/U=.[L^1[Y3_5VD +M_@[FR'>JOXO4W\$<^4[U=Y'ZNV7N2Y\CWZG^+E)_]V69:]S1_7>A^KM(_=V7 +MF;LOG3ORG>KO(O5W7V;NOG3NR'>JOXO4WWVYWIP=^4[U=Y'ZNW9V?8Y\I_J[ +M2/T=S)'O5'\7J;^#.?*=ZN^&Y3MI[FN?`]\-JK\;4G_W=9GKW('OOC_%W`VI +MO_LZ<_=UX6Y8\U/,W9#ZNZ\S=U]_;W/@NT'U=^UCF#RQO>_+CJY_LO +M^/ZQW\S?^?ZQMCMO^(^O46SZ#3]X>V>.OI3R7SD_NIWG5X.;S6J_OQG\G^7U +M^=_]Z?CQU\$WN]6P66VVJ]'_[!O^O__XW_2&?\[1EX__M\[OYUR)=7WB5#_\2WCLG;._?@;>BO@_<7\8>OSO03\M71EX__*^S=_)7KNY_G +M'U^`_OO_UE[^#$M-#`Y-BUM8G(N<6-O=S(N;W5T`*V8V;+3,`Q` +MW_L5+LL%+E!BR4Y3E@OX`%X3I=\13^>)%;C1)'BMI/6DVG'T1G9/E:6 +M+`L?8[PU+C=N8ZJMJ?]3`]/[,VSF^/O'SU7_H,2B%!L0I4:EPM15L-!$K<6HE##N22N$*(T[VS:NXT0I7EGT]Z50I3FG4U[ +MMQ6B-.]LVKN=$*5Y9]/>[84HS3M0O#,1=Q"B-.^`>;?>*<*\C3JAWH'D'S+LWA+N-.*'>@>8= +M,._>$NY=Q`GU#C3O@'GW?N2=%>H=:-XA\^X#L;*($^H=:MXA\\X2#B).J'>H +M>8?,.R2(?-N3;@BXH1ZAYIWR+S;$.YCQ`GU +M#C7OD'GWB7"?(TZH=ZAYA\R[+X2[BSBAWJ'FG6/>?27A7GO/UV\/[;"4>^8`!:7`*;S.>F@','_._I +M[]B_&C?;A@LX_>T`=70)VW-P[=N!WIE],_2.X;W>,N(FWPXTCSP'J4/-SL_L +MGBM87'^=VV>U77RH97?*W?J:F)]06V`PW(G\S'BXS46\>]AFJ]@N0&*X9HC; +M3J[M=';+<7:[F1?#\YUQYLYM(,.=&W`P;R&`MK+4!M9GC8]ZQ_'7:O@-0$?` +1V6;0Y#$M-#`Y-BUM8G(N(/I!8JM[0R04F8"W_PA!$1I`(8`W9=QWN'/ +M*NV^VE$WDW^/,DCI&X/^F8&WANV?JR;XXSX!<)0U@ +MW?DH!0[YA5'?*9=!2;@+^B`/UP7<,5VO(QS]"!=2W',QM\OJ=KFZIG`R[+0R +L5E9N@*25*S@J^Q#0YV7A&\BK\G'>X:\J[0(T';#8"1H*P.H-:WH%_)0&```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-mbr.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-mbr.vhd.gz.uu new file mode 100644 index 000000000000..92039f8fa627 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-mbr.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-mbr.vhd.gz +M'XL("/+%'50``VEM9RTQ>#$M-#`Y-BUM8G(N=FAD+F]U=`"METU3@S`0AN_] +M%>MX\]!)EF2A5T<].^.H5P'!\>#'J` +M`)0!M4`-D-37N0`Z0%X`J$%S8'_FYA:Z^NVUJ;^>O_?FU>T&&&>^56BN[3$# +MH1Z2`Y;Z(?2HKZ&SF/WIY=/9\\N3Q:'!V0<+`H$@%43,GD/,J=.DJ_.;BQ[Y +M,*K+YNI&*_6I!#`!G'LS,JONP6ET.*&LVK8_?GPV$WT8 +M*15R^OAL+(N[BZ94T$XV"H0NYS5WH:=\37$+I?*OZ%%H)\R%"@*3=@![]\/H +MC2CP]1%G*S&/)R.JK]3ZU-IBY<(Y/M"=[\.W`U;5-F#!!H4ASCE +M#44R!A-Y/"$G7ORJQ\3YK=IM0"EUQY@";ZV^.G4Z&@V4N>Z^DJ#`8QV^O[Q; +M6FY-9/7^L5DU^!O.">;'X#+32NU,OS+B`]U8)L.WQ8DU=7H)-YN@:E54@,KO";C`5U^8=1WF,O`P-T5?3!WM]2X/)S//1S^XBZ$N&HUM^OJ +M3N;JZL3):*#$M-#`Y-BUM8G(N=FAD9BYO=70`K96Q;H,P$(;W +M/,5%W3(@^[`/LD9-YTI5VS5`(,J0=NG0@8>OC3'8.)"D,AQ@=/;'?[ZS85J<6%*G$*Q^*%@9 +MN?9$/AGGYAF86B45L+SWH0\<\@NCOFTH`[UP%_1!&&ZA<9G?GSLXO!$N^+AR +M,;?+ZM:ANBIR,N1T9=RYTKXE_&J#H@=%F +MD/I?$:5`#5`-)'4[$T!;R'(7B'XEM=7W5UW]G'_=#&L<'_XGQF.K50AE@ +MH3]"1]UV]#WM3YOSY61Q=JNR'Q:D)UTJB`C")3_#$M-#`Y-BUM8G(N=FUD:RYO=70`K5Q=C]S&$7SW +MKZ"EER`/"]:27)(/`A+G'"`(`AB68[^&G]$AMB2<#D$,[(_/##DU5[P5-;2O +MY3V1H^VNG>[9JSM7%S;/US]95O9966;EF%67+$?F_FE]9'GQM'"/<\,GKG^_ +M^\>/)_[YP^ET_6H%@\^2%.0*)XO-ZUQ/S_X0[OREK,T3[G%.PA4^J[])#'#G +MG2=VX4KWY/ES*=Q=MSP]^AN!RR)0MH&K/E/3;K%?VMT?OPK-\_LK_![<\5[: +MK"ZR2Q^6V:5:UD56GY?G\JQV0;,#?)W=W7_Z3W8W?1H>[C\^?@C[._NS=<'E +MQ<=?!H_@"JLO_L8_X>%:#W&9LF+,"OBGL^O#7^]_GD[_G1X^W7]X_P8L]^S/ +MMBRRLO7;\?'YTV.S\"^29Q?XU\BN?_G;W9OPSLU/'[L'PODLMQ'WVJX.Q;U< +M,O]U^UAV-[U_](AS^!-WY\\V-*=:7KOT-U69U6VV;*?RV&?W]!A*7GHW/$S= +MX_3#KQ^G-Z]^^?`^]LZ?K6]9NP`U2Z.*K"H\5"C-MZ_RB/YMLYQ:=OWY_O'= +M_?#6E?EI>G5ZG1'NXGOG#K`)^UJK=BF7W9-UV[Y^^[]'5V\VAI.])]RRB:4( +M]]K5.:MJC^4.<#F*/6 +MDUX/>CF*<>Q/W=A]?)P>_/'&H^A]B\90J3_6\ND8MZ]3+R/0O\%%YA?G^7_-G/LT+S2EE4 +M&T#_4RQW7W]R7]\][>_B]W>1R%JS&EFT&[A_.8B/M^5>_'=A)Y&]9@VR&(]T +M[^*I;9+(^7GW^*L&Y'X?CK\+,++0K%(6U09NKW=5Z!TC:\UJ9-%NX/9Z=PF] +M8V2O68,LQD/%UJ%WC)PURU_XJQ3R`[^679K0.T86FE7*HMK`[?6N#;UC9*U9 +MC2S:#=Q>[[K0.T;VFC7(8CQ4;!]ZQ\A9L_R%!`&YWX<;0N\866A6*8MJ`[?7 +MNS'TCI&U9C6R:#=P>[V;0N\8V6O6((OQ4+%SZ!TC9\WREU)Z5Z;@ZCSTCI&% +M9I6RJ#9P.[VKR7>,K#6KD46[@=OI74V^8V2O68,LQD/%DN\8.6N6OU32NRH) +M1[YC9*%9I2RJ#=Q>[\AWC*PUJY%%NX';ZQWYCI&]9@VR&`\52[YCY*Q9_G*1 +MWEV2<.0[1A::50[1LZ: +MY2_\)0AROP]'OF-DH5FE+*H-W%[OR'>,K#6KD46[@=OK'?F.D;UF#;(8#Q5+ +MOF/DK%G^0D$&#V>D>^8V2M68TLV@W<7N_( +M=XSL-6N0Q7BH6/(=(V?-\A?^_Q/D?A^.?,?(0K-*650;N+W>D>\866M6(XMV +M`[?7._(=(WO-&F0Q'BJ6?,?(6;/\A?HCY'X?CGS'R$*S2EE4&[B]WI'O&%EK +M5B.+=@.WUSOR'2-[S1ID,1XJEGS'R%FS_&60W@TIN#8/O6-DH5FE+*H-W$[O +M6O(=(VO-:F31;N!V>M>2[QC9:]8@B_%0L>0[1LZ:Y2^C]&Y,PI'O&%EH5BF+ +M:@.WUSOR'2-KS6IDT6[@]GI'OF-DKUF#+,9#Q9+O&#EKEK],TKLI"4>^8V2A +M6:4LJ@W<7N_(=XRL-:N11;N!V^L=^8Z1O68-LA@/%4N^8^2L6?XR2^_F)!SY +MCI&%9I6RJ#9P>[TCWS&RUJQ&%NT&;J]WY#M&]IHUR&(\5"SYCI&S9N4R/8/< +M[\)U^=J[&%EH5BF+:@.WT[LN\%V,K#6KD46[@=OI71?X+D;VFC7(8CQ4;."[ +M&#EKEF^9Z'=(2EI=X#N(?@?5[R#Z'9+Z71?X#J+?0?4[B'Z'I'[7!;Z#Z'=0 +M_0ZBWQTH-O`=1+^#ZG<0_0Y)2:L+?`?1[Z#Z'42_0U*_ZP+?0?0[J'X'T>^0 +MU.^ZP'<0_0ZJWT'TNP/%!KZ#Z'=0_0ZBWR$I:76![R#Z'52_@^AW2.IW7>`[ +MB'X'U>\@^AV2^ET7^`ZBWT'U.XA^=Z#8P'<0_0ZJWT'T.R0EK3X/O1/]#JK? +M0?0[)/6[GGPG^AU4OX/H=TCJ=SWY3O0[J'X'T>\.%$N^$_T.JM]!]#LD):V> +M?"?Z'52_@^AW2.IW/?E.]#NH?@?1[Y#4[WKRG>AW4/T.HM\=*)9\)_H=5+^# +MZ'=(2EH]^4[T.ZA^!]'OD-3O>O*=Z'=0_0ZBWR&IW_7D.]'OH/H=1+\[4"SY +M3O0[J'X'T>^0E+1Z\IWH=U#]#J+?(:G?]>0[T>^@^AU$OT-2O^O)=Z+?0?4[ +MB'YWH%CRG>AW4/T.HM\A*6D->>B=Z'=0_0ZBWR&IWPWD.]'OH/H=1+]#4K\; +MR'>BWT'U.XA^=Z!8\IWH=U#]#J+?(2EI#>0[T>^@^AU$OT-2OQO(=Z+?0?4[ +MB'Z'I'XWD.]$OX/J=Q#][D"QY#O1[Z#Z'42_0U+2&LAWHM]!]3N(?H>D?C>0 +M[T2_@^IW$/T.2?UN(-^)?@?5[R#ZW8%BR7>BWT'U.XA^AZ2D-9#O1+^#ZG<0 +M_0Y)_6X@WXE^!]7O(/H=DOK=0+X3_0ZJWT'TNP/%DN]$OX/J=Q#]#DE):\Q# +M[T2_@^IW$/T.2?UN)-^)?@?5[R#Z'9+ZW4B^$_T.JM]!]+L#Q9+O1+^#ZG<0 +M_0Y)26LDWXE^!]7O(/H=DOK=2+X3_0ZJWT'T.R3UNY%\)_H=5+^#Z'<'BB7? +MB7X'U>\@^AV2DM9(OA/]#JK?0?0[)/6[D7PG^AU4OX/H=TCJ=R/Y3O0[J'X' +MT>\.%$N^$_T.JM]!]#LD):V1?"?Z'52_@^AW2.IW(_E.]#NH?@?1[Y#4[T;R +MG>AW4/T.HM\=*)9\)_H=5+^+9CK(O`F_*U=S&RT*P\__S#]#WOZ]_\3UF]/VOPB(_KYQM`%ES"O_=<@'MT +M5;AQC]69)@>!_8*_/@G<:-P_S+\-L*JRKKL!_"?W=[8^CN7S-:O:?^YL='.MD1P +E69AE]6+<_KW_Q/6[T_:_%;`,@&8=+/TGL>5?_1_0^/1A@%\````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-pc98.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-pc98.qcow.gz.uu new file mode 100644 index 000000000000..efca490443b9 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-pc98.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-pc98.qcow.gz +M'XL("+(S(E0``VEM9RTQ>#$M-#`Y-BUP8SDX+G%C;WG`Z^;F[L=JM;;5L%D-T^J\7WW_]?QAJY]^V___5?;W_^\>V/ +MNS&[^<53Z=>#KX9Y[M[6/[ZV.?_QU&%U,_W&W/+MK-;BY-_CO>>[/ +M^?6Y>+M;-3?>F[NDM^OB[4YJ;O=+6%S`LE=SAV)NP*>.:NY4S*WQJ3//V2^^ +MMG=S&WS*U)SCW*K-;?&I4'/W-7#S=@%ZF1OQ*<&=E=Q-^)3@SDKN=OB4X,Y* +M[O;XE.#.2NX.^)3@SDKNCOB4X,Y+[D[XE.#.2^[.^)3@+O_Q<\6=\5.".Z^X +M,_*=*^Z\XL[(=ZZX\XH[(]^YXLXK[HQ\YXH[K[@S\ITK[J+BSLAWH;B+BCLC +MWX7B+DKNR'>AN(N2._)=*.ZBY(Y\%XJ[*+DCWX7B+DKNR'>AN(N2._)=*.Z& +MDCORW:"X&TKNR'>#XFZHN'-^2G`W5-PY^6Y0W`T5=TZ^&Q1W0\6=D^\&Q=U0 +M<>?DNT%Q-U3<.?EN4-RM*^Z6W)'O1L7=6'$W\%."N['B;B#? +MC8J[L>)N(-^-BKNQXFX@WXV*N['B;B#?C8J[L>)N(-^-BKOE/W_K.?+=I+B; +M*NX&\MVDN)M*[LAWD^)N*KDCWTV*NZGDCGPW*>ZFDCORW:2XFTKNR'>3XFXJ +MN2/?38J[7)N7W)'OMLK[O8E=^2[O>)N7W)'OMLK[O8E=^2[O>)N7W)'OMLK[@XE +M=^2[@^+N4')'OCLH[@X5=QM^2G!WJ+C;D.\.BKM#Q=V&?'=0W!TJ[C;DNX/B +M[E!QMR'?'11WAXJ[#?GNH+@[5MQMR'='Q=VQXFY#OCLJ[HXE=^2[H^+N6')' +MOCLJ[HXE=^2[H^+N6')'OCLJ[HXE=^2[H^+N6')'OCLJ[DXE=^2[D^+N5')' +MOCLI[DX5=UM^2G!WJKC;DN].BKM3Q=V6?'=2W)TJ[K;DNY/B[E1QMR7?G11W +MIXJ[+?GNI+@[5]QMR7=GQ=VYXFY+OCLK[LXE=^2[L^+N7')'OCLK[LXE=^2[ +ML^+N7')'OCLK[LXE=^2[L^+N7')'OCL+[FSYB9X#W]F-X,YN2N[`=W8CN+.; +MBKN1GV+NK.SO1O"=J?[.ROYN!-^9ZN^L[.]&\)VI_L[*_FX$WYGJ[ZSL[T;P +MG:G^SLK^;@3?F>KOK.SO1O"=J?[.ROYN!-^9ZN^L[.]&\)VI_L[*_FX$WYGJ +M[ZSL[T;PG:G^SLK^;@3?F>KOK.SO1O"=J?[.ROYN)-^I_L[*_FXDWZG^SLK^ +M;N*G!'=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G +M97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O +M5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?[?CIP1W97^W +M(]^I_L[*_FY'OE/]G97]W8Y\I_H[*_N['?E.]7=6]G<[\IWJ[ZSL[W;D.]7? +M6=G?[]4?V=E?[^4_V=E?W=CGRG^CLK^[L= +M^4[U=U;V=SORG>KOK.SO=N0[U=]9V=_MR'>JO[.RO]OS4X*[LK_;D^]4?V=E +M?[KOK.SO]N0[ +MU=]9V=_MR7>JO[.RO]N3[U1_9V5_MR??J?[.ROYN3[Y3_9V5_=V>?*?Z.RO[ +MNSWY3O5W5O9W>_*=ZN^L[._VY#O5WUG9WQWX*<%=V=\=R'>JO[.ROSN0[U1_ +M9V5_=R#?J?[.RO[N0+Y3_9V5_=V!?*?Z.RO[NP/Y3O5W5O9W!_*=ZN^L[.\. +MY#O5WUG9WQW(=ZJ_L[*_.Y#O5']G97]W(-^I_L[*_NY`OE/]G97]W8%\I_H[ +M*_N[`_E.]7=6]G<'\IWJ[ZSL[X[\E."N[.^.Y#O5WUG9WQW)=ZJ_L[*_.Y+O +M5']G97]W)-^I_L[*_NY(OE/]G97]W9%\I_H[*_N[(_E.]7=6]G='\IWJ[ZSL +M[X[D.]7?6=G?']4?V=E?WKO +MK.SO3N0[U=]9V=^=R'>JO[.ROSN1[U1_9V5_=R+?J?[.RO[N1+Y3_9V5_=V) +M?*?Z.RO[NS,_);@K^[LS^4[U=U;V=V?RG>KOK.SOSN0[U=]9V=^=R7>JO[.R +MOSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9?*?Z.RO[NS/Y3O5W5O9W9_*= +MZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_.Y/O5'_GRT_2W*K/@>^^/\7<>>KOEOOT +M5IT[\)VK_LY3?[>:N5LMW,4-/\7<>>KO5C-WJS_;'/C.57_GJ;];7=+9!=U_ +MYZJ_\]3?M;/K<^`[5_V=I_X.YL!WKOH[3_T=S('O7/5WGOJ[9>Y!GP/?N>KO +M//5W#Y:Y59L#W[GJ[SSU=P]F[AYT[L!WKOH[3_W=@YF[!YT[\)VK_LY3?_?@ +MJO_/4WRUS#_L< +M^4[U=Y[ZNX?+7.>.?*?Z.T_]W<.9NX>-.[K_SE5_YZF_>SAS][!Q1_??N>KO +M//5W#R_Y[.C^.U?]G:?^KIU=GR/?J?[.4W\'<^0[U=]YZN]@CGRG^CM/_=TR +M]ZC/D>]4?^>IOWNTS#7NZ/X[5_V=I_[NT7:[.CGRG^CM/_5T[NSY'OE/]G:?^#N;(=ZJ_\]3?P1SY3O5WGOJ[ +M9>YQGR/?J?[.4W_W>)GKW)'O5'_GJ;][/'/WN'%']]^YZN\\]7>/9^X>-^[H +M_CM7_9VG_N[Q)9\=W7_GJK_SU-^UL^MSY#O5WWGJ[V".?*?Z.T_]']#GRG>KO//5W3Y:YQAW=?^>JO_/4WSV9N7O2N2/?J?[.4W_W9.;N +M2>>.?*?Z.T_]W9/+U=F1[U1_YZF_:V?7Y\AWJK_SU-_!'/E.]7>>^CN8(]^I +M_LY3?[?,/>USY#O5WWGJ[YXNXH_OO7/5WGOJ[9S-WSSIWY#O5WWGJ +M[Y[-W#WKW)'O5'_GJ;][=KDZ._*=ZN\\]7?M[/H<^4[U=Y[Z.Y@CWZG^SE-_ +M!W/D.]7?>>KOEKGG?8Y\I_H[3_W=\V6N^4_V=I_[N^>^KOGEWQV=/^=J_[.4W_7SJ[/D>]4?^>IOX,Y\IWJ +M[SSU=S!'OE/]G:?^;IE[T>?(=ZJ_\]3?O5CF&G=T_YVK_LY3?_=BYNY%YXY\ +MI_H[3_W=BYF[%YT[\IWJ[SSU=R\N5V='OE/]G:?^KIU=GR/?J?[.4W\'<^0[ +MU=]YZN]@CGRG^CM/_=TR][+/D>]4?^>IOWNYS'7NR'>JO_/4W[VKO//5W +M,$>^4_V=I_X.YLAWJK_SU-\M>^KM7RUSCCNZ_<]7?>>KO7LW< +MO>K]4?^>IOWLU<_>J^4_V=I_[NU>7J[,AWJK_SU-^UL^MSY#O5WWGJ +M[V".?*?Z.T_]']SGRG>KO//5WKY>YSAWY3O5WGOJ[US-W +MKQMW=/^=J_[.4W_W>N;N=>..[K]SU=]YZN]>7_+9T?UWKOH[3_U=.[L^1[Y3 +M_9VG_@[FR'>JO_/4W\$<^4[U=Y[ZNV7N39\CWZG^SE-_]V:9:]S1_7>N^CM/ +M_=V;F;LWG3ORG>KO//5W;V;NWG3NR'>JO_/4W[VY7)T=^4[U=Y[ZNW9V?8Y\ +MI_H[3_T=S)'O5'_GJ;^#.?*=ZN\\]7?+W-L^1[Y3_9U7_5W0_7>N^CNO^KN@ +M^^]<]7=>]7=!]]^YZN^\ZN^"[K]SU=]YU=\%W7_GJK_SJK\+NO_.57_G57\7 +M=/^=J_[.17_WKL^1[U1_YZF_>[?,->[H_CM7_9VG_N[=S-V[SAWY3O5WGOJ[ +M=S-W[SIWY#O5WWGJ[]Y=KLZ.?*?Z.T_]73N[/D>^4_V=I_X.YLAWJK_SU-_! +M'/E.]7>Q_"3-W?0Y\%VH_N[[)^YQM_CIIG,'O@O5WT7J[V[FO9O&'=U_%ZJ_ +MB]3?WKOVMGU.?!=J/XN4G\'<^"[ +M4/U=I/X.YL!WH?J[2/W=,F=]#GP7JK^+U-_9,M>XH_OO0O5WD?H[FU^>=>[` +M=Z'ZNTC]G<.?!>JOXO4W]GEZNS`=Z'ZNTC]73N[/@>^"]7?1>KO8`Y\ +M%ZJ_B]3?P1SX+E1_%ZF_6^:\SY'O5'\7J;_S9:YS1[Y3_5VD_LYG[KQQ1_?? +MA>KO(O5W/G/GC3NZ_RY4?Q>IO_-+/CNZ_RY4?Q>IOVMGU^?(=ZJ_B]3?P1SY +M3O5WD?H[F"/?J?XN4G^WS$6?(]^I_BY2?Q?+7...[K\+U=]%ZN]BYBXZ=^0[ +MU=]%ZN]BYBXZ=^0[U=]%ZN_BKO(O5W,$>^4_U= +MI/X.YLAWJK^+U-\M1^KO-,M>Y(]^I_BY2?[>9N=LT[NC^NU#] +M7:3^;C-SMVGKOVMGU.?*=ZN\B]7JOXO4WRUSVSY'OE/]7:3^;KO,->[H_KM0_5VD_FX[<[?MW)'O +M5'\7J;_;SMQM.W?D.]7?1>KOMI>KLR/?J?XN4G_7SJ[/D>]4?Q>IOX,Y\IWJ +M[R+U=S!'OE/]7:3^;ID;^QSY3O5WD?J[<9GKW)'O5'\7J;\;9^[&QAW=?Q>J +MOXO4WXTS=V/CCNZ_"]7?1>KOQDL^.[K_+E1_%ZF_:V?7Y\AWJK^+U-_!'/E. +M]7>1^CN8(]^I_BY2?[?,37V.?*?ZNTC]W;3,->[H_KM0_5VD_FZ:N9LZ=^0[ +MU=]%ZN^FF;NI^4_U=I/YNNER='?E.]7>1^KMV=GV.?*?ZNTC]'KO(O5WR]S[/D>^4_U=I/[N_3+7N2/?J?XN4G_W?N;N?>..[K\+ +MU=]%ZN_>S]R];]S1_7>A^KM(_=W[2SX[NO\N5'\7J;]K9]?GR'>JOXO4W\$< +M^4[U=Y'Z.Y@CWZG^+E)_M\Q]Z'/D.]7?1>KO/BQSC3NZ_RY4?Q>IO_LP<_>A +M^4_U=I/[NP\S=A\X=^4[U=Y'ZNP^7J[,CWZG^+E)_U\ZNSY'O5'\7J;^# +M.?*=ZN\B]7JOXO4WWU9NX^-.[K_+E1_%ZF_^WC)9T?WWX7J[R+U=^WL^ASY3O5W +MD?H[F"/?J?XN4G\'<^0[U=]%ZN^6N4]]CGRG^KM(_=VG9:YQ1_??A>KO(O5W +MGV;N/G7NR'>JOXO4WWV:N?O4N2/?J?XN4G_WZ7)U=N0[U=]%ZN_:V?4Y\IWJ +M[R+U=S!'OE/]7:3^#N;(=ZJ_B]3?+7.?^QSY3O5WD?J[S\M?+_GLZ/Z[4/U=I/ZNG5V? +M(]^I_BY2?P=SY#O5WT7J[V".?*?ZNTC]W3+WI<^1[U1_%ZF_^[+,->[H_KM0 +M_5VD_N[+S-V7SAWY3O5WD?J[+S-W7SIWY#O5WT7J[[Y^4_U=I/X.YLAWJK^+U-_!'/E.]7?#\I,T][7/@>\&U=\-J;_[NLQU[L!W +MWY]B[H;4WWV=N?NZ<#?<\%/,W9#ZNZ\S=U__;'/@NT'U=T/J[[Y>TMD-=/]= +M^]"?^/8V_?CVQ\O;P?7MVQU\=;.#O^M/?/O'V_M_M<';ZVK^@\'U>K6['OR? +M^0VO;Z^KF8;58:#W=3[WC^H-W\W1MS__*^F?_/'MIEM(*3]Q-W=U<=V6[N?I +M+^*'8$[T"?GJZ/N]_P58ME=WX/S\=;[]CO'?_^5X^?\?Z2+1]O5=]=='3?F] +MM_N+U[>Z?KNW?Z9M[__S]M.<%V]W=7]N_\NO[:]?W8/K5T??4_VO?#&N;G+Y +MS=^Y/T;N_\Z]F_._5P33K9E__+&S@[_K3WS[]]O[?]T-#K>#?_P_?B!?31"G +"```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-pc98.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-pc98.qcow2.gz.uu new file mode 100644 index 000000000000..afb67c951962 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-pc98.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-pc98.qcow2.gz +M'XL("*8[(U0``VEM9RTQ>#$M-#`Y-BUP8SDX+G%C;W<`$\Y4!5RHI;^$@BULK*;1P(8NKE)3EG<][5RLIRSN?]VZCI"SO +M?-Z[K9*RO/-Y[W9*RO+.Y[V[5U*6=V!XYQBW5U*6=R"\6Q+N&>,.2LKR#H1W +MSPGWHL-Y+65Y!\*[EX2[8)S2[\#R#H1WKPCWFG%*OP/+.Q#>O2'<)>.4?@>6 +M=R"\>TNX=XQ3^AU8WH'P[OW(.Z_T.["\0^'=!V(5C%/Z'5K>H?#.$PX8I_0[ +MM+Q#X1T2+C!.Z7=H>8?"NTBXDG%*OT/+.Q3>K0E7,4[I=VAYA\*[FG`?&:?T +M.[2\0^'=)\)]9IS2[]#R#H5W7PAWQ3BEWZ'E71#>?27<-\8I_2Y8W@7AW7?" +M73-.Z7?!\BX([VX(=]OA0$MUWA6%?A#N;G3/PKS/GX&?C[URM@/V@G'-?-71%+5\&I%?Z[^ZM,&.:;<,+9VWD:Z`KVI^#:[7SO +MF[[_<&8.#!_.EHR;W,XW>Y2]-F!6%^>5!:`2N?XZMYNK'>]"Q:-MM[Z.ZU.: +M`0RF.U&?&T^W^=7M=L=B%=L%R$S7#7';R;6=KFXYKFXW\V*@O#-.O',;R/#. +I33B8MQ&$]+]>T?;(T=D>./Y:#=\)&`@XVQ4,9?/;L?@/'U:4T(,4```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-pc98.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-pc98.raw.gz.uu new file mode 100644 index 000000000000..5398eaef066e --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-pc98.raw.gz.uu @@ -0,0 +1,11 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-pc98.raw.gz +M'XL("//%'50``VEM9RTQ>#$M-#`Y-BUP8SDX+G)A=RYO=70`K91!#H,@$$7W +MGF+<=F%@'*INFW3?3=NU-?44'+X@5`4$-0$,,?GP\C\#,&8:`"&P?F.,"_)6 +MN5T6EV*B\?$<4`CH0^!3`2<<:G\=P4"@_KP/QG'Y'$%67OOCN!)#D%T5%39P +M-BYEWC^<`HL&2("X0HM'';[OKXW`F"^PP>$>;C;,C^!JO6HU4[E%/N-B@L&5 +MEE4N.$JY4PCV/156Y#TLB*VW;EUG8.H,#\!:JZ$+G.L+B[\NM(%.W(0_"./V +M&M>X\_D*ASMQP<5]DK5-NRM#=T/F8M3^S3AX9G4"]1L9 +9C'%!/BJW&R!98+8=)-3`X@?$\J!S108````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-pc98.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-pc98.vhd.gz.uu new file mode 100644 index 000000000000..8df641e4f705 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-pc98.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-pc98.vhd.gz +M'XL("//%'50``VEM9RTQ>#$M-#`Y-BUP8SDX+G9H9"YO=70`K9=-;X,P#(;O +M_16N=NNA2HP3VNNT[CQIVG8M9;3:81]:>^B!'[\8$DCX6KL%*`H*?O+:<4PJ +M1'T`Z`3T'G0!6G$[)=!K2%<`IM->6-VE?80R__PH\M/;>6F/GK*[!+69V+NI4,8F1FKL)G804N6W2QL6A=YE4.1^_LN]CT=&' +M(ZFB&WVRUY>,NXLV5="];!40I_.4NU!13EW<0*K\*WHZM"/;,$$0RG5@Y7X8 +MO18%OCXMQ43,QR=C5%_&^LS:$MG`?;RCO%V&9P/<[:\#*L5+J`M\<@[GK&]- +MD--0W'TG+UH=^4CV_7E^B\CQP\IAE7*Y5!I6>*G"E\WS@,,8S^$:A[_A&L'R +M$EQB:Y][TZC%YFLSVE'CYI8U;W$TI8[77'&5LRINLF"^ZMCY\PS"Y'`.8N55 +M!0_8S"^T^M9]&1BX.Z$/^NYFC$O#]Z6'PU_'*K7$8MQ!059E-!G*-[-W'.\J'97C60+2E/MJW`VUMCJ:0+#":0K+5 +M.:)"*B:3[=HLU%9AI(TXXR)NQ!D7<2/.N(@;<<9%W(@S+N)&G'%1-^+:_,42 ++8O8#/[LV_KT-```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-pc98.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-pc98.vhdf.gz.uu new file mode 100644 index 000000000000..49a64aac2ce1 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-pc98.vhdf.gz.uu @@ -0,0 +1,14 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-pc98.vhdf.gz +M'XL("//%'50``VEM9RTQ>#$M-#`Y-BUP8SDX+G9H9&8N;W5T`*V5L6Z#,!"& +M]SS%1=TR1/BP#UBCIG.EJNT:0B'*T';IT(&'KVU,\&$@266PD-'AC__WV>,DO#/J*4`8RNPOZ(+1;&ES&OQ<>#J_8!8X[+N9V6=TZ5%=%3D8ZWADW[EP# +MX3NWPV'<0B!M9=8KT-3(X#D?:)^W_.Z`T@&CS2"YLX-2H`:H!E*FGTF@`K+< +M!R)?26WU_557/^=?/\,&)T85W6]F/*9FMU`&6)J?T(?I>_H>]J?-^?/4X_I2 +MU?]8DIETI2$RL$O<[M/NY=$B#X.Z-)PD\F?OJ$\H"4(PXT[=@2]GLOGMS=8- +D')65V3?VP@*3I#$M-#`Y-BUP8SDX+G9M9&LN;W5T`*U<76_#@>0B!PB"`,;Y>7E>+MKIWMV2W)U8=-T_4J2O$OR/,F'I"B3%,G\3^LM2;.'Q7P[UWS@\O>; +M?_QTXM7AP%P*7!*!D`U<\4=-NL<_M[H^O?//<_C*WA_EXRR:I +MLJ3L_#(IBV6=)=5Y>2Q-JCEHF@&_2VYNO_XGN1F_]G>W7^X_^_V=W=G.P7GI +MXLO>(@N6>W=GF +M69(W;CLN/GVX;1;N2=*DA'N.Y/*7O]V\]:_<]/2EO2.?,E+[_J[L;T? +M?_SV97S[YN/G3Z%W[FQ=RYH%J%X:E25%YJ!\::Y]A4-T+YOEU)++K[?WO]SV +M'^8ROXYO3M\EA"M=[^8#K/V^UJKGE'+W9.=M7][][WZN-QG\R=X2;MG$4L3\ +MW,4Y*2J'-1_@>.*_/&7<7D%$JY9WV8N>#T'+,NSN_!= +M6^$=B>7N@>5DDYOVODV^;[^.I^]N;KX/)]NZ8O/E-F]M="CE"NU>WTL[Y\:M +M)[T>]'(4P]"=VJ']N>,-1]&Y%@V^4G>L^<,Q;I^G6DYJ7,[ +MS&?J8/\]?OY(N'Y]&<_[<"^)9DG,W,7\ZEG@1_\,ZRO&'9.#&^_OOIWZ;[_> +M?AKF-UKREG##VKMY.^MI/ASF?(#S#I_YW9V?WH?OU*.GFM&3RT/7%MRO'BY+/05DGLHV +M+0K;69]0"'3L[S_?K1M[(WR99I7BZ+ +M8@/H?HJE\_>?YN_W#_LKW?Y*B:PTJY9%LX'[UPSQY;KZ6CME$BI\?=XZ\:D.M]./XNP,A,LW)9%!NXO=X5OG>,K#2KED6S@=OK7>E[ +MQ\A.LWI9#(>*K7SO&#EIEKOCKU)(#_Q:5M:^=XS,-"N71;&!V^M=XWO'R$JS +M:EDT&[B]WK6^=XSL-*N7Q7"HV,[WCI&39KD[$@3D>A^N][UC9*99N2R*#=Q> +M[P;?.T96FE7+HMG`[?5N]+UC9*=9O2R&0\5.OG>,G#3+W>72NSP&5Z6^=XS, +M-"N71;&!V^E=1;YC9*59M2R:#=Q.[RKR'2,[S>IE,1PJEGS'R$FSW%TAO2NB +M<.0[1F::E0[1DZ:Y>Y* +MZ5T9A2/?,3+3K%P6Q09NKW?D.T96FE7+HMG`[?6.?,?(3K-Z60R'BB7?,7+2 +M+'?'7X(@U_MPY#M&9IJ5RZ+8P.WUCGS'R$JS:EDT&[B]WI'O&-EI5B^+X5"Q +MY#M&3IKE[BC(0*YWX>K4]XZ1F6;ELB@V<#N]J\EWC*PTJY9%LX';Z5U-OF-D +MIUF]+(9#Q9+O&#EIEKMKI'=-%(Y\Q\A,LW)9%!NXO=Z1[QA9:58MBV8#M]<[ +M\ATC.\WJ93$<*I9\Q\A)L]P=__\$N=Z'(]\Q,M.L7!;%!FZO=^0[1E::5*)=\Q^8V2F6;DLB@W<7N_(=XRL +M-*N61;.!V^L=^8Z1G6;ULA@.%4N^8^2D6>ZNE][U,;@F];UC9*99N2R*#=Q. +M[QKR'2,KS:IET6S@=GK7D.\8V6E6+XOA4+'D.T9.FN7N!NG=$(4CWS$RTZQ< +M%L4&;J]WY#M&5II5RZ+9P.WUCGS'R$ZS>ED,AXHEWS%RTBQW-TKOQB@<^8Z1 +MF6;ELB@V<'N](]\QLM*L6A;-!FZO=^0[1G::U,S#0KET6Q@=OK'?F.D95FU;)H-G![O2/?,;+3K%X6PZ%BR7>,G#0KE>D9 +MY'H7KDW7WH7(3+-R610;N)W>M9[O0F2E6;4LF@W<3N]:SW\0U>]:SW<0_0ZJWT'T.T3UN];S'42_ +M@^IW$/WN0+&>[R#Z'52_@^AWB$I:K><[B'X'U>\@^AVB^EWK^0ZBWT'U.XA^ +MAZA^UWJ^@^AW4/T.HM\=*-;S'42_@^IW$/T.44FK]7P'T>^@^AU$OT-4OVL] +MWT'T.ZA^!]'O$-7O6L]W$/T.JM]!]+L#Q7J^@^AW4/T.HM\A*FEUJ>^=Z'=0 +M_0ZBWR&JWW7D.]'OH/H=1+]#5+_KR'>BWT'U.XA^=Z!8\IWH=U#]#J+?(2II +M=>0[T>^@^AU$OT-4O^O(=Z+?0?4[B'Z'J'[7D>]$OX/J=Q#][D"QY#O1[Z#Z +M'42_0U32ZLAWHM]!]3N(?H>H?M>1[T2_@^IW$/T.4?VN(]^)?@?5[R#ZW8%B +MR7>BWT'U.XA^AZBDU9'O1+^#ZG<0_0Y1_:XCWXE^!]7O(/H=HOI=1[X3_0ZJ +MWT'TNP/%DN]$OX/J=Q#]#E%)JT]][T2_@^IW$/T.4?VN)]^)?@?5[R#Z':+Z +M74^^$_T.JM]!]+L#Q9+O1+^#ZG<0_0Y12:LGWXE^!]7O(/H=HOI=3[X3_0ZJ +MWT'T.T3UNYY\)_H=5+^#Z'<'BB7?B7X'U>\@^AVBDE9/OA/]#JK?0?0[1/6[ +MGGPG^AU4OX/H=XCJ=SWY3O0[J'X'T>\.%$N^$_T.JM]!]#M$):V>?"?Z'52_ +M@^AWB.IW/?E.]#NH?@?1[Q#5[WKRG>AW4/T.HM\=*)9\)_H=5+^#Z'>(2EI# +MZGLG^AU4OX/H=XCJ=P/Y3O0[J'X'T>\0U>\&\IWH=U#]#J+?'2B6?"?Z'52_ +M@^AWB$I:`_E.]#NH?@?1[Q#5[P;RG>AW4/T.HM\AJM\-Y#O1[Z#Z'42_.U`L +M^4[T.ZA^!]'O$)6T!O*=Z'=0_0ZBWR&JWPWD.]'OH/H=1+]#5+\;R'>BWT'U +M.XA^=Z!8\IWH=U#]#J+?(2II#>0[T>^@^AU$OT-4OQO(=Z+?0?4[B'Z'J'XW +MD.]$OX/J=Q#][D"QY#O1[Z#Z73#30:X%+EF_/=R8KKT+D9EFI>G3M[EW,T2: +M7.UN-/8'8O$'AIG"6M7O`USAK/<7YMO2OX>\W^I?1)AO\_8B_R+"?)NW%_D7 +M$>;;O+W(OX@PWS;Q+R+,MTW\BPCS;1/_(L)\V\2_B##?-O$O(LRW3?R+"/-M +M$_\BPGS;Q+^(,-\V\2\BS+=-_(L(\VT3_R+"?-O$OX@PWS;Q+R+,MTW\BPCS +M;1/_(L)\V\2_B##?-O$O(LRW3?R+"/-M$_\BPGS;Q+^(,-\V\2\BS+=-_(L( +M\VT3_R+"?-O$OX@PWS;Q+R+,MTW\BPCS;1/_(L)\V\2_",ZW;?R+X'S;QK\( +MSK=M_(O@?-O&OPC.MVW\B^!\V\:_",ZW;?R+X'S;QK\(SK=M_(O@?-O&OPC. +MMVW\B^!\V\:_",ZW;?R+X'S;QK\(SK=M_(O@?-O&OPC.MVW\B^!\V\:_",ZW +M;?R+X'S;QK\(SK=M_(O@?-O&OPC.MVW\B^!\V\:_",ZW;?R+X'S;QK\(SK=M +M_(O@?-O&OPC.MVW\B^!\V\:_",ZW;?R+X'S;QK^(,-]FY(O\BPCS;4:^R+^( +M,-]FY(O\BPCS;4:^R+^(,-\V\2\BS+=-_(L(\VT3_R+"?-O$OX@PWS;Q+R+, +MMTW\BPCS;1/_(L)\V\2_B##?-O$O(LRW3?R+"/-M$_\BPGS;Q+^(,-\V\2\B +MS+=-_(L(\VT3_R+"?-O$OX@PWS;Q+R+,MTW\BPCS;1/_(L)\V\2_B##?-O$O +M(LRW3?R+"/-M$_\BPGS;Q+^(,-\V\2\BS+=-_(L(\VT3_R+"?-O$OPC.MVW\ +MBQA-_8L83?V+&$W]BQA-_8L83?V+&$W]BQA-_8L83?V+&$W]BQA-_8L83?V+ +M&$W]BQA-_8L83?V+&$W]BYC2U-"_B,G4OXC)U+^(R=2_B,G4OXC)U+^(R=2_ +MB,G4OXC)U+^(R=2_B,G4OXC)U+^(R=2_B,G4OXC)U+^(R=2_>$[3U-"_>+[Z +M+.%-UC[<=;&K/S!?]K=^.NCUW_L/7+X_;?\$0$R_#;`HDO8:\)^^X'SYO-XF +M3_K\J;JFZ>$6*WB%L^Y?;MR_>;/.RON=[&>5/N,_N[XI9R^1!@_?A5/<4-V^V4FVSA +MNF?/]OG=O;[>76]\&%M`MN_<%>YL2P3UPLRK>>+Z[_T'+N]/VS\K +.8+X`OOH_SBV/UN!>```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow.gz.uu new file mode 100644 index 000000000000..ddcfe733f234 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow.gz.uu @@ -0,0 +1,125 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-vtoc8.qcow.gz +M'XL("+,S(E0``VEM9RTQ>#$M-#`Y-BUV=&]C."YQ8V]W+F]U=`"MG=NN&\>2 +M!=_]%=3]+C$SFV2W[C@8'&`>!CB#^0'S^DS,LSY^).WN*NUD+.49V+)@2!!J +M@;L4#AAVH+1>WWU;K3:V&K:K85I=#JOO/Y^_V^J7G]S_OOKVW__\S[>_?OOV +MQ]V8K7]S*OU\\)7-<_>V_M'G_,>IXVH]_1MSW[_CW"^?+OX?G^Z7+_9V[N4? +M=U\LGW,U&/<&5_/<>OY\)FYO^/<^W]?TY=K=[?U]7ZZ++W>C!K?W!O\US_TY +M?SX77^Y.S8WWYJ[IRW7QY4YJ;O];6%S`<6?D.U?<1<6=D>]"<1<5=T:^"\5= +ME-R1[T)Q%R5WY+M0W$7)'?DN%'=1^"\5=E-R1[T)Q%R5WY+M0W`TE=^2[ +M07$WE-R1[P;%W5!QYWQ*<#=4W#GY;E#<#15W3KX;%'=#Q9V3[P;%W5!QY^2[ +M07$W5-PY^6Y0W&TJ[IQ\MU'<;2KNG'RW4=QM2N[(=QO%W:;DCGRW4=QM2N[( +M=QO%W:;DCGRW4=QM2N[(=QO%W:;DCGRW4=QM2^[(=UO%W;;DCGRW5=QM*^Z" +M3PGNMA5W0;[;*NZV%7=!OMLJ[K85=T&^VRKNMA5W0;[;*NZV%7=!OMLJ[G85 +M=T&^VRGN=A5W0;[;*>YV)7?DNYWB;E=R1[[;*>YV)7?DNYWB;E=R1[[;*>YV +M)7?DNYWB;E=R1[[;*>[&DCORW:BX&TONR'>CXFZLN!OXE.!NK+@;R'>CXFZL +MN!O(=Z/B;JRX&\AWH^)NK+@;R'>CXFZLN!O(=Z/B;OG/WWJ.?#ZFDCORW:2XFTKNR'>3 +MXFY?^VRON]B5WY+N]XFY?<;?A4X*[?<7=AGRW5]SM*^XVY+N]XFY?<;\7=\K\A]1SY[J"X.U3<;2.?'=0 +MW!U*[LAW!\7=H>2.?'=0W!U*[LAW!\7=H>2.?'=0W!U*[LAW!\7=L>2.?'=4 +MW!U+[LAW1\7=L>)NRZ<$=\>*NRWY[JBX.U;<;)N2[X[*NZ.%7=; +M\MU1<7>LN-N2[XZ*NU/%W99\=U+ZLN#M7W.W( +M=V?%W:7B;D>^NRCN+A5W._+=17%W*;DCWUT4=Y>2._+=17%W*;DCWUT4=Y>2 +M._+=17%W*;DCWUT4=Y>2._+=17!GRP_T'/C.UH([6Y?<@>]L+;BS=<7=R*>8 +M.RO[NQ%\9ZJ_L[*_&\%WIOH[*_N[$7QGJK^SLK\;P7>F^CLK^[L1?&>JO[.R +MOQO!=Z;Z.RO[NQ%\9ZJ_L[*_&\%WIOH[*_N[$7QGJK^SLK\;P7>F^CLK^[L1 +M?&>JO[.ROQO!=Z;Z.RO[NQ%\9ZJ_L[*_&\EWJK^SLK\;R7>JO[.ROYOXE."N +M[.\F\IWJ[ZSL[R;RG>KOK.SO)O*=ZN^L[.\F\IWJ[ZSL[R;RG>KOK.SO)O*= +MZN^L[.\F\IWJ[ZSL[R;RG>KOK.SO)O*=ZN^L[.\F\IWJ[ZSL[R;RG>KOK.SO +M)O*=ZN^L[.\F\IWJ[ZSL[R;RG>KOK.SO)O*=ZN^L[._V?$IP5_9W>_*=ZN^L +M[._VY#O5WUG9W^W)=ZJ_L[*_VY/O5']G97^W)]^I_L[*_FY/OE/]G97]W9Y\ +MI_H[*_N[/?E.]7=6]G=[\IWJ[ZSL[_;D.]7?6=G?[KOK.SO#N0[U=]9V=\=R'>JO[.ROSN0[U1_9V5_=R#?J?[.RO[N +M0+Y3_9V5_=V!?*?Z.RO[NP/Y3O5W5O9W!_*=ZN^L[.\.Y#O5WUG9WQW(=ZJ_ +ML[*_.Y#O5']G97]W(-^I_L[*_N[(IP1W97]W)-^I_L[*_NY(OE/]G97]W9%\ +MI_H[*_N[(_E.]7=6]G='\IWJ[ZSL[X[D.]7?6=G?'KOK.SOCN0[ +MU=]9V=\=R7>JO[.ROSOQ*<%=V=^=R'>JO[.ROSN1[U1_9V5_=R+?J?[.RO[N +M1+Y3_9V5_=V)?*?Z.RO[NQ/Y3O5W5O9W)_*=ZN^L[.].Y#O5WUG9WYW(=ZJ_ +ML[*_.Y'O5']G97]W(M^I_L[*_NY$OE/]G97]W8E\I_H[*_N[$_E.]7=6]GKOK.SOSN0[ +MU=]9V=^=R7>JO[.ROSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9?*?Z.RO[ +MNPN?$MR5_=V%?*?Z.RO[NPOY3O5W5O9W%_*=ZN^L[.\NY#O5WUG9WUW(=ZJ_ +ML[*_NY#O5']G97]W(=^I_L[*_NY"OE/]G97]W85\I_H[*_N["_E.]7=6]G<7 +M\IWJ[ZSL[R[D.]7?6=G?7<.?.>J +MO_/4WZUF[E8+=['F4\R=I_YN-7.W^K/-@>]<]7>>^KO5-=U=T/MWKOH[3_U= +MN[L^![YSU=]YZN]@#GSGJK_SU-_!'/C.57_GJ;];YA[T.?"=J_[.4W_W8)E; +MM3GPG:O^SE-_]V#F[D'G#GSGJK_SU-\]F+E[T+D#W[GJ[SSU=P^N-W<'OG/5 +MWWGJ[]K=]3GPG:O^SE-_!W/@.U?]G:?^#N;`=Z[Z.T_]W3+WL,^1[U1_YZF_ +M>[C,=>[(=ZJ_\]3?/9RY>]BXH_?O7/5WGOJ[AS-W#QMW]/Z=J_[.4W_W\)KO +MCMZ_<]7?>>KOVMWU.?*=ZN\\]7JO_/4WRUSC_H<^4[U +M=Y[ZNT?+7...WK]SU=]YZN\>S=P]ZMR1[U1_YZF_>S1S]ZAS1[Y3_9VG_N[1 +M]>;NR'>JO_/4W[6[ZW/D.]7?>>KO8(Y\I_H[3_T=S)'O5'_GJ;];YA[W.?*= +MZN\\]7>/E[G.'?E.]7>>^KO',W>/&W?T_IVK_LY3?_=XYNYQXX[>OW/5WWGJ +M[QY?\]W1^W>N^CM/_5V[NSY'OE/]G:?^#N;(=ZJ_\]3?P1SY3O5WGOJ[9>Y) +MGR/?J?[.4W_W9)EKW-'[=Z[Z.T_]W9.9NR>=._*=ZN\\]7=/9NZ>=.[(=ZJ_ +M\]3?/;G>W!WY3O5WGOJ[=G=]CGRG^CM/_1W,D>]4?^>IOX,Y\IWJ[SSU=\O< +MTSY'OE/]G:?^[NDRU[DCWZG^SE-_]W3F[FGCCMZ_<]7?>>KOGL[>^CN8(]^I_LY3 +M?[?,/>MSY#O5WWGJ[YXMO_.57_GJ;][-G/WK'-'OE/]G:?^[MG,W;/. +M'?E.]7>>^KMGUYN[(]^I_LY3?]?NKL^1[U1_YZF_@SGRG>KO//5W,$>^4_V= +MI_YNF7O>Y\AWJK_SU-\]7^8Z=^0[U=]YZN^>S]P];]S1^W>N^CM/_=WSF;OG +MC3MZ_\Y5?^>IOWM^S7='[]^YZN\\]7?M[OH<^4[U=Y[Z.Y@CWZG^SE-_!W/D +M.]7?>>KOEKD7?8Y\I_H[3_W=BV6N<4?OW[GJ[SSU=R]F[EYT[LAWJK_SU-^] +MF+E[T;DCWZG^SE-_]^)Z>KOVMWU.?*=ZN\\]7JO_/4WRUS+_L<^4[U=Y[ZNY?+7.>.?*?Z.T_]W-.WK_SE5_YZF_ +M>SES][)Q1^_?N>KO//5W+Z_Y[NC].U?]G:?^KMU=GR/?J?[.4W\'<^0[U=]Y +MZN]@CGRG^CM/_=TR]ZK/D>]4?^>IOWNUS#7NZ/T[5_V=I_[NU76_NCGRG^CM/_5V[NSY'OE/]G:?^#N;(=ZJ_ +M\]3?P1SY3O5WGOJ[9>YUGR/?J?[.4W_W>IGKW)'O5'_GJ;][/7/WNG%'[]^Y +MZN\\]7>O9^Y>-^[H_3M7_9VG_N[U-=\=O7_GJK_SU-^UN^MSY#O5WWGJ[V". +M?*?Z.T_]']#GRG>KO//5W;Y:YQAV]?^>JO_/4W[V9N7O3 +MN2/?J?[.4W_W9N;N3>>.?*?Z.T_]W9OKS=V1[U1_YZF_:W?7Y\AWJK_SU-_! +M'/E.]7>>^CN8(]^I_LY3?[?,O>USY#O5WWG5WP6]?^>JO_.JOPMZ_\Y5?^=5 +M?Q?T_IVK_LZK_B[H_3M7_9U7_5W0^W>N^CNO^KN@]^]<]7=>]7=![]^YZN]< +M]'?O^ASY3O5WGOJ[=\MOW/5WWGJ[][-W+WKW)'O5'_GJ;][-W/WKG-' +MOE/]G:?^[MWUYN[(=ZJ_\]3?M;OK<^0[U=]YZN]@CGRG^CM/_1W,D>]4?Q?+ +M#]+O\N5'\7J;];S]RM +M&W?T_EVH_BY2?[>^YKNC]^]"]7>1^KMV=WT.?!>JOXO4W\$<^"Y4?Q>IOX,Y +M\%VH_BY2?[?,69\#WX7J[R+U=[;,->[H_;M0_5VD_L[FCV>=._!=J/XN4G]G +M,W?6N0/?A>KO(O5W=KVY._!=J/XN4G_7[J[/@>]"]7>1^CN8`]^%ZN\B]7

]SY#O5WT7J[WR9Z]R1[U1_%ZF_\YD[;]S1^W>A^KM(_9W/ +MW'GCCMZ_"]7?1>KO_)KOCMZ_"]7?1>KOVMWU.?*=ZN\B]7JOXO4WRUST>?(=ZJ_B]3?Q3+7N*/W[T+U=Y'ZNYBYB\X=^4[U=Y'ZNYBY +MB\X=^4[U=Y'ZN[C>W!WY3O5WD?J[=G=]CGRG^KM(_1W,D>]4?Q>IOX,Y\IWJ +M[R+U=\O^4_U=I/X.YLAWJK^+U-_!'/E. +M]7>1^KME;M/GR'>JOXO4WVV6N<8=O7\7JK^+U-]M9NXVG3ORG>KO(O5WFYF[ +M3>>.?*?ZNTC]W>9ZKOVMWU.?*=ZN\B]7J +MOXO4WRUSVSY'OE/]7:3^;KO,=>[(=ZJ_B]3?;6?NMHT[>O\N5'\7J;_;SMQM +M&W?T_EVH_BY2?[>]YKNC]^]"]7>1^KMV=WV.?*?ZNTC]'KO(O5WR]RNSY'O5'\7J;_;+7.-.WK_+E1_%ZF_V\W<[3IWY#O5WT7J[W8S +M=[O.'?E.]7>1^KO=]>;NR'>JOXO4W[6[ZW/D.]7?1>KO8(Y\I_J[2/T=S)'O +M5'\7J;];YL8^1[Y3_5VD_FYKO(O5WX\S= +MV+BC]^]"]7>1^KOQFN^.WK\+U=]%ZN_:W?4Y\IWJ[R+U=S!'OE/]7:3^#N;( +M=ZJ_B]3?+7-3GR/?J?XN4G\W+7.-.WK_+E1_%ZF_FV;NILX=^4[U=Y'ZNVGF +M;NK]4?Q>IOYNN-W='OE/]7:3^KMU=GR/?J?XN4G\'<^0[U=]%ZN]@CGRG +M^KM(_=TR][[/D>]4?Q>IOWN_S'7NR'>JOXO4W[V?N7O?N*/W[T+U=Y'ZN_OPO5WT7J[]K=]3GRG>KO(O5W,$>^4_U=I/X. +MYLAWJK^+U-\M1^KL/RUSCCMZ_"]7?1>KO/LSC]4?Q>I +MO_LP<_>A^4_U=I/[NP_7F[LAWJK^+U-^UN^MSY#O5WT7J[V".?*?ZNTC] +M'KO(O5W'Y>YSAWY3O5WD?J[CS-W'QMW]/Y=J/XN +M4G_W<>;N8^..WK\+U=]%ZN\^7O/=T?MWH?J[2/U=N[L^1[Y3_5VD_@[FR'>J +MOXO4W\$<^4[U=Y'ZNV7N4Y\CWZG^+E)_]VF9:]S1^W>A^KM(_=VGF;M/G3OR +MG>KO(O5WGV;N/G7NR'>JOXO4WWVZWMP=^4[U=Y'ZNW9W?8Y\I_J[2/T=S)'O +M5'\7J;^#.?*=ZN\B]7?+W.<^1[Y3_5VD_N[S,M>Y(]^I_BY2?_=YYNYSXX[> +MOPO5WT7J[S[/W'UNW-'[=Z'ZNTC]W>=KOCMZ_RY4?Q>IOVMWU^?(=ZJ_B]3? +MP1SY3O5WD?H[F"/?J?XN4G^WS'WI<^0[U=]%ZN^^+'.-.WK_+E1_%ZF_^S)S +M]Z5S1[Y3_5VD_N[+S-V7SAWY3O5WD?J[+]>;NR/?J?XN4G_7[J[/D>]4?Q>I +MOX,Y\IWJ[R+U=S!'OE/]W;#\(,U][7/@NT'U=T/J[[XN=CM5S/WR[=L?+W\.;GY^OF&[VOEJ +MN_GQ??#5)E;#\.-_7:Z&DQK\Y_^>S__XG_\8_NO>Y]O\_9_O_C^W]OO!<;6> +M5FO'P;NY7_ZYG"#7P;OYGY\N7>'\^^PJ;GOO_#MPOO]4_[Q?X8;4W9_I0`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow2.gz.uu new file mode 100644 index 000000000000..426bfa74b1e6 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-vtoc8.qcow2.gz +M'XL("*@[(U0``VEM9RTQ>#$M-#`Y-BUV=&]C."YQ8V]W,BYO=70`K9C;CM,P +M$(;O^Q3NM4O7;\9%4G@)<"`$S?CHOH@ +MU$<3YL+Z8.GZD%\_>\S1@7*^/@SUT=1&PE59'#"I6L)MLSAD4HV$VV5QADFU +M$LYE<99)[06>^V3$KR +M3N>]:YB4Y)W.>[=C4I)W.N]=RZ0D[T#P3B6<8U*2=T"\6T?<5<+MF93D'1#O +MGD3/8NXYPG']#N0O`/BW8N(>YEP3+\#R3L@WKV*N.N$8_H= +M2-X!\>YUQ+U).*;?@>0=$._>3KS33+\#R3LDWKV+K"+AF'Z'DG=(O-,1!PG' +M]#N4O$/B'4:<23BFWZ'D'1+O;,25"(?&NCKCW +M"?8JXVX1C^AU*WAGBW>>(^Y)P3+\SDG>& +M>/[N]X/Y,:S/+GU# +M8-/Z%=PR4535'\=!6C\[6K\ZB\MLAPT'LT6F&W#-N3C_X^*/]JU3SA'IZ@S@>@`,N&ZZ(4QWF/EOX#BL#NM)?0&7I@N#"(QPFJO. +MGQ;[UQC7)IRF/6MVLFNV.K>H*GU?/@O7;E7CNI-MLYG@KHZXOB_[`Y"_:9V^ +;RP.'GS?C9U#%1.!B[IFR:U2K?VQQ7;KP$@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.raw.gz.uu new file mode 100644 index 000000000000..f5ae94e4a3e3 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.raw.gz.uu @@ -0,0 +1,10 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-vtoc8.raw.gz +M'XL("/3%'50``VEM9RTQ>#$M-#`Y-BUV=&]C."YR87@#7/;QMA@0*Y<>$H73S>%_F,2,$%Z`T3@1= +MA:,(50FE4"HO&'A]>N!N7VLOSZNZ%UPN8YCT8M(BE@17C,IEQPYXCGQR&7B& +MJ"$H"61;CN#+$9?-XPK,X+[A\TA_C^K@TL%"$DZGN4/`;XTR/DW^M2I[LSNZZ*O*S +M%6<:M!9$*/4$=]`=CH*K\M\WB7M><(\B?GA55`?<;?<4!6#V`]&)2;VR!``` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhd.gz.uu new file mode 100644 index 000000000000..aadaa429871a --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhd.gz.uu @@ -0,0 +1,17 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-vtoc8.vhd.gz +M'XL("/3%'50``VEM9RTQ>#$M-#`Y-BUV=&]C."YV:&0N;W5T`*V6R6[",!"& +M[SS%2+UQ0-[BP+5JN56JU!?`21S40Q.0"AICVC1Q,E?/QUQR.=J!/ +M!%)%M_KX:$Z&W14N543SLE.@*)WGW(6*AIWTZY`0:!)AH*]/4;H&D.V=2XT01C6"::+V716F\K@\\F9D +M(W\ZN=PDA5'^$B5GV$BUCU$2YBU4>XB%4?X2)6 +2?82+6O7I*O<6?^^O%OLJ#``` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhdf.gz.uu new file mode 100644 index 000000000000..bcf2071ac264 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhdf.gz.uu @@ -0,0 +1,14 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-vtoc8.vhdf.gz +M'XL("/7%'50``VEM9RTQ>#$M-#`Y-BUV=&]C."YV:&1F+F]U=`"ME,MN@S`0 +M1??YBBMUEP7RJC"#!1KF>*X] +M#&-A`(I0"Y#VI@2TA%*0Y!P]G']NL-MO8Q[?GNBE"L.N`HP[9S&$77/8*AMV +MM8[`31+'KP,W8`V8*`(#KCE'-3=QU_(+N'8IN0'7W8LC-_?H#8S)<+L);K_P +M8?"97`-WX/(^(,OE +MXPVQK)B=6;14^'`OKF_1&4@)J6K]\R2_A^?#^OWC,.)$5#4N[%KJJ9/F*BF5NW5]=/QU1YR<;Q)-=Z]38`J< +M)\)C=KNT6#Q.G<2:`9T^ICE:\I(XBK7G<9IE4?\O98^CA4O%U=[J#P!,R,C= +#!@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vmdk.gz.uu new file mode 100644 index 000000000000..238837c7ad0c --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vmdk.gz.uu @@ -0,0 +1,81 @@ +# $FreeBSD$ +begin 644 img-1x1-4096-vtoc8.vmdk.gz +M'XL("/7%'50``VEM9RTQ>#$M-#`Y-BUV=&]C."YV;61K+F]U=`"M7%UOY,81 +M?/>O&)Q?#@D@L);?#PQ>YWKSY(MPER]E[9Y8'I)`>YR +M\,0A7+$\>7DIA;OKUJ='?R-P+@*Y'5SY0DV'Q7YI=W_Z*C3/[R_W>UB.MVI= +MG;NJ#TM7E>LZ=_5E?2YS]1(T+X!?N]N[S_]QM]/GX?[NT\/'L+^+/]LEN*A\ +M?#5XA*6PNO(W_@D/UWJ(:G+YZ'+XI]WU_KN[7Z>;_T[WG^\^?G@'EGOQ9UOD +MKFC]=GQ\]OC8+?R+9*Z"?PUW_=O?;]^%=VYV\ZF[)YS/6C:RO/92A^)6E?/? +MSQ_K[J8/#QYQ#E]Q=_YL0W/*];4+?U,6KF[=NIW28U^6I\=0\MJ[X7[J'J:? +M?O\TO7OSV\7%E[;&6`UR/XN+RPM\M_[1L>*FD@`]RUX\?;G[\U_(C[IOU_H>__DBX9LE: +M(I<-+BE+0;N:RJW^\NG;TEW??^O>^")_^F5:WX&$:[K+NMGOHW#?=Y^GFZ]O;;^+)=K[88GTL6YL\2K5!^_?WVLZE<=M) +M;P>]'L4X]C?=V'UZF.[]\<:CZ'V+QE"I/];B\1CWKU.O)S7[=XR[OG-O[L;E +M3#WLOZ>/OQ%NV-[&RS[\6Z)=$W-_L[Q[5O@IO,+VCO''Y.&FA_O?;X;??[W[ +M,"X_:.X=X<:M=\MVMM-\/,SE`)<=OKC!I7=OUE.-VR/IZAD7%3 +M\67=];=U>[],W;AL;<$FW.QW=WEY'Z%33UYJ07?7QZZMN)\#7)X%"L@#E>U: +M%+>SO:`0Z#0\?+S?-O9&^#A_^KOLM7QG]5]N3W6:YYA2S* +M':#_+98MWW]9OG]XW%_E]U=)9*U9C2S:'=S/"\2GY^56_J>PD\A>LP99C&>Z +M5WEJFR1R?MH]_JD!N3^&X]\"C,PUJY!%N8,[ZET9>L?(6K,:6;0[N*/>5:%W +MC.PU:Y#%>*K8.O2.D;-F^0O_E$)VXL^RJ@F]8V2N684LRAW<4>_:T#M&UIK5 +MR*+=P1WUK@N]8V2O68,LQE/%]J%WC)PURU]($)#[8[@A](Z1N685LBAW<$>] +M&T/O&%EK5B.+=@=WU+LI](Z1O68-LAA/%3N'WC%RUBQ_*:1W10JNSD+O&)EK +M5B&+<@=WT+N:?,?(6K,:6;0[N(/>U>0[1O::-\8F6M6(8MR!W?4._(=(VO-:F31[N".>D>^8V2O68,LQE/%DN\8.6N6 +MO_"/(,C],1SYCI&Y9A6R*'=P1[TCWS&RUJQ&%NT.[JAWY#M&]IHUR&(\52SY +MCI&S9OD+!1G(_2%,3+7K$(6Y0[NH'<-^8Z1M68ULFAW<`>]:\AWC.PU +M:Y#%>*I8\ATC9\WREU9ZUR;AR'>,S#6KD$6Y@SOJ'?F.D;5F-;)H=W!'O2/? +M,;+7K$$6XZEBR7>,G#7+7_C_GR#WQW#D.T;FFE7(HMS!'?6.?,?(6K,:6;0[ +MN*/>D>\8V6O6((OQ5+'D.T;.FN4OU!\A]\=PY#M&YII5R*+[@#GK7 +MDN\866M6(XMV!W?0NY9\Q\A>LP99C*>*)=\QD>^8V2M68TLVAW<4>_(=XSL-6N0Q7BJ6/(=(V?-\I=9>C3^ +M$*[+MM[%R%RS"EF4.[B#WG6![V)DK5F-+-H=W$'ONL!W,;+7K$$6XZEB`]_% +MR%FS?,M$OT-2TNH"WT'T.ZA^!]'OD-3ONL!W$/T.JM]!]#LD];LN\!U$OX/J +M=Q#][D2Q@>\@^AU4OX/H=TA*6EW@.XA^!]7O(/H=DOI=%_@.HM]!]3N(?H>D +M?M<%OH/H=U#]#J+?G2@V\!U$OX/J=Q#]#DE)JPM\!]'OH/H=1+]#4K_K`M]! +M]#NH?@?1[Y#4[[K`=Q#]#JK?0?2[$\4&OH/H=U#]#J+?(2EI]5GHG>AW4/T. +MHM\AJ=_UY#O1[Z#Z'42_0U*_Z\EWHM]!]3N(?G>B6/*=Z'=0_0ZBWR$I:?7D +M.]'OH/H=1+]#4K_KR7>BWT'U.XA^AZ1^UY/O1+^#ZG<0_>Y$L>0[T>^@^AU$ +MOT-2TNK)=Z+?0?4[B'Z'I'[7D^]$OX/J=Q#]#DG]KB??B7X'U>\@^MV)8LEW +MHM]!]3N(?H>DI-63[T2_@^IW$/T.2?VN)]^)?@?5[R#Z'9+Z74^^$_T.JM]! +M]+L3Q9+O1+^#ZG<0_0Y)26O(0N]$OX/J=Q#]#DG];B#?B7X'U>\@^AV2^MU` +MOA/]#JK?0?2[$\62[T2_@^IW$/T.24EK(-^)?@?5[R#Z'9+ZW4"^$_T.JM]! +M]#LD];N!?"?Z'52_@^AW)XHEWXE^!]7O(/H=DI+60+X3_0ZJWT'T.R3UNX%\ +M)_H=5+^#Z'=(ZG<#^4[T.ZA^!]'O3A1+OA/]#JK?0?0[)"6M@7PG^AU4OX/H +M=TCJ=P/Y3O0[J'X'T>^0U.\&\IWH=U#]#J+?G2B6?"?Z'52_@^AW2$I:8Q9Z +M)_H=5+^#Z'=(ZG^0U.]&\IWH=U#]#J+?(:G?C>0[T>^@^AU$OSM1+/E. +M]#NH?@?1[Y"4M$;RG>AW4/T.HM\AJ=^-Y#O1[Z#Z'42_0U*_&\EWHM]!]3N( +M?G>B6/*=Z'=0_0ZBWR$I:8WD.]'OH/H=1+]#4K\;R7>BWT'U.XA^AZ1^-Y+O +M1+^#ZG<0_>Y$L>0[T>^@^ETTTT'N!O6@I?^&?8N_)?1)QOF_@7$>?;)OY%Q/FVB7\1<;YMXE]$ +MG&^;^!<1Y]LF_D7$^;:)?Q%QOFWB7T2<;YOX%Q'GVR;^1<3YMHE_$7&^;>)? +M1)QOF_@7$>?;)OY%Q/FVB7\1<;YMXE]$G&^;^!<1Y]LF_D7$^;:)?Q%QOFWB +M7T2<;YOX%Q'GVR;^1<3YMHE_$7&^;>)?!.?;-OY%<+YMXU\$Y]LV_D5POFWC +M7P3GVS;^17"^;>-?!.?;-OY%<+YMXU\$Y]LV_D5POFWC7P3GVS;^17"^;>-? +M!.?;-OY%<+YMXU\$Y]LV_D5POFWC7P3GVS;^17"^;>-?!.?;-OY%<+YMXU\$ +MY]LV_D5POFWC7P3GVS;^17"^;>-?!.?;-OY%<+YMXU\$Y]LV_D5POFWC7P3G +MVS;^17"^;>-?!.?;-OY%<+YMXU]$G&\S\E7^1<3Y-B-?Y5]$G&\S\E7^1<3Y +M-B-?Y5]$G&^;^!<1Y]LF_D7$^;:)?Q%QOFWB7T2<;YOX%Q'GVR;^1<3YMHE_ +M$7&^;>)?1)QOF_@7$>?;)OY%Q/FVB7\1<;YMXE]$G&^;^!<1Y]LF_D7$^;:) +M?Q%QOFWB7T2<;YOX%Q'GVR;^1<3YMHE_$7&^;>)?1)QOF_@7$>?;)OY%Q/FV +MB7\1<;YMXE]$G&^;^!<1Y]LF_D7$^;:)?Q%QOFWB7P3GVS;^14RF_D5,IOY% +M3*;^14RF_D5,IOY%3*;^14RF_D5,IOY%3*;^14RF_D5,IOY%3*;^14RF_D5, +MIOY%3*;^17];?K_;7V&_OV:7AR\#-NM( +M\W)XND76/F:U2;@O[6^#ZZS*W>#ZLW#;V&6GOGVVOPWNL5S]:;OLX/#2[L*/[!.X\1&N>9;U +MI6+?OKB[R?2M@ODLW-BY?G*7WN75,[@_5P%N_5CL;5+__+_'3UQ_N-G_;WNK +5%`'0[+U7^,]AS;[Z/YH4:2:>70`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-apm.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-apm.qcow.gz.uu new file mode 100644 index 000000000000..99f2a7bbd11e --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-apm.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-512-apm.qcow.gz +M'XL(")XS(E0``VEM9RTQ>#$M-3$R+6%P;2YQ8V]W+F]U=`"MG=F.'=EQ1=_[ +M*RYGLCC=B,B1LP2Y`3\8:%O0LY0C($"V$[(`O_#C7<4Z0U7V?E_G].:IY70>?V#N^@/.W7D[^R?>[LX7>SEW]=/M +M%XN?4S9H]P9/:>Z^G +MY,OMV=QP;^YP7ZZ2+W=D<]-W85$"R\SFEF"N@4^M;&X+YEKXU([GY#O?V]NY +M#CXE;$[AW*G,]?`I8W/-O;GSFPQTGAO@4X0[";D;X5.$.PFYF^!3A#L)N9OA +M4X0[";E;X%.$.PFY6^%3A#L-N=O@4X0[#;G;X5.$.XVX$_P4X4XC[@3Y3AEW +M&G$GR'?*N-.(.T&^4\:=1MP)\ITR[C3B3I#OE'%G$7>"?&>,.XNX$^0[8]Q9 +MR!WRG3'N+.0.^$W"'? +M-8R[)N0.^:YAW#41=XJ?(MPU$7>*?-.NC;A3Y+N6<==&W"GR7&W"'?M8R[-N0.^:YEW+4A=\AW+>.N"[E#ONL8=UW('?)=Q[CK(NX, +M/T6XZR+N#/FN8]QU$7>&?-.NC[@SY+N><=>'W"'?]8R[/N0.^:YGW/4A=\AW/>.N#[E#ONL9=WW( +M'?)=S[CK0^Z0[WK&W1!RAWPW,.Z&D#ODNX%Q-T3<-?@IPMT0<=<@WPV,NR'B +MKD&^&QAW0\1=@WPW,.Z&B+L&^6Y@W`T1=PWRW<"XR__S-Y]#OAL9=V/$78-\ +M-S+NQI`[Y+N1<3>&W"'?C8R[,>0.^6YDW(TA=\AW(^-N#+E#OAL9=V/('?+= +MR+B;0NZ0[R;&W11RAWPW,>ZFB+L6/T6XFR+N6N2[B7$W1=RUR'<3XVZ*N&N1 +M[R;&W11QUR+?38R[*>*N1;Z;&'?Y_X;D<\AW,^-NCKAKD>]FQMT<'W"'?S8R[.>0.^6YFW,TA=\AW,^-N#KE#OIL9=TO('?+=PKA; +M0NZ0[Q;&W1)QU^&G"'=+Q%V'?+ZVB+L>^6YCW&T1=SWRW<:XVR+N>N2[C7&W1=SUR'<;XVZ+N.N1[S;&W1YQ +MUR/?[8R[/>*N1[[;&7=[R!WRW' +MW"'?[8R[/>0.^6XGW$G^"9\#OI,SX4[.(7?`=W(FW,DYXF[`3V'N).SO!N`[ +M8?V=A/W=`'PGK+^3L+\;@.^$]7<2]G<#\)VP_D["_FX`OA/6WTG8WPW`=\+Z +M.PG[NP'X3EA_)V%_-P#?">OO).SO!N`[8?V=A/W=`'PGK+^3L+\;@.^$]7<2 +M]G<#\)VP_D["_FX`OA/6WTG8WPW(=ZR_D["_&Y#O6'\G87\WXJ<(=V%_-R+? +ML?Y.POYN1+YC_9V$_=V(?,?Z.PG[NQ'YCO5W$O9W(_(=Z^\D[.]&Y#O6WTG8 +MWXW(=ZR_D["_&Y'O6'\G87\W(M^Q_D["_FY$OF/]G83]W8A\Q_H["?N[$?F. +M]7<2]GOO).SO)N0[UM])V-_-^"G"7=C?S]8?R=A +M?SOO).SO9N0[ +MUM])V-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYN1KYC_9V$_=V,?,?Z.PG[ +MNQGYCO5W$O9W,_(=Z^\D[.\6_!3A+NSO%N0[UM])V-\MR'>LOY.POUN0[UA_ +M)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W$O9W"_(=Z^\D[.\6 +MY#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W(-^Q_D["_FY!OF/]G83]W8)\Q_H[ +M"?N[!?F.]7<2]G]8?R=A?[OO +M).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_)V%_MR'?L?Y.POYN0[YC_9V$_=V. +MGR+OO).SO=N0[UM])V-_MR'>LOY.P +MO]N1[UA_)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.PG[NQWYCO5W$O9W._(= +MZ^\D[.]VY#O6WTG8W^W(=ZR_T_P3-W>J<\!WUT]A[M3U=_D^O5/E#OA.67^G +MKK\[)>Y.F3L[XZNO\MS#^H<\)VR_DY=?_<@SYW* +M'/"=LOY.77_W(''WH'('?*>LOU/7WSU(W#VHW`'?*>OOU/5W#XZ+LP.^4];? +MJ>OORMG5.>`[9?V=NOX.S`'?*>OOU/5W8`[X3EE_IZZ_RW,/ZQSR'>OOU/5W +M#_-'O[L +MT/UWROH[=?U=.;LZAWS'^CMU_1V80[YC_9VZ_@[,(=^Q_DY=?Y?G'M4YY#O6 +MWZGK[Q[EN<(=NO].67^GKK][E+A[5+E#OF/]G;K^[E'B[E'E#OF.]7?J^KM' +MQ\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/(=ZR_4]??Y;G'=0[Y +MCO5WZOJ[QWFN/#W]VZ/X[9?V=NOZNG%V=0[YC_9VZ_@[,(=^Q_DY=?P?FD.]8?Z>NO\MS +M3^H<\AWK[]3U=T_R7.$.W7^GK+]3U]\]2=P]J=PAW['^3EU_]R1Q]Z1RAWS' +M^CMU_=V3X^+LD.]8?Z>NORMG5^>0[UA_IZZ_`W/(=ZR_4]??@3GD.];?J>OO +M\MS3.H=\Q_H[=?W=TSQ7N4.^8_V=NO[N:>+N:>$.W7^GK+]3U]\]3=P]+=RA +M^^^4]7?J^KNGAS\[=/^=LOY.77]7SJ[.(=^Q_DY=?P?FD.]8?Z>NOP-SR'>L +MOU/7W^6Y9W4.^8[U=^KZNV=YKG"'[K]3UM^IZ^^>)>Z>5>Z0[UA_IZZ_>Y:X +M>U:Y0[YC_9VZ_N[9<7%VR'>LOU/7WY6SJW/(=ZR_4]??@3GD.];?J>OOP!SR +M'>OOU/5W>>YYG4.^8_V=NO[N>9ZKW"'?L?Y.77_W/''WO'"'[K]3UM^IZ^^> +M)^Z>%^[0_7?*^CMU_=WSPY\=NO].67^GKK\K9U?GD.]8?Z>NOP-SR'>LOU/7 +MWX$YY#O6WZGK[_+OOP!SR'>OO +MU/5W8`[YCO5WZOJ[/'=5YY#O6'^GKK^[RG.5.^0[UM^IZ^^N$G=7A3MT_YVR +M_DY=?W>5N+LJW*'[[Y3U=^KZNZO#GQVZ_TY9?Z>NORMG5^>0[UA_IZZ_`W/( +M=ZR_4]??@3GD.];?J>OO\MS+.H=\Q_H[=?W=RSQ7N$/WWRGK[]3U=R\3=R\K +M=\AWK+]3U]^]3-R]K-PAW['^3EU_]_*X.#OD.];?J>OORMG5.>0[UM^IZ^_` +M'/(=Z^_4]7=@#OF.]7?J^KL\]ZK.(=^Q_DY=?_NOWN5N'M5 +MN$/WWRGK[]3U=Z\2=Z\*=^C^.V7]G;K^[M7ASP[=?Z>LOU/7WY6SJW/(=ZR_ +M4]??@3GD.];?J>OOP!SR'>OOU/5W>>YUG4.^8_V=NO[N=9XKW*'[[Y3U=^KZ +MN]>)N]>5.^0[UM^IZ^]>)^Y>5^Z0[UA_IZZ_>WUOOU/5WY>SJ'/(= +MZ^_4]7=@#OF.]7?J^CLPAWS'^CMU_5V>>U/GD.]8?Z=1?V?H_CME_9U&_9VA +M^^^4]7<:]7>&[K]3UM]IU-\9NO].67^G47]GZ/X[9?V=1OV=H?OOE/5W&O5W +MANZ_4];?*>GOWM8YY#O6WZGK[][FN<(=NO].67^GKK][F[A[6[E#OF/]G;K^ +M[FWB[FWE#OF.]7?J^KNWQ\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_ +M`W/(=ZR_L_P3-W>N<\!WQOJ[ZT_]OOSH<_.W3_G;'^SEQ_5\ZNS@'?&>OOS/5W8`[X +MSEA_9ZZ_`W/`=\;Z.W/]79Z3.@=\9ZR_,]??29XKW*'[[XSU=^;Z.TFO)Y4[ +MX#MC_9VY_DX2=U*Y`[XSUM^9Z^_DN#@[X#MC_9VY_JZ<79T#OC/6WYGK[\`< +M\)VQ_LYOO-'&GA3MT +M_YVQ_LY).RWLOS/7WUGBSBIW +MR'>LOS/7WUGBSBIWR'>LOS/7W]EQ<7;(=ZR_,]??E;.K<\AWK+\SU]^!.>0[ +MUM^9Z^_`'/(=Z^_,]7=YKJESR'>LOS/7WS5YKG*'?,?Z.W/]79.X:PIWZ/X[ +M8_V=N?ZN2=PUA3MT_YVQ_LYNO^L2=UWA#MU_ +M9ZR_,]??=8F[KG"'[K\SUM^9Z^^ZPY\=NO_.6']GKK\K9U?GD.]8?V>NOP-S +MR'>LOS/7WX$YY#O6WYGK[_)<7^>0[UA_9ZZ_Z_-LOS/7W_6)N[YR +MAWS'^CMS_5V?N.LK=\AWK+\SU]_UQ\79(=^Q_LYOOS/5WY>SJ'/(=Z^_,]7=@ +M#OF.]7?F^CLPAWS'^CMS_5V>&^L<\AWK[\SU=V.>*]RA^^^,]7?F^KLQ<3=6 +M[I#O6']GKK\;$W=CY0[YCO5WYOJ[\;@X.^0[UM^9Z^_*V=4YY#O6WYGK[\`< +M\AWK[\SU=V`.^8[U=^;ZNSSWKLXAW['^SEQ_]R[/5>Z0[UA_9ZZ_>Y>X>U>X +M0_??&>OOS/5W[Q)W[PIWZ/X[8_V=N?[NW>'/#MU_9ZR_,]??E;.K<\AWK+\S +MU]^!.>0[UM^9Z^_`'/(=Z^_,]7=Y[GV=0[YC_9VY_NY]GBO0[UA_9ZZ_^Y#G*G?(=ZR_,]?? +M?4COORMG5 +M.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\]['.(=^Q_LYOO/B7N/A7NT/UWQOH[<_W=I\3=I\(=NO_.6']GKK_[=/BS0_??&>OO +MS/5WY>SJ'/(=Z^_,]7=@#OF.]7?F^CLPAWS'^CMS_5V>^USGD.]8?V>NO_N< +MYPIWZ/X[8_V=N?[N<^+N<^4.^8[U=^;ZN\^)N\^5.^0[UM^9Z^\^'Q=GAWS' +M^CMS_5TYNSJ'?,?Z.W/]'9A#OF/]G;G^#LPAW['^KLD_<7-?ZASP7^$V90W_?=GDJF+OS +MX^M/5]\&VV_OU[2G5D]GK4_<7/\V?&_P7_[C9N:!>[_V-W^_;_?+7)]6LUX\ +M9W<'Y?XGOO[R;W[P=N[F_9IOX=CU1W?]WZ?;'WJ_WQW'WS8PA_Z^\O_7EWL[ +M9Y=OUWZS2B>G4Z^GOCEU8_IG=RVI[>;3Z>W^?$Q__\=?__'7__ZO/^>YFW]? +M=.O-P_T_\W;_.1WP[=#?5_YKOK?-#WYO_][FW[DM^K/EO^[]OGT[ +MNIN#O_Y&7'\T>FKMU#0W?SSBU+8WGVOM#$M-3$R+6%P;2YQ8V]W,BYO=70`K9A);]LP$$;O +M^15,]Z9-*LZ0E-P]FX$>"J0->@Z\R$"`+D8:H!?_^%+6R)2I&3$VY`A"#.)[ +M&`^?QZ:SK'XH9;4R3IF16DR5?TX7J-:3[4NMOHV_G+0?JX,:IC,AQ2P8W."V +M6.-:U2&#@R;5!:5P1JRN;X'!'1VL6[?>C")*X#[`&B=NQE[U +M05U?G#![U@=#UX=\_VR3BQ=G<@E7)''`I$82;I+$(9.:2KA9$F>8 +MU%S"E4F<95(+`:<3JGB<8U):PD$2ES,IE'`FB2N8E.2=3GLW8E*2=SKMW81) +M2=[IM'=3)B5YI]/>S9B4Y)U.>S=G4I)W('BG`JYD4I)W$'EW2+A'`;=@4I)W +M$'GWF'!/-CC-I23O(/+N*>&>!1PS[T#R#B+OGA/N1<`Q\PXD[R#R[B7AC@*. +MF7<@>0>1=Z\(]SK@F'D'DG<0>7?<\4XS\PXD[S#R[@VQLH!CYAU*WF'DG28< +M!!PS[U#R#B/OD'`FX)AYAY)W&'EG"><"CIEW*'F'D7H#%+L"^"FO<:-`7;.L7['?`0CA'9>M/R*(7>/F]PAQNUV>'/A#86A@_FA]WJ[&+] +MOY/]1OC+CTN+U93S7S.4M=6:Q2YP?%>6 +M9]<7QS_&U^W^F6%_;+#^1)7N'[3Z5[])VOU3[?K4YXV;HW]]_ +HM8A-?4/WKZ#^^9-Z]RXOK*Y.MO]JH"'@8!4:5TWG@_\+*`W"Y1,````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-apm.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-apm.raw.gz.uu new file mode 100644 index 000000000000..025d7ad4a149 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-apm.raw.gz.uu @@ -0,0 +1,12 @@ +# $FreeBSD$ +begin 644 img-1x1-512-apm.raw.gz +M'XL(".3%'50``VEM9RTQ>#$M-3$R+6%P;2YR87]/"5(HG(/PDN:+T(BV4_QK-KQGP` +M)"$%F$T64G`PPN4^2)B7M]+&71G#%![&V8VNZ[AR$*:X]T#ARI*!FE%?E0)Y +MOV#6KT.@QSE]Q*&92_4!)6?I6W;=9SN!$[D^U^.JL3JY.[]S0`MH@EJ$4^V@ +M6E<.ZK9=?3SM3_OOPS;BR.)4XYKU?]1]U=VD.IEYMC1SMA27,@#[LT741[EW +MC\[C4,YX.PB;)"`K$$$T5KAT-7L?`5?'MGW:/#^\KS:I?T29]:D9_HG$/_^3 +MI/XAU:=R^Z=N^JN*\7C#KLO]X(`5@-H4D +,'+#X`^%)]I"G!0`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-apm.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-apm.vhd.gz.uu new file mode 100644 index 000000000000..ad1859a2056c --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-apm.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-512-apm.vhd.gz +M'XL(".7%'50``VEM9RTQ>#$M-3$R+6%P;2YV:&0N;W5T`*U6RVX;(13=^RNN +ME%VD6L#`G739JO&N4I2HZV0Z9B)+36+%EIJ%/SY<'H9Y,+5=QA@Q8N[A<.X# +M&',/`%:`':`&5#2N)>!7J&\`S*1OPO;'`.$NM^N9D +M+RJ09I$:1$.+X)K&<`@PRZO;Y^O-RW.`$QXN+"P1I`!E0.1H'61'=H2T^O[P +MPT(^17;5F%VT,O_?$I@$SI,OJL#NZ-5=?95D/36)JA]5YZ$W&S`SC% +M!E8)S2E1D\U.P>&%CST!2.,]M%RS*?@@W$2K_I1[V[:0?&!&8"A/" +M;K^O7H2"E!]R-J-YWAE9?@WQ,ZFI1$AVVZI_;?CVGF#8T!U-QKL7Z]?2M,D0 +MN9Z*BO@RS-V[GY/ATA(_R2F,*9);BN%3^'W;;O_H"3A1:KL.KAJS4YW/.9MT +MKD3;WI5NU05VCR;;]IO]YNWU,3D@5SR"Q-L05S9GW$>#J76MS"GWYM7I(]=.R+#_.3M!/ +M)/JY)$GU2VL+SQWBE_.;U8\.DWHB-J-^N[\N$`._TOH)KQ]K)OK\Q.%NV?\Y +M0.&+:;'J+&+U*\-0>L!B#&7,X5(,.==&7 +BK*P5.^NJB[YD%;KJ$ES!JR[!%;WJHBVHBT^(Z?)+'PT````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-apm.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-apm.vhdf.gz.uu new file mode 100644 index 000000000000..189b488a594b --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-apm.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-1x1-512-apm.vhdf.gz +M'XL(".7%'50``VEM9RTQ>#$M-3$R+6%P;2YV:&1F+F]U=`"M54UOPC`,O?,K +M+.V&M*I-'(<=-PUND]#0SE!HBRH-J!C2=NB/7SYI2@MB4U,K2N3F]?G9<>/8 +M#@`4(!C$RF)GW,S-_L*@GKY':L21'_7(@B6W3EV'BRY&/1I;0*;=(@;,.N=X +M")BT'?7\[1+0PFE^F(",M=$&2-S%[[FJ/O,>.#94N!:.=]F)PJP3`,E`(M"3 +MFZD`RK7;L5M6Z?%4GLK#?NGA4,%1I@_+O[#;I54O.S%P;O'.W*);,`?8SBUX +M?CAT[:%)!VGA52*4(0/!`1%8IH@+[5/[#N#LF.DE`_"/G1T/K13?TD!RE[:K/1[^O;%J+G-[1^$Z=?G/;,UQWU/&H_%A`= +MX&`,R75GXNZN:Q&Y[P&3$)`UZ36`F\,^WYS*G_`&D^O.1=%O^CSC^E]`$EAJ +M6DRFUP&_A^EV7.ZV'LYW/_]AE>MSBB^CI':X,Y5@`[EJV/&N2!2JMT9=RTG2 +M"MRQ6X7J63@\!YL7L!:&IK?6IN7H[#$M-3$R+6%P;2YV;61K+F]U=`"MG%MOW,@1A=_] +M*PCORR)`!)[A_<%`UI$-!,$"QGJ3/&YXC878EB`)20S,CP^;[-,ZE$0WL2IE +MM)SR5-5T5X]*RE<'3-/U*TGR+LGS)!^2HDQ2)/,_K8\DS1Z,^7&J^<+YKY<_ +M__V"7S]>7)Q?KR+IDI`HV:0KGMG3[F:_M[H_O/+%<^O+W!KFXRV; +MI,J2LO-F4A:+G275:7DM3:K9:9H3_I!<7MW].[D<[_K;JYO[:[^^DSO;V3DO +MG7_9NPSSQJK2/7$ON'2-2U&.238D&=S+R?GV_=7G\>(_X^W=U?77-^!V3^YL +M\RS)&[<Y,T*>'>(SG_^2^7;_PG-[VX:6^9SD7-"YG?>]Z'YBW+ +MQ'T_?2RK&[_>NXR3_PJK5$VR+*=PN4_SRX/?\E*[_G9L +M[\=?O]V,;UY_N?X::N?.UI6L61+52Z&RI,A<*K\U5[["970?F^74DO/GJ_M/ +M5_W'>9MWX^N+'Q*F*UWMY@.L_;K67<\AY>[)SLL^O_O?_;S?9/`G>\5TRR*6 +M3HY:O:<%SB'S!O:[*E8]U\\_E@FYX_ODM=ND[]^&I=/(-,UZX^9CE*(:ANVB']N9^O'7'&XZB8/Q[A]GVHYJS)^>)?WHWV']Q+AC9_&=IB7-N=FNLFM[O3\.GRE'KW5G#TY/U1MR7OGTV6I +M;P&9;V6;$H7EK&\H#73L[Z]OUX6]EGZFC +MWV>9QN5B%)N$[K=8.G__:?[^\+"^TJVO%,]*HVHQFDVZ?\XI;IYNMW0_A:UX +M=AK5BS$F4;E8A2;='NU*WSMZ%EI5"U& +MLTFW5[O2UXZ>G4;U8@R'-EOYVM%STBAWX9]22`_\65;6OG;TS#0J%Z/8I-NK +M7>-K1\]*HVHQFDVZO=JUOG;T[#2J%V,XM-G.UXZ>DT:Y"QL$Y/E^NM[7CIZ9 +M1N5B%)MT>[4;?.WH66E4+4:S2;=7N]'7CIZ=1O5B#(F4;E8A2;='NU8[^C9Z51M1C-)MU>[=COZ-EI5"_&<&BS +M['?TG#3*74JI71E-QWY'STRCDX:Y2[\(PCR?#\=^QT],XW*Q2@VZ?9JQWY'STJC:C&:3;J]VK'? +MT;/3J%Z,X=!FV>_H.6F4NQ#(0)[OIJM37SMZ9AJ5BU%LTNW4KF:_HV>E4;48 +MS2;=3NUJ]CMZ=AK5BS$DT:Y"___$^3Y?CKV.WIF&I6+46S2 +M[=6._8Z>E4;58C2;='NU8[^C9Z=1O1C#HDX:Y2Z]U*Z/I6M2 +M7SMZ9AJ5BU%LTNW4KF&_HV>E4;48S2;=3NT:]CMZ=AK5BS$ +MDT:YRRBU&Z/IV._HF6E4+D:Q2;=7._8[>E8:58O1;-+MU8[]CIZ=1O5B#(CV*3;JQW['3TKC:K%:#;I]FK'?D?/3J-Z +M,89#FV6_H^>D4:E,SR#/=].UZ5J[X)EI5"Y&L4FW4[O6][O@66E4+4:S2;=3 +MN];WN^#9:50OQG!HL[[?!<])HUS)A-\ABK1:W^\@_`[*[R#\#E%^U_I^!^%W +M4'X'X7>(\KO6]SL(OX/R.PB_.[!9W^\@_`[*[R#\#E&DU?I^!^%W4'X'X7>( +M\KO6]SL(OX/R.PB_0Y3?M;[?0?@=E-]!^-V!S?I^!^%W4'X'X7>((JW6]SL( +MOX/R.PB_0Y3?M;[?0?@=E-]!^!VB_*[U_0["[Z#\#L+O#FS6]SL(OX/R.PB_ +M0Q1I=:FOG?`[*+^#\#M$^5W'?B?\#LKO(/P.47[7L=\)OX/R.PB_.[!9]COA +M=U!^!^%WB"*MCOU.^!V4WT'X':+\KF._$WX'Y7<0?HQWPN^@ +M_`["[PYLEOU.^!V4WT'X':)(JV._$WX'Y7<0?H_$WX'Y7<0?G=@L^QWPN^@_`["[Q!%6CW[G?`[*+^#\#M$ +M^5W/?B?\#LKO(/P.47[7L]\)OX/R.PB_.[!9]COA=U!^!^%WB"*MGOU.^!V4 +MWT'X':+\KF>_$WX'Y7<0?HQWPN^@_`["[Q#E=P/[G?`[*+^#\+L#FV6_$WX'Y7<0 +M?HQWPN^@_`["[Q#E=P/[G?`[*+^#\#M$^=W`?B?\#LKO(/SN +MP&;9[X3?0?D=A-\ABK0&]COA=U!^!^%WB/*[@?U.^!V4WT'X':+\;F"_$WX' +MY7<0?G=@L^QWPN^@_"Z(Z2#/)5VR?OMT8[K6[EE)^3/_%&J7/+NZT5@?B$4? +M&&8*ZZY^7\(UG?7ZPGR;CQ?I%Q'FVWR\2+^(,-_FXT7Z183Y-A\OTB\BS+=- +M](L(\VT3_2+"?-M$OX@PWS;1+R+,MTWTBPCS;1/](L)\VT2_B##?-M$O(LRW +M3?2+"/-M$_TBPGS;1+^(,-\VT2\BS+=-](L(\VT3_2+"?-M$OX@PWS;1+R+, +MMTWTBPCS;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2\B +MS+=-](L(\VT3_2+"?-M$OX@PWS;1+X+S;1O](CC?MM$O@O-M&_TB.-^VT2^" +M\VT;_2(XW[;1+X+S;1O](CC?MM$O@O-M&_TB.-^VT2^"\VT;_2(XW[;1+X+S +M;1O](CC?MM$O@O-M&_TB.-^VT2^"\VT;_2(XW[;1+X+S;1O](CC?MM$O@O-M +M&_TB.-^VT2^"\VT;_2(XW[;1+X+S;1O](CC?MM$O@O-M&_TB.-^VT2^"\VT; +M_2(XW[;1+X+S;1O](CC?MM$O(LRWZ?DB_2+"?)N>+](O(LRWZ?DB_2+"?)N> +M+](O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2\BS+=-](L(\VT3_2+"?-M$OX@P +MWS;1+R+,MTWTBPCS;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M$_TBPGS;1+^( +M,-\VT2\BS+=-](L(\VT3_2+"?-M$OX@PWS;1+R+,MTWTBPCS;1/](L)\VT2_ +MB##?-M$O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2^"\VT;_2)&4_TB1E/](D93 +M_2)&4_TB1E/](D93_2)&4_TB1E/](D93_2)&4_TB1E/](D93_2)&4_TB1E/] +M(D93_2*F-#74+V(RU2]B,M4O8C+5+V(RU2]B,M4O8C+5+V(RU2]B,M4O8C+5 +M+V(RU2]B,M4O8C+5+V(RU2]B,M4O8C+5+Y[2-#74+YZ>W$OX8+JGFUWU@?FR +MOKQP]R[5>_VN=S7^3L)WO[@T/SY:7VZ^ON5^O>[VJL.3N$P38OO"^GTGWY%[,OW>[:[KLZ>J*R=_H=[ES9\Z[ +MY?*>PL7$U?UVT][>7]U?77_]C>F6^_4._C:NQU?WI;UY=G7&]V+.\X-G2R)R +M\@FW9YMP?=;W_LSSY3A*WN^X<'?1+98[ZIZ&>>&%>ZW(GB9\?SN.;S]>_O%O +M[S]J_?+<>'WE@?JI%&[](='Z);H^:^UQ7GZW?E665-4SG\V'^MW]=_T@+[?_6A+E/:+;"W-U\-GWU?YW"XEV37@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow.gz.uu new file mode 100644 index 000000000000..1aab94860233 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow.gz.uu @@ -0,0 +1,125 @@ +# $FreeBSD$ +begin 644 img-1x1-512-bsd.qcow.gz +M'XL(")\S(E0``VEM9RTQ>#$M-3$R+6)S9"YQ8V]W+F]U=`"MGOYNJY]^SKW\X^[- +M\G.N!N/>X&J>6\^OS\3I#;_W^KZFMVMWI_?WO5T7;W>C!K?W!O\US_TYOSX7 +M;W>GYL9[<]?T=EV\W4G-[7\)BPM8#FKN6,P-^-1)S9V+N0T^=>$Y^\7G]FYN +MBT^9FL,_MV]7;6Z'3X6:&^[-K=\N0"]S(SXEN+.2NPF?$MQ9R=T>GQ+<6AN(N*.R/? +MA>(N2N[(=Z&XBY([\ETH[J+DCGP7BKLHN2/?A>(N2N[(=Z&XBY([\ETH[H:2 +M._+=H+@;2N[(=X/B;JBX]&Q=U8<3?P4X*[L>)N(-^- +MBKNQXFX@WXV*N['B;B#?C8J[L>)N(-^-BKNQXFX@WXV*N^6OO_4<^6Y2W$T5 +M=P/Y;E+<325WY+M)<3>5W)'O)L7=5')'OIL4=U/)'?EN4MQ-)7?DNTEQ-Y7< +MD>\FQ=V^Y(Y\MU?<[4ONR'=[Q=V^XF[#3PGN]A5W&_+=7G&WK[C;D._VBKM] +MQ=V&?+=7W.TK[C;DN[WB;E]QMR'?[15WR_^&U'/DNX/B[E!QMR'?'11WAY([ +M\MU!<7^.RONSA5W._+=67%WKKC;D>_.BKMS +MQ=V.?'=6W%TJ[G;DNXOB[E)QMR/?711WEY([\MU%<7"[TSU=U;V=R/XSE1_9V5_-X+O3/5W5O9W(_C.5']G97\W@N], +M]7=6]G"[TSU=U;V=R/XSE1_9V5_-X+O3/5W5O9W(_C.5']G +M97\W@N],]7=6]G"[TSU=U;V=R/Y3O5W5O9W(_E.]7=6]G<3 +M/R6X*_N[B7RG^CLK^[N)?*?Z.RO[NXE\I_H[*_N[B7RG^CLK^[N)?*?Z.RO[ +MNXE\I_H[*_N[B7RG^CLK^[N)?*?Z.RO[NXE\I_H[*_N[B7RG^CLK^[N)?*?Z +M.RO[NXE\I_H[*_N[B7RG^CLK^[N)?*?Z.RO[NXE\I_H[*_N[/3\EN"O[NSWY +M3O5W5O9W>_*=ZN^L[._VY#O5WUG9W^W)=ZJ_L[*_VY/O5']G97^W)]^I_L[* +M_FY/OE/]G97]W9Y\I_H[*_N[/?E.]7=6]G=[\IWJ[ZSL[_;D.]7?6=G?[KOK.SO#N0[U=]9V=\= +MR'>JO[.ROSN0[U1_9V5_=R#?J?[.RO[NR$\)[LK^[DB^4_V=E?W=D7RG^CLK +M^[LC^4[U=U;V=T?RG>KOK.SOCN0[U=]9V=\=R7>JO[.ROSN2[U1_9V5_=R3? +MJ?[.RO[N2+Y3_9V5_=V1?*?Z.RO[NR/Y3O5W5O9W1_*=ZN^L[.^.Y#O5WUG9 +MWQW)=ZJ_L[*_.Y+O5']G97]WXJ<$=V5_=R+?J?[.RO[N1+Y3_9V5_=V)?*?Z +M.RO[NQ/Y3O5W5O9W)_*=ZN^L[.].Y#O5WUG9WYW(=ZJ_L[*_.Y'O5']G97]W +M(M^I_L[*_NY$OE/]G97]W8E\I_H[*_N[$_E.]7=6]GKOK.SOSN0[ +MU=]9V=]=^"G!7=G?7KOK.SO+N0[U=]9V=]=R'>JO[.RO[N0[U1_ +M9V5_=R'?J?[.RO[N0KY3_9V5_=V%?*?Z.U]^DN96?0Y\]_TIYLY3?[?IOUO-W*W^;'/@.U?]G:?^;G5-9Q=T_YVK +M_LY3?]?.KL^![USU=Y[Z.Y@#W[GJ[SSU=S`'OG/5WWGJ[Y:Y!WT.?.>JO_/4 +MWSU8YE9M#GSGJK_SU-\]F+E[T+D#W[GJ[SSU=P]F[AYT[L!WKOH[3_W=@^O- +MV8'O7/5WGOJ[=G9]#GSGJK_SU-_!'/C.57_GJ;^#.?"=J_[.4W^WS#WL<^0[ +MU=]YZN\>+G.=._*=ZN\\]7-N[H_CM7_9VG_N[AS-W#QAW=?^>JO_/4 +MWSV\YK.C^^]<]7>>^KMV=GV.?*?Z.T_]'KO//5WR]RC +M/D>^4_V=I_[NT3+7N*/[[USU=Y[ZNTS=P]ZMR1[U1_ +MYZF_>W2].3ORG>KO//5W[>SZ'/E.]7>>^CN8(]^I_LY3?P=SY#O5WWGJ[Y:Y +MQWV.?*?Z.T_]W>-EKG-'OE/]G:?^[O',W>/&'=U_YZJ_\]3?/9ZY>]RXH_OO +M7/5WGOJ[Q]=\=G3_G:O^SE-_U\ZNSY'O5'_GJ;^#.?*=ZN\\]7]+GR'>JO_/4WSU9YAIW=/^=J_[.4W_W9.;N2>>.?*?Z.T_]W9.9NR>= +M._*=ZN\\]7=/KC=G1[Y3_9VG_JZ=79\CWZG^SE-_!W/D.]7?>>KO8(Y\I_H[ +M3_W=,O>TSY'O5'_GJ;][NLQU[LAWJK_SU-\]G;E[VKBC^^]<]7>>^KNG,W=/ +M&W=T_YVK_LY3?_?TFL^.[K]SU=]YZN_:V?4Y\IWJ[SSU=S!'OE/]G:?^#N;( +M=ZJ_\]3?+7//^ASY3O5WGOJ[9\M]4?^>IOUOFGO>KOGE_SV=']=Z[Z.T_]73N[/D>^4_V=I_X.YLAWJK_S +MU-_!'/E.]7>>^KME[D6?(]^I_LY3?_=BF6O>^KMV=GV.?*?Z.T_]'KO//5WR]S+/D>^4_V=I_[NY3+7N2/?J?[.4W_W..[K]S +MU=]YZN]>SMR];-S1_7>N^CM/_=W+:SX[NO_.57_GJ;]K9]?GR'>JO_/4W\$< +M^4[U=Y[Z.Y@CWZG^SE-_M\R]ZG/D.]7?>>KO7BUSC3NZ_\Y5?^>IOWLU<_>J +M^4_V=I_[NU]WGR'>JO_/4W[U>YCIWY#O5WWGJ[U[/W+UN +MW-']=Z[Z.T_]W>N9N]>-.[K_SE5_YZF_>WW-9T?WW[GJ[SSU=^WL^ASY3O5W +MGOH[F"/?J?[.4W\'<^0[U=]YZN^6N3=]CGRG^CM/_=V;9:YQ1_??N>KO//5W +M;V;NWG3NR'>JO_/4W[V9N7O3N2/?J?[.4W_WYGIS=N0[U=]YZN_:V?4Y\IWJ +M[SSU=S!'OE/]G:?^#N;(=ZJ_\]3?+7-O^QSY3O5W7O5W0???N>KOO.KO@NZ_ +M<]7?>=7?!=U_YZJ_\ZJ_"[K_SE5_YU5_%W3_G:O^SJO^+NC^.U?]G5?]7=#] +M=Z[Z.Q?]W;L^1[Y3_9VG_N[=,M>XH_OO7/5WGOJ[=S-W[SIWY#O5WWGJ[][- +MW+WKW)'O5'_GJ;][=[TY._*=ZN\\]7?M[/H<^4[U=Y[Z.Y@CWZG^SE-_!W/D +M.]7?Q?*3-+?N<^"[4/W=]P_KOUM=\=G3_7:C^+E)_U\ZNSX'O0O5WD?H[F`/?A>KO +M(O5W,`>^"]7?1>KOECGK<^"[4/U=I/[.EKG&'=U_%ZJ_B]3?V?SRK','O@O5 +MWT7J[VSFSCIWX+M0_5VD_LZN-V<'O@O5WT7J[]K9]3GP7:C^+E)_!W/@NU#] +M7:3^#N;`=Z'ZNTC]W3+G?8Y\I_J[2/V=+W.=._*=ZN\B]7<^<^>-.[K_+E1_ +M%ZF_\YD[;]S1_7>A^KM(_9U?\]G1_7>A^KM(_5T[NSY'OE/]7:3^#N;(=ZJ_ +MB]3?P1SY3O5WD?J[92[Z'/E.]7>1^KM8YAIW=/]=J/XN4G\7,W?1N2/?J?XN +M4G\7,W?1N2/?J?XN4G\7UYNS(]^I_BY2?]?.KL^1[U1_%ZF_@SGRG>KO(O5W +M,$>^4_U=I/YNF1OZ'/E.]7>1^KMAF>O]4?Q>IOQMF[H;&'=U_%ZJ_B]3? +M#3-W0^..[K\+U=]%ZN^&:SX[NO\N5'\7J;]K9]?GR'>JOXO4W\$<^4[U=Y'Z +M.Y@CWZG^+E)_M\QM^ASY3O5WD?J[S3+7N*/[[T+U=Y'ZN\W,W:9S1[Y3_5VD +M_FXS<[?IW)'O5'\7J;_;7&_.CGRG^KM(_5T[NSY'OE/]7:3^#N;(=ZJ_B]3? +MP1SY3O5WD?J[96[;Y\AWJK^+U-]ME[G.'?E.]7>1^KOMS-VV<4?WWX7J[R+U +M=]N9NVWCCNZ_"]7?1>KOMM=\=G3_7:C^+E)_U\ZNSY'O5'\7J;^#.?*=ZN\B +M]7[F;M=YXY\I_J[ +M2/W=;N9NU[DCWZG^+E)_M[O>G!WY3O5WD?J[=G9]CGRG^KM(_1W,D>]4?Q>I +MOX,Y\IWJ[R+U=\O^4_U=I/X.YLAWJK^+ +MU-_!'/E.]7>1^KME;NISY#O5WT7J[Z9EKG%']]^%ZN\B]7?3S-W4N2/?J?XN +M4G\WS=Q-G3ORG>KO(O5WT_7F[,AWJK^+U-^UL^MSY#O5WT7J[V".?*?ZNTC] +M']SGRG>KO(O5W[Y>YSAWY3O5WD?J[]S-W[QMW=/]=J/XN +M4G_W?N;N?>..[K\+U=]%ZN_>7_/9T?UWH?J[2/U=.[L^1[Y3_5VD_@[FR'>J +MOXO4W\$<^4[U=Y'ZNV7N0Y\CWZG^+E)_]V&9:]S1_7>A^KM(_=V'F;L/G3OR +MG>KO(O5W'V;N/G3NR'>JOXO4WWVXWIP=^4[U=Y'ZNW9V?8Y\I_J[2/T=S)'O +M5'\7J;^#.?*=ZN\B]7?+W,<^1[Y3_5VD_N[C,M>Y(]^I_BY2?_=QYNYCXX[N +MOPO5WT7J[S[.W'ULW-']=Z'ZNTC]W<=K/CNZ_RY4?Q>IOVMGU^?(=ZJ_B]3? +MP1SY3O5WD?H[F"/?J?XN4G^WS'WJ<^0[U=]%ZN\^+7.-.[K_+E1_%ZF_^S1S +M]ZES1[Y3_5VD_N[3S-VGSAWY3O5WD?J[3]>;LR/?J?XN4G_7SJ[/D>]4?Q>I +MOX,Y\IWJ[R+U=S!'OE/]7:3^;IG[W.?(=ZJ_B]3??5[F.G?D.]7?1>KO/L_< +M?6[KO(O5W[>SZ'/E. +M]7>1^CN8(]^I_BY2?P=SY#O5WT7J[Y:Y+WV.?*?ZNTC]W9=EKG%']]^%ZN\B +M]7=?9NZ^=.[(=ZJ_B]3??9FY^]*Y(]^I_BY2?_?E>G-VY#O5WT7J[]K9]3GR +MG>KO(O5W,$>^4_U=I/X.YLAWJK\;EI^DN:]]#GPWJ/YN2/W=UV6N

^^_X4 +MD_N[KS-W7A;MAS4\Q=T/J[[[.W'W]L\W1U]MN1R0_\.UM^O;MCY<_!C<_ +M7M_@J_4>?M0?^/:/M_?_:8,_+H39[%;#9K79KD;_W5?X?__\W_0*[^;^MC=\ +M-T=?8/S>7'O!]CMS/P3_T^_\Z^L;MW)/?N!N[N:FM`U="--?Q%]$G^D#\M71 +M%QC_3V"YN73EY\_SCR]1_OV_QI:_<$\W5[;/[ZJ_/HJ8[[W=7[R^U>W;_2'1 +MW?W?;S_->?%V5_?G#K_\W/[ZU3VX?77T1;S_DT_&S=4AO_DG]Z^1^W]R[^;\ +C[Q7![H=9_O+<'G[4'_CVK[?W_[D;''X,_O'_LNY7-X&E```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow2.gz.uu new file mode 100644 index 000000000000..0fb99580fd8c --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-1x1-512-bsd.qcow2.gz +M'XL(")$[(U0``VEM9RTQ>#$M-3$R+6)S9"YQ8V]W,BYO=70`K9C;DM)`$(;O +M>8I9SZZ*F>Y)2#RLNNM:Y9W>Z#6P\!0\O!NFR22=_C-(!5*IHH;_JY[,EV9" +M4<27_PL![G>A^'A#K]__%SV7X=%A/D"I(R!P!UNP+I+.$*X +MPH\'O(WK5<<&CDZI,2B'"["ZJ0$#=[TX7KKC8M0JP9<`(PXNQD7U4:Q/)\*% +M]='<];%]_D"X7197 +M&JD]P/F,*H^XRDAYA*,L;F6D&.%"%E<;*>2=SWO7&"GDG<][MS92R#N?]VYC +MI)!W/N_=UD@A[WS>NPDO'LJN&<= +MSELIY!TI[YX+[D7"&?V.D'>DO'LIN%<)9_0[0MZ1\NZUX*X3SNAWA+PCY=T; +MP;U-.*/?$?*.E'?O1MYYH]\1\HZ5=^^%522\8>LO/LLN)N$,_H=(^^"\NZ+X+XFG-'O`O(N*.^^">XVX8Q^ +M%Y!W07EW)[CO'8ZL5.==4=B'X.Y']RS-N_\,:7_LC3,>F`#6_P..-PNA^\.>%SA-^O^Y@(.##<75PDW^3C:[K%WU@"LKIQ9%JI5KK_.KMD?'U).W5UM +MS;KU=:D^0V8:3'>B/C>>;ONKT3W=J55L<929KAOB-I-K.UW=U;BZ[#$M-3$R+6)S9"YR87Y`2H7IKDMVWVD[.[,]!0\_4%0J`UU",22D[9>_U((X&8`BP/['GG:8J^#+ +M5*=JI)$#ZA:4!GV&SH;C^K$#KNYMYVF[RPSX`?P`&P\S[BP*6_L.J[ +MQ#*(E9O1!W&YO<.U/%X&.-HI%SCNE>UM7ET=JQL*-Z/93L;!R740/KD3CLH^ +B!#2^+/8/M%'QGG:8N^!K`BH/+':#BARP^@+33Z#K!04````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-bsd.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-bsd.vhd.gz.uu new file mode 100644 index 000000000000..ef644e42fab2 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-bsd.vhd.gz.uu @@ -0,0 +1,17 @@ +# $FreeBSD$ +begin 644 img-1x1-512-bsd.vhd.gz +M'XL(".;%'50``VEM9RTQ>#$M-3$R+6)S9"YV:&0N;W5T`*V7/6_#(!"&]_R* +MD[IEB.",L;M&3>=*E=HUCF-'&?JA)D,&__AR-MA@C).TV`1AP3V\=QR(,-8] +M`#(!68.L0*;4S@3(1\AR`-6I"[8UUY_0E%^?57D^7E;Z:18=C#/;RC4G>TQ` +MJ$DRP((FD7MJ0V,PJX?-87G\.!@<:IR96$@0"*F""&\>R7IU1'I>OSZUR.V@ +M+O'5#5;JMQ/`!'!NC4B,NFVOL<<)9577;8R;2)5_14^Z=D(W5!!8:CJP==^-WH`" +M6Y_D;";FX<4(ZBM(G]I;K)BHPQW->N6^/;`D8)K1=D\EY'AK!-\W;U/K6P;2 +MY8^[H\1KN%XPOP67Z+UK49(!%^KH<$RSV(`3<^HH9ZJ[G$TC)W.9C^SL=09> +M`]\#RZVLMH#]^L*@[]&7@8Z[,_K`=[<@7.:.YQ8.K[@++FXWN[;SZIBOKHR\ +M&/OQSKAQYQ+$W;D=#N,>!-B>+"H#U2B_#G#$M-3$R+6)S9"YV:&1F+F]U=`"ME$UO@S`,AN_\ +M"DN[]8"2D!AZK=:=)TW:K@4*50_=+COLD!^_&`+$?+6;"%$$IQ<\UK&Q:/1 +MX=0]7"]8/H)+R$LR2C+@E@PM3GB6&'!Z39W+A*C^%*S9*G==;;.17UAGD#7( +M,XC,VQ0']O6%0=]^*D.Q<%?TP33',)PF]NBU/;-@+5=!9W`MVNZ;ILL*\Q?UJ@]L#-,HB^]V$"6`-6@(;> +M4PVXAS0+@8J?)%M^?5;E]_4GK##AJ"!U/3_)7R5T6S`%E=-/\$SO@;ZGXV5W +MO5TZ7->JNA]KI*0;!]&3<)&'^W)X>VZ0IT%=,DT2AMDK-`@-4K+`O;H3/\Z$ +HTWVP50V%:61VDWTPPVRK(IP1(Z__UK;%X<9'Q1V^Z!>1V%I#,`<````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-bsd.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-bsd.vmdk.gz.uu new file mode 100644 index 000000000000..84e2c3e48411 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-bsd.vmdk.gz.uu @@ -0,0 +1,81 @@ +# $FreeBSD$ +begin 644 img-1x1-512-bsd.vmdk.gz +M'XL(".?%'50``VEM9RTQ>#$M-3$R+6)S9"YV;61K+F]U=`"MG-UOV\H1Q=_S +M5Q#.2]`'@4?\?@C0IDZ!HB@0W%S<^UKQJS&:Q(%M%`V@/[Y<DNW`,N7.-"E$.2]4D&]W!ROOO;S=?A\-_A[O[F]OM[,-VC.]L\ +M2_+&;4T;F9Y[RD/CEF7B +MOB]O\^Z&[P\NXNB_PN[;M%"[V<7JX]RG/M>ONAM/# +M\.O/'\/[JV^WWT/MW-FZDC5SH'HN5)84F0OE4W/E*UQ$][*93RTY?[UY^'+3 +M?9[2O!^N#F\3ABM=[:8#K/V^EJPGEW+S9*=MGS_^[V'*-^G]R=XPW+R).8GI +MN8MC4E0NUG2`\U$,LGAC)+S[??#+[]/;W%7K,^?_O(+P]63 +MUV0Y;7!RF1):Y50L^1=/7Y;)^?/'Y,HE^>N787X%,ERSO,V<\7(.F)='=^&K +MMH1W32QW#\PGFUR?'D[)A]/]<'A[??TAG.S))9O/MVEK@XM2+J'=ZWLNYU2X +MY:27@YZ/HN_;PZD__7@8[MSQAJ-H78EZGZD[UOSQ&-?/4\TG-;I73')^GUS= +M]-.9NK#_'FZ_,5RWO(RG?;B71#,[9NYB>O7,X0?_#,LKQAV3"S<\W/T\=#^_ +MWGSOIS=:\I[A^J5VTW:6TWP\S.D`IQT^N\&I=E?SJ8;M,=S@=M=?;'`^3U_( +ML*GPM,GYV[R]+\.IG[8VQ6:XT>WN^/P^?*6>/-44/3D_5FV.>^_#9:EO`9EO +M9:L2A>TL3R@-=.@>;N^6C5U)/\Z>_BQ[;3_.+WZD5G\PX!+.>G]E^N3G6:9^ +MN2R*54#W4RR=OO\\?7]ZW%_I]E>*9:5>M2R:5;A_32%^7*9;NG?A22Q;]>ID +MT>^I7NE:VR"6X]/J\5<-R/5V./XN0,M,O7)9%*MP6[4K?.UH6:E7+8MF%6ZK +M=J6O'2U;]>IDT>]*MO*UH^6H7NZ.OTHAW?%K65G[VM$R4Z]<%L4JW%;M&E\[ +M6E;J5!K1\M6O3I9]+N2'7WM:#FJE[O+I79Y+%R5 +M^MK1,E.O7!;%*MQ&[2KV.UI6ZE7+HEF%VZA=Q7Y'RU:].EGTNY)EOZ/EJ%[N +MKI#:%=%P['>TS-0KET6Q"K=5._8[6E;J5IDT>]*EOV. +MEJ-ZN;M2:E=&P['?T3)3KUP6Q2K<5NW8[VA9J5T;-6KDT6_ +M*UGV.UJ.ZN7N^$L0Y'H['/L=+3/URF51K,)MU8[]CI:5>M6R:%;AMFK'?D?+ +M5KTZ6?2[DF6_H^6H7NZ.0`9RO1FN3GWM:)FI5RZ+8A5NHW8U^QTM*_6J9=&L +MPFW4KF:_HV6K7ITL^EW)LM_1+?E>R['>T'-7+W752NRX6KDE] +M[6B9J5CU&Z,AF._HV6F7KDLBE6XK=JQW]&R4J]:%LTJW%;MV.]HV:I7 +M)XM^5[+L=[0C/<*5UJ%RPS]((JV3[W<0?@?E=Q!^ +MARB_._E^!^%W4'X'X7>(\KN3[W<0?@?E=Q!^MR-9W^\@_`[*[R#\#E&D=?+] +M#L+OH/P.PN\0Y7^$WT'Y'83?((\KN6_4[X +M'93?0?C=CF39[X3?0?D=A-\ABK1:]COA=U!^!^%WB/*[EOU.^!V4WT'X':+\ +MKF6_$WX'Y7<0?K(\KN._4[X'93?0?C=CF39[X3?0?D=A-\ABK0Z]COA=U!^!^%W +MB/*[COU.^!V4WT'X':+\KF._$WX'Y7<0?K(\KN>_4[X'93?0?C=CF39[X3?0?D= +MA-\ABK1Z]COA=U!^!^%WB/*[GOU.^!V4WT'X':+\KF>_$WX'Y7<0?K^$WT'Y'83? +M[4B6_4[X'93?0?@=HDBK9[\3?@?E=Q!^ARB_Z]GOA-]!^1V$WR'*[WKV.^%W +M4'X'X7<[DF6_$WX'Y7=!3`>YEG#)\NW##>E2NVI5]$F&^; +MZ!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AO +MF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28 +M;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$ +MF&^;Z!<1YMLF^D6$^;:)?A%AOFVB7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$ +MY]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3G +MVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?; +M-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV +M^D5POFVC7P3GVS;Z17"^;:-?1)AOT_)5^D6$^38M7Z5?1)AOT_)5^D6$^38M +M7Z5?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%A +MOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X1 +M8;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^ +M$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE\$Y]LV^D4,IOI%#*;Z10RF +M^D4,IOI%#*;Z10RF^D4,IOI%#*;Z10RF^D4,IOI%#*;Z10RF^D4,IOI%#*;Z +M10RF^D6,:6JH7\1HJE_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ +M7\1HJE_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7SRF:6JH7SQ>?);PSG"7R2[ZP'S> +MW_+IH)=_;S]P_G!8_PD!YP_8+2KW0:=%F=3'O3O\_>-OSR2<'\T27L)=?'CR +MTW!APSL^BSF?/V!7+5/]0.C-!Y9P[WRL=X_A\I=VIW.*?,JW1?VEURFZYJH?GRHGN+JW;J1;K(.U[YX +MMB_O[MWE[CKCP[CX*-:=[UP79/W.7<(=;1M!.7>69?A_^??V`^=/A_6?)6`^ +,!WSS?ZE[ZN&@70`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-ebr.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-ebr.qcow.gz.uu new file mode 100644 index 000000000000..8e8e277b4f0c --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-ebr.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-512-ebr.qcow.gz +M'XL("*$S(E0``VEM9RTQ>#$M-3$R+65B,"-N"WZP?;K[?&Y_H`?KPY9)[3';4V0[9$-0029&Y4G5Y: +MA*3%T^OUKV^KU<96PW8U3*O+8?7]Q_.'K>[\X/['ZMM__OM_O+W[[=L?O\9L +M_9NGTH\'7\4\=V_K'^LVYS^>.J[6TY^8^_YA-'?GU<7_X=7=>;.W6]ZNB=,;_MSK^YK>KOTZO;_O[;IXNQLUN+TW^,]Y[E_SZW/Q +M=G=J;KPW=TUOU\7;G=3<_K>PN(#EH.:.Q=R`3YW4W+F8V^!3%YZSWWQN?\UM +M\2E3ZLY.Z(3PGNK.3NA$\)[KSD[HQ/">Z\Y.Z"3PGNO.+.^"G!G5?<&?G.%7=> +M<6?D.U?<><6=D>]<<><5=T:^<\6=5]P9^^"\5=E-R1[T)Q%R5WY+M0W$7)'?DN%'=#R1WY;E#< +M#25WY+M!<3=4W#D_);@;*NZ+.R7>#XFZHN'/RW:"X +M&RKNG'PW*.XV%7=.OMLH[C85=TZ^VRCN-B5WY+N-XFY3^VRCN-B5WY+N- +MXFY3^VRCN-B5WY+N-XFY3^VRCNMB5WY+NMXFY;^VRKNMA5WP4\) +M[K85=T&^VRKNMA5W0;[;*NZV%7=!OMLJ[K85=T&^VRKNMA5W0;[;*NYV%7=! +MOMLI[G85=T&^VRGN=B5WY+N=XFY7^VRGN=B5WY+N=XFY7^VRGN=B5W +MY+N=XFY7^VRGNQI([\MVHN!M+[LAWH^)NK+@;^"G!W5AQ-Y#O1L7=6'$W +MD.]&Q=U8<3>0[T;%W5AQ-Y#O1L7=6'$WD.]&Q=WRG[_U'/EN4MQ-%7<#^6Y2 +MW$TE=^2[27$WE=R1[R;%W51R1[Z;%'=3R1WY;E+<325WY+M)<3>5W)'O)L7= +MON2.?+=7W.U+[LAW>\7=ON)NPT\)[O85=QORW5YQMZ^XVY#O]HJ[?<7=AGRW +M5]SM*^XVY+N]XFY?<;2._+=07%W +M*+DCWQT4=X>2._+=07%W*+DCWQT4=X>2._+=07%W*+DCWQT4=\>2._+=47%W +M++DCWQT5=\>*NRT_);@[5MQMR7='Q=VQXFY+OCLJ[HX5=UORW5%Q=ZRXVY+O +MCHJ[8\7=EGQW5-R=*NZVY+N3XNY4<;2._+=27%W*KDCWYT4=Z>2 +M._+=27%W*KDCWYT4=Z>2._+=27%W*KDCWYT4=^>2._+=67%W+KDCWYT5=^>* +MNQT_);@[5]SMR'=GQ=VYXFY'OCLK[LX5=SORW5EQ=ZZXVY'OSHJ[<\7=CGQW +M5MQ=*NYVY+N+XNY2<;2._+=17%W*;DCWUT4=Y>2._+=17%W*;DC +MWUT4=Y>2._+=17%W*;DCWUT$=[9\1\^![VPMN+-UR1WXSM:".UM7W(W\%'-G +M97\W@N],]7=6]G"[TSU=U;V=R/XSE1_9V5_-X+O3/5W5O9W +M(_C.5']G97\W@N],]7=6]G"[TSU=U;V=R/XSE1_9V5_-X+O +M3/5W5O9W(_C.5']G97\W@N],]7=6]GKOK.SO]N0[U=]9V=_MR7>JO[.RO]N3[U1_9V5_MR??J?[.ROYN3[Y3 +M_9V5_=V>?*?Z.RO[NSWY3O5W5O9W>_*=ZN^L[._VY#O5WUG9W^W)=ZJ_L[*_ +MVY/O5']G97^W)]^I_L[*_FY/OE/]G97]W8&?$MR5_=V!?*?Z.RO[NP/Y3O5W +M5O9W!_*=ZN^L[.\.Y#O5WUG9WQW(=ZJ_L[*_.Y#O5']G97]W(-^I_L[*_NY` +MOE/]G97]W8%\I_H[*_N[`_E.]7=6]G<'\IWJ[ZSL[P[D.]7?6=G?'[*_NY(OE/]G97]W9%\I_H[*_N[(_E. +M]7=6]G='\IWJ[ZSL[X[D.]7?6=G?'KOK.SOCN0[U=]9V=\=R7>J +MO[.ROSN2[U1_9V5_=^*G!'=E?WKOK.SO3N0[U=]9V=^=R'>JO[.ROSN1[U1_9V5_=R+?J?[. +MRO[N1+Y3_9V5_=V)?*?Z.RO[NQ/Y3O5W5O9W)_*=ZN^L[.].Y#O5WUG9WYW( +M=ZJ_L[*_._-3@KNROSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9?*?Z.RO[ +MNS/Y3O5W5O9W9_*=ZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_.Y/O5']G97]W)M^I +M_L[*_NY,OE/]G97]W9E\I_H[*_N[,_E.]7=6]G=G\IWJ[ZSL[\[D.]7?6=G? +M7?@IP5W9WUW(=ZJ_L[*_NY#O5']G97]W(=^I_L[*_NY"OE/]G97]W85\I_H[ +M*_N["_E.]7=6]G<7\IWJ[ZSL[R[D.]7?6=G?7;.4W^WW*>WZMR![USU +M=Y[ZN]7,W6KA+M;\%'/GJ;];S=RM_M7FP'>N^CM/_=WJFLXNZ/X[5_V=I_ZN +MG5V?`]^YZN\\]7S!S]Z!S![YSU=]YZN\>S-P]Z-R![USU=Y[ZNP?7F[,#W[GJ +M[SSU=^WL^ASXSE5_YZF_@SGPG:O^SE-_!W/@.U?]G:?^;IE[V.?(=ZJ_\]3? +M/5SF.G?D.]7?>>KO'L[,UG +M1_??N>KO//5W[>SZ'/E.]7>>^CN8(]^I_LY3?P=SY#O5WWGJ[Y:Y1WV.?*?Z +M.T_]W:-EKG%']]^YZN\\]7>/9NX>=>[(=ZJ_\]3?/9JY>]2Y(]^I_LY3?_?H +M>G-VY#O5WWGJ[]K9]3GRG>KO//5W,$>^4_V=I_X.YLAWJK_SU-\M>^KO'RUSGCGRG^CM/_=WCF;O'C3NZ_\Y5?^>IOWL\<_>X<4?WW[GJ[SSU +M=X^O^>SH_CM7_9VG_JZ=79\CWZG^SE-_!W/D.]7?>>KO8(Y\I_H[3_W=,O>D +MSY'O5'_GJ;][LLPU[NC^.U?]G:?^[LG,W9/.'?E.]7>>^KLG,W=/.G?D.]7? +M>>KOGEQOSHY\I_H[3_U=.[L^1[Y3_9VG_@[FR'>JO_/4W\$<^4[U=Y[ZNV7N +M:9\CWZG^SE-_]W29Z]R1[U1_YZF_>SIS][1Q1_??N>KO//5W3V?NGC;NZ/X[ +M5_V=I_[NZ36?'=U_YZJ_\]3?M;/K<^0[U=]YZN]@CGRG^CM/_1W,D>]4?^>I +MOUOFGO4Y\IWJ[SSU=\^6N<8=W7_GJK_SU-\]F[E[UKDCWZG^SE-_]VSF[EGG +MCGRG^CM/_=VSZ\W9D>]4?^>IOVMGU^?(=ZJ_\]3?P1SY3O5WGOH[F"/?J?[. +M4W^WS#WO<^0[U=]YZN^>+W.=._*=ZN\\]7?/9^Z>-^[H_CM7_9VG_N[YS-WS +MQAW=?^>JO_/4WSV_YK.C^^]<]7>>^KMV=GV.?*?Z.T_]'KO//5WR]R+/D>^4_V=I_[NQ3+7N*/[[USU=Y[ZNQ +MS-R]Z-R1[U1_YZF_>W&].3ORG>KO//5W[>SZ'/E.]7>>^CN8(]^I_LY3?P=S +MY#O5WWGJ[Y:YEWV.?*?Z.T_]W]FXH_OO7/5WGOJ[E]=\=G3_G:O^SE-_U\ZNSY'O5'_GJ;^#.?*=ZN\\ +M]7]7GR'>JO_/4W[U:YAIW=/^=J_[.4W_W:N;N5>>.?*?Z +M.T_]W:N9NU>=._*=ZN\\]7>OKC=G1[Y3_9VG_JZ=79\CWZG^SE-_!W/D.]7? +M>>KO8(Y\I_H[3_W=,O>ZSY'O5'_GJ;][O>^KO7,W>O&W=T_YVK_LY3?_?ZFL^.[K]SU=]YZN_:V?4Y\IWJ[SSU=S!' +MOE/]G:?^#N;(=ZJ_\]3?+7-O^ASY3O5WGOJ[-\M]4?^>IOUOFWO8Y\IWJ[[SJ[X+NOW/5WWG5WP7=?^>JO_.J +MOPNZ_\Y5?^=5?Q=T_YVK_LZK_B[H_CM7_9U7_5W0_7>N^CNO^KN@^^]<]7>KOVMGU.?*=ZN\\]7JOXOE +M.VENW>?`=Z'ZN^\_<8^[Q4_KSAWX+E1_%ZF_6\][Z\8=W7\7JK^+U-^M9^[6 +MC3NZ_RY4?Q>IOUM?\]G1_7>A^KM(_5T[NSX'O@O5WT7J[V`.?!>JOXO4W\$< +M^"Y4?Q>IOUOFK,^![T+U=Y'Z.UOF&G=T_UVH_BY2?V?SR[/.'?@N5'\7J;^S +MF3OKW('O0O5WD?H[N]Z<'?@N5'\7J;]K9]?GP'>A^KM(_1W,@>]"]7>1^CN8 +M`]^%ZN\B]7?+G/[(=ZJ_B]3?^KO(O5W?LUG1_??A>KO(O5W[>SZ'/E.]7>1^CN8(]^I_BY2?P=S +MY#O5WT7J[Y:YZ'/D.]7?1>KO8IEKW-']=Z'ZNTC]7>.?*?ZNTC]7>.?*?ZNTC]75QOSHY\I_J[2/U=.[L^1[Y3_5VD_@[FR'>JOXO4W\$<^4[U +M=Y'ZNV5NZ'/D.]7?1>KOAF6N^4_U=I/YNF+D;&G=T_UVH_BY2?S?,W`V- +M.[K_+E1_%ZF_&Z[Y[.C^NU#]7:3^KIU=GR/?J?XN4G\'<^0[U=]%ZN]@CGRG +M^KM(_=TRM^ESY#O5WT7J[S;+7...[K\+U=]%ZN\V,W>;SAWY3O5WD?J[SKO(O5W[>SZ'/E.]7>1^CN8(]^I_BY2?P=SY#O5 +MWT7J[Y:Y;9\CWZG^+E)_MUWF.G?D.]7?1>KOMC-WV\8=W7\7JK^+U-]M9^ZV +MC3NZ_RY4?Q>IO]M>\]G1_7>A^KM(_5T[NSY'OE/]7:3^#N;(=ZJ_B]3?P1SY +M3O5WD?J[96[7Y\AWJK^+U-_MEKG&'=U_%ZJ_B]3?[6;N=IT[\IWJ[R+U=[N9 +MNUWGCGRG^KM(_=WN>G-VY#O5WT7J[]K9]3GRG>KO(O5W,$>^4_U=I/X.YLAW +MJK^+U-\M9N +M;-S1_7>A^KM(_=UXS6=']]^%ZN\B]7?M[/H<^4[U=Y'Z.Y@CWZG^+E)_!W/D +M.]7?1>KOEKFISY'O5'\7J;^;EKG&'=U_%ZJ_B]3?33-W4^>.?*?ZNTC]W31S +M-W7NR'>JOXO4WTW7F[,CWZG^+E)_U\ZNSY'O5'\7J;^#.?*=ZN\B]7]_GR'>JOXO4W[U?YCIWY#O5WT7J[][/W+UOW-']=Z'ZNTC]W?N9 +MN_>-.[K_+E1_%ZF_>W_-9T?WWX7J[R+U=^WL^ASY3O5WD?H[F"/?J?XN4G\' +M<^0[U=]%ZN^6N0]]CGRG^KM(_=V'9:YQ1_??A>KO(O5W'V;N/G3NR'>JOXO4 +MWWV8N?O0N2/?J?XN4G_WX7IS=N0[U=]%ZN_:V?4Y\IWJ[R+U=S!'OE/]7:3^ +M#N;(=ZJ_B]3?+7,?^QSY3O5WD?J[C\M[H_KM0_5VD_N[3S-VGSAWY +M3O5WD?J[3S-WGSIWY#O5WT7J[SY=;\Z.?*?ZNTC]73N[/D>^4_U=I/X.YLAW +MJK^+U-_!'/E.]7>1^KME[G.?(]^I_BY2?_=YF>O]4?Q>IO_L\<_>Y<4?W +MWX7J[R+U=Y]G[CXW[NC^NU#]7:3^[O,UGQW=?Q>JOXO4W[6SZW/D.]7?1>KO +M8(Y\I_J[2/T=S)'O5'\7J;];YK[T.?*=ZN\B]7=?EKG&'=U_%ZJ_B]3??9FY +M^]*Y(]^I_BY2?_=EYNY+YXY\I_J[2/W=E^O-V9'O5'\7J;]K9]?GR'>JOXO4 +MW\$<^4[U=Y'Z.Y@CWZG^;EB^D^:^]CGPW:#ZNR'U=U^7NZ/Z[_E0Q=^?;MS]> +M_AS#E@H._YGZ0]_T7?/_8;^;O?/]8VYVY'U]2V/3K>W!WCK[R\5]Z +MN_3%V7\SN-FL]ON;P?]:7M_/RW0&7ZWW\'?]$]_^\?;^7^WU_?S3VYO=:MBL +M-MO5Z'_V#?_/O_TW?3KH3V___\[OUUQ)7WO!]F?F?OYN>^=7WB5#_\2WCLG; +M.]?6;>A/;_<7\4,O9_H)^>KHJ[W_%?9N_H3TW<_SSZ\7__U?C9?_^Y&N$6V? +MWU5_?524WWN[OWE]J]NW^_-WM-W]7V]WYKQXNZO[W+XZ^HKJ +M?^63$>Q^FN7';SI[^+O^B6__?'O_KU^#PSSX +3MYW@L!Z_O\H__A#$M-3$R+65B=2C@X)0:@U(XIU8W-2#@;A?M3]`TPX-3%N*H^"/7QA+NR +M/IB[/I1_/W_*\8%\NCX,]?'46L,521P(J8V&*Y,X%%);#;=+XIR0VFNX0Q+G +MA52EX&Q"E1J7"RFKX2")6PLIU'`NB2N$E.:=37NW$5*:=S;M72FD-.]LVKNM +MD-*\LVGO=D)*\\ZFO=L+*B +MPUDII7D'S+N7A+N).*'?@>8=,.]>$>YUQ`G]#C3O@'GWAG"W$2?T.]"\`^;= +M6\*]BSBAWX'F'3#OWH^\LT*_`\T[9-Y](%86<4*_0\T[9-Y9PD'$"?T.->^0 +M>8>$K0E71)S0[U#S#IEW&\)]C#BAWZ'F +M'3+O/A'N<\0)_0XU[Y!Y]X5P=Q$G]#O4O'/,NZ^$^Q9Q0K]SFG>.>?>=+]\=6>-4')H#%)<"I"@-N +M,^N$?=@;EP&K2JO/A[U1?Z&^2D]OZBM,C_*V]PZ#.B]*_DK+X6;;'P&G'^9I +MH"O8GH-K#_.];_;-T`>&MV;+B)L\S##$M-3$R+65B2%QV@I>3P08MQ!\<9((_K.[FX;^YPNV-`*4&I`/@:]:'Q +M$@A,K>QQ@[Z7_IST"0.4%0@)\@HU[@WX\WBOI4/P7/_/XG`+-PGF>W`7X^6< +M="LC;M!SF=CWB!,I=81@OT/!RLRU)^J%GYMG8-0E+;!ZL*$/G/(+L[Y;*`.] +M"U4@G0KWN$$_2W]:H!B`V?Z@0`,L_F-6J)F4!@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-ebr.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-ebr.vhd.gz.uu new file mode 100644 index 000000000000..c1f997c4041b --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-ebr.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-512-ebr.vhd.gz +M'XL(".?%'50``VEM9RTQ>#$M-3$R+65BO"0'R\$2"`)V"A-2I.!??+NLFPH8^8# +M0`50"]0`27U="J`]E#L`U6E/[%MN;Z&KWUZ;^NOY>VL_W<;`./.M0G-MCP4( +M]9`2L-(/H4=]#9W#;$\OG\Z>7YX<#BW./5@0"`2I(&+V'&*#.DVZ.K^YZ)$/ +MH[IBKFZT4M^#`":`4N])2O*6XA5?X5/0KMA+U006#2=6#O?AB] +M$06^/N(L$?/X9$3U54F__N#PX;`:&%%H<[O; +MK@-*J2O&%'CK]-7:2I4Z5BVT\8[N?!L>@[Y&`V6IJZ\DV.&Q#M]?WBU-1Q-9 +MO>OC9W#X&VX0S(_!%;:4NI%^9L0[NC%-S*_#B90ZO82;5<[*S+G7["9V_CP# +M4ZND!K:S?1@"A_F%4=]^+@,#=Q/Z8.YNI7%E.)Y[./S%70AQA^3CG:Z,(U>NAH0KU^`P;R'`OK*H#%2CYFV\H[O>AH+G_R[Z>O'*?85]/KMS'K-BJ?3W9#$M-3$R+65B0:F5TD) +M+.ML@@+[_,)-WRZ4(4BX,_H@##V\NG6HKHR<##5< +M&0M7KH'0E6MQ(NY&(-J=15>@'A7>IPW-ZY:>%B@[8+09Q.Y7A`E@#5@!*M-/ +M)>`.TLP'"EI)3?G]594_EU\_PP;'^S]'V(R_2,QJP11$;CZ")]/W]#T=SIO+ +M]>QP;JMR'Y9H)EUIB`S"11KNR_[MN44>;^J2<)+0G[U"`I/`.0F\4W>DY8SM +H/N^"K6HH5"O3-?)"#*-;E<$I-O#Z;VXM#B.7BJZ]U1_9@4$XOP@````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-ebr.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-ebr.vmdk.gz.uu new file mode 100644 index 000000000000..9ad3787b91bc --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-ebr.vmdk.gz.uu @@ -0,0 +1,82 @@ +# $FreeBSD$ +begin 644 img-1x1-512-ebr.vmdk.gz +M'XL(".C%'50``VEM9RTQ>#$M-3$R+65BO +MH*67(`\+UI)GKVQ73G+T7M;BS'.9FN<%']3:!/=X[< +MB*8KEYOGSX5P==UZ>W07DBX+B;)=NNHS-46+_=+J_OB5;YY;7^'6L&SOI[^59O3C-2\+7V=W]I_]D=].GX>'^X^,'O[ZSV]O%N;PX +M_\O@,BR%U1=WX6ZX=*U+<9FR8LP*N-O9]>&O]S]/I_].#Y_N/[Q_`Y9[=GM; +M%EG9NN4X__SIV!GN1?+L`O<:V?4O?[M[XY_<_/2Q>V`Z%[4L9'GMI0[->[ED +M[OOV6%\]FYXF+K' +MZ8=?/TYO7OWRX7WHG=M;U[)V3=2LC2JRJG"I?&FN?97+Z!Z;==>RZ\_WC^_N +MA[=+F9^F5Z?7&=-=7.^6#6S\NK:JEY!+=&>795^__=_C4F\V^IV]9[IU$6L1 +MRVM7YZRJ7:YE`]>M.&=%Z:Z6?UH6O%12PCEEUP_O3]__M+S%7;/>?O?G[YFN +M6:(6SV6!2\A2T*ZF:JN_>OY89M>WWV:O7)$_O)O6)Y#IVNUMYIRW?V[DT +M;MOI;:/7K1C'_M2-W&+=-+MWT^/#K:?CU +MY_OWX_)&R]XPW;CU;EG.MIM/F[ELX++"SRYPZ=VK=5?#\IAN-GL^LNZO'=3-RY+6W(SW>Q6=_[\.GRGGKW4DCV[/G5MS?O)IRMR#P&% +MA[)=B\)RMA<4`)V&QP\/V\)>"1X7SW^6O12/RYL?J?7O3+BELU[?)7_V\ZS0 +MN%*,:I?0_13+E^\_+=_?/:WOXM9W$<]:HQHQVEVZ?RTI/MZ6>W'OPDX\>XT: +MQ!B/=._BH&T2S_EY]_BK!N0ZGHZ_"]"ST*A2C&J7+M:[RO>.GK5&-6*TNW2Q +MWEU\[^C9:]0@QGBHV-KWCIZS1KD3?Y5"?N#7LDOC>T?/0J-*,:I=NECO6M\[ +M>M8:U8C1[M+%>M?YWM&SUZA!C/%0L;WO'3UGC7(G`@3D.IYN\+VC9Z%1I1C5 +M+EVL=Z/O'3UKC6K$:'?I8KV;?._HV6O4(,9XJ-C9]XZ>LT:Y4RF]*U/IZMSW +MCIZ%1I5B5+MTD=[5Q#MZUAK5B-'NTD5Z5Q/OZ-EKU"#&>*A8XAT]9XURITIZ +M5R73$>_H66A4*4:U2Q?K'?&.GK5&-6*TNW2QWA'OZ-EKU"#&>*A8XAT]9XUR +MIXOT[I),1[RC9Z%1I1C5+EVL=\0[>M8:U8C1[M+%>D>\HV>O48,8XZ%BB7?T +MG#7*G?A+$.0ZGHYX1\]"HTHQJEVZ6.^(=_2L-:H1H]VEB_6.>$?/7J,&,<9# +MQ1+OZ#EKE#N1D(%<1],UN>\=/0N-*L6H=NDBO6N(=_2L-:H1H]VEB_2N(=[1 +ML]>H08SQ4+'$.WK.&N5.K?2N3:8CWM&ST*A2C&J7+M8[XAT]:XUJQ&AWZ6*] +M(][1L]>H08SQ4+'$.WK.&N5._/\3Y#J>CGA'ST*C2C&J7;I8[XAW]*PUJA&C +MW:6+]8YX1\]>HP8QQD/%$N_H.6N4.Y%_A%S'TQ'OZ%EH5"E&M4L7ZQWQCIZU +M1C5BM+MTL=X1[^C9:]0@QGBH6.(=/6>-C>DTK6Y[QT]"XTJQ:AVZ2*] +M:XEW]*PUJA&CW:6+]*XEWM&SUZA!C/%0L<0[>LX:Y4ZC]&Y,IB/>T;/0J%*, +M:ILX:Y4Z3]&Y*IB/>T;/0 +MJ%*,:ILX:Y4ZS]&Y.IB/> +MT;/0J%*,:ILX:E/8:-8@Q'BK6XUWP +MG#7*M4SX.R0IK<[C'82_@_)W$/X.2?ZN\W@'X>^@_!V$OT.2O^L\WD'X.RA_ +M!^'O#A3K\0["WT'Y.PA_AR2EU7F\@_!W4/X.PM\AR=]U'N\@_!V4OX/P=TCR +M=YW'.PA_!^7O(/S=@6(]WD'X.RA_!^'OD*2T.H]W$/X.RM]!^#LD^;O.XQV$ +MOX/R=Q#^#DG^KO-X!^'OH/P=A+\[4*S'.PA_!^7O(/P=DI16G_O>"7\'Y>\@ +M_!V2_%U/O!/^#LK?0?@[)/F[GG@G_!V4OX/P=P>*)=X)?P?E[R#\'9*45D^\ +M$_X.RM]!^#LD^;N>>"?\'92_@_!W2/)W/?%.^#LH?P?A[PX42[P3_@[*WT'X +M.R0IK9YX)_P=E+^#\'=(\G<]\4[X.RA_!^'OD.3O>N*=\'=0_@["WQTHEG@G +M_!V4OX/P=TA26CWQ3O@[*'\'X>^0Y.]ZXIWP=U#^#L+?(^@_!V$ +MOSM0+/%.^#LH?P?A[Y"DM(;<]T[X.RA_!^'OD.3O!N*=\'=0_@["WR')WPW$ +M.^'OH/P=A+\[4"SQ3O@[*'\'X>^0I+0&XIWP=U#^#L+?(^@_!V$ +MOT.2OQN(=\+?0?D["']WH%CBG?!W4/X.PM\A26D-Q#OA[Z#\'82_0Y*_&XAW +MPM]!^3L(?X"7\'Y>\@_!V2_-U(O!/^#LK?0?@[)/F[D7@G_!V4OX/P +M=P>*)=X)?P?E[R#\'9*4UDB\$_X.RM]!^#LD^;N1>"?\'92_@_!W2/)W(_%. +M^#LH?P?A[PX42[P3_@[*WP4Q'>1:TF7;MT\WY5OO@F>A47G^^6/IW9(BSVY6 +M-QGK`['J`\-,8:OJ]R7+](O(LRW +MZ?DB_2+"?)N>+](O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2\BS+=-](L(\VT3 +M_2+"?-M$OX@PWS;1+R+,MTWTBPCS;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M +M$_TBPGS;1+^(,-\VT2\BS+=-](L(\VT3_2+"?-M$OX@PWS;1+R+,MTWTBPCS +M;1/](L)\VT2_B##?-M$O(LRW3?2+"/-M$_TBPGS;1+^(,-\VT2^"\VT;_2(F +M4_TB)E/](B93_2(F4_TB)E/](B93_2(F4_TB)E/](B93_2(F4_TB)E/](B93 +M_2(F4_TB)E/](B93_2+F/#?4+V(VU2]B-M4O8C;5+V(VU2]B-M4O8C;5+V(V +MU2]B-M4O8C;5+V(VU2]B-M4O8C;5+V(VU2]B-M4O8C;5+Y[S/#?4+YYO/DMX +M%Q5/=UOLI@\LT?_FA/,<[5X)]Z@L#LO15?YB.38AF?0-\?5]K>E&ZW+GWY:P +MJK*NNTGX3ZYO_33A[;-5;_^.W[A^<]K_">M;/PZSJMW'Q%:7K#D?+?BG;W]\ +M5O"6SNQQV=+=?/3T\W1AP0<^R;HLUX^>%D]],N(WKD^/R79FNO)+J],IS[%B +MC3]ZNBR;9W&ZS^N,8'A2,SQ#EK"_V=/ZVMMEG'?E?F%]-\A2ENY'D'[XJN[B +M#NLBY6;[=/T7]_;+J_OZ=G6#\694S]\9!]^Y+LG^G;NE.]L"P65%EDTZ#$M-3$R+6=P="YQ8V]W+F]U=`"MG?U +M%5=OB9*HC(C[U-MNM`'/RH9[UH.ZKQQU&]ES?7PSR?,@(_=6V!!51$$%X6YD +M'BTNJE2KC@Z'NV]-TTG3]DT[-<>EN?GG]"'-O7]X^-'\^-M?_GI]_]N/W^[& +MY/"3I]P_M]I(FGNP]>GUN8P_0MS-Q]P[MZKLW_CU=U[LY=S5[_=O5G\ +MG+)!>S#8I+E#>GU"3J_]UU[?=_=VY>[T'N_M*GF['1OL'PS^GN;^2*]/R=L= +MV-SX8.[DWJZ2MSNQN?FGL"B!96%S:S#7PJ"?&>,.XNX$^0[8]Q9R!WR +MG3'N+.0.^&W"'?M8R[ +M-N0.^:YEW+41=XJ?(MRU$7>*?-.NB[A3Y+N.<==%W"GR7<>XZT+ND.\ZQET7%W"'?=8R[+N0.^:YCW'4A=\AW'>.N#[E#ONL9=WW('?)=S[CK(^X,/T6X +MZR/N#/FN9]SU$7>&?-$W"'?#8R[(>0.^6Y@W`TA=\AW`^-N"+E#OAL8=T/('?+= +MP+@;0NZ0[P;&W1ARAWPW,N[&D#ODNY%Q-T;>0[R;&W11QUR+?38R[ +M*>0.^6YBW$TA=\AW$^-N"KE#OIL8=U/('?+=Q+B;0NZ0[R;&W11RAWPW,>[F +MD#ODNYEQ-X?<(=_-C+LYXJ[#3Q'NYHB[#OEN9MS-$7<=\MW,N)LC[CKDNYEQ +M-T?<=OP4X6Z-N.N1[U;&W1IQUR/?K8R[->*N1[Y;&7=KQ%V/?+%W"'?;8R[+>0.^6YCW&TA=\AW&^-N +M"[E#OML8=UO('?+=QKC;0NZ0[S;&W1YRAWRW,^[VD#ODNYUQMT?<#?@IPMT> +M<3<@W^V,NSWB;D"^VQEW>\3=@'RW,^[VB+L!^6YGW.T1=P/RW)N0+X[,NZ.(7?(=T?&W3'D#OGNR+@[AMPAWQT9=\>0.^2[(^/N&'*' +M?'=DW!U#[I#OCH0[R=_A<\!WL +MOY.POQN![X3U=Q+V=R/PG;#^3L+^;@2^$];?2=C?CLOY.POQN![X3U=Q+V=R/PG;#^3L+^ +M;@2^$];?2=C?C]8?R=A?SOO).SO9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/? +ML?Y.POYN1KYC_9V$_=V,?,?Z.PG[NP4_1;@+^[L%^8[U=Q+V=POR'>OO).SO +M%N0[UM])V-\MR'>LOY.POUN0[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z +M.PG[NP7YCO5W$O9W"_(=Z^\D[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W +M(-^Q_D["_FY!OF/]G83]W8J?(MR%_=V*?,?Z.PG[NQ7YCO5W$O9W*_(=Z^\D +M[.]6Y#O6WTG8WZW(=ZR_D["_6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83]W8I\ +MQ_H["?N[%?F.]7<2]G]8?R=A +M?[["_FY#OF/]G83]W89\Q_H["?N[#?F.]7<2]G<;\AWK +M[R3L[S;D.];?2=C?;OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_ +M)V%_M^.G"'=A?[^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V=SOR +M'>OO).SO=N0[UM])V-_MR'>LOY.PO]N1[UA_)V%_MR/?L?Y.POYN1[YC_9V$ +M_=V.?,?Z.PG[NQWYCO5W$O9W._(=Z^\D[.]VY#O6WTG8W^W(=ZR_D["_.^*G +M"'=A?W=$OF/]G83]W1'YCO5W$O9W1^0[UM])V-\=D>]8?R=A?W=$OF/]G83] +MW1'YCO5W$O9W1^0[UM])V-\=D>]8?R=A?W=$OF/]G83]W1'YCO5W$O9W1^0[ +MUM])V-\=D>]8?R=A?W=$OF/]G>;ON+FFS@'?W3R%N5/7W^7[])K*'?"=LOY. +M77_7).Z:S)T=\%.8.W7]79.X:_XH<\!WROH[=?U=OOP!SPG;+^3EU_!^:`[Y3U=^KZNSSWI,X!WRGK[]3U=T_R7%/F +M@.^4]7?J^KLGB;LGE3O@.V7]G;K^[DGB[DGE#OA.67^GKK][TSB'?L?Y.77_W +M-,]5[I#O6'^GKK][FKA[6KA#]]\IZ^_4]7=/$W=/"W?H_CME_9VZ_N[IR9\= +MNO].67^GKK\K9U?GD.]8?Z>NOP-SR'>LOU/7WX$YY#O6WZGK[_+LOU/7WY6SJW/(=ZR_4]??@3GD.];?J>OOP!SR'>OOU/5W>>YYG4.^ +M8_V=NO[N>9ZKW"'?L?Y.77_W/''WO'"'[K]3UM^IZ^^>)^Z>%^[0_7?*^CMU +M_=WSDS\[=/^=LOY.77]7SJ[.(=^Q_DY=?P?FD.]8?Z>NOP-SR'>LOU/7W^6Y +M%W4.^8[U=^KZNQ=YKG"'[K]3UM^IZ^]>).Y>5.Z0[UA_IZZ_>Y&X>U&Y0[YC +M_9VZ_N[%Z>+LD.]8?Z>NORMG5^>0[UA_IZZ_`W/(=ZR_4]??@3GD.];?J>OO +M\MS+.H=\Q_H[=?W=RSQ7N4.^8_V=NO[N9>+N9>$.W7^GK+]3U]^]3-R]+-RA +M^^^4]7?J^KN7)W]VZ/X[9?V=NOZNG%V=0[YC_9VZ_@[,(=^Q_DY=?P?FD.]8 +M?Z>NO\MSK^H<\AWK[]3U=Z_R7.$.W7^GK+]3U]^]2MR]JMPAW['^3EU_]RIQ +M]ZIRAWS'^CMU_=VKT\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/( +M=ZR_4]??Y;G7=0[YCO5WZOJ[UWFNO3_[LT/UWROH[=?U=.;LZAWS'^CMU_1V80[YC_9VZ +M_@[,(=^Q_DY=?Y?GWM0YY#O6WZGK[][DN<(=NO].67^GKK][D[A[4[E#OF/] +MG;K^[DWB[DWE#OF.]7?J^KLWIXNS0[YC_9VZ_JZ<79U#OF/]G;K^#LPAW['^ +M3EU_!^:0[UA_IZZ_RW-7=0[YCO5WZOJ[JSQ7N4.^8_V=NO[N*G%W5;A#]]\I +MZ^_4]7=7B;NKPAVZ_TY9?Z>NO[LZ^;-#]]\IZ^_4]7?E[.H<\AWK[]3U=V`. +M^8[U=^KZ.S"'?,?Z.W7]79Y[6^>0[UA_IZZ_>YOG"G?H_CME_9VZ_NYMXNYM +MY0[YCO5WZOJ[MXF[MY4[Y#O6WZGK[]Z>+LX.^8[U=^KZNW)V=0[YCO5WZOH[ +M,(=\Q_H[=?T=F$.^8_V=NOXNS[VK<\AWK+]3U]^]RW.5.^0[UM^IZ^_>)>[> +M%>[0_7?*^CMU_=V[Q-V[PAVZ_TY9?Z>NOWMW\F>'[K]3UM^IZ^_*V=4YY#O6 +MWZGK[\`<\AWK[]3U=V`.^8[U=^KZNSSWOLXAW['^3EU_]S[/%>[0_7?*^CMU +M_=W[Q-W[RAWR'>OOU/5W[Q-W[RMWR'>LOU/7W[T_79P=\AWK[]3U=^7LZASR +M'>OOU/5W8`[YCO5WZOH[,(=\Q_H[=?U=GKNN<\AWK+_3J+\S=/^=LOY.H_[. +MT/UWROH[C?H[0_??*>OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ.XWZ +M.T/WWRGK[Y3T=Q_J'/(=Z^_4]7AN +MOP-SR'>LO[/\'3=WJ'/`=\;ZNYL?>,!=]M.A<@=\9ZR_,]??'=+>H7"'[K\S +MUM^9Z^\.B;M#X0[=?V>LOS/7WQU._NS0_7?&^CMS_5TYNSH'?&>LOS/7WX$Y +MX#MC_9VY_@[,`=\9Z^_,]7=Y3NH<\)VQ_LYOOS/5WDKB3RAWPG;'^SEQ_)Z>+LP.^,];?F>OORMG5.>`[8_V=N?X. +MS`'?&>OOS/5W8`[XSEA_9ZZ_RW-:YY#O6']GKK_3/%>Y0[YC_9VY_DX3=UJX +M0_??&>OOS/5WFKC3PAVZ_\Y8?V>NO].3/SMT_YVQ_LYOOS/5W;9ZKW"'?L?[.7'_7)N[:PAVZ +M_\Y8?V>NOVL3=VWA#MU_9ZR_,]??M2=_=NC^.V/]G;G^KIQ=G4.^8_V=N?X. +MS"'?L?[.7'\'YI#O6']GKK_+ZZ +MRAWR'>OOS/5W7>*NJ]PAW['^SEQ_UYTNS@[YCO5WYOJ[Z0[UA_9ZZ_ZQ-W?>$. +MW7]GK+\SU]_UB;N^<(?NOS/6WYGK[_J3/SMT_YVQ_LYNOQM.%V>'?,?Z.W/]73F[.H=\Q_H[<_T= +MF$.^8_V=N?X.S"'?L?[.7'^7Y\8ZAWS'^CMS_=V8YRIWR'>LOS/7WXV)N[%P +MA^Z_,];?F>OOQL3=6+A#]]\9Z^_,]7?CR9\=NO_.6']GKK\K9U?GD.]8?V>N +MOP-SR'>LOS/7WX$YY#O6WYGK[_+<5.>0[UA_9ZZ_F_)LOS/7WTV) +MNZERAWS'^CMS_=V4N)LJ=\AWK+\SU]]-IXNS0[YC_9VY_JZ<79U#OF/]G;G^ +M#LPAW['^SEQ_!^:0[UA_9ZZ_RW,?ZQSR'>OOS/5W'_-LOS/7WWW*?3A=GAWS'^CMS_5TYNSJ' +M?,?Z.W/]'9A#OF/]G;G^#LPAW['^SEQ_E^<^USGD.];?F>OO/N>YRAWR'>OO +MS/5WGQ-WGPMWZ/X[8_V=N?[N<^+N<^$.W7]GK+\SU]]]/OFS0_??&>OOS/5W +MY>SJ'/(=Z^_,]7=@#OF.]7?F^CLPAWS'^CMS_5V>^U+GD.]8?V>NO_N2YPIW +MZ/X[8_V=N?[N2^+N2^4.^8[U=^;ZNR^)NR^5.^0[UM^9Z^^^G"[.#OF.]7?F +M^KMR=G4.^8[U=^;Z.S"'?,?Z.W/]'9A#OF/]G;G^+L]]K7/(=ZR_,]???OOOB;NOA;NT/UWQOH[<_W=U\3=U\(=NO_.6']GKK_[>O)GA^Z_ +M,];?F>OORMG5.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\]ZW.(=^Q_LY< +M?_OOOB?NOF?NV@-^BORYQ^[-?L^]\7690W_>=GDJ +MF+OW[<=O5W>#Z+ZJMF2`T>O[P[\^=%_5K[R^[O;\6FT.,_@[_X$??[Y^^%<9 +MO+T[Z-\8S*_PX5Q^P]W=W4&WT=1^X\YC^CC(_3<\UNOTP!M^#_Y5?W^UU/VW7M'W33NDBQU::3INN+7.W[[5;[[^^__S+ +M7YO?__3W?YS'_KN^W=OK?G9MAO7V#Q_8W*L3^G9_^+=[-W?[Y7OPIYWGC,X] +MP7.W7[Z[G\RA#S[7_NRI@])7=_%S>S?7'1X^-=Y_:NR:49O^YM^&9CKW/P_F +MT!\?_RODW=XV_OR'[S;CS:?)W7^:T=O_EVEJ!CG_ +M7W;GG]M__NWZGW=C[Z__[VUZ?76;I'.[TIP8(^^`_0TYOO3@\?TOE%P4^9'_>O$;T_!WZ]\DNG=_M_ +M-9Z_QL[@[_P'?OQ^_?"ON\$V#3[:*VP/_?J(GQWGN4?\[#C//>)GQWGN43\[ +MSH./^-EQGGO$SX[SW"-^=ISG'O6SXV;P]O<<'^F+^'GNS%YKS;PVZ]#T_HLX +M^W+\XS^NK_\7O-V[WW-D7_I_\D4<_V3LC_A%_#SW\R_B/?VYS=_AAN9_O;_@'C+'O6L```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu new file mode 100644 index 000000000000..7528fc4bcfba --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu @@ -0,0 +1,26 @@ +# $FreeBSD$ +begin 644 img-1x1-512-gpt.qcow2.gz +M'XL(")4[(U0``VEM9RTQ>#$M-3$R+6=P="YQ8V]W,BYO=70`K9A+;YPP$(#O +M^15.WTT:BLVL/+(]3%:EWVM]>C`T&,P/)UKMHE[N[CJ:?]LC`>$Q$(0-2C+@9Z]+A +M@,+%?#G`<=PD.X'@8(A:@K9PDLQN;0#!G1SU2]??C,R+$(<`#8Z\&0?E!R8_ +M/T(>F!^$SD_@ZZ>&.'\@6<]/F/S\J)3"99LX0*)R"E=LX@02M:=PY29.(E$5 +MA:LW<0J):@@0F+D.B*._XMG]*Y`H +MRCN^[=T>B:*\X]O>E4@4Y1W?]JY"HBCO@/"..5R-1%'>@>?=L<4]^%P2+\#RCOPO'MI<2<. +MA_0[H+P#S[M3BWOE<$B_`\H[\+P[6WC'D7X'E'?"\^ZU9<4.A_0[07DG/.^X +MQ8'#(?U.4-X)SSMA<=+AD'XG*.^$YYVRN,3AD'XG*.^$YUUJ<9G#(?U.4-X) +MS[OO;>X#PZ']#M!>2<][SY:W">' +M0_J=I+R3GG?G%G?A<$B_DY1WTO/NTN(^CSC`HD;OXAB_+.YJ4;.`]#N9W!.W +M6^+HAY5#CK/2';3`P(RX>-H@JL"KU]?;@\`*L6*8@'\ +M/N37EUM77^;=0&>WZIN!`J;DB.OGJLII?E>[:W9S_O6;AOUPT^W+3>-J_;!4 +M)%YVG)KNU1?$/F7*+6W\U1YP@L*-QS(/IX\7:;6"PR[6_B%P1TW;%LL4RX`E):L*$O=KADL"FR?U\#YA:JV"KEUM9L(L>(%>O,*N'+Y)."BV9=EBUH>`&W#[PZB5ZN*N/KG\O +M?^F!]B::?PU06F"P#&72E`&K0^,"5H?&!:P.C0M:'1H8L#HT+F!U:%S`ZM"X +MH-71`>LXW":N<=J]/&.J8KED335/@]R.V^@G.MT:UK;^E4T#$M-3$R+6=P="YR87.*>+8T+K=IG%GSBCWTO[.-."OG7G[JY2UX#:Z!MB)QGS.<8^X\ +M@^;:0=F`.X!5T'3XT#I0*L079.('2*AO"W('I0)=([`_OHACA-V(K^LQ/J/& +MCLAMVD!5S^BUCL"@_D@7YKB"NWH>JV?9JK<;FR6W:0-9O2I6+U\D4C)]JEI2 +M2,+5S-5S:`[Z"/_O\SMMZ/=B?D6@&8%L$8;F#$M-3$R+6=P="YV:&0N;W5T`*V82V^<,!"`[_D5 +M4_66JA0;V[#'1DVDWM+7+8>`@6BE=OM(#E'%CZ_'V(`7FW238;V(E7<^YN7Q +MR'D^7@"J`-6#ZD!)?"X%J!V4%8"9=(/;.W,_8=`_#YU^V#]F[AK.1AC+EU*A +M.,KS`H1Y20F\QI>H%I]A\)CL]>7=^?['G<=QA_,O%@H$!VD@8O4>E4_:(>GJ +MXLL'B[R=M2O6VLU2YML(R`4PMOA'X;6[G72<<,)(];T=)90URDXC^!%,(.YO +MEJUQ,C^26J@9<^K"V!A.;4F=@CL_<[$84\4D1FGNQG4,2H[/)FV\'U;#I,KC +M_:_ZSWUWI!]/I(J:]&.KN2)M+G>IPOV?G08"TWG+7+"4AV-<)%5>Y#T5ROGH +M&B?DTD]P:W[HO1D%2_T4RS=\G@Y&4K\:]3-K*Z\C]_3$<)&%GPG8-*[<(/`X?`I +M.XRPM]GO-TZ_CKF,B(WT1,I['=_*"%3J"7,AQ%'7Y:Y"[TDR[^UB+I +MO7KT7MQ)J%1LZ4Z[6I:]"G$-K?>8;1_-^C#U>WU/3PS76?@9@=QM0V3[&G>% +ME$Q#X8!D&@JW?@DU9&(SF*=&6;F@$%48Q!%6&,015AC$D588!!)6&,015AC$ +M$588Q)%6&$7;""G7".6E#4`!31>JD6QI!A\(WW)X'-]JGS8:H7@P*!LA]50C +MU'=)8_UU9"QA(Z2H&R'E"BG168;RC=!:A^><92C?""U>_(*S#!5OA)Y[EH$X +8PK,,Q!&>92"..%6P;SG[!W#$M-3$R+6=P="YV:&1F+F]U=`"METMOU#`0@._[ +M*P;U5D2P'=O)'EO12MS*Z]9#\["KE6`1$@<.^?%X_"!VU@X4.1E%64W\99X9 +M+R'N`.`,R)"YEA7+;9.>R^'Z8&ET?!G0O!]-V``;`W2XR2@)PV>4`JV]$&I7 +MN<5&6K+>6URS'J2)<'.\:B-E18QK'"ZXJU\&%`*&X0+X)=C';#H$<`G\",P\ +M3X!3$`P$_X.SOHLIMN_N_CT\W'S\C+#'U5U&C5+-0%J01]#SQCI:=O>T<=?A +MC$$8?::SSK9%W-MM]!RN1=R\@\M)&:A +MB/N:X&3ERN.H'B5T$T@%@L*D\6:60*FQS[1);R$,F,G[$3H*;$3@/4U\1.2DK2M'C;*\BT*B_N`LIKJT=O1ZC)ZI%[^B+)2=E13%Z@XM> +M/DAH5*YU#6C2TP&Y!U:S4&@]5>P.Q%7L +M#L15[`[$5>T.!%;L#L15[`[$5>P.Q%7M#@-4I-X01YRMOX5D5GP[%QMN(01US5(2[]]EN:W9GM+RGP +MON.X6>OZ&,C6FK'`Z?M933]/O^+H(8ZZBL@*KFG;<\`Q[U5X,5:TJ6(#X1?NRM3=^]M/[RSR:;4N\YF2#$M-3$R+6=P="YV;61K+F]U=`"M7%V/W,81?/>O +MF,@/#A)DP5J22_)!0.S(!HP@@&(I\4L>LOR*#Y$EY70(8F!_?#CDU%SQ;N=( +M^?I,B=O:[MKI'K+W7%U@EBT_SA6M*PI7]*X\N0QN^J?E<%E^;TS'L>8;ES^_ +M^LO?#_SY[>%P^6(!@X^2$&0*)\;J;P6PM6=Y[=[_T+@7`1R*[CR2D[)9)]:W>^^",7SZ\O]&J;M/36N +MRMVI#:8[E;.=N^HXOY>Y:G(:)\`OW:N;3_]VKX9/W>W-Q[L/87U'O[>3XRY^^?_4R7+G9X>/YEG`^:EK(]-E3'HI[.CG_ +MY_$QKVYX?^<1Q_`35^?W-A2GG#^[\"_*PE6-FY=3>NSC]'8?4IYKU]T.Y[OA +M[2\?AYD1_V +M3&E^&EX=O2'FS +MRZ,K*X\U;>"\%4>7%_[5]$_3@J=,"G@G=_GP_O##C],M[HOUYO77/Q"NGJ(F +MSVF!4\B4T"JGK5-W%GSS[98CZFI0T>Y;1`^^M[+N=4N&6G +MEXV>MZ+OV\.Y/W^\&V[]]L:M:'V)^I"IW];B?AO7GU/-.S7Z*\9=7KH7-_VT +MIQ[V7\.'GPG7+9?QM`Y_231S8.Y?3%?/##^$3UBN&+]-'FZXN_WET/WR[N9] +M/]UH[B7A^J5VTW*6W;S?S&D#IQ5>7>!4NQ?SKL;E$6[PJ^L?+7#>SU#(N*CX +ML>[R\[R\GX9S/RUMPB;7V_OI-?WTD\*XVJQ6A6+8:U8G1[ZG> +MR;>V03S'A]7CKQJ0UVDX_BY`SURC"C'*%5RJ=F6H'3TKC:K%:%9PJ=J=0NWH +MV6I4)T:_*]DJU(Z>HT;Y$W^50K;CU[)3'6I'SURC"C'*%5RJ=DVH'3TKC:K% +M:%9PJ=J=0^WHV6I4)T:_*]DVU(Z>HT;Y$QL$Y'4:K@NUHV>N4848Y0HN5;L^ +MU(Z>E4;58C0KN%3MAE`[>K8:U8G1[TIV#+6CYZA1_E1([8HMN"H+M:-GKE&% +M&.4*+E&[BOV.GI5&U6(T*[A$[2KV.WJV&M6)T>]*EOV.GJ-&^5,IM2LWX=CO +MZ)EK5"%&N8)+U8[]CIZ51M5B-"NX5.W8[^C9:E0G1K\K6?8[>HX:Y4\GJ=UI +M$X[]CIZY1A5BE"NX5.W8[^A9:50M1K."2]6._8Z>K49U8O2[DF6_H^>H4?[$ +M7X(@K]-P['?TS#6J$*-]*EOV.GJ-&^5,CM6LVX=COZ)EK5"%&N8)+U8[]CIZ51M5B-"NX5.W8[^C9 +M:E0G1K\K6?8[>HX:Y4_\_R?(ZS0<^QT]J +M'?L=/5N-ZL3H=R7+?D?/4:/\B?PCY'4:COV.GKE&%6*4*[A4[=COZ%EI5"U& +MLX)+U8[]CIZM1G5B]+N29;^CYZA1_M1)[;HMN"8+M:-GKE&%&.4*+E&[AOV. +MGI5&U6(T*[A$[1KV.WJV&M6)T>]*EOV.GJ-&^5,OM>LWX=COZ)EK5"%&N8)+ +MU8[]CIZ51M5B-"NX5.W8[^C9:E0G1K\K6?8[>HX:Y4^#U&[8A&._HV>N4848 +MY0HN53OV.WI6&E6+T:S@4K5COZ-GJU&=&/VN9-GOZ#EJE#^-4KMQ$X[]CIZY +M1A5BE"NX5.W8[^A9:50M1K."2]6._8Z>K49U8O2[DF6_H^>H49E,SR"ODW#G +M;*E=],PUJA"C7,$E:G<._2YZ5AI5B]&LX!*U.X=^%SU;C>K$Z'^@_!V$O]N1+/N=\'=0 +M_@["WV&3TFK9[X2_@_)W$/X.F_Q=RWXG_!V4OX/P=]CD[UKV.^'OH/P=A+_; +MD2S[G?!W4/X.PM]AD])JV>^$OX/R=Q#^#IO\7]V),M^)_P=E+^#\'?8I+0Z]COA[Z#\'82_PR9_U['? +M"7\'Y>\@_!TV^;N._4[X.RA_!^'O=B3+?B?\'92_@_!WV*2T.O8[X>^@_!V$ +MO\,F?]>QWPE_!^7O(/P=-OF[COU.^#LH?P?A[W8DRWXG_!V4OX/P=]BDM#KV +M.^'OH/P=A+_#)G_7L=\)?P?E[R#\'3;YNX[]3O@[*'\'X>]V),M^)_P=E+^# +M\'?8I+3Z+-1.^#LH?P?A[[#)W_7L=\+?0?D["'^'3?ZN9[\3_@[*WT'XNQW) +MLM\)?P?E[R#\'38IK9[]3O@[*'\'X>^PR=_U['?"WT'Y.PA_ATW^KF>_$_X. +MRM]!^+L=R;+?"7\'Y>\@_!TV*:V>_4[X.RA_!^'OL,G?]>QWPM]!^3L(?X=- +M_JYGOQ/^#LK?0?B['NKFZPU@>.XU[`_'JZ?H]CNLB>7,;GKP^S?C'./):J_SK`!?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2 +M?O)OI*6+1>P^#&,1R+N;][QT?=]^ +M][U[_?4/;SW8/^[3G1_O/':NZ=U0>8CUZO!$NF\?WQW%_'CGJ?K'ZFJR>1+N +MJVLW6S$_WGGLGX"[=J3ABJ>B/O=)X,7\>&>-4O6MJTM7'_WS>_MS$N[="NYD +M?.7-3YYM3Z[J_/.#2[AN?MAS?_*TM*NGVV2Y)X[NV'LE0@5W]$]D/ES>__7P +M?@'[P^$_OP_K6YX\B^M'^HU4]8KC4U>$7]1&NFX-EUM7S_^^TI9FU6O"Q7+M +M2+^1K-YYJ5[B6VU:U+5;=X+CM]IOUG"MX.#V=X=W@XP[O#PYG>'1[0\.[P<(9WAXV%>K=&?.,?G5_\27^/7-&`R_Q#W< +BDU_BXY!.-OP\2-;P2]S#F7Z)%_[IG=D7_P=,%9H/M&4````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-mbr.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-mbr.qcow.gz.uu new file mode 100644 index 000000000000..903950a45447 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-mbr.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-512-mbr.qcow.gz +M'XL("*0S(E0``VEM9RTQ>#$M-3$R+6UB:3Q75MU5JD1!@A07I.?1 +M$;KKR'.]_OEMM=K8:MBNAFEU.:R^_WC^L-6=']S_6'W[[__\K[=WOWW[[>>8 +MK7_Q5/KQX*N8Y^YM_6/=YOR/IXZK]?0GYKY_&,W=>77Q+[RZ.V_V=N[E;S_? +M+#_G:O#^VUW-<\O;-7%ZPY][?5_3V[6?I_?WO5T7;W>C!K?W!O\YS_T^OSX7 +M;W>GYL9[<]?T=EV\W4G-[7\)BPM8#FKN6,P-^-1)S9V+N0T^=>$Y^\7G]N?< +M%I\R-><6?D.U?<><6=D>]<<1<5=T:^"\5=5-P9^2X4=U%R +M1[X+Q5V4W)'O0G$7)7?DNU#<1+.R7>#XFZHN'/RW:"X&RKNG'PW*.Z&BCLGWPV* +MNZ'BSLEW@^)N4W'GY+N-XFY3<>?DNXWB;E-R1[[;*.XV)7?DNXWB;E-R1[[; +M*.XV)7?DNXWB;E-R1[[;*.XV)7?DNXWB;EMR1[[;*NZV)7?DNZWB;EMQ%_R4 +MX&Y;<1?DNZWB;EMQ%^2[K>)N6W$7Y+NMXFY;<1?DNZWB;EMQ%^2[K>)N5W$7 +MY+N=XFY7<1?DNYWB;E=R1[[;*>YV)7?DNYWB;E=R1[[;*>YV)7?DNYWB;E=R +M1[[;*>YV)7?DNYWB;BRY(]^-BKNQY(Y\-RKNQHJ[@9\2W(T5=P/Y;E3WGB/?38J[J>)N(-]- +MBKNIY(Y\-RGNII([\MVDN)M*[LAWD^)N*KDCWTV*NZGDCGPW*>ZFDCORW:2X +MVY?_VBKM]R1WY;J^XVU?<;?@IP=V^XFY#OMLK[O85=QORW5YQMZ^XVY#O +M]HJ[?<7=AGRW5]SM*^XVY+N]XF[YSY!ZCGQW4-P=*NXVY+N#XNY0^.RCN +M#B5WY+N#XNY0^.RCN#B5WY+N#XNY0^.RCN#B5WY+N#XNY8^.RKN +MCB5WY+NCXNY8<;?EIP1WQXJ[+?GNJ+@[5MQMR7='Q=VQXFY+OCLJ[HX5=UOR +MW5%Q=ZRXVY+OCHJ[4\7=EGQW4MR=*NZVY+N3XNY4^.RGN3B5WY+N3XNY4 +M^.RGN3B5WY+N3XNY4^.RGN3B5WY+N3XNY<^.RONSB5WY+NSXNY< +M<;?CIP1WYXJ['?GNK+@[5]SMR'=GQ=VYXFY'OCLK[LX5=SORW5EQ=ZZXVY'O +MSHJ[2\7=CGQW4=Q=*NYVY+N+XNY2^NRCN+B5WY+N+XNY2^NRCN+B5W +MY+N+XNY2^NRCN+B5WY+N+X,Z6[^@Y\)VM!7>V+KD#W]E:<&?KBKN1GV+N +MK.SO1O"=J?[.ROYN!-^9ZN^L[.]&\)VI_L[*_FX$WYGJ[ZSL[T;PG:G^SLK^ +M;@3?F>KOK.SO1O"=J?[.ROYN!-^9ZN^L[.]&\)VI_L[*_FX$WYGJ[ZSL[T;P +MG:G^SLK^;@3?F>KOK.SO1O"=J?[.ROYN)-^I_L[*_FXDWZG^SLK^;N*G!'=E +M?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4 +M?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\W +MD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?[?GIP1W97^W)]^I_L[* +M_FY/OE/]G97]W9Y\I_H[*_N[/?E.]7=6]G=[\IWJ[ZSL[_;D.]7?6=G?[KOK.SO]N0[U=]9V=_MR7>JO[.ROSOP4X*[LK\[D.]4?V=E?W<@WZG^ +MSLK^[D"^4_V=E?W=@7RG^CLK^[L#^4[U=U;V=P?RG>KOK.SO#N0[U=]9V=\= +MR'>JO[.ROSN0[U1_9V5_=R#?J?[.RO[N0+Y3_9V5_=V!?*?Z.RO[NP/Y3O5W +M5O9W!_*=ZN^L[.\.Y#O5WUG9WQWY*<%=V=\=R7>JO[.ROSN2[U1_9V5_=R3? +MJ?[.RO[N2+Y3_9V5_=V1?*?Z.RO[NR/Y3O5W5O9W1_*=ZN^L[.^.Y#O5WUG9 +MWQW)=ZJ_L[*_.Y+O5']G97]W)-^I_L[*_NY(OE/]G97]W9%\I_H[*_N[(_E. +M]7=6]G='\IWJ[ZSL[T[\E."N[.].Y#O5WUG9WYW(=ZJ_L[*_.Y'O5']G97]W +M(M^I_L[*_NY$OE/]G97]W8E\I_H[*_N[$_E.]7=6]G]4?V=E?WKOK.SOSN0[ +MU=]9V=^=R7>JO[.ROSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9?*?Z.RO[ +MNPL_);@K^[L+^4[U=U;V=Q?RG>KOK.SO+N0[U=]9V=]=R'>JO[.RO[N0[U1_ +M9V5_=R'?J?[.RO[N0KY3_9V5_=V%?*?Z.RO[NPOY3O5W5O9W%_*=ZN^L[.\N +MY#O5WUG9WUW(=ZJ_L[*_NY#O5'_GRW?2W*K/@>^^/\7<>>KOEOOT5IT[\)VK +M_LY3?[>:N5LMW,6:GV+N//5WJYF[U>]M#GSGJK_SU-^MKNGL@NZ_<]7?>>KO +MVMGU.?"=J_[.4W\'<^`[5_V=I_X.YL!WKOH[3_W=,O>@SX'O7/5WGOJ[!\O< +MJLV![USU=Y[ZNPIOWMPO3D[\)VK +M_LY3?]?.KL^![USU=Y[Z.Y@#W[GJ[SSU=S`'OG/5WWGJ[Y:YAWV.?*?Z.T_] +MW<-EKG-'OE/]G:?^[N',W]BXH_OO7/5WGOJ[A]=\ +M=G3_G:O^SE-_U\ZNSY'O5'_GJ;^#.?*=ZN\\]7]3GR'>J +MO_/4WSU:YAIW=/^=J_[.4W_W:.;N4>>.?*?Z.T_]W:.9NT>=._*=ZN\\]7>/ +MKC=G1[Y3_9VG_JZ=79\CWZG^SE-_!W/D.]7?>>KO8(Y\I_H[3_W=,O>XSY'O +M5'_GJ;][O,QU[LAWJK_SU-\]GKE[W+BC^^]<]7>>^KO',W>/&W=T_YVK_LY3 +M?_?XFL^.[K]SU=]YZN_:V?4Y\IWJ[SSU=S!'OE/]G:?^#N;(=ZJ_\]3?+7-/ +M^ASY3O5WGOJ[)\M]4?^>IOUOF +MGO8Y\IWJ[SSU=T^7N>KOGE[SV=']=Z[Z.T_]73N[/D>^4_V=I_X.YLAWJK_SU-_!'/E.]7>> +M^KME[EF?(]^I_LY3?_=LF6O>^KMV=GV.?*?Z.T_]'KO +M//5WR]SS/D>^4_V=I_[N^3+7N2/?J?[.4W_W?.;N>>..[K]SU=]YZN^>S]P] +M;]S1_7>N^CM/_=WS:SX[NO_.57_GJ;]K9]?GR'>JO_/4W\$<^4[U=Y[Z.Y@C +MWZG^SE-_M\R]Z'/D.]7?>>KO7BQSC3NZ_\Y5?^>IOWLQ<_>B^4_V=I_[N +MQ]GGR'>JO_/4W[U-.[K_SE5_YZF_>WG-9T?WW[GJ[SSU=^WL^ASY3O5WGOH[F"/?J?[. +M4W\'<^0[U=]YZN^6N5=]CGRG^CM/_=VK9:YQ1_??N>KO//5WKV;N7G7NR'>J +MO_/4W[V:N7O5N2/?J?[.4W_WZGIS=N0[U=]YZN_:V?4Y\IWJ[SSU=S!'OE/] +MG:?^#N;(=ZJ_\]3?+7.O^QSY3O5WGOJ[U\MOK_GLZ/X[5_V=I_ZNG5V?(]^I_LY3?P=S +MY#O5WWGJ[V".?*?Z.T_]W3+WIL^1[U1_YZF_>[/,->[H_CM7_9VG_N[-S-V; +MSAWY3O5WGOJ[-S-W;SIWY#O5WWGJ[]Y<;\Z.?*?Z.T_]73N[/D>^4_V=I_X. +MYLAWJK_SU-_!'/E.]7>>^KME[FV?(]^I_LZK_B[H_CM7_9U7_5W0_7>N^CNO +M^KN@^^]<]7=>]7=!]]^YZN^\ZN^"[K]SU=]YU=\%W7_GJK_SJK\+NO_.57_G +MHK][U^?(=ZJ_\]3?O5OF&G=T_YVK_LY3?_=NYNY=YXY\I_H[3_W=NYF[=YT[ +M\IWJ[SSU=^^N-V='OE/]G:?^KIU=GR/?J?[.4W\'<^0[U=]YZN]@CGRG^KM8 +MOI/FUGT.?!>JO_O^$_>X6_RT[MR![T+U=Y'ZN_6\MV[N9N +MW;BC^^]"]7>1^KOU-9\=W7\7JK^+U-^UL^MSX+M0_5VD_@[FP'>A^KM(_1W, +M@>]"]7>1^KMESOH<^"Y4?Q>IO[-EKG%']]^%ZN\B]7.?*?ZNTC]G<_<>>..[K\+U=]%ZN]\ +MYLX;=W3_7:C^+E)_Y]=\=G3_7:C^+E)_U\ZNSY'O5'\7J;^#.?*=ZN\B]7

JOXO4W\7,773NR'>JOXO4W\7, +M773NR'>JOXO4W\7UYNS(=ZJ_B]3?M;/K<^0[U=]%ZN]@CGRG^KM(_1W,D>]4 +M?Q>IOUOFACY'OE/]7:3^;ECF.G?D.]7?1>KOAIF[H7%']]^%ZN\B]7?#S-W0 +MN*/[[T+U=Y'ZN^&:SX[NOPO5WT7J[]K9]3GRG>KO(O5W,$>^4_U=I/X.YLAW +MJK^+U-\M1^KOM-9\=W7\7JK^+U-^UL^MSY#O5WT7J[V".?*?ZNTC]'Y(]^I_BY2?[>; +MN=MU[LAWJK^+U-_MKC=G1[Y3_5VD_JZ=79\CWZG^+E)_!W/D.]7?1>KO8(Y\ +MI_J[2/W=,C?V.?*=ZN\B]7?C,M>Y(]^I_BY2?S?.W(V-.[K_+E1_%ZF_&V?N +MQL8=W7\7JK^+U-^-UWQV=/]=J/XN4G_7SJ[/D>]4?Q>IOX,Y\IWJ[R+U=S!' +MOE/]7:3^;IF;^ASY3O5WD?J[:9EKW-']=Z'ZNTC]W31S-W7NR'>JOXO4WTTS +M=U/GCGRG^KM(_=UTO3D[\IWJ[R+U=^WL^ASY3O5WD?H[F"/?J?XN4G\'<^0[ +MU=]%ZN^6N?=]CGRG^KM(_=W[9:YS1[Y3_5VD_N[]S-W[QAW=?Q>JOXO4W[V? +MN7O?N*/[[T+U=Y'ZN_?7?'9T_UVH_BY2?]?.KL^1[U1_%ZF_@SGRG>KO(O5W +M,$>^4_U=I/YNF?O0Y\AWJK^+U-]]6.8:=W3_7:C^+E)_]V'F[D/GCGRG^KM( +M_=V'F;L/G3ORG>KO(O5W'ZXW9T>^4_U=I/ZNG5V?(]^I_BY2?P=SY#O5WT7J +M[V".?*?ZNTC]W3+WL<^1[U1_%ZF_^[C,=>[(=ZJ_B]3??9RY^]BXH_OO0O5W +MD?J[CS-W'QMW=/]=J/XN4G_W\9K/CNZ_"]7?1>KOVMGU.?*=ZN\B]7JOXO4WRUSG_H<^4[U=Y'ZNT_+7...[K\+U=]%ZN\^S=Q]ZMR1 +M[U1_%ZF_^S1S]ZES1[Y3_5VD_N[3]>;LR'>JOXO4W[6SZW/D.]7?1>KO8(Y\ +MI_J[2/T=S)'O5'\7J;];YC[W.?*=ZN\B]7>?E[G.'?E.]7>1^KO/,W>?&W=T +M_UVH_BY2?_=YYNYSXX[NOPO5WT7J[SY?\]G1_7>A^KM(_5T[NSY'OE/]7:3^ +M#N;(=ZJ_B]3?P1SY3O5WD?J[9>Y+GR/?J?XN4G_W99EKW-']=Z'ZNTC]W9>9 +MNR^=._*=ZN\B]7=?9NZ^=.[(=ZJ_B]3??;G>G!WY3O5WD?J[=G9]CGRG^KM( +M_1W,D>]4?Q>IOX,Y\IWJ[X;E.VGN:Y\#WPVJOQM2?_=UF>O<@>^^/\7<#:F_ +M^SIS]W7A;ECS4\S=D/J[KS-W7W]O<^"[0?5W[6.9R[WQ0/??]:>*N3O?OOWV +M\L?@YL?;'7RUWL._]4]\^\?;^_^TP1]7_?P+@]]_HUTN-X/+&][\N.KG^R_X +M_K'?S-_Y_K&V.V_XCZ]1;/H-/WA[9XZ^E/)?.3^ZG>=7@YO-:K^_&?R?Y?7Y +MW_WI^/'7P3>[U;!9;;:KT?_L&_Z___C?](9_SM&7C_^WSN_G7(ES>\'V9^9^ +M_/%]YU?>)4/_Q+>.R=L[]^!MZ*^#]Q?QAZ_.]!/RU=&7C_\K[-W\E>N[G^<_[TBV/TPRQ]_BNWA +AW_HGOOWS[?U_?@X.\^#?=H+#>OS^*G_[?V9WPD*PIP`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-mbr.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-mbr.qcow2.gz.uu new file mode 100644 index 000000000000..0b7d7dbb85df --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-mbr.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-1x1-512-mbr.qcow2.gz +M'XL(")<[(U0``VEM9RTQ>#$M-3$R+6UB*VD]:3:M-5R1Q($0M=%P91*'0M16P^V2."=$[37<(8GS +M0E2EX&Q"E1J7"U%6PT$2MQ:B4,.Y)*X0HC3O;-J[C1"E>6?3WI5"E.:=37NW +M%:(T[VS:NYT0I7EGT][MA2C-.U"\,Q%W$*(T[X!YMR3/2?< +MBPYGI2C-.V#>O23<3<0)]0XT[X!Y]XIPKR-.J'>@>0?,NS>$NXTXH=Z!YATP +M[]X2[EW$"?4.-.^`>?=^Y)T5ZAUHWB'S[@.QLH@3ZAUJWB'SSA(.(DZH=ZAY +MA\P[))R+.*'>H>8=,N\\X?*($^H=:MXA\VY-N"+BA'J'FG?(O-L0[F/$"?4. +M->^0>?>)<)\C3JAWJ'F'S+LOA+N+.*'>H>:=8]Y])=RWB!/JG=.\<\R[[X2[ +MCSBAWCG-.\>\>R#<8X<#*:KS+LOD1KBGT9Z%>>\_7;P_ML)1[Y@`%I<`IS(, +MN,VL`_9AP(T&I7#4.X[WJ^&W`[:;[0)@/3]5-0+2@'W8;/4)=2L]_:A;F"\: +MGNU=T84!+U<]W'[F^6OWQP5`[TU9CH!_3OG!W,OA&J!?-YO,YZ:`F7TS]([AO=XRXB;?#C2//`>I0\W.S^R> +M*UA+C-1;Q[V&:KV"Y`8KAFB-M. +MKNUT=LMQ=KN9%\/SG7'FSFT@PYT;<#!O(8"VLM0&UF>-CWK'\==J^`U`1\#9 +09M#ES:5H\1\W+X2OTA0````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-mbr.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-mbr.raw.gz.uu new file mode 100644 index 000000000000..494fe712eb74 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-mbr.raw.gz.uu @@ -0,0 +1,11 @@ +# $FreeBSD$ +begin 644 img-1x1-512-mbr.raw.gz +M'XL(".G%'50``VEM9RTQ>#$M-3$R+6UBX<\J +M[;[:5Q^:?FX#U@AMFP$5`P77,(X7L#G;3=A00Q#.'YM&(-W-Q<"KL>U4A'L- +MNW*;=\0X);@^W'8;T%IP+@/>>GU4.ATF`.T1C`7[!S6M#?AQN4\"%IPN=7Z" +MHU^X0;!>@SN$7='*^&;,._QX3>3?X\R2.D;@_Z9@;>&[9^K)OCC/@%PE#6#= +M^2@%#OF%4=\IET%)N`OZ(`_7!=PQ7:\C'/T(%U+<$;R*OR<=[AKRKM`C0=L-@)&@K`Z@UK>@7\E`8````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-mbr.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-mbr.vhd.gz.uu new file mode 100644 index 000000000000..69446fd3e64d --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-mbr.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-512-mbr.vhd.gz +M'XL(".K%'50``VEM9RTQ>#$M-3$R+6UBH!P_\>!-(0@($BZ:E%";9AW<_LDT9&UX` +ME`&U0`V0U->Y`#I`7@"H07-@?^;F%KKZ[;6IOYZ_]^;5[0889[Y5:*[M,0.A +M'I(#EOHA]*BOH;.8_>GET]GSRY/%H<'9!PL"@2`51,R>0\RITZ2K\YN+'ODP +MJLOFZD8K]:D$,`&<>S,RJ^[!:70XH:S:MC]R*,M>ICV"FV!@=':"DVQBYAIWQ-<0NE\J_H46@GS(4*`I-V`'OWP^B- +M*/#U$6_*K'Q/FMVFU`*77'F`)OK;XZ=3H:#92Y[KZ2H,!C';Z_O%M: +M;DUD]?ZQ637X&\X)YL?@,M-*[4R_,N(#W5@FP[?%B35U>@DWFYR5B6NO*29V +M?IZ!J552`RN\)N,!77YAU'>8R\#`W15],'>WU+@\G,\]'/[B+H2X:C6WZ^I. +MYNKJQ,EHIROCR)6K(>'*'7"8MA%@WUE4!:I9\W-\H+O>A^\!B.:7(]E/$9K> +METRA,,!D"H5MIND49FRUV+96(1F%B?;U%&_W?]G7D]?N$^SKR;;[F!7;M*\G +>T^X3[>O)MOLT^WJ-2[JO)_6/C;'=#W^X!V4,#@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-mbr.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-mbr.vhdf.gz.uu new file mode 100644 index 000000000000..b9c8a97c9d63 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-mbr.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-1x1-512-mbr.vhdf.gz +M'XL(".K%'50``VEM9RTQ>#$M-3$R+6UB[VJPZ&B\?`^8,FB8`)@IH<)7"J0[*"MDWE#$.6KBZE'$& +MR/NV,6B3\5@G#NXXC`IMWN'B$H.SX3:/`:6$H@B`[U8?QDZ'T$"9@9`@"7*\ +M-^#/_<;/X/`6;A#,[\&E>I33TZV,>4<[EHEY6IQ84J<0K'XH6!FY +M]D0^&>?F&9A:)16PO/>A#QSR"Z.^;2@#O7`7]$$8;J%QF=^?.SB\$2[XN'(Q +MM\OJUJ&Z*G(RY'1EW+ER-<1?N0:'<3<"['8658&J5WB?=[2OB7\:H.B!T6:0 +M^E\1I4`-4`TD=3L30%O((?B6UU?=77?VU/F_/E9'%VJ[(?%J0G72J(",(E/]R7W=MSASR,ZM)PDLB=O5(` +M$\"Y%WBO[N"7,W7[O`VV;J"4G4QKWHOGN+I5:9QDDU'_S:W!4>124;6W^@.> +'9*U,OP@````` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-mbr.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-mbr.vmdk.gz.uu new file mode 100644 index 000000000000..24643628ba1f --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-mbr.vmdk.gz.uu @@ -0,0 +1,82 @@ +# $FreeBSD$ +begin 644 img-1x1-512-mbr.vmdk.gz +M'XL(".K%'50``VEM9RTQ>#$M-3$R+6UBO +MH*67(`\+UI)?&T<(]SPR>N?[_[ +MQX\G_OG#Z73]:@6#SY(4Y`HGB\WK7$_/_A#N_*6LS1/N<4["%3ZKOTD,<.>= +M)W;A2O?D^7,IW%VW/#WZ&X'+(E"V@:L^4]-NL5_:W1^_"LWS^RO\'MSQ7MJL +M+K)+'Y;9I5K615:?E^?RK'9!LP-\G=W=?_I/=C=]&A[N/SY^"/L[^[-UP>7% +MQU\&C^`*JR_^QC_AX5H/<9FR8LP*^*>SZ\-?[W^>3O^='C[=?WC_!BSW[,^V +M++*R]=OQ\?G38[/P+Y)G%_C7R*Y_^=O=F_#.S4\?NP?"^2RW$??:K@[%O5PR +M_W7[6'8WO7_TB'/X$W?GSS8TIUI>N_0W59G5;;9LI_+89_?T&$I>>C<\3-WC +M],.O'Z[B>^<.L`G[6JMV*9?=DW7;OG[[OT=7;S:&D[TGW+*)I0CW +MVM4YJVJ/Y0YP.8IS5I3^SOV3V["KI(0/RJX?WI^^_\E]B_MFO?WNS]\3KG%9 +M+M)MT*6X@C8U56O]U?.W979]^VWVRA?YP[MI>0<2KEV_S7SP>@Y8EF=_$[JV +MPGL2*_T3R\EF=]UCEWW3?9I.K^_NOHDGV_EBR^7AMC9YE,L*[=_?2SM=X]:3 +M7@]Z.8IQ[$_=V'U\G![\\<:CZ'V+QE"I/];RZ1BWKU,O)S7[=TQV?9.]NA_= +MF7K8?T\??B'II/A^D.T.WPLQMTO7NUG&K<'N$FO[OQ9H/+>89&QDW% +ME\VNORS;>S=UH]N:PR;<['=W_OP^0J>>O91#SZY/75MP/P6X(@\44`0JV[0H +M;F=]02'0:7C\\+!N[)7P??XJP;D?A^.OPLPLM"L4A;5!FZO=U7H'2-KS6IDT6[@]GIW";UC +M9*]9@RS&0\76H7>,G#7+7_BK%/(#OY9=FM`[1A::5[ +M,?2.D;5F-;)H-W![O9M"[QC9:]8@B_%0L7/H'2-GS?*74GI7IN#J//2.D85F +ME;*H-G`[O:O)=XRL-:N11;N!V^E=3;YC9*]9@RS&0\62[Q@Y:Y:_5-*[*@E' +MOF-DH5FE+*H-W%[OR'>,K#6KD46[@=OK'?F.D;UF#;(8#Q5+OF/DK%G^ +M79)PY#M&%II5RJ+:P.WUCGS'R%JS&EFT&[B]WI'O&-EKUB"+\5"QY#M&SIKE +M+_PE"'*_#T>^8V2A6:4LJ@W<7N_(=XRL-:N11;N!V^L=^8Z1O68-LA@/%4N^ +M8^2L6?Y"009ROPO7Y*%WC"PTJY1%M8';Z5U#OF-DK5F-+-H-W$[O&O(=(WO- +M&F0Q'BJ6?,?(6;/\I97>M4DX\ATC"\TJ95%MX/9Z1[YC9*U9C2S:#=Q>[\AW +MC.PU:Y#%>*A8\ATC9\WR%_[_$^1^'XY\Q\A"LTI95!NXO=Z1[QA9:U8CBW8# +MM]<[\ATC>\T:9#$>*I9\Q\A9L_R%^B/D?A^.?,?(0K-*650;N+W>D>\866M6 +M(XMV`[?7._(=(WO-&F0Q'BJ6?,?(6;/\99#>#2FX-@^]8V2A6:4LJ@W<3N]: +M\ATC:\UJ9-%NX'9ZUY+O&-EKUB"+\5"QY#M&SIKE+Z/T;DS"D>\866A6*8MJ +M`[?7._(=(VO-:F31;N#V>D>^8V2O68,LQD/%DN\8.6N6OTS2NRD)1[YC9*%9 +MI2RJ#=Q>[\AWC*PUJY%%NX';ZQWYCI&]9@VR&`\52[YCY*Q9_C)+[^8D'/F. +MD85FE;*H-G![O2/?,;+6K$86[09NKW?D.T;VFC7(8CQ4+/F.D;-FY3(]@]SO +MPG7YVKL866A6*8MJ`[?3NR[P78RL-:N11;N!V^E=%_@N1O::-D?M<%OH/H=U#] +M#J+?'2@V\!U$OX/J=Q#]#DE)JPM\!]'OH/H=1+]#4K_K`M]!]#NH?@?1[Y#4 +M[[K`=Q#]#JK?0?2[`\4&OH/H=U#]#J+?(2EI=8'O(/H=5+^#Z'=(ZG==X#N( +M?@?5[R#Z'9+Z71?X#J+?0?4[B'YWH-C`=Q#]#JK?0?0[)"6M/@^]$_T.JM]! +M]#LD];N>?"?Z'52_@^AW2.IW/?E.]#NH?@?1[PX42[X3_0ZJWT'T.R0EK9Y\ +M)_H=5+^#Z'=(ZG<]^4[T.ZA^!]'OD-3O>O*=Z'=0_0ZBWQTHEGPG^AU4OX/H +M=TA*6CWY3O0[J'X'T>^0U.]Z\IWH=U#]#J+?(:G?]>0[T>^@^AU$OSM0+/E. +M]#NH?@?1[Y"4M'KRG>AW4/T.HM\AJ=_UY#O1[Z#Z'42_0U*_Z\EWHM]!]3N( +M?G>@6/*=Z'=0_0ZBWR$I:0UYZ)WH=U#]#J+?(:G?#>0[T>^@^AU$OT-2OQO( +M=Z+?0?4[B'YWH%CRG>AW4/T.HM\A*6D-Y#O1[Z#Z'42_0U*_&\AWHM]!]3N( +M?H>D?C>0[T2_@^IW$/WN0+'D.]'OH/H=1+]#4M(:R'>BWT'U.XA^AZ1^-Y#O +M1+^#ZG<0_0Y)_6X@WXE^!]7O(/K=@6+)=Z+?0?4[B'Z'I*0UD.]$OX/J=Q#] +M#DG];B#?B7X'U>\@^AV2^MU`OA/]#JK?0?2[`\62[T2_@^IW$/T.24EKS$/O +M1+^#ZG<0_0Y)_6XDWXE^!]7O(/H=DOK=2+X3_0ZJWT'TNP/%DN]$OX/J=Q#] +M#DE):R3?B7X'U>\@^AV2^MU(OA/]#JK?0?0[)/6[D7PG^AU4OX/H=P>*)=^) +M?@?5[R#Z'9*2UDB^$_T.JM]!]#LD];N1?"?Z'52_@^AW2.IW(_E.]#NH?@?1 +M[PX42[X3_0ZJWT'T.R0EK9%\)_H=5+^#Z'=(ZG)%_$7&^ +MS<>+_(N(\VT3_R+B?-O$OX@XWS;Q+R+.MTW\BXCS;1/_(N)\V\2_B#C?-O$O +M(LZW3?R+B/-M$_\BXGS;Q+^(.-\V\2\BSK=-_(N(\VT3_R+B?-O$OX@XWS;Q +M+R+.MTW\BXCS;1/_(N)\V\2_B#C?-O$O(LZW3?R+B/-M$_\BXGS;Q+^(.-\V +M\2\BSK=-_(N(\VT3_R+B?-O$OX@XWS;Q+R+.MTW\B^!\V\:_",ZW;?R+X'S; +MQK\(SK=M_(O@?-O&OPC.MVW\B^!\V\:_",ZW;?R+X'S;QK\(SK=M_(O@?-O& +MOPC.MVW\B^!\V\:_",ZW;?R+X'S;QK\(SK=M_(O@?-O&OPC.MVW\B^!\V\:_ +M",ZW;?R+X'S;QK\(SK=M_(O@?-O&OPC.MVW\B^!\V\:_",ZW;?R+X'S;QK\( +MSK=M_(O@?-O&OPC.MVW\B^!\V\:_",ZW;?R+B/-M1K[(OX@XWV;DB_R+B/-M +M1K[(OX@XWV;DB_R+B/-M$_\BXGS;Q+^(.-\V\2\BSK=-_(N(\VT3_R+B?-O$ +MOX@XWS;Q+R+.MTW\BXCS;1/_(N)\V\2_B#C?-O$O(LZW3?R+B/-M$_\BXGS; +MQ+^(.-\V\2\BSK=-_(N(\VT3_R+B?-O$OX@XWS;Q+R+.MTW\BXCS;1/_(N)\ +MV\2_B#C?-O$O(LZW3?R+B/-M$_\BXGS;Q+^(.-\V\2\BSK=-_(O@?-O&OXC) +MU+^(R=2_B,G4OXC)U+^(R=2_B,G4OXC)U+^(R=2_B,G4OXC)U+^(R=2_B,G4 +MOXC)U+^(R=2_B,G4OX@YSPW]BYA-_8N83?V+F$W]BYA-_8N83?V+F$W]BYA- +M_8N83?V+F$W]BYA-_8N83?V+F$W]BYA-_8N83?V+F$W]B^<\SPW]B^>;SQ+> +M9.W#W1:[^@/+97_KIX/>_KW_Q/6;T_:_"(C^MP&Z\Y[G&T`67,*_]UR`>W15 +MN'&/U9DF!X']@K\^"=QHW#_,OPVPJK*NNP'\)_=WMCZ.Y?,UJ]I_[FQUR9KS +MT8)_^O;'9P6O<&;OOQ7NYK.LG\/%#1_X:.RR7#[+6B+UG;'_Q/7I;;)>"5=^ +M:77=?W^YN,#Z,ZOEWQL'O7`^R_QY5_]']#X]&&`7P`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-pc98.qcow.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-pc98.qcow.gz.uu new file mode 100644 index 000000000000..5a36a47ff1bb --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-pc98.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-1x1-512-pc98.qcow.gz +M'XL("*8S(E0``VEM9RTQ>#$M-3$R+7!C.3@N<6-O=RYO=70`K9W+CAQ'DD7W +M^HKD^TV6F45F1O"-!KJ!V?4L9F:K?*[S`_CQ0U9%N+,LSZ6Q(5$%@40I+C*] +M#@\AZ<#KYN;NQVJUMM6P60W3ZKQ???_U_&&KGWYQ_V/U[;__]5]O?_[Q[8^[ +M,;OYQ5/IUX.OAGGNWM8_OK8Y__'4874S_<;<]P^CN9]>7?P'K^ZG-WL]]_*/ +MNS?+S[D:C'N#JWGN9GY])DYO^+W7]S6]7;L[O;_O[;IXNVLUN+DW^.]Y[L_Y +M];EXNULU-]Z;NZ2WZ^+M3FIN]TM87,"R5W.'8F[`IXYJ[E3,K?&I,\_9+[ZV +M=W,;?,K4G./AN(N*.R/? +MA>(N2N[(=Z&XBY([\ETH[J+DCGP7BKLHN2/?A>(N2N[(=Z&XBY([\ETH[H:2 +M._+=H+@;2N[(=X/B;JBX]&Q=U8<3?P4X*[L>)N(-^- +MBKNQXFX@WXV*N['B;B#?C8J[L>)N(-^-BKNQXFX@WXV*N^4_?^LY\MVDN)LJ +M[@;RW:2XFTKNR'>3XFXJN2/?38J[J>2.?#XVY7]VBKM=Q=V:GQ+<[2KNUN2[G>)N5W&W)M_M%'>[ +MBKLU^6ZGN-M5W*W)=SO%W:[B;DV^VRGNEO\-J>?(=WO%W;[B;DV^VRON]B5W +MY+N]XFY?^VRON]B5WY+N]XFY?^VRON]B5WY+N]XFY?^VRON#B5W +MY+N#XNY0^.RCN#A5W&WY*<'>HN-N0[PZ*NT/%W89\=U#<'2KN-N2[@^+N +M4'&W(=\=%'>'BKL-^>Z@N#M6W&W(=T?%W;'B;D.^.RKNCB5WY+NCXNY8^ +M.RKNCB5WY+NCXNY8^.RKNCB5WY+NCXNY8^.RKN3B5WY+N3XNY4^ +M.RGN3A5W6WY*<'>JN-N2[TZ*NU/%W99\=U+G +MBKLM^>ZDN#M7W&W)=V?%W;GB;DN^.RONSB5WY+NSXNY<^.RONSB5WY+NS +MXNY<^.RONSB5WY+NSXNY<^.PON;/F)G@/?V8W@SFY*[L!W=B.XLYN* +MNY&?8NZL[.]&\)VI_L[*_FX$WYGJ[ZSL[T;PG:G^SLK^;@3?F>KOK.SO1O"= +MJ?[.ROYN!-^9ZN^L[.]&\)VI_L[*_FX$WYGJ[ZSL[T;PG:G^SLK^;@3?F>KO +MK.SO1O"=J?[.ROYN!-^9ZN^L[.]&\)VI_L[*_FXDWZG^SLK^;B3?J?[.ROYN +MXJ<$=V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E +M?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4 +M?V=E?S>1[U1_9V5_-Y'O5']G97\WD>]4?V=E?S>1[U1_9V5_M^.G!'=E?[^4_V=E?W=CGRG^CLK^[L=^4[U=U;V=SORG>KOK.SO=N0[U=]9 +MV=_MR'>JO[.RO]N1[U1_9V5_MR/?J?[.ROYN1[Y3_9V5_=V.?*?Z.RO[NQWY +M3O5W5O9W._*=ZN^L[.]VY#O5WUG9W^W(=ZJ_L[*_V_-3@KNRO]N3[U1_9V5_ +MMR??J?[.ROYN3[Y3_9V5_=V>?*?Z.RO[NSWY3O5W5O9W>_*=ZN^L[._VY#O5 +MWUG9W^W)=ZJ_L[*_VY/O5']G97^W)]^I_L[*_FY/OE/]G97]W9Y\I_H[*_N[ +M/?E.]7=6]G=[\IWJ[ZSL[_;D.]7?6=G?'?@IP5W9WQW(=ZJ_L[*_.Y#O5']G +M97]W(-^I_L[*_NY`OE/]G97]W8%\I_H[*_N[`_E.]7=6]G<'\IWJ[ZSL[P[D +M.]7?6=G?'KOK.SOCOR4X*[L[X[D.]7?6=G?'KOK.SO +MCN0[U=]9V=\=R7>JO[.ROSN2[U1_9V5_=R3?J?[.RO[N2+Y3_9V5_=V1?*?Z +M.RO[NR/Y3O5W5O9W)WY*<%?V=R?RG>KOK.SO3N0[U=]9V=^=R'>JO[.ROSN1 +M[U1_9V5_=R+?J?[.RO[N1+Y3_9V5_=V)?*?Z.RO[NQ/Y3O5W5O9W)_*=ZN^L +M[.].Y#O5WUG9WYW(=ZJ_L[*_.Y'O5']G97]W(M^I_L[*_NY$OE/]G97]W8E\ +MI_H[*_N[,S\EN"O[NS/Y3O5W5O9W9_*=ZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_ +M.Y/O5']G97]W)M^I_L[*_NY,OE/]G97]W9E\I_H[*_N[,_E.]7=6]G=G\IWJ +M[ZSL[\[D.]7?6=G?GK/]L<^,Y5?^>IOUM=TMD%W7_G +MJK_SU-^UL^MSX#M7_9VG_@[FP'>N^CM/_1W,@>]<]7>>^KME[D&?`]^YZN\\ +M]7KO//5W#V;N'G3NP'>N^CM/_=V#F;L'G3OPG:O^SE-_]^!R +M=7;@.U?]G:?^KIU=GP/?N>KO//5W,`>^<]7?>>KO8`Y\YZJ_\]3?+7,/^QSY +M3O5WGOJ[A\M[3,->[H_CM7_9VG_N[1S-VCSAWY3O5WGOJ[1S-WCSIWY#O5 +MWWGJ[QY=KLZ.?*?Z.T_]73N[/D>^4_V=I_X.YLAWJK_SU-_!'/E.]7>>^KME +M[G&?(]^I_LY3?_=XF>O]4?^>IOWL\<_>X<4?WW[GJ[SSU=X]G[AXW[NC^ +M.U?]G:?^[O$EGQW=?^>JO_/4W[6SZW/D.]7?>>KO8(Y\I_H[3_T=S)'O5'_G +MJ;];YI[T.?*=ZN\\]7=/EKG&'=U_YZJ_\]3?/9FY>]*Y(]^I_LY3?_=DYNY) +MYXY\I_H[3_W=D\O5V9'O5'_GJ;]K9]?GR'>JO_/4W\$<^4[U=Y[Z.Y@CWZG^ +MSE-_M\P][7/D.]7?>>KOGBYSG3ORG>KO//5W3V?NGC;NZ/X[5_V=I_[NZ2SH_OO7/5WGOJ[=G9]CGRG^CM/_1W,D>]4?^>IOX,Y +M\IWJ[SSU=\O>^KMG,W?/.G?D.]7?>>KO +MGLWO]4?^>IOWMVN3H[\IWJ[SSU=^WL^ASY3O5WGOH[F"/?J?[.4W\' +M<^0[U=]YZN^6N>=]CGRG^CM/_=WS9:YS1[Y3_9VG_N[YS-WSQAW=?^>JO_/4 +MWSV?N7O>N*/[[USU=Y[ZN^>7?'9T_YVK_LY3?]?.KL^1[U1_YZF_@SGRG>KO +M//5W,$>^4_V=I_YNF7O1Y\AWJK_SU-^]6.8:=W3_G:O^SE-_]V+F[D7GCGRG +M^CM/_=V+F;L7G3ORG>KO//5W+RY79T>^4_V=I_ZNG5V?(]^I_LY3?P=SY#O5 +MWWGJ[V".?*?Z.T_]W3+WLL^1[U1_YZF_>[G,=>[(=ZJ_\]3?O9RY>]FXH_OO +M7/5WGOJ[ES-W+QMW=/^=J_[.4W_W\I+/CNZ_<]7?>>KOVMGU.?*=ZN\\]7

JO_/4WRUSK_H<^4[U=Y[ZNU?+7...[K]SU=]YZN]>S=R] +MZMR1[U1_YZF_>S5S]ZIS1[Y3_9VG_N[5Y>KLR'>JO_/4W[6SZW/D.]7?>>KO +M8(Y\I_H[3_T=S)'O5'_GJ;];YE[W.?*=ZN\\]7>OE[G.'?E.]7>>^KO7,W>O +M&W=T_YVK_LY3?_=ZYNYUXX[NOW/5WWGJ[UY?\MG1_7>N^CM/_5T[NSY'OE/] +MG:?^#N;(=ZJ_\]3?P1SY3O5WGOJ[9>Y-GR/?J?[.4W_W9IEKW-']=Z[Z.T_] +MW9N9NS>=._*=ZN\\]7=O9N[>=.[(=ZJ_\]3?O;E]4?^>IOX,Y\IWJ[SSU=\OJO_.JOPNZ_\Y5?^=5?Q=T +M_YVK_LY%?_>NSY'O5'_GJ;][M\PU[NC^.U?]G:?^[MW,W;O.'?E.]7>>^KMW +M,W?O.G?D.]7?>>KOWEVNSHY\I_H[3_U=.[L^1[Y3_9VG_@[FR'>JO_/4W\$< +M^4[U=['\),W=]#GP7:C^[OLG[G&W^.FF

^"]7?1>KO;N:]F\8=W7\7JK^+ +MU-_=S-S=-.[H_KM0_5VD_N[FDL^.[K\+U=]%ZN_:V?4Y\%VH_BY2?P=SX+M0 +M_5VD_@[FP'>A^KM(_=TR9WT.?!>JOXO4W]DRU[BC^^]"]7>1^CN;7YYU[L!W +MH?J[2/V=S=Q9YPY\%ZJ_B]3?V>7J[,!WH?J[2/U=.[L^![X+U=]%ZN]@#GP7 +MJK^+U-_!'/@N5'\7J;];YKS/D>]4?Q>IO_-EKG-'OE/]7:3^SF?NO'%']]^% +MZN\B]7<^<^>-.[K_+E1_%ZF_\TL^.[K_+E1_%ZF_:V?7Y\AWJK^+U-_!'/E. +M]7>1^CN8(]^I_BY2?[?,19\CWZG^+E)_%\MKOVMGU.?*=ZN\B]7JOXO4WRUS0Y\CWZG^+E)_-RQSG3ORG>KO(O5WP\S=T+BC^^]"]7>1 +M^KMAYFYHW-']=Z'ZNTC]W7#)9T?WWX7J[R+U=^WL^ASY3O5WD?H[F"/?J?XN +M4G\'<^0[U=]%ZN^6N76?(]^I_BY2?[=>YAIW=/]=J/XN4G^WGKE;=^[(=ZJ_ +MB]3?K6?NUIT[\IWJ[R+U=^O+U=F1[U1_%ZF_:V?7Y\AWJK^+U-_!'/E.]7>1 +M^CN8(]^I_BY2?[?,;?H<^4[U=Y'ZN\TRU[DCWZG^+E)_MYFYVS3NZ/Z[4/U= +MI/YN,W.W:=S1_7>A^KM(_=WFDL^.[K\+U=]%ZN_:V?4Y\IWJ[R+U=S!'OE/] +M7:3^#N;(=ZJ_B]3?+7/;/D>^4_U=I/YNN\PU[NC^NU#]7:3^;CMSM^W]4 +M?Q>IO]O.W&T[=^0[U=]%ZN^VEZNS(]^I_BY2?]?.KL^1[U1_%ZF_@SGRG>KO +M(O5W,$>^4_U=I/YNF1O['/E.]7>1^KMQF>O]4?Q>IOQMG[L;&'=U_%ZJ_ +MB]3?C3-W8^..[K\+U=]%ZN_&2SX[NO\N5'\7J;]K9]?GR'>JOXO4W\$<^4[U +M=Y'Z.Y@CWZG^+E)_M\Q-?8Y\I_J[2/W=M,PU[NC^NU#]7:3^;IJYFSIWY#O5 +MWT7J[Z:9NZES1[Y3_5VD_FZZ7)T=^4[U=Y'ZNW9V?8Y\I_J[2/T=S)'O5'\7 +MJ;^#.?*=ZN\B]7?+W/L^1[Y3_5VD_N[],M>Y(]^I_BY2?_=^YNY]XX[NOPO5 +MWT7J[][/W+UOW-']=Z'ZNTC]W?M+/CNZ_RY4?Q>IOVMGU^?(=ZJ_B]3?P1SY +M3O5WD?H[F"/?J?XN4G^WS'WH<^0[U=]%ZN\^+'.-.[K_+E1_%ZF_^S!S]Z%S +M1[Y3_5VD_N[#S-V'SAWY3O5WD?J[#Y>KLR/?J?XN4G_7SJ[/D>]4?Q>IOX,Y +M\IWJ[R+U=S!'OE/]7:3^;IG[V.?(=ZJ_B]3??5SF.G?D.]7?1>KO/L[,EG1_??A>KO(O5W[>SZ'/E.]7>1 +M^CN8(]^I_BY2?P=SY#O5WT7J[Y:Y3WV.?*?ZNTC]W:=EKG%']]^%ZN\B]7>? +M9NX^=>[(=ZJ_B]3??9JY^]2Y(]^I_BY2?_?IKO +M(O5W,$>^4_U=I/X.YLAWJK^+U-\M1^KO/RUSGCGRG^KM(_=WG +MF;O/C3NZ_RY4?Q>IO_L\<_>Y<4?WWX7J[R+U=Y\O^>SH_KM0_5VD_JZ=79\C +MWZG^+E)_!W/D.]7?1>KO8(Y\I_J[2/W=,O>ESY'O5'\7J;_[LLPU[NC^NU#] +M7:3^[LO,W9?.'?E.]7>1^KLO,W=?.G?D.]7?1>KOOERNSHY\I_J[2/U=.[L^ +M1[Y3_5VD_@[FR'>JOXO4W\$<^4[U=\/RDS3WM<^![P;5WPVIO_NZS'7NP'?? +MGV+NAM3??9VY^[IP-]SP4\S=D/J[KS-W7_]L<^"[0?5W0^KOOE[2V0UT_UW[ +MT)_X]C;]^/;'R]O!]>W;'7QULX._ZT]\^\?;^W^UP=OK:OZ#P?5ZM;L>_)_Y +M#:]OKZN9AM5AH/=U/O>/Z@W?S=&W/_\KYS?\S>>WO7W#Z^UJ6*_6F]7HO_L* +M_^^?_PMO>/OWO>&[N9*_]H+M=^9N_[S]Z9_\\>VF6T@I/W$W=W5QW9;NY^DO +MXH=@3O0)^>KH^[W_!5BV5W?@_/QUOOV.\=__Y7CY_Q_I(M'V]5WUUT=-^;VW +M^XO7M[I^N[=_IFWO__/VTYP7;W=U?V[_RZ_MKU_=@^M71]]3_:]\,:YN#$M-3$R+7!C.3@N<6-O=S(N;W5T`*V8VY+3,`R& +M[_L4+H<%%BBQ9*<)AP7VP`QW<`%\CNM5APH.'E-C4`X7S.JF!A3<'"BGZ\-4GTRM+5R5Q8&2JBW<)HM#);6U<+LL+BBI>PNW +MS^*BDCH8.)]1Y0%7*BEOX2"+6RLIM'`ABZN4E.6=SWM7*RG+.Y_W;J.D+.]\ +MWKNMDK*\\WGO=DK*\L[GO;M74I9W8'CG&+=74I9W(+Q;$NX9XPY*RO(.A'?/ +M"?>BPWDM97D'PKN7A+M@G-+OP/(.A'>O"/>:<4J_`\L[$-Z](=PEXY1^!Y9W +M(+Q[2[AWC%/Z'5C>@?#N_<@[K_0[L+Q#X=T'8A6,4_H=6MZA\,X3#ABG]#NT +MO$/A'1(N,$[I=VAYA\*[2+B2<4J_0\L[%-ZM"55=$-Y])=PWQBG]+EC>!>'==\)= +M,T[I=\'R+@CO;@AWV^%`2W7>%85^$.YN=,_"O,^?@9^/O7*V!R:`U5.`4Q4F +M7#WKA&.:<*/!1CG;`\?KU?#=`5MAG@",T6W&P#]IPC$)4P>W"]J\#@<^3KA^ +M<6YA8K,DLUX_:"<1KH"O:GX-KM?.^; +MOO]P9@X,'\Z6C)OUVQV(5VP7(3-<-<=O)M9VN;CFN;C?S8J"\,TZ\#$M-3$R+7!C.3@N> +M8MQV86`^^.X$D.07145-G`V +M+F7>/YP"BP9(@+A"BT<=ON^OC<"8+[#!X1YN-LR/X&J]:C53N44^XV*"P966 +M52XX2KE3"/8]%5;D/2R(K;=N76=@Z@P/P%JKH0N1\"FEYF=0+U&QF, +8<4$^*K<;(%E@MATDU,#B!\3RH'-%!@`` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-pc98.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-pc98.vhd.gz.uu new file mode 100644 index 000000000000..01016a55890e --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-pc98.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-1x1-512-pc98.vhd.gz +M'XL(".O%'50``VEM9RTQ>#$M-3$R+7!C.3@N=FAD+F]U=`"METUO@S`,AN_] +M%:YVZZ%*C!/:Z[3N/&G:=BUEM-IA'UI[Z($?OQ@22/A:NP4H"@I^\MIQ3"I$ +M?0#H!/0>=`%:<3LET&M(5P"FTUY8W:5]A#+__"CRT]MY:8]R5L.D\*U"<[;' +M!,@,D@)F/(A^Y3:4#K.\V1P6;^\'AT.+LKL$M9G8NZE0QB9&:NPF=A!2Y;=+&Q:%WF50Y'[^R[V/1T8CJT(]LP01#*=6#E?AB] +M%@6^/BW%1,S')V-47\;ZS-H2VL;TV0 +MTU#7Z+R/'#RF&5/FEC5O<32ECM=<<96S*FZR8+[JV/GS#,+D<`YBY54% +M#]C,+[3ZUGT9&+@[H0_Z[F:,2\/WI8?#7]R%$+>;G-MI=?.^NCSR9+QV5\:% +M*Y-9`M*4^VK<#;6V.II`L,)I"LM4Y +MHD(J)I/MVBS45F&DC3CC(F[$&1=Q(\ZXB!MQQD7#$M-3$R+7!C.3@N=FAD9BYO=70`K96Q;H,P$(;W +M/,5%W3)$^+`/6*.FO;4SP82!)9;"0T>&/__?9YR3I +M+@")D)03S_E`N]ORNUUM5I8FFON`2D$9`E\UT.+0Z"LD5!)T;]2@:8;&`NUV +M=/4XH8,AR(V:#4S@G%T9>?[0&E892`6*(,=;%;[OWR8,8SS#'0ZOX2Z"Q2VX +MU(SROM1J45QP@U7D.0NAAQX +MR2\,^HI0!C*["_H@M%L:7,:_%QX.K]@%CCLNYG99W3I45T5.1CK>&3?N7`/A +M.[?#8=Q"(&UEUBO0U,C@.1]HG[?\[H#2`:/-(+FS@U*@!J@&4J:?2:`"LMP' +M(E]);?7]55<_YU\_PP8G1A7=;V8\IF:W4`98FI_0A^E[^A[VI\WY\]3C^E+5 +M_UB2F72E(3*P2]SNT^[ET2(/@[HTG"3R9^^H3R@)0C#C3MV!+V>R^>W-U@T< +CE979-_;"`I.ERN!4,AKUW]QV.(J\5/2IMOH#34'Y,G`(```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-pc98.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-pc98.vmdk.gz.uu new file mode 100644 index 000000000000..7f13ae450062 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-pc98.vmdk.gz.uu @@ -0,0 +1,82 @@ +# $FreeBSD$ +begin 644 img-1x1-512-pc98.vmdk.gz +M'XL(".O%'50``VEM9RTQ>#$M-3$R+7!C.3@N=FUD:RYO=70`K5Q=;]S($7SW +MKZ!]+T$>%JSE]X.!Y"('"((`QOER]QI^YH25XNVNG>W9+D*),4R?Q/ZRU)LX?%?#O7?.#R]YM_ +M_'3BUQ].I\NK%0PN2U*0*IPL-L]S.3WZ(MSYN:S-`_/M'(7+7%9WE>CASCL/ +M[,+E\X/GIU*XNW9Y>'`7`I<$H&0#5SQ1TVZQS^WNCZ]\\]S^,K>'^7C+)JFR +MI.S\,BF+99TEU7EY+$VJ.6B:`;]+;FZ__B>Y&;_V=[=?[C_[_9W=V<[!>>GB +MR]XAS(55I;MP#SBXQD&48Y(-20;W<'*Y^^OMK^/IO^/=U]O/G]Z"Y9[=V>99 +MDC=N.RX^?;AM%NY)TJ2$>X[D\I>_W;SUK]ST]*6](YS+FC*^ +MKV_+[L9/]PYQ\E]A=^YL?7.*Y;ES=U'D2=4DRW8*AWV>'QY\R4OO^KNQO1]_ +M_/9E?/OFX^=/H7?N;%W+F@6H7AJ5)47FH'QIKGV%0W0OF^74DLNOM_>_W/8? +MYC*_CF].WR6$*UWOY@.L_;[6JN>4WN&O6A_=__H%P]9PU +M1\X;G%/F@C8U%6O]Q>.797+Y\"YYXXK\\9=Q>042KEG?9BYX/0Z!Y623F_:^3;YOOXZG[VYNO@\GV[IB\^4V;VUT*.4*[5[?2SOGQJTG +MO1[T!'_PSK*\8=DX,;[^^^G?IOO]Y^ +M&N8W6O*6<,/:NWD[ZVD^'.9\@/,.G]S@W+LWRZF&[1%N=+L;KC:XG*=O9-A4 +M>-KD\G'9WB]C.\Q;F[$)-[G=G9_>A^_4HZ>:T9/+0]<6W*\>+DL]!62>RC8M +M"MM9GU`(=.SO/]^M&WLC?)P]_EGV4C[.KWZD5K\3<(6SWE^9/OIYEFE>+HMB +M`^A^BJ7S]Y_F[_PTJY?%<*1[ +MI:.V42*GQ]WCKQJ0ZWTX_B[`R$RSED,AXJM?.\8.6F6N^.O4D@/_%I6UKYWC,PT*Y=%L8';ZUWC>\?(2K-J +M630;N+W>M;YWC.PTJY?%<*C8SO>.D9-FN3L2!.1Z'Z[WO6-DIEFY+(H-W%[O +M!M\[1E::5*)=\QD>\8V6E6+XOA4+'D +M.T9.FN7N*,A`KG?AZM3WCI&99N6R*#9P.[VKR7>,K#2KED6S@=OI74V^8V2G +M6;TLAD/%DN\8.6F6NVND=TT4CGS'R$RSIE,1PJEGS'R$FSW!W__P2YWHED,AXHEWS%RTBQW1_T1[\AWC*PT +MJY9%LX';ZQWYCI&=9O6R&`X52[YCY*19[JZ7WO4QN";UO6-DIEFY+(H-W$[O +M&O(=(RO-JF71;.!V>M>0[QC9:58OB^%0L>0[1DZ:Y>X&Z=T0A2/?,3+3K%P6 +MQ09NKW?D.T96FE7+HMG`[?6.?,?(3K-Z60R'BB7?,7+2+'[TCWS&RTJQ:%LT&;J]WY#M&=IK5RV(X5"SYCI&39KF[27HW1>'( +M=XS,-"N71;&!V^L=^8Z1E6;5LF@V<'N](]\QLM.L7A;#H6+)=XR<-"N5Z1GD +M>A>N3=?>A%L.A8CW? +MAY`L9[O(/H=5+^#Z'>(2EJMYSN(?@?5[R#Z':+Z7>OY#J+?0?4[B'Z' +MJ'[7>KZ#Z'=0_0ZBWQTHUO,=1+^#ZG<0_0Y12:OU?`?1[Z#Z'42_0U2_:SW? +M0?0[J'X'T>\0U>]:SW<0_0ZJWT'TNP/%>KZ#Z'=0_0ZBWR$J:76I[YWH=U#] +M#J+?(:K?=>0[T>^@^AU$OT-4O^O(=Z+?0?4[B'YWH%CRG>AW4/T.HM\A*FEU +MY#O1[Z#Z'42_0U2_Z\AWHM]!]3N(?H>H?M>1[T2_@^IW$/WN0+'D.]'OH/H= +M1+]#5-+JR'>BWT'U.XA^AZA^UY'O1+^#ZG<0_0Y1_:XCWXE^!]7O(/K=@6+) +M=Z+?0?4[B'Z'J*35D>]$OX/J=Q#]#E']KB/?B7X'U>\@^AVB^EU'OA/]#JK? +M0?2[`\62[T2_@^IW$/T.44FK3WWO1+^#ZG<0_0Y1_:XGWXE^!]7O(/H=HOI= +M3[X3_0ZJWT'TNP/%DN]$OX/J=Q#]#E%)JR??B7X'U>\@^AVB^EU/OA/]#JK? +M0?0[1/6[GGPG^AU4OX/H=P>*)=^)?@?5[R#Z':*25D^^$_T.JM]!]#M$];N> +M?"?Z'52_@^AWB.IW/?E.]#NH?@?1[PX42[X3_0ZJWT'T.T0EK9Y\)_H=5+^# +MZ'>(ZG<]^4[T.ZA^!]'O$-7O>O*=Z'=0_0ZBWQTHEGPG^AU4OX/H=XA*6D/J +M>R?Z'52_@^AWB.IW`_E.]#NH?@?1[Q#5[P;RG>AW4/T.HM\=*)9\)_H=5+^# +MZ'>(2EH#^4[T.ZA^!]'O$-7O!O*=Z'=0_0ZBWR&JWPWD.]'OH/H=1+\[4"SY +M3O0[J'X'T>\0E;0&\IWH=U#]#J+?(:K?#>0[T>^@^AU$OT-4OQO(=Z+?0?4[ +MB'YWH%CRG>AW4/T.HM\A*FD-Y#O1[Z#Z'42_0U2_&\AWHM]!]3N(?H>H?C>0 +M[T2_@^IW$/WN0+'D.]'OH/I=,--!K@4N6;\]W)BNO0N1F6:EZ=.WN7&F<):U>\#7.&L]Q?FV]*_A[S?ZE]$F&_S]B+_(L)\F[<7^1<1 +MYMN\O(6S[E]NW+]R*;BHW`?%%F52GX_N\.=W/SU1<&E7\`IW]>'3 +MC^'"A@]\EG6Y?$"Q1KKWU(-HN??`"O?:8[U^@,N?VYW.>8X5:_SAT^7R(<`: +MJ^>\3`GZ!S_#(VX)YYL\[*^YWL9Y4^XS^[OBEG+Y$&#]^%4]Q0W;[92;;.&Z +M9\_V^=V]OMY=;WP85Q]E>_"=ZT"V[]P5[FQ+!/7"S*MYXOKO_0#$M-3$R+79T;V,X+G%C;WXJ[60LY1G8LF!($&J! +MNQ0.&':@M%[??5NM-K8:MJMA6ET.J^\_G[_;ZI>?W/^^^O;?__S/M[]^^_;' +MW9BM?W,J_7SPE?\QZGC:CW]&W/?O^/<+Y\N_A^?[I$MQ9R=T>3PGNK.3N +M@*<$=U9R=\13@CLKN3OA*<&=E]R=\93@SDON+GA*<.<5=\:G!'=><6?D.U?< +M><6=D>]<<><5=T:^<\6=5]P9^4W)'O!L7=4''G?$IP-U3<.?EN4-P-%7=.OAL4=T/%G9/O!L7=4''GY+M! +M<3=4W#GY;E#<;2KNG'RW4=QM*NZZV%7=!OMLJ[K85=T&^VRKNMA5W0;[;*NZV%7=!OMLJ[K85=T&^VRKN=A5W +M0;[;*>YV%7=!OMLI[G8E=^2[G>)N5W)'OMLI[G8E=^2[G>)N5W)'OMLI[G8E +M=^2[G>)N5W)'OMLI[L:2._+=J+@;2^[(=Z/B;JRX&_B4X&ZLN!O(=Z/B;JRX +M&\AWH^)NK+@;R'>CXFZLN!O(=Z/B;JRX&\AWH^)N^<_?>HY\-RGNIHJ[@7PW +M*>ZFDCORW:2XFTKNR'>3XFXJN2/?38J[J>2.?#^.RGN3B5WY+N3XNY4 +M^.RGN3B5WY+N3XNY4^.RGN3B5WY+N3XNY<^.RONSB5WY+NSXNY< +M<;?C4X*[<\7=CGQW5MR=*^YVY+NSXNY<<;*NQWY[JRX.U?<[)N1[Z[*.XN%7<[\MU%<7F^CLK^[L1?&>JO[.ROQO!=Z;Z.RO[NQ%\9ZJ_L[*_ +M&\%WIOH[*_N[$7QGJK^SLK\;P7>F^CLK^[L1?&>JO[.ROQO!=Z;Z.RO[NQ%\ +M9ZJ_L[*_&\%WIOH[*_N[$7QGJK^SLK\;R7>JO[.ROQO)=ZJ_L[*_F_B4X*[L +M[R;RG>KOK.SO)O*=ZN^L[.\F\IWJ[ZSL[R;RG>KOK.SO)O*=ZN^L[.\F\IWJ +M[ZSL[R;RG>KOK.SO)O*=ZN^L[.\F\IWJ[ZSL[R;RG>KOK.SO)O*=ZN^L[.\F +M\IWJ[ZSL[R;RG>KOK.SO)O*=ZN^L[.\F\IWJ[ZSL[_9\2G!7]G=[\IWJ[ZSL +M[_;D.]7?6=G?[KOK.SO]N0[U=]9V=_MR7>JO[.RO]N3[U1_9V5_ +MMR??J?[.ROYN3[Y3_9V5_=V>?*?Z.RO[NP.?$MR5_=V!?*?Z.RO[NP/Y3O5W +M5O9W!_*=ZN^L[.\.Y#O5WUG9WQW(=ZJ_L[*_.Y#O5']G97]W(-^I_L[*_NY` +MOE/]G97]W8%\I_H[*_N[`_E.]7=6]G<'\IWJ[ZSL[P[D.]7?6=G?'KOK.SOCN0[U=]9V=\=R7>JO[.ROSN2[U1_9V5_ +M=R3?J?[.RO[N2+Y3_9V5_=V1?*?Z.RO[NR/Y3O5W5O9W1_*=ZN^L[.^.Y#O5 +MWUG9WQW)=ZJ_L[*_._$IP5W9WYW(=ZJ_L[*_.Y'O5']G97]W(M^I_L[*_NY$ +MOE/]G97]W8E\I_H[*_N[$_E.]7=6]G]4?V=E?WKOK.SOSGQ*<%?V=V?RG>KOK.SOSN0[U=]9V=^=R7>JO[.ROSN3[U1_9V5_ +M=R;?J?[.RO[N3+Y3_9V5_=V9?*?Z.RO[NS/Y3O5W5O9W9_*=ZN^L[._.Y#O5 +MWUG9WYW)=ZJ_L[*_.Y/O5']G97]W)M^I_L[*_NY,OE/]G97]W9E\I_H[*_N[ +M"Y\2W)7]W85\I_H[*_N["_E.]7=6]G<7\IWJ[ZSL[R[D.]7?6=G?7KOK.SO+N0[U=]9V=]=R'>JO_/E!VENU>?`=]]/,7>>^KOE/;U5YPY\YZJ_ +M\]3?K6;N5@MWL>93S)VG_FXU<[?ZL\V![USU=Y[ZN]4UW5W0^W>N^CM/_5V[ +MNSX'OG/5WWGJ[V`.?.>JO_/4W\$<^,Y5?^>IOUOF'O0Y\)VK_LY3?_=@F5NU +M.?"=J_[.4W_W8.;N0><.?.>JO_/4WSV8N7O0N0/?N>KO//5W#ZXW=P>^<]7? +M>>KOVMWU.?"=J_[.4W\'<^`[5_V=I_X.YL!WKOH[3_W=,O>PSY'O5'_GJ;][ +MN,QU[LAWJK_SU-\]G+E[V+BC]^]<]7>>^KN',WOW/5WWGJ[Q[-W#WJW)'O5'_GJ;][-'/WJ'-'OE/]G:?^[M'U +MYN[(=ZJ_\]3?M;OK<^0[U=]YZN]@CGRG^CM/_1W,D>]4?^>IOUOF'O>KO +M'E_SW='[=Z[Z.T_]7;N[/D>^4_V=I_X.YLAWJK_SU-_!'/E.]7>>^KME[DF? +M(]^I_LY3?_=DF6O>^KMV=WV.?*?Z.T_]'KO//5WR]S3 +M/D>^4_V=I_[NZ3+7N2/?J?[.4W_W=.;N:>..WK]SU=]YZN^>SMP];=S1^W>N +M^CM/_=W3:[X[>O_.57_GJ;]K=]?GR'>JO_/4W\$<^4[U=Y[Z.Y@CWZG^SE-_ +MM\P]ZW/D.]7?>>KOGBUSC3MZ_\Y5?^>IOWLV<_>L^4_V=I_[NV][GR'>JO_/4WSU?YCIWY#O5WWGJ[Y[/W#UOW-'[=Z[Z.T_]W?.9N^>- +M.WK_SE5_YZF_>W[-=T?OW[GJ[SSU=^WN^ASY3O5WGOH[F"/?J?[.4W\'<^0[ +MU=]YZN^6N1=]CGRG^CM/_=V+9:YQ1^_?N>KO//5W+V;N7G3NR'>JO_/4W[V8 +MN7O1N2/?J?[.4W_WXGIS=^0[U=]YZN_:W?4Y\IWJ[SSU=S!'OE/]G:?^#N;( +M=ZJ_\]3?+7,O^QSY3O5WGOJ[E\MO_.57_GJ;][ +M.7/WLG%'[]^YZN\\]7[7,->[H_3M7_9VG_N[5S-VKSAWY3O5W +MGOJ[5S-WKSIWY#O5WWGJ[UY=;^Z.?*?Z.T_]7;N[/D>^4_V=I_X.YLAWJK_S +MU-_!'/E.]7>>^KME[G6?(]^I_LY3?_=ZF>O]4?^>IOWL]<_>Z<4?OW[GJ +M[SSU=Z]G[EXW[NC].U?]G:?^[O4UWQV]?^>JO_/4W[6[ZW/D.]7?>>KO8(Y\ +MI_H[3_T=S)'O5'_GJ;];YM[T.?*=ZN\\]7=OEKG&';U_YZJ_\]3?O9FY>].Y +M(]^I_LY3?_=FYNY-YXY\I_H[3_W=F^O-W9'O5'_GJ;]K=]?GR'>JO_/4W\$< +M^4[U=Y[Z.Y@CWZG^SE-_M\R][7/D.]7?>=7?!;U_YZJ_\ZJ_"WK_SE5_YU5_ +M%_3^G:O^SJO^+NC].U?]G5?]7=#[=Z[Z.Z_ZNZ#W[USU=U[U=T'OW[GJ[UST +M=^_Z'/E.]7>>^KMWRUSCCMZ_<]7?>>KOWLWO]4?^>IOWLW<_>N^ +M4_V=I_[NW?7F[LAWJK_SU-^UN^MSY#O5WWGJ[V".?*?Z.T_]'+G]:=._!=J/XN4G^WGO?6C3MZ_RY4?Q>IOUO/W*T; +M=_3^7:C^+E)_M[[FNZ/W[T+U=Y'ZNW9W?0Y\%ZJ_B]3?P1SX+E1_%ZF_@SGP +M7:C^+E)_M\Q9GP/?A>KO(O5WMLPU[NC]NU#]7:3^SN:/9YT[\%VH_BY2?VKO?)GKW)'O5'\7J;_SF3MOW-'[=Z'ZNTC]G<_< +M>>..WK\+U=]%ZN_\FN^.WK\+U=]%ZN_:W?4Y\IWJ[R+U=S!'OE/]7:3^#N;( +M=ZJ_B]3?+7/1Y\AWJK^+U-_%,M>XH_?O0O5WD?J[F+F+SAWY3O5WD?J[F+F+ +MSAWY3O5WD?J[N-[<'?E.]7>1^KMV=WV.?*?ZNTC]'KO +M(O5WR]S0Y\AWJK^+U-\-RUSGCGRG^KM(_=TPJOXO4W\$<^4[U +M=Y'ZNV5NT^?(=ZJ_B]3?;9:YQAV]?Q>JOXO4WVUF[C:=._*=ZN\B]7>;F;M- +MYXY\I_J[2/W=YGIS=^0[U=]%ZN_:W?4Y\IWJ[R+U=S!'OE/]7:3^#N;(=ZJ_ +MB]3?+7/;/D>^4_U=I/YNN\QU[LAWJK^+U-]M9^ZVC3MZ_RY4?Q>IO]O.W&T; +M=_3^7:C^+E)_M[WFNZ/W[T+U=Y'ZNW9W?8Y\I_J[2/T=S)'O5'\7J;^#.?*= +MZN\B]7?+W*[/D>]4?Q>IO]LMO\N5'\7J;_;S=SM.G?D.]7?1>KO=C-W +MN\X=^4[U=Y'ZN]WUYN[(=ZJ_B]3?M;OK<^0[U=]%ZN]@CGRG^KM(_1W,D>]4 +M?Q>IOUOFQCY'OE/]7:3^;ESF.G?D.]7?1>KOQIF[L7%'[]^%ZN\B]7?CS-W8 +MN*/W[T+U=Y'ZN_&:[X[>OPO5WT7J[]K=]3GRG>KO(O5W,$>^4_U=I/X.YLAW +MJK^+U-\MO\N5'\7J;^;9NZFSAWY3O5WD?J[:>9N +MZMR1[U1_%ZF_FZXW=T>^4_U=I/ZNW5V?(]^I_BY2?P=SY#O5WT7J[V".?*?Z +MNTC]W3+WOL^1[U1_%ZF_>[_,=>[(=ZJ_B]3?O9^Y>]^XH_?O0O5WD?J[]S-W +M[QMW]/Y=J/XN4G_W_IKOCMZ_"]7?1>KOVMWU.?*=ZN\B]7JOXO4WRUS'_H<^4[U=Y'ZNP_+7...WK\+U=]%ZN\^S-Q]Z-R1[U1_%ZF_ +M^S!S]Z%S1[Y3_5VD_N[#]>;NR'>JOXO4W[6[ZW/D.]7?1>KO8(Y\I_J[2/T= +MS)'O5'\7J;];YC[V.?*=ZN\B]71^KN/,WOPO5WT7J[SY>\]W1^W>A^KM(_5V[NSY'OE/]7:3^#N;(=ZJ_ +MB]3?P1SY3O5WD?J[9>Y3GR/?J?XN4G_W:9EKW-'[=Z'ZNTC]W:>9NT^=._*= +MZN\B]7>?9NX^=>[(=ZJ_B]3??;K>W!WY3O5WD?J[=G=]CGRG^KM(_1W,D>]4 +M?Q>IOX,Y\IWJ[R+U=\OKO/L_1^CN8(]^I_BY2?[?,?>ESY#O5WT7J[[XLO\N5'\7J;_[,G/W +MI7-'OE/]7:3^[LO,W9?.'?E.]7>1^KLOUYN[(]^I_BY2?]?NKL^1[U1_%ZF_ +M@SGRG>KO(O5W,$>^4_W=L/P@S7WM<^"[0?5W0^KOOBYSG3OPW?=3S-V0^KNO +M,W=?%^Z&-9\2?^YQ^F*_+KWQVS9'?]YV.U7,_?+MVQ\O?PYN?GZ^8;O:^6J[ +M^?%]\-4F5L/PXW]=KH:3&OSG_Y[/__B?_QC^Z][GV_S]G^_^/[?V^\%QM9Y6 +M:\?!N[E?_KF=RKG??;Z[.?ISH__"'/VYT3CW0T_?_XWCN^//:>[/7^;HSXW^ +M*[\9M\\X_?SWBA]O!8[UX(-?!N_F?GRY=X?S[["IN>^_\.W!S>>[F^M?KO]R +MQ._-&7VZ'X\;KF[FNJ;R9RQN[P%^.M#47T"%GG'BN=-^=3C_?-+N\-Z^_U3_O%_AAM3=G^E```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-vtoc8.qcow2.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.qcow2.gz.uu new file mode 100644 index 000000000000..c389b8f5f6de --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-1x1-512-vtoc8.qcow2.gz +M'XL(")L[(U0``VEM9RTQ>#$M-3$R+79T;V,X+G%C;WITZ((#Z6L5J94IE;[1OG/\0(U^#"^U.'7X_>;X>.P"C!=""EFP.`)-V+= +M)QQ(N$)/!S2/&U2'#`Z.J2DHAS-B=7,##.YZU2]=OQD52>`EP(`3-^.B^B#4 +M1Q/FPOI@Z?J07S][S-&!Z;QW-9.2O--Y[[9,2O). +MY[UKF)3DG +M1-S3$TYS*O8JXZX1C^AU( +MW@'Q[G7$O4DXIM^!Y!T0[]Y.O--,OP/).R3>O8NL(N&8?H>2=TB\TQ$'"0=$N]LQ)4)Q_0[E+Q#XMTFXJJ$8_H=2MXA\:Z.N/<) +MQ_0[E+Q#XMV'B/N8<$R_0\D[)-Y]BKC;A&/Z'4K>&>+=YXC[DG!,OS.2=X9X +M]S7B[A*.Z7=&\LX0[^XC[N&$`RYU\JXH^"OBODV^L[#L^=.D\[%FWN6!&6#U +M/\"Y"@.N7G3"-DS8WSIN0)6VN[P2%KN=]$U$F58"/OYU[N[W@_DQK,\N?4-@ +MT_H5W#)15-4?QT%:/SM:OSJ+RVR'#0>S1:8;<,VY./_CXH_VK5/.$=R?`6ZW +M\&;HR71==_+WQZGJ#.!Z``RX;KHA3'>8^6_@.*P.ZTE]`9>F"X,(C'":J\Z? +M%OO7&-.ZDVVSF>"NCKB^+_L#D+]IG;[+ +:`X>?-^-G4,5$X&+NF;)K5*M_;'%=NO`2```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-vtoc8.raw.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.raw.gz.uu new file mode 100644 index 000000000000..c35f98dc8060 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.raw.gz.uu @@ -0,0 +1,10 @@ +# $FreeBSD$ +begin 644 img-1x1-512-vtoc8.raw.gz +M'XL(".S%'50``VEM9RTQ>#$M-3$R+79T;V,X+G)A=RYO=70`K9)-#H(P$(7W +MG.+AT@5IAU)E:XP[$Q,O(-AZ`-<]O&V&!`KEQX2A=/-X7^8Q(P07H#1.!%V% +MHPA5":50*B\8>'UZX&Y?:R_/J[H77"YCF/1BTB*6!%>,RF7'#GB.?'(9>(:H +M(2@)9%S=N^I5W%)_C&OVBLNX=BM.^]O`6%@[PKT&N/?.PY"3N!9^X"3#GUP% +MYN.X,L1E\WC"LS@ON'S2'^/ZN#2P4(23J>Y0\!OC3(^3?ZU*GNS.[KHJ\K,5 +L9QJT%D0H]01WT!V.@JORWS>)>UYPCR)^>%54!]QM]Q0%8/8#T8E)O;($```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhd.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhd.gz.uu new file mode 100644 index 000000000000..e3f9594789d8 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhd.gz.uu @@ -0,0 +1,17 @@ +# $FreeBSD$ +begin 644 img-1x1-512-vtoc8.vhd.gz +M'XL(".S%'50``VEM9RTQ>#$M-3$R+79T;V,X+G9H9"YO=70`K9;);L(P$(;O +M/,5(O7%`WN+`M6JY5:K4%\!)'-1#%P$'#CQ\9Q)G<1('*`[&,G+F\S_CL1G& +MZ@=`2]`E:`LZH7&J0&\@70/@I&NBZKG["9?\Y]OFI\_SRCV710WCK&_EFY.] +MD*!PD12$H45T06.X-)C5T^M^^?FU;W#"X9J%E08E($&(&JVC6:N.2-OGCY<* +MN>O4R;&ZS@J_F0*F@//>&[)1MVLUMCB%5F59M12,J60VS?OA373.#G`)&UCU +M9$X%M>?L%$[/6=V#6R[<7M2I@HF18H^AXY`*&F/:-'$8-4R5\_'7'(YVH$\$ +M4D6W^OAH3H;=%2Y51/.R4Z`HG>?C +MUZ&@KT]S-A/S\&8$]1G2A\<+=Y1N@:0[9U+C1!%R>'NP%D^:?O/C9P*[^^_X +MF;5G=^5TK(%MZ-8)IHO9=%:;QP^;,;'NZ)D(#S>Z7$@=M,>LCRM:W%#C +M%6?9I#H;-56R\E9<82"S("7(9(23B,IA"!-K)"SF8SX][SJYW"2%4?X2)6?82+6/41+F+51[B(51_A(E9] +1A(M:]>DJ]Q9_[Z\6^RH,```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhdf.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhdf.gz.uu new file mode 100644 index 000000000000..bb8e69831df8 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhdf.gz.uu @@ -0,0 +1,14 @@ +# $FreeBSD$ +begin 644 img-1x1-512-vtoc8.vhdf.gz +M'XL(".S%'50``VEM9RTQ>#$M-3$R+79T;V,X+G9H9&8N;W5T`*V4RVZ#,!!% +M]_F**W67!?)S"-NJS:Y2I?Y`()BHB[92U447_OC:L4FP<1ZJ,(,%&N9XKCT, +M8V$`BE`+D/:F!+2$4I#D'#VZ*4*PZX"C#MG,81=<]@J&W:U +MCL!-$L>O`S=@#9@H`@.N.4Q40U#V7R\<$W0+5)#M'X1 +MZOWS)+^'Y\/Z_>,PXD14-2[L6NJID^8J*96[=7UT_'5'G)QO$DUWKU-@"IPG +MPF-VN[18/$Z=Q)H!G3ZF.5KRDCB*M>=QFF51_R]ECZ.%2\75WNH/`$S(R-T& +"```` +` +end diff --git a/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vmdk.gz.uu b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vmdk.gz.uu new file mode 100644 index 000000000000..2cc570c86059 --- /dev/null +++ b/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vmdk.gz.uu @@ -0,0 +1,81 @@ +# $FreeBSD$ +begin 644 img-1x1-512-vtoc8.vmdk.gz +M'XL(".W%'50``VEM9RTQ>#$M-3$R+79T;V,X+G9M9&LN;W5T`*U<76_DQA%\ +M]Z\8G%\."2"PEM\/!R2.;"`(#!@^(WDU/V,A]MU!)P0QL#\^'')J5)3$&\)J +M965R;KMKIWM6):6ZL%FV?3E7]*XH7#&ZLG(9W/)/V\-E^>-B>5P:/G']Q^WW +M_[SAU]N;F^M7&QA\EJ0@4SA9[%[G>O/DBW"7+V7MGE@>ER1<[K/Z9XD![G+P +MQ"%2F%N^O6IT=_(W`N`KD=7/E"38?%?FEW?_HJ-,_O+_=[6(ZW:EV= +MNZH/2U>5ZSIW]65]+G/U$C0O@%^[V[O/_W&WT^?A_N[3P\>POXL_VR6XJ'Q\ +M-7B$I;"Z\C?^"0_7>HAJ?[SY^>`>6>_%G6^2N +M:/UV?'SV^-@M_(MDKH)_#7?]V]]OWX5W;G;SJ;LGG,]:-K*\]E*'XE:5\]_/ +M'^ONI@\/'G$.7W%W_FQ#<\KUM0M_4Q:N;MVZG=)C7Y:GQU#RVKOA?NH>II]^ +M_S2]>_/;QP^Q=_YL?FKN^NO=PR]WP_NE +MS,_3FYNO'>$JW[OE`)NPKZWJ):4Z/-EEV]=O__>PU.O&<+)WA%LWL1:QO'9Y +M<67ML98#7(_BXO+"WRW_M&QXJ:2`#W+7CQ]N?OS7\B/NF_7^A[_^2+AFR5HB +MEPTN*4M!NYK*K?[RZ=O27=]_Z][X(G_Z95K?@81KMQ\S'[R=`];EQ=^$KFWP +MGL0*_\1ZLNZV>^C<-]WGZ>;KV]MOXLEVOMAB?2Q;FSQ*M4'[]_?:SJ5QVTEO +M![T>Q3CV-]W8?7J8[OWQQJ/H?8O&4*D_UN+Q&/>O4Z\G-?MWC+N^R_IX^_$6[8WL;+/OQ;HET37D?H5-/7FI!=]?'KJVXGP-6J;)')^VCW^J0&Y/X;CWP*,S#6KD$6Y@SOJ71EZQ\A:LQI9M#NXH]Y5H7>, +M[#5KD,5XJM@Z](Z1LV;Y"_^40G;BS[*J";UC9*Y9A2S*'=Q1[]K0.T;6FM7( +MHMW!'?6N"[UC9*]9@RS&4\7VH7>,G#7+7T@0D/MCN"'TCI&Y9A6R*'=P1[T; +M0^\866M6(XMV!W?4NRGTCI&]9@VR&$\5.X?>,7+6+'\II'=%"J[.0N\8F6M6 +M(8MR!W?0NYI\Q\A:LQI9M#NX@][5Y#M&]IHUR&(\52SYCI&S9OE+*;TKDW#D +M.T;FFE7(HMS!'?6.?,?(6K,:6;0[N*/>D>\8V6O6((OQ5+'D.T;.FN4OE?2N +M2L*1[QB9:U8ABW('=]0[\ATC:\UJ9-'NX(YZ1[YC9*]9@RS&4\62[Q@Y:Y:_ +M\(\@R/TQ'/F.D;EF%;(H=W!'O2/?,;+6K$86[0[NJ'?D.T;VFC7(8CQ5+/F. +MD;-F^0L%&L0A;E#NZ@=PWYCI&U9C6R:'=P![UKR'>,[#5K +MD,5XJECR'2-GS?*75GK7)N'(=XS,-:N01;F#.^H=^8Z1M68ULFAW<$>](]\Q +MLM>L01;CJ6+)=XR<-0[1LZ:Y2_4'R'WQW#D.T;FFE7(HMS!'?6.?,?(6K,: +M6;0[N*/>D>\8V6O6((OQ5+'D.T;.FN4O@_1N2,&U6>@=(W/-*F11[N`.>M>2 +M[QA9:U8CBW8'=]"[EGS'R%ZS!EF,IXHEWS%RUBQ_&:5W8Q*.?,?(7+,*690[ +MN*/>D>\866M6(XMV!W?4._(=(WO-&F0QGBJ6?,?(6;/\99+>34DX\ATC<\TJ +M9%'NX(YZ1[YC9*U9C2S:'=Q1[\AWC.PU:Y#%>*I8\ATC9\WREUEZ-R?AR'>, +MS#6KD$6Y@SOJ'?F.D;5F-;)H=W!'O2/?,;+7K$$6XZEBR7>,G#4KD^D9Y/X0 +MKLNVWL7(7+,*690[N(/>=8'O8F2M68TLVAW<0>^ZP'L01;CJ6(#W\7( +M6;-\RT2_0U+2Z@+?0?0[J'X'T>^0U.^ZP'<0_0ZJWT'T.R3UNR[P'42_@^IW +M$/WN1+&![R#Z'52_@^AW2$I:7>`[B'X'U>\@^AV2^ET7^`ZBWT'U.XA^AZ1^ +MUP6^@^AW4/T.HM^=*#;P'42_@^IW$/T.24FK"WP'T>^@^AU$OT-2O^L"WT'T +M.ZA^!]'OD-3ONL!W$/T.JM]!]+L3Q0:^@^AW4/T.HM\A*6GU6>B=Z'=0_0ZB +MWR&IW_7D.]'OH/H=1+]#4K_KR7>BWT'U.XA^=Z)8\IWH=U#]#J+?(2EI]>0[ +MT>^@^AU$OT-2O^O)=Z+?0?4[B'Z'I'[7D^]$OX/J=Q#][D2QY#O1[Z#Z'42_ +M0U+2ZLEWHM]!]3N(?H>D?M>3[T2_@^IW$/T.2?VN)]^)?@?5[R#ZW8EBR7>B +MWT'U.XA^AZ2DU9/O1+^#ZG<0_0Y)_:XGWXE^!]7O(/H=DOI=3[X3_0ZJWT'T +MNQ/%DN]$OX/J=Q#]#DE):\A"[T2_@^IW$/T.2?UN(-^)?@?5[R#Z'9+ZW4"^ +M$_T.JM]!]+L3Q9+O1+^#ZG<0_0Y)26L@WXE^!]7O(/H=DOK=0+X3_0ZJWT'T +M.R3UNX%\)_H=5+^#Z'\@^AV2DM9`OA/]#JK?0?0[)/6[@7PG +M^AU4OX/H=TCJ=P/Y3O0[J'X'T>].%$N^$_T.JM]!]#LD):V!?"?Z'52_@^AW +M2.IW`_E.]#NH?@?1[Y#4[P;RG>AW4/T.HM^=*)9\)_H=5+^#Z'=(2EIC%GHG +M^AU4OX/H=TCJ=R/Y3O0[J'X'T>^0U.]&\IWH=U#]#J+?G2B6?"?Z'52_@^AW +M2$I:(_E.]#NH?@?1[Y#4[T;RG>AW4/T.HM\AJ=^-Y#O1[Z#Z'42_.U$L^4[T +M.ZA^!]'OD)2T1O*=Z'=0_0ZBWR&IWXWD.]'OH/H=1+]#4K\;R7>BWT'U.XA^ +M=Z)8\IWH=U#]#J+?(2EIC>0[T>^@^AU$OT-2OQO)=Z+?0?4[B'Z'I'XWDN]$ +MOX/J=Q#][D2QY#O1[Z#Z73330>X%SFW?`6[*MMZ]:"E_X9]B[]R+NYN,_8%8 +M_8%QIK!5]<<`-SCK_<7Y-A^O\B\BSK?Y>)5_$7&^S<>K_(N(\VT^7N5?1)QO +MF_@7$>?;)OY%Q/FVB7\1<;YMXE]$G&^;^!<1Y]LF_D7$^;:)?Q%QOFWB7T2< +M;YOX%Q'GVR;^1<3YMHE_$7&^;>)?1)QOF_@7$>?;)OY%Q/FVB7\1<;YMXE]$ +MG&^;^!<1Y]LF_D7$^;:)?Q%QOFWB7T2<;YOX%Q'GVR;^1<3YMHE_$7&^;>)? +M1)QOF_@7$>?;)OY%Q/FVB7\1<;YMXE\$Y]LV_D5POFWC7P3GVS;^17"^;>-? +M!.?;-OY%<+YMXU\$Y]LV_D5POFWC7P3GVS;^17"^;>-?!.?;-OY%<+YMXU\$ +MY]LV_D5POFWC7P3GVS;^17"^;>-?!.?;-OY%<+YMXU\$Y]LV_D5POFWC7P3G +MVS;^17"^;>-?!.?;-OY%<+YMXU\$Y]LV_D5POFWC7P3GVS;^17"^;>-?!.?; +M-OY%<+YMXU\$Y]LV_D5POFWC7T2<;S/R5?Y%Q/DV(U_E7T2<;S/R5?Y%Q/DV +M(U_E7T2<;YOX%Q'GVR;^1<3YMHE_$7&^;>)?1)QOF_@7$>?;)OY%Q/FVB7\1 +M<;YMXE]$G&^;^!<1Y]LF_D7$^;:)?Q%QOFWB7T2<;YOX%Q'GVR;^1<3YMHE_ +M$7&^;>)?1)QOF_@7$>?;)OY%Q/FVB7\1<;YMXE]$G&^;^!<1Y]LF_D7$^;:) +M?Q%QOFWB7T2<;YOX%Q'GVR;^1<3YMHE_$7&^;>)?!.?;-OY%3*;^14RF_D5, +MIOY%3*;^14RF_D5,IOY%3*;^14RF_D5,IOY%3*;^14RF_D5,IOY%3*;^14RF +M_D5,IOY%S%EFZ%_$;.I?Q&SJ7\1LZE_$;.I?Q&SJ7\1LZE_$;.I?Q&SJ7\1L +MZE_$;.I?Q&SJ7\1LZE_$;.I?Q&SJ7\1LZE^\9%EFZ%^\//LLX9-PSXO=_('% +MNK^BXF>ZEOZ30LOU4T/STOF//SX`_.Y^FKYY?UM^O]M?8;^_9I>'+P,VZTCS +M^?;:_#>ZQ7/UIN^S@\-+NPH_L$[CQ$:YYEO6E +M8M^^N+O)]*V"^2SY=4SN#]7`6[]6.QM4O_\O\=/7'^XV?]O>ZL4 +4`=#LO5?XSV'-OOH_FA1I)IY=```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-apm.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-apm.qcow.gz.uu new file mode 100644 index 000000000000..491ab8063ef8 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-apm.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-apm.qcow.gz +M'XL(",$S(E0``VEM9RTV,W@R-34M-#`Y-BUA<&TN<6-O=RYO=70`K9W9CAW9 +M<47?^RLN9[(XW8C(D;,$N0$_&&A;T+.4(R!`MA.R`+_PXUW%.D-5W+T9E+NI +M0H-$(3>R3BTN":W%P_/Y]L?IU,JIZ4[->-KGT_6OTX><[OSB_L?IZ[___*]O +M[O[X^M/MF)R_\Y3[=:,G27/WMGY?Y_3FJ>5T'G]@[OH#SMUY._LGWN[.%WLY +M=_73[1>+GU,V:/<&3VGNG-Y/R.DU/_9^7]R7*[>G]]M]N4J^W)8-=O<&?TES +M?TGOI^3+[=G<<&_N<%^NDB]W9'/3=V%1`LO,YI9@KH%/K6QN"^9:^-2.Y^0[ +MW]O;N0X^)6Q.X=RIS/7P*6-SS;VY\YL,=)X;X%.$.PFY&^%3A#L)N9O@4X0[ +M";F;X5.$.PFY6^!3A#L)N5OA4X0[#;G;X%.$.PVYV^%3A#N-N!/\%.%.(^X$ +M^4X9=QIQ)\AWRKC3B#M!OE/&G4;<"?*=,NXTXDZ0[Y1Q9Q%W@GQGC#N+N!/D +M.V/<6<@=\ITQ[BSD#OG.&'<6*GR+<-1%WBGS7,.Z:B#M%OFL8=TW$G2+?-8R[ +M)N).D>\:QET3<:?(=PWCKHVX4^2[EG'71MPI\EW+N&M#[I#O6L9=&W*'?-X +MZR+N##]%N.LB[@SYKF/<=1%WAGS7,>ZZB#M#ONL8=UW$G2'?=8R[+N+.D.\Z +MQET?<6?(=SWCKH^X,^2[GG'7A]PAW_6,NS[D#OFN9]SU(7?(=SWCK@^Y0[[K +M&7=]R!WR7<^XZT/ND.]ZQMT0*N0[Y;&'=+Q%V'?+ZVB+L>^6YCW&T1=SWRW<:XVR+N>N2[C7&W1=SUR'<; +MXVZ/N.N1[W;&W1YQUR/?[8R[/>0.^6YGW.TA=\AW.^-N#[E#OML9=WO('?+= +MSKC;0^Z0[W;&W1YRAWRW$^XD_X3/`=_)F7`GYY`[X#LY$^[D''$WX*LOY.POQN`[X3U=Q+V=P/PG;#^3L+^;@"^$];?2=C?#OO).SO9OP4X2[L[V;D.];?2=C?S]8?R=A?SOO).SO9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYN1KYC +M_9V$_=V,?,?Z.PG[NQGYCO5W$O9W"WZ*OO).SO%N0[UM])V-\M +MR'>LOY.POUN0[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W +M$O9W"_(=Z^\D[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W(-^Q_D["_FY! +MOF/]G83]W8)\Q_H["?N[%3]%N`O[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6WTG8 +MWZW(=ZR_D["_6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83]W8I\Q_H["?N[%?F. +M]7<2]G]8?R=A?[OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_)V%_MR'?L?Y. +MPOYNQT\1[L+^;D>^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V=SOR'>OO).SO=N0[ +MUM])V-_MR'>LOY.PO]N1[UA_)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.PG[ +MNQWYCO5W$O9W._(=Z^\D[.]VY#O6WVG^B9L[U3G@N^NG,'?J^KM\G]ZI<@=\ +MIZR_4]??G1)WI\R=G?%3F#MU_=TI<7?Z2YD#OE/6WZGK[TZ'.SM#]]\IZ^_4 +M]7?E[.H<\)VR_DY=?P?F@.^4]7?J^CLP!WRGK+]3U]_EN0=U#OA.67^GKK][ +MD.=.90[X3EE_IZZ_>Y"X>U"Y`[Y3UM^IZ^\>).X>5.Z`[Y3U=^KZNP?'Q=D! +MWRGK[]3U=^7LZASPG;+^3EU_!^:`[Y3U=^KZ.S`'?*>LOU/7W^6YAW4.^8[U +M=^KZNX=YKG*'?,?Z.W7]WYBX>UBX0_??*>OOU/5W +M#P]_=NC^.V7]G;K^KIQ=G4.^8_V=NOX.S"'?L?Y.77\'YI#O6'^GKK_+/\ESA#MU_IZR_4]??/4KHNOP-SR'>LOU/7WX$YY#O6WZGK[_+< +MXSJ'?,?Z.W7]W>,\5[E#OF/]G;K^[G'B[G'A#MU_IZR_4]??/4[:YPA^Z_4];?J>OOGB3NGE3ND.]8?Z>NOWN2N'M2 +MN4.^8_V=NO[NR7%Q=LAWK+]3U]^5LZMSR'>LOU/7WX$YY#O6WZGK[\`<\AWK +M[]3U=WGN:9U#OF/]G;K^[FF>J]PAW['^3EU_]S1Q][1PA^Z_4];?J>OOGB;N +MGA;NT/UWROH[=?W=T\.?';K_3EE_IZZ_*V=7YY#O6'^GKK\#<\AWK+]3U]^! +M.>0[UM^IZ^_RW+,ZAWS'^CMU_=VS/%>X0_??*>OOU/5WSQ)WSRIWR'>LOU/7 +MWSU+W#VKW"'?L?Y.77_W[+@X.^0[UM^IZ^_*V=4YY#O6WZGK[\`<\AWK[]3U +M=V`.^8[U=^KZNSSWO,XAW['^3EU_]SS/5>Z0[UA_IZZ_>YZX>UZX0_??*>OO +MU/5WSQ-WSPMWZ/X[9?V=NO[N^>'/#MU_IZR_4]??E;.K<\AWK+]3U]^!.>0[ +MUM^IZ^_`'/(=Z^_4]7=Y[D6=0[YC_9VZ_NY%GBO6YRAWR'>OOU/5W5XF[J\(= +MNO].67^GKK^[2MQ=%>[0_7?*^CMU_=W5X<\.W7^GK+]3U]^5LZMSR'>LOU/7 +MWX$YY#O6WZGK[\`<\AWK[]3U=WGN99U#OF/]G;K^[F6>*]RA^^^4]7?J^KN7 +MB;N7E3OD.];?J>OO7B;N7E;ND.]8?Z>NOWMY7)P=\AWK[]3U=^7LZASR'>OO +MU/5W8`[YCO5WZOH[,(=\Q_H[=?U=GGM5YY#O6'^GKK][E>'[K]3UM^IZ^_*V=4Y +MY#O6WZGK[\`<\AWK[]3U=V`.^8[U=^KZNSSWNLXAW['^3EU_]SK/%>[0_7?* +M^CMU_=WKQ-WKRAWR'>OOU/5WKQ-WKRMWR'>LOU/7W[T^+LX.^8[U=^KZNW)V +M=0[YCO5WZOH[,(=\Q_H[=?T=F$.^8_V=NOXNS[VI<\AWK+_3J+\S=/^=LOY. +MH_[.T/UWROH[C?H[0_??*>OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ +M.XWZ.T/WWRGK[Y3T=V_K'/(=Z^_4]7=O\USA#MU_IZR_4]??O4WVNOP-SR'>L +MOU/7WX$YY#O6WUG^B9L[USG@.V/]W?4G[G&7_72NW`'?&>OOS/5WY[1W+MRA +M^^^,]7?F^KMSXNYNORMG5^>`[XSU=^;Z +M.S`'?&>LOS/7WX$YX#MC_9VY_B[/29T#OC/6WYGK[R3/%>[0_7?&^CMS_9VD +MUY/*'?"=L?[.7'\GB3NIW`'?&>OOS/5W5.^0[UM^9Z^\L<6>5.^0[UM^9Z^_LN#@[Y#O6WYGK[\K9U3GD.];?F>OO +MP!SR'>OOS/5W8`[YCO5WYOJ[/-?4.>0[UM^9Z^^:/%>Y0[YC_9VY_JY)W#6% +M.W3_G;'^SEQ_UR3NFL(=NO_.6']GKK]K#G]VZ/X[8_V=N?ZNG%V=0[YC_9VY +M_@[,(=^Q_LYNO\MS;9U#OF/]G;G^KLUSA3MT_YVQ_LYZ.H=\Q_H[<_U=E^X0_??&>OOS/5WW>'/#MU_9ZR_,]??E;.K<\AWK+\S +MU]^!.>0[UM^9Z^_`'/(=Z^_,]7=YKJ]SR'>LOS/7W_5YKG"'[K\SUM^9Z^_Z +MQ%U?N4.^8_V=N?ZN3]SUE3OD.];?F>OO^N/B[)#O6']GKK\K9U?GD.]8?V>N +MOP-SR'>LOS/7WX$YY#O6WYGK[_+<4.>0[UA_9ZZ_&_)OOS/5WY>SJ'/(=Z^_, +M]7=@#OF.]7?F^CLPAWS'^CMS_5V>>U?GD.]8?V>NOWN7YRIWR'>LOS/7W[U+ +MW+TKW*'[[XSU=^;ZNW>)NW>%.W3_G;'^SEQ_]^[P9X?NOS/6WYGK[\K9U3GD +M.];?F>OOP!SR'>OOS/5W8`[YCO5WYOJ[//>^SB'?L?[.7'_W/L\5[M#]=\;Z +M.W/]W?O$W?O*'?(=Z^_,]7?O$W?O*W?(=ZR_,]??O3\NS@[YCO5WYOJ[LOS/7WWW(OOS/5W8`[YCO5WYOH[,(=\Q_H[<_U=GOM8YY#O6']GKK_[F.<* +M=^C^.V/]G;G^[F/B[F/E#OF.]7?F^KN/B;N/E3OD.];?F>OO/AX79X=\Q_H[ +M<_U=.;LZAWS'^CMS_1V80[YC_9VY_@[,(=^Q_LYOOS/5WGX^+ +MLT.^8_V=N?ZNG%V=0[YC_9VY_@[,(=^Q_LY:YR!WQW_13FKG']W9?$W9?,77/&3Y&_]]A]L5]R;_RFS*&_;[L\ +M%#MW\W[-MW#L^J.[_M_3[0^]W^^.XV\;F$-_7_G_ +MZ\N]G;/+MVN_6:63TZG74]^[ +MYX?^./BO>K_N!\Y/[YS?[6^2N^=WNOM^Z,]N_;KW^^[Y]7;J>\!F/;__^=]; +F$//[_<;GUYW3^9TG\$_^B:^_O+G_G]O!YMO@3_\'*;=.DB.F```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-apm.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-apm.qcow2.gz.uu new file mode 100644 index 000000000000..aa257d4b971f --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-apm.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-apm.qcow2.gz +M'XL("+@[(U0``VEM9RTV,W@R-34M-#`Y-BUA<&TN<6-O=S(N;W5T`*V826_; +M,!!&[_D53/>F32K.D)35/9N!'@JD#7H.O,A`@"Y&&J`7__A2ULB4J1DQ-N0( +M1@SB>Q@/GT>FLZQ^*&6U,DZ90BVFRK^F"U3KQ?:E5M_&7T[:C]5!#=.9D&(6 +M#&YP6ZSS@`,)E^GN@N9QK>J0P4&3ZH)2."-6U[?`X(X.UJU;;\8H2N`^P!HG +M;L9>]4%=7YPP>]8'0]>'?/]LDXL77']]6-<7IW()-TKB@$D5$FZ2Q"&3FDJX +M61)GF-1Z;1W4R8E>:?3WLV8E.2=3GLW9U*2=R!XIP*N9%*2=Q!Y=TBX1P&W +M8%*2=Q!Y]YAP3S8XS:4D[R#R[BGAG@4<,^]`\@XB[YX3[D7`,?,.).\@\NXE +MX8X"CIEW('D'D7>O"/8>2=QAY9PGG`HZ9=RAYAY%W.>%&`8>2=QAY]X%P'P..F76X4YW*[/#GT@L+4P +M?C*;>2>'TH'/+ZRNOC+]L[4P_N/@IZF_W$PY^Z#Z3I?+GR6#DT^WNQ^G/`Z[ +MU=G%^G\O2PXJ-\H5].P6RI75,E5WLYSW_[Y?=/@JANDFU?A?)?J?DV6 +M;'5VX+TU#]S;YGX!!-S>6]749X9VSZRWPU6-]QOA+S\N+593SG_-4-96:Q:[ +MP/%=69Y=7QS_&%^W^V>&_;'!^A-5NG_0ZE_](6GW3[7K5YXR; +MH7]__]4B-O4-W#^=4?_\2;W[+"^LKDZV_VJ@(>!@%1I73>>#_Z4*H1'E$P`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-apm.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-apm.raw.gz.uu new file mode 100644 index 000000000000..13210f03aded --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-apm.raw.gz.uu @@ -0,0 +1,12 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-apm.raw.gz +M'XL("/[%'50``VEM9RTV,W@R-34M-#`Y-BUA<&TN6#-2, +M^JH4R/L%LWH;`CW.Z2,.S5RJ3R@Y2]]3UWVU$SB1ZW,]KAJKD]OS.P>T@":H +MQW"J+53KRD'=IJN/I]UI=]AO(HXL3C6N6?]'W7?=3:J3F6=+,V>[B$L9@/W9 +M(NJCW+M'YW$H9[P=A$T2D!6((!HK7+J:O8^`RV/;/J]?'CZ6Z]0_HLSZU`S_ +M1.*?_TE2_Y#J4[G]4S?]TQ6TGMC-BW\_OWX1H[[,_G$6_&/UQ'F]8%9E__%` +1"L!L"DDX8/$'F8$ZXZ<%```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-apm.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-apm.vhd.gz.uu new file mode 100644 index 000000000000..03492316e6ac --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-apm.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-apm.vhd.gz +M'XL("/_%'50``VEM9RTV,W@R-34M-#`Y-BUA<&TN=FAD+F]U=`"M5EUOVR`4 +M?<^ON-+>*BT"#-?=T]1JS=ND:M6>6\O!5:2UC9I(ZX-__+A\U#@&U\UP$,'" +M]W`X]P,8H+P',I&_"]MR_0M^^/.OVN'M;^Z=?.3#. +M8JNQ.=F+"J19I`;1T"*XI3'T`6;]Y>;Q8O?T&."$APL+2P0I0!D0.5D'V3L[ +M0MIW/9+BTQ$]R"F.*Y)9B>`F_J_W^CT[`B5+;=7#5 +ME)WJ?,[9I',EVO:N=*LNL+LWV7;<'7SSORLE]$S+'35Q7R5.>>J +J2W`%K[KH2U;6ROTMO>JB+UF%KKH$5_"J2W!%K[IH"^KJ'[J1;&,?#0`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-apm.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-apm.vhdf.gz.uu new file mode 100644 index 000000000000..e1b66268c980 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-apm.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-apm.vhdf.gz +M'XL("/_%'50``VEM9RTV,W@R-34M-#`Y-BUA<&TN=FAD9BYO=70`K57);L(P +M$+WS%2/UAM3(\3*FIRXJW"JAHIXA(@F*5""B2.TA'U^OX"P@6MF,+$<3/]Z\ +M9T\(L0.`"Q`4B`KB@IGY_-P):*;OB1HD\:,96;#TVJ[+<$EG-*.Q!:0Z+0CP +MO+>/A8!I.]',W[J`%D[SXRE(H@/7@.(F?L]U_5D,P-%8Y5HXUF4W>CMQ"^H` +MV]Z"Y\=CGSUN[$`MO#)"!:<@&'`.-%?$AR@?ERHIDG +M[9\%Y`XP&D-TW1F9N^M:1.9[P"0$I&=[#>!ZORO6Q^HGO,'HNG-9#H?>3YG^ +M%J`$FID6D^MUP.]NNAE7VXV'\]W/_['R^F1QMTILESM3!AO(U9D=ZXN$'?44 +M3U:V"G?L5F9^#(OEIV*+$KBEZ:/UT$IHN*>V&1;.=+_PY?]Z:^$P\E%1'\K1 +)+TV"K"_2!P`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-apm.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-apm.vmdk.gz.uu new file mode 100644 index 000000000000..860e005e645a --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-apm.vmdk.gz.uu @@ -0,0 +1,83 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-apm.vmdk.gz +M'XL("/_%'50``VEM9RTV,W@R-34M-#`Y-BUA<&TN=FUD:RYO=70`K9Q;;^3& +M$87?_2L(^<4(D`'/\/ZP0.S(!H+`P,+K)(\.K[&0]4J0A"0+S(\/F^S3.I3$ +M;<*J]<@SM5-5TUU-E;1?'3!-US])DG=)GB?YD!1EDB*9_VI])&GV9,R/<\TW +M+G^]_O'O)_[YYG2Z?+4F@XN2$*2:3HS-YUQ.S_XPW?E+49LWYLVE2S4[3G/#KY/KFX=_)]?C0W]_>G\R]YEF#=6E>Z%>\.E:UR*,YV+FAOE85C=^>G09)_\GK,Z=K2].L7QV[EX4>5(UR;*/O][T'^9M/HQ7IZ\3IBM=[>8#K/VZUEW/(>7NR<[+OGS_O\=YO\G@3_:& +MZ99%+)N8/[LX)T7EGJ.6KVG!M?$9=?3_WGCS>?AOD;+7G'=,-:NWDY6>H7%=;T?%'A8^?:7:5/2YMS,]WH2K0N +MJO;?&'.N=1U/57!73.$>O@J7SZ=?QW:8EY5]%R+ +M]2C\PCZ?'L;>I\M2?X#3ICCKFI*L3++,KVC;0!]O[Y>EE=F5]N/L^<^RM_;C +M_,6/U.IW)ES36:^O3)_]/,LT+A>CV"1T/\72^>M/\]?[I_65;GVE>%8:58O1 +M;-+]K%&`YMMO*UH^>D4>Z)OTHA/?!K +M65G[VM$STZAC.'09CM?.WI. +M&N6>V"`@K_?3];YV],PT*A>CV*3;J]W@:T?/2J-J,9I-NKW:C;YV].PTJA=C +M.+39R=>.GI-&N:=<:I?'TE6IKQT],XW*Q2@VZ79J5['?T;/2J%J,9I-NIW85 +M^QT].XWJQ1@.;9;]CIZ31KFG0FI71-.QW]$STZADT:YIU)J5T;3L=_1,].H7(QBDVZO=NQW]*PT +MJA:CV:3;JQW['3T[C>K%&`YMEOV.GI-&N2?^$@1YO9^._8Z>F4;E8A2;='NU +M8[^C9Z51M1C-)MU>[=COZ-EI5"_&<&BS['?TG#3*/1'(0%[OIJM37SMZ9AJ5 +MBU%LTNW4KF:_HV>E4;48S2;=3NUJ]CMZ=AK5BS$G8:U8LQ'-HL^QT])XUR3_PG +M%.3U?CKV.WIF&I6+46S2[=6._8Z>E4;58C2;='NU8[^C9Z=1O1C#H;V?COV.GIE&Y6(4FW1[M6._HV>E4;48S2;=7NW8[^C9:50OQG!H +ML^QW])PTRCWU4KL^EJY)?>WHF6E4+D:Q2;=3NX;]CIZ51M5B-)MT.[5KV._H +MV6E4+\9P:+/L=_2<-,H]#5*[(9J._8Z>F4;E8A2;='NU8[^C9Z51M1C-)MU> +M[=COZ-EI5"_&<&BS['?TG#3*/8U2NS&:COV.GIE&Y6(4FW1[M6._HV>E4;48 +MS2;=7NW8[^C9:50OQG!HL^QW])PTRCU-4KLIFH[]CIZ91N5B%)MT>[5COZ-G +MI5&U&,TFW5[MV._HV6E4+\9P:+/L=_2<-"J5Z1GD]6ZZ-EUK%SPSC^$WT'Y'83?(8JT^M373O@= +ME-]!^!VB_*YGOQ-^!^5W$'Z'*+_KV>^$WT'Y'83?'=@L^YWP.RB_@_`[1)%6 +MSWXG_`[*[R#\#E%^U[/?";^#\CL(OT.4W_7L=\+OH/P.PN\.;);]3O@=E-]! +M^!VB2*MGOQ-^!^5W$'Z'*+_KV>^$WT'Y'83?(O8[X7=0?@?A=P7YAO\_$F_2+"?)N/-^D7$>;; +M?+Q)OX@PW^;C3?I%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB +M7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YM +MHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^ +M;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D5POFVC7P3G +MVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?; +M-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV +M^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z +M17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z183Y-CW?I%]$F&_3 +M\TWZ183Y-CW?I%]$F&_3\TWZ183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FV +MB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183Y +MMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$ +M^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI% +M<+YMHU_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7\1HJE_$:*I?Q&BJ7\1HJE_$:*I? +MQ&BJ7\1HJE_$:*I?Q&BJ7\1HJE_$E*:&^D5,IOI%3*;Z14RF^D5,IOI%3*;Z +M14RF^D5,IOI%3*;Z14RF^D5,IOI%3*;Z14RF^D5,IOI%3*;Z14RF^L5SFJ:& +M^L7SBWL)'TSWJ_?]:[&7TCX_4\NS3?/UI>;KV^Y7Z^[ +MO>KP(B[3A-B^<7G_XVOURY?[]>;+;4W=;4S7^_4>6-^W=W[FZ8O(W^EWNWYGS;KF\IW`Q<76_W+7WCS>/-[>??F&ZY7Z]@[^-Z_'5 +M_=;>O;HZXWLQY_G!L^6_$,X^X?9L$Z[/^MZ?>;X<1\G['1?N+KK%6!^JDT9/TFT?HENCYK[7%>?K%^ +M5994U2O7YE/]'OZ[7HA'0&J`]=Z_>O;:K6QU;!=#=/J'/O;ZOZ>W:K]/[Z]ZNB[>[48/;>X/_F.=^ +MGU^?B[>[4W/CO;EK>KLNWNZDYO9_"(L+6`YJ[EC,#?C42NN/.*.R/?N>(N*NZ,?!>*NZBX,_)= +M*.ZBY(Y\%XJ[*+DCWX7B+DKNR'>AN(N2._)=*.ZBY(Y\%XJ[*+DCWX7B;BBY +M(]\-BKNAY(Y\-RCNAHH[YZ<$=T/%G9/O!L7=4''GY+M!<3=4W#GY;E#<#15W +M3KX;%'=#Q9V3[P;%W:;BSLEW&\7=IN+.R7<;Q=VFY(Y\MU'<;4KNR'<;Q=VF +MY(Y\MU'<;4KNR'<;Q=VFY(Y\MU'<;4KNR'<;Q=VVY(Y\MU7<;4ONR'=;Q=VV +MXB[X*<'=MN(NR'=;Q=VVXB[(=UO%W;;B+LAW6\7=MN(NR'=;Q=VVXB[(=UO% +MW:[B+LAW.\7=KN(NR'<[Q=VNY(Y\MU/<[4KNR'<[Q=VNY(Y\MU/<[4KNR'<[ +MQ=VNY(Y\MU/<[4KNR'<[Q=U8^&Q5W8\D=^6Y4W(T5=P,_);@;*^X&\MVH +MN!LK[@;RW:BX&RON!O+=J+@;*^X&\MVHN!LK[@;RW:BX6_[Z6\^1[R;%W51Q +M-Y#O)L7=5')'OIL4=U/)'?EN4MQ-)7?DNTEQ-Y7\FQ=U4^FQ1W4\D= +M^6Y2W.U+[LAW>\7=ON2.?+=7W.TK[C;\E.!N7W&W(=_M%7?[BKL-^6ZON-M7 +MW&W(=WO%W;[B;D.^VRON]A5W&_+=7G&W_&](/4>^.RCN#A5W&_+=07%W*+DC +MWQT4=X>2._+=07%W*+DCWQT4=X>2._+=07%W*+DCWQT4=X>2._+=07%W++DC +MWQT5=\>2._+=47%WK+C;\E."NV/%W99\=U3<'2ONMN2[H^+N6'&W)=\=%7?' +MBKLM^>ZHN#M6W&W)=T?%W:GB;DN^.RGN3A5W6_+=27%W*KDCWYT4=Z>2._+= +M27%W*KDCWYT4=Z>2._+=27%W*KDCWYT4=Z>2._+=27%W+KDCWYT5=^>2._+= +M67%WKKC;\5."NW/%W8Y\=U;ZLN#M7 +MW.W(=V?%W:7B;D>^NRCN+A5W._+=17%W*;DCWUT4=Y>2._+=17%W*;DCWUT4 +M=Y>2._+=17%W*;DCWUT4=Y>2._+=17!GRP=Z#GQG:\&=K4ONP'>V%MS9NN)N +MY*>8.RO[NQ%\9ZJ_L[*_&\%WIOH[*_N[$7QGJK^SLK\;P7>F^CLK^[L1?&>J +MO[.ROQO!=Z;Z.RO[NQ%\9ZJ_L[*_&\%WIOH[*_N[$7QGJK^SLK\;P7>F^CLK +M^[L1?&>JO[.ROQO!=Z;Z.RO[NQ%\9ZJ_L[*_&\EWJK^SLK\;R7>JO[.ROYOX +M*<%=V=]-Y#O5WUG9WTWD.]7?6=G?3>0[U=]9V=]-Y#O5WUG9WTWD.]7?6=G? +M3>0[U=]9V=]-Y#O5WUG9WTWD.]7?6=G?3>0[U=]9V=]-Y#O5WUG9WTWD.]7? +M6=G?3>0[U=]9V=]-Y#O5WUG9WTWD.]7?6=G?3>0[U=]9V=_M^2G!7=G?[KOK.SO]N0[U=]9V=_MR7>JO[.RO]N3[U1_9V5_MR??J?[.ROYN3[Y3 +M_9V5_=V>?*?Z.RO[NSWY3O5W5O9W>_*=ZN^L[.\._)3@KNSO#N0[U=]9V=\= +MR'>JO[.ROSN0[U1_9V5_=R#?J?[.RO[N0+Y3_9V5_=V!?*?Z.RO[NP/Y3O5W +M5O9W!_*=ZN^L[.\.Y#O5WUG9WQW(=ZJ_L[*_.Y#O5']G97]W(-^I_L[*_NY` +MOE/]G97]W8%\I_H[*_N[`_E.]7=6]G='?DIP5_9W1_*=ZN^L[.^.Y#O5WUG9 +MWQW)=ZJ_L[*_.Y+O5']G97]W)-^I_L[*_NY(OE/]G97]W9%\I_H[*_N[(_E. +M]7=6]G='\IWJ[ZSL[X[D.]7?6=G?']4?V=E?WKOK.SO3N0[U=]9V=^=R'>JO[.ROSN1[U1_9V5_=R+?J?[. +MRO[N1+Y3_9V5_=V9GQ+KOK.SOSN0[ +MU=]9V=^=R7>JO[.ROSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9?*?Z.RO[ +MNS/Y3O5W5O9W9_*=ZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_.Y/O5']G97]W)M^I +M_L[*_N["3PGNRO[N0KY3_9V5_=V%?*?Z.RO[NPOY3O5W5O9W%_*=ZN^L[.\N +MY#O5WUG9WUW(=ZJ_L[*_NY#O5']G97]W(=^I_L[*_NY"OE/]G97]W85\I_H[ +M*_N["_E.]7=6]G<7\IWJ[ZSL[R[D.]7?^?)!FEOU.?#=]Z>8.T_]W7*?WJIS +M![YSU=]YZN]6,W>KA;M8\U/,G:?^;C5SM_J]S8'O7/5WGOJ[U36=7=#]=Z[Z +M.T_]73N[/@>^<]7?>>KO8`Y\YZJ_\]3?P1SXSE5_YZF_6^8>]#GPG:O^SE-_ +M]V"96[4Y\)VK_LY3?_=@YNY!YPY\YZJ_\]3?/9BY>]"Y`]^YZN\\]7N^CM/_=TR][#/D>]4 +M?^>IOWNXS'7NR'>JO_/4WSVKO//5W,$>^4_V=I_X.YLAWJK_SU-\M>^KM'RUSCCNZ_<]7?>>KO'LWK]4?^>IOWLT<_>H^4_V= +MI_[NT?7F[,AWJK_SU-^UL^MSY#O5WWGJ[V".?*?Z.T_]' +M]SGRG>KO//5WCY>YSAWY3O5WGOJ[QS-WCQMW=/^=J_[.4W_W>.;N<>..[K]S +MU=]YZN\>7_/9T?UWKOH[3_U=.[L^1[Y3_9VG_@[FR'>JO_/4W\$<^4[U=Y[Z +MNV7N29\CWZG^SE-_]V29:]S1_7>N^CM/_=V3F;LGG3ORG>KO//5W3V;NGG3N +MR'>JO_/4WSVYWIP=^4[U=Y[ZNW9V?8Y\I_H[3_T=S)'O5'_GJ;^#.?*=ZN\\ +M]7?+W-,^1[Y3_9VG_N[I,M>Y(]^I_LY3?_=TYNYIXX[NOW/5WWGJ[Y[.W#UM +MW-']=Z[Z.T_]W=-K/CNZ_\Y5?^>IOVMGU^?(=ZJ_\]3?P1SY3O5WGOH[F"/? +MJ?[.4W^WS#WK<^0[U=]YZN^>+7.-.[K_SE5_YZF_>S9S]ZQS1[Y3_9VG_N[9 +MS-VSSAWY3O5WGOJ[9]>;LR/?J?[.4W_7SJ[/D>]4?^>IOX,Y\IWJ[SSU=S!' +MOE/]G:?^;IE[WN?(=ZJ_\]3?/5_F.G?D.]7?>>KOGL_KO//5W[>SZ'/E.]7>>^CN8(]^I_LY3 +M?P=SY#O5WWGJ[Y:Y%WV.?*?Z.T_]W8MEKG%']]^YZN\\]7=.[(=ZJ_ +M\]3?O9BY>]&Y(]^I_LY3?_?B>G-VY#O5WWGJ[]K9]3GRG>KO//5W,$>^4_V= +MI_X.YLAWJK_SU-\M>^KN7RUSGCGRG^CM/_=W+F;N7C3NZ_\Y5 +M?^>IOWLY<_>R<4?WW[GJ[SSU=R^O^>SH_CM7_9VG_JZ=79\CWZG^SE-_!W/D +M.]7?>>KO8(Y\I_H[3_W=,O>JSY'O5'_GJ;][M>^KM7,W>O.G?D.]7?>>KO7EUOSHY\I_H[3_U=.[L^1[Y3_9VG_@[F +MR'>JO_/4W\$<^4[U=Y[ZNV7N=9\CWZG^SE-_]WJ9Z]R1[U1_YZF_>SUS][IQ +M1_??N>KO//5WKV?N7C?NZ/X[5_V=I_[N]36?'=U_YZJ_\]3?M;/K<^0[U=]Y +MZN]@CGRG^CM/_1W,D>]4?^>IOUOFWO0Y\IWJ[SSU=V^6N<8=W7_GJK_SU-^] +MF;E[T[DCWZG^SE-_]V;F[DWGCGRG^CM/_=V;Z\W9D>]4?^>IOVMGU^?(=ZJ_ +M\]3?P1SY3O5WGOH[F"/?J?[.4W^WS+WM<^0[U=]YU=\%W7_GJK_SJK\+NO_. +M57_G57\7=/^=J_[.J_XNZ/X[5_V=5_U=T/UWKOH[K_J[H/OO7/5W7O5W0??? +MN>KO7/1W[_H<^4[U=Y[ZNW?+7...[K]SU=]YZN_>S=R]Z]R1[U1_YZF_>S=S +M]ZYS1[Y3_9VG_N[=]>;LR'>JO_/4W[6SZW/D.]7?>>KO8(Y\I_H[3_T=S)'O +M5'\7RP=I;MWGP'>A^KOOG[C'W>*G=><.?!>JOXO4WZWGO77CCNZ_"]7?1>KO +MUC-WZ\8=W7\7JK^+U-^MK_GLZ/Z[4/U=I/ZNG5V?`]^%ZN\B]7A^KM(_9TM59YPY\%ZJ_ +MB]3?V[`=Z'ZNTC]G5UOS@Y\%ZJ_B]3?M;/K<^"[4/U=I/X.YL!WH?J[ +M2/T=S('O0O5WD?J[9<[['/E.]7>1^CM?YCIWY#O5WT7J[WSFSAMW=/]=J/XN +M4G_G,W?>N*/[[T+U=Y'Z.[_FLZ/[[T+U=Y'ZNW9V?8Y\I_J[2/T=S)'O5'\7 +MJ;^#.?*=ZN\B]7?+7/0Y\IWJ[R+U=[',->[H_KM0_5VD_BYF[J)S1[Y3_5VD +M_BYF[J)S1[Y3_5VD_BZN-V='OE/]7:3^KIU=GR/?J?XN4G\'<^0[U=]%ZN]@ +MCGRG^KM(_=TR-_0Y\IWJ[R+U=\,RU[DCWZG^+E)_-\S<#8T[NO\N5'\7J;\; +M9NZ&QAW=?Q>JOXO4WPW7?'9T_UVH_BY2?]?.KL^1[U1_%ZF_@SGRG>KO(O5W +M,$>^4_U=I/YNF=OT.?*=ZN\B]7>;9:YQ1_??A>KO(O5WFYF[3>>.?*?ZNTC] +MW6;F;M.Y(]^I_BY2?[>YWIP=^4[U=Y'ZNW9V?8Y\I_J[2/T=S)'O5'\7J;^# +M.?*=ZN\B]7?+W+;/D>]4?Q>IO]LNKO +MMC-WV\8=W7\7JK^+U-]MK_GLZ/Z[4/U=I/ZNG5V?(]^I_BY2?P=SY#O5WT7J +M[V".?*?ZNTC]W3*WZW/D.]7?1>KO=LM1 +M^KO=S-VN^4_U=I/YN=[TY._*=ZN\B]7?M[/H<^4[U=Y'Z.Y@CWZG^+E)_ +M!W/D.]7?1>KOEKFQSY'O5'\7J;\;E[G.'?E.]7>1^KMQYFYLW-']=Z'ZNTC] +MW3AS-S;NZ/Z[4/U=I/YNO.:SH_OO0O5WD?J[=G9]CGRG^KM(_1W,D>]4?Q>I +MOX,Y\IWJ[R+U=\O]4?Q>IOVMGU^?(=ZJ_B]3?P1SY3O5WD?H[ +MF"/?J?XN4G^WS+WO<^0[U=]%ZN_>+W.=._*=ZN\B]7?O9^[>-^[H_KM0_5VD +M_N[]S-W[QAW=?Q>JOXO4W[V_YK.C^^]"]7>1^KMV=GV.?*?ZNTC]'KO(O5WR]R'/D>^4_U=I/[NPS+7N*/[[T+U=Y'ZNP\S=Q\Z=^0[ +MU=]%ZN\^S-Q]Z-R1[U1_%ZF_^W"].3ORG>KO(O5W[>SZ'/E.]7>1^CN8(]^I +M_BY2?P=SY#O5WT7J[Y:YCWV.?*?ZNTC]W<=EKG-'OE/]7:3^[N/,WJOXO4WWU:YAIW=/]=J/XN4G_W:>;N +M4^>.?*?ZNTC]W:>9NT^=._*=ZN\B]7>?KC=G1[Y3_5VD_JZ=79\CWZG^+E)_ +M!W/D.]7?1>KO8(Y\I_J[2/W=,O>YSY'O5'\7J;_[O,QU[LAWJK^+U-]]GKG[ +MW+BC^^]"]7>1^KO/,W>?&W=T_UVH_BY2?_?YFL^.[K\+U=]%ZN_:V?4Y\IWJ +M[R+U=S!'OE/]7:3^#N;(=ZJ_B]3?+7-?^ASY3O5WD?J[+\M]4?SH_FY(_=W79:YS![[[_A1S +M-Z3^[NO,W=>%NV'-3S%W0^KOOL["+/9K8;-:K-=C?YG7^'__\__I5?X:^XO>\._ +MYN@?&+\WM[S@)KR;N2]WYGX(_G+G5Z[MSE-'ZW]<'\>;/[I_?/O\]HZ1-W0A +M3)_[0?29/B'?+/T#X_\-+#>7KMS].O^\9#=6Z^4OW-/-E>WKN^JOCR+F>V_W +M#U[?ZO;M_I3H[OZOMSMS7KS=U?VYGQ*]\_6\]R4L3N_S[:NC?\3[O_EBW%P= +M\B=_Y_X8N?\[]]><_[4BV/TTRP_/[>%'_8EO_WA[_[]?@\//P=_^#8HD%YJ! +#I0`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-bsd.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-bsd.qcow2.gz.uu new file mode 100644 index 000000000000..b27f56cb6bab --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-bsd.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-bsd.qcow2.gz +M'XL("+H[(U0``VEM9RTV,W@R-34M-#`Y-BUB.FD[F>FX_S=R +M_%E)6A3IY5SI7:A<:-UQY^Z_TP?3`]5\?9CJDZG:PC59'"BIUL)MLSA44CL+M\_B@I*Z +MLW#&SAW@2B5U-'`^H\H]KE)2WL)!%ET2XQXP[*BG+ +M.Q#>/2'.4?@>6=R"\>T&XEXQ3^AU8WH'P[A7AKABG +M]#NPO`/AW6O"O6&4="N^0<(%Q2K]#RSL4WI6$JQBG]#NTO$/A74VXAG%*OT/+.Q3>M81[ +MSSBEWZ'E'0KO/A#N(^.4?H>6=RB\^T2X:\8I_0XM[X+P;D.XSXQ3^EVPO`O" +MNR^$NV&!UJJ]ZXH]`_A;B=[%I:]_PQ\?^R5HSTP`VS^ +M!SA78<*UBTZX3!..&FR5HSUPNEF/WSWPO,)E'5>UK%P##ZWPS^WOZ83+!5S'41KH"NZWX`2W&>#B%>TX^.5P'=W>\_8?$@>XZ\3K<+./H_$>^Z`-F),M +M%Y8%&I$;KG.\M8MWX%UW%[=F_?HZKD^1&4;3G:G/3:<;KQK]TYU8CXB#S'3= +M&!>O&F)?\A)FSMYF6MU^X<5`N3,>N',C9+QS$PZ6;020_IM_@&MW,T%PLF#=('BW@&'^DE:>%"])HVN +M*]P,M9Z,/RYYA7LPNB:@GH'%*EA_K"=67[CE +&;;$%!0`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-bsd.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-bsd.vhd.gz.uu new file mode 100644 index 000000000000..9e1039688b42 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-bsd.vhd.gz.uu @@ -0,0 +1,17 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-bsd.vhd.gz +M'XL("`#&'50``VEM9RTV,W@R-34M-#`Y-BUB5LB`]_)6VQ"<*">WB/ +M.Q`1HGT`5`*J`E6"2JF=25"WD.4`IM,6;.K8?D*M/]Y+_7TX1?:I%RTL%MS* +M-R=[3$":23+`@B91.VI#[3#1S7:_/+SM'0XMSDTL%4B$U$#D8)Y!C?O^ZG4H +MX/I4+&;6?#H8D_H*TF?VEBA&ZNF.>A/Y[QFH"9AFM-U3!3E>NX(OV^>Q^.J) +M=/GC[M!X"><$\]/`QZT8+FG#T5%8\H*.(2F[;SF"NS._=8>3<^HH9\JQCDEG +MT\#)K/.>'8\SQ"7$"8B<934#GN,+G;[;H0STW)W1!T-W"\)E_OB8X?""N^#C +M7NVYS`9W(;RP>NNA.ATX&+O^SKARYQ+$W[DM#L,>!-B<+"8#S:AA/=U1/T;^ +MVP+1'E7!SCYT1U4HA=("@RDTP#*P0BQGD^VW6:BLPD`72<(%O$@2+N!%DG`! +>+Y*$"WB1)%S`BR3A@EXDE?F+(,3B!S97<3I\A^-+5O.X +M?#`B3JSAHL.RGL,=$IP,PCK19#RQJCA(U^_5!.X^/,<>IY:\"YE@;DHP&ZS> +M*G>QMG9@E]89N`,N@=E.)BCP5E_H_=N/W1`DW`7_8!QNB;B"ZO,$)U;"!8I[ +M0QPGRGT)5[)W''M7;5P,.;P9?[RY"*$WM\6);1N!:#I+.(%!:_R>%_BGG,X6 +MJ#K@9AFT7>\S$DP-QH'1^%TH,'LH;`H4]"3YZNO35=_7G[3"B.-M,YA<:"\D +MWA93@"CQ)^8=OQ/_[LZ7W?7C$G&Q5<4?*X-)UP&B1N%:&N[CZ?EAZ)T<)\F2 +M[''T,VU[(7"2O4.*4[=@G6M:(.\7V1#!9*M"G&8#J__6ML69C8]*.'S9+_P) +&SWLP!P`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-bsd.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-bsd.vmdk.gz.uu new file mode 100644 index 000000000000..3df9b01e40e9 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-bsd.vmdk.gz.uu @@ -0,0 +1,81 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-bsd.vmdk.gz +M'XL("`'&'50``VEM9RTV,W@R-34M-#`Y-BUBB#F<^\,FCB,'"((`AFW8K^;<8B'V[D(K!%F`/S[3,WU:9T2- +M>V"5S%VREE7%[NIAB?[J@%FV_CA7=*XH7#&XLG(9W/Q/Z\UE^;,QWXKXQ/6? +M]__Z\<2?KTZGZQ=K,O@H"4&FZ<38O,[U].*'ZUN]O=6]Z?EN7]J]YGF#=65_Z!?\*G:WV*:G3YX'+XI]WU\>\/OXZG_XZ/GQX^O'\';O?L +MS[;(7='ZY7C_[/FV,?R+9*Z"?PUW_=L_[M^%*S<[?;P\,IV/FAK6+[S_/00MKS4KG\< +M+T_C#Y\_CN_N?OOP/M;.GZTO6;LD:I9"Y:[,?:JP-5^^TF?TE\UR:N[ZZ\/3 +M+P_]]_,V/XUWIR\=TU6^=O,!-F%=ZZ[GD&KW9.=E7[_YW].\7S>$DWU@NF41 +MRR;FUR[/KJQ]KOD`\[EV>>[RQN5+^GG!\TX*>"=W_?#^]-U/#E7>%.[[;__Z +M'=,U<[K9O;S#NOYX#% +M//L'H6IK>M_$"O_$_&;+9;;O+319ZG6U/[Z +M7LHY%VX]Z?6@EZ,8ANYT&2X?G\9'?[SQ*#I_M0YAI_Y8B^=CW+Y.O9S4Y*\8 +M=WWG[AZ&^4Q]VG^/'WYCNGZ]C.=U^$NB70)S_V"^>I;T8WB%]8KQQ^33C4^/ +MGT_]YU\?W@_S&\V]8[IAK=V\G/DTUT7%-;U<5'S9N79W>%[:G)OI1E^B=5%- +M>&/,N=9U/%M!S+=:C +M"`O[?/HT]B%=GH4#G#;%6=?D+^7Y2EY7M&V@3Q\>EZ55^9WVX_SE[[*W]N/B +MYE=J_0<3KNFLUU=E+WZ?Y1I7B%%N$OK?8MGZ,>#T[?/Z*K^^2CQKC6K$:#?I +M?IY3?+S=;N4OL8MX=AK5BS$[Z?C9P%ZYAI5B%%N +MTNW5K@RUHV>M48T8[2;=7NVJ4#MZ=AK5BS$[6[A-K1L].H7HSAT&:[4#MZ3AKE +M[]@@((_WT_6A=O3,-:H0H]RDVZO=$&I'SUJC&C':3;J]VHVA=O3L-*H78SBT +MV2G4CIZ31OF[0FI7I-+56:@=/7.-*L0H-^EV:E>SW]&SUJA&C':3;J=V-?L= +M/3N-ZL48#FV6_8Z>DT;YNU)J5R;3L=_1,]>H0HQRDVZO=NQW]*PUJA&CW:3; +MJQW['3T[C>K%&`YMEOV.GI-&^;M*:EDX:Y>\:J5V32M=DH7;TS#6J$*/< +MI-NI7<-^1\]:HQHQVDVZG=HU['?T[#2J%V,XM%GV.WI.&N7O6JE=FTS'?D?/ +M7*,*,N8:58A1;M+MU8[]CIZU1C5BM)MT>[5COZ-GIU&]&,.AS;+? +MT7/2*'_72^WZ5+HV"[6C9ZY1A1CE)MU.[5KV.WK6&M6(T6[2[=2N9;^C9Z=1 +MO1C#HG4;T8PZ'-LM_1<](H?S=*[<9D.O8[>N8:58A1;M+MU8[]CIZU1C5BM)MT +M>[5COZ-GIU&]&,.AS;+?T7/2*'\W2>VF9#KV.WKF&E6(46[2[=6._8Z>M48U +M8K2;='NU8[^C9Z=1O1C#H0Q[OI+ME:N^B9:U0A1KE)MU.[ +M2^AWT;/6J$:,=I-NIW:7T.^B9Z=1O1C#H\NH=]!^!V4WT'XW8'-AGX' +MX7=0?@?A=T@BK4OH=Q!^!^5W$'Z')+^[A'X'X7=0?@?A=TCRNTOH=Q!^!^5W +M$'YW8+.AWT'X'93?0?@=DDBKRT+MA-]!^1V$WR')[SKV.^%W4'X'X7=(\KN. +M_4[X'93?0?C=@QWPF_@_(["+\[L%GV.^%W4'X'X7=((JT^"[43?@?E +M=Q!^AR2_Z]GOA-]!^1V$WR')[WKV.^%W4'X'X7<'-LM^)_P.RN\@_`Y)I-6S +MWPF_@_(["+]#DM_U['?"[Z#\#L+OD.1W/?N=\#LHOX/PNP.;9;\3?@?E=Q!^ +MAR32ZMGOA-]!^1V$WR')[WKV.^%W4'X'X7=(\KN>_4[X'93?0?C=@PWPF_@_(["+]#DM\- +M['?"[Z#\#L+O#FR6_4[X'93?0?@=DDAK8+\3?@?E=Q!^AR2_&]COA-]!^1V$ +MWR')[P;V.^%W4'X'X7<'-LM^)_P.RN\@_`Y)I#6PWPF_@_(["+]#DM\-['?" +M[Z#\#L+OD.1W`_N=\#LHOX/PNP.;9;\3?@?E=U%,!WDLZ=SZ)Z0;L[5VKTK* +M7_FG6#OWZNI&8WT@%GU@G"FLN_IC"==TUNN+\VW>WJ1?1)QO\_8F_2+B?)NW +M-^D7$>?;O+U)OX@XWS;1+R+.MTWTBXCS;1/](N)\VT2_B#C?-M$O(LZW3?2+ +MB/-M$_TBXGS;1+^(.-\VT2\BSK=-](N(\VT3_2+B?-M$OX@XWS;1+R+.MTWT +MBXCS;1/](N)\VT2_B#C?-M$O(LZW3?2+B/-M$_TBXGS;1+^(.-\VT2\BSK=- +M](N(\VT3_2+B?-M$OX@XWS;1+R+.MTWTBXCS;1/](N)\VT2_",ZW;?2+X'S; +M1K\(SK=M](O@?-M&OPC.MVWTB^!\VT:_",ZW;?2+X'S;1K\(SK=M](O@?-M& +MOPC.MVWTB^!\VT:_",ZW;?2+X'S;1K\(SK=M](O@?-M&OPC.MVWTB^!\VT:_ +M",ZW;?2+X'S;1K\(SK=M](O@?-M&OPC.MVWTB^!\VT:_",ZW;?2+X'S;1K\( +MSK=M](O@?-M&OPC.MVWTB^!\VT:_",ZW;?2+X'S;1K^(.-^FYYOTBXCS;7J^ +M2;^(.-^FYYOTBXCS;7J^2;^(.-\VT2\BSK=-](N(\VT3_2+B?-M$OX@XWS;1 +M+R+.MTWTBXCS;1/](N)\VT2_B#C?-M$O(LZW3?2+B/-M$_TBXGS;1+^(.-\V +MT2\BSK=-](N(\VT3_2+B?-M$OX@XWS;1+R+.MTWTBXCS;1/](N)\VT2_B#C? +M-M$O(LZW3?2+B/-M$_TBXGS;1+^(.-\VT2\BSK=-](N(\VT3_2+B?-M$OPC. +MMVWTBQA-]8L83?6+&$WUBQA-]8L83?6+&$WUBQA-]8L83?6+&$WUBQA-]8L8 +M3?6+&$WUBQA-]8L83?6+&$WUBYBRS%"_B,E4OXC)5+^(R52_B,E4OXC)5+^( +MR52_B,E4OXC)5+^(R52_B,E4OXC)5+^(R52_B,E4OXC)5+^(R52_>,ZRS%"_ +M>+[Y+N&#Z6XWN^H#BV5]Z[>#WOZ]_\3UZ]/VOYAP^8+=LO9?=%I6KCD?7>%/ +MW_SXRH:+L]F&UW0W7Y[\,EWD7=->NK](.M_@)_'/SW;Q2KH_G^2; +MHHOE"W9W5Z=SBF.;-?[RY&+Y$EOUU7/V'<:#'WZ>?_'>B.?KGM?7WB[CO-GN +M[ZS/W6[7-U']^E`]C\V[=6>[;IO.-U$]S\T1)JKWU>WJ>N/#N/DJUH/O7)]D +G^\Y=TYUM&T&U=)9U^'_[]_X3UV]/V__6A,62\(O_`X=39?HNIWL_>?C]]/6??_O[^_O?OCZZ +M&Y/S3YYR/^^W,O=@Z[]U3K\_M9S.XR_,??LN:.[>J[/?\>KNO=GCW-6CNS>+ +MGU,V:`\&3VGNG%Z?D--K?NWUW;JW*W>G]^>]725OM_VUP7^XUZ>_"Y9?>GV_ +M\^O;P<'?RNMKX%,]FQL>S%T.;[>%3XUL;OHIS'KNX%,SFUN"N1X^M;*Y+9@; +MX%,[GI.??&WOYD;XE+`YA7.G,C?!IXS--0_FSFGNMLS-\"GRN1#'7?Y<5.X6 +M^!3A3D+N5O@4X4Y"[C;X%.%.0NYV^!3A3B+N!#]%N-.(.T&*4L:=1MP),K(R +M[C3B3I#OE'&G$7>"?*>,.XVX$^0[9=QIQ)T@WRGC3B/N!/E.&7<:XLY`[Y +MSAAW%G&G^"G"71-QI\AW#>.NB;A3Y+N&<==$W"GR7<.X:R+N%/FN8=PU$7>* +M?-.NB[@SY+N.<==%W!GR7<>XZR+N#/FN8]QU$7>&?-L9='W*'?-\FQMT4<=ZFB+L6^6YBW$T1=RWRW<2XFR+N6N2[B7$WA=PAWTV,N_R?2?D<\MW, +MN)M#[I#O9L;=''*'?#&W"'?K8R[->0. +M^6YEW*TA=\AW*^-N#;E#OEL9=VO('?+=RKA;0^Z0[U;&W1IQU^.G"'ZVB+L>^6YCW&T1=SWRW<:XVR+N>N2[C7&W1=SUR'<;XVZ+N.N1[S;& +MW19QUR/?;8R[+>0.^6YCW.TA=\AW.^-N#[E#OML9=WO('?+=SKC;0^Z0[W;& +MW1YRAWRW,^[VD#ODNYUQMX?<(=_MC+L]XF[`3V'N)/^`SP'?R9EP)^>(NP'X +M3LZ$.SE'W`W`=\+Z0/']W8&[`?A.6'\G87\W`-\)Z^\D[.\&X#MA_9V$_=T` +M?">LOY.POQN`[X3U=Q+V=P/PG;#^3L+^;@"^$];?2=C?#LOY.POQOQ4X2[L+\;D>]8?R=A +M?SOO).SO1N0[ +MUM])V-^-R'>LOY.POQN1[UA_)V%_-R+?L?Y.POYN1+YC_9V$_=V(?,?Z.PG[ +MNQ'YCO5W$O9W(_(=Z^\D[.]&Y#O6WTG8WTWX*<)=V-]-R'>LOY.POYN0[UA_ +M)V%_-R'?L?Y.POYN0KYC_9V$_=V$?,?Z.PG[NPGYCO5W$O9W$_(=Z^\D[.\F +MY#O6WTG8WTW(=ZR_D["_FY#O6'\G87\W(=^Q_D["_FY"OF/]G83]W81\Q_H[ +M"?N["?F.]7<2]G<3\AWK[R3L[V;\%.$N[.]FY#O6WTG8W\W(=ZR_D["_FY'O +M6'\G87\W(]^Q_D["_FY&OF/]G83]W8Q\Q_H["?N[&?F.]7<2]G]8?R=A?SOO +M).SO%N0[UM])V-\MR'>LOY.POUN0[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V" +M?,?Z.PG[NQ4_1;@+^[L5^8[U=Q+V=ROR'>OO).SO5N0[UM])V-^MR'>LOY.P +MOUN1[UA_)V%_MR+?L?Y.POYN1;YC_9V$_=V*?,?Z.PG[NQ7YCO5W$O9W*_(= +MZ^\D[.]6Y#O6WTG8WZW(=ZR_D["_6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83] +MW8:?(MR%_=V&?,?Z.PG[NPWYCO5W$O9W&_(=Z^\D[.\VY#O6WTG8WVW(=ZR_ +MD["_VY#O6'\G87^W(=^Q_D["_FY#OF/]G83]W89\Q_H["?N[#?F.]7<2]G<; +M\AWK[R3L[S;D.];?2=C?;[" +M_FY'OF/]G83]W8Y\Q_H["?N['?F.]7<2]G<[\AWK[R3L[W;D.];?2=C?[]8?R=A?[^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V +M=SOR'>OO).SO=N0[UM])V-_MR'>LOY.PO]N1[UA_)U%_9V?\%.9.\P_PISIZZ_R_?]G4YE#OA.67^GKK\[)>Y.MV4.^$Y9?Z>NOSLE[DZ_E3G@ +M.V7]G;K^[G0YG!WPG;+^3EU_5\ZNS@'?*>OOU/5W8`[X3EE_IZZ_`W/`=\KZ +M.W7]79Y[7.>`[Y3U=^KZN\=YKG('?*>LOU/7WSU.W#VNW`'?*>OOU/5WCQ-W +MCRMWP'?*^CMU_=WCR^'L@.^4]7?J^KMR=G4.^$Y9?Z>NOP-SP'?*^CMU_=UQ +M#MU_IZR_4]??Y;DG=0[YCO5WZOJ[)WFN<(?NOU/6WZGK[YXD[IX4[M#]=\KZ +M.W7]W9/$W9/"';K_3EE_IZZ_>W(YG!WR'>OOU/5WY>SJ'/(=Z^_4]7=@#OF. +M]7?J^CLPAWS'^CMU_5V>>UKGD.]8?Z>NOWN:YRIWR'>LOU/7WSU-W#VMW"'? +ML?Y.77_W-''WM'*'?,?Z.W7]W=/+X>R0[UA_IZZ_*V=7YY#O6'^GKK\#<\AW +MK+]3U]\=Y]#]=\KZ.W7]79Y[5N>0[UA_IZZ_>Y;G"G?H_CME_9VZ_NY9XNY9 +MX0[=?Z>LOU/7WSU+W#TKW*'[[Y3U=^KZNV>7P]DAW['^3EU_5\ZNSB'?L?Y. +M77\'YI#O6'^GKK\#<\AWK+]3U]_EN>=U#OF.]7?J^KOG>:YRAWS'^CMU_=WS +MQ-WSRAWR'>OOU/5WSQ-WSRMWR'>LOU/7WSV_',X.^8[U=^KZNW)V=0[YCO5W +MZOH[,(=\Q_H[=?W=<0[=?Z>LOU/7W^6Y%W4.^8[U=^KZNQ=YKG"'[K]3UM^I +MZ^]>).Y>%.[0_7?*^CMU_=V+Q-V+PAVZ_TY9?Z>NOWMQ.9P=\AWK[]3U=^7L +MZASR'>OOU/5W8`[YCO5WZOH[,(=\Q_H[=?U=GGM9YY#O6'^GKK][F>NORMG +M5^>0[UA_IZZ_`W/(=ZR_4]??'>?0_7?*^CMU_5V>>U7GD.]8?Z>NOWN5YPIW +MZ/X[9?V=NO[N5>+N5>$.W7^GK+]3U]^]2MR]*MRA^^^4]7?J^KM7E\/9(=^Q +M_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/(=ZR_4]??Y;G7=0[YCO5WZOJ[ +MUWFN$.W7^GK+]3U]]=)>ZN"G?H_CME_9VZ_N[J +MOOP!SR'>OOU/5W8`[YCO5WZOJ[//>FSB'? +ML?Y.77_W)L]5[I#O6'^GKK][D[A[4[E#OF/]G;K^[DWB[DWE#OF.]7?J^KLW +ME\/9(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_.\ZA^^^4]7?J^KL\][;. +M(=^Q_DY=?_S0[YC_9VZ_JZ<79U#OF/]G;K^#LPAW['^3EU_!^:0[UA_IZZ_ +MRW/OZASR'>OOU/5W[_)OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ.R7]W8Y0[YC_9VZ_NY#XNY#Y0[YCO5WZOJ[#XF[#Y4[Y#O6WZGK[SY<#F>'?,?Z +M.W7]73F[.H=\Q_H[=?T=F$.^8_V=NO[N.(?NOU/6WUG^@9L[USG@.V/]W;=? +M>,!=]M.Y<(?NOS/6WYGK[\YI[URX0_??&>OOS/5WY\3=N7"'[K\SUM^9Z^_. +ME\/9`=\9Z^_,]7?E[.H<\)VQ_LYOO]'(X.^0[UM^9Z^_*V=4YY#O6WYGK[\`<\AWK[\SU=V`.^8[U=^;ZNSQG +M=0[YCO5WYOH[RW.5.^0[UM^9Z^\L<6>5.^0[UM^9Z^\L<6>5.^0[UM^9Z^_L +MOOP!SR'>OOS/5WQSET_YVQ_LYS0[YC_9VY_JZ<79U#OF/]G;G^#LPAW['^SEQ_!^:0[UA_9ZZ_RW-M +MG4.^8_V=N?ZNS7.5.^0[UM^9Z^_:Q%U;N4.^8_V=N?ZN3=RUE3OD.];?F>OO +MVLOA[)#O6']GKK\K9U?GD.]8?V>NOP-SR'>LOS/7WQWGT/UWQOH[<_U=GNOJ +M'/(=Z^_,]7==GBO[0_7?&^CMS_5V7N.L*=^C^.V/] +MG;G^KKLZ0[UA_9ZZ_ZQ-W?>4.^8[U=^;ZNSYQUU?ND.]8?V>N +MO^LOA[-#OF/]G;G^KIQ=G4.^8_V=N?X.S"'?L?[.7']WG$/WWQGK[\SU=WEN +MJ'/(=ZR_,]??#7FN<(?NOS/6WYGK[X;$W5"X0_??&>OOS/5W0^)N*-RA^^^, +M]7?F^KOAOOP!SR'>OOS/5W8`[YCO5WYOJ[ +M/#?6.>0[UM^9Z^_&/%>Y0[YC_9VY_FY,W(V5.^0[UM^9Z^_&Q-U8N4.^8_V= +MN?YNO!S.#OF.]7?F^KMR=G4.^8[U=^;Z.S"'?,?Z.W/]W7$.W7]GK+\SU]_E +MN8]U#OF.]7?F^KN/>:YPA^Z_,];?F>OO/B;N/A;NT/UWQOH[<_W=Q\3=Q\(= +MNO_.6']GKK_[>#F<'?(=Z^_,]7?E[.H<\AWK[\SU=V`.^8[U=^;Z.S"'?,?Z +M.W/]79[[5.>0[UA_9ZZ_^Y3G*G?(=ZR_,]???4KI +MNOP-SR'>LOS/7WQWGT/UW +MQOH[<_U=GOMN +MOP-SR'>LOS/7W^6Y+W4.^8[U=^;ZNR]YKG*'?,?Z.W/]W9?$W9?*'?(=Z^_, +M]7=?$G=?*G?(=ZR_,]???;D0[UA_9ZZ_N\ESE3OD.];?F>OO;A)W-Y4[ +MY#O6WYGK[VX2=S>5.^0[UM^9Z^]N+H>S0[YC_9VY_JZ<79U#OF/]G;G^#LPA +MW['^SEQ_=YAKSO@IS%V3?^#F;NL<\%W#^KO&]7>W>>Y4YH#OOCV%N6M; +MN+N]+7/`=PWK[QK7W]TF[FY_*W/`=PWK[QK7W]U>#F>'_KSM0)_Y[_P]2_O'_Z5 +M!_L?G]VV/S7MJ>U.@_[J*_S/7_\-OKX]^NS^?V_X;@Y\=A_.Y1=[N__C>W/7[>[_?]NBS6^>^^VI#OT#?[)_\V>T/]T/> +M_SK_N$+93N?\GU/[D]>W^GX=G_\^T#_\)^7>W,:O-W3 +MP[FYF`5\"8/3NSZ^.O3GT?^1+\;AEL-?_.1^'WGXR;V;TS]7!,,/LWS_76P" +A?^>_\/4?[Q_^=3?8I,$_[02;;_2=SX_^!PM'3SM0J``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-ebr.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-ebr.qcow2.gz.uu new file mode 100644 index 000000000000..304b69423447 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-ebr.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-ebr.qcow2.gz +M'XL("%[N+50``VEM9RTV,W@R-34M-#`Y-BUE8G(N<6-O=S(N;W5T`*V8VY+3 +M,`R&[_[@`KA.3T_1X=FI:R5V%"G>=M)V,NVX_S=R +M_%E-6A3A84QIC:N,:\QA8TZ?Z04F^3!\F>.O[S\6Z>-X$V"V4%+"P'+?XP:L +M?Q$'&JZPXP$KXY+J4,!!EQJ#-4)*\\[FO6N% +ME.:=S7NW$5*:=S;OW59(:=[9O'<[(:5Y!XIW)N+V0DKS#IAWCPCW..(.0DKS +M#IAW3PCWM,=9*:5Y!\R[9X1['G%"OP/-.V#>O2#@>0?,N]>$>Q-Q0K\#S3M@WKT=>6>%?@>:=\B\>T>L(N*$?H>:=\B\LX2# +MB!/Z'6K>(?,.">^0>;Q]Q0K]#S3MDWGT@W,>($_H=:MXA\^X3X581)_0[U+QSS+LUX3Y'G-#OG.:= +M8]Y](=Q=Q`G]SFG>.>;=5\)]ZW$@I7KOBD)^$>Y^M&=AWNM/%Z^/K7#4!R:` +M]27`J0H#KIEUPF78&Q<"Y0D'G-\;83)MV9ELR6?*;VW<%6E]ZV#S*L7MYI[N +MX3)@69JV'0%_=_7!9!F7U[?<^V&_*UOAJ`\<[Q;#9P>LP[\#2[_)RLK4\-`* +M_][_$=:WGN^&+^#T?P=HH"NX[X@CW#K!^0N,0_+-=%L-O$O?)[C5(G;F$V[R +MWP%_R[.7!M3)EO/*4O>]I;UOB+H?6W:EW*^OB?4)O04&TYVHSXRG +MZW_$^YMMMAX>!YGIFB%NTW<680DS9V\UKFX[\V)8OC,>N',]9+AS`P[F;03- +DN;.<##Q]:WS4!XX_%\-G`#H"SG8&7>5_>V_^`UMI__/2%``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-ebr.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-ebr.raw.gz.uu new file mode 100644 index 000000000000..024a0b2549c3 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-ebr.raw.gz.uu @@ -0,0 +1,12 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-ebr.raw.gz +M'XL("%[N+50``VEM9RTV,W@R-34M-#`Y-BUE8G(NC:,F="V`Z,*X[^GOJV@140\'(`G()\@I*'%7X>;P#^56,QPK8 +MX,0>;A)L*BB$JRQZ:MK(B>#+V_&P9M+$/?F&IR(^Q#.ZHW^FKAE@/@*CG2"] +,?(PE/\L2J-?E!@`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-ebr.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-ebr.vhd.gz.uu new file mode 100644 index 000000000000..4a2ad29f823b --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-ebr.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-ebr.vhd.gz +M'XL("%_N+50``VEM9RTV,W@R-34M-#`Y-BUE8G(N=FAD+F]U=`"METUOXR`0 +MAN_Y%2/UUH.%QX#=2R)5S9Y7JMJ>L6M7/>R'FCWDX!^_C(%D\%>:EI@@K&$> +MWH$!"R'<#T`7H#O0+6A%[5*"OH.R`K!&7W"H<_\*??/G=]O\>S]F_M=O'"P7 +MW"MV)W\L0-I!2D!#@^A7:D,?,-G-_NWV_==;P*''A8&E!HF@+$1.QJG$21V1 +M?MP_/HS5%5-U9R\W3M=!T;$>!5>793N.D];+]J>BH9.#S%"BE\C`<9$Z)49> +M3.;L:W.W&KX5+%9L8I:T%Z!Q*I+9-FS`/DV)3Y7CX:SX.[4@? +M+J2*9HLQMLGE<-&G"H;.7H$D@6OAPD`YC'$SJ?*MV=.QG_0-.PE"!0,.X<>S +M=T8!UZ=SL3+GRXNQJ,^LQO6%@.OZ>N#*[J@;OSL$&$4U[=+<[U7OW]CW=D;? +MSFW;+<>]I@ZWNPZH%!@S`3X%?4WBY:@J,MNS4YB9>MG0WV?Q9KBM^P>< +M7%-'9T([9U@,5B5.%E.-_/@Z0]Y"7H"HO`UCX&E]X:SO;BH#HW!7],$T7$.X +M,NZ?,QQ>"!=B7'TZ66:6\,+L;:?JFL2+48]WQB=W+D'BG>MPF/8@,,/)8C/0 +M]IK6RX;^9Q8_#HC^4Y3LVX;^,$VF4'I@,H46V"96:-)^/[17F.BB0+B$%P7" +D);PH$"[A18%P"2\*A$MX42!=*5=O9<7&4H>W2H8-_?#EC',[&>508C$`'G^_% +MF3'_`+@WV><%[6KTM(OEHJ/QP_U`G@1Z7(VG.&ZK%(Y%@TLNX8+"/H-2N&V$*YRPB7;Z3.Q/Q7D7SR/YNI=G7F8/#QS;CQYB*$WER/$WD+P;JK+"X#W:[I +M."]HGU>T>:#L@=D\:/I_FRY`-Z`M:(7S4H)>0VEBH*"9U-;?7[;^.?W&$48< +M]\4@V?&\*/"VZ!)$A1_1'SB/]'O8'Y>GSV/`A5(5/BPU.ETYB)R8:ZBY3[N7 +MQ[%VQ=1)AGB/HYYQV7.&$^]M8YPIS.G +.BOOO+OX`/$*Q[A`)```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-ebr.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-ebr.vmdk.gz.uu new file mode 100644 index 000000000000..3ad6aa6f77fa --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-ebr.vmdk.gz.uu @@ -0,0 +1,84 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-ebr.vmdk.gz +M'XL("%_N+50``VEM9RTV,W@R-34M-#`Y-BUE8G(N=FUD:RYO=70`K5S1;N3& +M$7SW5PSDMSPL6,LEN7PX.W'.`8(@@!$[]FO(Y3`68M\==$*0`_3QX9!3HR)% +M'FFK=:L#^]A=V]U#M735!679].'3D]?3&`(41*"3.'$F+W/TVGQ0;CSYZ)F-X;7>1[L*%P+D$Y&9PQ4I-F\5^+KL_?!&;%_++0P[#\9:U +MJW)7MM%T93':N:O.X[W,58-3/P!^Z=[>?_R/>^L_WA[N/SR^C_F=P]D.SIW@#`45I7A(MP(<'6`*+W+.Y_#-H__A +MTP?_YN[7]^]2[\+9AI;5(]!U;%3NBCQ`Q=)"^XJ`&!Z;\=3;)#VD_?_N]QJ-=U\63O"3Y;G+KRX?X8>$ATHN"$[NZ?V[TS]^`X)#B%#0;.:BJG^8OE8NJ?OOW5WH<@??O;C$TBX>OHR"\[3.6`TS^$B=FV" +M#T/L$FZ,)^O>-H^-^Z;YZ$]?OGW[33K9)A1[&5]#:CZ@E!-T>+['=@Z-FTYZ +M.NCQ*+JN/35=\^'1/X3C34?1AJ>UBY6&8[T\'^/\?:KQI/KPQ+BG-^[NOAO. +M-,#^V[__E7"WZ3$>\@B/1#T&YN%B>'I&>!_?87IBPC$%./_X\.ET^_3+_;MN +M^$)S;PC73;T;TAE.7QW(5\ +M>!7A%;OP].GTLV^Z(2UW=RZ*NW04_?(HM$6++DP'/?1B.HJ8V*?31W^+<'D6 +M#["?-6?**3S*PY,\930?H(_O'\;4ROQ.YW&^_%[VVGE\>?$MM?J=@!.<=7YE +MMO?]C*]\!N@$+'O.KPSY7<2ST*A2C&H&-_PT'8:Y<7H#\%=8HOX`PKD>FPJC5QO)#BWZ%T1>T?/0J-*,:H9 +MW%;ORM@[>M8:U8C1KF:W++:*O:-GIU%>C/X0W#7VCC^`0:['WM'(L[6?\I:] +MJV/OZ%EH5"E&-8/;ZET3>T?/6J,:,=K5[);%MK%W].PTRHO1'X*[Q=YQK$"N +MQ][1R/7&9N^ZV#MZ%AI5BE'-X+9ZYV/OZ%EK5"-&NYK=LM@^]HZ>G49Y,?HC +M<%46>W>1WO%Z[!V-7&]L]:[BO*-GH5&E&-4,;J-W%><=/6N-:L1H5[-;%LMY +M1\].H[P8_2$XSKM">L?KL74?/6J,:,=K5 +M[);%\7KL'8U<;VSVCO..GH5&E6)4,[BMWG'>T;/6 +MJ$:,=C6[9;&<=_3L-,J+T1^"X[SCCTZ0Z[%W-'*]L=D[SCMZ%AI5BE'-X+9Z +MQWE'SUJC&C':U>R6Q7+>T;/3*"]&?P3NFL7>7:5WO!Y[1R/7&UN]NW+>T;/0 +MJ%*,:@:WT;LKYQT]:XUJQ&A7LUL6RWE'STZCO!C](3C.NUIZQ^NQ=S1RO;'9 +M.\X[>A8:58I1S>"V>L=Y1\]:HQHQVM7LEL5RWM&STR@O1G\(CO..__&"7(^] +MHY'KC<=[1L]"H4HQJ!K?5.\X[>M8:U8C1KF:W+);SCIZ=1GDQ^D-PG'=D +M+2'78^]HY'ICLW><=_0L-*H4HYK!;?6.\XZ>M48U8K2KV2V+Y;RC9Z=17HS^ +M"%R=Q=[=I'>\'GM'(]<;6[VK.>_H66A4*48U@]OH7A8:58I1S>"V>L=Y1\]:HQHQ +MVM7LEL5RWM&STR@O1G\(CO/.2^]X/?:.1JXW-GO'>4?/0J-*,:H9W%;O.._H +M66M4(T:[FMVR6,X[>G8:Y<7H#\%QWO72.UZ/O:.1ZXW-WG'>T;/0J%*,:@:W +MU3O..WK6&M6(T:YFMRR6\XZ>G49Y,?HC<$TV]2[MW"#7H7?)R/7&5N^:..^2 +M9Z%1I1C5#&ZC=TV<=\FSUJA&C'8UNV6Q<=XESTZCO!C](;@X[R#\'92_@_!W +MV.7OFCCO(/P=E+^#\'?8Y>^:..\@_!V4OX/P=RO9+8N-\P["WT'Y.PA_=P`N +MSCL(?P?E[R#\'7;YNR;..PA_!^7O(/P==OF[)LX["'\'Y>\@_-U*=LMBX[R# +M\'=0_@["WQV`B_,.PM]!^3L(?X==_JZ)\P["WT'Y.PA_AUW^KHGS#L+?0?D[ +M"'^WDMVRV#CO(/P=E+^#\'?[<&T6>R?\'92_@_!WV.7O6LX[X>^@_!V$O\,N +M?]=RW@E_!^7O(/S=2G;+8CGOA+^#\G<0_NX`'.>=\'=0_@["WV&7OVLY[X2_ +M@_)W$/X.N_Q=RWDG_!V4OX/P=RO9+8OEO!/^#LK?0?B[`W"<=\+?0?D["'^' +M7?ZNY;P3_@[*WT'X.^SR=RWGG?!W4/X.PM^M9+^PR]^UG'?"WT'Y.PA_MY+=LEC..^'OH/P= +MA+_;A[MEL7?"WT'Y.PA_AUW^[L9Y)_P=E+^#\'?8Y>]NG'?"WT'Y.PA_MY+= +MLEC..^'OH/P=A+\[`,=Y)_P=E+^#\'?8Y>]NG'?"WT'Y.PA_AUW^[L9Y)_P= +ME+^#\']NG'?"WT'Y.PA_MY+=LEC..^'OH/P=A+\[`,=Y)_P=E+^#\'?8Y>]NG'?" +MWT'Y.PA_AUW^[L9Y)_P=E+^#\'_ZSCOA+^#\G<0_FXENV6QG'?"WT'Y.PA_=P". +M\T[X.RA_!^'OL,O?=9QWPM]!^3L(?X==_J[CO!/^#LK?0?B[E>R6Q7+>"7\' +MY>\@_-T!.,X[X>^@_!V$O\,N?]=QW@E_!^7O(/P==OF[CO-.^#LH?P?A[U:R +M6Q;+>2?\'92_@_!W!^`X[X2_@_)W$/X.N_Q=QWDG_!V4OX/P=]CE[SK..^'O +MH/P=A+];R6Y9+.>=\'=0_@["W^W#^6SJ79+@0:Y'&2.-7&\\C4T;/MWPF;EG +MN#CO5A5]*_^4>N?6LWNAQ3\&][+826Z(46Z8-A%3N;\/<((SED/B&KN^#WA$ +M#HFT+N?K57)(I'4Y7Z^20R*MR_EZE1P2:5UN(H=$6I>;R"&1UN4F;R"&1UN4F;R"&1UN4F;R"&1 +MUN4F;R"&1UN4F; +MR"&1UN4F$-Y5#PIO*(>%-Y9#P +MIG)(>%,Y)+RI'!+>5`X);RJ'A#>50\*;RB'A3>60\*9R2/199BB'1&\JAT1O +M*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\J +MAT1O*H=$;RJ'/&=99BB'/&>F-_X?(^F'DO<+?!]BOY?3W\&3Z^4KC.NMS^MP$6A6N:%X#_9'[GSZ;QV_.K +MQO]=3+]*]N7?VS>>OCG-_Q#P.C[.115^*VY1NNOY:(8_??OC(L,)SDSN.L'M +M/LZ)M.RWX+X6N/#MNQ?/V2_NUN=.KP7NJ^F3<)?/9:?[I&/%&O^F[6MV7<3I +M.8=O$X&]XW_*SG/`=+[N.;_Z91KG6;F?R<^]+#=\B]3?-:OG,9NJ&^6Z.5R; +M)LO*$>YT[ZN7V=V,#P/+KXR#7[D!9/Z5.\&=;0=!/4Z62:3Q\N_M&T_?G>9_ +7)L!+!#3KX"7\'I'LB_\#:C6@$!Y@```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu new file mode 100644 index 000000000000..624c3269a491 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu @@ -0,0 +1,132 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-gpt.qcow.gz +M'XL(",8S(E0``VEM9RTV,W@R-34M-#`Y-BUG<'0N<6-O=RYO=70`K9W;;AS7 +MM47?_16ENT1)5*^UJJJK=$^`!,B;$YSS=@Z0NCX&G7=]?-CDOI"KY]2*(=J$ +M(4.HB>ZMP4'9'MX\'.[^:)I.FK9OVK'9Y^;F[].'-/?^YN%'\^/O?_W;]?T_ +M?OQV-R:'GSSE_K[51M/<@ZT_-V5.ST\MS6'\+^9N/@3-W7MU]@=>W;TW>SEW +M]=O=F\7/*1NT!X--FCNDUR?D]-K_[O5]=V]7[D[O\=ZNDK?;L<'^P>#O:>Z? +MZ?4I>;M'-C<\F#NYMZOD[8YL;OHI+$I@F=G<$LRU\*F5S6W!7`>?VO&<_.37 +M]FZNAT\)FX.?M]=-F3O"IXS-M0_F#M<9Z#PWP*<(=Q)R-\*G"'<2,.PNY0[XSQIV%W"'?&>/.0NZ0[XQQ9R%WR'?&N+.0.^0[ +M8]RU(7?(=RWCK@VY0[YK&7=MQ)WBIPAW;<2=(M^UC+LVXDZ1[UK&71MQI\AW +M+>.NC;A3Y+N6<==&W"GR7*?-XZT/ND.]ZQET?.NC[@S +MY+N><7>,N#/DNR/C[AAQ9\AW1\;=,>0.^>[(N#N&W"'?'1EWQY`[Y+LCX^X8 +MZFB+L. +M^6YBW$T1=QWRW<2XFR+N.N2[B7$W1=QUR'<3XR[_9T@^AWPW,^[FB+L.^6YF +MW,TA=\AW,^-N#KE#OIL9=W/('?+=S+B;0^Z0[V;&W1QRAWPW,^[FD#ODNYEQ +MMX3<(=\MC+LEY`[Y;F'<+1%W/7Z*<+=$W/7(=POC;HFXZY'O%L;=$G'7(]\M +MC+LEXJY'OEL8=TO$78]\MS#NUHB['OEN9=RM$7<]\MW*N%M#[I#O5L;=&G*' +M?+\VQMT6 +M<7=$OML8=WO$W1'Y;F?<[1%W1^2[G7&WA]PAW^V,NSWD#OEN9]SM(7?(=SOC +M;@^Y0[[;&7=[R!WRWLOY.POQN`[X3U=Q+V=P/PG;#^3L+^;@"^$];?2=C?#OO).SO1N0[UM])V-^-R'>LOY.POQN1[UA_)V%_-R+?L?Y. +MPOYN1+YC_9V$_=V(?,?Z.PG[NQ'YCO5W$O9W(_(=Z^\D[.]&Y#O6WTG8WXW( +M=ZR_D["_&Y'O6'\G87\W(M^Q_D["_FY$OF/]G83]W8A\Q_H["?N["3]%N`O[ +MNPGYCO5W$O9W$_(=Z^\D[.\FY#O6WTG8WTW(=ZR_D["_FY#O6'\G87\W(=^Q +M_D["_FY"OF/]G83]W81\Q_H["?N["?F.]7<2]G<3\AWK[R3L[R;D.];?2=C? +M3]8?R=A?SOO).SO9N0[UM]) +MV-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYNP4\1[L+^;D&^8_V=A/W=@GS' +M^CL)^[L%^8[U=Q+V=POR'>OO).SO%N0[UM])V-\MR'>LOY.POUN0[UA_)V%_ +MMR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W$O9W"_(=Z^\D[.\6Y#O6 +MWTG8WRW(=ZR_D["_6Y#O6'\G87^WXJ<(=V%_MR+?L?Y.POYN1;YC_9V$_=V* +M?,?Z.PG[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6WTG8WZW(=ZR_D["_6Y'O6'\G +M87^W(M^Q_D["_FY%OF/]G83]W8I\Q_H["?N[%?F.]7<2]GOO).SO +M-N0[UM])V-_M^"G"7=C?[]8?R=A?[^8_V= +MA/W=CGS'^CL)^[L=^8[U=Q+V=SOR'>OO).SO=N0[UM])V-_MR'>LOY.PO]N1 +M[UA_)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.\T_<'--G0.^NWD*NO\OW +MZ365.^`[9?V=NOZN2=PUF3L[X*OOU/5WSL +MOU/7WSW)).Z>5.Z`[Y3U=^KZNR>)NR>5.^`[9?V=NO[N +MR>GB[(#OE/5WZOJ[OO\MS3 +M.H=\Q_H[=?W=TSQ7N4.^8_V=NO[N:>+N:>$.W7^GK+]3U]\]3=P]+=RA^^^4 +M]7?J^KNG)W]VZ/X[9?V=NOZNG%V=0[YC_9VZ_@[,(=^Q_DY=?P?FD.]8?Z>N +MO\MSS^H<\AWK[]3U=\_R7.$.W7^GK+]3U]\]2]P]J]PAW['^3EU_]RQQ]ZQR +MAWS'^CMU_=VST\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/(=ZR_ +M4]??Y;GG=0[YCO5WZOJ[YWFNOOU/5W+_-GOS9H?OOE/5WZOJ[LOU/7W[W*O3A=GAWS'^CMU_5TYNSJ'?,?Z.W7]'9A# +MOF/]G;K^#LPAW['^3EU_E^=>USGD.];?J>OO7N>YRAWR'>OOU/5WKQ-WKPMW +MZ/X[9?V=NO[N=>+N=>$.W7^GK+]3U]^]/OFS0_??*>OOU/5WY>SJ'/(=Z^_4 +M]7=@#OF.]7?J^CLPAWS'^CMU_5V>>U/GD.]8?Z>NOWN3YPIWZ/X[9?V=NO[N +M3>+N3>4.^8[U=^KZNS>)NS>5.^0[UM^IZ^_>G"[.#OF.]7?J^KMR=G4.^8[U +M=^KZ.S"'?,?Z.W7]'9A#OF/]G;K^+L]=U3GD.];?J>OOKO)$.W7^GK+]3U]]=)>ZN"G?H_CME_9VZ_N[JY,\.W7^GK+]3U]^5LZMS +MR'>LOU/7WX$YY#O6WZGK[\`<\AWK[]3U=WGN;9U#OF/]G;K^[FV>*]RA^^^4 +M]7?J^KNWB;NWE3OD.];?J>OOWB;NWE;ND.]8?Z>NOWM[NC@[Y#O6WZGK[\K9 +MU3GD.];?J>OOP!SR'>OOU/5W8`[YCO5WZOJ[//>NSB'?L?Y.77_W+L]5[I#O +M6'^GKK][E[A[5[A#]]\IZ^_4]7?O$G?O"G?H_CME_9VZ_N[=R9\=NO].67^G +MKK\K9U?GD.]8?Z>NOP-SR'>LOU/7WX$YY#O6WZGK[_+<^SJ'?,?Z.W7]W?L\ +M5[A#]]\IZ^_4]7?O$W?O*W?(=ZR_4]??O4_L +MOU/7WY6SJW/(=ZR_4]??@3GD.];?J>OOP!SR'>OOU/5W>>ZZSB'?L?Y.H_[. +MT/UWROH[C?H[0_??*>OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ.XWZ +M.T/WWRGK[S3J[PS=?Z>LOU/2WWVH<\AWK+]3U]]]R'.%.W3_G;+^3EU_]R%Q +M]Z%RAWS'^CMU_=V'Q-V'RAWR'>OOU/5W'TX79X=\Q_H[=?U=.;LZAWS'^CMU +M_1V80[YC_9VZ_@[,(=^Q_L[R#]S).*G?`=\;Z.W/]G9PNS@[XSEA_9ZZ_*V=7 +MYX#OC/5WYOH[,`=\9ZR_,]??@3G@.V/]G;G^+L]IG4.^8_V=N?Y.\USE#OF. +M]7?F^CM-W&GA#MU_9ZR_,]??:>)."W?H_CMC_9VY_DY/_NS0_7?&^CMS_5TY +MNSJ'?,?Z.W/]'9A#OF/]G;G^#LPAW['^SEQ_E^>LSB'?L?[.7']G>:YPA^Z_ +M,];?F>OO+'%GE3OD.];?F>OO+'%GE3OD.];?F>OO['1Q=LAWK+\SU]^5LZMS +MR'>LOS/7WX$YY#O6WYGK[\`<\AWK[\SU=WFNK7/(=ZR_,]??M7FNZ.#OD.];?F>OORMG5 +M.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\U]NO^M/_NS0_7?&^CMS_5TY +MNSJ'?,?Z.W/]'9A#OF/]G;G^#LPAW['^SEQ_E^>.=0[YCO5WYOJ[8YXKW*'[ +M[XSU=^;ZNV/B[EBY0[YC_9VY_NZ8N#M6[I#O6']GKK\[GB[.#OF.]7?F^KMR +M=G4.^8[U=^;Z.S"'?,?Z.W/]'9A#OF/]G;G^+L\-=0[YCO5WYOJ[(<]5[I#O +M6']GKK\;$G=#X0[=?V>LOS/7WPV)NZ%PA^Z_,];?F>OOAI,_.W3_G;'^SEQ_ +M5\ZNSB'?L?[.7'\'YI#O6']GKK\#<\AWK+\SU]_EN;'.(=^Q_LYOOS/5W8`[YCO5WYOH[,(=\Q_H[<_U=GOM4YY#O6']GKK_[ +ME.<*=^C^.V/]G;G^[E/B[E/E#OF.]7?F^KM/B;M/E3OD.];?F>OO/ITNS@[Y +MCO5WYOJ[LOS/7 +MWWW.?$W>?"';K_SEA_9ZZ_^WSR +M9X?NOS/6WYGK[\K9U3GD.];?F>OOP!SR'>OOS/5W8`[YCO5WYOJ[//>ESB'? +ML?[.7'_W)<\5[M#]=\;Z.W/]W9?$W9?*'?(=Z^_,]7=?$G=?*G?(=ZR_,]?? +M?3E=G!WR'>OOS/5WY>SJ'/(=Z^_,]7=@#OF.]7?F^CLPAWS'^CMS_5V>^UKG +MD.]8?V>NO_N:YRIWR'>LOS/7WWU-W'TMW*'[[XSU=^;ZNZ^)NZ^%.W3_G;'^ +MSEQ_]_7DSP[=?V>LOS/7WY6SJW/(=ZR_,]??@3GD.];?F>OOP!SR'>OOS/5W +M>>Y;G4.^8_V=N?[N6YXKW*'[[XSU=^;ZNV^)NV^5.^0[UM^9Z^^^)>Z^5>Z0 +M[UA_9ZZ_^W:Z.#OD.];?F>OORMG5.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7=M +M_H&;^U[G@.]:UM^UKK_[GNWYM=H< +M)O!7_A,__GS]\,\R>'MWT!\8S*_PX5S^!>GN[@ZZC::V&W?NZ>,@]][P^9L> +M"W_#3Z[OS:'OS?PKYX>N^_G98-]]-V3=LW[9@N^>?[FMW#6;.Z0#D+?[O_[ +MMWLW=_OE>_>GG>>,SCW!<[=?OM>?S*$//M?^[*F#TE=W\6M[-]<='CXUW'_J +M_-L,:_:IF58R]]7-H6\?_RODW=X<,/?-\>8?6F]^@R?-LI]_L/;G;[[;##>? +M)G?_:49O_U^FL3G*^?^RNQG\\:^_7__K;NS]];_?IM=W=W.`X`_^$^ST[FX. +M&-C;S?]YD;_=YN$<^)W>KYW>^?M/=Z>%#.I\>_)3Y +MU7C?/7V`G\E?_$C]^O'_YY-]BFP4=[A3>#RR-^=ISG +M'O&SXSSWB)\=Y[E'_>PX#S[B9\=Y[A$_.\YSC_C9<9Y[U,^.F\';?^?X2%_$ +MSW-R]V5R7YM!F\W_AV[_Z=(_O2_Y,OXO@78WO$+^+GN9]_$=_^ +;Z)M]Q"_BY[E'_2+>'HXWWOOM/_VP*B?UK``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu new file mode 100644 index 000000000000..b082a2de9712 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu @@ -0,0 +1,26 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-gpt.qcow2.gz +M'XL("+X[(U0``VEM9RTV,W@R-34M-#`Y-BUG<'0N<6-O=S(N;W5T`*V92V_4 +M,!"`[_T5+F]:6.)7DN51:$LK]=8BN'')\UB)*PK\=N+8B9/)3-PNWK6BKJSY +M9#O?C)TT2>R',$)$(1U*3K@% +MZ]+C!(5+^+J#X[C9Z"2"$V/4&A3"*7)T6QT([N1H6+KA9N0@0AX"M#CR9APT +M/F''!R/4@>,3L<PI7!'$2B2HI7!7$ +M*22JIG!-$*>1J);`\8`J/2Y%HCB%$T%"N!R)HKSC8>_V2!3E'0][ +M5R!1E'<\[%V)1%'>\;!W%1)%>BA]0[07DG@'>G#O?&XY!Z)RCO!/#N[2X=Y['%+O).6=!-Y]<+B/'H?4.TEY)X%WGQSNS..0>B4^)-6-L)&ZL*Y$IW=!>[Y7<" +M#KG[".`XPB7.35C;W+4/C$W#VM8UNU(N.)\=$)`)'^]FN#KR^@WI]@B@UJPH +M5L`?X_B&=.OSR[X;Z.W60S'0@FDUX8:YZFH^OJOK&W9[_NV[@?WTTQW2+2M8 +MQ5F1LP*.CE/3_8W9IVVZ92U<[1$G*=QT+`,X<[S(Z@TRV+88SUIYEW)S=>F!W?[>[M["WNU^G;GR*.R.P1G=0JZ>&RIQ3T\W\@P`Q +M7;;$8:^1_FOU3%TN=;35VSM9L$9WD*M7V-7#%\FL'IHRW;AJ8\*-N#+NZG'[ +M"C,Q]7M]I3NZV]WR:X'*`:.-4*5M%3$[#"YB=AA(&9]PK,E8+\YRX^'_!UG;<#8^/Z^DV8FOKW]C$\9O1 +E1-S$#6YS$\\:>K+V\Q=,-N(F;G!1-W&5F>/WT3\!FKQU%1H````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu new file mode 100644 index 000000000000..d413df2e2b4a --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-gpt.raw.gz +M'XL("`+&'50``VEM9RTV,W@R-34M-#`Y-BUG<'0NU52W;V`262JW42MW2JMW:@3]FC-2=#U\?A@2(C1KIP$)(Q_UR]_#C +M(F4X`*,AJ\@U'>B?Q?+L=W>[@:;JVX#^]ZF$%5!X8,`U/B@U/>,3SAQ.?9BAFO/6=K7-O+Z7US<VLL(>^M^[#3@KEUG%/"MSJ#-T%:HV@7M< +MX7+FG6G&1 +M2+VH9?I)M7^I;M +I.KTU^C>&>/QE.,8A3KCM(>YN;99QB!..=8@;_W]*RMT?5F[7A(@+```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu new file mode 100644 index 000000000000..0dfa2d8094ba --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-gpt.vhd.gz +M'XL("`+&'50``VEM9RTV,W@R-34M-#`Y-BUG<'0N=FAD+F]U=`"MF#MOW#`, +M@/?[%2RZI:ACR9+L6UHT:`)T2U];A_@A!QEZ?5R&#/[Q%67Y(5MRX81W@LZ& +MS,\D15$\I6G_`5`9J!:4!B7Q.A>@CI`7`&;0-6Y[YFZAJW^==/WX\)2X3W?H +M82R=2_GB*,\S$.8E.?`27Z(:O(9NP"2OK^\O'G[>#SCN<,.+A0+!01J(6+U' +MI:-V2+JY^OK1(N\F[;*U=I-4_].VD+6S)[)!NSO;OY\;*XR4>1Y;#JF$5$S- +MN_$&)F,7OI/I0FJF9LBI,V-#.+4EM0=W<7!ST8>*"8S<],9U#'*.UR9L!C^L +MF@F5I_/O\N]9+_3CD5!1HWYL-9;%S>4N5/CPL--`8#AOF0N6\KC$!4+E1=Y3 +MOMPPN\8))G#<#;?F^]Z;4##73[%TP^?QR8CJ5Z)^9FVE9:"/#W17B?\=@56U +M#SAXT,>-!EVRGNMW??,);C]\^8:P'Y.Y-89+PZ&HH3Y"6RVT +M6Z^T[=Q2\S[Z>!LT-HOB+L,X7&QMLX$+M3A.;$FYK6R'L3+UI8JY5*:ARJ`M +MH6PBN'<+''5>UCA<*[<(7`[O0Y +M.?6PM\F?-TX_S5Q$A%I\(.8];?-R$3,WGQ)VQ%SP<=1Y61?H/4GFO:,+EE"+ +M#T2]5_;>"SL)O1=:NN.NEB2O?%Q%ZSUF=PVS/DS^7O?Q@>XV\;\]D+MMB&Q? +MXRZ1DFDH')!,0^'6+Z&&3&].YMY95FY2B#(,X@@S#.((,PSB2#,,`@DS#.(( +M,PSB"#,,XD@SC*(MA)0KA+("-,,_+I4?-?&2IBN2N+82BY=-&(12> +M#,I"2/VO$&IUS-B1LS"6L!!2U(60]\S367P9T]\<05D#B@`$W."?E>(TQ +M8.ULE/E58;$S09=SCR/+1DF$&^-5*RL[8AP)N*-<>QE0*>BZ,^"W8WS>O"/N^R.7,.4<.[0##'FR_BH[] +MO]R`)Q`W;N!R5L;)K56AABX1JVBZJHU7"0.]`-M!-Q9P +M;UZA8U,NI#A1.WLM9D]5R]Y^+I:_DD8?9RK>MP<];(JQ37U\T>\U/#]8=[?Y\?RX[I@:1[`,H96"U"9>U0L3L0 +M5[$[$%>Q.Q!7M3L06+$[$%>Q.Q!7L3L05[4['-#0>D,<<5A[H@7#H!'0IU53 +M'L=32WZ'P&X2N89OC?Z-(9Y_&*;B$$?]F]F6#Z25X;KN<#"U*Y%.KR) +M'O$\BN_J[NGZ^297IW+O;[]\\,C');K,:TJOLN?B +M%#81/D?WZ(_O8K'R)-98<,JI7"SYD3BRA8PX7RKQQ2]]M@%7NU3<7X/=/VC0 +&,#.S#0`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu new file mode 100644 index 000000000000..829240355e69 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu @@ -0,0 +1,88 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-gpt.vmdk.gz +M'XL("`/&'50``VEM9RTV,W@R-34M-#`Y-BUG<'0N=FUD:RYO=70`K5Q=C]S& +M$7SWKYB<'QPDR(*U_%H^*(B=LP,C"*#(3O*2ARR_XD-L23D=C`C8'Q\..357 +MO+LY4KX^\;3;VN[:Z9YEFXWCB +M"Y<_7__E[P?^_/IPN'RV@,%'20@RA1-C]3Z7PX,?PAV?BUJ],!W'3;C<1[6/ +M`@/<,?%"$JZ87CP^%<+5G>>7>_]$X%P$7^S5, +MVULUKLY=U0;35>5LYZX^SJ]EKIZO+][%]9W]'L[ +M.1>5]Z\ZCS`E5E?^B7_!PS4>HAIN\I#\6M +M*N=_'Q_SZH:W=QYQ##]Q=7YO0W'*^;T+_Z0L7-VX>3FEQSY.+_UP +MOAN^__A^>'7UT[NWL79^;WW)FAGH-!'SQWA*E^[:0-/85U+UE-(E=S9:=F7K_]W-^7K^K"S-X2;%S$G +M,;UW>71E[;&F#9RWXNCRPC^;_FE:\)1)`>_D+N_>'M[\8SK%?;&^>_WE&\*= +MIJC)6[K]V53_+['X;Y$TBX9CG-O/.R#YC-HW\2 +MJK;`^R96^!?FG777Y[NS^^K\83A\?GW]5=S9LT^VF(]I:8-'J19H__F>RSD5 +M;MGI9:/GK>C[]G#NS^_OAEN_O7$K6E^B/F3JM[6XW\;U^]3S3HW^$^,NK]S5 +M33_MJ8?]]_#N)\)UR\=X6H?_2#1S8.Z?3)^>&7X([[!\8OPV>;CA[O;CH?OX +MX\W;?CK1W"O"]4OMIN7D65A47-/#1<6WG6IWE=TO;<(FW.!+M"SJ%$Z,"6M9 +MQWT5_">F]$>HPN7CX8?AW$_+/+JGU+P1< +MX*S75V4/KF>YQA5BE"M`?Q7+IM\_3+^O[]=7^?55XEEKU$F,9@7WKPGB_>-T +M*_\1.XMGJU&=&/V>ZE6^M0WB.3ZL'K]J0)ZGX?A=@)ZY1A5BE"NX5.W*4#MZ +MUAIU$J-9P:5J5X7:T;/5J$Z,?E>R=:@=/4>-\@_\*H5LQ]>RZA1J1\]R;:@=/4>-\@]L$)#G:;@N +MU(Z>N4858I0KN%3M^E`[>M8:=1*C6<&E:C>$VM&SU:A.C'Y7LF.H'3U'C?(/ +MA=2NV(*KLU`[>N8:58A1KN`2M:O9[^A9:]1)C&8%EZA=S7Y'SU:C.C'Z7M8:=1*C6<&E:L=^1\]6 +MHSHQ^EW)LM_1<]0H_\`O09#G:3CV.WKF&E6(4:[@4K5COZ-GK5$G,9H57*IV +M['?T;#6J$Z/?E2S['3U'C?(/)&0@SY-PIRS4CIZY1A5BE"NX1.U.['?TK#7J +M)$:S@DO4[L1^1\]6HSHQ^EW)LM_1<]0H_]!([9I-./8[>N8:58A1KN!2M6._ +MHV>M42-\@_\+Q3D>1J._8Z>N4858I0K +MN%3MV._H66O428QF!9>J'?L=/5N-ZL3H=R7+?D?/4:/\`_E'R/,T'/L=/7.- +M*L0H5W"IVK'?T;/6J),8S0HN53OV.WJV&M6)T>]*EOV.GJ-&^8=.:M=MP359 +MJ!T]QW]*PUZB1&LX)+U*YAOZ-GJU&=&/VN9-GOZ#EJE'_H +MI7;])AS['3USC2K$*%=PJ=JQW]&SUJB3&,T*+E4[]CMZMAK5B='O2I;]CIZC +M1OF'06HW;,*QW]$SUZA"C'(%EZH=^QT]:XTZB=&LX%*U8[^C9ZM1G1C]KF39 +M[^@Y:I1_&*5VXR8<^QT]K8:U8G1 +M[TJ6_8Z>HT9E,CV#/$_"G;.E=M$SUZA"C'(%EZC=.?2[Z%EKU$F,9@67J-TY +M]+OHV6I4)T:_*]G0[Z+GJ%&^9,+?89/2.H=^!^'OH/P=A+_#)G]W#OT.PM]! +M^3L(?X=-_NX<^AV$OX/R=Q#^;D>RH=]!^#LH?P?A[[!):9U#OX/P=U#^#L+? +M89._.X=^!^'OH/P=A+_#)G]W#OT.PM]!^3L(?[\@ +M_-V.9-GOA+^#\G<0_@Z;E%;+?B?\'92_@_!WV.3O6O8[X>^@_!V$O\,F?]>R +MWPE_!^7O(/S=CF39[X2_@_)W$/X.FY16RWXG_!V4OX/P=]CD[UKV.^'OH/P= +MA+_#)G_7LM\)?P?E[R#\W8YDV>^$OX/R=Q#^#IN45LM^)_P=E+^#\'?8Y.]: +M]COA[Z#\'82_PR9_U[+?"7\'Y>\@_-V.9-GOA+^#\G<0_@Z;E%:7A=H)?P?E +M[R#\'3;YNX[]3O@[*'\'X>^PR=]U['?"WT'Y.PA_MR-9]COA[Z#\'82_PR:E +MU;'?"7\'Y>\@_!TV^;N._4[X.RA_!^'OL,G?=>QWPM]!^3L(?[^@ +M_!V$O\,FI=6QWPE_!^7O(/P=-OF[COU.^#LH?P?A[[#)WW7L=\+?0?D["'^W +M(UGV.^'OH/P=A+_#)J75L=\)?P?E[R#\'3;YNX[]3O@[*'\'X>^PR=]U['?" +MWT'Y.PA_MR-9]COA[Z#\'82_PR:EU6>A=L+?0?D["'^'3?ZN9[\3_@[*WT'X +M.VSR=SW[G?!W4/X.PM_M2);]3O@[*'\'X>^P26GU['?"WT'Y.PA_ATW^KF>_ +M$_X.RM]!^#ML\G<]^YWP=U#^#L+?[4B6_4[X.RA_!^'OL$EI]>QWPM]!^3L( +M?X=-_JYGOQ/^#LK?0?@[;/)W/?N=\'=0_@["W^U(EOU.^#LH?P?A[[!):?7L +M=\+?0?D["'^'3?ZN9[\3_@[*WT'X.VSR=SW[G?!W4/X.PM_M2);]3O@[*'\7 +MQ720YP+GEM\`-V1+[9Z4E#_Q3[%V[LG5#=;ZP''<"Y@_G:[?XY@NLF>7\>GK +MPZQ?C#./I>J_#'"!,ZX?XOQ=RG0?]ZGZ2L3Y.X\7Z2L1Y^\\7J2O1)R_\WB1 +MOA)Q_FZBKT2?O)OI*Q/F[ +MB;X2?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2O#NL_$1#MIP%RA6LX)ES`GQN+ +MUFL8W#B&8U'.W6<8[V+]1,*_/@A<;UR__?N['&7ISN='@'_C^N;]+4I_/^:B +MF6_.RSOSED6$FW,O.UW?U]]\ZUY_^>9[#_;/^W3GVSMWN2?;BMJCK%>'=+I_ +M>O/X["CFVSM/U3_63R:;)^&^>.ID*^;;.X_],W!/'6FXXKFH3[T3>#'?WEFC +M5'WK\L&UN1O/[MPGX'[_`*XR_N3-=YYM*U=W_O[!)5PWW^RYKSPM[4[3:;*< +M$T=W[+T2H88[^CLR'RYO_WIXNX#][O#?WX;U+7>>Q=-'^H54]8KY+N^G5+IU +MHF&OV[S`Y=;5\]]7VM*L>DWXL#QUI%](5N^\5"]Q59NJ]]2I.\'QJO:K-5QK +M6[UROFHLPI/'?Z=?N+P^K/\L@$4`-%MAX6\I:'=V>#C#L\/#&9X='L[T[/"` +MAF>'AS,\.SR)&MX$?=PIA?QPM^],_OL +)_ZT-&`6T90`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-mbr.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-mbr.qcow.gz.uu new file mode 100644 index 000000000000..2a4ea04ec888 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-mbr.qcow.gz.uu @@ -0,0 +1,128 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-mbr.qcow.gz +M'XL("&'N+50``VEM9RTV,W@R-34M-#`Y-BUM8G(N<6-O=RYO=70`K9W)CE79 +M$47G]16/'I+N1<1M:3)3EFS),WM@>UJW';\/0/YV`WF:S+A[$Y0+0*5$67?K +MO9.+1:E8.IS/=]].IU9.37=JQM,^G[[^//V0T[V?//QQ^O+/O_W]W?UO7WZ[ +M&Y/S#YYR/^^W,O=@Z[]U3K\]M9S.XT_,??TA:.[>J[,_\.KNO=GCW-5O=V\6 +M/Z=LT!X,GM+<.;T^(:?7_-SKNW5O5^Y.[]>]725OM_VYP7^XUZ=_"):?>GU_ +M\.O;P<'?R^MKX%,]FQL>S%T.;[>%3XUL;OHAS'KNX%,SFUN"N1X^M;*Y+9@; +MX%,[GI,??&WOYD;XE+`YA7.G,C?!IXS--0_FSFGNMLS-\"GRZT(<=_G71>5N +M@4\1[B3D;H5/$>XDY&Z#3Q'N).1NAT\1[B3B3O!3A#N-N!.D*&7<:<2=(",K +MXTXC[@3Y3AEW&G$GR'?*N-.(.T&^4\:=1MP)\ITR[C3B3I#OE'&G(7?(=\JX +MLY`[Y#MCW%G('?*=,>XLY`[YSAAW%G*'?&>,.PNY0[XSQIV%W"'?&>/.0NZ0 +M[XQQ9Q%WBI\BW#41=XI\US#NFH@[1;YK&'=-Q)TBWS6,NR;B3I'O&L9=$W&G +MR'<-XZZ)N%/DNX9QUT3<*?)=P[AK0NZ0[QK&71MRAWS7,N[:D#ODNY9QUX;< +M(=^UC+LVY`[YKF7L9='W*'?-*N0;X;&'=# +MQ%V#?#2[D7$WAMPAWXV,NS'D#OEN9-R-(7?(=R/C;@RY0[X;&7=CR!WR +MWZFB+L6^6YBW$T1=RWRW<2XFR+N +M6N2[B7$W1=RUR'<3XVZ*N&N1[R;&W11QUR+?38R[*>0.^6YBW.4_)N5SR'Z6B+L.^6YAW"T1=QWRW<*X6R+N.N2[A7&W1-QUR'<+XVZ)N.N0 +M[Q;&W1)QUR'?+8R[)>*N0[Y;&'=+R!WRW<*X6T/ND.]6QMT:&W"'?K8R[->0.^6YEW*TA=\AW*^-N#;E#OEL9=VO$78^?(MR10.C> +M'/+=QKC;(NYZY+N-<;=%W/7(=QOC;HNXZY'O-L;=%G'7(]]MC+LMXJY'OML8 +M=UO$78]\MS'NMI`[Y+N-<;>'W"'?[8R[/>0.^6YGW.TA=\AW.^-N#[E#OML9 +M=WO('?+=SKC;0^Z0[W;&W1YRAWRW,^[VB+L!/X6YD_P!GP.^DS/A3LX1=P/P +MG9P)=W*.N!N`[X3U@>+[NP-W`_"=L/Y.POYN`+X3UM])V-\-P'?"^CL)^[L! +M^$Y8?R=A?S<`WPGK[R3L[P;@.V']G83]W0!\)ZR_D["_&X#OA/5W$O9W`_"= +ML/Y.POYN`+X3UM])V-\-P'?"^CL)^[L!^$Y8?R=A?S?BIPAW87\W(M^Q_D[" +M_FY$OF/]G83]W8A\Q_H["?N[$?F.]7<2]G]8?R=A?SOO).SO1N0[UM])V-^-R'>LOY.POYOP4X2[L+^;D.]8?R=A?SOO).SO)N0[UM])V-]- +MR'>LOY.POYN0[UA_)V%_-R'?L?Y.POYN0KYC_9V$_=V$?,?Z.PG[NPGYCO5W +M$O9W$_(=Z^\D[.\FY#O6WTG8W\WX*<)=V-_-R'>LOY.POYN1[UA_)V%_-R/? +ML?Y.POYN1KYC_9V$_=V,?,?Z.PG[NQGYCO5W$O9W,_(=Z^\D[.]FY#O6WTG8 +MW\W(=ZR_D["_FY'O6'\G87\W(]^Q_D["_FY&OF/]G83]W8Q\Q_H["?N[&?F. +M]7<2]G]8?R=A +M?[OO).SO5N0[ +MUM])V-^MR'>LOY.POUN1[UA_)V%_MR+?L?Y.POYN1;YC_9V$_=V*?,?Z.PG[ +MNPT_1;@+^[L-^8[U=Q+V=QOR'>OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_ +M)V%_MR'?L?Y.POYN0[YC_9V$_=V&?,?Z.PG[NPWYCO5W$O9W&_(=Z^\D[.\V +MY#O6WTG8WVW(=ZR_D["_VY#O6'\G87^W(=^Q_D["_FY#OF/]G83]W8Z?(MR% +M_=V.?,?Z.PG[NQWYCO5W$O9W._(=Z^\D[.]VY#O6WTG8W^W(=ZR_D["_VY'O +M6'\G87^W(]^Q_D["_FY'OF/]G83]W8Y\Q_H["?N['?F.]7<2]G<[\AWK[R3L +M[W;D.];?2=C?[]8?R=A?[Y.MV4.^$Y9?Z>NOSLE[DZ_ESG@ +M.V7]G;K^[G0YG!WPG;+^3EU_5\ZNS@'?*>OOU/5W8`[X3EE_IZZ_`W/`=\KZ +M.W7]79Y[5.>`[Y3U=^KZNT=YKG('?*>LOU/7WSU*W#VJW`'?*>OOU/5WCQ)W +MCRIWP'?*^CMU_=VCR^'L@.^4]7?J^KMR=G4.^$Y9?Z>NOP-SP'?*^CMU_=UQ +M#MU_IZR_4]??Y;G'=0[YCO5WZOJ[QWFN<(?NOU/6WZGK[QXG[AX7[M#]=\KZ +M.W7]W>/$W>/"';K_3EE_IZZ_>WPYG!WR'>OOU/5WY>SJ'/(=Z^_4]7=@#OF. +M]7?J^CLPAWS'^CMU_5V>>U+GD.]8?Z>NOWN2YRIWR'>LOU/7WSU)W#VIW"'? +ML?Y.77_W)''WI'*'?,?Z.W7]W9/+X>R0[UA_IZZ_*V=7YY#O6'^GKK\#<\AW +MK+]3U]\=Y]#]=\KZ.W7]79Y[6N>0[UA_IZZ_>YKG"G?H_CME_9VZ_NYIXNYI +MX0[=?Z>LOU/7WSU-W#TMW*'[[Y3U=^KZNZ>7P]DAW['^3EU_5\ZNSB'?L?Y. +M77\'YI#O6'^GKK\#<\AWK+]3U]_EN6=U#OF.]7?J^KMG>:YRAWS'^CMU_=VS +MQ-VSRAWR'>OOU/5WSQ)WSRIWR'>LOU/7WSV[',X.^8[U=^KZNW)V=0[YCO5W +MZOH[,(=\Q_H[=?W=<0[=?Z>LOU/7W^6YYW4.^8[U=^KZN^=YKG"'[K]3UM^I +MZ^^>)^Z>%^[0_7?*^CMU_=WSQ-WSPAVZ_TY9?Z>NOWM^.9P=\AWK[]3U=^7L +MZASR'>OOU/5W8`[YCO5WZOH[,(=\Q_H[=?U=GGM1YY#O6'^GKK][D>NORMG +M5^>0[UA_IZZ_`W/(=ZR_4]??'>?0_7?*^CMU_5V>>UGGD.]8?Z>NOWN9YPIW +MZ/X[9?V=NO[N9>+N9>$.W7^GK+]3U]^]3-R]+-RA^^^4]7?J^KN7E\/9(=^Q +M_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/(=ZR_4]??Y;E7=0[YCO5WZOJ[ +M5WFN$.W7^GK+]3U]]=)>ZN"G?H_CME_9VZ_N[J +MOOP!SR'>OOU/5W8`[YCO5WZOJ[//>ZSB'? +ML?Y.77_W.L]5[I#O6'^GKK][G;A[7;E#OF/]G;K^[G7B[G7E#OF.]7?J^KO7 +ME\/9(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_.\ZA^^^4]7?J^KL\]Z;. +M(=^Q_DY=?_S0[YC_9VZ_JZ<79U#OF/]G;K^#LPAW['^3EU_!^:0[UA_IZZ_ +MRW-OZQSR'>OOU/5W;_-SF<'?(=Z^_4]7?E[.H<\AWK[]3U=V`.^8[U=^KZN^,OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ.R7]W?LZAWS'^CMU_=W[ +M/%>Y0[YC_9VZ_NY]XNY]Y0[YCO5WZOJ[]XF[]Y4[Y#O6WZGK[]Y?#F>'?,?Z +M.W7]73F[.H=\Q_H[=?T=F$.^8_V=NO[N.(?NOU/6WUG^P,V=ZQSPG;'^[NLG +M'G"7_70NW*'[[XSU=^;ZNW/:.Q?NT/UWQOH[<_W=.7%W+MRA^^^,]7?F^KOS +MY7!VP'?&^CMS_5TYNSH'?&>LOS/7WX$YX#MC_9VY_@[,`=\9Z^_,]7=Y3NH< +M\)VQ_LYLOS/7WTEZ>5*Y`[XSUM^9Z^\D<2>5.^`[8_V=N?Y. +M+H>S`[XSUM^9Z^_*V=4YX#MC_9VY_@[,`=\9Z^_,]7?'.73_G;'^SEQ_E^>T +MSB'?L?[.7'^G>:YPA^Z_,];?F>OO-'&GA3MT_YVQ_LY).RWLOS/7W^6YILXA +MW['^SEQ_U^2YPAVZ_\Y8?V>NOVL2=TWA#MU_9ZR_,]??-8F[IG"'[K\SUM^9 +MZ^^:R^'LD.]8?V>NORMG5^>0[UA_9ZZ_`W/(=ZR_,]??@3GD.];?F>OO\EQ; +MYY#O6']GKK]K\USE#OF.]7?F^KLV<==6[I#O6']GKK]K$W=MY0[YCO5WYOJ[ +M]G(X.^0[UM^9Z^_*V=4YY#O6WYGK[\`<\AWK[\SU=\NO\MS +M?9U#OF/]G;G^KL]SE3OD.];?F>OO^L1=7[E#OF/]G;G^KD_<]94[Y#O6WYGK +M[_K+X>R0[UA_9ZZ_*V=7YY#O6']GKK\#<\AWK+\SU]\=Y]#]=\;Z.W/]79X; +MZASR'>OOS/5W0YXKW*'[[XSU=^;ZNR%Q-Q3NT/UWQOH[<_W=D+@;"G?H_CMC +M_9VY_FZX',X.^8[U=^;ZNW)V=0[YCO5WYOH[,(=\Q_H[<_T=F$.^8_V=N?XN +MSXUU#OF.]7?F^KLQSU7ND.]8?V>NOQL3=V/E#OF.]7?F^KLQ<3=6[I#O6']G +MKK\;+X>S0[YC_9VY_JZ<79U#OF/]G;G^#LPAW['^SEQ_=YQ#]]\9Z^_,]7=Y +M[D.=0[YC_9VY_NY#GBOOO/N:YRAWR'>OOS/5W'Q-W'RMWR'>LOS/7WWU,W'VL +MW"'?L?[.7'_W\7(X.^0[UM^9Z^_*V=4YY#O6WYGK[\`<\AWK[\SU=\0[UM^9Z^\^Y;G"';K_SEA_9ZZ_^Y2X^U2X0_??&>OOS/5W +MGQ)WGPIWZ/X[8_V=N?[NT^5P=LAWK+\SU]^5LZMSR'>LOS/7WX$YY#O6WYGK +M[\`<\AWK[\SU=WGNJ]PAW['^SEQ_]SEQ][ERAWS'^CMS +M_=WGQ-WGRAWR'>OOS/5WGR^'LT.^8_V=N?ZNG%V=0[YC_9VY_@[,(=^Q_LY< +M?W><0_??&>OOS/5W>>ZZSB'?L?[.7']WG><*=^C^.V/]G;G^[CIQ=UVX0_?? +M&>OOS/5WUXF[Z\(=NO_.6']GKK^[OAS.#OF.]7?F^KMR=G4.^8[U=^;Z.S"' +M?,?Z.W/]'9A#OF/]G;G^+L_=U#GD.];?F>OO;O)4. +M^8[U=^;ZNYO$W4WE#OF.]7?F^KN;R^'LD.]8?V>NORMG5^>0[UA_9ZZ_`W/( +M=ZR_,]??'>::,WX*<]?D#]S<;9T#OFM8?]>X_NXVSYW*'/#=UZW90[XKF']7>/ZN]O$W>WO90[XKF']7>/ZN]O+X>S0W[==3IQ^XLL[]^W+ +M;U??!]OO7]M&3^<)_)-_XLM?WCW\7@:_WVOT!P:_O6$Y#.8WW-[=:_2]K9O: +M!-[7G][9+;V]1>KOLO??\,T=?-?O[LVAOS?ZSYP?NHKH1X-M>YJFP^"_\NM# +M5Q']F=?7;;_XZ]M_!Z;M3TU[:KO3H#_["O_SUW^[5W@W!V3P_[WANSD@@X=S +M^067WQ\/ZNM#@?^#M_N#UW?K\;;-+@+SO!YBM]Y_-O_P.[1]$3H:@````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-mbr.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-mbr.qcow2.gz.uu new file mode 100644 index 000000000000..4524f2b8b903 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-mbr.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-mbr.qcow2.gz +M'XL("&+N+50``VEM9RTV,W@R-34M-#`Y-BUM8G(N<6-O=S(N;W5T`*V8VY+3 +M,`Q`W_[80HS3N;]FXO1&G>@>*=";B#$*5Y!\R[1X1[''!'(4KS +M#IAW3PCW=,!9*4KS#IAWSPCW/."$?@>:=\"\>T&XEP$G]#O0O`/FW2O"W0:< +MT.]`\PZ8=Z\)]R;@A'X'FG?`O'L[\Q]P0K]#S3MDWGT@W,>`$_H=:MXA\^X3X=8!)_0[U+QSS+L-X3X'G-#OG.:= +M8]Y](=Q=P`G]SFG>.>;=5\)]&W`@10W>99E\$.Y^4K.P[/6G"]?'5CCK`S/` +MZA+@7(8>5R\ZX=Q/N-.@$<[ZP.EN-7X/P'.Q70"L:`7'.)IP[HO-KTZ3]Z5A +MJ4!H>CL;RBR>\,:7QWH5X?8+K]^Y/BX`YKEIF@GP=Y\?S*9Q>7[E8>']K?SC +MAK*KVKPP%3PTP[_W?Z9"M[C%*MCC],<---`G/+38"6X3X;HKEF/TR[A.1][% +MGR/<>A5:?8N;?=S0W4,=I`%ULOFRLE1#LQILC?:YNW3O[K#Z?V]VZ3WLKPGY +M">IK=;N'-L+PR'EBY +M'61][(S9\;5I_#AMUAURN#'F$"18`J__$L+B-P`*@/H +M5\9MQ_"E8AN*CV*DZ<,P8&AM_3?37/N +M,!!!70;=@2X!W>0S,7#)+SSU75(9)@IW1Q^DX?J` +MJ^/U6N#,0;@0XQ[+R[*2PH/3:U)U;>9DZ->;\>;-#9#XYC+.Y'T(+N/+0A5( +L6-'.?2A;@\Y^,.7,>`%OS;;S)I%6,"/ +M/\S#0@C_`]`5Z!YT!UI1NY:@[Z$V`*XS%!SK,KS"T/[ZV;5_7UZ+\!L.'E:* +M=%8^G>9C!=(M4@-:6D0_41N&B"D^/#[?O?QXCC@,N+BPU"`1E(/(Q3I&3.J( +M].GAR\>YNFJI[C++K]/W4/7)B"I55Q2G%"?=+#>>BH9>CC)CR5ZRCA27J5-B +M-BN1N7:HR6;7<'IOUBVXNT.PA7<5YQBUJP7H$FJDMG.;>`Z+XESE]?S;_CEW +M,WVXX2HZ,<:\3VYO%X.K8!P<%$@2N+==&"GG.6[%5=YU>CJ?)T/#'8)0L0/' +M[>>G=T%!JD^78N?,MXVQJ<^2/A=;PJ[4VQW#0Y$_$[!I;@,:X:,CQTT;;MH0 +M'0*LHIJBM`RQ&LZO=>_=BD%./FR/R?DU3\SV;?K;@$J!M0O@UZBOW95QNSYC +MF.UK1H=1-:5SI<'@6Q5^?_RV$K_&;J2#_\M^QN(U7!2<9OL<=TIPE0^W"R5) +M3IG?I>T$=_3_B)-[ZB@G=&L=FYM5S,YBS6Q>:FV"SFNF3++B@FOG-YQJ:YE-D8SCXPW1BY!\LCU +M..1-!';,+,X#W:AEO=TQ?"[RQP,Q?(K8OFT8DBF;0AF`;`H=L&-6:'F_'SHH +L9+HH$([QHD`XQHL"X1@O"H1CO"@0CO&B0#C6BX)V5T`A#O\`HP_9YET.```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-mbr.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-mbr.vhdf.gz.uu new file mode 100644 index 000000000000..1e1f5378332f --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-mbr.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-mbr.vhdf.gz +M'XL("&+N+50``VEM9RTV,W@R-34M-#`Y-BUM8G(N=FAD9BYO=70`K94];\,@ +M$(;W_(J3NF6P``,F2R)%3>=*5=O9<7"4(>W2H8-_?.^,[8"Q\U%A",(Z>/(> +M=YP9T&RSL#6+Y:*E\?UC0,.`\0B8(=#A*L3A`I19*AKSFEYI +M)`.C7N&[[>:N0X.$;(,-GW7FX0[#KKC/&UJ<_USWWBJHS' +M]14V<7Q-FS"J`*E`:3#B7H6?NX^10H?CJ1QV.'$+UPMV&32%VWBX'(VUM])E +M8K?+SSM_[N'6[M?CY#5U>!+,3AEFG55ID\5@"_?Y<09N@>?`3&<3(7"(+UST +MK6(9(G#WBCZ(W2T)5X3KN8<3-]R%$+:>OJ?=<7DZ'WM<7ZKZ +M/Y::#ETA1$;NFM#=E^W;\UA='A^2"4Z/DTZ_[*'CP>EM?)P3D]?3&`(41*"3.'$F+W/TVGQ0;CSYZ)F-X;7>1[L*%P+D$Y&9PQ4I-F\5^+KL_?!&;%_++0P[#\9:U +MJW)7MM%T93':N:O.X[W,58-3/P!^Z=[>?_R/>^L_WA[N/SR^C_F=P]D.SIW@#`45I7A(MP(<'6`*+W+.Y_#-H__A +MTP?_YN[7]^]2[\+9AI;5(]!U;%3NBCQ`Q=)"^XJ`&!Z;\=3;)#VD_?_N]QJ-=U\63O"3Y;G+KRX?X8>$ATHN"$[NZ?V[TS]^`X)#B%#0;.:BJG^8OE8NJ?OOW5WH<@??O;C$TBX>OHR"\[3.6`TS^$B=FV" +M#T/L$FZ,)^O>-H^-^Z;YZ$]?OGW[33K9)A1[&5]#:CZ@E!-T>+['=@Z-FTYZ +M.NCQ*+JN/35=\^'1/X3C34?1AJ>UBY6&8[T\'^/\?:KQI/KPQ+BG-^[NOAO. +M-,#^V[__E7"WZ3$>\@B/1#T&YN%B>'I&>!_?87IBPC$%./_X\.ET^_3+_;MN +M^$)S;PC73;T;TAE.7QW(5\ +M>!7A%;OP].GTLV^Z(2UW=RZ*NW04_?(HM$6++DP'/?1B.HJ8V*?31W^+<'D6 +M#["?-6?**3S*PY,\930?H(_O'\;4ROQ.YW&^_%[VVGE\>?$MM?J=@!.<=7YE +MMO?]C*]\!N@$+'O.KPSY7<2ST*A2C&H&-_PT'8:Y<7H#\%=8HOX`PKD>FPJC5QO)#BWZ%T1>T?/0J-*,:H9 +MW%;ORM@[>M8:U8C1KF:W++:*O:-GIU%>C/X0W#7VCC^`0:['WM'(L[6?\I:] +MJV/OZ%EH5"E&-8/;ZET3>T?/6J,:,=K5[);%MK%W].PTRHO1'X*[Q=YQK$"N +MQ][1R/7&9N^ZV#MZ%AI5BE'-X+9ZYV/OZ%EK5"-&NYK=LM@^]HZ>G49Y,?HC +M<%46>W>1WO%Z[!V-7&]L]:[BO*-GH5&E&-4,;J-W%><=/6N-:L1H5[-;%LMY +M1\].H[P8_2$XSKM">L?KL74?/6J,:,=K5 +M[);%\7KL'8U<;VSVCO..GH5&E6)4,[BMWG'>T;/6 +MJ$:,=C6[9;&<=_3L-,J+T1^"X[SCCTZ0Z[%W-'*]L=D[SCMZ%AI5BE'-X+9Z +MQWE'SUJC&C':U>R6Q7+>T;/3*"]&?P3NFL7>7:5WO!Y[1R/7&UN]NW+>T;/0 +MJ%*,:@:WT;LKYQT]:XUJQ&A7LUL6RWE'STZCO!C](3C.NUIZQ^NQ=S1RO;'9 +M.\X[>A8:58I1S>"V>L=Y1\]:HQHQVM7LEL5RWM&STR@O1G\(CO..__&"7(^] +MHY'KC<=[1L]"H4HQJ!K?5.\X[>M8:U8C1KF:W+);SCIZ=1GDQ^D-PG'=D +M+2'78^]HY'ICLW><=_0L-*H4HYK!;?6.\XZ>M48U8K2KV2V+Y;RC9Z=17HS^ +M"%R=Q=[=I'>\'GM'(]<;6[VK.>_H66A4*48U@]OH7A8:58I1S>"V>L=Y1\]:HQHQ +MVM7LEL5RWM&STR@O1G\(CO/.2^]X/?:.1JXW-GO'>4?/0J-*,:H9W%;O.._H +M66M4(T:[FMVR6,X[>G8:Y<7H#\%QWO72.UZ/O:.1ZXW-WG'>T;/0J%*,:@:W +MU3O..WK6&M6(T:YFMRR6\XZ>G49Y,?HC<$TV]2[MW"#7H7?)R/7&5N^:..^2 +M9Z%1I1C5#&ZC=TV<=\FSUJA&C'8UNV6Q<=XESTZCO!C](;@X[R#\'92_@_!W +MV.7OFCCO(/P=E+^#\'?8Y>^:..\@_!V4OX/P=RO9+8N-\P["WT'Y.PA_=P`N +MSCL(?P?E[R#\'7;YNR;..PA_!^7O(/P==OF[)LX["'\'Y>\@_-U*=LMBX[R# +M\'=0_@["WQV`B_,.PM]!^3L(?X==_JZ)\P["WT'Y.PA_AUW^KHGS#L+?0?D[ +M"'^WDMVRV#CO(/P=E+^#\'?[<&T6>R?\'92_@_!WV.7O6LX[X>^@_!V$O\,N +M?]=RW@E_!^7O(/S=2G;+8CGOA+^#\G<0_NX`'.>=\'=0_@["WV&7OVLY[X2_ +M@_)W$/X.N_Q=RWDG_!V4OX/P=RO9+8OEO!/^#LK?0?B[`W"<=\+?0?D["'^' +M7?ZNY;P3_@[*WT'X.^SR=RWGG?!W4/X.PM^M9+^PR]^UG'?"WT'Y.PA_MY+=LEC..^'OH/P= +MA+_;A[MEL7?"WT'Y.PA_AUW^[L9Y)_P=E+^#\'?8Y>]NG'?"WT'Y.PA_MY+= +MLEC..^'OH/P=A+\[`,=Y)_P=E+^#\'?8Y>]NG'?"WT'Y.PA_AUW^[L9Y)_P= +ME+^#\']NG'?"WT'Y.PA_MY+=LEC..^'OH/P=A+\[`,=Y)_P=E+^#\'?8Y>]NG'?" +MWT'Y.PA_AUW^[L9Y)_P=E+^#\'_ZSCOA+^#\G<0_FXENV6QG'?"WT'Y.PA_=P". +M\T[X.RA_!^'OL,O?=9QWPM]!^3L(?X==_J[CO!/^#LK?0?B[E>R6Q7+>"7\' +MY>\@_-T!.,X[X>^@_!V$O\,N?]=QW@E_!^7O(/P==OF[CO-.^#LH?P?A[U:R +M6Q;+>2?\'92_@_!W!^`X[X2_@_)W$/X.N_Q=QWDG_!V4OX/P=]CE[SK..^'O +MH/P=A+];R6Y9+.>=\'=0_@["W^W#^6SJ79+@0:Y'&2.-7&\\C4T;/MWPF;EG +MN#CO5A5]*_^4>N?6LWNAQ3\&][+826Z(46Z8-A%3N;\/<((SED/B&KN^#WA$ +M#HFT+N?K57)(I'4Y7Z^20R*MR_EZE1P2:5UN(H=$6I>;R"&1UN4F;R"&1UN4F;R"&1UN4F;R"&1 +MUN4F;R"&1UN4F; +MR"&1UN4F$-Y5#PIO*(>%-Y9#P +MIG)(>%,Y)+RI'!+>5`X);RJ'A#>50\*;RB'A3>60\*9R2/199BB'1&\JAT1O +M*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\J +MAT1O*H=$;RJ'/&=99BB'/&>F/KF +M-/^3`-'^-L!)$+<$9,$7C(_RR'XUX_\)\SZ8>2\%WP;;KQ3\]?!G^/CJ)'"= +MFNYZ,9_O3MCXL, +M)S@S_>P$M_OUD5C0?@ON:X$+/P_TXCG[3>#ZW.FUP'TU?1+N\KGL=$%UK%CC +M7]U]S:Z+.#WG\'TGT('\7]YY#IC.USWG5[],XSPK]S/YN9?EAN^Y^LMK]3QF +M8WJC7#>':]-D63G"G>Y]]3*[F_%A8/F5O7WCZ;O3_,\$>(F`9AV\A%],DGWQ?Q6YC7-O8``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-pc98.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-pc98.qcow.gz.uu new file mode 100644 index 000000000000..bfa03be0f1d2 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-pc98.qcow.gz.uu @@ -0,0 +1,126 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-pc98.qcow.gz +M'XL("&/N+50``VEM9RTV,W@R-34M-#`Y-BUP8SDX+G%C;W#T/@/SLAF9W[NZH]4TP&A@T +M`A7Y*2MK]0+-+&W6ZY_?5JO15L-F-?MNZWN_>3A]]6W__J/_WQW +M_]NW/WZ.V?HOKDH_WYZ6N0=;_]?G_,=5A]5Z_H6Y[]^-YN[=7?R-N[OW9B_G +MKO[X^6;Y.E>#\6!PU>;6[?Y,/+WAU^[O2WJ[]O/I_;ZWZ^+MCFIP\V#P:YO[ +M5[L__UNP_-+]_)7X0K,[PM,7VM=E;H]7;=3< +M0^[^=<'=`:\2W%G)W1&O$MQ9R=T)KQ+<6NN/.*.R/?N>+.*^Z,?.>*.Z^X,_*=*^Z\ +MY(Y\%XJ[*+DCWX7B+DKNR'>AN(N2._)=*.ZBY(Y\%XJ[*+DCWX7B+DKNR'>A +MN(N2._)=*.ZBXL[IJD%Q-U3<.?EN4-P-%7=.OAL4=T/%G9/O!L7=4''GY+M! +M<3=4W#GY;E#<#15W3KX;%'=#Q9V3[P;%W5!R1[X;%7=CR1WY;E36W)'O1L7=6')'OAL5=V/)'?EN5-R-)7?DNU%Q-Y;]&Q=U8<1=TU49Q +MMZFX"_+=1G&WJ;@+\MU&<;>IN`ORW49QMZFX"_+=1G&WJ;@+\MU&<;>IN`OR +MW49QMZFX"_+=1G&W*;DCWVT5=]N2._+=5G&W+;DCWVT5=]N2._+=5G&W+;DC +MWVT5=]N2._+=5G&W+;DCWVT5=]N2._+=5G&WK;@;Z*I)<3=5W`WDNTEQ-U7< +M#>2[27$W5=P-Y+M)<3=5W`WDNTEQ-U7<#>2[27$W5=P-Y+M)<3=5W`WDNTEQ +M-Y7_N_BL\O%!Q1[Z;%7=SR1WY;E;7W)'O9L7=7')'OIL5 +M=W/)'?EN5MS-)7?DNUEQ-U?ZHN#N6W)'OCHJ[ +M8\D=^>ZHN#N6W)'OCHJ[8\D=^>ZHN#N6W)'OCHJ[8\D=^>ZHN#N6W)'OCHJ[ +M8\7=EJY:.J#+%PKNMN2[D^+N5'&W)=^=%'>GBKLM^>ZDN#M5W&W)=R?%W:GB +M;DN^.RGN3A5W6_+=27%WJKC;DN].BKM3R1WY[JRX.Y?_.BKMSR1WY[JRX +M.Y?_.BKMSR1WY[JRX.Y?_.BKMSR1WY[JRX.Y?_.BKMSQ=T$5]G= +M#^"%@KL)?&`[ +M4_V=E?W=!+XSU=]9V=]-X#M3_9V5_=T$OC/5WUG9WTW@.U/]G97]W02^,]7? +M6=G?3>`[4_V=E?W=!+XSU=]9V=]-X#M3_9V5_=T$OC/5WUG9WTW@.U/]G97] +MW4Q7J?[.ROYN)M^I_L[*_FXFWZG^SLK^;B;?J?[.ROYN)M^I_L[*_FXFWZG^ +MSLK^;B;?J?[.ROYN)M^I_L[*_FXFWZG^SLK^;B;?J?[.ROYN)M^I_L[*_FXF +MWZG^SLK^;B;?J?[.ROYN)M^I_L[*_FXFWZG^SLK^;B;?J?[.ROYN1U>I_L[* +M_FY'OE/]G97]W8Y\I_H[*_N['?E.]7=6]G<[\IWJ[ZSL[W;D.]7?6=G?[]4?V=E?[^4_V=E?W=CGRG^CLK^[L=^4[U=U;V +M=SORG>KOK.SO=N0[U=]9V=_MR'>JO[.RO]N1[U1_9V5_MZ>K5']G97^W)]^I +M_L[*_FY/OE/]G97]W9Y\I_H[*_N[/?E.]7=6]G=[\IWJ[ZSL[_;D.]7?6=G? +M[KOK.SO]N0[U=]9V=_MR7>JO[.ROSO05:J_L[*_.Y#O5']G97]W +M(-^I_L[*_NY`OE/]G97]W8%\I_H[*_N[`_E.]7=6]G<'\IWJ[ZSL[P[D.]7? +M6=G?'KOK.SO#N0[U=]9V=\=Z2K5WUG9WQW)=ZJ_L[*_.Y+O5']G +M97]W)-^I_L[*_NY(OE/]G97]W9%\I_H[*_N[(_E.]7=6]G='\IWJ[ZSL[X[D +M.]7?6=G?'KOK.SO3G25ZN^L[.].Y#O5WUG9WYW(=ZJ_L[*_.Y'O +M5']G97]W(M^I_L[*_NY$OE/]G97]W8E\I_H[*_N[$_E.]7=6]G]4?V=E?WZ2O5W5O9W9_*=ZN^L[._.Y#O5WUG9WYW)=ZJ_L[*_ +M.Y/O5']G97]W)M^I_L[*_NY,OE/]G97]W9E\I_H[*_N[,_E.]7=6]G=G\IWJ +M[ZSL[\[D.]7?6=G?GK +MQMWJZS('OG/5WWGJ[U:-N]6?RQSXSE5_YZF_@V<'OG/5WWGJ[V`.?.>JO_/4 +MW\$<^,Y5?^>IOX,Y\)VK_LY3?_>HS3WJ<^`[5_V=I_[N4;N]1YT[\)VK_LY3 +M?_>HH

^<]7?>>KO'C7N'G7NP'>N^CM/_1T\._"=J_[.4W\'<^`[5_V= +MI_X.YL!WKOH[3_W=Y1R=?^>JO_/4WSUN>^KO'C;O'"W=T_IVK +M_LY3?_>X>^KNG;>YIGR/?J?[.4W_WM''W=.&.SK]S +MU=]YZN^>-NZ>+MS1^7>N^CM/_=W3QMW3A3LZ_\Y5?^>IOX-G1[Y3_9VG_@[F +MR'>JO_/4W\$<^4[U=Y[Z.Y@CWZG^SE-_]ZS-/>MSY#O5WWGJ[YXU[IYU[LAW +MJK_SU-\]:]P]Z]R1[U1_YZF_>]:X>]:Y(]^I_LY3?P?/CGRG^CM/_1W,D>]4 +M?^>IOX,Y\IWJ[SSU=Y=S=/Z=J_[.4W_WO,T][W/D.]7?>>KOGC?NGB_>^CN8(]^I_LY3?P=SY#O5WWGJ[UZTN1=]CGRG^CM/_=V+QMV+SAWY +M3O5WGOJ[%XV[%YT[\IWJ[SSU=R\:=R\Z=^0[U=]YZN_@V9'O5'_GJ;^#.?*= +MZN\\]7>KO7K:YEWV.?*?Z.T_]W]FX>[EP1^??N>KO//5W+QMW+Q?NZ/P[5_V=I_X.GAWY3O5WGOH[ +MF"/?J?[.4W\'<^0[U=]YZN]@CGRG^CM/_=VK-O>JSY'O5'_GJ;][U;A[U;DC +MWZG^SE-_]ZIQ]ZIS1[Y3_9VG_NY5X^Y5YXY\I_H[3_T=/#ORG>KO//5W,$>^ +M4_V=I_X.YLAWJK_SU-]=SM'Y=Z[Z.T_]W56;N^ISY#O5WWGJ[ZX:=U<+=W3^ +MG:O^SE-_=]6XNUJXH_/O7/5WGOJ[J\;=U<(=G7_GJK_SU-_!LR/?J?[.4W\' +M<^0[U=]YZN]@CGRG^CM/_1W,D>]4?^>IOWO=YE[W.?*=ZN\\]7>O&W>O.W?D +M.]7?>>KO7C?N7G?NR'>JO_/4W[UNW+WNW)'O5'_GJ;^#9T>^4_V=I_X.YLAW +MJK_SU-_!'/E.]7>>^KO+.3K_SE5_YZF_>]/FWO0Y\IWJ[SSU=V\:=V\6[NC\ +M.U?]G:?^[DWC[LW"'9U_YZJ_\]3?O6G';D.]7?>>KO +M8(Y\I_H[3_T=S)'O5'_GJ;^#.?*=ZN\\]7=OV]S;/D>^4_V=I_[N;>/N;>>. +M?*?Z.T_]W=O&W=O.'?E.]7>>^KNWC;NWG3ORG>KO//5W\.S(=ZJ_\]3?P1SY +M3O5WGOH[F"/?J?[.4W]W.4?GW[GJ[[SJ[X+.OW/5WWG5WP6=?^>JO_.JOPLZ +M_\Y5?^=5?Q=T_IVK_LZK_B[H_#M7_9U7_5W0^7>N^CNO^KN@\^]<]7=>]7=! +MY]^YZN\\]7?OV];[/D>^4_V=I_[N?>/N?>>.?*?Z.T_]W?O&W?O.'?E.]7>> +M^KOWC;OWG3ORG>KO//5W\.S(=ZJ_\]3?P1SY3O5WGOH[F"/?J?[.4W]W.4?G +MW\7=#^"%!]RMV]RZSX'OOE_%W$7J[]:-N_7"'9U_%ZJ_B]3?K1MWZX4[.O\N +M5'\7J;];-^[6"W=T_EVH_BY2?P?/#GP7JK^+U-_!'/@N5'\7J;^#.?!=J/XN +M4G\'<^"[4/U=I/[.VISU.?!=J/XN4G]GC3OKW('O0O5WD?H[:]Q9YPY\%ZJ_ +MB]3?6>/..G?@NU#]7:3^#IX=^"Y4?Q>IOX,Y\%VH_BY2?P=SX+M0_5VD_NYR +MCLZ_"]7?1>KOO,UYGR/?J?XN4G_GC3M?N*/S[T+U=Y'Z.V_<^<(=G7\7JK^+ +MU-]YX\X7[NC\NU#]7:3^#IX=^4[U=Y'Z.Y@CWZG^+E)_!W/D.]7?1>KO8(Y\ +MI_J[2/U=M+GH<^0[U=]%ZN^B<1>=._*=ZN\B]7?1N(O.'?E.]7>1^KMHW$7G +MCGRG^KM(_1T\._*=ZN\B]7JOXO4WUW.T?EWH?J[2/W= +MT.:&/D>^4_U=I/YN:-P-"W=T_EVH_BY2?S]4?Q>IOQO; +MW-CGR'>JOXO4WXV-N[%S1[Y3_5VD_FYLW(V=._*=ZN\B]7=CXV[LW)'O5'\7 +MJ;^#9T>^4_U=I/X.YLAWJK^+U-_!'/E.]7>1^KO+.3K_+E1_%ZF_V[2Y39\C +MWZG^+E)_MVG<;1;NZ/R[4/U=I/YNT[C;+-S1^7>A^KM(_=VF<;=9N*/S[T+U +M=Y'Z.WAVY#O5WT7J[V".?*?ZNTC]'KO(O5WVS:W[7/D +M.]7?1>KOMHV[;>>.?*?ZNTC]W;9QM^W]4?Q>IO]LV[K:=._*=ZN\B]7?P +M[,AWJK^+U-_!'/E.]7>1^CN8(]^I_BY2?WKO(O5W4YN;^ASY3O5W +MD?J[J7$W+=S1^7>A^KM(_=W4N)L6[NC\NU#]7:3^;FK<30MW=/Y=J/XN4G\' +MSXY\I_J[2/T=S)'O5'\7J;^#.?*=ZN\B]71^KNY<3=W[LAWJK^+U-_-C;NY^4_U=I/X.GAWY3O5W +MD?H[F"/?J?XN4G\'<^0[U=]%ZN\NY^C\NU#]7:3^[D.;^]#GR'>JOXO4WWUH +MW'U8N*/S[T+U=Y'ZNP^-NP\+=W3^7:C^+E)_]Z%Q]V'ACLZ_"]7?1>KOX-F1 +M[U1_%ZF_@SGRG>KO(O5W,$>^4_U=I/X.YLAWJK^+U-]];',?^QSY3O5WD?J[ +MCXV[CYT[\IWJ[R+U=Q\;=Q\[=^0[U=]%ZN\^-NX^=N[(=ZJ_B]3?P;,CWZG^ +M+E)_!W/D.]7?1>KO8(Y\I_J[2/W=Y1R=?Q>JOXO4WWUJ1^KM/ +MC;M/"W=T_EVH_BY2?_>I1^KOK-G?=Y\AWJK^+U-]= +M-^ZN%^[H_+M0_5VD_NZZ<7>]<$?GWX7J[R+U=]>-N^N%.SK_+E1_%ZF_@V=' +MOE/]7:3^#N;(=ZJ_B]3?P1SY3O5WD?H[F"/?J?XN4G]WT^9N^ASY3O5WD?J[ +MF\;=3>>.?*?ZNTC]W4WC[J9S1[Y3_5VD_NZF<7?3N2/?J?XN4G\'SXY\I_J[ +M2/T=S)'O5'\7J;^#.?*=ZN\B]7<7<\,:KAKN?@`O/.#N+NC]TN?`=X/J[[Z_ +M\("[+XV[+^ME#GPWJ/YN2/W=EW9[7[XN<^"[0?5W0^KOOC3NOORYS('O!M7? +M#:F_@V='?]^V^BCZ"]_>I6_?_KBZ'1QO/]O!5^L=_%N_\.W?WCW\9QF\/9OG +M;PR.XVIW.?C?[0V/MV?SS,/J,-#[:O8S_89OEC?\K[P/V^I@_0]^]W]\;^[ZW;W?PB?209_[(_^UXT_'%P^WU6_/TK\'[S=O[B_U>7;O?TCQO;AK[=[ +M'-OC;GN#P'9?U^H__!PSBQAVCJ``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-pc98.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-pc98.qcow2.gz.uu new file mode 100644 index 000000000000..be431e6cfaa7 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-pc98.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-pc98.qcow2.gz +M'XL("&/N+50``VEM9RTV,W@R-34M-#`Y-BUP8SDX+G%C;W(.!8*U*_G")2F%,L,;/`#/B9M\189O)XH42U[O6FU0XO$TH^Z9 +ME?9H(Z>J_$LIJY6IE>G4?JN.G\,%*ODPOM3AY[?OR_1U6'B8KH0H9J#9#;@1 +MZV_$@82K]'1`\[@D.V1P<(Z:@G(X(V8W-\#@KA:GI3L5HR41>`G0X\1B7)0? +M^/QHA+DP/RB='_+K9\]Q=*">SP]]?C2JD7!M%@=,5"?A-ED<,E%;"==G<8:) +MNI-PPLY-<):)V@LXG5'EB*N9*"WA((MKF"B4<":+:YDHR3N=]ZYCHB3O=-Z[ +M#1,E>:?SWFV9*,D[G?>N9Z(D[W3>NSLF2O(.!.]4Q.V8*,D[(-X]"KC'$;=G +MHB3O@'CW).">#CC-14G>`?'N6<`]CSBFWX'D'1#O7@3/=VXIUF^AU(WB'Q[EU@51'']#N4O$/B +MG0XXB#BFWZ'D'1+O,.!,Q#']#B7OD'AG`ZZ..*;?H>0=$N^:@&LCCNEW*'F' +MQ+LNX-Y''-/O4/(.B7!6$?0ZXFXAC^IV1O#/$NR\!]W7``1%=5_!5PMY,]"V7/GR:>CS5S +MEP=F@.U#@',9>EQ7=,+63]AIL&'N\L#A9CE^#\"3,`\`6JLV4^`O/V'KA>F, +MZ@TWK[!/M#SA=;I^MK0PUI6DZ/H!^X3V'QDVN\(9MOX'A\;M6UNK%NZ;X9_; +MWU.EC[AB)?$X^0>','!.>&BR$]PZP;DSRS[YSU0VU>O8X-._$]QJ&9O]$3?[ +M@X-[BMIQ`^)D;5E9VJ%=G:^TSN[P[IZQSM_?Y/`]U%?%_)AV!:/ISN2GIM-U +MYX+A^9W4P^$@,UTUQKES05K/40DSJ[>:9M<7+H:F.^.>.]=!QCO7XZ!L(^A. +CG>5HH.OBD[L\RNV=K]%?XXY@5S&SUH!K=3":&J0SM%KXS +M3AIC"@J[=@T+KEQPP5V5^?Q('`KY7&$]9%;8.(6ZAM+0%S3TKL*_Q^]*H<=E +M"XG'T1EN%AR29P-WBW"5,8[1RCC9T$M40_B)YQ'NZM\9IX[4F9,0PY9AUUF= +M-UD:T_F^.,Z0`V0%T00;<>`27[STM:D,8NX>Z$/J;F=Q-5\O(QR=N`N.>UI< +M%$\6PI/3NZ;J^LS!D.N;\>;-M1!^K:Q.A=,[VM<7'5."Y<],?+*3"%TG8<+],.H0$> +MWO,!!,;L#T!6(#N0+4A!]9J#W$*M`$RC>W$H2_<)??/VVC:?+U^%^_4;"RM9 +M."H>3N.Q`FXFJ0$U32+_4AUZCRDN;I\O7_X]>QPZG)^82^`(PD!X,H]B1W5$ +MNKM^N)FJJU)UXR@[3]=!U04]JE!=4>Q"'#>C3']Z)71\D.G?Z"-J"'&1.L$F +MHP*9#L:A/DSZSMIB>*9<;^NLB?H[`?7<>4`C0*?#1&]R0OBV' +MAL_YW2W9)&-&@W=Q?)N%[/MU?-O,_D.]*N1\A4IE5J@&A:*F#5U(4/A3A7]N +MGV96L-+90F)Q>`KG!8?[?8S;!;C*+KB1$B0;-"54K?L(ZP'NROX]CJ^IHUVA +MG6M8-%9D3A:M)N/".$/90ED!4ZX-8^`QOC#JVZ8R,#)W11^DYFK"U7'_,L#A +M"7,AQNW=R>M[1B$\X;VK5%V3.1C[Z%0B7\:I`N(Q7!<)EO2I(@!B@'HH.-8>"87SCKJU(9#+E[01^D[M8.5^+G +M:81C5]P%C/MPN"B?*(57HK=)U369DT&G.^/&G>L@>.=Z',O;"*J^L]@*=%T\ +MN2X;NN<"#P\4`9@M@CI\W10'U8(RH*2;EP)4!:6.@0Q74M=\?YGFY_@;9]CA +MJ&\&LZ=;S[C;+:H$5KN7J$\WC_0][`_KX^DPX(96-;Q8*!=T:2$B<5=C=Y]V +M+X]3=3P-DD;1HTYGW/:LXRAZVQ@G1F>-Z5L@/9_H!AEF6Y7#23)9]=_<>IS* +/7"KVP[OZ`WO*69D2"0`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-pc98.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-pc98.vmdk.gz.uu new file mode 100644 index 000000000000..c3521af3e482 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-pc98.vmdk.gz.uu @@ -0,0 +1,84 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-pc98.vmdk.gz +M'XL("&7N+50``VEM9RTV,W@R-34M-#`Y-BUP8SDX+G9M9&LN;W5T`*U<78_< +MQA%\]Z\8G-_RL&`MOY8/LA-'#A`$`8S8L5]#+LGX$%L23H<@`O;'AT-.S16Y +MI$C[^K0GL,7NVNZ>W;Y3=6&39/IR+FM"]QY>#4#X!?NK>/'__CWG8?KT^/'Y[?A_S._FP'YZSP +M_L75(PR%E86_\#<\7.4ABLZEK4OA;[O;TU\>?^E._^V>/CZ^?_<&+/?LSS9+ +M75;Y=+Q_\O*8&?Y)$E?`/X>[_?FO;]^$5VYR^E`_$7&='*/?1YNMZ'DL7?7IZY^[G[X +M]*%[\_#K^W>Q=_YL?@R-BIU>>JA0FF^?;E']"^;\=3<[9?'YY\?K]\/ +M97[L'DY?.L(5OG?#`5Y"7E/50TBQ>;)#VK=O__<\U.O:<+*/A!N3&(L8GCL_ +MN[ST6,,!ID/OTM2E%Y>.\$/"0R49O).[O7]W^L=/#D5ZR=SWW_WI'X2[#'"# +MYY#@$#(4-*LIG^K/ER]+=_O^6_?@B_SAYVY\!1*NFMYFWGDZ!XSFV5^$KDWP +M?HAE_L9XLNYM_5R[;^J/W>G+MV^_B2=;^V*S\3&DUGF48H+VK^^QG4/CII.> +M#GH\BK9M3G5;?WCNGOSQQJ-H_*NU#97Z8\U>CG'^/.5X4KU_Q;C;&_?PV`YG +MZF'_W;W_E7#7Z64\Y.%?$M48F/J+X=4SPG?A&:97C#\F#]<]/WTZ73_]\OBN +M'=YH[@WAVJEW0SK#:4Y)Q9R62<6G'7KW@)?4!FS"=;Y%4U*7\,88L*8\7KJ0 +M#H_A;9HT87IH(=>3$<1$OMT^MA=`UR: +MA`/L9\V9&5/&4T'Z#/[Y_&U(KT0>=QNOQ9]MIYG-W]2"U_)^`$9YU? +MD>S]/.,CG0$Z`4M>\BM\?IEXYAI5B%'.X(;?)D[?#=__&KX_")Q_B5W$L]*H +M6HSF2/<*__/B*IZM1G5B](?@LM`B_H("N1Z;2B/5&Q'.+7J7A][1,]>H0HQR +M!K?5NR+TCIZ51M5B-*O9+8LM0^_HV6I4)T9_".X2>L=?P"#78^]HI,G:;WG+ +MWE6A=_3,-:H0HYS!;?6N#KVC9Z51M1C-:G;+8IO0.WJV&M6)T1^"NX;><:Q` +MKL?>T4CUQF;OVM`[>N8:58A1SN"V>M>%WM&STJA:C&8UNV6Q?>@=/5N-ZL3H +MC\"52>A=)KWC]=@[&JG>V.I=R7E'SURC"C'*&=Q&[TK..WI6&E6+T:QFMRR6 +M\XZ>K49U8O2'X#COT4CUQF;O.._HF6M4(48Y@]OJ'><=/2N-JL5H +M5K-;%LMY1\]6HSHQ^D-PG'>%]([78^]HI'ICLW><=_3,-:H0HYS!;?6.\XZ> +ME4;58C2KV2V+Y;RC9ZM1G1C](3C.._[J!+D>>T.\HV>N4848Y0QN +MJW><=_2L-*H6HUG-;EDLYQT]6XWJQ.B/P%V2T+N+]([78^]HI'ICJW<7SCMZ +MYAI5B%'.X#9Z=^&\HV>E4;48S6IVRV(Y[^C9:E0G1G\(CO.NDM[Q>NP=C51O +M;/:.\XZ>N4858I0SN*W><=[1L]*H6HQF-;MEL9QW]&PUJA.C/P3'>$&N +MQ][12/7&9N\X[^B9:U0A1CF#V^H=YQT]*XVJQ6A6LUL6RWE'SU:C.C'Z0W"< +M=V0M(==C[VBD>F.S=YQW],PUJA"CG,%M]8[SCIZ51M5B-*O9+8OEO*-GJU&= +M&/T1N"H)O;M*[W@]]HY&JC>V>E=QWM$SUZA"C'(&M]&[BO..GI5&U6(TJ]DM +MB^6\HV>K49T8_2$XSKM6>L=KLMJQ=^T=W+)WG'?TS#6J$*.K49T8_2$XSKM.>L?KL74?/2J-J,9K5[);%<=/7.-*L0H +M9W!;O>.\HV>E4;48S6IVRV(Y[^C9:E0G1G\$KDZFWL6=&^3:]RX:J=[8ZET= +MYEWTS#6J$*.\@_!UV^;LZS#L(?P?E[R#\W4IVRV+#O(/P=U#^#L+? +M'8`+\P["WT'Y.PA_AUW^K@[S#L+?0?D["'^'7?ZN#O,.PM]!^3L(?[>2W;+8 +M,.\@_!V4OX/P=P?@PKR#\'=0_@["WV&7OZO#O(/P=U#^#L+?89>_J\.\@_!W +M4/X.PM^M9+\@_-T^7).$W@E_!^7O(/P==OF[AO-.^#LH?P?A +M[[#+WS6<=\+?0?D["'^WDMVR6,X[X>^@_!V$OSL`QWDG_!V4OX/P=]CE[QK. +M.^'OH/P=A+_#+G_7<-X)?P?E[R#\W4IVRV(Y[X2_@_)W$/[N`!SGG?!W4/X. +MPM]AE[]K..^$OX/R=Q#^#KO\7<-Y)_P=E+^#\'_VX:Y)Z)WP=U#^#L+?89>_NW+>"7\'Y>\@_!UV^;LKYYWP=U#^#L+? +MK62W+);S3O@[*'\'X>\.P''>"7\'Y>\@_!UV^;LKYYWP=U#^#L+?89>_NW+> +M"7\'Y>\@_-U*=LMB.>^$OX/R=Q#^[@`_NW+>"7\'Y>\@ +M_!UV^;LKYYWP=U#^#L+?K62W+);S3O@[*'\'X>\.P''>"7\'Y>\@_!UV^;LK +MYYWP=U#^#L+?89>_NW+>"7\'Y>\@_-U*=LMB.>^$OX/R=Q#^;A^N34+OA+^# +M\G<0_@Z[_%W+>2?\'92_@_!WV.7O6LX[X>^@_!V$OUO);EDLYYWP=U#^#L+? +M'8#CO!/^#LK?0?@[[/)W+>>=\'=0_@["WV&7OVLY[X2_@_)W$/YN);MEL9QW +MPM]!^3L(?W<`CO-.^#LH?P?A[[#+W[6<=\+?0?D["'^'7?ZNY;P3_@[*WT'X +MNY7LEL5RW@E_!^7O(/S=`3C..^'OH/P=A+_#+G_7]6LEL6RWDG_!V4OX/P=_MP73+U+DKP(->CC)%&JC=N8].&;S=\ +M)^X%+LR[547?RC_%WKGU[.ZT^,?@[HN=Y(88Y89Q$S&5^_L`)SAC.20NH>O[ +M@$?DD(CK)8=$7)?S\2HY).*ZG(]7R2$1U^4F;R"$1U^4F;R"$1U^4F;R"$1U^4F;R"$1U^4F5.GUUZ__?V +MC=LWI_F?"(C^MP'FN:OO`?\9"L[&3Q.N,G?-UNI*I^/$=L%?S_J7G8WEFEEF +MW+\B^6PBOSW#LC/.\#)FF)?^@W;SPEW.1S/\Z=L?%QE.<&9',L'MOD,B#]IO +MP7TM$*0_\\[SP'C^;J7_*K[-,ZSJ-%.][ZZS^YJ?!A8OC,.OG,]R/R=.\&=;0=!-4Z62?=Q__?VC=MWI_F?"3`+ +3@&8=S/Q'DR1?_!^)[K:L<6`````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.qcow.gz.uu new file mode 100644 index 000000000000..50e4d02facaf --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-vtoc8.qcow.gz +M'XL(",PS(E0``VEM9RTV,W@R-34M-#`Y-BUV=&]C."YQ8V]W+F]U=`"MG<0]4ZT:M>^..;DMX@1MZK\"03 +M!@4Z+XI/AT>R??!X/G_]<3IU+G]+<-GMSKD]]Q>E_>#+Z^OI[3R]Z?799X7,#&QSO#>[N]=EE@T]-;&[^+LQVN<"G%C:W!G-7 +M^-3&YB[?G[OBIZYX3K[SB_%U#OW:2OEZ/WY`X=RISJ&O#"E?3\,.PVY0[Y3QIV& +MW"'?*>-.0^Z0[Y1QIP%W"?Y>IHP["[A+\/,NA=PA +MWR7&70JY0[Y+C+L40.^2XQ[E+('?)=8MRED#ODN\2X2R%WR'>) +M<9L9='W*'?-ZFB#M#OIL8=U/$ +MG2'?38R[*>+.D.\FQMT4<6?(=Q/C;HJX,^2[B7$W1=P9\MW$N)M"[I#O)L;= +M''*'?#&W"'?K8R[->0.^6YEW*TA=\AW*^-N#;E#OEL9=VO$78>? +M(MQM$7<=\MW&N-LB[CKDNXUQMT7<=ZVD#ODNXUQ=PFY0[Z[,.XN(7?(=Q?&W27D#OGNPKB[ +MA-PAWUT8=Y>0.^2["^/N$G*'?'=AW%U"[I#O+HR[2\1=CY\BW%TC[GKDNROC +M[AIQUR/?71EWUXB['OGNRKB[1MSUR'=7QMTUXJY'OKLR[JX1=SWRW95Q=XVX +MZY'OKHR[:\@=\MV5<"?E'3X'?"=GPIV<0^Z`[^1,N)-SR!WPG9P)=W(.N0.^ +M$];?2=3?I1[X3EA_)U%_EWK@.V']G43]7>J![X3U=Q+U=W?_E@*?(MQ%_5T: +M@.^$]7<2]7=I`+X3UM])U-^E`?A.6'\G47^7!N`[8?V=1/U=&H#OA/5W$O5W +M:0"^$];?2=3?I0'X3EA_)U%_EP;@.V']G43]71J0[UA_)U%_EP;D.];?2=3? +MI0'YCO5W$O5W:4"^8_V=1/U=&I#O6'\G47^7!N0[UM])U-^E`?F.]7<2]G]8?R=A?SOO).SO)N0[UM])V-]- +MR'>LOY.POYN0[UA_)V%_-R'?L?Y.POYN0KYC_9V$_=V,GR+OO).SO9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/? +ML?Y.POYN1KYC_9V$_=V,?,?Z.PG[NQGYCO5W$O9W,_(=Z^\D[.]FY#O6WTG8 +MW\W(=ZR_D["_FY'O6'\G87\W(]^Q_D["_F[!3Q'NPOYN0;YC_9V$_=V"?,?Z +M.PG[NP7YCO5W$O9W"_(=Z^\D[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W +M(-^Q_D["_FY!OF/]G83]W8)\Q_H["?N[!?F.]7<2]G<+\AWK[R3L[Q;D.];? +M2=C?+]8?R=A +M?[OO).SO5N0[ +MUM])V-^MR'>LOY.PO]OP4X2[L+_;D.]8?R=A?[OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_ +M)V%_MR'?L?Y.POYN0[YC_9V$_=V&?,?Z.PG[NPWYCO5W$O9W&_(=Z^\D[.\V +MY#O6WTG8WUWP4X2[L+^[(-^Q_D["_NZ"?,?Z.PG[NPOR'>OO).SO+LAWK+^3 +ML+^[(-^Q_D["_NZ"?,?Z.PG[NPOR'>OO).SO+LAWK+_3\HZ;.[4YX+N[IS!W +MZOJ[LOU/7WYTR=Z?&'?"=LOY.77]WRMR=&G?`=\KZ.W7]W6D_ +MG!WPG;+^3EU_5\^NS0'?*>OOU/5W8`[X3EE_IZZ_.\ZA^^^4]7?J^KLR]Z#- +M`=\IZ^_4]7LOU/7W]6S:W/(=ZR_4]??@3GD.];?J>OO#G/=&3]% +MN'/]79E[U.:0[UA_IZZ_>U3F3G4.^8[U=^KZNT>9NT>W=0[YCO5WZOJ[1YF[ +M1[_4.>0[UM^IZ^\>[8>S0[YC_9VZ_JZ>79M#OF/]G;K^#LPAW['^3EU_!^:0 +M[UA_IZZ_*W./VQSR'>OOU/5WC\MOOGF3NGE3NT/UWROH[ +M=?W=D\S=D\H=NO].67^GKK][LA_.#OF.]7?J^KMZ=FT.^8[U=^KZ.S"'?,?Z +M.W7]'9A#OF/]G;K^KLP];7/(=ZR_4]??/2USC3OD.];?J>OOGF;NGC;ND.]8 +M?Z>NOWN:N7O:N$.^8_V=NO[NZ7XX.^0[UM^IZ^_JV;4YY#O6WZGK[\`<\AWK +M[]3U=\0[UM^IZ^^>E;G*';K_3EE_IZZ_>Y:Y>U:Y +M0_??*>OOU/5WSS)WSRIWZ/X[9?V=NO[NV7XX.^0[UM^IZ^_JV;4YY#O6WZGK +M[\`<\AWK[]3U=V`.^8[U=^KZNS+WO,TAW['^3EU_][S,->Z0[UA_IZZ_>YZY +M>]ZX0[YC_9VZ_NYYYNYYXP[YCO5WZOJ[Y_OA[)#O6'^GKK^K9]?FD.]8?Z>N +MOP-SR'>LOU/7WQWGT/UWROH[=?U=F7O1YI#O6'^GKK][4>8J=^C^.V7]G;K^ +M[D7F[D7E#MU_IZR_4]??ONOP-SR'>LOU/7WX$YY#O6WZGK[\K<39M#OF/]G;K^[J;,->Z0[UA_ +MIZZ_N\GNO[O)W-TT[I#O6'^GKK^[V0]GAWS'^CMU_5T]NS:' +M?,?Z.W7]'9A#OF/]G;K^[CB'[K]3UM^IZ^_*W,LVAWS'^CMU_=W+,E>Y0_?? +M*>OOU/5W+S-W+RMWZ/X[9?V=NO[N9>;N9>4.W7^GK+]3U]^]W`]GAWS'^CMU +M_5T]NS:'?,?Z.W7]'9A#OF/]G;K^#LPAW['^3EU_5^9>M3GD.];?J>OO7I6Y +MQAWR'>OOU/5WKS)WKQIWR'>LOU/7W[W*W+UJW"'?L?Y.77_W:C^<'?(=Z^_4 +M]7?U[-H<\AWK[]3U=V`.^8[U=^KZN^,O +MRUSE#MU_IZR_4]??O<[C^< +M'?(=Z^_4]7?U[-H<\AWK[]3U=V`.^8[U=^KZ.S"'?,?Z.W7]79G[LOO-.KO.G3_G;+^3J/^KD/WWRGK[Y3T=V_:'/(=Z^_4]7=ORESE#MU_IZR_ +M4]??ONOSO.H?OOC/5WYOJ[,B=M#OC.6']GKK^3 +M,E>Y0_??&>OOS/5WDE^>5.[0_7?&^CMS_9UD[J1RA^Z_,];?F>OO9#^<'?"= +ML?[.7']7SZ[-`=\9Z^_,]7=@#OC.6']GKK\#<\!WQOH[<_U=F=,VAWS'^CMS +M_9V6N<8=\AWK[\SU=YJYT\8=\AWK[\SU=YJYT\8=\AWK[\SU=[H?S@[YCO5W +MYOJ[>G9M#OF.]7?F^CLPAWS'^CMS_=UQ#MU_9ZR_,]??E3EK<\AWK+\SU]]9 +MF:OLOS/7WUGFSBIWZ/X[8_V=N?[.]L/9(=^Q +M_LYLOS/7 +MW]6S:W/(=ZR_,]??@3GD.];?F>OOCG/H_CMC_9VY_J[,=6T.^8[U=^;ZNZ[, +M5>[0_7?&^CMS_5V7N>LJ=^C^.V/]G;G^KLO<=94[=/^=L?[.7'_7[8>S0[YC +M_9VY_JZ>79M#OF/]G;G^#LPAW['^SEQ_!^:0[UA_9ZZ_*W-]FT.^8_V=N?ZN +M+W.-.^0[UM^9Z^_ZS%W?N$.^8_V=N?ZNS]SUC3OD.];?F>OO^OUP=LAWK+\S +MU]_5LVMSR'>LOS/7WX$YY#O6WYGK[XYSZ/X[8_V=N?ZNS`UM#OF.]7?F^KNA +MS%7NT/UWQOH[<_W=D+D;*G?H_CMC_9VY_F[(W`V5.W3_G;'^SEQ_-^R'LT.^ +M8_V=N?ZNGEV;0[YC_9VY_@[,(=^Q_LYNORMS8YM#OF/]G;G^ +M;BQSC3OD.];?F>OOQLS=V+A#OF/]G;G^;LS0[UM^9Z^^.<^C^.V/]G;G^KLQ-;0[YCO5WYOJ[ +MJOOWF;NWC;ND.]8?V>NOWN['\X. +M^8[U=^;ZNWIV;0[YCO5WYOH[,(=\Q_H[<_W=<0[=?V>LOS/7WY6Y=VT.^8[U +M=^;ZNW=EKG*'[K\SUM^9Z^_>9>[>5>[0_7?&^CMS_=V[S-V[RAVZ_\Y8?V>N +MOWNW'\X.^8[U=^;ZNWIV;0[YCO5WYOH[,(=\Q_H[<_T=F$.^8_V=N?ZNS+UO +M<\AWK+\SU]^]+W.-.^0[UM^9Z^_>9^[>-^Z0[UA_9ZZ_>Y^Y>]^X0[YC_9VY +M_N[]?C@[Y#O6WYGK[^K9M3GD.];?F>OOP!SR'>OOS/5WQSET_YVQ_LYOOP!SR'>OOS/5W8`[YCO5W +MYOJ[,O>QS2'?L?[.7'_WLNOZMGU^:0[UA_9ZZ_`W/(=ZR_,]??'>?0_7?& +M^CMS_5V9^]3FD.]8?V>NO_M4YBIWZ/X[8_V=N?[N4^;N4^4.W7]GK+\SU]]] +MRMQ]JMRA^^^,]7?F^KM/^^'LD.]8?V>NOZMGU^:0[UA_9ZZ_`W/(=ZR_,]?? +M@3GD.];?I?*.F[MM<\!WB?5WR?5WMV6N<0=\=_<4YBZY_NXVW;GTYU[???;D^X/CZ3R= +MS@H'O\Y]P]X4SGWO]7V=0]_K_4_,H>_U#N<^4W?W!YB[WS(N;NZ7;^;0]WK_ +M,[\8QZLYRA]3SO8'/MUZ-8>U?_CZY;>M.[N0.6ESG_Q<^W35/:6G]CQX=2?X +MZMJ7VG+W;X5V_ZGO?K)_1W/H6]O_<530U1QX;IM/RQTG(#I?1@>9O=K_?VF_]HM.IA=*JG1 +M"6M6Q1$W8/TC'&BX$!>^)>)ZTZ&`@T-J#$KAG#K=U`D!=[UHMZZ]&#E+X"7` +M#J=>C(OF@VX^GG`7S@=SSX?R_OD+Y\/YY\-Z*L<'SU+S82.D5AHN3^&>$E-5PD,1Y(84:SB5QF9#R&B[I +MG5L)*0>*=X9P6R&E>0?, +MNR<1]Y1PE9#2O`/FW;.(>TZX6DAIW@'S[D7$71%.Z#O0O`/FWW7$>2FE +M>0?,N]<1=TTXH>]`\PZ8=V\B[BWAA+X#S3M@WKT;>>>%O@/-.V3>O8^L)>&$ +MOD/-.V3>V8@#P@E]AYIWR+S#B'.$$_H.->^0>>H>8?,NU7$Y803 +M^@XU[Y!Y5T3:=\B\^QAQGP@G]!UJWB'S[G/$?2&H>>>8=[<1 +M]Y5P0M\YS3O'O/L6<7>$$_K.:=XYYMU]Q#T03N@[IWGGF'>/$;C +M^WCH.V?WZP?T42-S5?A]O,M=P.5YZ*"_4= +M;NVKVM0UP_WIX;8S7PP[6FY]N//'"Y9K#\M%^N&F;;[0?PJN]\MVRW&T7&`I +M^D>-E:8SXG35$5=NJ?-.V;U["3?Y9'O^WIW$3```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.raw.gz.uu new file mode 100644 index 000000000000..941ae5b49fac --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.raw.gz.uu @@ -0,0 +1,11 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-vtoc8.raw.gz +M'XL("`;&'50``VEM9RTV,W@R-34M-#`Y-BUV=&]C."YR87T`AIYC_-%\-8 +M"$#6:#CJZG(E1R4@)00'A']I^);DPAU/QAS^OKGX*:_AB@`C7YSWCZK%@BN3 +M<,7'"%03':T#%5@+QK/`@&NCJGV*6YLOX+J][`99XJ)=GJ@XHCXS';+3Z3NN'R#%5+5J +M]BN',[NN"MFM.-VA]WM"L,,RCJ\.\>JJ-%I=@97OZC)YN>!^R^D)P'X$[C4A +.-4K5C!5GC7NA2P,%```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhd.gz.uu new file mode 100644 index 000000000000..7c4a413cb062 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-vtoc8.vhd.gz +M'XL("`;&'50``VEM9RTV,W@R-34M-#`Y-BUV=&]C."YV:&0N;W5T`*V6S6[; +M,`S'[WD*`KOU8,B4+-NG`NO6VX`!>X')MEP4P]:AW:&'//Q(6XXE?ZU9F0B. +M#(D__2E1#)4:/P!6@^W!>K`%]TL#MH:R`J#!T'!XYN$5SNW3+]_^>7S-PN=\ +M&F&YBJU2<[9'#886*0$=+V([[L-YPF0?/C_]!]]$,':O+LML89\B*YG.ST(\RIY:\)`,Q +M+E%7J(55I'1K4R-GMW#VR.H:W,TIG,48*A08)3T5V!Q*Y#Z%S;0/JT:A\OKR +MVSV_^(4^W`D5>]&7K\;:?758KZV +M&@$T];K-_;M_]IXN+NHOB3ZW$RS_?1RN2NS^<=DJ4#4GL=WCZ(:]Z*HYRA.N@\>+_`?8]PK?!A-"MW_1#_:DB_5[O;3.[J>?)XKRBS[^"B +MO'R[Q+7)58L;PFR_H0XVU7477-."T:G5H;-W6S@O&BI-_U9=A^BM7;N.Y/W#^FJ7?$6B"0C&7"2BKT`:@F$)+ +M1:2HPK*K4?24JZ!0J&YFG&#=S#C!NIEQ@G4SXP3K9L8)ULV,$ZV;"4BQ=_H+ +(%O'FLVP-```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhdf.gz.uu new file mode 100644 index 000000000000..d5ecd33a2377 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhdf.gz.uu @@ -0,0 +1,14 @@ +# $FreeBSD$ +begin 644 img-63x255-4096-vtoc8.vhdf.gz +M'XL("`?&'50``VEM9RTV,W@R-34M-#`Y-BUV=&]C."YV:&1F+F]U=`"ME+UN +MPR`4A?<\Q9&Z98C,C[$]1>I/MDJ5^@*U#409VDI5APY^^&*P8R#832-CA(C@ +M?)Q++C?+7`.X0$$A\KYSBIR!#%M=7 +M/I.]R=[KJ:FEYI`"M.X/$;*?>_[NGH[;T_MQQ-$AJO%@4Z//I3E^$F48[L$4 +MYM@=BR_)5[DW:'PR'3X:__;V/HZ?@S4%2#?6YMB#'\%"*OLL+L\BUO5C`)550B)<-1L/DZCS?/_@"N^E+5Y@5_55FXVK\HPT5A +MA*MV7MB%TS"[:R4X75_X!LHI?$)P;Q-0L8$[7>EIM]DOG>Y/7\7A^9>K.IS! +MW][F7+1UT0PQ+)K3$M=%6RVOE47KDV8/^+JXO?OT[^+6?1KO[SX^?(CGJ\*] +M]BEO!R\7C_W=VO[N8_[O[3W8?W;P3M +M5N'>:EWH.1PGY)=/UR8(7Z0L&@E?HWC\YF^W;^*36]Y\[.\!%ZK\0?S7]GTP +M;M,4X>/R6D[GWC\$Q#G^2:<+]S8.Y[1\;0V?G+1HS\5RG%/`KOS+4VQYF=UX +M[_H']]/GC^[-J]\^O$^S"_HV%H8WRD@AL=FN6O%XZ]W +M#[_]\FY_":,#M_`[MXKK5K7]+LWEE_[,=O__O@^RVF>&?O`+<< +M8FG"?^U359S:@%7[\?DJ?Q]KWVP5_LH?V'>B$I**QP_O;W[\IQ^T^.C=#W_] +M$7"=A_.9_H"^Q#>TZ>FT]G]Z_E@6C^^^+5Z%)G_ZQ2U/(.#.X3%>D]?[($M8 +MA4_BU%;X0&(:7ECN;'';/_3%U_TG=_/Z]O;K=&?[T*PNES^:"RC-"AV>[V6< +M?G#KG5YO]'(KIFFXZ:?^XX.[#[!>_POK$A-L4X-S#_>>; +M\?.O=^\G_T8KW@!N6F?GCU/7\5#I3,\/E;ZLG]VK^NEH'AMP+HQH/507WQ@> +M:SW'TQ3\LQ*>F#2%Q\\WO[A^\L1K`ET([B>^T+VVW*W+?'ZX!OKY^O,;X=<@KOW!/E-ES7 +M4M!M`'_P(#_[CX^;\\DIO'//E-ESU4#!F#G?"A?>N1-E.JZ:GS4J6;CPSA7* +MK+BJID`OX,)/*:7_>$MPE3-E]EPU4#`>:79Y5";* +M=%PUEYL?([,_-DI3Q=DAL^*JF@*]@+LRNZ:.LT-FPU4M!=T&;F]V&F>'S)ZK +M!@K&0\V>XNR0Z;AJ+K<_)M=9N";.#ID55]44Z`7J@8+Q2+,M^`Z9CJMF"L+59.'`=\BLN*JF0"_@KLRN +M!=\AL^&JEH)N`[ZX:*!@/-0N^0Z;CJKG<_(!;=EDX\!TR*ZZJ +M*=`+N&NS`]\AL^&JEH)N`[JP8*QB/-=N`[9#JNFBD(5Y^% +M`]\AL^*JF@*]@+LRNPY\A\R&JUH*N@W^0V;%534%>@%W;7;@.V0V7-52T&W@]F8'OD-FSU4#!>.A9L%WR'1< +M-9?;?\./63CP'3(KKJHIT`NX:[,#WR&SX:J6@FX#MS<[\!TR>ZX:*!@/-0N^ +M0Z;CJIF"<$U9./`=,BNNJBG0"[AKLP/?(;/AJI:";@.W,[MS&6>'S)ZK!@K& +M(\V>P7?(=%PU4Q`NEX4#WR&SXJJ:`KV`NS*[,_@.F0U7M11T&[B]V8'OD-ES +MU4#!>*A9\!TR'5?-%(1KSL*![Y!9<55-@5[`79L=^`Z9#5>U%'0;N+W9@>^0 +MV7/50,%XJ%GP'3(=5\WE1J=,F[Y]N,AW*;/BJIH"O8"[-KO(=RFSX:J6@FX# +MMS>[R'J@8+Q4+.1[U*FXZIYNQF5K*1UCGPGI-\)ZW="^IUD];MSY#LA +M_4Y8OQ/2[R2KW_5EG!WI=\+ZG9!^EV^VCWPGI-\)ZW="^IUD):T^\IV0?B>L +MWPGI=Y+5[_K(=T+ZG;!^)Z3?25:_ZR/?">EWPOJ=D'YWH-G(=T+ZG;!^)Z3? +M25;2ZB/?">EWPOJ=D'XG6?VNCWPGI-\)ZW="^IUD];L^\IV0?B>LWPGI=P>: +MC7PGI-\)ZW>;;4M6TNK!=Z3?">MW0OJ=9/6['GQ'^IVP?B>DWTE6O^O!=Z3? +M">MW0OK=@6;!=Z3?">MW0OJ=9"6M'GQ'^IVP?B>DWTE6O^O!=Z3?">MW0OJ= +M9/6[H8RS(_U.6+\3TN_RS0[@.]+OA/4[(?U.LI+6`+XC_4Y8OQ/2[R2KWPW@ +M.]+OA/4[(?U.LOK=`+XC_4Y8OQ/2[PXT"[XC_4Y8OQ/2[R0K:0W@.]+OA/4[ +M(?U.LOK=`+XC_4Y8OQ/2[R2KWPW@.]+OA/4[(?WN0+/@.]+OA/4[WBA+5M(: +MP'>DWPGK=T+ZG63UNP%\1_J=L'XGI-])5K\;P'>DWPGK=T+ZW8%FP7>DWPGK +M=T+ZG60EK0%\1_J=L'XGI-])5K\;P'>DWPGK=T+ZG63UN[&,LR/]3EB_$]+O +M\LV.X#O2[X3U.R']3K*2U@B^(_U.6+\3TN\DJ]^-X#O2[X3U.R']3K+ZW0B^ +M(_U.6+\3TN\.-`N^(_U.6+\3TN\D*VF-X#O2[X3U.R']3K+ZW0B^(_U.6+\3 +MTN\DJ]^-X#O2[X3U.R'][D"SX#O2[X3U._:&2E;2&L%WI-\)ZW="^IUD];L1 +M?$?ZG;!^)Z3?25:_&\%WI-\)ZW="^MV!9L%WI-\)ZW="^IUD):T1?$?ZG;!^ +M)Z3?25:_&\%WI-\)ZW="^IUD];NIC+,C_4Y8OQ/2[_+-3N`[TN^$]3LA_4ZR +MDM8$OB/]3EB_$]+O)*O?3>`[TN^$]3LA_4ZR^MT$OB/]3EB_$]+O#C0+OB/] +M3EB_$]+O)"MI3>`[TN^$]3LA_4ZR^MT$OB/]3EB_$]+O)*O?3>`[TN^$]3LA +M_>Y`L^`[TN^$]3LA_:XJK\,53W"1[RHJ>:JJ*=`MG(R:FM;Y)G9-3>M\$[NFIG6^B5U3TSK?Q*ZI:9UO8M?4M,XWL6MJ +M6N>;V#4UK?--[)J:UODF=DU-ZWP3NZ:F=;Z)75/3.M_$KJEIG6]BU]2TSC>Q +M:VI:YYO8-36M\TWLFIK6^29V34WK?!.[IJ9UOHE=4],ZW\2NJ6F=;V+7U+3. +M-[%K:EKGF]@U-:WS3>R:FM;Y)G9-3>M\$[NFIG6^B5U3LR:BG6^C5U3LR:BG6^C5U3LR:BG6^C5U3LR:BG6^C5U3TSH?F2^R:VI:YR/S +M179-3>M\9+[(KJEIG8_,%]DU-:WS3>R:FM;Y)G9-3>M\$[NFIG6^B5U3TSK? +MQ*ZI:9UO8M?4M,XWL6MJ6N>;V#4UK?--[)J:UODF=DU-ZWP3NZ:F=;Z)75/3 +M.M_$KJEIG6]BU]2TSC>Q:VI:YYO8-36M\TWLFIK6^29V34WK?!.[IJ9UOHE= +M4],ZW\2NJ6F=;V+7U+3.-[%K:EKGF]@U-:WS3>R:FM;Y)G9-3>M\$[NFIG6^ +MB5U3L6AG9-=:9V376F=DUU +MIG9-=:9V376F=DUUIG9-=:9V376F=DUUIG9-=:9V376F=DUUIG9-=:9V376F +M=DUUIG9-GIDR\#=LM2M-I]6+KR_%1USL)]Z7PK7&_5[@HW +M'(5;-S>3*YQ[!OMZ#DR>XOSR'>VKW +M^;NM*I[JKYRNN'JZ*<$-8_C5V,>G]\TU.&?ZJ,A\%&[JB\$_)U+,XSY<]<5# +H_/^/2K\`KOZ`R__OO^"_9VS_6P$U`IJ=4/U[HRR_^A][EZ;PS5\````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-apm.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-apm.qcow.gz.uu new file mode 100644 index 000000000000..d0370635c7fe --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-apm.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-63x255-512-apm.qcow.gz +M'XL("+4S(E0``VEM9RTV,W@R-34M-3$R+6%P;2YQ8V]W+F]U=`"MG=F.'=EQ +M1=_[*RYGLCC=B,B1LP2Y`3\8:%O0LY0C($"V$[(`O_#C7<4Z0U7V?E_G].:IY70>?V#N^@/.W7D[^R?>[LX7>SEW +M]=/M%XN?4S9H]P9/:>Z^GY,OMV=QP;^YP7ZZ2+W=D<]-W85$"R\SFEF"N@4^M;&X+YEKXU([GY#O? +MV]NY#CXE;$[AW*G,]?`I8W/-O;GSFPQTGAO@4X0[";D;X5.$.PFYF^!3A#L) +MN9OA4X0[";E;X%.$.PFY6^%3A#L-N=O@4X0[#;G;X5.$.XVX$_P4X4XC[@3Y +M3AEW&G$GR'?*N-.(.T&^4\:=1MP)\ITR[C3B3I#OE'%G$7>"?&>,.XNX$^0[ +M8]Q9R!WRG3'N+.0.^$ +MW"'?-8R[)N0.^:YAW#41=XJ?(MPU$7>*?-.NC;A3Y+N6<==&W"GR7&W"'?M8R[-N0.^:YEW+4A=\AW+>.N"[E#ONL8=UW('?)=Q[CK +M(NX,/T6XZR+N#/FN8]QU$7>&?-.NC[@SY+N><=>'W"'?]8R[/N0.^:YGW/4A=\AW/>.N#[E#ONL9 +M=WW('?)=S[CK0^Z0[WK&W1!RAWPW,.Z&D#ODNX%Q-T3<-?@IPMT0<=<@WPV, +MNR'BKD&^&QAW0\1=@WPW,.Z&B+L&^6Y@W`T1=PWRW<"XR__S-Y]#OAL9=V/$ +M78-\-S+NQI`[Y+N1<3>&W"'?C8R[,>0.^6YDW(TA=\AW(^-N#+E#OAL9=V/( +M'?+=R+B;0NZ0[R;&W11RAWPW,>ZFB+L6/T6XFR+N6N2[B7$W1=RUR'<3XVZ* +MN&N1[R;&W11QUR+?38R[*>*N1;Z;&'?Y_X;D<\AW,^-NCKAKD>]FQMT<'W"'?S8R[.>0.^6YFW,TA=\AW,^-N#KE#OIL9=TO('?+= +MPKA;0NZ0[Q;&W1)QU^&G"'=+Q%V'?+ZVB+L>^6YCW&T1=SWRW<:XVR+N>N2[C7&W1=SUR'<;XVZ+N.N1[S;& +MW1YQUR/?[8R[/>*N1[[;&7=[R!WRW'W"'?[8R[/>0.^6XGW$G^"9\#OI,SX4[.(7?`=W(FW,DYXF[`3V'N).SO +M!N`[8?V=A/W=`'PGK+^3L+\;@.^$]7<2]G<#\)VP_D["_FX`OA/6WTG8WPW` +M=\+Z.PG[NP'X3EA_)V%_-P#?">OO).SO!N`[8?V=A/W=`'PGK+^3L+\;@.^$ +M]7<2]G<#\)VP_D["_FX`OA/6WTG8WPW(=ZR_D["_&Y#O6'\G87\WXJ<(=V%_ +M-R+?L?Y.POYN1+YC_9V$_=V(?,?Z.PG[NQ'YCO5W$O9W(_(=Z^\D[.]&Y#O6 +MWTG8WXW(=ZR_D["_&Y'O6'\G87\W(M^Q_D["_FY$OF/]G83]W8A\Q_H["?N[ +M$?F.]7<2]GOO).SO)N0[UM])V-_-^"G"7=C?S]8 +M?R=A?SOO).SO +M9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYN1KYC_9V$_=V,?,?Z +M.PG[NQGYCO5W$O9W,_(=Z^\D[.\6_!3A+NSO%N0[UM])V-\MR'>LOY.POUN0 +M[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W$O9W"_(=Z^\D +M[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W(-^Q_D["_FY!OF/]G83]W8)\ +MQ_H["?N[!?F.]7<2]G]8?R=A?[OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_)V%_MR'?L?Y.POYN0[YC_9V$ +M_=V.GR+OO).SO=N0[UM])V-_MR'>L +MOY.PO]N1[UA_)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.PG[NQWYCO5W$O9W +M._(=Z^\D[.]VY#O6WTG8W^W(=ZR_T_P3-W>J<\!WUT]A[M3U=_D^O5/E#OA. +M67^GKK\[)>Y.F3L[XZNO\MS#^H<\)VR_DY=?_<@ +MSYW*'/"=LOY.77_W(''WH'('?*>LOU/7WSU(W#VHW`'?*>OOU/5W#XZ+LP.^ +M4];?J>OORMG5.>`[9?V=NOX.S`'?*>OOU/5W8`[X3EE_IZZ_RW,/ZQSR'>OO +MU/5W#_- +M'O[LT/UWROH[=?U=.;LZAWS'^CMU_1V80[YC_9VZ_@[,(=^Q_DY=?Y?G'M4Y +MY#O6WZGK[Q[EN<(=NO].67^GKK][E+A[5+E#OF/]G;K^[E'B[E'E#OF.]7?J +M^KM'Q\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_`W/(=ZR_4]??Y;G' +M=0[YCO5WZOJ[QWFN/#W]VZ/X[9?V=NOZNG%V=0[YC_9VZ_@[,(=^Q_DY=?P?FD.]8?Z>N +MO\MS3^H<\AWK[]3U=T_R7.$.W7^GK+]3U]\]2=P]J=PAW['^3EU_]R1Q]Z1R +MAWS'^CMU_=V3X^+LD.]8?Z>NORMG5^>0[UA_IZZ_`W/(=ZR_4]??@3GD.];? +MJ>OO\MS3.H=\Q_H[=?W=TSQ7N4.^8_V=NO[N:>+N:>$.W7^GK+]3U]\]3=P] +M+=RA^^^4]7?J^KNGAS\[=/^=LOY.77]7SJ[.(=^Q_DY=?P?FD.]8?Z>NOP-S +MR'>LOU/7W^6Y9W4.^8[U=^KZNV=YKG"'[K]3UM^IZ^^>)>Z>5>Z0[UA_IZZ_ +M>Y:X>U:Y0[YC_9VZ_N[9<7%VR'>LOU/7WY6SJW/(=ZR_4]??@3GD.];?J>OO +MP!SR'>OOU/5W>>YYG4.^8_V=NO[N>9ZKW"'?L?Y.77_W/''WO'"'[K]3UM^I +MZ^^>)^Z>%^[0_7?*^CMU_=WSPY\=NO].67^GKK\K9U?GD.]8?Z>NOP-SR'>L +MOU/7WX$YY#O6WZGK[_+OOP!SR +M'>OOU/5W8`[YCO5WZOJ[/'=5YY#O6'^GKK^[RG.5.^0[UM^IZ^^N$G=7A3MT +M_YVR_DY=?W>5N+LJW*'[[Y3U=^KZNZO#GQVZ_TY9?Z>NORMG5^>0[UA_IZZ_ +M`W/(=ZR_4]??@3GD.];?J>OO\MS+.H=\Q_H[=?W=RSQ7N$/WWRGK[]3U=R\3 +M=R\K=\AWK+]3U]^]3-R]K-PAW['^3EU_]_*X.#OD.];?J>OORMG5.>0[UM^I +MZ^_`'/(=Z^_4]7=@#OF.]7?J^KL\]ZK.(=^Q_DY=?_NOWN5 +MN'M5N$/WWRGK[]3U=Z\2=Z\*=^C^.V7]G;K^[M7ASP[=?Z>LOU/7WY6SJW/( +M=ZR_4]??@3GD.];?J>OOP!SR'>OOU/5W>>YUG4.^8_V=NO[N=9XKW*'[[Y3U +M=^KZN]>)N]>5.^0[UM^IZ^]>)^Y>5^Z0[UA_IZZ_>WUOOU/5WY>SJ +M'/(=Z^_4]7=@#OF.]7?J^CLPAWS'^CMU_5V>>U/GD.]8?Z=1?V?H_CME_9U& +M_9VA^^^4]7<:]7>&[K]3UM]IU-\9NO].67^G47]GZ/X[9?V=1OV=H?OOE/5W +M&O5WANZ_4];?*>GOWM8YY#O6WZGK[][FN<(=NO].67^GKK][F[A[6[E#OF/] +MG;K^[FWB[FWE#OF.]7?J^KNWQ\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_ +MIZZ_`W/(=ZR_L_P3-W>N<\!WQOJ[ZT_]OOSH<_.W3_G;'^SEQ_5\ZNS@'?&>OOS/5W +M8`[XSEA_9ZZ_`W/`=\;Z.W/]79Z3.@=\9ZR_,]??29XKW*'[[XSU=^;Z.TFO +M)Y4[X#MC_9VY_DX2=U*Y`[XSUM^9Z^_DN#@[X#MC_9VY_JZ<79T#OC/6WYGK +M[\`<\)VQ_LYOO-'&G +MA3MT_YVQ_LY).RWLOS/7WUGB +MSBIWR'>LOS/7WUGBSBIWR'>LOS/7W]EQ<7;(=ZR_,]??E;.K<\AWK+\SU]^! +M.>0[UM^9Z^_`'/(=Z^_,]7=YKJESR'>LOS/7WS5YKG*'?,?Z.W/]79.X:PIW +MZ/X[8_V=N?ZN2=PUA3MT_YVQ_LYNO^L2=UWA +M#MU_9ZR_,]??=8F[KG"'[K\SUM^9Z^^ZPY\=NO_.6']GKK\K9U?GD.]8?V>N +MOP-SR'>LOS/7WX$YY#O6WYGK[_)<7^>0[UA_9ZZ_Z_-LOS/7W_6) +MN[YRAWS'^CMS_5V?N.LK=\AWK+\SU]_UQ\79(=^Q_LYOOS/5WY>SJ'/(=Z^_, +M]7=@#OF.]7?F^CLPAWS'^CMS_5V>&^L<\AWK[\SU=V.>*]RA^^^,]7?F^KLQ +M<3=6[I#O6']GKK\;$W=CY0[YCO5WYOJ[\;@X.^0[UM^9Z^_*V=4YY#O6WYGK +M[\`<\AWK[\SU=V`.^8[U=^;ZNSSWKLXAW['^SEQ_]R[/5>Z0[UA_9ZZ_>Y>X +M>U>X0_??&>OOS/5W[Q)W[PIWZ/X[8_V=N?[NW>'/#MU_9ZR_,]??E;.K<\AW +MK+\SU]^!.>0[UM^9Z^_`'/(=Z^_,]7=Y[GV=0[YC_9VY_NY]GBO0[UA_9ZZ_^Y#G*G?(=ZR_ +M,]???4COO +MRMG5.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\]['.(=^Q_LYOO/B7N/A7NT/UWQOH[<_W=I\3=I\(=NO_.6']GKK_[=/BS0_?? +M&>OOS/5WY>SJ'/(=Z^_,]7=@#OF.]7?F^CLPAWS'^CMS_5V>^USGD.]8?V>N +MO_N^$V90W_?=GDJ +MF+OSX^M/5]\&VV_OU[2G5D]GK4_<7/\V?&_P7_[C9N:!>[_V-W^_;_?+7)]6 +MLUX\9W<'Y?XGOO[R;W[P=N[F_9IOX=CU1W?]WZ?;'WJ_WQW'WS8PA_Z^\O_7 +MEWL[9Y=OUWZS2B>G4Z^GOCEU8_IG=RVI[>;3Z>W^?$Q__\=?__'7__ZO/^>Y +MFW]?=.O-P_T_\W;_.1WP[=#?5_YKOK?-#WYO_][FW[DM^K/EO^[] +MOGT[NIN#O_Y&7'\T>FKMU#0W?SSBU+8WGVOM"J0->@Z\R$"`+D8:H!?_^%+6R)2I&3$VY`A" +M#.)[&`^?QZ:SK'XH9;4R3IF16DR5?TX7J-:3[4NMOHV_G+0?JX,:IC,AQ2P8 +MW."V6.-:U2&#@R;5!:5P1JRN;X'!'1VL6[?>C")*X#[`&B=N +MQE[U05U?G#![U@=#UX=\_VR3BQ=G<@E7)''`I$82;I+$(9.:2KA9 +M$F>8U%S"E4F<95(+`:<3JGB<8U):PD$2ES,IE'`FB2N8E.2=3GLW8E*2=SKM +MW81)2=[IM'=3)B5YI]/>S9B4Y)U.>S=G4I)W('BG`JYD4I)W$'EW2+A'`;=@ +M4I)W$'GWF'!/-CC-I23O(/+N*>&>!1PS[T#R#B+OGA/N1<`Q\PXD[R#R[B7A +MC@*.F7<@>0>1=Z\(]SK@F'D'DG<0>7?<\4XS\PXD[S#R[@VQLH!CYAU*WF'D +MG28<"CIEW*'F'D7H#%+L"^"FO<:-`7;.L7['?`0CA'9>M/R*(7>/F]PAQNUV>'/A#86A@_ +MFA]WJ +M[&+]OY/]1OC+CTN+U93S7S.4M=6:Q2YP +M?%>69]<7QS_&U^W^F6%_;+#^1)7N'[3Z5[])VOU3[?K4YXV;H +KW]]_M8A-?4/WKZ#^^9-Z]RXOK*Y.MO]JH"'@8!4:5TWG@_\+*`W"Y1,````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-apm.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-apm.raw.gz.uu new file mode 100644 index 000000000000..b47d4c617b0d --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-apm.raw.gz.uu @@ -0,0 +1,12 @@ +# $FreeBSD$ +begin 644 img-63x255-512-apm.raw.gz +M'XL("/7%'50``VEM9RTV,W@R-34M-3$R+6%P;2YR87]/"5(HG(/PDN:+T(BV4_QK-K +MQGP`)"$%F$T64G`PPN4^2)B7M]+&71G#%![&V8VNZ[AR$*:X]T#ARI*!FE%? +ME0)YOV#6KT.@QSE]Q*&92_4!)6?I6W;=9SN!$[D^U^.JL3JY.[]S0`MH@EJ$ +M4^V@6E<.ZK9=?3SM3_OOPS;BR.)4XYKU?]1]U=VD.IEYMC1SMA27,@#[LT74 +M1[EWC\[C4,YX.PB;)"`K$$$T5KAT-7L?`5?'MGW:/#^\KS:I?T29]:D9_HG$ +M/_^3I/XAU:=R^Z=N^JN*\7C#KLO]X(`5@ +/-H4D'+#X`^%)]I"G!0`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-apm.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-apm.vhd.gz.uu new file mode 100644 index 000000000000..68c383866a79 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-apm.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-512-apm.vhd.gz +M'XL("/;%'50``VEM9RTV,W@R-34M-3$R+6%P;2YV:&0N;W5T`*U66VO;,!1^ +MSZ\XT+="@Z['W=/86/,V*"M[;HTCE\#:AB:P/OC'5T>76HYES\WD"$5&/I\^ +M?>8?`)2`+:`!U#2N%.`7J*X![&1HPO4\O$+7O#R;YKA[6X>G6WDPSE*K +MH3G9"PG*+E*!J&D1W-(8N@BSOKAYO-P]/48X$>#BP@I!"=`61(W60?;!CI`V +MW^]^.,B'GIT2*<9B=6"VM=!PJ06,;-E&'4;.A\G;8 +MUZ\'<\)/3(0*?O#CHSDYO5T10D7$CP,#1>$\MUUP*,=3N$RH_)=Z.+1386!% +M8#I."+?]H7H]%*3\D+,9S:>=,Z:_->&;WX1##MU1SWAW;/U +M:VC:9HC:YJ*B?^'#B>[V9S9<&N*G.(4Q17)#,;R$W[?]_H_)P(E2V_5P%BDJM0US.[JG>9]GIPKXU"WT; +MDT8$P*%O(?(SI6//.'<@"4\GI.[/(+&UQ#7-V?<1X.;5&'L*7?W>W*7Z&566 +M'V<+]!.)?CY)4OW2VL*G#O'S^GJ\PY5UV" +I*WC5Q5"R)JW\W]*K+H:25>BJ2W`%K[H$5_2JBZZ@KMX!;=,CGA\-```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-apm.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-apm.vhdf.gz.uu new file mode 100644 index 000000000000..6096dacbb0a9 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-apm.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-512-apm.vhdf.gz +M'XL("/;%'50``VEM9RTV,W@R-34M-3$R+6%P;2YV:&1F+F]U=`"M54UKPD`0 +MO?LK!GH3&I+=R<2>^D'U5I!*SQI,(H&JP0KM(3^^^ZF[211;=AV6#9-]OGEO +M=Q+'>@!@"BF#6$1L@JOY_-P):*?OD1AQ9$<[TF#)M5V7X:+.:$=C#T!$Q>0G>U5@.O]KEP?ZQ_W!I/ISE4U''(_X_); +M0!FP7+680JX=?G?3S;C>;BR<[7[VCX77)XN[59)?[DP8K"!79W:\+Q)UU!,\ +M>>45;MBMU/SH%HNG8LL*4-.TX3UX"0GWY)NAX53W=-W;3Y?.;Y]="N+IV>7MP+R1=$A(EFW3%*WO:W>R75O>'KWSQW/HRMX;Y +M>,LFJ;*D[+R9E,5B9TEU7MY+DVIVFN:$7R?7-P__3J['A_[^YN[QUJ_O[,YV +M=LY+YU_V+L.\L:IT+]P;+EWC4I1CD@U)!O=V;C>/K/>/]P<_OI';C= +MLSO;/$ORQBW'^:=/CXWA/B1-2KC/2"Y__LOU.W_EIJ>[]I[I7-2\D/FSYWUH +MWK),W/?+Q[*Z\=.CRSCYK[`Z=[:^.,7RV;E[4>1)U23+<@J7^SR_/?@M+[7K +M[\?V67#[> +M//YZTW^8M_DP7IV^3IBN=+6;#[#VZUIW/8>4NR<[+_OR_?\>Y_TF@S_9&Z9; +M%K%L8O[LXIP4E&FJ^>HV7->X!PR;VBSIV+=?_'\LDPN'[Y/KMPF?_YU7*Y`IFO6'S/GO)X# +M%O/L7OBJK>E=$\O=&\O))M?M8YM\USZ,IZ^OK[\+)]NZS>;+8U[:Z+*4:VIW +M?2_EG`NWGO1ZT,M1#$-W:H?V[G&\=\<;CJ)S)1K\3MVQYD_'N/V<:CFIR5TQ +MR>5= +M?S[UGS_>?!KF'[3D'=,-:^WFY62I7U18T_-%A8^=:W>5/BUMSLUTHRO1NJC: +M_V#,N=9U/%7!73&%>_@J7#Z??AW;85Y6M!S+=:C +M\`O[?'H8>Y\N2_T!3IOBK&M*LC+),K^B;0-]O+U?EE9F5]J/L^>_R][:C_,7 +MOU*KWYEP36>]OC)]]OLLT[A)9:50M1K-) +M]\\YQ=W+[9;N$FO%L].H7HSA2/5*U]I&\9R>5X]_:D!>[Z?CWP+TS#0J%Z/8 +MI-NK7>%K1\]*HVHQFDVZO=J5OG;T[#2J%V,XM-G*UXZ>DT:Y)_XIA?3`GV5E +M[6M'STRCC&&0YOM?.WH.6F4 +M>V*#@+S>3]?[VM$STZAC.'0 +M9B=?.WI.&N6>CV*3;J5W%?D?/2J-J,9I-NIW:5>QW +M].PTJA=C.+19]CMZ3AKEG@JI71%-QWY'STRCDX:Y9Y*J5T93<=^1\],HW(QBDVZO=JQW]&STJA: +MC&:3;J]V['?T[#2J%V,XM%GV.WI.&N6>^$<0Y/5^.O8[>F8:E8M1;-+MU8[] +MCIZ51M5B-)MT>[5COZ-GIU&]&,.AS;+?T7/2*/=$(`-YO9NN3GWMZ)EI5"Y& +ML4FW4[N:_8Z>E4;58C2;=#NUJ]GOZ-EI5"_&<&BS['?TG#3*/352NR::COV. +MGIE&Y6(4FW1[M6._HV>E4;48S2;=7NW8[^C9:50OQG!HL^QW])PTRCWQ_T)! +M7N^G8[^C9Z91N1C%)MU>[=COZ%EI5"U<FW5SOV.WIV&M6+,1S:+/L=/2>- +MG4;U8@R'-LM^1\])H]S3*+4;H^G8[^B9:50N1K%)MU<[]CMZ5AI5B]%L +MTNW5COV.GIU&]6(,AS;+?D?/2:/E8: +M58O1;-+MU8[]CIZ=1O5B#(05[OIFO3M7;!,].H7(QBDVZG +M=JWO=\&STJA:C&:3;J=VK>]WP;/3J%Z,X=!F?;\+GI-&N9()OT,4:;6^WT'X +M'93?0?@=HORN]?T.PN^@_`["[Q#E=ZWO=Q!^!^5W$'YW8+.^WT'X'93?0?@= +MHDBK]?T.PN^@_`["[Q#E=ZWO=Q!^!^5W$'Z'*+]K?;^#\#LHOX/PNP.;]?T. +MPN^@_`["[Q!%6JWO=Q!^!^5W$'Z'*+]K?;^#\#LHOX/P.T3Y7>O['83?0?D= +MA-\=V*SO=Q!^!^5W$'Z'*-+J4E\[X7=0?@?A=XCRNX[]3O@=E-]!^!VB_*YC +MOQ-^!^5W$'YW8+/L=\+OH/P.PN\015H=^YWP.RB_@_`[1/E=QWXG_`[*[R#\ +M#E%^U['?";^#\CL(OSNP6?8[X7=0?@?A=X@BK8[]3O@=E-]!^!VB_*YCOQ-^ +M!^5W$'Z'*+_KV.^$WT'Y'83?'=@L^YWP.RB_@_`[1)%6QWXG_`[*[R#\#E%^ +MU['?";^#\CL(OT.4WW7L=\+OH/P.PN\.;);]3O@=E-]!^!VB2*M/?>V$WT'Y +M'83?(O8[X7=0?@?A=XCRNY[]3O@=E-]!^-V!S;+?";^#\CL(OT,4:?7L +M=\+OH/P.PN\0Y7<]^YWP.RB_@_`[1/E=SWXG_`[*[R#\[L!FV>^$WT'Y'83? +M(8JT>O8[X7=0?@?A=XCRNY[]3O@=E-]!^!VB_*YGOQ-^!^5W$'YW8+/L=\+O +MH/P.PN\015H]^YWP.RB_@_`[1/E=SWXG_`[*[R#\#E%^U[/?";^#\CL(OSNP +M6?8[X7=0?@?A=X@BK2'UM1-^!^5W$'Z'*+\;V.^$WT'Y'83?(^$WT'Y71#305Y+NF3]]NG&=*W=JY+R +M5_XIU"YY=76CL3X0BSXPS!367?V^A&LZZ_6%^38?;](O(LRW^7B3?A%AOLW' +MF_2+"/-M/MZD7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI% +MA/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z +M183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF +M^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?!.?;-OI%<+YM +MHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC +M7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-? +M!.?;-OI%<+YMHU\$Y]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU\$ +MY]LV^D5POFVC7P3GVS;Z17"^;:-?!.?;-OI%<+YMHU]$F&_3\TWZ183Y-CW? +MI%]$F&_3\TWZ183Y-CW?I%]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH +M%Q'FVR;Z183YMHE^$6&^;:)?1)AOF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^; +MZ!<1YMLF^D6$^;:)?A%AOFVB7T28;YOH%Q'FVR;Z183YMHE^$6&^;:)?1)AO +MF^@7$>;;)OI%A/FVB7X18;YMHE]$F&^;Z!<1YMLF^D6$^;:)?A%AOFVB7P3G +MVS;Z18RF^D6,IOI%C*;Z18RF^D6,IOI%C*;Z18RF^D6,IOI%C*;Z18RF^D6, +MIOI%C*;Z18RF^D6,IOI%C*;Z14QI:JA?Q&2J7\1DJE_$9*I?Q&2J7\1DJE_$ +M9*I?Q&2J7\1DJE_$9*I?Q&2J7\1DJE_$9*I?Q&2J7\1DJE_$9*I?/*=I:JA? +M/+^XE_#!="\WN^H#\V5]>>'N7:KW^EWO:OR%A-__Y-)\\VQ]N?GZEOOUNMNK +M#B_B,DV([1N7]S^^5K]\N5]OOMS6U-W&=+U?[X'U?7MW]W%\)=V+>S'_WNVN +MZ;*7JRLF?Z/?Y?Z=.>^6RWL*%Q-7]\M=>_]X\WAS^^D7IEONUSOXV[@>7]UO +M[=VKJS.^%W.>'SQ;$I&S3[@]VX3KL[[W9YXOQU'R?L>%NXMNL=Q1]SS,"R_< +M>T7V,N$/]^/XW8?K/_[MAP]:OSPW7E]YH'XJA5M_2+1^B:[/6GN_/>MCBN^0'J?V\-$>Z9QG/+JM&E$H044G%! +M>AX=`:H#UWK]Z]MJM;'5L%T-T^IR6'W_^?S=5G=^>[TVJ:Y^YM_:O/^8^GCJOU]"?FOG\WFKOSZN(_>'5WWNSMW,O? +M?KU9?L[58-P;7,USZ_GUF3B]X<^]OJ_I[=JOT_OKWJZ+M[M1@]M[@_^8YWZ? +M7Y^+M[M3<^.]N6MZNR[>[J3F]G\(BPM8#FKN6,P-^-1)S9V+N0T^=>$Y^X.O +M[:^Y+3YE:LYQ;M7F=OA4J+GAWMSZ[0+T,C?B4X([*[F;\"G!G97<[?$IP9V5 +MW!WP*<&=E=P=\2G!G97+.*^Z,?.>*.Z^X,_*=*^Z\XL[(=ZZX\XH[(]^YXBXJ[HQ\%XJ[J+@S\ETH +M[J+DCGP7BKLHN2/?A>(N2N[(=Z&XBY([\ETH[J+DCGP7BKLHN2/?A>)N*+DC +MWPV*NZ'DCGPW*.Z&BCOGIP1W0\6=D^\&Q=U0<>?DNT%Q-U3<.?EN4-P-%7=. +MOAL4=T/%G9/O!L7=IN+.R7<;Q=VFXL[)=QO%W:;DCGRW4=QM2N[(=QO%W:;D +MCGRW4=QM2N[(=QO%W:;DCGRW4=QM2N[(=QO%W;;DCGRW5=QM2^[(=UO%W;;B +M+O@IP=VVXB[(=UO%W;;B+LAW6\7=MN(NR'=;Q=VVXB[(=UO%W;;B+LAW6\7= +MKN(NR'<[Q=VNXB[(=SO%W:[DCGRW4]SM2N[(=SO%W:[DCGRW4]SM2N[(=SO% +MW:[DCGRW4]SM2N[(=SO%W5AR1[X;%7=CR1WY;E3^FQ1W4\D=^6Y2W$TE=^2[27$WE=R1[R;%W51R1[Z;%'=3R1WY +M;E+<[4ONR'=[Q=V^Y(Y\MU?<[2ON-OR4X&Y?<;\7=ON)N0[[;*^[V%7<;\MU><;?\;T@]1[X[*.X.%7<;\MU!<7LN-OR4X*[8\7=EGQW5-P=*^ZVY+NCXNY8<;* +MNRWY[JBX.U;<;)N2[X[*>Y.%7=;\MU)<7NN-OQ4X*[<\7=CGQW5MR=*^YVY+NSXNY<<;*NQWY[JRX.U?< +M[)N1[Z[*.XN%7<[\MU%<7F^CLK^[L1?&>JO[.ROQO!=Z;Z.RO[NQ%\9ZJ_ +ML[*_&\%WIOH[*_N[$7QGJK^SLK\;P7>F^CLK^[L1?&>JO[.ROQO!=Z;Z.RO[ +MNQ%\9ZJ_L[*_&\%WIOH[*_N[$7QGJK^SLK\;R7>JO[.ROQO)=ZJ_L[*_F_@I +MP5W9WTWD.]7?6=G?3>0[U=]9V=]-Y#O5WUG9WTWD.]7?6=G?3>0[U=]9V=]- +MY#O5WUG9WTWD.]7?6=G?3>0[U=]9V=]-Y#O5WUG9WTWD.]7?6=G?3>0[U=]9 +MV=]-Y#O5WUG9WTWD.]7?6=G?3>0[U=]9V=]-Y#O5WUG9W^WY*<%=V=_MR7>J +MO[.RO]N3[U1_9V5_MR??J?[.ROYN3[Y3_9V5_=V>?*?Z.RO[NSWY3O5W5O9W +M>_*=ZN^L[._VY#O5WUG9W^W)=ZJ_L[*_VY/O5']G97^W)]^I_L[*_FY/OE/] +MG97]W9Y\I_H[*_N[/?E.]7=6]G=[\IWJ[ZSL[P[\E."N[.\.Y#O5WUG9WQW( +M=ZJ_L[*_.Y#O5']G97]W(-^I_L[*_NY`OE/]G97]W8%\I_H[*_N[`_E.]7=6 +M]G<'\IWJ[ZSL[P[D.]7?6=G?'KOK.SOCN0[U=]9V=\=R7>JO[.ROSN2[U1_9V5_=R3?J?[.RO[N +M2+Y3_9V5_=V1?*?Z.RO[NQ,_);@K^[L3^4[U=U;V=R?RG>KOK.SO3N0[U=]9 +MV=^=R'>JO[.ROSN1[U1_9V5_=R+?J?[.RO[N1+Y3_9V5_=V)?*?Z.RO[NQ/Y +M3O5W5O9W)_*=ZN^L[.].Y#O5WUG9WYW(=ZJ_L[*_.Y'O5']G97]W(M^I_L[* +M_NY$OE/]G97]W9F?$MR5_=V9?*?Z.RO[NS/Y3O5W5O9W9_*=ZN^L[._.Y#O5 +MWUG9WYW)=ZJ_L[*_.Y/O5']G97]W)M^I_L[*_NY,OE/]G97]W9E\I_H[*_N[ +M,_E.]7=6]G=G\IWJ[ZSL[\[D.]7?6=G?G[*_NY"OE/]G97]W85\I_H[*_N["_E.]7=6]G<7\IWJ[ZSL[R[D +M.]7?6=G?7KOK.SO+N0[U=_Y\D&:6_4Y\-WWIY@[3_W=JG,' +MOG/5WWGJ[U8S=ZN%NUCS4\R=I_YN-7.W^KW-@>]<]7>>^KO5-9U=T/UWKOH[ +M3_U=.[L^![YSU=]YZN]@#GSGJK_SU-_!'/C.57_GJ;];YA[T.?"=J_[.4W_W +M8)E;M3GPG:O^SE-_]V#F[D'G#GSGJK_SU-\]F+E[T+D#W[GJ[SSU=P^N-V<' +MOG/5WWGJ[]K9]3GPG:O^SE-_!W/@.U?]G:?^#N;`=Z[Z.T_]W3+WL,^1[U1_ +MYZF_>[C,=>[(=ZJ_\]3?/9RY>]BXH_OO7/5WGOJ[AS-W#QMW=/^=J_[.4W_W +M\)K/CNZ_<]7?>>KOVMGU.?*=ZN\\]7JO_/4WRUSC_H< +M^4[U=Y[ZNT?+7...[K]SU=]YZN\>S=P]ZMR1[U1_YZF_>S1S]ZAS1[Y3_9VG +M_N[1]>;LR'>JO_/4W[6SZW/D.]7?>>KO8(Y\I_H[3_T=S)'O5'_GJ;];YA[W +M.?*=ZN\\]7>/E[G.'?E.]7>>^KO',W>/&W=T_YVK_LY3?_=XYNYQXX[NOW/5 +MWWGJ[QY?\]G1_7>N^CM/_5T[NSY'OE/]G:?^#N;(=ZJ_\]3?P1SY3O5WGOJ[ +M9>Y)GR/?J?[.4W_W9)EKW-']=Z[Z.T_]W9.9NR>=._*=ZN\\]7=/9NZ>=.[( +M=ZJ_\]3?/;G>G!WY3O5WGOJ[=G9]CGRG^CM/_1W,D>]4?^>IOX,Y\IWJ[SSU +M=\O>KOGL[>^CN8(]^I +M_LY3?[?,/>MSY#O5WWGJ[YXM>^KMGUYNS(]^I_LY3?]?.KL^1[U1_YZF_@SGRG>KO//5W,$>^ +M4_V=I_YNF7O>Y\AWJK_SU-\]7^8Z=^0[U=]YZN^>S]P];]S1_7>N^CM/_=WS +MF;OGC3NZ_\Y5?^>IOWM^S6=']]^YZN\\]7?M[/H<^4[U=Y[Z.Y@CWZG^SE-_ +M!W/D.]7?>>KOEKD7?8Y\I_H[3_W=BV6N<4?WW[GJ[SSU=R]F[EYT[LAWJK_S +MU-^]F+E[T;DCWZG^SE-_]^)Z>KOVMGU.?*=ZN\\]7JO_/4WRUS+_L<^4[U=Y[ZNY?+7.>.?*?Z.T_]W-.[K_SE5_ +MYZF_>SES][)Q1_??N>KO//5W+Z_Y[.C^.U?]G:?^KIU=GR/?J?[.4W\'<^0[ +MU=]YZN]@CGRG^CM/_=TR]ZK/D>]4?^>IOWNUS#7NZ/X[5_V=I_[NU76_.CGRG^CM/_5T[NSY'OE/]G:?^#N;( +M=ZJ_\]3?P1SY3O5WGOJ[9>YUGR/?J?[.4W_W>IGKW)'O5'_GJ;][/7/WNG%' +M]]^YZN\\]7>O9^Y>-^[H_CM7_9VG_N[U-9\=W7_GJK_SU-^UL^MSY#O5WWGJ +M[V".?*?Z.T_]']#GRG>KO//5W;Y:YQAW=?^>JO_/4W[V9 +MN7O3N2/?J?[.4W_W9N;N3>>.?*?Z.T_]W9OKS=F1[U1_YZF_:V?7Y\AWJK_S +MU-_!'/E.]7>>^CN8(]^I_LY3?[?,O>USY#O5WWG5WP7=?^>JO_.JOPNZ_\Y5 +M?^=5?Q=T_YVK_LZK_B[H_CM7_9U7_5W0_7>N^CNO^KN@^^]<]7=>]7=!]]^Y +MZN]<]'?O^ASY3O5WGOJ[=\M]4 +M?Q?+!VENW>?`=Z'ZN^^?N,?=XJ=UYPY\%ZJ_B]3?K>>]=>..[K\+U=]%ZN_6 +M,W?KQAW=?Q>JOXO4WZVO^>SH_KM0_5VD_JZ=79\#WX7J[R+U=S`'O@O5WT7J +M[V`.?!>JOXO4WRUSUN?`=Z'ZNTC]G2USC3NZ_RY4?Q>IO[/YY5GG#GP7JK^+ +MU-_9S)UU[L!WH?J[2/V=76_.#GP7JK^+U-^UL^MSX+M0_5VD_@[FP'>A^KM( +M_1W,@>]"]7>1^KMESOL<^4[U=Y'Z.U_F.G?D.]7?1>KO?.;.&W=T_UVH_BY2 +M?^]4?Q>I +MOX,Y\IWJ[R+U=\M<]#GRG>KO(O5WL^4_U=I/ZNG5V?(]^I_BY2?P=SY#O5WT7J[V". +M?*?ZNTC]W3(W]#GRG>KO(O5WPS+7N2/?J?XN4G\WS-P-C3NZ_RY4?Q>IOQMF +M[H;&'=U_%ZJ_B]3?#==\=G3_7:C^+E)_U\ZNSY'O5'\7J;^#.?*=ZN\B]7

;F;M-YXY\I_J[2/W= +M9N9NT[DCWZG^+E)_M[G>G!WY3O5WD?J[=G9]CGRG^KM(_1W,D>]4?Q>IOX,Y +M\IWJ[R+U=\OKO(O5WVYF[;>..[K\+U=]%ZN^V +M,W?;QAW=?Q>JOXO4WVVO^>SH_KM0_5VD_JZ=79\CWZG^+E)_!W/D.]7?1>KO +M8(Y\I_J[2/W=,K?K<^0[U=]%ZN]VRUSCCNZ_"]7?1>KO=C-WN\X=^4[U=Y'Z +MN]W,W:YS1[Y3_5VD_FYWO3D[\IWJ[R+U=^WL^ASY3O5WD?H[F"/?J?XN4G\' +M<^0[U=]%ZN^6N;'/D>]4?Q>IOQN7N1^KMV=GV.?*?ZNTC]'KO(O5WR]S4Y\AWJK^+U-]-RUSCCNZ_"]7?1>KOIIF[J7-'OE/]7:3^ +M;IJYFSIWY#O5WT7J[Z;KS=F1[U1_%ZF_:V?7Y\AWJK^+U-_!'/E.]7>1^CN8 +M(]^I_BY2?[?,O>]SY#O5WT7J[]XOXH_OO0O5WD?J[#S-W'SIWY#O5 +MWT7J[S[,W'WHW)'O5'\7J;_[<+TY._*=ZN\B]7?M[/H<^4[U=Y'Z.Y@CWZG^ +M+E)_!W/D.]7?1>KOEKF/?8Y\I_J[2/W=QV6N^4_U=I/[NX\S=Q\8=W7\7 +MJK^+U-]]G+G[V+BC^^]"]7>1^KN/UWQV=/]=J/XN4G_7SJ[/D>]4?Q>IOX,Y +M\IWJ[R+U=S!'OE/]7:3^;IG[U.?(=ZJ_B]3??5KF&G=T_UVH_BY2?_=IYNY3 +MYXY\I_J[2/W=IYF[3YT[\IWJ[R+U=Y^N-V='OE/]7:3^KIU=GR/?J?XN4G\' +M<^0[U=]%ZN]@CGRG^KM(_=TR][G/D>]4?Q>IO_N\S'7NR'>JOXO4WWV>N?O< +MN*/[[T+U=Y'ZN\\S=Y\;=W3_7:C^+E)_]_F:SX[NOPO5WT7J[]K9]3GRG>KO +M(O5W,$>^4_U=I/X.YLAWJK^+U-\M1^KLORUSCCNZ_"]7?1>KO +MOLSG]4?Q>IO_LR<_>E^4_U=I/[NR_7F[,AWJK^+U-^UL^MSY#O5 +MWT7J[V".?*?ZNTC]'WO.`FO)NY+W?F?@C^NW/TZ_[QD-U;KY2_N[ZJ^/(N9[;_O-W5_;F?$KWS];SW)2Q.[_/MJZ-_Q/N_^6+<7!WR +M)W_G_ABY_SOWUYS_M2+8_33+#\_MX4?]B6__>'O_OU^#P\_!W_X-BB07FH&E +"```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-bsd.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-bsd.qcow2.gz.uu new file mode 100644 index 000000000000..3663da0f939d --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-bsd.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-63x255-512-bsd.qcow2.gz +M'XL("*P[(U0``VEM9RTV,W@R-34M-3$R+6)S9"YQ8V]W,BYO=70`K9C;DM,P +M#(;O^Q3F#`N46').'+:PL,QP!S=PW7;;I^CP[*QK)4H4*5XZ:3N9Z;C_-W+\ +M64E:%.GE7.E=J%QHW7'G[K_3!]S@R_CC3K^^_U@/7Z=5@OG"2"D#]:''C5A_ +M&0<6KO#3`:_C!M6A@H,N-07E<,&L;FY`P5VMSJ?NO!B-2.`EP(0S%^.B^B#5 +M)Q/APOI@Z?I0/W]EEY,#U7Q]F.J3J=K"-5D<**G6PFVS.%12.PNWS^*"DKJS +M<,;.'>!*)74T<#ZCRCVN4E+>PD$65RLIM'`ABVN4E.6=SWO7*BG+.Y_W;JND +M+.]\WKN=DK*\\WGO]DK*\L[GO;M34I9W8'CG&'=04I9W(+Q[1+C'C#LJ*UE.4=".^>$>XYXY1^!Y9W(+Q[0;B7C%/Z'5C>@?#N%>&N&*?T +M.["\`^'=:\*]89S2[\#R#H1W;R?>>:7?@>4="N_>$:M@G-+OT/(.A7>><,`X +MI=^AY1T*[Y!P@7%*OT/+.Q3>E82K&*?T.[2\0^%=3;B&<4J_0\L[%-ZUA'O/ +M.*7?H>4="N\^$.XCXY1^AY9W*+S[1+AKQBG]#BWO@O!N0[C/C%/Z7;"\"\*[ +M+X2[89S2[X+E71#>?27_IA,L%5SCA +M[,=1&N@*[K?@!+<9X.(5[3CXY7`=W=[S]A\2![CKQ.MPLX^C\1[[H`V8DRT7 +ME@4:D1NN<[RUBW?@77<7MV;]^CJN3Y$91M.=J<]-IQNO&OW3G5B/B(/,=-T8 +M%Z\:8E_R$F;.WF9:W7[AQ4"Y,QZX^#T]R?#XF:X6+`:LCA +MK@BGO')`EEP@KTZ`ZN<#_D:X9GHC3N]%YRO!^RU%-EE3JG:QMW;EA_L,H@>A +M@-M9)RGPUU]8XKND84B2[DY\D*;;!EQ-[07"R8-T@>+>`8?Z25IX4+TFC:XK +MW`RUGHP_)S=`Z.1..%GV(I#CS>+_0&^5[GF%>S"Z)J">@<4J6'^L)U9?N.5M +%L04%```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-bsd.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-bsd.vhd.gz.uu new file mode 100644 index 000000000000..2e7c6573ef52 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-bsd.vhd.gz.uu @@ -0,0 +1,17 @@ +# $FreeBSD$ +begin 644 img-63x255-512-bsd.vhd.gz +M'XL("/?%'50``VEM9RTV,W@R-34M-3$R+6)S9"YV:&0N;W5T`*V7/6_#(!"& +M]_R*D[IEL/`98W=IHJCI7*E2.[O$CC+T0TV'#/[QY6R(#W\E;;$)PH)[>(\[ +M$!&B?0!4`JH"58)*J9U)4+>0Y0"FTQ9LZMA^0JT_WDO]?3A%]JD7+2P6W,HW +M)WM,0)I),L"")E$[:D/M,-'-=K\\O.T=#BW.32P52(340.1@GER7#-5U5NT\505)Q48D7%T4K3A.&BLSGHJ"2C8R7?$^O`Z.\]2EHF?%9(XM +M*G-V#*?FK'Z#6RYL+-I4,8F1F5J`BB%#:INT<>LP*"953L?/XNM8]O3A1*HH +M%HQ^GYQV%VVJH!ML%4@2..2*O]:/>7;2=LPBR!2UX&-^_[J=2C@ +M^E0L9M9\.AB3^@K29_:6*$;JZ8YZ$_GO&:@)F&:TW5,%.5Z[@B_;Y['XZHET +M^>/NT'@)YP3ST\#'K1@N:XPN=OMNA#/3 +M[;G,!G5<'./G1'52B%T@*#*33`,K!"+&>3[;=9J*S"0!=)P@6\2!(NX$62<`$O +=DH0+>)$D7,"+).&"7B25^8L@Q.('-E=QRWT,```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-bsd.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-bsd.vhdf.gz.uu new file mode 100644 index 000000000000..c102a9fd6bc6 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-bsd.vhdf.gz.uu @@ -0,0 +1,14 @@ +# $FreeBSD$ +begin 644 img-63x255-512-bsd.vhdf.gz +M'XL("/?%'50``VEM9RTV,W@R-34M-3$R+6)S9"YV:&1F+F]U=`"ME#M/PS`0 +M@/?\BI/8.D1^QUUH55%F)"280W"J#L#"P.`?CR^)&U^>",5VHEAW]^4>]C'6 +M#@`E@)43[WF!/^5T^FR7-32!0%V`TJ`-V*#.^D4V1.!?SR]Y.GR'XTM6\[A\ +M,").K.&BP[*>PQT2G`S".M%D/+&J.$C7[]4$[CX\QQZGEKP+F6!N2C`;K-XJ +M=[&V=F"7UAFX`RZ!V4XF*/!67^C]VX_=$"3U=M7`PYO!E_O+D(H3>WQ8EM&X%H.DLX@4%K_)X7^*>RAL"A3T)/GJZ]-5W]>?M,*(XVTSF%QH+R3> +M%E.`*/$GYAV_$__NSI?=]>,2<;%5Q1\K@TG7`:)&X5H:[N/I^6'HG1PGR9+L +MS`'```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-bsd.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-bsd.vmdk.gz.uu new file mode 100644 index 000000000000..79b142eba461 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-bsd.vmdk.gz.uu @@ -0,0 +1,81 @@ +# $FreeBSD$ +begin 644 img-63x255-512-bsd.vmdk.gz +M'XL("/?%'50``VEM9RTV,W@R-34M-3$R+6)S9"YV;61K+F]U=`"MG%MO(\<1 +MA=_]*QKR6QZ(.9S[PR:.(P<(@@"&;=BOYMQB(?;N0BL$68`_/M,S?5IG1(U[ +M8)7,7;*65<7NZF&)_NJ`6;;^.%=TKBA<,;BR8-U97_H%_PJ=K?8IJ=/G@/_L^;8Q_(MDKH)_#7?]VS_NWX4K-SM]O#PRG8^:%S*_]KP/S5M5 +MSO^YO2VK&]\_^8Q3^(FK\V<;BE,NKUWX!V7AZM8MRRE][O/\]!"VO-2N?QPO +M3^,/GS^.[^Y^^_`^ULZ?K2]9NR1JED+EKLQ]JK`U7[[29_27S7)J[OKKP],O +M#_WW\S8_C7>G+QW35;YV\P$V85WKKN>0:O=DYV5?O_G?T[Q?-X23?6"Z91'+ +M)N;7+L^NK'VN^0#SN79Y[O+&Y4OZ><'S3@IX)W?]\/[TW4\.5=X4[OMO__H= +MTS5SNMES7N`<,F]HLZ=RW7_Y\K)TU^^_<7=^DS_\,BY7(-.UZ]O,.Z_G@,4\ +M^P>A:FMZW\0*_\1RLN[^\G1Q7U\^C: +MRCD7;CWI]:"7HQB&[G09+A^?QD=_O/$H.G^U#F&G_EB+YV/?N'H;Y3'W:?X\??F.Z?KV,YW7X2Z)=`G/_8+YZEO1C>(7UBO''Y-.-3X^? +M3_WG7Q_>#_,;S;UCNF&MW;R<^3371<4UO5Q4?-FY=G=X7MJA0.<-L59U^0OY?E*7E>T;:!/'QZ7I57YG?;C_.7OLK?VX^+F +M5VK]!Q.NZ:S75V4O?I_E&E>(46X2^M]BV?HQX/3M\_HJO[Y*/&N-:L1H-^E^ +MGE-\O-UNY2^QBWAV&M6+,1RI7N5_7XSB.;VL'C]J0![OI^-G`7KF&E6(46[2 +M[=6N#+6C9ZU1C1CM)MU>[:I0.WIV&M6+,1S:;!UJ1\])H_P=/THA._"QK&I" +M[>B9:U0A1KE)MU>[-M2.GK5&-6*TFW1[M;N$VM&STZA>C.'09KM0.WI.&N7O +MV"`@C_?3]:%V],PUJA"CW*3;J]T0:D?/6J,:,=I-NKW:C:%V].PTJA=C.+39 +M*=2.GI-&^;M":E>DTM59J!T]DT;YNTIJ5R73L=_1,]>H0HQRDVZO=NQW]*PUJA&C +MW:3;JQW['3T[C>K%&`YMEOV.GI-&^3M^"((\WD_'?D?/7*,*,DX:Y>]:J5V;3,=^1\]< +MHPHQRDVZO=JQW]&SUJA&C':3;J]V['?T[#2J%V,XM%GV.WI.&N7O^+]0D,?[ +MZ=COZ)EK5"%&N4FW5SOV.WK6&M6(T6[2[=6._8Z>G4;U8@R'-LM^1\])H_P= +M^2/D\7XZ]CMZYAI5B%%NTNW5COV.GK5&-6*TFW1[M6._HV>G4;T8PZ'-LM_1 +M<](H?]=+[?I4NC8+M:-GKE&%&.4FW4[M6O8[>M8:U8C1;M+MU*YEOZ-GIU&] +M&,.AS;+?T7/2*'\W2.V&9#KV.WKF&E6(46[2[=6._8Z>M48U8K2;='NU8[^C +M9Z=1O1C#HG4;T8PZ'-LM_1<](H?S=)[:9D.O8[>N8:58A1;M+MU8[]CIZU1C5B +MM)MT>[5COZ-GIU&]&,.AS;+?T7/2J$RF9Y#'N^DNV5J[Z)EK5"%&N4FW4[M+ +MZ'?1L]:H1HQVDVZG=I?0[Z)GIU&]&,.AS89^%STGC?(E$WZ')-*ZA'X'X7=0 +M?@?A=TCRNTOH=Q!^!^5W$'Z')+^[A'X'X7=0?@?A=P^$WT'Y'83?(8FT.O8[X7=0?@?A=TCRNX[]3O@= +ME-]!^!V2_*YCOQ-^!^5W$'YW8+/L=\+OH/P.PN^01%H=^YWP.RB_@_`[)/E= +MQWXG_`[*[R#\#DE^U['?";^#\CL(OSNP6?8[X7=0?@?A=T@BK3X+M1-^!^5W +M$'Z')+_KV>^$WT'Y'83?(O8[X7=0?@?A=P^$WT'Y'83?(O8[X7=0?@?A=TCRNY[]3O@=E-]!^-V!S;+?";^# +M\CL(OT,2:?7L=\+OH/P.PN^0Y'<]^YWP.RB_@_`[)/E=SWXG_`[*[R#\[L!F +MV>^$WT'Y'83?(8FTABS43O@=E-]!^!V2_&Y@OQ-^!^5W$'Z')+\;V.^$WT'Y +M'83?'=@L^YWP.RB_@_`[))'6P'XG_`[*[R#\#DE^-[#?";^#\CL(OT.2WPWL +M=\+OH/P.PN\.;);]3O@=E-]!^!V22&M@OQ-^!^5W$'Z')+\;V.^$WT'Y'83? +M(2SIW/HGI!NSM7:O2LI? +M^:=8._?JZD9C?2`6?6"<*:R[^F,)UW36ZXOS;=[>I%]$G&_S]B;](N)\F[KY) +MOX@XWZ;GF_2+B/-M>KY)OX@XWS;1+R+.MTWTBXCS;1/](N)\VT2_B#C?-M$O +M(LZW3?2+B/-M$_TBXGS;1+^(.-\VT2\BSK=-](N(\VT3_2+B?-M$OX@XWS;1 +M+R+.MTWTBXCS;1/](N)\VT2_B#C?-M$O(LZW3?2+B/-M$_TBXGS;1+^(.-\V +MT2\BSK=-](N(\VT3_2+B?-M$OX@XWS;1+R+.MTWTBXCS;1/](N)\VT2_",ZW +M;?2+&$WUBQA-]8L83?6+&$WUBQA-]8L83?6+&$WUBQA-]8L83?6+&$WUBQA- +M]8L83?6+&$WUBQA-]8L83?6+F++,4+^(R52_B,E4OXC)5+^(R52_B,E4OXC) +M5+^(R52_B,E4OXC)5+^(R52_B,E4OXC)5+^(R52_B,E4OXC)5+]XSK+,4+]X +MOODNX8/I;C>[Z@.+97WKMX/>_KW_Q/7KT_:_F'#Y@MVR]E]T6E:N.1]=X4_? +M_/C*AHNSV8;7=#=?GOPR7>1=TUZZOT@ZW^`G\=Q\%W,/EX_/=O%*NC^?Y)NB +MB^4+=G=7IW.*8YLU_O+D8OD26_75<_8=QH,??IY_\=Z(Y^N>U]?>+N.\V>[O +MK,_=;MIZX\.X^2K6@^]S]Y^/WT]9]_^_O[^]^^/KH; +MD_-/GG(_[[/Z<7I^0TVM^[?7=NKN[@4S.;6X*Y'CZULKDMF!O@ +M4SN>DY]\;>_F1OB4L#F%ZVS,WP*?*Y$,==_EQ4[A;X +M%.%.0NY6^!3A3D+N-O@4X4Y"[G;X%.%.(NX$/T6XTX@[08I2QIU&W`DRLC+N +M-.).D.^4<:<1=X)\IXP[C;@3Y#MEW&G$G2#?*>-.(^X$^4X9=QIRAWRGC#L+ +MN4.^,\:=A=PAWQGCSD+ND.^,<6&W"'?M8R[-N+.\%.$NR[BSI#O +M.L9=%W%GR'<=XZZ+N#/DNXYQUT7<&?)=Q[CK(NX,^:YCW'41=X9\US'NNH@[ +M0[[K&'==R!WR7<>XZT/ND.]ZQET?<=>'W"'?]8R[/N0. +M^:YGW/4A=\AW/>.N#[E#ONL9=WW$78.?(MP-$7<-\MW`N!LB[AKDNX%Q-T3< +M-3Z'?#*N1;Z;&'=3Q%V+ +M?#%W"'?38R[_)])^1SRW'W"'?S8R[.>0.^6YFW,TA=\AW,^-N +MCKCK\%.$NR7BKD.^6QAW2\1=AWRW,.Z6B+L.^6YAW"T1=QWRW<*X6R+N.N2[ +MA7&W1-QUR'<+XVZ)N.N0[Q;&W1)RAWRW,.[6D#ODNY5QMX;<(=^MC+LUY`[Y +M;F7' +M?+\@=\MW.N-M#[I#O=L;= +M'G*'?+XD_X#/`=_)F7`GYXB[`?A. +MSH0[.4?<#OO).SO9OP4X2[L[V;D.];?2=C?S]8 +M?R=A?SOO).SO +M9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYN1KYC_9V$_=V,?,?Z +M.PG[NQGYCO5W$O9W"WZ*OO).SO%N0[UM])V-\MR'>LOY.POUN0 +M[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7YCO5W$O9W"_(=Z^\D +M[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W(-^Q_D["_FY!OF/]G83]W8)\ +MQ_H["?N[%3]%N`O[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6WTG8WZW(=ZR_D["_ +M6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83]W8I\Q_H["?N[%?F.]7<2]G]8?R=A?[OO).SO-N0[UM])V-]MR'>LOY.PO]N0[UA_)V%_MR'?L?Y.POYNQT\1[L+^ +M;D>^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V=SOR'>OO).SO=N0[UM])V-_MR'>L +MOY.PO]N1[UA_)V%_MR/?L?Y.POYN1[YC_9V$_=V.?,?Z.PG[NQWYCO5W$O9W +M._(=Z^\D[.]VY#O6WTG8W^W(=ZR_D["_VY'O6'\G47]G9_P4YD[S#]SNOSLE[DZW90[X3EE_IZZ_.R7N3K^5.>`[ +M9?V=NO[N=#F<'?"=LOY.77]7SJ[.`=\IZ^_4]7=@#OA.67^GKK\#<\!WROH[ +M=?U=GGM/$W>/ +M*W?`=\KZ.W7]W>/+X>R`[Y3U=^KZNW)V=0[X3EE_IZZ_`W/`=\KZ.W7]W7$. +MW7^GK+]3U]_EN2=U#OF.]7?J^KLG>:YPA^Z_4];?J>OOGB3NGA3NT/UWROH[ +M=?W=D\3=D\(=NO].67^GKK][0[UA_IZZ_>YKG*G?(=ZR_4]??/4WTNOP-SR'>L +MOU/7WQWGT/UWROH[=?U=GGM6YY#O6'^GKK][EN<*=^C^.V7]G;K^[EGB[EGA +M#MU_IZR_4]??/4ONOP-SR'>LOU/7W^6YYW4.^8[U=^KZN^=YKG*'?,?Z.W7]W?/$ +MW?/*'?(=Z^_4]7?/$W?/*W?(=ZR_4]??/;\W$YG!WR'>OOU/5WY>SJ +M'/(=Z^_4]7=@#OF.]7?J^CLPAWS'^CMU_5V>>UGGD.]8?Z>NOWN9YRIWR'>L +MOU/7W[U,W+VLW"'?L?Y.77_W,G'WLG*'?,?Z.W7]WR0[UA_IZZ_*V=7 +MYY#O6'^GKK\#<\AWK+]3U]\=Y]#]=\KZ.W7]79Y[5>>0[UA_IZZ_>Y7G"G?H +M_CME_9VZ_NY5XNY5X0[=?Z>LOU/7W[U*W+TJW*'[[Y3U=^KZNU>7P]DAW['^ +M3EU_5\ZNSB'?L?Y.77\'YI#O6'^GKK\#<\AWK+]3U]_EN==U#OF.]7?J^KO7 +M>:YRAWS'^CMU_=WKQ-WKRAWR'>OOU/5WKQ-WKRMWR'>LOU/7W[V^',X.^8[U +M=^KZNW)V=0[YCO5WZOH[,(=\Q_H[=?W=<0[=?Z>LOU/7W^6YJSJ'?,?Z.W7] +MW56>*]RA^^^4]7?J^KNKQ-U5X0[=?Z>LOU/7WUTE[JX*=^C^.V7]G;K^[NIR +M.#OD.];?J>OORMG5.>0[UM^IZ^_`'/(=Z^_4]7=@#OF.]7?J^KL\]Z;.(=^Q +M_DY=?_NOWN3N'M3N4.^8_V=NO[N3>+N3>4.^8[U=^KZNS>7 +MP]DAW['^3EU_5\ZNSB'?L?Y.77\'YI#O6'^GKK\[SJ'[[Y3U=^KZNSSWMLXA +MW['^3EU_]S;/%>[0_7?*^CMU_=W;Q-W;PAVZ_TY9?Z>NOWN;N'M;N$/WWRGK +M[]3U=V\OA[-#OF/]G;K^KIQ=G4.^8_V=NOX.S"'?L?Y.77\'YI#O6'^GKK_+ +M<^_J'/(=Z^_4]7?O\ESE#OF.]7?J^KMWB;MWE3OD.];?J>OOWB7NWE7ND.]8 +M?Z>NOWMW.9P=\AWK[]3U=^7LZASR'>OOU/5W8`[YCO5WZOJ[XQRZ_TY9?Z>N +MO\MS[^L<\AWK[S3J[PS=?Z>LO].HOS-T_YVR_DZC_L[0_7?*^CN-^CM#]]\I +MZ^\TZN\,W7^GK+_3J+\S=/^=LOY.H_[.T/UWROH[)?W=ASJ'?,?Z.W7]W8<\ +M5[E#OF/]G;K^[D/B[D/E#OF.]7?J^KL/B;L/E3OD.];?J>OO/EP.9X=\Q_H[ +M=?U=.;LZAWS'^CMU_1V80[YC_9VZ_NXXA^Z_4];?6?Z!FSO7.>`[8_W=MU]X +MP%WVT[EPA^Z_,];?F>OOSFGO7+A#]]\9Z^_,]7?GQ-VY<(?NOS/6WYGK[\Z7 +MP]D!WQGK[\SU=^7LZASPG;'^SEQ_!^:`[XSU=^;Z.S`'?&>LOS/7W^4YJ7/` +M=\;Z.W/]G>2YRAWPG;'^SEQ_)^GE2>4.^,Y8?V>NOY/$G53N@.^,]7?F^CNY +M',X.^,Y8?V>NORMG5^>`[XSU=^;Z.S`'?&>LOS/7WQWGT/UWQOH[<_U=GM,Z +MAWS'^CMS_9WFN<(=NO_.6']GKK_3Q)T6[M#]=\;Z.W/]G2;NM'"'[K\SUM^9 +MZ^_TOOP!SR'>OOS/5W8`[YCO5WYOJ[/&=U +M#OF.]7?F^CO+OORMG5.>0[UM^9Z^_`'/(=Z^_,]7?'.73_G;'^SEQ_E^>:.H=\ +MQ_H[<_U=D^<*=^C^.V/]G;G^KDG<-84[=/^=L?[.7'_7).Z:PAVZ_\Y8?V>N +MOVLNA[-#OF/]G;G^KIQ=G4.^8_V=N?X.S"'?L?[.7'\'YI#O6']GKK_+NORMG5^>0[UA_9ZZ_`W/(=ZR_,]??'>?0_7?&^CMS_5V>Z^H< +M\AWK[\SU=UV>*]RA^^^,]7?F^KLN<=<5[M#]=\;Z.W/]79>XZPIWZ/X[8_V= +MN?ZNNQS.#OF.]7?F^KMR=G4.^8[U=^;Z.S"'?,?Z.W/]'9A#OF/]G;G^+L_U +M=0[YCO5WYOJ[/L]5[I#O6']GKK_K$W=]Y0[YCO5WYOJ[/G'75^Z0[UA_9ZZ_ +MZR^'LT.^8_V=N?ZNG%V=0[YC_9VY_@[,(=^Q_LY<0_??&>OOS/5W>6ZH +M<\AWK+\SU]\->:YPA^Z_,];?F>OOAL3=4+A#]]\9Z^_,]7=#XFXHW*'[[XSU +M=^;ZN^%R.#OD.];?F>OORMG5.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\ +M-]8YY#O6WYGK[\8\5[E#OF/]G;G^;DSLOS/7W^6Y +MCW4.^8[U=^;ZNX]YKG"'[K\SUM^9Z^\^)NX^%N[0_7?&^CMS_=W'Q-W'PAVZ +M_\Y8?V>NO_MX.9P=\AWK[\SU=^7LZASR'>OOS/5W8`[YCO5WYOH[,(=\Q_H[ +M<_U=GOM4YY#O6']GKK_[E.NORMG5^>0[UA_9ZZ_`W/(=ZR_,]??'>?0_7?& +M^CMS_5V>^USGD.]8?V>NO_NLZAWS'^CMS_=UUGBO$.W7]G +MK+\SU]]=)^ZN"W?H_CMC_9VY_N[ZOOP!SR +M'>OOS/5W8`[YCO5WYOJ[/'=3YY#O6']GKK^[R7.5.^0[UM^9Z^]N$GOO;A)W-Y4[Y#O6WYGK[VXNA[-#OF/]G;G^KIQ=G4.^8_V=N?X.S"'? +ML?[.7']WF&O.^"G,79-_X.9NZQSP7OO&M??W2;N;G\K<\!W#>OO&M??W5X.9X?^O.URXO07OKYWW[X^ +MNOHQV*)KB*)!@8-WCFH#_R^KH?_U.JT=-Y`G_GO_#U+^\?_I4' +M^Q^?W;8_->VI[4Z#_NHK_,]?_PV^OCWZ[/Y_;_AN#GQV'\[E%UQ^.SO,W=R; +M^_[9W>_]DV>Y]]1][N[_^-[<]?M[O]_VZ+-;Y[[[:D._0-_LG_S9[0_W0][_ +M.O^X0ME.Y_R?4]R]I.7K>ZJO#_7X#][N3U[?Z?AV?_S[0/_PGY=[?C)O9O3/U<$PP^S?/]=;`)_ +@Y[_P]1_O'_YU-]BDP3_M!)MO])W/C_X'"T=/.U"H```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-ebr.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-ebr.qcow2.gz.uu new file mode 100644 index 000000000000..71e3879fa9ec --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-ebr.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-512-ebr.qcow2.gz +M'XL("%+N+50``VEM9RTV,W@R-34M-3$R+65B2D"8<6%I89[N`"N$Y/3]'AV:EK)784*=YVTG8R[;C_-W+\ +M64U:%.%A3&F-JXQKS&%C3I_I!2;Y,'R9XZ_O/Q;IXW@38+904L+`*[<14IIW-N_=5DAIWMF\=SLAI7D'BG/"/TQUDII7D'S+MGA'L><4*_`\T[8-Z](-S+B!/Z'6C>`?/N%>%N(T[H +M=Z!Y!\R[UX1[$W%"OP/-.V#>O1UY9X5^!YIWR+Q[1ZPBXH1^AYIWR+RSA(.( +M$_H=:MXA\PX)YR).Z'>H>8?,NY)P5<0)_0XU[Y!YMR1<'7%"OT/-.V3>-81[ +M'W%"OT/-.V3>?2#N^*0GX1[GZT9V'>ZT\7KX^M<-0')H#U +M)<"I"@.NF77"9=@;%P+E"0>WFGN[A +M,F!9FK8=`7]W]<%D&9?7M]S[8;\K6^&H#QSO%L-G!ZS#OP-+O\G*RM3PT`K_ +MWO\1UK>>[X8OX/1_!VB@*[COB"/<.L'Y"XQ#\LUT6PV\2]\GN-4B=N83;O+? +M`7_+LY<&U,F6\\I2][VEMS599W^E[6^(NA];=J7F:(6[3=Q9A"3-G;S6N;COS8EB^,QZX!KTB^K:!%1#P<@"<@GR"DH<5?AYO`/Y58S'"MC@ +MQ!YN$FPJ*(2K+%R&SLY::2IQW&77G?UOX4K3)UR^I0Y/@K4AQVJP,FZQ*#1W +MGYUGX"WP#)@:?<(%SOF%O[Z;+T,XX6[H`S]<3;C"7<\MG-@)%UQJVIZQ:U<][(>:/>3@'[^,@63P5YJ6F""L81[> +M@0$+(=P/0!>@.]`M:$7M4H*^@[("L$9?<*AS_PI]\^=WV_Q[/V;^UV\<+!?< +M*W8G?RQ`VD%*0$.#Z%=J0Q\PV%@:4&B:`L1$[&J<1)'9%^ +MW#\^C-454W5G+S=.UT'1L1X%5Y=E.XZ3ULOVIZ*ADX/,4**7R,!QD3HE1EY, +MYMRDLF#G<'K-ZQK<[<:OA4L5FQBEK07H'$JDMDV;,`^38E/E>/AK/@[M2!\N +MI(IFBS&VR>5PT:<*ALY>@22!:^'"0#F,<3.I\JW9T[&?]`T["4(%`P[AQ[-W +M1@'7IW.Q,N?+B[&HSZS&]86`Z_IZX,KNJ!N_.P08137MTMSO5>_?V/=V1M_. +M;=LMQ[VF#K>[#J@4&#,!/@5]3>+EJ"HRV[-3F)EZV=#?9_%S`@X)HTHZSI6& +M"C^K\&7_/+.^E5DX#JX/V.'P$BX(YJ=]C-LQ7.&V&T_5LQ?/.]YFN*W[!YQ< +M4T=G0CMG6`Q6)4X64XW\^#I#WD)>@*B\#6/@:7WAK.]N*@.C<%?TP31<0[@R +M[I\S'%X(%V)*=ZW"8]B`PP\EB,]#V +MFM;+AOYG%C\.B/Y3E.S;AOXP3:90>F`RA1;8)E9HTGX_M%>8Z*)`N(07!<(E +CO"@0+N%%@7`)+PJ$2WA1(%S2BX*V5T`A-O\!]-GJEUT.```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-ebr.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-ebr.vhdf.gz.uu new file mode 100644 index 000000000000..edf435474725 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-ebr.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-512-ebr.vhdf.gz +M'XL("%/N+50``VEM9RTV,W@R-34M-3$R+65B?[\69 +M,?\`N#?9YP7M:O2TB^6BH_'#_4">!'I)Z[A@L(^@U*X;80KG+")=OI,[$_%>1?/(]S&OP$G+VGG +M/,%L2C!KK,J;+,8U>BZ.,W`+O`!F>IF@P"&^<-9O/55#$',OZ`=3ALB1">,5[FZEV=>9@\/'-N/'F(H3>7(\3>0O!NJLL+@/=KNDX +M+VB?5[1YH.R!V3QH^G^;+D`WH"UHA?-2@EY#:6*@H)G4UM]?MOXY_<811ASW +MQ2#9\;PH\+;H$D2%']$?.(_T>]@?EZ?/8\"%4A4^+#4Z73F(G)AKJ+E/NY?' +ML7;%U$F&>(^CGG'9* +-^^\N_@`\0K'N$`D````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-ebr.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-ebr.vmdk.gz.uu new file mode 100644 index 000000000000..ada1aea35e94 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-ebr.vmdk.gz.uu @@ -0,0 +1,84 @@ +# $FreeBSD$ +begin 644 img-63x255-512-ebr.vmdk.gz +M'XL("%/N+50``VEM9RTV,W@R-34M-3$R+65B +M::MUJP/[V%W;W4.U=-4%9=GTX=RE=9>+NW2N*%T&-_S3]')9_FP,KTNZ\?2W +MMW__\<2//YY.3U],8`A1$H),X<28O<_3:?%!N//GHF8WAM=Y%RX/4>V+P`AW +MWKBQ"3?TPYW70IA=,][NPH7`N03D9G#%2DV;Q7XNNS]\$9L7\LM##L/QEK6K +MVT71E,=JYJ\[CO'NX_/+Z/^9W#V0[.ES+X +ME[>`,!16E>$BW`AP=8`HO>W=[\,VC_^'3 +M!__F[M?W[U+OPMF&EM4CT'5L5.Z*/$#%TD+[BH`8'IOQU-S3+_>//]_?OA_* +M_.CO3E\ZPI6A=\,!7F->4]5#2+EYLD/:3]_^[W&HUW7Q9.\)-R8Q%C&\=W%V +M116PA@/,A][ENAR!]^]N,32+AZ^C(+SM,Y8#3/X2)V;8(/ +M0^P2;HPGZ]XVCXW[IOGH3U^^??M-.MDF%'L97T-J/J"4$W1XOL=V#HV;3GHZ +MZ/$HNJX]-5WSX=$_A.--1]&&I[6+E89CO3P?X_Q]JO&D^O#$N*D9X']]A>F+",04X__CPZ73[],O]NV[X +M0G-O"-=-O1O2&4YS2BKEM$PJO>W0NSL\IS9@$\Z'%DU)7>,7QH`UY?'$5N_#TZ?2S;[HA+7=W+HJ[=!3]\BBT18LN3`<]]&(ZBIC8I]-'?XMP>18/ +ML)\U9\HI/,K#DSQE-!^@C^\?QM3*_$[G<;[\7O;:>7QY\2VU^IV`$YQU?F6V +M]_V,KWP&Z`0L>\ZO#/E=Q+/0J%*,:@8W_#1Q^F[X_-?P^4'@PB-V%<]:HQHQ +MVB/=*\/WBYMX=AKEQ>@/P5UBB_@#"N1Z;"J-7&\D.+?H71%[1\]"HTHQJAG< +M5N_*V#MZUAK5B-&N9KG45Z,_A#<-?:./X!!KL?>T\7KL'8U<;VSUKN*\HV>A4:48U0QNHW<5YQT]:XUJQ&A7LUL6RWE' +MSTZCO!C](3C.NT)ZQ^NQ=S1RO;'9.\X[>A8:58I1S>"V>L=Y1\]:HQHQVM7L +MEL5RWM&STR@O1G\(CO.NE-[Q>NP=C5QO;/:.\XZ>A4:58E0SN*W><=[1L]:H +M1HQV-;MEL9QW].PTRHO1'X+CO../3I#KL74?/6J,:,=K5[);%\'GM'(]<;6[V[S6Q;+>4?/3J.\&/TA.,Z[6GK'Z[%W-'*]L=D[ +MSCMZ%AI5BE'-X+9ZQWE'SUJC&C':U>R6Q7+>T;/3*"]&?PB.\X[_\8)N-S=YQWM&ST*A2C&H&M]4[SCMZUAK5B-&N9K3'Z0W"<=V0M +M(==C[VCD>F.S=YQW]"PTJA2CFL%M]8[SCIZU1C5BM*O9+8OEO*-GIU%>C/X( +M7)W%WMVD=[P>>TR6Q7+> +MT;/3*"]&?PB.\ZZ3WO&:K';J7?<";MD[SCMZ%AI5BE'-X+9ZQWE'SUJC&C': +MU>R6Q7+>T;/3*"]&?PB.\\Y+[W@]]HY&KC\=Y1\]"HTHQJAG<5N\X[^A9 +M:U0C1KN:W;)8SCMZ=AKEQ>@/P7'>]=([7H^]HY'KC<=[1L]"H4HQJ!K?5 +M.\X[>M8:U8C1KF:W+);SCIZ=1GDQ^B-P33;U+NW<(->A=\G(]<96[YHX[Y)G +MH5&E&-4,;J-W39QWR;/6J$:,=C6[9;%QWB7/3J.\&/TAN#CO(/P=E+^#\'?8 +MY>^:..\@_!V4OX/P=]CE[YHX[R#\'92_@_!W*]DMBXWS#L+?0?D["']W`"[. +M.PA_!^7O(/P==OF[)LX["'\'Y>\@_!UV^;LFSCL(?P?E[R#\W4IVRV+CO(/P +M=U#^#L+?'8"+\P["WT'Y.PA_AUW^KHGS#L+?0?D["'^'7?ZNB?,.PM]!^3L( +M?[>2W;+8..\@_!V4OX/P=_MP;19[)_P=E+^#\'?8Y>]:SCOA[Z#\'82_PRY_ +MUW+>"7\'Y>\@_-U*=LMB.>^$OX/R=Q#^[@`_:SGOA+^# +M\G<0_@Z[_%W+>2?\'92_@_!W*]DMB^6\$_X.RM]!^+L#<)QWPM]!^3L(?X== +M_J[EO!/^#LK?0?@[[/)W+>>=\'=0_@["WZUDMRR6\T[X.RA_!^'O#L!QW@E_ +M!^7O(/P==OF[EO-.^#LH?P?A[[#+W[6<=\+?0?D["'^WDMVR6,X[X>^@_!V$ +MO]N'NV6Q=\+?0?D["'^'7?[NQGDG_!V4OX/P=]CE[VZ<=\+?0?D["'^WDMVR +M6,X[X>^@_!V$OSL`QWDG_!V4OX/P=]CE[VZ<=\+?0?D["'^'7?[NQGDG_!V4 +MOX/P=RO9+8OEO!/^#LK?0?B[`W"<=\+?0?D["'^'7?[NQGDG_!V4OX/P=]CE +M[VZ<=\+?0?D["'^WDMVR6,X[X>^@_!V$OSL`QWDG_!V4OX/P=]CE[VZ<=\+? +M0?D["'^'7?[NQGDG_!V4OX/P=RO9+8OEO!/^#LK?0?B[?;@NB[T3_@[*WT'X +M.^SR=QWGG?!W4/X.PM]AE[_K..^$OX/R=Q#^;B6[9;&<=\+?0?D["']W`([S +M3O@[*'\'X>^PR]]UG'?"WT'Y.PA_AUW^KN.\$_X.RM]!^+N5[);%"7\'Y>\@_!UV^;N.\T[X.RA_!^'O5K); +M%LMY)_P=E+^#\'<'X#COA+^#\G<0_@Z[_%W'>2?\'92_@_!WV.7O.LX[X>^@ +M_!V$OUO);EDLYYWP=U#^#L+?[X +M..]6%7TK_Y1ZY]:S>Z'%/P;WLMA);HA1;I@V$5.YOP]P@C.60^(:N[X/>$0. +MB;0NY^M5;R"&1UN4F;R"&1UN4F/??N]\LAD=;E]'R5'!)I74[/5\DAD=;E]'R5'!)I76XBAT1:EYO((9'6 +MY29R2*1UN8D<$FE=;B*'1%J7F\@AD=;E)G)(I'6YB1P2:5UN(H=$6I>;R"&1 +MUN4F;R"&1UN4F$-Y5#PIO*(>%-Y9#PIG)(]%EF*(=$;RJ'1&\J +MAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ' +M1&\JAT1O*H<\9UEF*(<\9Z9RR//+7TU\#.YEL9/<\(+VMP-BLWL7C$_>2%8U +MXW_A\CZ8>2]PM\'V*_E]/?P9/KY2N,ZZW/ZW`1:%:YH7@/]D?N?/IO';\ZO& +M_UU,OTKVY=_;-YZ^.T^ +MSHFT[+?@OA:X\.V[%\_9+^[6YTZO!>ZKZ9-PE\]EI_ND8\4:_Z;M:W9=Q.DY +MAV\3@;WC?\K.<\!TONXYO_IE&N=9N9_)S[TL-WR+U-\UJ^D>R+_P-J-:`0'F`````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu new file mode 100644 index 000000000000..4753ee6b9f3a --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu @@ -0,0 +1,132 @@ +# $FreeBSD$ +begin 644 img-63x255-512-gpt.qcow.gz +M'XL("+HS(E0``VEM9RTV,W@R-34M-3$R+6=P="YQ8V]W+F]U=`"MG?U%5=OB9*HC(C[U-MNM`'/RH9[UH.ZKQQU&]ES?7PSR?,@(_=6V!!51$$% +MX6YD'BTNJE2KC@Z'NV]-TTG3]DT[-<>EN?GG]"'-O7]X^-'\^-M?_GI]_]N/ +MW^[&Y/"3I]P_M]I(FGNP]>GUN8P_0MS-Q]P[MZKLW_CU=U[LY=S5[_= +MO5G\G+)!>S#8I+E#>GU"3J_]UU[?=_=VY>[T'N_M*GF['1OL'PS^GN;^2*]/ +MR=L=V-SX8.[DWJZ2MSNQN?FGL"B!96%S:S#7PJ"?&>,.XNX$^0[8]Q9 +MR!WRG3'N+.0.^&W"'? +MM8R[-N0.^:YEW+41=XJ?(MRU$7>*?-.NB[A3Y+N.<==%W"GR7<>XZT+ND.\ZQET7%W"'?=8R[+N0.^:YCW'4A=\AW'>.N#[E#ONL9=WW('?)=S[CK(^X, +M/T6XZR/N#/FN9]SU$7>&?-$W"'?#8R[(>0.^6Y@W`TA=\AW`^-N"+E#OAL8=T/( +M'?+=P+@;0NZ0[P;&W1ARAWPW,N[&D#ODNY%Q-T;>0[R;&W11QUR+? +M38R[*>0.^6YBW$TA=\AW$^-N"KE#OIL8=U/('?+=Q+B;0NZ0[R;&W11RAWPW +M,>[FD#ODNYEQ-X?<(=_-C+LYXJ[#3Q'NYHB[#OEN9MS-$7<=\MW,N)LC[CKD +MNYEQ-T?<=OP4X6Z-N.N1[U;&W1IQUR/?K8R[->*N1[Y;&7=KQ%V/?+%W"'?;8R[+>0.^6YCW&TA=\AW +M&^-N"[E#OML8=UO('?+=QKC;0NZ0[S;&W1YRAWRW,^[VD#ODNYUQMT?<#?@I +MPMT><3<@W^V,NSWB;D"^VQEW>\3=@'RW,^[VB+L!^6YGW.T1=P/RW)N0+X[,NZ.(7?(=T?&W3'D#OGNR+@[AMPAWQT9=\>0.^2[(^/N +M&'*'?'=DW!U#[I#OCH0[R=_A<\!WLOY.POQN![X3U=Q+V=R/PG;#^3L+^;@2^$];?2=C?CLOY.POQN![X3U=Q+V=R/PG;#^ +M3L+^;@2^$];?2=C?C]8?R=A?SOO).SO9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_ +M-R/?L?Y.POYN1KYC_9V$_=V,?,?Z.PG[NP4_1;@+^[L%^8[U=Q+V=POR'>OO +M).SO%N0[UM])V-\MR'>LOY.POUN0[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V" +M?,?Z.PG[NP7YCO5W$O9W"_(=Z^\D[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G +M87^W(-^Q_D["_FY!OF/]G83]W8J?(MR%_=V*?,?Z.PG[NQ7YCO5W$O9W*_(= +MZ^\D[.]6Y#O6WTG8WZW(=ZR_D["_6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83] +MW8I\Q_H["?N[%?F.]7<2]G]8 +M?R=A?[["_FY#OF/]G83]W89\Q_H["?N[#?F.]7<2]G<; +M\AWK[R3L[S;D.];?2=C?;OO).SO-N0[UM])V-]MR'>LOY.PO]N0 +M[UA_)V%_M^.G"'=A?[^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V +M=SOR'>OO).SO=N0[UM])V-_MR'>LOY.PO]N1[UA_)V%_MR/?L?Y.POYN1[YC +M_9V$_=V.?,?Z.PG[NQWYCO5W$O9W._(=Z^\D[.]VY#O6WTG8W^W(=ZR_D["_ +M.^*G"'=A?W=$OF/]G83]W1'YCO5W$O9W1^0[UM])V-\=D>]8?R=A?W=$OF/] +MG83]W1'YCO5W$O9W1^0[UM])V-\=D>]8?R=A?W=$OF/]G83]W1'YCO5W$O9W +M1^0[UM])V-\=D>]8?R=A?W=$OF/]G>;ON+FFS@'?W3R%N5/7W^7[])K*'?"= +MLOY.77_7).Z:S)T=\%.8.W7]79.X:_XH<\!WROH[=?U=OOP!SPG;+^3EU_!^:`[Y3U=^KZNSSWI,X!WRGK[]3U=T_R +M7%/F@.^4]7?J^KLGB;LGE3O@.V7]G;K^[DGB[DGE#OA.67^GKK][TSB'?L?Y. +M77_W-,]5[I#O6'^GKK][FKA[6KA#]]\IZ^_4]7=/$W=/"W?H_CME_9VZ_N[I +MR9\=NO].67^GKK\K9U?GD.]8?Z>NOP-SR'>LOU/7WX$YY#O6WZGK[_+LOU/7WY6SJW/(=ZR_4]??@3GD.];?J>OOP!SR'>OOU/5W>>YY +MG4.^8_V=NO[N>9ZKW"'?L?Y.77_W/''WO'"'[K]3UM^IZ^^>)^Z>%^[0_7?* +M^CMU_=WSDS\[=/^=LOY.77]7SJ[.(=^Q_DY=?P?FD.]8?Z>NOP-SR'>LOU/7 +MW^6Y%W4.^8[U=^KZNQ=YKG"'[K]3UM^IZ^]>).Y>5.Z0[UA_IZZ_>Y&X>U&Y +M0[YC_9VZ_N[%Z>+LD.]8?Z>NORMG5^>0[UA_IZZ_`W/(=ZR_4]??@3GD.];? +MJ>OO\MS+.H=\Q_H[=?W=RSQ7N4.^8_V=NO[N9>+N9>$.W7^GK+]3U]^]3-R] +M+-RA^^^4]7?J^KN7)W]VZ/X[9?V=NOZNG%V=0[YC_9VZ_@[,(=^Q_DY=?P?F +MD.]8?Z>NO\MSK^H<\AWK[]3U=Z_R7.$.W7^GK+]3U]^]2MR]JMPAW['^3EU_ +M]RIQ]ZIRAWS'^CMU_=VKT\79(=^Q_DY=?U?.KLXAW['^3EU_!^:0[UA_IZZ_ +M`W/(=ZR_4]??Y;G7=0[YCO5WZOJ[UWFNO3_[LT/UWROH[=?U=.;LZAWS'^CMU_1V80[YC +M_9VZ_@[,(=^Q_DY=?Y?GWM0YY#O6WZGK[][DN<(=NO].67^GKK][D[A[4[E# +MOF/]G;K^[DWB[DWE#OF.]7?J^KLWIXNS0[YC_9VZ_JZ<79U#OF/]G;K^#LPA +MW['^3EU_!^:0[UA_IZZ_RW-7=0[YCO5WZOJ[JSQ7N4.^8_V=NO[N*G%W5;A# +M]]\IZ^_4]7=7B;NKPAVZ_TY9?Z>NO[LZ^;-#]]\IZ^_4]7?E[.H<\AWK[]3U +M=V`.^8[U=^KZ.S"'?,?Z.W7]79Y[6^>0[UA_IZZ_>YOG"G?H_CME_9VZ_NYM +MXNYMY0[YCO5WZOJ[MXF[MY4[Y#O6WZGK[]Z>+LX.^8[U=^KZNW)V=0[YCO5W +MZOH[,(=\Q_H[=?T=F$.^8_V=NOXNS[VK<\AWK+]3U]^]RW.5.^0[UM^IZ^_> +M)>[>%>[0_7?*^CMU_=V[Q-V[PAVZ_TY9?Z>NOWMW\F>'[K]3UM^IZ^_*V=4Y +MY#O6WZGK[\`<\AWK[]3U=V`.^8[U=^KZNSSWOLXAW['^3EU_]S[/%>[0_7?* +M^CMU_=W[Q-W[RAWR'>OOU/5W[Q-W[RMWR'>LOU/7W[T_79P=\AWK[]3U=^7L +MZASR'>OOU/5W8`[YCO5WZOH[,(=\Q_H[=?U=GKNN<\AWK+_3J+\S=/^=LOY. +MH_[.T/UWROH[C?H[0_??*>OO-.KO#-U_IZR_TZB_,W3_G;+^3J/^SM#]=\KZ +M.XWZ.T/WWRGK[Y3T=Q_J'/(=Z^_4]7ANOP-SR'>LO[/\'3=WJ'/`=\;ZNYL?>,!=]M.A<@=\9ZR_,]??'=+>H7"' +M[K\SUM^9Z^\.B;M#X0[=?V>LOS/7WQU._NS0_7?&^CMS_5TYNSH'?&>LOS/7 +MWX$YX#MC_9VY_@[,`=\9Z^_,]7=Y3NH<\)VQ_LYOOS/5WDKB3RAWPG;'^SEQ_)Z>+LP.^,];?F>OORMG5.>`[8_V= +MN?X.S`'?&>OOS/5W8`[XSEA_9ZZ_RW-:YY#O6']GKK_3/%>Y0[YC_9VY_DX3 +M=UJX0_??&>OOS/5WFKC3PAVZ_\Y8?V>NO].3/SMT_YVQ_LYOOS/5W;9ZKW"'?L?[.7'_7)N[: +MPAVZ_\Y8?V>NOVL3=VWA#MU_9ZR_,]??M2=_=NC^.V/]G;G^KIQ=G4.^8_V= +MN?X.S"'?L?[.7'\'YI#O6']GKK_+ZZRAWR'>OOS/5W7>*NJ]PAW['^SEQ_UYTNS@[YCO5WYOJ[Z0[UA_9ZZ_ZQ-W +M?>$.W7]GK+\SU]_UB;N^<(?NOS/6WYGK[_J3/SMT_YVQ_LYNOQM.%V>'?,?Z.W/]73F[.H=\Q_H[ +M<_T=F$.^8_V=N?X.S"'?L?[.7'^7Y\8ZAWS'^CMS_=V8YRIWR'>LOS/7WXV) +MN[%PA^Z_,];?F>OOQL3=6+A#]]\9Z^_,]7?CR9\=NO_.6']GKK\K9U?GD.]8 +M?V>NOP-SR'>LOS/7WX$YY#O6WYGK[_+<5.>0[UA_9ZZ_F_)LOS/7 +MWTV)NZERAWS'^CMS_=V4N)LJ=\AWK+\SU]]-IXNS0[YC_9VY_JZ<79U#OF/] +MG;G^#LPAW['^SEQ_!^:0[UA_9ZZ_RW,?ZQSR'>OOS/5W'_-LOS/7WWW*?3A=GAWS'^CMS_5TY +MNSJ'?,?Z.W/]'9A#OF/]G;G^#LPAW['^SEQ_E^<^USGD.];?F>OO/N>YRAWR +M'>OOS/5WGQ-WGPMWZ/X[8_V=N?[N<^+N<^$.W7]GK+\SU]]]/OFS0_??&>OO +MS/5WY>SJ'/(=Z^_,]7=@#OF.]7?F^CLPAWS'^CMS_5V>^U+GD.]8?V>NO_N2 +MYPIWZ/X[8_V=N?[N2^+N2^4.^8[U=^;ZNR^)NR^5.^0[UM^9Z^^^G"[.#OF. +M]7?F^KMR=G4.^8[U=^;Z.S"'?,?Z.W/]'9A#OF/]G;G^+L]]K7/(=ZR_,]?? +M?OOOB;NOA;NT/UWQOH[<_W=U\3=U\(=NO_.6']GKK_[>O)G +MA^Z_,];?F>OORMG5.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F^KL\]ZW.(=^Q +M_LYOOOB?NOF?NV@-^BORYQ^[-?L^]\7690W_> +M=GDJF+OW[<=O5W>#Z+ZJMF2`T>O[P[\^=%_5K[R^[O;\6FT.,_@[_X$??[Y^ +M^%<9O+T[Z-\8S*_PX5Q^P]W=W4&WT=1^X\YC^CC(_3<\UNOTP!M^#_Y5?W^UU/VW7M'W33NDBQU::3INN+7.W[[5;[[^^ +M__S+7YO?__3W?YS'_KN^W=OK?G9MAO7V#Q_8W*L3^G9_^+=[-W?[Y7OPIYWG +MC,X]P7.W7[Z[G\RA#S[7_NRI@])7=_%S>S?7'1X^-=Y_:NR:49O^YM^&9CKW +M/P_FT!\?_RODW=XV_OR'[S;CS:?)W7^:T=O_EVEJ +M!CG_7W;GG]M__NWZGW=C[Z__[VUZ?76;I'.[TIP8(^^`_0TYOO3@\?TOE%P4^9'_>O$;T_!WZ]\DNG +M=_M_-9Z_QL[@[_P'?OQ^_?"ON\$V#3[:*VP/_?J(GQWGN4?\[#C//>)GQWGN +M43\[SH./^-EQGGO$SX[SW"-^=ISG'O6SXV;P]O<<'^F+^'GNS%YKS;PVZ]#T +M_HLX^W+\XS^NK_\7O-V[WW-D7_I_\D4<_V3LC_A%_#SW\R_B/?VYS=_AAN9_O;_@'C+'O6L```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu new file mode 100644 index 000000000000..26ffd0b9f976 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu @@ -0,0 +1,26 @@ +# $FreeBSD$ +begin 644 img-63x255-512-gpt.qcow2.gz +M'XL("+`[(U0``VEM9RTV,W@R-34M-3$R+6=P="YQ8V]W,BYO=70`K9A+;YPP +M$(#O^15.WTT:BLVL/+(]3%:EWVM]>C`T&,P/)UKMHE[N[CJ:?]LC`>$Q$(0-2C+@9 +MZ]+A@,+%?#G`<=PD.X'@8(A:@K9PDLQN;0#!G1SU2]??C,R+$(<`#8Z\&0?E +M!R8_/T(>F!^$SD_@ZZ>&.'\@6<]/F/S\J)3"99LX0*)R"E=LX@02M:=PY29. +M(E$5A:LW<0J):@@0F+D.B*._XMG] +M*Y`HRCN^[=T>B:*\X]O>E4@4Y1W?]JY"HBCO@/"..5R-1%'>@>?=L<4]^%P2+\#RCOPO'MI +M<2<.A_0[H+P#S[M3BWOE<$B_`\H[\+P[6WC'D7X'E'?"\^ZU9<4.A_0[07DG +M/.^XQ8'#(?U.4-X)SSMA<=+AD'XG*.^$YYVRN,3AD'XG*.^$YUUJ<9G#(?U. +M4-X)S[OO;>X#PZ']#M!>2<][SY: +MW">'0_J=I+R3GG?G%G?A<$B_DY1WTO/NTN(^CSC`HD;OXAB_+.YJ4;.`]#N9 +MW!.W6^+HAY5#CK/2';3`P(RX>-H@JL"KU]?;@\`*L6* +M8@'\/N37EUM77^;=0&>WZIN!`J;DB.OGJLII?E>[:W9S_O6;AOUPT^W+3>-J +M_;!4)%YVG)KNU1?$/F7*+6W\U1YP@L*-QS(/IX\7:;6"PR[6_B%P1TW;%LL4RX`E):L*$O=KADL"FR?U\#YA:JV"KEUM9L(L>(%>O,*N'+Y)."BV9=EBUH>`&W#[PZB5ZN*N/ +MKG\O?^F!]B::?PU06F"P#&72E`&K0^,"5H?&!:P.C0M:'1H8L#HT+F!U:%S` +MZM"XH-71`>LXW":N<=J]/&.J8KED335/@]R.V^@G.MT:UK;^E4T.*>+8T+K=IG%GSBCWTO[.-."OG7G[JY2UX#:Z!MB)QGS.< +M8^X\@^;:0=F`.X!5T'3XT#I0*L079.('2*AO"W('I0)=([`_OHACA-V(K^LQ +M/J/&CLAMVD!5S^BUCL"@_D@7YKB"NWH>JV?9JK<;FR6W:0-9O2I6+U\D4C)] +MJEI22,+5S-5S:`[Z"/_O\SMMZ/=B?D6@&8%L$8;FD)F/ +M;YX>F;'Q`E`%J!Y4!TKB?2E`[:"L`,RB&]S.N7N$0?\Z=/IA_YBY:S@;P7(V +MEPK%49X7(,Q'2N`U?D2U>`^#A\E>7]Z=[W_>>3CNX/R'A0+!01H0L?J.8D=V +MB'1U\?6CA;R=V!5K=I/4^-?W4/2S-PK/[M;.[^?*"B-EWL=1`I/`Q#2"AV!A +M4G9A.\D64C.:,:/.E(W!J2VI4^#.SYPOQE`Q@5&:V9@NAY+CO0D;;X?5,*'R +M>/^[_GO?+?CQ1*BH([]\M5:DU>4N5+A_V3$0&,Y;ZH)%>5C"14+E1=93H9SW +MKC&""1SWP*WZH?4F*)CS4SG;L'G:&4E^-?(SN<7JR)Q>&"ZR\'<$;)K3`+T% +M0[BCPHU&^]DZTG631F.03(8M-AS"9O9K6F+_-OUI@%)"7:\`;SP_;=TA;<'; +M86"8XB!RD*;X3>%L=9=ZSN_RZA-NQ0PR5;=O%^S6F794 +M=Q]+-LW'Z.-]5-DB"?S_"ZF6+)2JYE*5A(J# +MTM#62;@?`1QU7>YPN5%0:MS"90[:[N6M@CPW_$R:5!:$`S=^-QN[V84;!!P. +MG[/#"/8V^_/&\>MR%Q&QD5Y(6:_C6Q&!I)Y0%T(XZKK<56@]26:]G0N6V$@O +M)*U7C]:+&PE)Q5+WN*MEV:L0KJ&U7F[;1Y,?IGZOY_3"<)V%OQ&0NVV(;%_C +MKI"2,10.D(RA4**=%9AO*-T)K#<\XRE&^$9A]^P5F&BC="SSW+ +:0#C"LPR$(SS+0#CB4,&^Y>P?_R=O5``3```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu new file mode 100644 index 000000000000..b9a9b8a1a58c --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu @@ -0,0 +1,19 @@ +# $FreeBSD$ +begin 644 img-63x255-512-gpt.vhdf.gz +M'XL("/G%'50``VEM9RTV,W@R-34M-3$R+6=P="YV:&1F+F]U=`"METUOU#`0 +MAN_[*P9Q*R+8CNUD3XB*5N)6/GKCT'S8U4JP"(D#A_QX9NRDL;-VH,B)%7DU +M\9-YQS.9+&/^`)`"6)>XY@W3=16?T^'JX&B\?QX0GT\N;(`5`CUN0",3=(\Q +M8.T\&'>K_&(<-5OG#E>M!ZL"W!BNVHR\(<15'K?(M<\#*@5==P&\7_P3;CL4 +M2`WR"`+O9R`Y*`%*/N&<=C6$_MW,?S +M5Q-N'$'EQIYG-Q;Y7/HW_;6XQ2+5[7AJE9! +M*T`/,'99W+<(IPMGGB1SKZ$90!M0'`9+DU$#Y^@?EDGK(`($[OL1&@ZB)^!T +M_EB=/>QU]?/5[)_DQE!3OU%+L2XNG3T6HJ>*A:]XYPLJ9$W +M9*/7^>BE@T1.I4H7<7/4JA\X;IKHI/#Y0SL)B'RMJA +M8'40KF!U$*Y@=1"N:'40L&!U$*Y@=1"N8'40KFAU(-"P#$7NO?:>+IS3`%FSCA=INX-5FQR[$16[")$ZYH$]?SY[?& +MKS-77UK1O)'TL=:T(5"L.>.`PX^S&7Z=?H?1(QSW&9$/5Z?OCPM.S*J6!U-&8Q8C1%[(U;'/;CKVU"L?!)K+*!R)M<1_8@,R40FG$N5\.;_W5N/*YTJ^-?@\`>4./-P +$LPT````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu new file mode 100644 index 000000000000..ea3a546f8163 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu @@ -0,0 +1,88 @@ +# $FreeBSD$ +begin 644 img-63x255-512-gpt.vmdk.gz +M'XL("/K%'50``VEM9RTV,W@R-34M-3$R+6=P="YV;61K+F]U=`"M7%UOW-81 +M?<^ON%4>$K3H@F?Y_6"@294`01'`C=WFI0]=?C5"'=F5A:(&]L>7E[SGZE!: +MBG0T"NW=,6?.WIE+SBIG#I@D\X]S6>.RS&6=RPN7P(W_-!\N21^,\3A6/''^ +MR_6/?S_PY^O#X?S%#`8?)2%(%$Z,Q>><#X]^"'=\+FIQ8CR.FW"ICVJ>!`:X +MX\J)5;AL/'F\%,+5G:;3G7\C<"X"N05IW.)*T>G803\TEW??/RWN^X_MGW[X"TSWZO3@6AO^0Q!7PG^'.?_[A^E6X>\0A_,35^;T-QVFY>0>^SB>[D+*4^W:N_YTW[_] +M]*%_=?7K^]M8.[^WOF3U!%1-A4I=GGJHD)HO7^X1_64S[9H[O[NY_^6F?3.F +M^;&_.GSI"%?XVHT;6(5US5F/(<7JSH[+/G_WO_LQ7]>%G;TAW+2(*8GQL_.C +MRTN/-6[@M!5'EV;^W?A/XX+'3#)X)W=^?WOXZ>?Q%O?%>O/ZFY\(5XU1H^>X +MP#%D3&B14S[GGS^^+-WYS7?NRB?Y]I=^N@()5\^WF7>>]P&3>?1O0M5F>-_$ +M,G]BVEEW?;H_N6]/'_O#E]?7W\:=/?EDL^D8E]9[E&*&]M?W5,ZQ<=FKP5XP[OW)7-]VXIQ[V +M7_W[7PG7SI?QN`Y_2=138.K?C%?/!-^'3YBO&+]-'JZ_O_MT:#^]N[GMQAO- +MO2)<-]=N7$Z:A$7%-3U>5/S8L797RG>H5O;;UX#H^KQU\U(._7X?B[`#U3CP0:D?/0:/\2R:UR[;@ +MRB34CIZI1F5BY`NXE=J5['?T+#6J$J->P*W4KF2_HV>C4:T8W:YDV>_H.6B4 +M?\FE=ODF'/L=/5.-RL3(%W!KM6._HV>I4948]0)NK7;L=_1L-*H5H]N5+/L= +M/0>-\B^%U*[8A&._HV>J49D8^0)NK7;L=_0L-:H2HU[`K=6._8Z>C4:U8G2[ +MDF6_H^>@4?Z%OP1!WJ_#L=_1,]6H3(Q\`;=6._8[>I8:58E1+^#6:L=^1\]& +MHUHQNEW)LM_1<]`H_T)"!O)^%:Y*0NWHF6I4)D:^@%NI7<5^1\]2HRHQZ@7< +M2NTJ]CMZ-AK5BM'M2I;]CIZ#1OF76FI7;\*QW]$SU:A,C'P!MU8[]CMZEAI5 +MB5$OX-9JQWY'ST:C6C&Z7J49D8^0)NK7;L +M=_0L-:H2HU[`K=6._8Z>C4:U8G2[DF6_H^>@4?Z%_"/D_3H<^QT]4XW*Q,@7 +M<&NU8[^C9ZE1E1CU`FZM=NQW]&PTJA6CVY4L^QT]!XWR+ZW4KMV"JY-0.WJF +M&I6)D2_@5FI7L]_1L]2H2HQZ`;=2NYK]CIZ-1K5B=+N29;^CYZ!1_J63VG6; +M<.QW]$PU*A,C7\"MU8[]CIZE1E5BU`NXM=JQW]&ST:A6C&Y7LNQW]!PTRK_T +M4KM^$X[]CIZI1F5BY`NXM=JQW]&SU*A*C'H!MU8[]CMZ-AK5BM'M2I;]CIZ# +M1OF706HW;,*QW]$SU:A,C'P!MU8[]CMZEAI5B5$OX-9JQWY'ST:C6C&Z70]ZMPIV2N7?1,-2H3(U_`K=3N%/I=]"PUJA*C7L"MU.X4^EWT +M;#2J%:/;E6SH=]%ST"A?,N'OL$EIG4*_@_!W4/X.PM]AD[\[A7X'X>^@_!V$ +MO\,F?W<*_0["WT'Y.PA_MR/9T.\@_!V4OX/P=]BDM$ZAWT'X.RA_!^'OL,G? +MG4*_@_!W4/X.PM]AD[\[A7X'X>^@_!V$O]N1;.AW$/X.RM]!^#ML4EJGT.\@ +M_!V4OX/P=]CD[TZAWT'X.RA_!^'OL,G?G4*_@_!W4/X.PM_M2#;T.PA_!^7O +M(/P=-BFM)@FU$_X.RM]!^#ML\G<-^YWP=U#^#L+?89._:]COA+^#\G<0_FY' +MLNQWPM]!^3L(?X=-2JMAOQ/^#LK?0?@[;/)W#?N=\'=0_@["WV&3OVO8[X2_ +M@_)W$/YN1[+L=\+?0?D["'^'34JK8;\3_@[*WT'X.VSR=PW[G?!W4/X.PM]A +MD[]KV.^$OX/R=Q#^;D>R['?"WT'Y.PA_ATU*JV&_$_X.RM]!^#ML\G<-^YWP +M=U#^#L+?89._:]COA+^#\G<0_FY'LNQWPM]!^3L(?X=-2JM-0NV$OX/R=Q#^ +M#IO\7^@_!V$O]N1+/N=\'=0_@[" +MWV&3TFK9[X2_@_)W$/X.F_Q=RWXG_!V4OX/P=]CD[UKV.^'OH/P=A+_;D2S[ +MG?!W4/X.PM]AD])JV>^$OX/R=Q#^#IO\7]V),M^)_P=E+^#\'?8I+0Z]COA[Z#\'82_PR9_U['?"7\' +MY>\@_!TV^;N._4[X.RA_!^'O=B3+?B?\'92_@_!WV*2T.O8[X>^@_!V$O\,F +M?]>QWPE_!^7O(/P=-OF[COU.^#LH?P?A[W8DRWXG_!V4OX/P=]BDM#KV.^'O +MH/P=A+_#)G_7L=\)?P?E[R#\'3;YNX[]3O@[*'\'X>]V),M^)_P=E+^+8CK( +M>X%S\Y\`UR=S[2Y*RB_\4ZR=N[BZWEH?.`Q[`=/+Z?H]CNDB>789G[\^3/K% +M./.8J_[;`&?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2?O)OI*Q/F[B;X2=;P3[FFRLS[P +M"%-]Y?'X[#(^?WW95+_YZ:I/_UX_V/6>O6] +M&X9PS,JYAPSC4ZPO)/SU0>`ZX_KMW]_YR'-W.CT!_!O7-^UOEOOG,6?U]'!> +M/IDWSR+ZOJ^^_X']_J;G]YZL'\\I#L]WGEH7=VYOO00R]7AF73?/KT[ +MLNGQSF/UC^7%9--5N*\NW6S9]'CGH7L&[M*Q#I<]%_6Y3P+/IL<[:Y2J;UV5 +MN^KHG]_;/7[R[`/0NP5<87SE34^>;0I7MO[YP3E<.SWLN2L\+>VJ\3:9[XFC +M.W9>B5#"'?T3F0_GV[\>;F>P/Q[^\X>POOG)L[A\K)]8JUYV?.Z*\(O:2-LG5JMWFJNW\JTV+NK2K3O"\5OM=TNXQKAZDRI_ +M%IX\_7O]Q/GU8?G?#)@%0+,59OZ1@G9WAX%,[PX/:'AW>#C# +MN\/#&=X='L[T[LC\`R/MOL0]G+_VNK'FM7^&?[Z\:M:_CL?U_?QF6MA7BW0G +MSG'UJ_^9+_'+F]$;?HE[N&>_Q(=^/=GP\RA9PR]Q#V?Z)9[YIW?U%8\>DNY%Q&UI,E.6;,DS>V![6K<=OP]`_G8#>9K,N'L3E`M`I419=^N] +MDXM%J5@ZG,]WWTZG5DY-=VK&TSZ?OOX\_9#3O9\\_''Z\L^__?W=_6]??KL; +MD_,/GG(_[[/TMPYO3XAI]?\W.N[=6]7[D[OU[U=)6^W_;G!?[C7IW\(EI]Z?7_P +MZ]O!P=_+ZVO@4SV;&Q[,70YOMX5/C6QN^B',>N[@4S.;6X*Y'CZULKDMF!O@ +M4SN>DQ]\;>_F1OB4L#F%ZVS,WP*?+K0AQW^==%Y6Z! +M3Q'N).1NA4\1[B3D;H-/$>XDY&Z'3Q'N).).\%.$.XVX$Z0H9=QIQ)T@(ROC +M3B/N!/E.&7<:<2?(=\JXTX@[0;Y3QIU&W`GRG3+N-.).D.^4<:*GR+<-1%WBGS7,.Z:B#M%OFL8=TW$G2+?-8R[)N).D>\:QET3<:?( +M=PWCKHFX4^2[AG'71-PI\EW#N&M"[I#O&L9=&W*'?-ZZB#M#ONL8=UW$G2'?=8R[+N+.D.\ZQET7<6?(=QWCKHNX +M,^2[CG'7A=PAWW6,NS[D#OFN9]SU(7?(=SWCK@^Y0[[K&7=]R!WR7<^XZT/N +MD.]ZQET?<=='W#7X*<+=$''7(-\-C+LAXJY!OAL8=T/$ +M78-\-S#NAHB[!OEN8-P-$7<-\MW`N!LB[AKDNX%Q-T3<-&W"'?C8R[,>0.^6YDW(TA=\AW(^-N#+E#OAL9=V/('?+= +MR+@;0^Z0[T;&W1AQU^*G"'=3Q%V+?#'W"'?S8R[ +M.>*NPT\1[I:(NP[Y;F'<+1%W'?+=PKA;(NXZY+N%<;=$W'7(=POC;HFXZY#O +M%L;=$G'7(=\MC+LEXJY#OEL8=TO('?+=PKA;0^Z0[U;&W1IRAWRW,N[6D#OD +MNY5QMX;<(=^MC+LUY`[Y;F7\VQMT6<=^VQAW +M6\1=CWRW,>ZVD#ODNXUQMX?<(=_MC+L]Y`[Y;F?<[2%WR'<[XVX/N4.^VQEW +M>\@=\MW.N-M#[I#O=L;='G*'?+OO).SO!N`[8?V=A/W=`'PGK+^3L+\;@.^$]7<2]G<#\)VP +M_D["_FX`OA/6WTG8WPW`=\+Z.PG[NP'X3EA_)V%_-^*G"'=A?SOO).SO1N0[UM])V-^-R'>L +MOY.POQN1[UA_)V%_-R+?L?Y.POYN1+YC_9V$_=V(?,?Z.PG[NQ'YCO5W$O9W +M(_(=Z^\D[.]&Y#O6WTG8WXW(=ZR_D["_F_!3A+NPOYN0[UA_)V%_-R'?L?Y. +MPOYN0KYC_9V$_=V$?,?Z.PG[NPGYCO5W$O9W$_(=Z^\D[.\FY#O6WTG8WTW( +M=ZR_D["_FY#O6'\G87\W(=^Q_D["_FY"OF/]G83]W81\Q_H["?N["?F.]7<2 +M]G<3\AWK[R3L[R;D.];?2=C?S?@IPEW8W\W(=ZR_D["_FY'O6'\G87\W(]^Q +M_D["_FY&OF/]G83]W8Q\Q_H["?N[&?F.]7<2]G]8?R=A?SOO).SO%OP4X2[L[Q;D.];?2=C?+OO).SO%N0[UM]) +MV-\MR'>LOY.POUN0[UA_)V%_MR#?L?Y.POYN0;YC_9V$_=V"?,?Z.PG[NP7Y +MCO5W$O9W*WZ*OO).SO5N0[UM])V-^MR'>LOY.POUN1[UA_)V%_ +MMR+?L?Y.POYN1;YC_9V$_=V*?,?Z.PG[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6 +MWTG8WZW(=ZR_D["_6Y'O6'\G87^W(M^Q_D["_FY%OF/]G83]W8I\Q_H["?N[ +M#3]%N`O[NPWYCO5W$O9W&_(=Z^\D[.\VY#O6WTG8WVW(=ZR_D["_VY#O6'\G +M87^W(=^Q_D["_FY#OF/]G83]W89\Q_H["?N[#?F.]7<2]G<;\AWK[R3L[S;D +M.];?2=C?;]8 +M?R=A?[^8_V=A/W=CGS'^CL)^[L=^8[U=Q+V=SOR'>OO).SO +M=N0[UM])V-_MR'>LOY.PO]N1[UA_)V%_MR/?L?Y.HO[.SO@IS)WF#]SNOSLE[DZW90[X3EE_IZZ_.R7N3K^7.>`[ +M9?V=NO[N=#F<'?"=LOY.77]7SJ[.`=\IZ^_4]7=@#OA.67^GKK\#<\!WROH[ +M=?U=GGM4YX#OE/5WZOJ[1WFN<@=\IZR_4]??/4K/$G>/ +M*G?`=\KZ.W7]W:/+X>R`[Y3U=^KZNW)V=0[X3EE_IZZ_`W/`=\KZ.W7]W7$. +MW7^GK+]3U]_EN<=U#OF.]7?J^KO'>:YPA^Z_4];?J>OO'B?N'A?NT/UWROH[ +M=?W=X\3=X\(=NO].67^GKK][?#F<'?(=Z^_4]7?E[.H<\AWK[]3U=V`.^8[U +M=^KZ.S"'?,?Z.W7]79Y[4N>0[UA_IZZ_>Y+G*G?(=ZR_4]??/4GDNOP-SR'>L +MOU/7WQWGT/UWROH[=?U=GGM:YY#O6'^GKK][FN<*=^C^.V7]G;K^[FGB[FGA +M#MU_IZR_4]??/4WNOP-SR'>LOU/7W^6Y9W4.^8[U=^KZNV=YKG*'?,?Z.W7]W;/$ +MW;/*'?(=Z^_4]7?/$G?/*G?(=ZR_4]??/;LWXYG!WR'>OOU/5WY>SJ +M'/(=Z^_4]7=@#OF.]7?J^CLPAWS'^CMU_5V>>U'GD.]8?Z>NOWN1YRIWR'>L +MOU/7W[U(W+VHW"'?L?Y.77_W(G'WHG*'?,?Z.W7]W8O+X>R0[UA_IZZ_*V=7 +MYY#O6'^GKK\#<\AWK+]3U]\=Y]#]=\KZ.W7]79Y[6>>0[UA_IZZ_>YGG"G?H +M_CME_9VZ_NYEXNYEX0[=?Z>LOU/7W[U,W+TLW*'[[Y3U=^KZNY>7P]DAW['^ +M3EU_5\ZNSB'?L?Y.77\'YI#O6'^GKK\#<\AWK+]3U]_EN5=U#OF.]7?J^KM7 +M>:YRAWS'^CMU_=VKQ-VKRAWR'>OOU/5WKQ)WKRIWR'>LOU/7W[VZ',X.^8[U +M=^KZNW)V=0[YCO5WZOH[,(=\Q_H[=?W=<0[=?Z>LOU/7W^6YJSJ'?,?Z.W7] +MW56>*]RA^^^4]7?J^KNKQ-U5X0[=?Z>LOU/7WUTE[JX*=^C^.V7]G;K^[NIR +M.#OD.];?J>OORMG5.>0[UM^IZ^_`'/(=Z^_4]7=@#OF.]7?J^KL\][K.(=^Q +M_DY=?_NOWN=N'M=N4.^8_V=NO[N=>+N=>4.^8[U=^KZN]>7 +MP]DAW['^3EU_5\ZNSB'?L?Y.77\'YI#O6'^GKK\[SJ'[[Y3U=^KZNSSWILXA +MW['^3EU_]R;/%>[0_7?*^CMU_=V;Q-V;PAVZ_TY9?Z>NOWN3N'M3N$/WWRGK +M[]3U=V\NA[-#OF/]G;K^KIQ=G4.^8_V=NOX.S"'?L?Y.77\'YI#O6'^GKK_+ +MOOWB;NWE;ND.]8 +M?Z>NOWM[.9P=\AWK[]3U=^7LZASR'>OOU/5W8`[YCO5WZOJ[XQRZ_TY9?Z>N +MO\MS[^H<\AWK[S3J[PS=?Z>LO].HOS-T_YVR_DZC_L[0_7?*^CN-^CM#]]\I +MZ^\TZN\,W7^GK+_3J+\S=/^=LOY.H_[.T/UWROH[)?W=^SJ'?,?Z.W7]W?L\ +M5[E#OF/]G;K^[GWB[GWE#OF.]7?J^KOWB;OWE3OD.];?J>OOWE\.9X=\Q_H[ +M=?U=.;LZAWS'^CMU_1V80[YC_9VZ_NXXA^Z_4];?6?[`S9WK'/"=L?[NZR<> +M<)?]="[%.W3_G;'^SEQ_IXD[+=RA^^^,]7?F +M^CN]',X.^8[U=^;ZNW)V=0[YCO5WYOH[,(=\Q_H[<_T=F$.^8_V=N?XNSUF= +M0[YC_9VY_L[R7.4.^8[U=^;Z.TO<6>4.^8[U=^;Z.TO<6>4.^8[U=^;Z.[L< +MS@[YCO5WYOJ[$.W7]GK+\SU]\UB;NF<(?NOS/6WYGK +M[YK+X>R0[UA_9ZZ_*V=7YY#O6']GKK\#<\AWK+\SU]^!.>0[UM^9Z^_R7%OG +MD.]8?V>NOVOS7.4.^8[U=^;ZNS9QUU;ND.]8?V>NOVL3=VWE#OF.]7?F^KOV +MOOP!SR'>OOS/5WQSET_YVQ_LYS0[YC_9VY_JZ<79U#OF/]G;G^#LPAW['^SEQ_!^:0[UA_9ZZ_RW-] +MG4.^8_V=N?ZNSW.5.^0[UM^9Z^_ZQ%U?N4.^8_V=N?ZN3]SUE3OD.];?F>OO +M^LOA[)#O6']GKK\K9U?GD.]8?V>NOP-SR'>LOS/7WQWGT/UWQOH[<_U=GAOJ +M'/(=Z^_,]7=#GBOZ0[UA_9ZZ_&Q-W8^4.^8[U=^;ZNS%Q-U;ND.]8?V>N +MOQLOA[-#OF/]G;G^KIQ=G4.^8_V=N?X.S"'?L?[.7']WG$/WWQGK[\SU=WGN +M0YU#OF/]G;G^[D.>*]RA^^^,]7?F^KL/B;L/A3MT_YVQ_LYA<(?N +MOS/6WYGK[SY<#F>'?,?Z.W/]73F[.H=\Q_H[<_T=F$.^8_V=N?X.S"'?L?[. +M7'^7YS[6.>0[UM^9Z^\^YKG*'?(=Z^_,]7OOP!SR'>OOS/5WQSET_YVQ +M_LY? +M$G>?"G?H_CMC_9VY_N[3Y7!VR'>LOS/7WY6SJW/(=ZR_,]??@3GD.];?F>OO +MP!SR'>OOS/5W>>YSG4.^8_V=N?[N?$W>?*'?(=Z^_,]7>?+X>S0[YC_9VY_JZ<79U#OF/]G;G^#LPAW['^SEQ_ +M=YQ#]]\9Z^_,]7=Y[KK.(=^Q_LY=YPIWZ/X[8_V=N?[N.G%W7;A#]]\9 +MZ^_,]7?7B;OKPAVZ_\Y8?V>NO[N^',X.^8[U=^;ZNW)V=0[YCO5WYOH[,(=\ +MQ_H[<_T=F$.^8_V=N?XNS]W4.>0[UM^9Z^]N\ESE#OF.]7?F^KN;Q-U-Y0[Y +MCO5WYOJ[F\3=3>4.^8[U=^;ZNYO+X>R0[UA_9ZZ_*V=7YY#O6']GKK\#<\AW +MK+\SU]\=YIHS?@ISU^0/W-QMG0.^:UA_U[C^[C;/GOO;A-W +MM[=E#OBN8?U=X_J[V\3=[>]E#OBN8?U=X_J[V\OA[-#?MUU.G'[BRSOW[/?Q>!K_?:_0'!K^]83D,YC??WMDMO;U%ZN^R]]_PS1U\U^_NS:&_-_K/G!^ZBNA'@VU[FJ;#X+_RZT-7 +M$?V9U]=MO_CKVW\'INU/37MJN].@/_L*__/7?[M7>#<'9/#_O>&[.2"#AW/Y +M!9??'P]S-_?FOLE@O_=OGN7>4_>YN__QO;GK=_=^`^^1#.K<-P%NZ!/TS?YB +M&?2'"R?O?YV_W\ELIW/^\QEWT6GY^I[JZT.!_X.W^X/7=SJ^W>__@=$__/?E +MWIP&;_?T<&XN9@%?PN#TKH^O#OT%]W_FBW&X-O$G?^5^&WGX*_=N3G^M"(;O +G9OGVV^($_LD_\>4?[QY^OQMLTN`O.\'F*WWG\V__`[M'T1.AJ``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-mbr.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-mbr.qcow2.gz.uu new file mode 100644 index 000000000000..bea1353303ef --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-mbr.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-512-mbr.qcow2.gz +M'XL("%7N+50``VEM9RTV,W@R-34M-3$R+6UB3:=\"\>SOQS@K]#C3OD'GWCEA9P`G]#C7OD'EG"0U81[ +M'W!"OT/-.V3>?2#A7A]@NOW[D^+@#FN6F:"?!WGQ_,IG%Y?N5AX?VM_..& +MLJO:O#`5/#3#O_=_ID*WN,4JV./TQPTTT"<\M-@);A/ANBN68_3+N$Y'WL6? +M(]QZ%5I]BYM]W-#=0QVD`76R^;*R5$.S&FR-]KF[=._NL/I_;W;I/>RO"?D) +MS0I&TYW)STRGVUT5#'?O;#\Z'"2F:\:X[=!9A"U,K-YZFMUNX6+D= +L9%RY'@?+-H+ZW%E:`]M?3<_ZP.GG:OSV0$?`Q5;0%=U_V\U_7_5L5B,5```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-mbr.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-mbr.raw.gz.uu new file mode 100644 index 000000000000..dc6c0cb6efe6 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-mbr.raw.gz.uu @@ -0,0 +1,12 @@ +# $FreeBSD$ +begin 644 img-63x255-512-mbr.raw.gz +M'XL("%;N+50``VEM9RTV,W@R-34M-3$R+6UB80)%@"K_\2PN(W``J`^A7 +MQFW'\*5B&XJ/8J3IQSF@0T"=`!4!&=<2CA:03&_#6/;A-XS!@:&W]-]-<^XP +M$$%=R:@U2N#^EEUIWW:,.-F>X?;G@-:"]PGP=]9G=F6.<+-@KJ`UW%7@2G+V8B57XK1+UIV<"US#WXRK +M]M3126"WYM@,UN8M%D<6[Y-Y!MV!+@'=Y#,Q<,DO//5=4ADF"G=''Z3A^H"K +MX_5:X,Q!N!#C'LO+LI+"@]-K4G5MYF3HUYOQYLT-D/CF,L[D?0@NX\M"%4BK +;TG';,?RHV!A83/L3B'ZC")G7E!@`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-mbr.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-mbr.vhd.gz.uu new file mode 100644 index 000000000000..251e27e9698a --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-mbr.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-512-mbr.vhd.gz +M'XL("%;N+50``VEM9RTV,W@R-34M-3$R+6UBJVIZQ8T5HIT +M5CZ=YF,%TBU2`UI:1#]1&X:(*3X\/M^]_'B..`RXN+#4(!&4@\C%.D9,ZHCT +MZ>'+Q[FZ:JGN,LNOT_=0]I4V(V +M*Y&Y=JC)9M=P>F_6+;B[0["%=Q7G&+6K!>@2:J2V!;%7Y__+82O\9NI(/_RW[&XC5<%)QF^QQW2G"5#[<+)4E. +MF=^E[01W]/^(DWOJ*"=T:QV;FU7,SF+-;%YJ9R@[*"L0)O1A#ISL"Q=]]TL9 +MF&UW1Q\LMVL)5^?CRP2'5[8+.:Z9,LN*":^;\?.BAD +KNB@0CO&B0#C&BP+A&"\*A&.\*!".\:)`.-:+@G970"$._P"C#]GF70X````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-mbr.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-mbr.vhdf.gz.uu new file mode 100644 index 000000000000..0ba75331f78c --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-mbr.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-512-mbr.vhdf.gz +M'XL("%;N+50``VEM9RTV,W@R-34M-3$R+6UBX;OMYJY#@X1L@PV?=>;A#L.NN,\;6IS_7-RM'P,J!649`=][?>*JC,?U +M%39Q?$V;,*H`J4!I,.)>A9^[CY%"A^.I''8X<0O7"W89-(7;>+@*/HC=+0E7A.NYAQ,WW(40MQ\JRT0(;YS>.E97)0X&']^,.V\N0<*; +MZW`B;2%8M94%,Q!7Q>.\H7G-PN:`L@,F.T'3?=MT#KH&;4$KFA<2]`H*XP-% +MF$E-]?UEJY_3KQ]APG%7#"8[[13H?>UQ?JOH_ +MEIH.72%$1NZ:T-V7[=OS6%T>'Y()3H^33K_LH>/!Z6U\G!R +M::MUJP/[V%W;W4.U=-4%9=GTX=RE=9>+NW2N*%T&-_S3]')9_FP,KTNZ\?2W +MMW__\<2//YY.3U],8`A1$H),X<28O<_3:?%!N//GHF8WAM=Y%RX/4>V+P`AW +MWKBQ"3?TPYW70IA=,][NPH7`N03D9G#%2DV;Q7XNNS]\$9L7\LM##L/QEK6K +MVT71E,=JYJ\[CO'NX_/+Z/^9W#V0[.ES+X +ME[>`,!16E>$BW`AP=8`HO>W=[\,VC_^'3 +M!__F[M?W[U+OPMF&EM4CT'5L5.Z*/$#%TD+[BH`8'IOQU-S3+_>//]_?OA_* +M_.CO3E\ZPI6A=\,!7F->4]5#2+EYLD/:3]_^[W&HUW7Q9.\)-R8Q%C&\=W%V +M116PA@/,A][ENAR!]^]N,32+AZ^C(+SM,Y8#3/X2)V;8(/ +M0^P2;HPGZ]XVCXW[IOGH3U^^??M-.MDF%'L97T-J/J"4$W1XOL=V#HV;3GHZ +MZ/$HNJX]-5WSX=$_A.--1]&&I[6+E89CO3P?X_Q]JO&D^O#$N*D9X']]A>F+",04X__CPZ73[],O]NV[X +M0G-O"-=-O1O2&4YS2BKEM$PJO>W0NSL\IS9@$\Z'%DU)7>,7QH`UY?'$5N_#TZ?2S;[HA+7=W+HJ[=!3]\BBT18LN3`<]]&(ZBIC8I]-'?XMP>18/ +ML)\U9\HI/,K#DSQE-!^@C^\?QM3*_$[G<;[\7O;:>7QY\2VU^IV`$YQU?F6V +M]_V,KWP&Z`0L>\ZO#/E=Q+/0J%*,:@8W_#1Q^F[X_-?P^4'@PB-V%<]:HQHQ +MVB/=*\/WBYMX=AKEQ>@/P5UBB_@#"N1Z;"J-7&\D.+?H71%[1\]"HTHQJAG< +M5N_*V#MZUAK5B-&N9KG45Z,_A#<-?:./X!!KL?>T\7KL'8U<;VSUKN*\HV>A4:48U0QNHW<5YQT]:XUJQ&A7LUL6RWE' +MSTZCO!C](3C.NT)ZQ^NQ=S1RO;'9.\X[>A8:58I1S>"V>L=Y1\]:HQHQVM7L +MEL5RWM&STR@O1G\(CO.NE-[Q>NP=C5QO;/:.\XZ>A4:58E0SN*W><=[1L]:H +M1HQV-;MEL9QW].PTRHO1'X+CO../3I#KL74?/6J,:,=K5[);%\'GM'(]<;6[V[S6Q;+>4?/3J.\&/TA.,Z[6GK'Z[%W-'*]L=D[ +MSCMZ%AI5BE'-X+9ZQWE'SUJC&C':U>R6Q7+>T;/3*"]&?PB.\X[_\8)N-S=YQWM&ST*A2C&H&M]4[SCMZUAK5B-&N9K3'Z0W"<=V0M +M(==C[VCD>F.S=YQW]"PTJA2CFL%M]8[SCIZU1C5BM*O9+8OEO*-GIU%>C/X( +M7)W%WMVD=[P>>TR6Q7+> +MT;/3*"]&?PB.\ZZ3WO&:K';J7?<";MD[SCMZ%AI5BE'-X+9ZQWE'SUJC&C': +MU>R6Q7+>T;/3*"]&?PB.\\Y+[W@]]HY&KC\=Y1\]"HTHQJAG<5N\X[^A9 +M:U0C1KN:W;)8SCMZ=AKEQ>@/P7'>]=([7H^]HY'KC<=[1L]"H4HQJ!K?5 +M.\X[>M8:U8C1KF:W+);SCIZ=1GDQ^B-P33;U+NW<(->A=\G(]<96[YHX[Y)G +MH5&E&-4,;J-W39QWR;/6J$:,=C6[9;%QWB7/3J.\&/TAN#CO(/P=E+^#\'?8 +MY>^:..\@_!V4OX/P=]CE[YHX[R#\'92_@_!W*]DMBXWS#L+?0?D["']W`"[. +M.PA_!^7O(/P==OF[)LX["'\'Y>\@_!UV^;LFSCL(?P?E[R#\W4IVRV+CO(/P +M=U#^#L+?'8"+\P["WT'Y.PA_AUW^KHGS#L+?0?D["'^'7?ZNB?,.PM]!^3L( +M?[>2W;+8..\@_!V4OX/P=_MP;19[)_P=E+^#\'?8Y>]:SCOA[Z#\'82_PRY_ +MUW+>"7\'Y>\@_-U*=LMB.>^$OX/R=Q#^[@`_:SGOA+^# +M\G<0_@Z[_%W+>2?\'92_@_!W*]DMB^6\$_X.RM]!^+L#<)QWPM]!^3L(?X== +M_J[EO!/^#LK?0?@[[/)W+>>=\'=0_@["WZUDMRR6\T[X.RA_!^'O#L!QW@E_ +M!^7O(/P==OF[EO-.^#LH?P?A[[#+W[6<=\+?0?D["'^WDMVR6,X[X>^@_!V$ +MO]N'NV6Q=\+?0?D["'^'7?[NQGDG_!V4OX/P=]CE[VZ<=\+?0?D["'^WDMVR +M6,X[X>^@_!V$OSL`QWDG_!V4OX/P=]CE[VZ<=\+?0?D["'^'7?[NQGDG_!V4 +MOX/P=RO9+8OEO!/^#LK?0?B[`W"<=\+?0?D["'^'7?[NQGDG_!V4OX/P=]CE +M[VZ<=\+?0?D["'^WDMVR6,X[X>^@_!V$OSL`QWDG_!V4OX/P=]CE[VZ<=\+? +M0?D["'^'7?[NQGDG_!V4OX/P=RO9+8OEO!/^#LK?0?B[?;@NB[T3_@[*WT'X +M.^SR=QWGG?!W4/X.PM]AE[_K..^$OX/R=Q#^;B6[9;&<=\+?0?D["']W`([S +M3O@[*'\'X>^PR]]UG'?"WT'Y.PA_AUW^KN.\$_X.RM]!^+N5[);%"7\'Y>\@_!UV^;N.\T[X.RA_!^'O5K); +M%LMY)_P=E+^#\'<'X#COA+^#\G<0_@Z[_%W'>2?\'92_@_!WV.7O.LX[X>^@ +M_!V$OUO);EDLYYWP=U#^#L+?[X +M..]6%7TK_Y1ZY]:S>Z'%/P;WLMA);HA1;I@V$5.YOP]P@C.60^(:N[X/>$0. +MB;0NY^M5;R"&1UN4F;R"&1UN4F/??N]\LAD=;E]'R5'!)I74[/5\DAD=;E]'R5'!)I76XBAT1:EYO((9'6 +MY29R2*1UN8D<$FE=;B*'1%J7F\@AD=;E)G)(I'6YB1P2:5UN(H=$6I>;R"&1 +MUN4F;R"&1UN4F$-Y5#PIO*(>%-Y9#PIG)(]%EF*(=$;RJ'1&\J +MAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ'1&\JAT1O*H=$;RJ' +M1&\JAT1O*H<\9UEF*(<\9Z9RR//+7TU\#.YEL9/<\#*6._WNTI=_;]]X^N8T +M_Y,`T?XVP$D0MP1DP1>,C_+(?C7C_PGS/IAY+P7?!MNO%/SU\&?X^.HD<)UQ +M_]#_-L"B<$WS`O"?S._\V31^>WZ5-S[?Z_C`%%7X-;M%Z:[GHQG^].V/BPPG +M.#/][`2W^_616-!^"^YK@0L_#_3B.?M-X/KQT076L6.-? +MW7W-KHLX/>?P?2?0@?Q?WGD.F,[7/>=7OTSC/"OW,_FYE^6&[[GZRVOU/&9C +M>J-<-X=KTV19.<*=[GWU,KN;\6%@^95Q\"LW@,R_XL^T@J,?),JD^7OZ] +=?>/IN]/\SP1XB8!F';R$7TR2??%_%;F-MX/0^`_.R&9G?N[JCU33`:�" +M%?DI*VOU`LTL;=;KG]]6J]%6PV8US*OS?O7]Y^V[K>[]Y.'WU;?_^H__?'?_ +MV[<_?H[9^B^N2C_?GI:Y!UO_U^?\QU6'U7K^A;GOWXWF[MU=_(V[N_=F+^>N +M_OCY9ODZ5X/Q8'#5YM;M_DP\O>'7[N]+>KOV\^G]OK?KXNV.:G#S8/!KF_M7 +MNS__6[#\TOW]S<]WBX-_+O:KW=XE?A"LSO"TQ?:UV5NCU=MU-Q# +M[OYUP=T!KQ+<6+. +M*^Z,C.R*.Z^X,_*=*^Z\XL[(=ZZX\XH[(]^YXLXK[HQ\YXH[K[@S\ITK[KSD +MCGP7BKLHN2/?A>(N2N[(=Z&XBY([\ETH[J+DCGP7BKLHN2/?A>(N2N[(=Z&X +MBY([\ETH[J+BSNFJ07$W5-PY^6Y0W`T5=TZ^&Q1W0\6=D^\&Q=U0<>?DNT%Q +M-U3<.?EN4-P-%7=.OAL4=T/%G9/O!L7=4')'OAL5=V/)'?EN5-R-)7?DNU%Q +M-Y;]&Q=U8^&Q5W8\D=^6Y4W(TE=^2[47$WEMR1[T;%W5AQ%W351G&W +MJ;@+\MU&<;>IN`ORW49QMZFX"_+=1G&WJ;@+\MU&<;>IN`ORW49QMZFX"_+= +M1G&WJ;@+\MU&<;MN!OHJDEQ-U7<#>2[27$W5=P- +MY+M)<3=5W`WDNTEQ-U7<#>2[27$W5=P-Y+M)<3=5W`WDNTEQ-U7<#>2[27$W +ME=R1[^[^*SR\4'%'OIL5=W/)'?EN5MS-)7?DNUEQ-Y?]FQ=U<^FQ5W +M<\D=^6Y6W,TE=^2[67$W5]R-=-5.<;>KN!O)=SO%W:[B;B3?[11WNXJ[D7RW +M4]SM*NY&\MU.<;>KN!O)=SO%W:[B;B3?[11WNXJ[D7RW4]SM2N[(=W?_-Q1> +MJ+@CW^T5=_N2._+=7G&W+[DCW^T5=_N2._+=7G&W+[DCW^T5=_N2._+=7G&W +M+[DCW^T5=_N*NPU==5#<'2KN-N2[@^+N4'&W(=\=%'>'BKL-^>Z@N#M4W&W( +M=P?%W:'B;D.^.RCN#A5W&_+=07%WJ+C;D.\.BKM#R1WY[JBX.Y;^.BKMC +MR1WY[JBX.Y;^.BKMCR1WY[JBX.Y;^.BKMCR1WY[JBX.Y;^.BKMC +MQ=V6KEHZH,L7"NZVY+N3XNY4<;*NRWY[J2X.U7<;)N +M2[X[*>Y.%7=;\MU)<7>JN-N2[TZ*NU/)'?GNK+@[E]R1[\Z*NW/)'?GNK+@[ +ME]R1[\Z*NW/)'?GNK+@[E]R1[\Z*NW/)'?GNK+@[E]R1[\Z*NW/%W017V=T/ +MX(6"NPE\9RHXM"HX]`E\9RHXM'7%W02^L[7@SG)_=\'=!+XSU=]9V=]-X#M3 +M_9V5_=T$OC/5WUG9WTW@.U/]G97]W02^,]7?6=G?3>`[4_V=E?W=!+XSU=]9 +MV=]-X#M3_9V5_=T$OC/5WUG9WTW@.U/]G97]W02^,]7?6=G?3>`[4_V=E?W= +M3%>I_L[*_FXFWZG^SLK^;B;?J?[.ROYN)M^I_L[*_FXFWZG^SLK^;B;?J?[. +MROYN)M^I_L[*_FXFWZG^SLK^;B;?J?[.ROYN)M^I_L[*_FXFWZG^SLK^;B;? +MJ?[.ROYN)M^I_L[*_FXFWZG^SLK^;B;?J?[.ROYN)M^I_L[*_FY'5ZG^SLK^ +M;D>^4_V=E?W=CGRG^CLK^[L=^4[U=U;V=SORG>KOK.SO=N0[U=]9V=_MR'>J +MO[.RO]N1[U1_9V5_MR/?J?[.ROYN1[Y3_9V5_=V.?*?Z.RO[NQWY3O5W5O9W +M._*=ZN^L[.]VY#O5WUG9W^W(=ZJ_L[*_VY'O5']G97^WIZM4?V=E?[KOK.SO]N0[U=]9V=_M +MR7>JO[.RO]N3[U1_9V5_MR??J?[.ROYN3[Y3_9V5_=V>?*?Z.RO[NSWY3O5W +M5O9W>_*=ZN^L[._VY#O5WUG9W^W)=ZJ_L[*_.]!5JK^SLK\[D.]4?V=E?W<@ +MWZG^SLK^[D"^4_V=E?W=@7RG^CLK^[L#^4[U=U;V=P?RG>KOK.SO#N0[U=]9 +MV=\=R'>JO[.ROSN0[U1_9V5_=R#?J?[.RO[N0+Y3_9V5_=V!?*?Z.RO[NP/Y +M3O5W5O9W!_*=ZN^L[.\.Y#O5WUG9WQWI*M7?6=G?'KOK.SOCN0[ +MU=]9V=\=R7>JO[.ROSN2[U1_9V5_=R3?J?[.RO[N2+Y3_9V5_=V1?*?Z.RO[ +MNR/Y3O5W5O9W1_*=ZN^L[.].=)7J[ZSL[T[D.]7?6=G?G]4 +M?V=E?WKOK.SO +M3N0[U=]9V=^=R'>JO[.ROSN1[U1_9V5_=R+?J?[.RO[N1+Y3_9V5_=V)?*?Z +M.RO[NQ/Y3O5W5O9W9[I*]7=6]G=G\IWJ[ZSL[\[D.]7?6=G?GKO +MK.SOSN0[U=]9V=^=R7>JO[.ROSN3[U1_9V5_=R;?J?[.RO[N3+Y3_9V5_=V9 +M?*?Z.ZOZNUC#57[W`WCA`7=WG*SZ'/C.57_GJ;];M;W5>ID#W[GJ[SSU=ZO& +MW>KK,@>^<]7?>>KO5HV[U9_+'/C.57_GJ;^#9P>^<]7?>>KO8`Y\YZJ_\]3? +MP1SXSE5_YZF_@SGPG:O^SE-_]ZC-/>ISX#M7_9VG_NY1N[U'G3OPG:O^SE-_ +M]ZAQ]ZAS![YSU=]YZN\>->X>=>[`=Z[Z.T_]'3P[\)VK_LY3?P=SX#M7_9VG +M_@[FP'>N^CM/_=WE')U_YZJ_\]3?/6YSC_L<^4[U=Y[ZN\>-N\<+=W3^G:O^ +MSE-_][AQ]WCACLZ_<]7?>>KO'C?N'B_KO//5W,$>^ +M4_V=I_X.YLAWJK_SU-_!'/E.]7>>^KLG;>Y)GR/?J?[.4W_WI''WI'-'OE/] +MG:?^[DGC[DGGCGRG^CM/_=V3QMV3SAWY3O5WGOH[>';D.]7?>>KO8(Y\I_H[ +M3_T=S)'O5'_GJ;^[G*/S[USU=Y[ZNZ=M[FF?(]^I_LY3?_>T>KOGC7NGG7NR'>J +MO_/4WSUKW#WKW)'O5'_GJ;][UKA[UKDCWZG^SE-_!\^.?*?Z.T_]'KO//5WEW-T_IVK_LY3?_>\S3WO<^0[U=]YZN^>-^Z>+]S1^7>N +M^CM/_=WSQMWSA3LZ_\Y5?^>IOWO>N'N^<$?GW[GJ[SSU=_#LR'>JO_/4W\$< +M^4[U=Y[Z.Y@CWZG^SE-_!W/D.]7?>>KO7K2Y%WV.?*?Z.T_]W8O&W8O.'?E. +M]7>>^KL7C;L7G3ORG>KO//5W+QIW+SIWY#O5WWGJ[^#9D>]4?^>IOX,Y\IWJ +M[SSU=S!'OE/]G:?^[G*.SK]SU=]YZN]>MKF7?8Y\I_H[3_W=R\;=RX4[.O_. +M57_GJ;][V;A[N7!'Y]^YZN\\]7'?E.]7>>^CN8 +M(]^I_LY3?P=SY#O5WWGJ[V".?*?Z.T_]W:LV]ZK/D>]4?^>IOWO5N'O5N2/? +MJ?[.4W_WJG'WJG-'OE/]G:?^[E7C[E7GCGRG^CM/_1T\._*=ZN\\]7JO_/4WUW.T?EWKOH[3_W=59N[ZG/D.]7?>>KOKAIW5PMW=/Z= +MJ_[.4W]WU;B[6KBC\^]<]7>>^KNKQMW5PAV=?^>JO_/4W\&S(]^I_LY3?P=S +MY#O5WWGJ[V".?*?Z.T_]']WF7O-^Y>=^[(=ZJ_\]3?O6[[]4?^>IOX-G1[Y3_9VG_@[FR'>J +MO_/4W\$<^4[U=Y[ZN\LY.O_.57_GJ;][T^;>]#GRG>KO//5W;QIW;Q;NZ/P[ +M5_V=I_[N3>/NS<(=G7_GJK_SU-^]:=R]6;BC\^]<]7>>^CMX=N0[U=]YZN]@ +MCGRG^CM/_1W,D>]4?^>IOX,Y\IWJ[SSU=V_;W-L^1[Y3_9VG_NYMX^YMYXY\ +MI_H[3_W=V\;=V\X=^4[U=Y[ZN[>-N[>=._*=ZN\\]7?P[,AWJK_SU-_!'/E. +M]7>>^CN8(]^I_LY3?WKOO.KO@LZ_<]7?>=7?!9U_YZJ_\ZJ_"SK_ +MSE5_YU5_%W3^G:O^SJO^+NC\.U?]G5?]7=#Y=Z[Z.Z_ZNZ#S[USU=U[U=T'G +MW[GJ[SSU=^_;UOL^1[Y3_9VG_NY]X^Y]YXY\I_H[3_W=^\;=^\X=^4[U=Y[Z +MN_>-N_>=._*=ZN\\]7?P[,AWJK_SU-_!'/E.]7>>^CN8(]^I_LY3?W^^7\7<1>KOUHV[]<(=G7\7JK^+U-^M&W?KA3LZ_RY4 +M?Q>IOULW[M8+=W3^7:C^+E)_!\\.?!>JOXO4W\$<^"Y4?Q>IOX,Y\%VH_BY2 +M?P=SX+M0_5VD_L[:G/4Y\%VH_BY2?V>-.^O<@>]"]7>1^CMKW%GG#GP7JK^+ +MU-]9X\XZ=^"[4/U=I/X.GAWX+E1_%ZF_@SGP7:C^+E)_!W/@NU#]7:3^[G*. +MSK\+U=]%ZN^\S7F?(]^I_BY2?^>-.U^XH_/O0O5WD?H[;]SYPAV=?Q>JOXO4 +MWWGCSA?NZ/R[4/U=I/X.GAWY3O5WD?H[F"/?J?XN4G\'<^0[U=]%ZN]@CGRG +M^KM(_5VTN>ASY#O5WT7J[Z)Q%YT[\IWJ[R+U=]&XB\X=^4[U=Y'ZNVC<1>>. +M?*?ZNTC]'3P[\IWJ[R+U=S!'OE/]7:3^#N;(=ZJ_B]3?7<[1^7>A^KM(_=W0 +MYH8^1[Y3_5VD_FYHW`T+=W3^7:C^+E)_-S3NAH4[.O\N5'\7J;\;&G?#PAV= +M?Q>JOXO4W\&S(]^I_BY2?P=SY#O5WT7J[V".?*?ZNTC]']4?Q>I +MOX-G1[Y3_5VD_@[FR'>JOXO4W\$<^4[U=Y'ZN\LY.O\N5'\7J;_;M+E-GR/? +MJ?XN4G^W:=QM%N[H_+M0_5VD_F[3N-LLW-'Y=Z'ZNTC]W:9QMUFXH_/O0O5W +MD?H[>';D.]7?1>KO8(Y\I_J[2/T=S)'O5'\7J;^#.?*=ZN\B]7?;-K?M<^0[ +MU=]%ZN^VC;MMYXY\I_J[2/W=MG&W[=R1[U1_%ZF_VS;NMIT[\IWJ[R+U=_#L +MR'>JOXO4W\$<^4[U=Y'Z.Y@CWZG^+E)_=SE'Y]^%ZN\B]7=3FYOZ'/E.]7>1 +M^KNI<3]4?Q>IOX,Y\IWJ[R+U=S!'OE/]7:3^;FYSJOXO4W\V-N[ES1[Y3_5VD_@Z>'?E.]7>1 +M^CN8(]^I_BY2?P=SY#O5WT7J[R[GZ/R[4/U=I/[N0YO[T.?(=ZJ_B]3??6C< +M?5BXH_/O0O5WD?J[#XV[#PMW=/Y=J/XN4G_WH7'W8>&.SK\+U=]%ZN_@V9'O +M5'\7J;^#.?*=ZN\B]7JOXO4WWUL1^KN/ +MC;N/G3ORG>KO(O5W'QMW'SMWY#O5WT7J[SXV[CYV[LAWJK^+U-_!LR/?J?XN +M4G\'<^0[U=]%ZN]@CGRG^KM(_=WE')U_%ZJ_B]3??6ISG_H<^4[U=Y'ZNT^- +MNT\+=W3^7:C^+E)_]ZEQ]VGACLZ_"]7?1>KO/C7N/BWKO(O5W,$>^4_U=I/X.YLAWJK^+U-_!'/E.]7>1^KO/;>YSGR/?J?XN4G_W +MN7'WN7-'OE/]7:3^[G/C[G/GCGRG^KM(_=WGQMWGSAWY3O5WD?H[>';D.]7? +M1>KO8(Y\I_J[2/T=S)'O5'\7J;^[G*/S[T+U=Y'ZN^LV=]WGR'>JOXO4WUTW +M[JX7[NC\NU#]7:3^[KIQ=[UP1^??A>KO(O5WUXV[ZX4[.O\N5'\7J;^#9T>^ +M4_U=I/X.YLAWJK^+U-_!'/E.]7>1^CN8(]^I_BY2?W?3YF[Z'/E.]7>1^KN; +MQMU-YXY\I_J[2/W=3>/NIG-'OE/]7:3^[J9Q=].Y(]^I_BY2?P?/CGRG^KM( +M_1W,D>]4?Q>IOX,Y\IWJ[R+U=Q=SPQJN&NY^`"\\X.XNZ/W2Y\!W@^KOOK_P +M@+LOC;LOZV4.?#>H_FY(_=V7=GM?OBYSX+M!]7=#ZN^^-.Z^_+G,@>\&U=\- +MJ;^#9T=_W[;Z*/H+W]ZE;]_^N+H='&\_V\%7ZQW\6[_P[=_>/?QG&;P]F^=O +M#([C:G_K-=SC=WN&X70WC:MRL)O_5._S??_^?=(<_YW[;1_)S#G3P<.[NAI?? +M.B_F;N[-_=#!^=ZOO`_;ZF#]#W[W?WQO[OK=O=_")])!G_LASA.](-_L;];! +M=''DY/W/^?8LYUBM[_[7C3\<7#[?5;\_2OP?O-V_N+_5Y=N]_2/&]N&OMWMS +M7KS=U<.YVS]BW/L\'WR$Q=.[OKP[^BON_\F'<7%PXB]^Y?X8>?B5^W/.?Z\( +IYENS_/CM=`?_UB]\^_KNX3\_!XX/`=E_7ZC_\'#.+&':.H```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-pc98.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-pc98.qcow2.gz.uu new file mode 100644 index 000000000000..2d392cdc5a48 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-pc98.qcow2.gz.uu @@ -0,0 +1,22 @@ +# $FreeBSD$ +begin 644 img-63x255-512-pc98.qcow2.gz +M'XL("%?N+50``VEM9RTV,W@R-34M-3$R+7!C.3@N<6-O=S(N;W5T`*V8VW+3 +M,!!`W_,5X@X%@K4K^<(E*84RPQL\`,^)FWQ%AF\GBA1+7N]:;5#B\32C[IF5 +M]F@CIZK\2RFKE:F5Z=1^JXZ?PP4J^3"^U.'GM^_+]'58>)BNA"AFH-D-N!'K +M;\2!A*OT=$#SN"0[9'!PCIJ"E.Q6C)1%X"=#CQ&)6(JYDH+>$@BVN8*)1P)HMKF2C).YWWKF.B).]TWKL- +M$R5YI_/>;9DHR3N=]ZYGHB3O=-Z[.R9*\@X$[U3$[9@HR3L@WCT*N,<1MV>B +M).^`>/Y9P#V/.*;?@>0=$.]>!-S+B&/Z'4C>`?'N5(?'N76!5$0=$N\PX$S$,?T.)>^0>&<#KHXXIM^AY!T2[YJ`:R..Z78?$ +MNR[@WD<^0>/[RP.%F.7X/P),P#P!:JS93X"\_8>N%Z8SJ +M#3>OL$^T/.%UNGZVM##6E:3H^@'[A/8?&3:[PAFV_@>'QNU;6ZL6[IOAG]O? +M4Z6/N&(E\3CY!XFTW7G +M@N'YG=3#X2`S737&N7-!6L]1"3.KMYIFUQ\!P,C5+VT29/>][*[9VOT5_CCER\M(WZT":"(&7CR#C.,$+X!BB"Z +MC7'?,-U+WJ?BJW`T.7X&U!I="OPQ0(+<)4QCM'*.-G02U1#^(GG$>[JWQFGCM29DQ##EF'769TW +M61K3^;XXSI`#9`71!!MQX!)?O/2UJ0QB[A[H0^IN9W$U7R\C')VX"XY[6EP4 +M3Q;"D].[INKZS,&0ZYOQYLVU$'YS/8[R%H+651:3@;:*)^.^8?HN>?=`%8#9 +/3M!6/B&*?U("+YGG!@`` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-pc98.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-pc98.vhd.gz.uu new file mode 100644 index 000000000000..dd481004e925 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-pc98.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-512-pc98.vhd.gz +M'XL("%CN+50``VEM9RTV,W@R-34M-3$R+7!C.3@N=FAD+F]U=`"METU/["`4 +MAO?S*T[BSD5#3X$R&R +M\P$$QNP/0%8@.Y`M2$'UFH/<0JT`3*-[<2A+]PE]\_;:-I\O7X7[]1L+*UDX +M*AY.X[$";B:I`35-(O]2'7J/*2YNGR]?_CU['#JHF;;P?DM>DRM?A77\4_&X[BK&"& +MS_G=+=DD8T:#=W%\FX7L^W5\V\S^0[TJY'R%2F56J`:%HJ8-74A0^%.%?VZ? +M9E:PTME"8G%X"N<%A_M]C-L%N,HNN)$2)!LT)52M^PCK`>[*_CV.KZFC7:&= +M:U@T5F1.%JTFX\(X0]E"60%3K@UCX#&^,.K;IC(P,G=%'Z3F:L+5E,L- +M_7T1/Q:([C#*=KJA.SVR*>0.F$TA=^='1H6Z64VV<[-0.H69K@J$RWA5(%S& +BJP+A,EX5")?QJD"XC%<%PF6]*DAS"61L\PVA;@PG7PX````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-pc98.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-pc98.vhdf.gz.uu new file mode 100644 index 000000000000..5600c7aba7c4 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-pc98.vhdf.gz.uu @@ -0,0 +1,15 @@ +# $FreeBSD$ +begin 644 img-63x255-512-pc98.vhdf.gz +M'XL("%CN+50``VEM9RTV,W@R-34M-3$R+7!C.3@N=FAD9BYO=70`K94[;X,P +M$,?W?(J3NF5`?F.61(J:SI6JMC.E)LJ0=NG0@0]?&QOBPY!'94R(T>$?_WOX +M(,0?`((!J6>NRX9N5^#1K=:KGD;;^X!20IT"7RVPQS&GKQ+0"+"SR0F\[6-<-P:V^C)N-B@H%V<9Z`&*`>B@XUAX)A?..NK4AD,N7M!'Z3NU@Y7XN=I +MA&-7W`6,^W"X*)\HA5>BMTG5-9F30:<[X\:=ZR!XYWH;G^!MGV.&H +M;P:SIUO/N-LMJ@16NY>H3S>/]#WL#^OCZ3#@AE8UO%@H%W1I(2)Q5V-WGW8O +MCU-U/`V21M&C3F?<]JSC*'K;&"=&9XWI6R`]G^@&&69;E<-),EGUW]QZG,I< +.*O;#N_H#>\I9F1()```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-pc98.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-pc98.vmdk.gz.uu new file mode 100644 index 000000000000..b2d29cc5eeeb --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-pc98.vmdk.gz.uu @@ -0,0 +1,84 @@ +# $FreeBSD$ +begin 644 img-63x255-512-pc98.vmdk.gz +M'XL("%CN+50``VEM9RTV,W@R-34M-3$R+7!C.3@N=FUD:RYO=70`K5Q=C]S& +M$7SWKQB'0T[-%;FD +M2/OZM">PQ>[:[I[=OE-U89-D^G(N:UR6N:QU>>$2N.&?IH=+TA=C>&3QQNUO +M;__^XXE??SR=;E],8/!1$H)$X<28/<_MM/@BW/ES4;,;P^.\"Y?ZJ.8N,,"= +M-VYLP@W]<.>U$&97C[=;?R%P+@*Y&5R^4M-FL9_+[@]?A.;Y_%*?PW"\1>7* +MU!5-,%V1CW;JRO-X+W'EX-0/@%^ZMX\?_^/>=A^O3X\?GM^'_,[^;`?GK/#^ +MQ=4C#(65A;_P-SQ_?L$?OP%;/S9QN:DX_/G?F+/'-EY<9T2Q=]>GKG[N?OCT +MH7OS\.O[=[%W_FQ]RZH1Z#(V*G5YZJ%":;Y]N4?T+YOQU-SME\?GGQ^OWP]E +M?NP>3E\ZPA6^=\,!7D)>4]5#2+%YLD/:MV__]SS4Z]IPLH^$&Y,8BQB>.S^[ +MO/18PP&F0^_2U*47EX[P0\)#)1F\D[N]?W?ZQT\.17K)W/??_>D?A+L,<(/G +MD.`0,A0TJRF?ZL^7+TMW^_Y;]^"+_.'G;GP%$JZ:WF;>>3H'C.;97X2N3?!^ +MB&7^QGBR[FW]7+MOZH_=Z91B@O:O[[&=0^.FDYX. +M>CR*MFU.=5M_>.Z>_/'&HVC\J[4-E?ICS5Z.,/R8/UST_?3I=/_WR^*X= +MWFCN#>':J7=#.L-I3DG%G)9)Q:<=>O>`E]0&;,)UOD534I?PQABPICQ>NI`. +MC]P_0A=NGTX_=W4[I.4>SGG^$(^B7QZ%MFC1A>F@AUY,1Q$2^W3ZV%T#7)J$ +M`^QGS9ER\B_EX94\930?H,_OG\;4BO1!YW&Z_%GVVGFI>'WM$SUZA"C'(& +MM]6[(O2.GI5&U6(TJ]DMBRU#[^C9:E0G1G\([A)ZQU_`(-=C[VBDR=IO> +M5:%W],PUJA"CG,%M]:X.O:-GI5&U&,UJ=LMBF]`[>K8:U8G1'X*[AMYQK$"N +MQ][12/7&9N_:T#MZYAI5B%'.X+9ZUX7>T;/2J%J,9C6[9;%]Z!T]6XWJQ.B/ +MP)5)Z%TFO>/UV#L:J=[8ZEW)>4?/7*,*,E8:58O1K&:W+);S +MCIZM1G5B](?@..]RZ1VOQ][12/7&9N\X[^B9:U0A1CF#V^H=YQT]*XVJQ6A6 +MLUL6RWE'SU:C.C'Z0W"<=X7TCM=C[VBD>F.S=YQW],PUJA"CG,%M]8[SCIZ5 +M1M5B-*O9+8OEO*-GJU&=&/TA.,X[_NH$N1Y[1R/5&YN]X[RC9ZY1A1CE#&ZK +M=YQW]*PTJA:C6K$Z(_`79+0NXOTCM=C[VBD>F.K=Q?..WKF +M&E6(4<[@-GIWX;RC9Z51M1C-:G;+8CGOZ-EJ5"=&?PB.\ZZ2WO%Z[!V-5&]L +M]H[SCIZY1A5BE#.XK=YQWM&STJA:C&8UNV6QG'?T;#6J$Z,_!,=YQ_]X0:[' +MWM%(]<9F[SCOZ)EK5"%&.8/;ZAWG'3TKC:K%:%:S6Q;+>4?/5J,Z,?I#<)QW +M9"TAUV/O:*1Z8[-WG'?TS#6J$*.K49T8 +M_1&X*@F]NTKO>#WVCD:J-[9Z5W'>T3/7J$*,<@:WT;N*\XZ>E4;58C2KV2V+ +MY;RC9ZM1G1C](3C.NU9ZQVNRVK%W[1W<=_3,-:H0HYS!;?6.\XZ>E4;5 +M8C2KV2V+Y;RC9ZM1G1C](3C.NTYZQ^NQ=S12O;'9.\X[>N8:58A1SN"V>L=Y +M1\]*HVHQFM7LEL5RWM&SU:A.C/X0'.==+[WC]=@[&JG>V.P=YQT]Q9T;Y-KW+AJIWMCJ71WF +M7?3,-:H0HYS!;?2N#O,N>E8:58O1K&:W+#;,N^C9:E0G1G\(+LP["'\'Y>\@ +M_!UV^;LZS#L(?P?E[R#\'7;YNSK,.PA_!^7O(/S=2G;+8L.\@_!W4/X.PM\= +M@`OS#L+?0?D["'^'7?ZN#O,.PM]!^3L(?X==_JX.\P["WT'Y.PA_MY+=LM@P +M[R#\'92_@_!W!^#"O(/P=U#^#L+?89>_J\.\@_!W4/X.PM]AE[^KP[R#\'=0 +M_@["WZUDMRPVS#L(?P?E[R#\W3Y"7\'Y>\@_!UV^;N&\T[X.RA_!^'O +ML,O?-9QWPM]!^3L(?[>2W;)8SCOA[Z#\'82_.P#'>2?\'92_@_!WV.7O&LX[ +MX>^@_!V$O\,N?]=PW@E_!^7O(/S=2G;+8CGOA+^#\G<0_NX`'.>=\'=0_@[" +MWV&7OVLX[X2_@_)W$/X.N_Q=PWDG_!V4OX/P=RO9+8OEO!/^#LK?0?B[`W"< +M=\+?0?D["'^'7?ZNX;P3_@[*WT'X.^SR=PWGG?!W4/X.PM^M9+]:SCOA[Z#\'82_6\EN62SGG?!W4/X.PM\= +M@..\$_X.RM]!^#OL\G_:SGOA+^#\G<0_FXENV6QG'?" +MWT'Y.PA_=P".\T[X.RA_!^'OL,O?M9QWPM]!^3L(?X==_J[EO!/^#LK?0?B[ +ME>R6Q7+>"7\'Y>\@_-T!.,X[X>^@_!V$O\,N?]=RW@E_!^7O(/P==OF[EO-. +M^#LH?P?A[U:R6Q;+>2?\'92_@_!W^W!=,O4N2O`@UZ.,D4:J-VYCTX9O-WPG +M[@4NS+M51=_*/\7>N?7L[K3XQ^#NBYWDAACEAG$3,97[^P`G.&,Y)"ZAZ_N` +M1^20B.MR/EXEAT1;R"$1U^4F;R"$1U^4F;R"$1U^4F;R"$1U^4FG^9\(B/ZW`>:YJ^\!_QD*SL9/$ZXR=\W6ZDJGX\1VP5_/^I>=C>6:66;< +MOR+Y;"*_/<.R,\[P,F:8E_Z#=O/"7V^0R(/VF_! +M?2UP_C>"7CQGGP5^A4LYC?5:X+Z:O@F7?2X[75$=*];XP[LOR641I^?L?_)X +M0I#_SSO/`>/YNI?\JOLTSK-R/Y.?NR_7_]35CZ_5\Y@-ZHURW1S._]35\YP= +MX4[WOKK/[FI\&%B^,PZ^G^9\),`N` +29AW,_$>3)%_\'XGNMJQQ8``` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-vtoc8.qcow.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.qcow.gz.uu new file mode 100644 index 000000000000..791a1e015359 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.qcow.gz.uu @@ -0,0 +1,127 @@ +# $FreeBSD$ +begin 644 img-63x255-512-vtoc8.qcow.gz +M'XL("+\S(E0``VEM9RTV,W@R-34M-3$R+79T;V,X+G%C;W7Z3TS<_N?]V^O7?/_WSQV]_ +M_/K#US$Y?^>I>S^7TS">ICQW;^M_;4X_/[6>SE,X]^5-T-PWK\Y^\ZN[]\D> +MYVY^^/K)XN?TMPV>W.N3WW%Z7]X,OKYSG5/X5&)SW;VYVSSWGU +MOVWP%W=Z^GM/+WI]=EGAW/G/'=; +MY]!7AI2OI^,'^GMS/_]8@"YS"3Y%N).(NVL'GR+<2<3=M8=/$>XDXNXZP*<( +M=Q)R-\*G"'<:/.`N[2&?G.&'<6<)?.R'?&N+.`NW1&OC/&G87<(=\9XRZ%W"'? +M)<9="KE#ODN,NQ1RAWR7&'ZZB#M!ONL8=UW$G2#?=8R[+N).D.\Z +MQET7<2?(=QWCKHNX$^2[CG'7A=PAWW6,NS[D#OFN9]SU(7?(=SWCK@^Y0[[K +M&7=]R!WR7<^XZT/ND.]ZQET?<=='W"E^BG`W1-PI\MW` +MN!LB[A3Y;F#<#1%WBGPW,.Z&B#M%OAL8=T/$G2+?#8R[(>).D>\&QMT0<:?( +M=P/C;@BY0[X;&'=CR!WRW&W"'? +MC8R[,>0.^6YDW(TA=\AW(^-NC+@S_!3AKOSG>3Z'?#'W"'?S8R[.>0.^6YFW,TA=\AW,^-N#KE#OIL9=W/( +M'?+=S+B;(^X2?HIP5_XW*9]#OEL8=TO$74*^6QAW2\1=0KY;&'=+Q%U"OEL8 +M=TO$74*^6QAW2\1=0KY;&'=+Q%U"OEL8=TO('?+=PKA;0^Z0[U;&W1IRAWRW +M,N[6D#ODNY5QMX;<(=^MC+LUY`[Y;F7*N +M0[[;&'=;Q%V'?+0.^>["N+N$ +MW"'?71AWEY`[Y+L+X^X2N2[*^/N +M&G'7(]]=&7?7B+L>^>[*N+M&W/7(=U?&W37BKD>^NS+NKA%W/?+=E7%WC;CK +MD>^NC+MKR!WRW95P)^4=/@=\)V?"G9Q#[H#OY$RXDW/('?"=G`EW<@ZY`[X3 +MUM])U-^E'OA.6'\G47^7>N`[8?V=1/U=ZH'OA/5W$O5W=_^6`I\BW$7]71J` +M[X3U=Q+U=VD`OA/6WTG4WZ4!^$Y8?R=1?Y<&X#MA_9U$_5T:@.^$]7<2]7=I +M`+X3UM])U-^E`?A.6'\G47^7!N`[8?V=1/U=&I#O6'\G47^7!N0[UM])U-^E +M`?F.]7<2]7=I0+YC_9U$_5T:D.]8?R=1?Y<&Y#O6WTG4WZ4!^8[U=Q+V=R-^ +MBG`7]G]8?R=A?SOO).SO1N0[UM])V-^-R'>L +MOY.POQN1[UA_)V%_-R+?L?Y.POYN1+YC_9V$_=V(?,?Z.PG[NPD_1;@+^[L) +M^8[U=Q+V=Q/R'>OO).SO)N0[UM])V-]-R'>LOY.POYN0[UA_)V%_-R'?L?Y. +MPOYN0KYC_9V$_=V$?,?Z.PG[NPGYCO5W$O9W$_(=Z^\D[.\FY#O6WTG8WTW( +M=ZR_D["_FY#O6'\G87\W(=^Q_D["_FY"OF/]G83]W8R?(MR%_=V,?,?Z.PG[ +MNQGYCO5W$O9W,_(=Z^\D[.]FY#O6WTG8W\W(=ZR_D["_FY'O6'\G87\W(]^Q +M_D["_FY&OF/]G83]W8Q\Q_H["?N[&?F.]7<2]G]8?R=A?S["_FY!OF/]G83]W8)\Q_H[ +M"?N[!?F.]7<2]G<+\AWK[R3L[Q;D.];?2=C?+OO).SO%N0[UM]) +MV-\MR'>LOY.POUN0[UA_)V%_M^*G"'=A?[OO).SO5N0[UM])V-^MR'>LOY.POUN1[UA_)V%_ +MMR+?L?Y.POYN1;YC_9V$_=V*?,?Z.PG[NQ7YCO5W$O9W*_(=Z^\D[.]6Y#O6 +MWTG8WZW(=ZR_D["_V_!3A+NPO]N0[UA_)V%_MR'?L?Y.POYN0[YC_9V$_=V& +M?,?Z.PG[NPWYCO5W$O9W&_(=Z^\D[.\VY#O6WTG8WVW(=ZR_D["_VY#O6'\G +M87^W(=^Q_D["_FY#OF/]G83]W89\Q_H["?N[#?F.]7<2]G<;\AWK[R3L[S;D +M.];?2=C?7?!3A+NPO[L@W['^3L+^[H)\Q_H["?N["_(=Z^\D[.\NR'>LOY.P +MO[L@W['^3L+^[H)\Q_H["?N["_(=Z^\D[.\NR'>LO]/RCIL[M3G@N[NG,'?J +M^KMRW]^I<0=\IZR_4]??G3)WI\8=\)VR_DY=?W?*W)T:=\!WROH[=?W=:3^< +M'?"=LOY.77]7SZ[-`=\IZ^_4]7=@#OA.67^GKK\[SJ'[[Y3U=^KZNS+WH,T! +MWRGK[]3U=P_*7.4.W7^GK+]3U]\]R-P]J-RA^^^4]7?J^KL'F;L'E3MT_YVR +M_DY=?_=@/YP=\)VR_DY=?U?/KLT!WRGK[]3U=V`.^$Y9?Z>NOP-SP'?*^CMU +M_5V9>]CFD.]8?Z>NOWM8YAIWR'>LOU/7WSW,W#ULW"'?L?Y.77_W,'/WL'&' +M?,?Z.W7]W0[UM^IZ^\.<]T9/T6X +M<_U=F7O4YI#O6'^GKK][5.9.=0[YCO5WZOJ[1YF[1[=U#OF.]7?J^KM'F;M' +MO]0YY#O6WZGK[Q[MA[-#OF/]G;K^KIY=FT.^8_V=NOX.S"'?L?Y.77\'YI#O +M6'^GKK\K/RUSC#OF.]7?J^KO'F;O'C3OD.];?J>OO'F?N +M'C?ND.]8?Z>NOWN\'\X.^8[U=^KZNWIV;0[YCO5WZOH[,(=\Q_H[=?W=<0[= +M?Z>LOU/7WY6Y)VT.^8[U=^KZNR=EKG*'[K]3UM^IZ^^>9.Z>5.[0_7?*^CMU +M_=V3S-V3RAVZ_TY9?Z>NOWNR'\X.^8[U=^KZNWIV;0[YCO5WZOH[,(=\Q_H[ +M=?T=F$.^8_V=NOZNS#UM<\AWK+]3U]\]+7.-.^0[UM^IZ^^>9NZ>-NZ0[UA_ +MIZZ_>YJY>]JX0[YC_9VZ_N[I?C@[Y#O6WZGK[^K9M3GD.];?J>OOP!SR'>OO +MU/5WQSET_YVR_DY=?U?FGK4YY#O6WZGK[YZ5NOO +MP!SR'>OOU/5W8`[YCO5WZOJ[,O>\S2'?L?Y.77_WO,PU[I#O6'^GKK][GKE[ +MWKA#OF/]G;K^[GGF[GGC#OF.]7?J^KOG^^'LD.]8?Z>NOZMGU^:0[UA_IZZ_ +M`W/(=ZR_4]??'>?0_7?*^CMU_5V9>]'FD.]8?Z>NOWM1YBIWZ/X[9?V=NO[N +M1>;N1>4.W7^GK+]3U]^]R-R]J-RA^^^4]7?J^KL7^^'LD.]8?Z>NOZMGU^:0 +M[UA_IZZ_`W/(=ZR_4]??@3GD.];?J>OORMQ-FT.^8_V=NO[NILPU[I#O6'^G +MKK^[R=S=-.Z0[UA_IZZ_N\GNO[O9#V>'?,?Z.W7]73V[-H=\ +MQ_H[=?T=F$.^8_V=NO[N.(?NOU/6WZGK[\KLOU/7W[W<#V>'?,?Z.W7] +M73V[-H=\Q_H[=?T=F$.^8_V=NOX.S"'?L?Y.77]7YEZU.>0[UM^IZ^]>E;G& +M'?(=Z^_4]7>O,G>O&G?(=ZR_4]??OOOU/5W8`[YCO5WZOJ[XQRZ_TY9?Z>NORMSK]L<\AWK[]3U=Z_+ +M7.4.W7^GK+]3U]^]SMR]KMRA^^^4]7?J^KO7F;O7E3MT_YVR_DY=?_=Z/YP= +M\AWK[]3U=_7LVASR'>OOU/5W8`[YCO5WZOH[,(=\Q_H[=?U=F?NQS2'?L?Y. +MH_ZN0_??*>OO-.KO.G3_G;+^3J/^KD/WWRGK[S3J[SIT_YVR_DZC_JY#]]\I +MZ^\TZN\Z=/^=LOY.H_ZN0_??*>OOE/1W;]H<\AWK[]3U=V_*7.4.W7^GK+]3 +MU]^]R=R]J=RA^^^4]7?J^KLWF;LWE3MT_YVR_DY=?_=F/YP=\AWK[]3U=_7L +MVASR'>OOU/5W8`[YCO5WZOH[,(=\Q_H[*^^XN7.;`[XSUM_=?>`>=\5/Y\8= +M\)VQ_LY^?&'?"=L?[.7']WSMR=&W?`=\;Z.W/]W7D_G!WPG;'^SEQ_ +M5\^NS0'?&>OOS/5W8`[XSEA_9ZZ_.\ZA^^^,]7?F^KLR)VT.^,Y8?V>NOY,R +M5[E#]]\9Z^_,]7>27YY4[M#]=\;Z.W/]G63NI'*'[K\SUM^9Z^]D/YP=\)VQ +M_LYNOP-SP'?&^CMS_5V9TS:'?,?Z.W/] +MG9:YQAWR'>OOS/5WFKG3QAWR'>OOS/5WFKG3QAWR'>OOS/5WNA_.#OF.]7?F +M^KMZ=FT.^8[U=^;Z.S"'?,?Z.W/]W7$.W7]GK+\SU]^5.6MSR'>LOS/7WUF9 +MJ]RA^^^,]7?F^CO+W%GE#MU_9ZR_,]??6>;.*G?H_CMC_9VY_L[VP]DAW['^ +MSEQ_5\^NS2'?L?[.7'\'YI#O6']GKK\#<\AWK+\SU]^5N=3FD.]8?V>NOTME +MKG&'?,?Z.W/]7LOS/7WZ7]<';(=ZR_,]?? +MU;-K<\AWK+\SU]^!.>0[UM^9Z^^.<^C^.V/]G;G^KLQU;0[YCO5WYOJ[KLQ5 +M[M#]=\;Z.W/]79>YZRIWZ/X[8_V=N?ZNR]QUE3MT_YVQ_LYLOS/7 +MW]6S:W/(=ZR_,]??@3GD.];?F>OOCG/H_CMC_9VY_J[,#6T.^8[U=^;ZNZ', +M5>[0_7?&^CMS_=V0N1LJ=^C^.V/]G;G^;LC<#94[=/^=L?[.7'\W[(>S0[YC +M_9VY_JZ>79M#OF/]G;G^#LPAW['^SEQ_!^:0[UA_9ZZ_*W-CFT.^8_V=N?YN +M+'.-.^0[UM^9Z^_&S-W8N$.^8_V=N?YNS-R-C3OD.];?F>OOQOUP=LAWK+\S +MU]_5LVMSR'>LOS/7WX$YY#O6WYGK[XYSZ/X[8_V=N?ZNS$UM#OF.]7?F^KNI +MS%7NT/UWQOH[<_W=E+F;*G?H_CMC_9VY_F[*W$V5.W3_G;'^SEQ_-^V'LT.^ +M8_V=N?ZNGEV;0[YC_9VY_@[,(=^Q_LYNORMS;]L<\AWK[\SU +M=V_+7.,.^8[U=^;ZN[>9N[>-.^0[UM^9Z^_>9N[>-NZ0[UA_9ZZ_>[L?S@[Y +MCO5WYOJ[>G9M#OF.]7?F^CLPAWS'^CMS_=UQ#MU_9ZR_,]??E;EW;0[YCO5W +MYOJ[=V6N[G9M#OF.]7?F^CLPAWS'^CMS_1V80[YC_9VY_J[,O6]S +MR'>LOS/7W[TOOOZMFU.>0[UM^9Z^_`'/(=Z^_,]7?'.73_G;'^SEQ_5^8^ +MM#GD.];?F>OO/I2YRAVZ_\Y8?V>NO_N0N?M0N4/WWQGK[\SU=Q\R=Q\J=^C^ +M.V/]G;G^[L-^.#OD.];?F>OOZMFU.>0[UM^9Z^_`'/(=Z^_,]7=@#OF.]7?F +M^KLR]['-(=^Q_LYQS#7ND.]8?V>NO_N8N?O8N$.^8_V=N?[N8^;N8^,. +M^8[U=^;ZNX_[X>R0[UA_9ZZ_JV?7YI#O6']GKK\#<\AWK+\SU]\=Y]#]=\;Z +M.W/]79G[U.:0[UA_9ZZ_^U3F*G?H_CMC_9VY_NY3YNY3Y0[=?V>LOS/7WWW* +MW'VJW*'[[XSU=^;ZNT_[X>R0[UA_9ZZ_JV?7YI#O6']GKK\#<\AWK+\SU]^! +M.>0[UM^E\HZ;NVUSP'>)]7?)]7>W9:YQ!WQW]Q3F+KG^[C9S=]NX`[Y+K+]+ +MKK^[S=S=-NZ`[Q+K[^I;F3OTQNC^N_94,/?-CU]_N/DRV)\_?SCUIT%/???Y +M+>FILU-*G\N/+QG%!@=_^N_E\K?__$/M7]^^OA[=N?3G7M]]]N3[@^/I/)W. +M"@>_SGW#WA3.?>_U?9U#W^O]3\RA[_4.YSY3=_<'F+O?,BYN[I=OYM#W>O\S +MOQC'JSG*'U/.]@<^W7HUA[5_^/KEMZT[NY`Y:7.?_%S[=-4]I:?V/'AU)_CJ +MVI?:]^LG]'<^A;V_]Q5-#5''ANFT_+'2=RNJY\#EW-\6=0&;X, +E?I;F#/[./_#KSS_>_^OK8,J#?]DK3'=>.9]_^#\)B7^=OZ8````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-vtoc8.qcow2.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.qcow2.gz.uu new file mode 100644 index 000000000000..0a79ac256b65 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.qcow2.gz.uu @@ -0,0 +1,21 @@ +# $FreeBSD$ +begin 644 img-63x255-512-vtoc8.qcow2.gz +M'XL("+8[(U0``VEM9RTV,W@R-34M-3$R+79T;V,X+G%C;W'J)`Z%5*/@;%(5YX24U7"0Q'DAA1K.)7&9D/(:+NF= +M6PDIS3N;]BX74IIW-NU=(:0T[VS:NXV0TKRS:>]*(:5Y!XIWAG!;(:5Y!\R[ +M)Q'WE'"5D-*\`^;=LXA[3KA:2&G>`?/N1<1=$4[H.]"\`^;=RXA[=<1Y*:5Y +M!\R[UQ%W33BA[T#S#IAW;R+N+>&$O@/-.V#>O1MYYX6^`\T[9-Z]CZPEX82^ +M0\T[9-[9B`/""7V'FG?(O,.((?/N<\1](9S0=ZAYYYAWMQ'W +ME7!"WSG-.\>\^Q9Q=X03^LYIWCGFW7W$/1!.Z#NG>>>8=X\1MR9<,^O]IZ/[ +M=RN\ZR,J$;C^6]=W +MOQ\`?_3F\W,_$'C:O^5@@Q1@WMZ.@[9_?K!_11(W-5^'V\RUW`Y7GHH+]1UN +M[:O:U#7#_>GAMC-?##M:;GVX\\<+EFL/RT7ZX:9MOM!_"J[WRW;+<;1<8"GZ +M1XV5IC/B=-415VZI\T[9O7L)-_ED>_[>G=Q\U<:4P1-KFJV.@\DASE8ERUM@ +BN&<)3\'C=_W$[N?-\*L#N@B<;<+P@!9>B_]NV1VQX1,````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-vtoc8.raw.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.raw.gz.uu new file mode 100644 index 000000000000..c949873459fc --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.raw.gz.uu @@ -0,0 +1,11 @@ +# $FreeBSD$ +begin 644 img-63x255-512-vtoc8.raw.gz +M'XL("/W%'50``VEM9RTV,W@R-34M-3$R+79T;V,X+G)A=RYO=70`K9)!;L,@ +M$$7W/L5?=V$Q@&V\JI16V56JU`O4-G"`K#E\2'!"C+'C1![0"&GF/\T7PU@( +M0-9H..KJ$?VGXEN3"'4_&'/Z^N?@IK^&*`"-?G/>/JL6"*Y-P +MQ<<(5!,=K0,56`O&L\"`:Z.J?8I;FR_@NKWL!ER_%5?[K*$-C$EP_P^X8>?/ +MH)E=`PH/\89=NMD5L=G:2Q9V"4<1]YGBHEV>J#BB/C,=LM/I.ZX?(,54M6KV +M*XT*PPS*.KP[QZJHT6EV!E>_J,GFYX'[+Z0G`?@3N-2$U +-2M6,%6>->Z%+`P4````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhd.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhd.gz.uu new file mode 100644 index 000000000000..523a1ae8f369 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhd.gz.uu @@ -0,0 +1,18 @@ +# $FreeBSD$ +begin 644 img-63x255-512-vtoc8.vhd.gz +M'XL("/W%'50``VEM9RTV,W@R-34M-3$R+79T;V,X+G9H9"YO=70`K9;-;MLP +M#,?O>0H"N_5@R)0LVZ<"Z];;@`%[@HA56D=&M3(V>WOQMI]=S&$"DZ3@P**Y>;071@H/Y:X5:B\<_=L:F?238I? +MQAFT.ZK8=]?.NX?3IE$CU:H\.HQL\%>M<*@.K(YP.^XZ=I=N*P4()Y5BOK8: +M`33UNLW]NW_VGBXNZB^)/K<3+/]]'*Y*[/YQV2I0-2>QW>-P]6Q5O__N.B?E +M[HAKWHJCG*$ZZ#QXO\!]CW"M\&$T*W?]$/]J2+]7N]M,[NIY\GBO*+/OX**\ +M?+O$M5YV'Z*U=NX[D_:S;`T````` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhdf.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhdf.gz.uu new file mode 100644 index 000000000000..d8c4d3d6bf31 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhdf.gz.uu @@ -0,0 +1,14 @@ +# $FreeBSD$ +begin 644 img-63x255-512-vtoc8.vhdf.gz +M'XL("/[%'50``VEM9RTV,W@R-34M-3$R+79T;V,X+G9H9&8N;W5T`*V4O6[# +M(!2%]SS%D;IEB,R/L3U%ZD^V2I7Z`K4-1!G:2E6'#G[X8K!C(-A-(V.$B.!\ +MG$LN-\M<`[A`02'ROG.*G(%S,`HP,Y,P6Z*.[O"EU/WK(V7/.]NZC8,1LWBY +M?U#-+G2[J'6;[0`L`QU9!I;(*F0T"72X:E)5?^*6_#ECMO3^W'$T2&J\6!3H\^E.7X291CNP13F +MV!V++\E7N3=H?#(=/AK_]O8^CI^#-05(-];FV(,?P4(J^RPNSR+5S6_#XL3* +.J6)R;_,+FZ-::BX'```` +` +end diff --git a/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vmdk.gz.uu b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vmdk.gz.uu new file mode 100644 index 000000000000..d9340d12bc61 --- /dev/null +++ b/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vmdk.gz.uu @@ -0,0 +1,83 @@ +# $FreeBSD$ +begin 644 img-63x255-512-vtoc8.vmdk.gz +M'XL("/[%'50``VEM9RTV,W@R-34M-3$R+79T;V,X+G9M9&LN;W5T`*U<76_= +MQA%]SZ\@[#X412%PR+DD[X-1-U$"%$6`(`[:U_!CV0A-;$,6BAK0C^\NN6=U +MJ'OI9:-QJ$#C.W.T,^0]DL\A5E_13X:TPO +M//[]]OM_W-"?QZ]6,`E55"(EPU&P^3J/-\_^`*[Z4M7F!7]56;C:ORC#16&$ +MJW9>V(73,+MK)3A=7_@&RBE\0G!O$U"Q@3M=Z6FWV2^=[D]?Q>'YEZLZG,'? +MWN9N39@_XNKB]^_3OXM9]&N_O/CY\B.>KPKWU +MR=J$_&8,"+ZQM@F?A!<"W#E`-*ZHIZ*6\'+Q>/_=W:_NYC_N_M/=A_=O!.U6 +MX=YJ7>@Y'"?DET_7)@A?I"P:"5^C>/SF;[=OXI-;WGSL[P$7JOQ!_-?V?3!N +MTQ3AX_):3N?>/P3$.?Y)IPOW-@[GM'QM#9^/[LVKWSZ\3[,+]S:,[+P`=67_LQV__^^#[+:9X9^\`MQQB +M:<)_[5-5G-J`5?OQ^2I_'VO?;!7^RA_8=Z(2DHK'#^]O?ORG'[3XZ-T/?_T1 +M<)V'\YG^@+[$-[3IZ;3V?WK^6!:/[[XM7H4F?_K%+4\@X,[A,5Z3U_L@2UB% +M3^+45OA`8AI>6.YL<=L_],77_2=W\_KV]NMT9_O0K"Z7/YH+*,T*'9[O99Q^ +M<.N=7F_T'4W^7L:8/_E/OP&N'%]C/TYPB-Q7@KK\(E_>A9X%[_"^L2$VQ3@W,/]YYOQ +M\Z]W[R?_1BO>`&Y:9^>/4]?Q4.E,SP^5OJR?W:OZZ6@>&W`NC&@]5!??&!YK +M/_N'[RQRI>5:?3JW0KYN>W@D?T;`KKC?:S6&]%/-CG +MFT]NC'!U&6_@O!G.>J:B;IY&L"70AP_WR]$:WS/Q]E+^5@OOJ6V#,C? +ME^8#WWXTG$\(3MK?>;X5[N)[[0O;;@V<#NS6QZ5,V7V7#50,!YI=GE4)LIT +M7#67FQ\CLS\V2E/%V2&SXJJ:`KV`NS*[IHZS0V;#52T%W09N;W8:9X?,GJL& +M"L9#S9[B[)#IN&HNMS\FUUFX)LX.F157U13H!=RUV;5Q=LALN*JEH-O`['S(JK:@KT`N[:[,!WR&RXJJ6@ +MV\#MS0Y\A\R>JP8*QD/-@N^0Z;AJIB!^0V7!5 +M2T&W@=N975O&V2&SYZJ!@O%(LRWX#IF.JV8*PM5DXZX:*!@/-0N^0Z;CJIF"<+59./`=,BNNJBG0"[AK +MLP/?(;/AJI:";@.W-SOP'3)[KAHH&`\U"[Y#IN.JN=S\@%MV63CP'3(KKJHI +MT`NX:[,#WR&SX:J6@FX#MS<[\!TR>ZX:*!@/-0N^0Z;CJIF"<)VS<.`[9%9< +M55.@%W#79@>^0V;#52T%W09N9W9=&6>'S)ZK!@K&(\UVX#MD.JZ:*0A7GX4# +MWR&SXJJ:`KV`NS*[#GR'S(:K6@JZ#=S>[,!WR.RY:J!@/-0L^`Z9CJOF#V9@>^0V;/50,%XZ%FP7?(=%PU +ME]M_PX]9./`=,BNNJBG0"[AKLP/?(;/AJI:";@.W-SOP'3)[KAHH&`\U"[Y# +MIN.JF8)P35DX\!TR*ZZJ*=`+N&NS`]\AL^&JEH)N`[U%'0;N+W9@>^0V7/5 +M0,%XJ%GP'3(=5\T4A&O.PH'OD%EQ54V!7L!=FQWX#ID-5[44=!NXO=F![Y#9 +M<]5`P7BH6?`=,AU7S>5&ITR;OGVXR'DWPGK=T+ZG63UNW/D.R'] +M3EB_$]+O)*O?]66<'>EWPOJ=D'Z7;[:/?">DWPGK=T+ZG60EK3[RG9!^)ZS? +M">EWDM7O^LAW0OJ=L'XGI-])5K_K(]\)Z7?"^IV0?G>@VDWPGK=T+ZG63UNS[RG9!^)ZS?">EW!YJ- +M?">DWPGK=YMM2U;2ZL%WI-\)ZW="^IUD];L>?$?ZG;!^)Z3?25:_Z\%WI-\) +MZW="^MV!9L%WI-\)ZW="^IUD):T>?$?ZG;!^)Z3?25:_Z\%WI-\)ZW="^IUD +M];NAC+,C_4Y8OQ/2[_+-#N`[TN^$]3LA_4ZRDM8`OB/]3EB_$]+O)*O?#>`[ +MTN^$]3LA_4ZR^MT`OB/]3EB_$]+O#C0+OB/]3EB_$]+O)"MI#>`[TN^$]3LA +M_4ZR^MT`OB/]3EB_$]+O)*O?#>`[TN^$]3LA_>Y`L^`[TN^$]3O>*$M6TAK` +M=Z3?">MW0OJ=9/6[`7Q'^IVP?B>DWTE6OQO`=Z3?">MW0OK=@6;!=Z3?">MW +M0OJ=9"6M`7Q'^IVP?B>DWTE6OQO`=Z3?">MW0OJ=9/6[L8RS(_U.6+\3TN_R +MS8[@.]+OA/4[(?U.LI+6"+XC_4Y8OQ/2[R2KWXW@.]+OA/4[(?U.LOK="+XC +M_4Y8OQ/2[PXT"[XC_4Y8OQ/2[R0K:8W@.]+OA/4[(?U.LOK="+XC_4Y8OQ/2 +M[R2KWXW@.]+OA/4[(?WN0+/@.]+OA/4[]H9*5M(:P7>DWPGK=T+ZG63UNQ%\ +M1_J=L'XGI-])5K\;P7>DWPGK=T+ZW8%FP7>DWPGK=T+ZG60EK1%\1_J=L'XG +MI-])5K\;P7>DWPGK=T+ZG63UNZF,LR/]3EB_$]+O\LU.X#O2[X3U.R']3K*2 +MU@2^(_U.6+\3TN\DJ]]-X#O2[X3U.R']3K+ZW02^(_U.6+\3TN\.-`N^(_U. +M6+\3TN\D*VE-X#O2[X3U.R']3K+ZW02^(_U.6+\3TN\DJ]]-X#O2[X3U.R'] +M[D"SX#O2[X3U.R']KBJOPQ5/<)'O*BIYJJHIT"V5 +MOTJS*ZXW.WZI:A_N3&G,:GS0HJ)_SE;=<\!PQ#_XCS^F\]6+*:TB +MN/K8^?XLEQVMF5VS[HSMFIK6^;A>9-?4M,[']2*[IJ9U/JX7 +MV34UK?--[)J:UODF=DU-ZWP3NZ:F=;Z)75/3.M_$KJEIG6]BU]2TSC>Q:VI: +MYYO8-36M\TWLFIK6^29V34WK?!.[IJ9UOHE=4],ZW\2NJ6F=;V+7U+3.-[%K +M:EKGF]@U-:WS3>R:FM;Y)G9-3>M\$[NFIG6^B5U3TSK?Q*ZI:9UO8M?4M,XW +ML6MJ6N>;V#4UK?--[)J:UODF=DU-ZWP3NZ:F=;Z)75.QSK>Q:RK6^39V3<4Z +MW\:NJ5CGV]@U%>M\&[NF8IUO8]=4K/-M[)J*=;Z-75.QSK>Q:RK6^39V3<4Z +MW\:NJ5CGV]@U%>M\&[NF8IUO8]=4K/-M[)J*=;Z-75.QSK>Q:RK6^39V3<4Z +MW\:NJ5CGV]@U%>M\&[NF8IUO8]=4K/-M[)J*=;Z-75.QSK>Q:RK6^39V3<4Z +MW\:NJ5CGV]@U%>M\&[NF8IUO8]=4K/-M[)J*=;Z-75/3.A^9+[)K:EKG(_-% +M=DU-ZWQDOLBNJ6F=C\P7V34UK?--[)J:UODF=DU-ZWP3NZ:F=;Z)75/3.M_$ +MKJEIG6]BU]2TSC>Q:VI:YYO8-36M\TWLFIK6^29V34WK?!.[IJ9UOHE=4],Z +MW\2NJ6F=;V+7U+3.-[%K:EKGF]@U-:WS3>R:FM;Y)G9-3>M\$[NFIG6^B5U3 +MTSK?Q*ZI:9UO8M?4M,XWL6MJ6N>;V#4UK?--[)J:UODF=DU-ZWP3NZ:F=;Z) +M75.QSK>Q:RK6^39V39U,[9HZF=HU=3*U:^ID:M=45Y:&=DUUIG9-=:9V376F +M=DUUIG9-=:9V376F=DUUIG9-=:9V376F=DUUIG9-=:9V376F=DUUIG9-=:9V +M376F=DV=R]+0KJFSJ5U39U.[ILZF=DV=3>V:.IO:-74VM6OJ;&K7U-G4KJFS +MJ5U39U.[ILZF=DV=C>V:71E>U@:_L?<4?@_L:?F=L'7X[9]U^/W6UP"_NW?N +MZW>W5?T]GZ^[^$W6+SY?MZF3+P-VRU*TVGU8NO+\5'7.PGWI?"M<;]7N"C<< +MA5LW-Y,KG'L&]S/!63\LV2X#0O;]9ZWH.3)[B_/(=[:O?Y +MNZTJGNJOG*ZX>KHIP0UC^-78QZ?WS34X9_JHR'P4;NJ+P3\G4LSC/ESUQ4/\ +G_X]*OP"N_H#+_^^_X+]G;/];`34"FIU0_7NC++_Z'WN7IO#-7P`` +` +end diff --git a/usr.bin/mkimg/tests/mkimg.sh b/usr.bin/mkimg/tests/mkimg.sh new file mode 100755 index 000000000000..8dfb74c40d04 --- /dev/null +++ b/usr.bin/mkimg/tests/mkimg.sh @@ -0,0 +1,164 @@ +# $FreeBSD$ + +mkimg_blksz_list="512 4096" +mkimg_format_list="qcow qcow2 raw vhd vhdf vmdk" +mkimg_geom_list="1x1 63x255" +mkimg_scheme_list="apm bsd ebr gpt mbr pc98 vtoc8" + +bootcode() +{ + case $1 in + bsd|pc98) echo 8192 ;; + gpt|mbr) echo 512 ;; + *) echo 0 ;; + esac + return 0 +} + +mkcontents() +{ + local byte count name + + byte=$1 + count=$2 + + name=_tmp-$byte-$count.bin + jot -b $byte $(($count/2)) > $name + echo $name + return 0 +} + +makeimage() +{ + local blksz bootarg bootsz format geom nhds nsecs partarg pfx scheme + + format=$1 + scheme=$2 + blksz=$3 + geom=$4 + pfx=$5 + shift 5 + + nsecs=${geom%x*} + nhds=${geom#*x} + + bootsz=`bootcode $scheme` + if test $bootsz -gt 0; then + bootarg="-b `mkcontents B $bootsz`" + else + bootarg="" + fi + + partarg="" + for P in $*; do + partarg="$partarg -p $P" + done + if test -z "$partarg"; then + local swap ufs + swap="-p freebsd-swap::128K" + ufs="-p freebsd-ufs:=`mkcontents P 4194304`" + partarg="$ufs $swap" + fi + + imagename=$pfx-$geom-$blksz-$scheme.$format + + mkimg -y -f $format -o $imagename -s $scheme -P $blksz -H $nhds -T $nsecs \ + $bootarg $partarg + echo $imagename + return 0 +} + +mkimg_rebase() +{ + local baseline image result tmpfile update + + image=$1 + result=$2 + + baseline=$image.gz.uu + update=yes + + if test -f $baseline; then + tmpfile=_tmp-baseline + uudecode -p $baseline | gunzip -c > $tmpfile + if cmp -s $tmpfile $result; then + update=no + fi + fi + + if test $update = yes; then + # Prevent keyword expansion when writing the keyword. + (echo -n '# $'; echo -n FreeBSD; echo '$') > $baseline + gzip -c $result | uuencode $image.gz >> $baseline + fi + + rm $image $result _tmp-* + return 0 +} + +mkimg_test() +{ + local blksz format geom scheme + + geom=$1 + blksz=$2 + scheme=$3 + format=$4 + + case $scheme in + ebr|mbr|pc98) + bsd=`makeimage raw bsd $blksz $geom _tmp` + partinfo="freebsd:=$bsd" + ;; + *) + partinfo="" + ;; + esac + image=`makeimage $format $scheme $blksz $geom img $partinfo` + result=$image.out + hexdump -C $image > $result + if test "x$mkimg_update_baseline" = "xyes"; then + mkimg_rebase $image $result + else + baseline=`atf_get_srcdir`/$image + atf_check -s exit:0 cmp -s $baseline $result + fi + return 0 +} + +atf_test_case rebase +rebase_body() +{ + local nm + + mkimg_update_baseline=yes + for nm in $mkimg_tests; do + ${nm}_body + done + return 0 +} + +atf_init_test_cases() +{ + local B F G S nm + + for G in $mkimg_geom_list; do + for B in $mkimg_blksz_list; do + for S in $mkimg_scheme_list; do + for F in $mkimg_format_list; do + nm="${S}_${G}_${B}_${F}" + atf_test_case $nm + eval "${nm}_body() { mkimg_test $G $B $S $F; }" + mkimg_tests="${mkimg_tests} ${nm}" + atf_add_test_case $nm + done + done + done + done + + # XXX hack to make updating the baseline easier + if test "${__RUNNING_INSIDE_ATF_RUN}" != "internal-yes-value"; then + atf_add_test_case rebase + fi +} + diff --git a/usr.bin/mkimg/vhd.c b/usr.bin/mkimg/vhd.c index af3d95eaccd7..6b9d6a087d61 100644 --- a/usr.bin/mkimg/vhd.c +++ b/usr.bin/mkimg/vhd.c @@ -64,7 +64,7 @@ __FBSDID("$FreeBSD$"); struct vhd_footer { uint64_t cookie; -#define VHD_FOOTER_COOKIE 0x636f6e6563746978 +#define VHD_FOOTER_COOKIE 0x636f6e6563746978ULL uint32_t features; #define VHD_FEATURES_TEMPORARY 0x01 #define VHD_FEATURES_RESERVED 0x02 @@ -236,7 +236,7 @@ vhd_resize(lba_t imgsz) struct vhd_dyn_header { uint64_t cookie; -#define VHD_HEADER_COOKIE 0x6378737061727365 +#define VHD_HEADER_COOKIE 0x6378737061727365ULL uint64_t data_offset; uint64_t table_offset; uint32_t version; diff --git a/usr.bin/mkimg/vtoc8.c b/usr.bin/mkimg/vtoc8.c index 8eb7d24080bd..2f5cf0f706e3 100644 --- a/usr.bin/mkimg/vtoc8.c +++ b/usr.bin/mkimg/vtoc8.c @@ -53,13 +53,12 @@ static struct mkimg_alias vtoc8_aliases[] = { { ALIAS_NONE, 0 } }; -static u_int -vtoc8_metadata(u_int where) +static lba_t +vtoc8_metadata(u_int where, lba_t blk) { - u_int secs; - secs = (where == SCHEME_META_IMG_START) ? nsecs * nheads : 0; - return (secs); + blk += (where == SCHEME_META_IMG_START) ? 1 : 0; + return (round_cylinder(blk)); } static int @@ -87,10 +86,6 @@ vtoc8_write(lba_t imgsz, void *bootcode __unused) be16enc(&vtoc8.nsecs, nsecs); be16enc(&vtoc8.magic, VTOC_MAGIC); - error = image_set_size(imgsz); - if (error) - return (error); - be32enc(&vtoc8.map[VTOC_RAW_PART].nblks, imgsz); STAILQ_FOREACH(part, &partlist, link) { n = part->index + ((part->index >= VTOC_RAW_PART) ? 1 : 0); diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index a44ff3ebf44f..96fdcaf6f7e3 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -346,7 +346,7 @@ static const char *srcrule_str[] = { "public/temporary address", "alive interface", "better virtual status", - "rule #10", + "preferred source", "rule #11", "rule #12", "rule #13", diff --git a/usr.bin/rctl/rctl.8 b/usr.bin/rctl/rctl.8 index f7afee99aede..3f72b9122171 100644 --- a/usr.bin/rctl/rctl.8 +++ b/usr.bin/rctl/rctl.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 16, 2014 +.Dd September 11, 2014 .Dt RCTL 8 .Os .Sh NAME @@ -209,7 +209,7 @@ resource would be .Bl -column -offset 3n "pseudoterminals" .It Em action .It Sy deny Ta deny the allocation; not supported for -.Sy cpu +.Sy cputime and .Sy wallclock .It Sy log Ta "log a warning to the console" diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index d811a868bc6c..372c661d40ee 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -897,7 +897,7 @@ fix_obsolete_keys(int *argc, char **argv) } } } - sprintf(sopt, "-k%d.%d", f1, c1); + sprintf(sopt, "-k%d.%d%s", f1, c1, sopts1); argv[i] = sort_strdup(sopt); } } diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c index 4cfe01c4d616..35e575631a1b 100644 --- a/usr.bin/systat/ifstat.c +++ b/usr.bin/systat/ifstat.c @@ -68,14 +68,14 @@ struct if_stat { struct ifmibdata if_mib; struct timeval tv; struct timeval tv_lastchanged; - u_long if_in_curtraffic; - u_long if_out_curtraffic; - u_long if_in_traffic_peak; - u_long if_out_traffic_peak; - u_long if_in_curpps; - u_long if_out_curpps; - u_long if_in_pps_peak; - u_long if_out_pps_peak; + uint64_t if_in_curtraffic; + uint64_t if_out_curtraffic; + uint64_t if_in_traffic_peak; + uint64_t if_out_traffic_peak; + uint64_t if_in_curpps; + uint64_t if_out_curpps; + uint64_t if_in_pps_peak; + uint64_t if_out_pps_peak; u_int if_row; /* Index into ifmib sysctl */ int if_ypos; /* -1 if not being displayed */ u_int display; @@ -269,8 +269,8 @@ fetchifstat(void) struct if_stat *ifp = NULL; struct timeval tv, new_tv, old_tv; double elapsed = 0.0; - u_int new_inb, new_outb, old_inb, old_outb = 0; - u_int new_inp, new_outp, old_inp, old_outp = 0; + uint64_t new_inb, new_outb, old_inb, old_outb = 0; + uint64_t new_inp, new_outp, old_inp, old_outp = 0; SLIST_FOREACH(ifp, &curlist, link) { /* diff --git a/usr.bin/truss/arm-fbsd.c b/usr.bin/truss/arm-fbsd.c index b71761986f8a..3bac40095c7c 100644 --- a/usr.bin/truss/arm-fbsd.c +++ b/usr.bin/truss/arm-fbsd.c @@ -201,7 +201,7 @@ arm_syscall_entry(struct trussinfo *trussinfo, int nargs) */ // XXX BAD constant used here iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.r[_REG_SP] + + iorequest.piod_offs = (void *)(regs.r_sp + 4 * sizeof(uint32_t)); iorequest.piod_addr = &fsc->args[4]; iorequest.piod_len = (nargs - 4) * sizeof(fsc->args[0]); @@ -316,7 +316,7 @@ arm_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) } retval = regs.r[0]; - errorp = !!(regs.r_cpsr & PSR_C_bit); + errorp = !!(regs.r_cpsr & PSR_C); /* * This code, while simpler than the initial versions I used, could diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 227f3c26adc2..669ac3fba095 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -657,6 +657,8 @@ dovmstat(unsigned int interval, int reps) uptime = getuptime(); halfuptime = uptime / 2; rate_adj = 1; + ncpus = 1; + maxid = 0; /* * If the user stops the program (control-Z) and then resumes it, @@ -702,7 +704,7 @@ dovmstat(unsigned int interval, int reps) } for (hdrcnt = 1;;) { if (!--hdrcnt) - printhdr(ncpus, cpumask); + printhdr(maxid, cpumask); if (kd != NULL) { if (kvm_getcptime(kd, cur.cp_time) < 0) errx(1, "kvm_getcptime: %s", kvm_geterr(kd)); @@ -753,7 +755,7 @@ dovmstat(unsigned int interval, int reps) errx(1, "%s", devstat_errbuf); break; case 1: - printhdr(ncpus, cpumask); + printhdr(maxid, cpumask); break; default: break; @@ -822,7 +824,7 @@ dovmstat(unsigned int interval, int reps) } static void -printhdr(int ncpus, u_long cpumask) +printhdr(int maxid, u_long cpumask) { int i, num_shown; @@ -834,7 +836,7 @@ printhdr(int ncpus, u_long cpumask) (void)printf("disk"); (void)printf(" faults "); if (Pflag) { - for (i = 0; i < ncpus; i++) { + for (i = 0; i <= maxid; i++) { if (cpumask & (1ul << i)) printf("cpu%-2d ", i); } @@ -850,8 +852,10 @@ printhdr(int ncpus, u_long cpumask) dev_select[i].unit_number); (void)printf(" in sy cs"); if (Pflag) { - for (i = 0; i < ncpus; i++) - printf(" us sy id"); + for (i = 0; i <= maxid; i++) { + if (cpumask & (1ul << i)) + printf(" us sy id"); + } printf("\n"); } else printf(" us sy id\n"); diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index f40cdc5e7870..b59db70bf99d 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1263,13 +1263,18 @@ install_dir(char *path) if (!*p || (p != path && *p == '/')) { ch = *p; *p = '\0'; - if (stat(path, &sb)) { - if (errno != ENOENT || mkdir(path, 0755) < 0) { +again: + if (stat(path, &sb) < 0) { + if (errno != ENOENT) + err(EX_OSERR, "stat %s", path); + if (mkdir(path, 0755) < 0) { + if (errno == EEXIST) + goto again; err(EX_OSERR, "mkdir %s", path); - /* NOTREACHED */ - } else if (verbose) + } + if (verbose) (void)printf("install: mkdir %s\n", - path); + path); } else if (!S_ISDIR(sb.st_mode)) errx(EX_OSERR, "%s exists but is not a directory", path); if (!(*p = ch)) diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index f4c51d2e7a60..b0cff950bf2b 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -26,7 +26,6 @@ SUBDIR= adduser \ digictl \ diskinfo \ dumpcis \ - etcupdate \ extattr \ extattrctl \ fifolog \ @@ -278,6 +277,10 @@ SUBDIR+= repquota SUBDIR+= rwhod .endif +.if ${MK_RCS} != "no" +SUBDIR+= etcupdate +.endif + .if ${MK_SENDMAIL} != "no" SUBDIR+= editmap SUBDIR+= mailstats diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64 index b82162580bbc..2d1a3e8daadd 100644 --- a/usr.sbin/Makefile.amd64 +++ b/usr.sbin/Makefile.amd64 @@ -18,6 +18,9 @@ SUBDIR+= boot0cfg SUBDIR+= btxld .endif SUBDIR+= cpucontrol +.if ${MK_HYPERV} != "no" +SUBDIR+= hyperv +.endif SUBDIR+= kgmon SUBDIR+= lptcontrol SUBDIR+= mount_smbfs diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386 index 7d66f783f28a..de7bb464f581 100644 --- a/usr.sbin/Makefile.i386 +++ b/usr.sbin/Makefile.i386 @@ -9,6 +9,9 @@ SUBDIR+= asf SUBDIR+= btxld .endif SUBDIR+= cpucontrol +.if ${MK_HYPERV} != "no" +SUBDIR+= hyperv +.endif SUBDIR+= kgmon SUBDIR+= kgzip SUBDIR+= lptcontrol diff --git a/usr.sbin/acpi/acpiconf/Makefile b/usr.sbin/acpi/acpiconf/Makefile index 5f862a2c621e..0bbadc1e8fb9 100644 --- a/usr.sbin/acpi/acpiconf/Makefile +++ b/usr.sbin/acpi/acpiconf/Makefile @@ -3,5 +3,6 @@ PROG= acpiconf MAN= acpiconf.8 +WARNS?= 3 .include diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile index c08c70b41b62..15d114d7892e 100644 --- a/usr.sbin/acpi/acpidb/Makefile +++ b/usr.sbin/acpi/acpidb/Makefile @@ -3,10 +3,13 @@ PROG= acpidb SRCS= acpidb.c +# common +SRCS+= acgetline.c ahids.c ahuuids.c cmfsize.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 + dbtest.c dbutils.c dbxface.c # components/disassembler SRCS+= dmbuffer.c dmdeferred.c dmnames.c dmobject.c dmopcode.c \ @@ -46,26 +49,27 @@ 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 tbprint.c tbutils.c \ - tbxface.c tbxfload.c +SRCS+= tbdata.c tbfadt.c tbfind.c tbinstal.c tbprint.c \ + tbutils.c tbxface.c tbxfload.c # components/utilities SRCS+= utaddress.c utalloc.c utbuffer.c utcache.c utcopy.c \ utdebug.c utdecode.c utdelete.c uterror.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 \ + utexcep.c utfileio.c utglobal.c uthex.c utids.c \ + utinit.c utlock.c utmath.c utmisc.c utmutex.c \ + utobject.c utosi.c utownerid.c utpredef.c utprint.c \ + utresrc.c utstate.c utstring.c uttrack.c utuuid.c \ utxface.c utxferror.c utxfinit.c +# os_specific/service_layers +SRCS+= oslibcfs.c osunixxf.c + MAN= acpidb.8 WARNS?= 3 diff --git a/usr.sbin/acpi/acpidb/acpidb.c b/usr.sbin/acpi/acpidb/acpidb.c index 3cd8d3fc7456..3688cafd70cd 100644 --- a/usr.sbin/acpi/acpidb/acpidb.c +++ b/usr.sbin/acpi/acpidb/acpidb.c @@ -45,6 +45,7 @@ #include #include #include +#include /* * Dummy DSDT Table Header @@ -89,9 +90,9 @@ static UINT64 aml_simulate_prompt(char *msg, UINT64 def_val); static void aml_simulation_regload(const char *dumpfile); static void aml_simulation_regdump(const char *dumpfile); -/* Stubs to simplify linkage to the ACPI CA core subsystem. */ +/* Stubs to simplify linkage to the ACPICA core subsystem. */ ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer(void) +AcpiOsGetRootPointer(void) { return (0); @@ -102,6 +103,18 @@ AeTableOverride(ACPI_TABLE_HEADER *ExistingTable, ACPI_TABLE_HEADER **NewTable) { } +void +MpSaveGpioInfo(ACPI_PARSE_OBJECT *Op, AML_RESOURCE *Resource, + UINT32 PinCount, UINT16 *PinList, char *DeviceName) +{ +} + +void +MpSaveSerialInfo(ACPI_PARSE_OBJECT *Op, AML_RESOURCE *Resource, + char *DeviceName) +{ +} + static void aml_simulation_init(void) { diff --git a/usr.sbin/acpi/acpidump/Makefile b/usr.sbin/acpi/acpidump/Makefile index e00450091222..e258f8e34f05 100644 --- a/usr.sbin/acpi/acpidump/Makefile +++ b/usr.sbin/acpi/acpidump/Makefile @@ -3,5 +3,6 @@ PROG= acpidump MAN= acpidump.8 SRCS= acpi.c acpi_user.c acpidump.c +WARNS?= 3 .include diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 66cd7bd0087d..ae7ebf2b8931 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -934,10 +934,10 @@ acpi_handle_dmar_remapping_structure(void *addr, int remaining) case ACPI_DMAR_TYPE_RESERVED_MEMORY: acpi_handle_dmar_rmrr(addr); break; - case ACPI_DMAR_TYPE_ATSR: + case ACPI_DMAR_TYPE_ROOT_ATS: acpi_handle_dmar_atsr(addr); break; - case ACPI_DMAR_HARDWARE_AFFINITY: + case ACPI_DMAR_TYPE_HARDWARE_AFFINITY: acpi_handle_dmar_rhsa(addr); break; default: diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile index 161b2f412348..8f021a3d7e7a 100644 --- a/usr.sbin/acpi/iasl/Makefile +++ b/usr.sbin/acpi/iasl/Makefile @@ -1,29 +1,31 @@ # $FreeBSD$ PROG= iasl -SRCS= adfile.c adisasm.c adwalk.c # common -SRCS+= ahpredef.c dmextern.c dmrestag.c dmtable.c dmtbdump.c \ - dmtbinfo.c getopt.c +SRCS= adfile.c adisasm.c adwalk.c ahids.c ahpredef.c \ + ahuuids.c cmfsize.c dmextern.c dmrestag.c dmtable.c \ + dmtbdump.c dmtbinfo.c getopt.c # compiler -SRCS+= aslanalyze.c aslbtypes.c aslcodegen.c aslcompile.c \ - aslcompiler.y.h aslcompilerlex.c aslcompilerparse.c \ - aslerror.c aslfileio.c aslfiles.c aslfold.c aslhex.c \ - asllength.c asllisting.c asllistsup.c aslload.c \ - asllookup.c aslmain.c aslmap.c aslmethod.c aslnamesp.c \ - asloffset.c aslopcodes.c asloperands.c aslopt.c \ - asloptions.c aslpredef.c aslprepkg.c aslresource.c \ - aslrestype1.c aslrestype1i.c aslrestype2.c \ - aslrestype2d.c aslrestype2e.c aslrestype2q.c \ - aslrestype2s.c aslrestype2w.c aslstartup.c aslstubs.c \ - asltransform.c asltree.c aslutils.c asluuid.c \ - aslwalks.c aslxref.c dtcompile.c dtexpress.c dtfield.c \ - dtio.c dtparser.y.h dtparserlex.c dtparserparse.c \ - dtsubtable.c dttable.c dttemplate.c dtutils.c \ - prexpress.c prmacros.c prparser.y.h prparserlex.c \ - prparserparse.c prscan.c prutils.c +SRCS+= aslanalyze.c aslascii.c aslbtypes.c aslcodegen.c \ + aslcompile.c aslcompiler.y.h aslcompilerlex.c \ + aslcompilerparse.c aslerror.c aslfileio.c aslfiles.c \ + aslfold.c aslhex.c asllength.c asllisting.c \ + asllistsup.c aslload.c asllookup.c aslmain.c aslmap.c \ + aslmapenter.c aslmapoutput.c aslmaputils.c \ + aslmessages.c aslmethod.c aslnamesp.c asloffset.c \ + aslopcodes.c asloperands.c aslopt.c asloptions.c \ + aslpredef.c aslprepkg.c aslresource.c aslrestype1.c \ + aslrestype1i.c aslrestype2.c aslrestype2d.c \ + aslrestype2e.c aslrestype2q.c aslrestype2s.c \ + aslrestype2w.c aslstartup.c aslstubs.c asltransform.c \ + asltree.c aslutils.c asluuid.c aslwalks.c aslxref.c \ + dtcompile.c dtexpress.c dtfield.c dtio.c dtparser.y.h \ + dtparserlex.c dtparserparse.c dtsubtable.c dttable.c \ + dttemplate.c dtutils.c prexpress.c prmacros.c \ + prparser.y.h prparserlex.c prparserparse.c prscan.c \ + prutils.c # components/debugger SRCS+= dbfileio.c @@ -52,17 +54,19 @@ SRCS+= nsaccess.c nsalloc.c nsdump.c nsnames.c nsobject.c \ nsparse.c nssearch.c nsutils.c nswalk.c # components/tables -SRCS+= tbfadt.c tbinstal.c tbprint.c tbutils.c tbxface.c +SRCS+= tbdata.c tbfadt.c tbinstal.c tbprint.c tbutils.c \ + tbxface.c # components/utilities SRCS+= utaddress.c utalloc.c utbuffer.c utcache.c utcopy.c \ utdebug.c utdecode.c utdelete.c uterror.c utexcep.c \ - utglobal.c utinit.c utlock.c utmath.c utmisc.c \ - utmutex.c utobject.c utownerid.c utpredef.c utresrc.c \ - utstate.c utstring.c utxface.c utxferror.c + utfileio.c utglobal.c uthex.c utinit.c utlock.c \ + utmath.c utmisc.c utmutex.c utobject.c utownerid.c \ + utpredef.c utprint.c utresrc.c utstate.c utstring.c \ + utuuid.c utxface.c utxferror.c # os_specific/service_layers -SRCS+= osunixxf.c +SRCS+= oslibcfs.c osunixxf.c WARNS?= 2 @@ -72,15 +76,20 @@ CFLAGS+= -DACPI_ASL_COMPILER -I. LFLAGS= -i -s YFLAGS= -d -CLEANFILES= aslcompiler.y.h aslcompilerlex.c aslcompilerparse.c \ - aslcompilerparse.h dtparser.y.h dtparserlex.c \ - dtparserparse.c dtparserparse.h prparser.y.h \ - prparserlex.c prparserparse.c prparserparse.h +CLEANFILES= aslcompiler.y aslcompiler.y.h aslcompilerlex.c \ + aslcompilerparse.c aslcompilerparse.h dtparser.y.h \ + dtparserlex.c dtparserparse.c dtparserparse.h \ + prparser.y.h prparserlex.c prparserparse.c \ + prparserparse.h aslcompilerlex.c: aslcompiler.l aslsupport.l ${LEX} ${LFLAGS} -PAslCompiler -o${.TARGET} \ ${ACPICA_DIR}/compiler/aslcompiler.l +aslcompiler.y: aslparser.y aslrules.y aslsupport.y asltokens.y asltypes.y + m4 -P -I${ACPICA_DIR}/compiler \ + ${ACPICA_DIR}/compiler/aslparser.y > ${.TARGET} + .ORDER: aslcompilerparse.c aslcompilerparse.h aslcompilerparse.c aslcompilerparse.h: aslcompiler.y ${YACC} ${YFLAGS} -pAslCompiler -oaslcompilerparse.c ${.ALLSRC} diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index 1d1117c2ba8e..cefbcc8b3104 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -673,11 +673,21 @@ node_find(struct node *node, const char *path) { struct node *child, *found; char *tmp; + size_t tmplen; //log_debugx("looking up %s in %s", path, node->n_key); tmp = node_path(node); - if (strncmp(tmp, path, strlen(tmp)) != 0) { + tmplen = strlen(tmp); + if (strncmp(tmp, path, tmplen) != 0) { + free(tmp); + return (NULL); + } + if (path[tmplen] != '/' && path[tmplen] != '\0') { + /* + * If we have two map entries like 'foo' and 'foobar', make + * sure the search for 'foobar' won't match 'foo' instead. + */ free(tmp); return (NULL); } diff --git a/usr.sbin/autofs/token.l b/usr.sbin/autofs/token.l index 8224042114d8..5062a137a23a 100644 --- a/usr.sbin/autofs/token.l +++ b/usr.sbin/autofs/token.l @@ -48,6 +48,7 @@ extern int yylex(void); %option noyywrap %% +\"[^"]+\" { yytext++; yytext[strlen(yytext) - 1] = '\0'; return STR; }; [a-zA-Z0-9\.\+-_/\:\[\]$&{}]+ { return STR; } #.*\n { lineno++; return NEWLINE; }; \\\n { lineno++; }; diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 5dea3001de22..b955eccecec6 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -430,7 +430,10 @@ basl_fwrite_fadt(FILE *fp) EFPRINTF(fp, "\n"); EFPRINTF(fp, "[0001]\t\tValue to cause reset : 06\n"); - EFPRINTF(fp, "[0003]\t\tReserved : 000000\n"); + EFPRINTF(fp, "[0002]\t\tARM Flags (decoded below): 0000\n"); + EFPRINTF(fp, "\t\t\tPSCI Compliant : 0\n"); + EFPRINTF(fp, "\t\t\tMust use HVC for PSCI : 0\n"); + EFPRINTF(fp, "[0001]\t\tFADT Minor Revision : 01\n"); EFPRINTF(fp, "[0008]\t\tFACS Address : 00000000%08X\n", basl_acpi_base + FACS_OFFSET); EFPRINTF(fp, "[0008]\t\tDSDT Address : 00000000%08X\n", diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8 index 114aaf162533..755fa3356b34 100644 --- a/usr.sbin/bhyve/bhyve.8 +++ b/usr.sbin/bhyve/bhyve.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 26, 2014 +.Dd September 17, 2014 .Dt BHYVE 8 .Os .Sh NAME @@ -43,7 +43,7 @@ .Ar vmname .Sh DESCRIPTION .Nm -is an experimental hypervisor that runs guest operating systems inside a +is a hypervisor that runs guest operating systems inside a virtual machine. .Pp Parameters such as the number of virtual CPUs, amount of guest memory, and diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 7dcf6d016b87..b2b36bb17478 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -803,6 +803,12 @@ main(int argc, char *argv[]) exit(1); } + error = init_msr(); + if (error) { + fprintf(stderr, "init_msr error %d", error); + exit(1); + } + init_mem(); init_inout(); pci_irq_init(ctx); diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c index 1ec0344f3fca..b03822807d4b 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -278,6 +278,7 @@ blockif_open(const char *optstr, const char *ident) bc->bc_magic = BLOCKIF_SIG; bc->bc_fd = fd; + bc->bc_rdonly = ro; bc->bc_size = size; bc->bc_sectsz = sectsz; pthread_mutex_init(&bc->bc_mtx, NULL); diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c index cf1c65557015..394b116b3028 100644 --- a/usr.sbin/bhyve/pci_virtio_block.c +++ b/usr.sbin/bhyve/pci_virtio_block.c @@ -133,6 +133,7 @@ static struct virtio_consts vtblk_vi_consts = { pci_vtblk_notify, /* device-wide qnotify */ pci_vtblk_cfgread, /* read PCI config */ pci_vtblk_cfgwrite, /* write PCI config */ + NULL, /* apply negotiated features */ VTBLK_S_HOSTCAPS, /* our capabilities */ }; diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index c3b8690bb6e0..5ac9ecd45d11 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -135,11 +135,14 @@ struct pci_vtnet_softc { int vsc_rx_ready; volatile int resetting; /* set and checked outside lock */ - uint32_t vsc_features; + uint64_t vsc_features; /* negotiated features */ + struct virtio_net_config vsc_config; pthread_mutex_t rx_mtx; int rx_in_progress; + int rx_vhdrlen; + int rx_merge; /* merged rx bufs in use */ pthread_t tx_tid; pthread_mutex_t tx_mtx; @@ -151,6 +154,7 @@ static void pci_vtnet_reset(void *); /* static void pci_vtnet_notify(void *, struct vqueue_info *); */ static int pci_vtnet_cfgread(void *, int, int, uint32_t *); static int pci_vtnet_cfgwrite(void *, int, int, uint32_t); +static void pci_vtnet_neg_features(void *, uint64_t); static struct virtio_consts vtnet_vi_consts = { "vtnet", /* our name */ @@ -160,6 +164,7 @@ static struct virtio_consts vtnet_vi_consts = { NULL, /* device-wide qnotify -- not used */ pci_vtnet_cfgread, /* read PCI config */ pci_vtnet_cfgwrite, /* write PCI config */ + pci_vtnet_neg_features, /* apply negotiated features */ VTNET_S_HOSTCAPS, /* our capabilities */ }; @@ -212,6 +217,8 @@ pci_vtnet_reset(void *vsc) pci_vtnet_rxwait(sc); sc->vsc_rx_ready = 0; + sc->rx_merge = 1; + sc->rx_vhdrlen = sizeof(struct virtio_net_rxhdr); /* now reset rings, MSI-X vectors, and negotiated capabilities */ vi_reset_dev(&sc->vsc_vs); @@ -253,14 +260,34 @@ pci_vtnet_tap_tx(struct pci_vtnet_softc *sc, struct iovec *iov, int iovcnt, */ static uint8_t dummybuf[2048]; +static __inline struct iovec * +rx_iov_trim(struct iovec *iov, int *niov, int tlen) +{ + struct iovec *riov; + + /* XXX short-cut: assume first segment is >= tlen */ + assert(iov[0].iov_len >= tlen); + + iov[0].iov_len -= tlen; + if (iov[0].iov_len == 0) { + assert(*niov > 1); + *niov -= 1; + riov = &iov[1]; + } else { + iov[0].iov_base = (void *)((uintptr_t)iov[0].iov_base + tlen); + riov = &iov[0]; + } + + return (riov); +} + static void pci_vtnet_tap_rx(struct pci_vtnet_softc *sc) { + struct iovec iov[VTNET_MAXSEGS], *riov; struct vqueue_info *vq; - struct virtio_net_rxhdr *vrx; - uint8_t *buf; - int len; - struct iovec iov; + void *vrx; + int len, n; /* * Should never be called without a valid tap fd @@ -296,21 +323,19 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc *sc) do { /* - * Get descriptor chain, which should have just - * one descriptor in it. - * ??? allow guests to use multiple descs? + * Get descriptor chain. */ - assert(vq_getchain(vq, &iov, 1, NULL) == 1); + n = vq_getchain(vq, iov, VTNET_MAXSEGS, NULL); + assert(n >= 1 && n <= VTNET_MAXSEGS); /* * Get a pointer to the rx header, and use the * data immediately following it for the packet buffer. */ - vrx = iov.iov_base; - buf = (uint8_t *)(vrx + 1); + vrx = iov[0].iov_base; + riov = rx_iov_trim(iov, &n, sc->rx_vhdrlen); - len = read(sc->vsc_tapfd, buf, - iov.iov_len - sizeof(struct virtio_net_rxhdr)); + len = readv(sc->vsc_tapfd, riov, n); if (len < 0 && errno == EWOULDBLOCK) { /* @@ -323,16 +348,21 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc *sc) /* * The only valid field in the rx packet header is the - * number of buffers, which is always 1 without TSO - * support. + * number of buffers if merged rx bufs were negotiated. */ - memset(vrx, 0, sizeof(struct virtio_net_rxhdr)); - vrx->vrh_bufs = 1; + memset(vrx, 0, sc->rx_vhdrlen); + + if (sc->rx_merge) { + struct virtio_net_rxhdr *vrxh; + + vrxh = vrx; + vrxh->vrh_bufs = 1; + } /* * Release this chain and handle more chains. */ - vq_relchain(vq, len + sizeof(struct virtio_net_rxhdr)); + vq_relchain(vq, len + sc->rx_vhdrlen); } while (vq_has_descs(vq)); /* Interrupt if needed, including for NOTIFY_ON_EMPTY. */ @@ -623,6 +653,8 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) sc->resetting = 0; + sc->rx_merge = 1; + sc->rx_vhdrlen = sizeof(struct virtio_net_rxhdr); sc->rx_in_progress = 0; pthread_mutex_init(&sc->rx_mtx, NULL); @@ -656,9 +688,10 @@ pci_vtnet_cfgwrite(void *vsc, int offset, int size, uint32_t value) ptr = &sc->vsc_config.mac[offset]; memcpy(ptr, &value, size); } else { + /* silently ignore other writes */ DPRINTF(("vtnet: write to readonly reg %d\n\r", offset)); - return (1); } + return (0); } @@ -673,6 +706,20 @@ pci_vtnet_cfgread(void *vsc, int offset, int size, uint32_t *retval) return (0); } +static void +pci_vtnet_neg_features(void *vsc, uint64_t negotiated_features) +{ + struct pci_vtnet_softc *sc = vsc; + + sc->vsc_features = negotiated_features; + + if (!(sc->vsc_features & VIRTIO_NET_F_MRG_RXBUF)) { + sc->rx_merge = 0; + /* non-merge rx header is 2 bytes shorter */ + sc->rx_vhdrlen -= 2; + } +} + struct pci_devemu pci_de_vnet = { .pe_emu = "virtio-net", .pe_init = pci_vtnet_init, diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index 4d531834cbe2..0a31080114c0 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -80,6 +80,7 @@ static struct virtio_consts vtrnd_vi_consts = { pci_vtrnd_notify, /* device-wide qnotify */ NULL, /* read virtio config */ NULL, /* write virtio config */ + NULL, /* apply negotiated features */ 0, /* our capabilities */ }; diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c index 28c7eb2c74b4..59a1358bd0b0 100644 --- a/usr.sbin/bhyve/smbiostbl.c +++ b/usr.sbin/bhyve/smbiostbl.c @@ -737,7 +737,7 @@ smbios_ep_initializer(struct smbios_entry_point *smbios_ep, uint32_t staddr) smbios_ep->eplen = 0x1F; assert(sizeof (struct smbios_entry_point) == smbios_ep->eplen); smbios_ep->major = 2; - smbios_ep->minor = 4; + smbios_ep->minor = 6; smbios_ep->revision = 0; memcpy(smbios_ep->ianchor, SMBIOS_ENTRY_IANCHOR, SMBIOS_ENTRY_IANCHORLEN); diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c index 2f04b90ab44f..19c0d4710d28 100644 --- a/usr.sbin/bhyve/virtio.c +++ b/usr.sbin/bhyve/virtio.c @@ -698,6 +698,9 @@ vi_pci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, switch (offset) { case VTCFG_R_GUESTCAP: vs->vs_negotiated_caps = value & vc->vc_hv_caps; + if (vc->vc_apply_features) + (*vc->vc_apply_features)(DEV_SOFTC(vs), + vs->vs_negotiated_caps); break; case VTCFG_R_PFN: if (vs->vs_curq >= vc->vc_nvq) diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h index 1f29dfa8ef73..6f655f3f7980 100644 --- a/usr.sbin/bhyve/virtio.h +++ b/usr.sbin/bhyve/virtio.h @@ -352,6 +352,8 @@ struct virtio_consts { /* called to read config regs */ int (*vc_cfgwrite)(void *, int, int, uint32_t); /* called to write config regs */ + void (*vc_apply_features)(void *, uint64_t); + /* called to apply negotiated features */ uint64_t vc_hv_caps; /* hypervisor-provided capabilities */ }; diff --git a/usr.sbin/bhyve/xmsr.c b/usr.sbin/bhyve/xmsr.c index 63522bf023be..c0ab7c55f3bc 100644 --- a/usr.sbin/bhyve/xmsr.c +++ b/usr.sbin/bhyve/xmsr.c @@ -31,33 +31,84 @@ __FBSDID("$FreeBSD$"); #include +#include #include +#include + #include #include #include +#include #include "xmsr.h" +static int cpu_vendor_intel, cpu_vendor_amd; + int emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t val) { - switch (code) { - case 0xd04: /* Sandy Bridge uncore PMC MSRs */ - case 0xc24: - return (0); - case 0x79: - return (0); /* IA32_BIOS_UPDT_TRIG MSR */ - default: - break; + if (cpu_vendor_intel) { + switch (code) { + case 0xd04: /* Sandy Bridge uncore PMCs */ + case 0xc24: + return (0); + case MSR_BIOS_UPDT_TRIG: + return (0); + case MSR_BIOS_SIGN: + return (0); + default: + break; + } } return (-1); } int -emulate_rdmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t *val) +emulate_rdmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t *val) { + int error = 0; - return (-1); + if (cpu_vendor_intel) { + switch (num) { + case MSR_BIOS_SIGN: + case MSR_IA32_PLATFORM_ID: + case MSR_PKG_ENERGY_STATUS: + case MSR_PP0_ENERGY_STATUS: + case MSR_PP1_ENERGY_STATUS: + case MSR_DRAM_ENERGY_STATUS: + *val = 0; + break; + default: + error = -1; + break; + } + } + return (error); +} + +int +init_msr(void) +{ + int error; + u_int regs[4]; + char cpu_vendor[13]; + + do_cpuid(0, regs); + ((u_int *)&cpu_vendor)[0] = regs[1]; + ((u_int *)&cpu_vendor)[1] = regs[3]; + ((u_int *)&cpu_vendor)[2] = regs[2]; + cpu_vendor[12] = '\0'; + + error = 0; + if (strcmp(cpu_vendor, "AuthenticAMD") == 0) { + cpu_vendor_amd = 1; + } else if (strcmp(cpu_vendor, "GenuineIntel") == 0) { + cpu_vendor_intel = 1; + } else { + fprintf(stderr, "Unknown cpu vendor \"%s\"\n", cpu_vendor); + error = -1; + } + return (error); } diff --git a/usr.sbin/bhyve/xmsr.h b/usr.sbin/bhyve/xmsr.h index b097cf885357..bcf65b712736 100644 --- a/usr.sbin/bhyve/xmsr.h +++ b/usr.sbin/bhyve/xmsr.h @@ -29,6 +29,7 @@ #ifndef _XMSR_H_ #define _XMSR_H_ +int init_msr(void); int emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t val); int emulate_rdmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t *val); diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index b6006b72a767..f5e50d35b219 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -309,7 +309,7 @@ dump_vmcs_msr_bitmap(int vcpu, u_long addr) if (fd < 0) goto done; - bitmap = mmap(NULL, PAGE_SIZE, PROT_READ, 0, fd, addr); + bitmap = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, addr); if (bitmap == MAP_FAILED) goto done; diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin/bsdinstall/distextract/distextract.c index a35dbd606c19..54e0171cfe90 100644 --- a/usr.sbin/bsdinstall/distextract/distextract.c +++ b/usr.sbin/bsdinstall/distextract/distextract.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2011 Nathan Whitehorn + * Copyright (c) 2014 Devin Teske * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,114 +23,199 @@ * LIABILITY, OR 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 +__FBSDID("$FreeBSD$"); + #include -#include +#include +#include +#include +#include #include #include -#include -#include +#include +#include +#include +#include -static int extract_files(int nfiles, const char **files); +/* Data to process */ +static char *distdir = NULL; +struct file_node { + char *path; + char *name; + int length; + struct file_node *next; +}; +static struct file_node *dists = NULL; + +/* Function prototypes */ +static int count_files(const char *file); +static int extract_files(int nfiles, struct file_node *files); + +#if __FreeBSD_version <= 1000008 /* r232154: bump for libarchive update */ +#define archive_read_support_filter_all(x) \ + archive_read_support_compression_all(x) +#endif + +#define _errx(...) (end_dialog(), errx(__VA_ARGS__)) int main(void) { - char *diststring; - const char **dists; - int i, retval, ndists = 0; + char *chrootdir; + char *distributions; + int ndists = 0; + int retval; + size_t file_node_size = sizeof(struct file_node); + size_t span; + struct file_node *dist = dists; + char error[PATH_MAX + 512]; - if (getenv("DISTRIBUTIONS") == NULL) { - fprintf(stderr, "DISTRIBUTIONS variable is not set\n"); - return (1); - } - - diststring = strdup(getenv("DISTRIBUTIONS")); - for (i = 0; diststring[i] != 0; i++) - if (isspace(diststring[i]) && !isspace(diststring[i+1])) - ndists++; - ndists++; /* Last one */ - - dists = calloc(ndists, sizeof(const char *)); - if (dists == NULL) { - fprintf(stderr, "Out of memory!\n"); - free(diststring); - return (1); - } - - for (i = 0; i < ndists; i++) - dists[i] = strsep(&diststring, " \t"); + if ((distributions = getenv("DISTRIBUTIONS")) == NULL) + errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set"); + if ((distdir = getenv("BSDINSTALL_DISTDIR")) == NULL) + distdir = __DECONST(char *, ""); + /* Initialize dialog(3) */ init_dialog(stdin, stdout); dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); dlg_put_backtitle(); - if (chdir(getenv("BSDINSTALL_CHROOT")) != 0) { - char error[512]; - sprintf(error, "Could could change to directory %s: %s\n", - getenv("BSDINSTALL_DISTDIR"), strerror(errno)); + dialog_msgbox("", + "Checking distribution archives.\nPlease wait...", 4, 35, FALSE); + + /* + * Parse $DISTRIBUTIONS into linked-list + */ + while (*distributions != '\0') { + span = strcspn(distributions, "\t\n\v\f\r "); + if (span < 1) { /* currently on whitespace */ + distributions++; + continue; + } + ndists++; + + /* Allocate a new struct for the distribution */ + if (dist == NULL) { + if ((dist = calloc(1, file_node_size)) == NULL) + _errx(EXIT_FAILURE, "Out of memory!"); + dists = dist; + } else { + dist->next = calloc(1, file_node_size); + if (dist->next == NULL) + _errx(EXIT_FAILURE, "Out of memory!"); + dist = dist->next; + } + + /* Set path */ + if ((dist->path = malloc(span + 1)) == NULL) + _errx(EXIT_FAILURE, "Out of memory!"); + snprintf(dist->path, span + 1, "%s", distributions); + dist->path[span] = '\0'; + + /* Set display name */ + dist->name = strrchr(dist->path, '/'); + if (dist->name == NULL) + dist->name = dist->path; + + /* Set initial length in files (-1 == error) */ + dist->length = count_files(dist->path); + if (dist->length < 0) { + end_dialog(); + return (EXIT_FAILURE); + } + + distributions += span; + } + + /* Optionally chdir(2) into $BSDINSTALL_CHROOT */ + chrootdir = getenv("BSDINSTALL_CHROOT"); + if (chrootdir != NULL && chdir(chrootdir) != 0) { + snprintf(error, sizeof(error), + "Could not change to directory %s: %s\n", + chrootdir, strerror(errno)); dialog_msgbox("Error", error, 0, 0, TRUE); end_dialog(); - return (1); + return (EXIT_FAILURE); } retval = extract_files(ndists, dists); end_dialog(); - free(diststring); - free(dists); + while ((dist = dists) != NULL) { + dists = dist->next; + if (dist->path != NULL) + free(dist->path); + free(dist); + } return (retval); } +/* + * Returns number of files in archive file. Parses $BSDINSTALL_DISTDIR/MANIFEST + * if it exists, otherwise uses archive(3) to read the archive file. + */ static int count_files(const char *file) { + static FILE *manifest = NULL; + char *p; + int file_count; + int retval; + size_t span; struct archive *archive; struct archive_entry *entry; - static FILE *manifest = NULL; - char path[MAXPATHLEN]; - char errormsg[512]; - int file_count, err; + char line[512]; + char path[PATH_MAX]; + char errormsg[PATH_MAX + 512]; if (manifest == NULL) { - sprintf(path, "%s/MANIFEST", getenv("BSDINSTALL_DISTDIR")); + snprintf(path, sizeof(path), "%s/MANIFEST", distdir); manifest = fopen(path, "r"); } if (manifest != NULL) { - char line[512]; - char *tok1, *tok2; - rewind(manifest); while (fgets(line, sizeof(line), manifest) != NULL) { - tok2 = line; - tok1 = strsep(&tok2, "\t"); - if (tok1 == NULL || strcmp(tok1, file) != 0) + p = &line[0]; + span = strcspn(p, "\t") ; + if (span < 1 || strncmp(p, file, span) != 0) continue; /* * We're at the right manifest line. The file count is * in the third element */ - tok1 = strsep(&tok2, "\t"); - tok1 = strsep(&tok2, "\t"); - if (tok1 != NULL) - return atoi(tok1); + span = strcspn(p += span + (*p != '\0' ? 1 : 0), "\t"); + span = strcspn(p += span + (*p != '\0' ? 1 : 0), "\t"); + if (span > 0) { + file_count = (int)strtol(p, (char **)NULL, 10); + if (file_count == 0 && errno == EINVAL) + continue; + return (file_count); + } } } - /* Either we didn't have a manifest, or this archive wasn't there */ - archive = archive_read_new(); + /* + * Either no manifest, or manifest didn't mention this archive. + * Use archive(3) to read the archive, counting files within. + */ + if ((archive = archive_read_new()) == NULL) { + snprintf(errormsg, sizeof(errormsg), + "Error: %s\n", archive_error_string(NULL)); + dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); + return (-1); + } archive_read_support_format_all(archive); archive_read_support_filter_all(archive); - sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), file); - err = archive_read_open_filename(archive, path, 4096); - if (err != ARCHIVE_OK) { + snprintf(path, sizeof(path), "%s/%s", distdir, file); + retval = archive_read_open_filename(archive, path, 4096); + if (retval != ARCHIVE_OK) { snprintf(errormsg, sizeof(errormsg), "Error while extracting %s: %s\n", file, archive_error_string(archive)); @@ -146,76 +232,83 @@ count_files(const char *file) } static int -extract_files(int nfiles, const char **files) +extract_files(int nfiles, struct file_node *files) { - const char *items[nfiles*2]; - char path[PATH_MAX]; + int archive_file; int archive_files[nfiles]; - int total_files, current_files, archive_file; + int current_files = 0; + int i; + int last_progress; + int progress = 0; + int retval; + int total_files = 0; struct archive *archive; struct archive_entry *entry; - char errormsg[512]; + struct file_node *file; char status[8]; - int i, err, progress, last_progress; + static char title[] = "Archive Extraction"; + static char pprompt[] = "Extracting distribution files...\n"; + char path[PATH_MAX]; + char errormsg[PATH_MAX + 512]; + const char *items[nfiles*2]; - err = 0; - progress = 0; - /* Make the transfer list for dialog */ - for (i = 0; i < nfiles; i++) { - items[i*2] = strrchr(files[i], '/'); - if (items[i*2] != NULL) - items[i*2]++; - else - items[i*2] = files[i]; + i = 0; + for (file = files; file != NULL; file = file->next) { + items[i*2] = file->name; items[i*2 + 1] = "Pending"; + archive_files[i] = file->length; + + total_files += file->length; + i++; } - dialog_msgbox("", - "Checking distribution archives.\nPlease wait...", 0, 0, FALSE); - - /* Count all the files */ - total_files = 0; - for (i = 0; i < nfiles; i++) { - archive_files[i] = count_files(files[i]); - if (archive_files[i] < 0) - return (-1); - total_files += archive_files[i]; - } - - current_files = 0; - - for (i = 0; i < nfiles; i++) { - archive = archive_read_new(); + i = 0; + for (file = files; file != NULL; file = file->next) { + if ((archive = archive_read_new()) == NULL) { + snprintf(errormsg, sizeof(errormsg), + "Error: %s\n", archive_error_string(NULL)); + dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); + return (EXIT_FAILURE); + } archive_read_support_format_all(archive); archive_read_support_filter_all(archive); - sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), files[i]); - err = archive_read_open_filename(archive, path, 4096); + snprintf(path, sizeof(path), "%s/%s", distdir, file->path); + retval = archive_read_open_filename(archive, path, 4096); + if (retval != 0) { + snprintf(errormsg, sizeof(errormsg), + "Error opening %s: %s\n", file->name, + archive_error_string(archive)); + dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); + return (EXIT_FAILURE); + } items[i*2 + 1] = "In Progress"; archive_file = 0; - while ((err = archive_read_next_header(archive, &entry)) == + dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles, + __DECONST(char **, items)); + + while ((retval = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) { last_progress = progress; progress = (current_files*100)/total_files; - sprintf(status, "-%d", + snprintf(status, sizeof(status), "-%d", (archive_file*100)/archive_files[i]); items[i*2 + 1] = status; if (progress > last_progress) - dialog_mixedgauge("Archive Extraction", - "Extracting distribution files...", 0, 0, + dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles, __DECONST(char **, items)); - err = archive_read_extract(archive, entry, + retval = archive_read_extract(archive, entry, ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL | ARCHIVE_EXTRACT_XATTR | ARCHIVE_EXTRACT_FFLAGS); - if (err != ARCHIVE_OK) + if (retval != ARCHIVE_OK) break; archive_file++; @@ -224,18 +317,22 @@ extract_files(int nfiles, const char **files) items[i*2 + 1] = "Done"; - if (err != ARCHIVE_EOF) { + if (retval != ARCHIVE_EOF) { snprintf(errormsg, sizeof(errormsg), "Error while extracting %s: %s\n", items[i*2], archive_error_string(archive)); items[i*2 + 1] = "Failed"; - dialog_msgbox("Extract Error", errormsg, 0, 0, - TRUE); - return (err); + dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); + return (retval); } + progress = (current_files*100)/total_files; + dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles, + __DECONST(char **, items)); + archive_read_free(archive); + i++; } - return (0); + return (EXIT_SUCCESS); } diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c index ae5766c75082..4e870c8bbdbf 100644 --- a/usr.sbin/bsdinstall/distfetch/distfetch.c +++ b/usr.sbin/bsdinstall/distfetch/distfetch.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2011 Nathan Whitehorn + * Copyright (c) 2014 Devin Teske * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,15 +23,21 @@ * LIABILITY, OR 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 +__FBSDID("$FreeBSD$"); + #include -#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include static int fetch_files(int nfiles, char **urls); @@ -39,12 +46,13 @@ main(void) { char *diststring; char **urls; - int i, nfetched, ndists = 0; + int i; + int ndists = 0; + int nfetched; + char error[PATH_MAX + 512]; - if (getenv("DISTRIBUTIONS") == NULL) { - fprintf(stderr, "DISTRIBUTIONS variable is not set\n"); - return (1); - } + if (getenv("DISTRIBUTIONS") == NULL) + errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set"); diststring = strdup(getenv("DISTRIBUTIONS")); for (i = 0; diststring[i] != 0; i++) @@ -54,9 +62,8 @@ main(void) urls = calloc(ndists, sizeof(const char *)); if (urls == NULL) { - fprintf(stderr, "Out of memory!\n"); free(diststring); - return (1); + errx(EXIT_FAILURE, "Out of memory!"); } init_dialog(stdin, stdout); @@ -65,17 +72,17 @@ main(void) for (i = 0; i < ndists; i++) { urls[i] = malloc(PATH_MAX); - sprintf(urls[i], "%s/%s", getenv("BSDINSTALL_DISTSITE"), - strsep(&diststring, " \t")); + snprintf(urls[i], PATH_MAX, "%s/%s", + getenv("BSDINSTALL_DISTSITE"), strsep(&diststring, " \t")); } if (chdir(getenv("BSDINSTALL_DISTDIR")) != 0) { - char error[512]; - sprintf(error, "Could could change to directory %s: %s\n", + snprintf(error, sizeof(error), + "Could could change to directory %s: %s\n", getenv("BSDINSTALL_DISTDIR"), strerror(errno)); dialog_msgbox("Error", error, 0, 0, TRUE); end_dialog(); - return (1); + return (EXIT_FAILURE); } nfetched = fetch_files(ndists, urls); @@ -87,31 +94,32 @@ main(void) free(urls[i]); free(urls); - return ((nfetched == ndists) ? 0 : 1); + return ((nfetched == ndists) ? EXIT_SUCCESS : EXIT_FAILURE); } static int fetch_files(int nfiles, char **urls) { + FILE *fetch_out; + FILE *file_out; const char **items; - FILE *fetch_out, *file_out; - struct url_stat ustat; - off_t total_bytes, current_bytes, fsize; - char status[8]; - char errormsg[512]; - uint8_t block[4096]; - size_t chunk; - int i, progress, last_progress; + int i; + int last_progress; int nsuccess = 0; /* Number of files successfully downloaded */ + int progress = 0; + size_t chunk; + off_t current_bytes; + off_t fsize; + off_t total_bytes; + char status[8]; + struct url_stat ustat; + char errormsg[PATH_MAX + 512]; + uint8_t block[4096]; - progress = 0; - /* Make the transfer list for dialog */ items = calloc(sizeof(char *), nfiles * 2); - if (items == NULL) { - fprintf(stderr, "Out of memory!\n"); - return (-1); - } + if (items == NULL) + errx(EXIT_FAILURE, "Out of memory!"); for (i = 0; i < nfiles; i++) { items[i*2] = strrchr(urls[i], '/'); @@ -177,7 +185,8 @@ fetch_files(int nfiles, char **urls) } if (ustat.size > 0) { - sprintf(status, "-%jd", (fsize*100)/ustat.size); + snprintf(status, sizeof(status), "-%jd", + (fsize*100)/ustat.size); items[i*2 + 1] = status; } @@ -212,4 +221,3 @@ fetch_files(int nfiles, char **urls) free(items); return (nsuccess); } - diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index 27feb577e823..37b172e8cb39 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -27,6 +27,7 @@ */ #include +#include #include #include #include @@ -119,6 +120,53 @@ newfs_command(const char *fstype, char *command, int use_default) else if (strcmp(items[i].name, "TRIM") == 0) strcat(command, "-t "); } + } else if (strcmp(fstype, "freebsd-zfs") == 0) { + int i; + DIALOG_LISTITEM items[] = { + {"fletcher4", "checksum algorithm: fletcher4", + "Use fletcher4 for data integrity checking. " + "(default)", 1 }, + {"fletcher2", "checksum algorithm: fletcher2", + "Use fletcher2 for data integrity checking. " + "(not recommended)", 0 }, + {"sha256", "checksum algorithm: sha256", + "Use sha256 for data integrity checking. " + "(not recommended)", 0 }, + {"atime", "Update atimes for files", + "Disable atime update", 0 }, + }; + + if (!use_default) { + int choice; + choice = dlg_checklist("ZFS Options", "", 0, 0, 0, + sizeof(items)/sizeof(items[0]), items, NULL, + FLAG_CHECK, &i); + if (choice == 1) /* Cancel */ + return; + } + + strcpy(command, "zpool create -f -m none "); + if (getenv("BSDINSTALL_TMPBOOT") != NULL) { + char zfsboot_path[MAXPATHLEN]; + sprintf(zfsboot_path, "%s/zfs", + getenv("BSDINSTALL_TMPBOOT")); + mkdir(zfsboot_path, S_IRWXU | S_IRGRP | S_IXGRP | + S_IROTH | S_IXOTH); + sprintf(command, "%s -o cachefile=%s/zpool.cache ", + command, zfsboot_path); + } + for (i = 0; i < (int)(sizeof(items)/sizeof(items[0])); i++) { + if (items[i].state == 0) + continue; + if (strcmp(items[i].name, "fletcher4") == 0) + strcat(command, "-O checksum=fletcher4 "); + else if (strcmp(items[i].name, "fletcher2") == 0) + strcat(command, "-O checksum=fletcher2 "); + else if (strcmp(items[i].name, "sha256") == 0) + strcat(command, "-O checksum=sha256 "); + else if (strcmp(items[i].name, "atime") == 0) + strcat(command, "-O atime=off "); + } } else if (strcmp(fstype, "fat32") == 0 || strcmp(fstype, "efi") == 0) { int i; DIALOG_LISTITEM items[] = { @@ -329,7 +377,7 @@ gpart_bootcode(struct ggeom *gp) } static void -gpart_partcode(struct gprovider *pp) +gpart_partcode(struct gprovider *pp, const char *fstype) { struct gconfig *gc; const char *scheme; @@ -344,7 +392,7 @@ gpart_partcode(struct gprovider *pp) } /* Make sure this partition scheme needs partcode on this platform */ - if (partcode_path(scheme) == NULL) + if (partcode_path(scheme, fstype) == NULL) return; LIST_FOREACH(gc, &pp->lg_config, lg_config) { @@ -356,7 +404,7 @@ gpart_partcode(struct gprovider *pp) /* Shell out to gpart for partcode for now */ sprintf(command, "gpart bootcode -p %s -i %s %s", - partcode_path(scheme), indexstr, pp->lg_geom->lg_name); + partcode_path(scheme, fstype), indexstr, pp->lg_geom->lg_name); if (system(command) != 0) { sprintf(message, "Error installing partcode on partition %s", pp->lg_name); @@ -416,15 +464,15 @@ gpart_edit(struct gprovider *pp) const char *errstr, *oldtype, *scheme; struct partition_metadata *md; char sizestr[32]; - char newfs[64]; + char newfs[255]; intmax_t idx; int hadlabel, choice, junk, nitems; unsigned i; DIALOG_FORMITEM items[] = { {0, "Type:", 5, 0, 0, FALSE, "", 11, 0, 12, 15, 0, - FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-swap)", - FALSE}, + FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-zfs, " + "freebsd-swap)", FALSE}, {0, "Size:", 5, 1, 0, FALSE, "", 11, 1, 12, 0, 0, FALSE, "Partition size. Append K, M, G for kilobytes, " "megabytes or gigabytes.", FALSE}, @@ -565,6 +613,8 @@ set_default_part_metadata(const char *name, const char *scheme, const char *type, const char *mountpoint, const char *newfs) { struct partition_metadata *md; + char *zpool_name = NULL; + int i; /* Set part metadata */ md = get_part_metadata(name, 1); @@ -577,8 +627,18 @@ set_default_part_metadata(const char *name, const char *scheme, if (newfs != NULL && newfs[0] != '\0') { md->newfs = malloc(strlen(newfs) + strlen(" /dev/") + - strlen(name) + 1); - sprintf(md->newfs, "%s /dev/%s", newfs, name); + strlen(mountpoint) + 5 + strlen(name) + 1); + if (strcmp("freebsd-zfs", type) == 0) { + zpool_name = strdup((strlen(mountpoint) == 1) ? + "root" : &mountpoint[1]); + for (i = 0; zpool_name[i] != 0; i++) + if (!isalnum(zpool_name[i])) + zpool_name[i] = '_'; + sprintf(md->newfs, "%s %s /dev/%s", newfs, + zpool_name, name); + } else { + sprintf(md->newfs, "%s /dev/%s", newfs, name); + } } } @@ -587,8 +647,9 @@ set_default_part_metadata(const char *name, const char *scheme, if (strcmp(type, bootpart_type(scheme)) == 0) md->bootcode = 1; - /* VTOC8 needs partcode in UFS partitions */ - if (strcmp(scheme, "VTOC8") == 0 && strcmp(type, "freebsd-ufs") == 0) + /* VTOC8 needs partcode at the start of partitions */ + if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0 + || strcmp(type, "freebsd-zfs") == 0)) md->bootcode = 1; if (mountpoint == NULL || mountpoint[0] == '\0') { @@ -611,8 +672,13 @@ set_default_part_metadata(const char *name, const char *scheme, free(md->fstab->fs_mntops); free(md->fstab->fs_type); } - md->fstab->fs_spec = malloc(strlen(name) + 6); - sprintf(md->fstab->fs_spec, "/dev/%s", name); + if (strcmp("freebsd-zfs", type) == 0) { + md->fstab->fs_spec = strdup(zpool_name); + } else { + md->fstab->fs_spec = malloc(strlen(name) + + strlen("/dev/") + 1); + sprintf(md->fstab->fs_spec, "/dev/%s", name); + } md->fstab->fs_file = strdup(mountpoint); /* Get VFS from text after freebsd-, if possible */ if (strncmp("freebsd-", type, 8) == 0) @@ -625,6 +691,10 @@ set_default_part_metadata(const char *name, const char *scheme, md->fstab->fs_type = strdup(FSTAB_SW); md->fstab->fs_freq = 0; md->fstab->fs_passno = 0; + } else if (strcmp(type, "freebsd-zfs") == 0) { + md->fstab->fs_type = strdup(FSTAB_RW); + md->fstab->fs_freq = 0; + md->fstab->fs_passno = 0; } else { md->fstab->fs_type = strdup(FSTAB_RW); if (strcmp(mountpoint, "/") == 0) { @@ -637,6 +707,9 @@ set_default_part_metadata(const char *name, const char *scheme, } md->fstab->fs_mntops = strdup(md->fstab->fs_type); } + + if (zpool_name != NULL) + free(zpool_name); } static @@ -748,7 +821,7 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size, struct ggeom *geom; const char *errstr, *scheme; char sizestr[32], startstr[32], output[64], *newpartname; - char newfs[64], options_fstype[64]; + char newfs[255], options_fstype[64]; intmax_t maxsize, size, sector, firstfree, stripe; uint64_t bytes; int nitems, choice, junk; @@ -756,8 +829,8 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size, DIALOG_FORMITEM items[] = { {0, "Type:", 5, 0, 0, FALSE, "freebsd-ufs", 11, 0, 12, 15, 0, - FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-swap)", - FALSE}, + FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-zfs, " + "freebsd-swap)", FALSE}, {0, "Size:", 5, 1, 0, FALSE, "", 11, 1, 12, 15, 0, FALSE, "Partition size. Append K, M, G for kilobytes, " "megabytes or gigabytes.", FALSE}, @@ -935,6 +1008,20 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size, goto addpartform; } + /* If this is the root partition, check that this fs is bootable */ + if (strcmp(items[2].text, "/") == 0 && !is_fs_bootable(scheme, + items[0].text)) { + char message[512]; + sprintf(message, "This file system (%s) is not bootable " + "on this system. Are you sure you want to proceed?", + items[0].text); + dialog_vars.defaultno = TRUE; + choice = dialog_yesno("Warning", message, 0, 0); + dialog_vars.defaultno = FALSE; + if (choice == 1) /* cancel */ + goto addpartform; + } + /* * If this is the root partition, and we need a boot partition, ask * the user to add one. @@ -1177,12 +1264,22 @@ gpart_commit(struct gmesh *mesh) struct gctl_req *r; const char *errstr; const char *modified; + const char *rootfs; LIST_FOREACH(classp, &mesh->lg_class, lg_class) { if (strcmp(classp->lg_name, "PART") == 0) break; } + /* Figure out what filesystem / uses */ + rootfs = "ufs"; /* Assume ufs if nothing else present */ + TAILQ_FOREACH(md, &part_metadata, metadata) { + if (md->fstab != NULL && strcmp(md->fstab->fs_file, "/") == 0) { + rootfs = md->fstab->fs_vfstype; + break; + } + } + if (strcmp(classp->lg_name, "PART") != 0) { dialog_msgbox("Error", "gpart not found!", 0, 0, TRUE); return; @@ -1222,7 +1319,7 @@ gpart_commit(struct gmesh *mesh) break; if (cp == NULL) /* No sub-partitions */ - gpart_partcode(pp); + gpart_partcode(pp, rootfs); } r = gctl_get_handle(); diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c index a304fb83039c..3f7ccd59a1a2 100644 --- a/usr.sbin/bsdinstall/partedit/part_wizard.c +++ b/usr.sbin/bsdinstall/partedit/part_wizard.c @@ -31,6 +31,9 @@ #include #include +#include +#include + #include #include #include @@ -44,10 +47,16 @@ static char *boot_disk(struct gmesh *mesh); static char *wizard_partition(struct gmesh *mesh, const char *disk); int -part_wizard(void) { +part_wizard(const char *fsreq) { int error; struct gmesh mesh; char *disk, *schemeroot; + const char *fstype; + + if (fsreq != NULL) + fstype = fsreq; + else + fstype = "ufs"; startwizard: error = geom_gettree(&mesh); @@ -70,11 +79,11 @@ part_wizard(void) { dlg_put_backtitle(); error = geom_gettree(&mesh); - error = wizard_makeparts(&mesh, schemeroot, 1); + error = wizard_makeparts(&mesh, schemeroot, fstype, 1); if (error) goto startwizard; free(schemeroot); - + geom_deletetree(&mesh); return (0); @@ -106,9 +115,9 @@ boot_disk(struct gmesh *mesh) LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { desc = type = NULL; LIST_FOREACH(gc, &pp->lg_config, lg_config) { - if (strcmp(gc->lg_name, "type") == 0) + if (strcmp(gc->lg_name, "type") == 0) type = gc->lg_val; - if (strcmp(gc->lg_name, "descr") == 0) + if (strcmp(gc->lg_name, "descr") == 0) desc = gc->lg_val; } @@ -200,7 +209,7 @@ wizard_partition(struct gmesh *mesh, const char *disk) break; if (classp != NULL) { - LIST_FOREACH(gpart, &classp->lg_geom, lg_geom) + LIST_FOREACH(gpart, &classp->lg_geom, lg_geom) if (strcmp(gpart->lg_name, disk) == 0) break; } @@ -282,21 +291,29 @@ wizard_partition(struct gmesh *mesh, const char *disk) } int -wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive) +wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype, int interactive) { struct gmesh submesh; struct gclass *classp; struct ggeom *gp; struct gprovider *pp; intmax_t swapsize, available; - char swapsizestr[10], rootsizestr[10]; + char swapsizestr[10], rootsizestr[10], *fsname; + char *fsnames[] = {"freebsd-ufs", "freebsd-zfs"}; int retval; + if (strcmp(fstype, "zfs") == 0) { + fsname = fsnames[1]; + } else { + /* default to UFS */ + fsname = fsnames[0]; + } + LIST_FOREACH(classp, &mesh->lg_class, lg_class) if (strcmp(classp->lg_name, "PART") == 0) break; - LIST_FOREACH(gp, &classp->lg_geom, lg_geom) + LIST_FOREACH(gp, &classp->lg_geom, lg_geom) if (strcmp(gp->lg_name, disk) == 0) break; @@ -331,7 +348,7 @@ wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive) geom_gettree(&submesh); pp = provider_for_name(&submesh, disk); - gpart_create(pp, "freebsd-ufs", rootsizestr, "/", NULL, 0); + gpart_create(pp, fsname, rootsizestr, "/", NULL, 0); geom_deletetree(&submesh); geom_gettree(&submesh); diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c index eff87feaef54..ac3cd8a9c9c0 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.c +++ b/usr.sbin/bsdinstall/partedit/partedit.c @@ -95,7 +95,12 @@ main(int argc, const char **argv) if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */ prompt = "Please review the disk setup. When complete, press " "the Finish button."; - part_wizard(); + /* Experimental ZFS autopartition support */ + if (argc > 1 && strcmp(argv[1], "zfs") == 0) { + part_wizard("zfs"); + } else { + part_wizard("ufs"); + } } else if (strcmp(basename(argv[0]), "scriptedpart") == 0) { error = scripted_editor(argc, argv); prompt = NULL; @@ -162,7 +167,7 @@ main(int argc, const char **argv) init_fstab_metadata(); break; case 4: /* Auto */ - part_wizard(); + part_wizard("ufs"); break; } diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h index 32e3a36f374b..b6f725893cbd 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.h +++ b/usr.sbin/bsdinstall/partedit/partedit.h @@ -54,9 +54,10 @@ struct partition_metadata { struct partition_metadata *get_part_metadata(const char *name, int create); void delete_part_metadata(const char *name); -int part_wizard(void); +int part_wizard(const char *fstype); int scripted_editor(int argc, const char **argv); -int wizard_makeparts(struct gmesh *mesh, const char *disk, int interactive); +int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype, + int interactive); /* gpart operations */ void gpart_delete(struct gprovider *pp); @@ -75,9 +76,10 @@ void set_default_part_metadata(const char *name, const char *scheme, /* machine-dependent bootability checks */ const char *default_scheme(void); int is_scheme_bootable(const char *scheme); +int is_fs_bootable(const char *scheme, const char *fs); size_t bootpart_size(const char *scheme); const char *bootpart_type(const char *scheme); const char *bootcode_path(const char *scheme); -const char *partcode_path(const char *scheme); +const char *partcode_path(const char *scheme, const char *fs_type); #endif diff --git a/usr.sbin/bsdinstall/partedit/partedit_generic.c b/usr.sbin/bsdinstall/partedit/partedit_generic.c index 8498a78ffcb6..ceee95ad8d56 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_generic.c +++ b/usr.sbin/bsdinstall/partedit/partedit_generic.c @@ -50,6 +50,11 @@ is_scheme_bootable(const char *part_type) { return (1); } +int +is_fs_bootable(const char *part_type, const char *fs) { + return (1); +} + /* No clue => no boot partition, bootcode, or partcode */ size_t @@ -68,7 +73,7 @@ bootcode_path(const char *part_type) { } const char * -partcode_path(const char *part_type) { +partcode_path(const char *part_type, const char *fs_type) { return (NULL); } diff --git a/usr.sbin/bsdinstall/partedit/partedit_pc98.c b/usr.sbin/bsdinstall/partedit/partedit_pc98.c index dd075a1af7f9..8e914eab0ca7 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_pc98.c +++ b/usr.sbin/bsdinstall/partedit/partedit_pc98.c @@ -45,6 +45,15 @@ is_scheme_bootable(const char *part_type) { return (0); } +int +is_fs_bootable(const char *part_type, const char *fs) +{ + if (strcmp(fs, "freebsd-ufs") == 0) + return (1); + + return (0); +} + size_t bootpart_size(const char *part_type) { /* No boot partition */ @@ -67,7 +76,7 @@ bootcode_path(const char *part_type) { } const char * -partcode_path(const char *part_type) { +partcode_path(const char *part_type, const char *fs_type) { /* No partcode */ return (NULL); } diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c index 77c682a6b94d..6a5dbb2fdf3e 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c +++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c @@ -67,6 +67,15 @@ is_scheme_bootable(const char *part_type) { return (0); } +int +is_fs_bootable(const char *part_type, const char *fs) +{ + if (strcmp(fs, "freebsd-ufs") == 0) + return (1); + + return (0); +} + size_t bootpart_size(const char *part_type) { size_t platlen = sizeof(platform); @@ -100,7 +109,7 @@ bootcode_path(const char *part_type) { } const char * -partcode_path(const char *part_type) { +partcode_path(const char *part_type, const char *fs_type) { size_t platlen = sizeof(platform); if (strlen(platform) == 0) sysctlbyname("hw.platform", platform, &platlen, NULL, -1); diff --git a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c index 8232c550c609..c420f6a4efd9 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c +++ b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c @@ -42,6 +42,15 @@ is_scheme_bootable(const char *part_type) { return (0); } +int +is_fs_bootable(const char *part_type, const char *fs) +{ + if (strcmp(fs, "freebsd-ufs") == 0 || strcmp(fs, "freebsd-zfs") == 0) + return (1); + return (0); +} + + size_t bootpart_size(const char *part_type) { /* No standalone boot partition */ @@ -58,11 +67,16 @@ const char * bootcode_path(const char *part_type) { return (NULL); } - + const char * -partcode_path(const char *part_type) { - if (strcmp(part_type, "VTOC8") == 0) - return ("/boot/boot1"); +partcode_path(const char *part_type, const char *fs_type) { + if (strcmp(part_type, "VTOC8") == 0) { + if (strcmp(fs_type, "ufs") == 0) { + return ("/boot/boot1"); + } else if (strcmp(fs_type, "zfs") == 0) { + return ("/boot/zfsboot"); + } + } return (NULL); } diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index b458475fe6c6..bd98ac55cf39 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -58,6 +58,21 @@ is_scheme_bootable(const char *part_type) { return (0); } +int +is_fs_bootable(const char *part_type, const char *fs) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + + if (strcmp(fs, "freebsd-ufs") == 0) + return (1); + + if (strcmp(fs, "freebsd-zfs") == 0 && strcmp(platform, "BIOS") == 0) + return (1); + + return (0); +} + size_t bootpart_size(const char *scheme) { size_t platlen = sizeof(platform); @@ -107,7 +122,7 @@ bootcode_path(const char *part_type) { } const char * -partcode_path(const char *part_type) { +partcode_path(const char *part_type, const char *fs_type) { size_t platlen = sizeof(platform); if (strlen(platform) == 0) sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); @@ -115,6 +130,8 @@ partcode_path(const char *part_type) { if (strcmp(part_type, "GPT") == 0) { if (strcmp(platform, "UEFI") == 0) return ("/boot/boot1.efifat"); + else if (strcmp(fs_type, "zfs") == 0) + return ("/boot/gptzfsboot"); else return ("/boot/gptboot"); } diff --git a/usr.sbin/bsdinstall/partedit/sade.8 b/usr.sbin/bsdinstall/partedit/sade.8 index 79df079e371b..3bb1c65e4206 100644 --- a/usr.sbin/bsdinstall/partedit/sade.8 +++ b/usr.sbin/bsdinstall/partedit/sade.8 @@ -68,7 +68,5 @@ with the equivalent part of .Sh BUGS The utility misses a lot of nice features, such as tools for manipulating -.Xr gmirror 8 -or -.Xr zfs 8 . +.Xr gmirror 8 . These will be added later. diff --git a/usr.sbin/bsdinstall/partedit/scripted.c b/usr.sbin/bsdinstall/partedit/scripted.c index 4ac34824b090..876df5498ba9 100644 --- a/usr.sbin/bsdinstall/partedit/scripted.c +++ b/usr.sbin/bsdinstall/partedit/scripted.c @@ -109,7 +109,7 @@ part_config(char *disk, const char *scheme, char *config) /* Create partitions */ if (config == NULL) { - wizard_makeparts(&mesh, disk, 0); + wizard_makeparts(&mesh, disk, "ufs", 0); goto finished; } diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index d2ac83ddeaa3..433744e9bb62 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -107,14 +107,14 @@ rm -f $PATH_FSTAB touch $PATH_FSTAB PMODES="\ -Guided \"Partitioning Tool (Recommended for Beginners)\" \ -Manual \"Manually Configure Partitions (Expert)\" \ +\"Auto (UFS)\" \"Guided Disk Setup\" \ +Manual \"Manual Disk Setup (experts)\" \ Shell \"Open a shell and partition by hand\"" CURARCH=$( uname -m ) case $CURARCH in amd64|i386) # Booting ZFS Supported - PMODES="$PMODES ZFS \"Automatic Root-on-ZFS (Experimental)\"" + PMODES="$PMODES \"Auto (ZFS)\" \"Guided Root-on-ZFS\"" ;; *) # Booting ZFS Unspported ;; @@ -128,7 +128,7 @@ PARTMODE=`echo $PMODES | xargs dialog --backtitle "FreeBSD Installer" \ exec 3>&- case "$PARTMODE" in -"Guided") # Guided +"Auto (UFS)") # Guided bsdinstall autopart || error "Partitioning error" bsdinstall mount || error "Failed to mount filesystem" ;; @@ -146,7 +146,7 @@ case "$PARTMODE" in fi bsdinstall mount || error "Failed to mount filesystem" ;; -"ZFS") # ZFS +"Auto (ZFS)") # ZFS bsdinstall zfsboot || error "ZFS setup failed" bsdinstall mount || error "Failed to mount filesystem" ;; @@ -252,7 +252,8 @@ if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then fi dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \ - --yesno "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0 + --default-button no --yesno \ + "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0 if [ $? -eq 0 ]; then clear mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" diff --git a/usr.sbin/bsdinstall/scripts/config b/usr.sbin/bsdinstall/scripts/config index 98baade77535..bc3d723afc3b 100755 --- a/usr.sbin/bsdinstall/scripts/config +++ b/usr.sbin/bsdinstall/scripts/config @@ -36,6 +36,7 @@ cp $BSDINSTALL_TMPETC/* $BSDINSTALL_CHROOT/etc cat $BSDINSTALL_TMPBOOT/loader.conf.* >> $BSDINSTALL_TMPBOOT/loader.conf rm $BSDINSTALL_TMPBOOT/loader.conf.* +df -t zfs $BSDINSTALL_CHROOT > /dev/null && echo "zfs_load=\"YES\"" >> $BSDINSTALL_TMPBOOT/loader.conf cp $BSDINSTALL_TMPBOOT/* $BSDINSTALL_CHROOT/boot diff --git a/usr.sbin/bsdinstall/scripts/services b/usr.sbin/bsdinstall/scripts/services index 54c5018610e2..83786c2868e0 100755 --- a/usr.sbin/bsdinstall/scripts/services +++ b/usr.sbin/bsdinstall/scripts/services @@ -43,6 +43,7 @@ DAEMONS=$( dialog --backtitle "FreeBSD Installer" \ --title "System Configuration" --nocancel --separate-output \ --checklist "Choose the services you would like to be started at boot:" \ 0 0 0 \ + local_unbound "Local caching validating resolver" ${local_unbound:-off} \ sshd "Secure shell daemon" ${sshd_enable:-off} \ moused "PS/2 mouse pointer on console" ${moused_enable:-off} \ ntpd "Synchronize system and network time" ${ntpd_enable:-off} \ diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot index 9f1abb8b2f2c..2b01dea09e1c 100755 --- a/usr.sbin/bsdinstall/scripts/zfsboot +++ b/usr.sbin/bsdinstall/scripts/zfsboot @@ -156,7 +156,7 @@ f_isset ZFSBOOT_DATASETS || ZFSBOOT_DATASETS=" /usr/src # Create /var and friends - /var mountpoint=/var + /var mountpoint=/var,canmount=off /var/crash exec=off,setuid=off /var/log exec=off,setuid=off /var/mail atime=on @@ -293,6 +293,7 @@ msg_swap_mirror_help="Mirror swap partitions for redundancy, breaks crash dumps" msg_swap_size="Swap Size" msg_swap_size_help="Customize how much swap space is allocated to each selected disk" msg_these_disks_are_too_small="These disks are too small given the amount of requested\nswap (%s) and/or geli(8) (%s) partitions, which would\ntake 50%% or more of each of the following selected disk\ndevices (not recommended):\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of devices." +msg_uefi_not_supported="The FreeBSD UEFI loader does not currently support booting root-on-ZFS. Your system will need to boot in legacy (CSM) mode.\nDo you want to continue?" msg_unable_to_get_disk_capacity="Unable to get disk capacity of \`%s'" msg_unsupported_partition_scheme="%s is an unsupported partition scheme" msg_user_cancelled="User Cancelled." @@ -687,6 +688,48 @@ dialog_menu_layout() return $DIALOG_OK } +# dialog_uefi_prompt +# +# Confirm that the user wants to continue with the installation on a BIOS +# system when they have booted with UEFI +# +dialog_uefi_prompt() +{ + local title="$DIALOG_TITLE" + local btitle="$DIALOG_BACKTITLE" + local prompt # Calculated below + local hline="$hline_arrows_tab_enter" + + local height=8 width=50 prefix=" " + local plen=${#prefix} list= line= + local max_width=$(( $width - 3 - $plen )) + + local yes no defaultno extra_args format + if [ "$USE_XDIALOG" ]; then + yes=ok no=cancel defaultno=default-no + extra_args="--wrap --left" + format="$msg_uefi_not_supported" + else + yes=yes no=no defaultno=defaultno + extra_args="--cr-wrap" + format="$msg_uefi_not_supported" + fi + + # Add height for Xdialog(1) + [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 )) + + prompt=$( printf "$format" ) + f_dprintf "%s: UEFI prompt" "$0" + $DIALOG \ + --title "$title" \ + --backtitle "$btitle" \ + --hline "$hline" \ + --$yes-label "$msg_yes" \ + --$no-label "$msg_no" \ + $extra_args \ + --yesno "$prompt" $height $width +} + # zfs_create_diskpart $disk $index # # For each block device to be used in the zpool, rather than just create the @@ -1272,8 +1315,6 @@ zfs_create_boot() "$funcname" f_eval_catch $funcname echo "$ECHO_APPEND" 'zfs_enable=\"YES\"' \ $BSDINSTALL_TMPETC/rc.conf.zfs || return $FAILURE - f_eval_catch $funcname echo "$ECHO_APPEND" 'zfs_load=\"YES\"' \ - $BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE f_eval_catch $funcname echo "$ECHO_APPEND" \ 'kern.geom.label.disk_ident.enable=\"0\"' \ $BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE @@ -1385,6 +1426,21 @@ f_dprintf "BSDINSTALL_CHROOT=[%s]" "$BSDINSTALL_CHROOT" f_dprintf "BSDINSTALL_TMPETC=[%s]" "$BSDINSTALL_TMPETC" f_dprintf "FSTAB_FMT=[%s]" "$FSTAB_FMT" +# +# If the system was booted with UEFI, warn the user that FreeBSD can't do +# ZFS with UEFI yet +# +if f_interactive; then + bootmethod=$(sysctl -n machdep.bootmethod) + f_dprintf "machdep.bootmethod=[%s]" "$bootmethod" + if [ "$bootmethod" != "BIOS" ]; then + dialog_uefi_prompt + retval=$? + f_dprintf "uefi_prompt=[%s]" "$retval" + [ $retval -eq $DIALOG_OK ] || f_die + fi +fi + # # Loop over the main menu until we've accomplished what we came here to do # diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8 index f58a760f39d3..1cacf64211a5 100644 --- a/usr.sbin/ctladm/ctladm.8 +++ b/usr.sbin/ctladm/ctladm.8 @@ -34,7 +34,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd July 9, 2014 +.Dd September 13, 2014 .Dt CTLADM 8 .Os .Sh NAME @@ -959,8 +959,19 @@ Setting to "on" allows EXTENDED COPY command sent to this LUN access other LUNs on this host, not accessible otherwise. This allows to offload copying between different iSCSI targets residing on the same host in trusted environments. +.It Va readcache +Set to "off", disables read caching for the LUN, if supported by the backend. +.It Va reordering +Set to "unrestricted", allows target to process commands with SIMPLE task +attribute in arbitrary order. Any data integrity exposures related to +command sequence order shall be explicitly handled by the application +client through the selection of appropriate commands and task attributes. +The default value is "restricted". It improves data integrity, but may +introduce some additional delays. .It Va unmap -Set to "on", enables UNMAP support for the LUN. +Set to "on", enables UNMAP support for the LUN, if supported by the backend. +.It Va writecache +Set to "off", disables write caching for the LUN, if supported by the backend. .El .Pp Options specific for block backend: diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 index 0c73f64d6bf4..efdbcfb51f71 100644 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 28, 2014 +.Dd September 14, 2014 .Dt CTL.CONF 5 .Os .Sh NAME @@ -46,179 +46,250 @@ The general syntax of the .Nm file is: .Bd -literal -offset indent -pidfile +.No pidfile Ar path -auth-group { - chap - ... +.No auth-group Ar name No { +.Dl chap Ar user Ar secret +.Dl ... } -portal-group { - listen

- listen-iser
- discovery-auth-group - ... +.No portal-group Ar name No { +.Dl listen Ar address +.Dl listen-iser Ar address +.Dl discovery-auth-group Ar name +.Dl ... } -target { - auth-group - portal-group - lun { - path - } - ... +.No target Ar name { +.Dl auth-group Ar name +.Dl portal-group Ar name +.Dl lun Ar number No { +.Dl path Ar path +.Dl } +.Dl ... } .Ed -.Ss global level -The following statements are available at the global level: +.Ss Global Context .Bl -tag -width indent -.It Ic auth-group Aq Ar name -Opens an auth-group section, defining an authentication group, +.It Ic auth-group Ar name +Create an +.Sy auth-group +configuration context, +defining a new auth-group, which can then be assigned to any number of targets. -.It Ic debug Aq Ar level -Specifies debug level. +.It Ic debug Ar level +The debug verbosity level. The default is 0. -.It Ic maxproc Aq Ar number -Specifies limit for concurrently running child processes handling +.It Ic maxproc Ar number +The limit for concurrently running child processes handling incoming connections. The default is 30. -Setting it to 0 disables the limit. -.It Ic pidfile Aq Ar path -Specifies path to pidfile. +A setting of 0 disables the limit. +.It Ic pidfile Ar path +The path to the pidfile. The default is .Pa /var/run/ctld.pid . -.It Ic portal-group Aq Ar name -Opens a portal-group section, defining a portal group, +.It Ic portal-group Ar name +Create a +.Sy portal-group +configuration context, +defining a new portal-group, which can then be assigned to any number of targets. -.It Ic target Aq Ar name -Opens a target configuration section. -.It Ic timeout Aq Ar seconds -Specifies timeout for login session, after which the connection +.It Ic target Ar name +Create a +.Sy target +configuration context, which can contain one or more +.Sy lun +contexts. +.It Ic timeout Ar seconds +The timeout for login sessions, after which the connection will be forcibly terminated. The default is 60. -Setting it to 0 disables the timeout. +A setting of 0 disables the timeout. .El -.Ss auth-group level -The following statements are available at the auth-group level: +.Ss auth-group Context .Bl -tag -width indent -.It Ic auth-type Ao Ar type Ac -Specifies authentication type. -Type can be either "none", "deny", "chap", or "chap-mutual". + +.It Ic auth-type Ar type +Sets the authentication type. +Type can be either +.Qq Ar none , +.Qq Ar deny , +.Qq Ar chap , +or +.Qq Ar chap-mutual . In most cases it is not necessary to set the type using this clause; -it is usually used to disable authentication for a given auth-group. -.It Ic chap Ao Ar user Ac Aq Ar secret -Specifies CHAP authentication credentials. -.It Ic chap-mutual Ao Ar user Ac Ao Ar secret Ac Ao Ar mutualuser Ac Aq Ar mutualsecret -Specifies mutual CHAP authentication credentials. -Note that for any auth-group, configuration may contain either chap, -or chap-mutual entries; it is an error to mix them. -.It Ic initiator-name Ao Ar initiator-name Ac -Specifies iSCSI initiator name. +it is usually used to disable authentication for a given +.Sy auth-group . +.It Ic chap Ar user Ar secret +A set of CHAP authentication credentials. +Note that for any +.Sy auth-group , +the configuration may only contain either +.Sy chap +or +.Sy chap-mutual +entries; it is an error to mix them. +.It Ic chap-mutual Ar user Ar secret Ar mutualuser Ar mutualsecret +A set of mutual CHAP authentication credentials. +Note that for any +.Sy auth-group , +the configuration may only contain either +.Sy chap +or +.Sy chap-mutual +entries; it is an error to mix them. +.It Ic initiator-name Ar initiator-name +An iSCSI initiator name. +Only initiators with a name matching one of the defined +names will be allowed to connect. If not defined, there will be no restrictions based on initiator name. -Otherwise, only initiators with names matching one of defined -ones will be allowed to connect. -.It Ic initiator-portal Ao Ar address Ac -Specifies iSCSI initiator portal - IPv4 or IPv6 address or network. +.It Ic initiator-portal Ar address Ns Op / Ns Ar prefixlen +An iSCSI initiator portal: an IPv4 or IPv6 address, optionally +followed by a literal slash and a prefix length. +Only initiators with an address matching one of the defined +addresses will be allowed to connect. If not defined, there will be no restrictions based on initiator address. -Otherwise, only initiators with addresses matching one of defined -ones will be allowed to connect. .El -.Ss portal-group level -The following statements are available at the portal-group level: +.Ss portal-group Context .Bl -tag -width indent -.It Ic discovery-auth-group Aq Ar name -Assigns previously defined authentication group to the portal group, +.It Ic discovery-auth-group Ar name +Assign a previously defined authentication group to the portal group, to be used for target discovery. By default, portal groups that do not specify their own auth settings, -using clauses such as "chap" or "initiator-name", are assigned -predefined auth-group "default", which denies discovery. -Another predefined auth-group, "no-authentication", may be used +using clauses such as +.Sy chap +or +.Sy initiator-name , +are assigned +predefined +.Sy auth-group +.Qq Ar default , +which denies discovery. +Another predefined +.Sy auth-group , +.Qq Ar no-authentication , +may be used to permit discovery without authentication. -.It Ic listen Aq Ar address -Specifies IPv4 or IPv6 address and port to listen on for incoming connections. -.It Ic listen-iser Aq Ar address -Specifies IPv4 or IPv6 address and port to listen on for incoming connections +.It Ic listen Ar address +An IPv4 or IPv6 address and port to listen on for incoming connections. +.It Ic listen-iser Ar address +An IPv4 or IPv6 address and port to listen on for incoming connections using iSER (iSCSI over RDMA) protocol. .El -.Ss target level: -The following statements are available at the target level: +.Ss target Context .Bl -tag -width indent -.It Ic alias Aq Ar text -Assigns human-readable description to the target. +.It Ic alias Ar text +Assign a human-readable description to the target. There is no default. -.It Ic auth-group Aq Ar name -Assigns previously defined authentication group to the target. +.It Ic auth-group Ar name +Assign a previously defined authentication group to the target. By default, targets that do not specify their own auth settings, -using clauses such as "chap" or "initiator-name", are assigned -predefined auth-group "default", which denies all access. -Another predefined auth-group, "no-authentication", may be used to permit access +using clauses such as +.Sy chap +or +.Sy initiator-name , +are assigned +predefined +.Sy auth-group +.Qq Ar default , +which denies all access. +Another predefined +.Sy auth-group , +.Qq Ar no-authentication , +may be used to permit access without authentication. -.It Ic auth-type Ao Ar type Ac -Specifies authentication type. -Type can be either "none", "deny", "chap", or "chap-mutual". +Note that targets must only use one of +.Sy auth-group , chap , No or Sy chap-mutual ; +it is a configuration error to mix multiple types in one target. +.It Ic auth-type Ar type +Sets the authentication type. +Type can be either +.Qq Ar none , +.Qq Ar deny , +.Qq Ar chap , +or +.Qq Ar chap-mutual . In most cases it is not necessary to set the type using this clause; -it is usually used to disable authentication for a given target. -This clause is mutually exclusive with auth-group; one cannot use +it is usually used to disable authentication for a given +.Sy target . +This clause is mutually exclusive with +.Sy auth-group ; +one cannot use both in a single target. -.It Ic chap Ao Ar user Ac Aq Ar secret -Specifies CHAP authentication credentials. -Note that targets must use either auth-group, or chap, -or chap-mutual clauses; it is a configuration error to mix them in one target. -.It Ic chap-mutual Ao Ar user Ac Ao Ar secret Ac Ao Ar mutualuser Ac Aq Ar mutualsecret -Specifies mutual CHAP authentication credentials. -Note that targets must use either auth-group, chap, or -chap-mutual clauses; it is a configuration error to mix them in one target. -.It Ic initiator-name Ao Ar initiator-name Ac -Specifies iSCSI initiator name. +.It Ic chap Ar user Ar secret +A set of CHAP authentication credentials. +Note that targets must only use one of +.Sy auth-group , chap , No or Sy chap-mutual ; +it is a configuration error to mix multiple types in one target. +.It Ic chap-mutual Ar user Ar secret Ar mutualuser Ar mutualsecret +A set of mutual CHAP authentication credentials. +Note that targets must only use one of +.Sy auth-group , chap , No or Sy chap-mutual ; +it is a configuration error to mix multiple types in one target. +.It Ic initiator-name Ar initiator-name +An iSCSI initiator name. +Only initiators with a name matching one of the defined +names will be allowed to connect. If not defined, there will be no restrictions based on initiator name. -Otherwise, only initiators with names matching one of defined -ones will be allowed to connect. -This clause is mutually exclusive with auth-group; one cannot use +This clause is mutually exclusive with +.Sy auth-group ; +one cannot use both in a single target. -.It Ic initiator-portal Ao Ar address Ac -Specifies iSCSI initiator portal - IPv4 or IPv6 address. +.It Ic initiator-portal Ar address Ns Op / Ns Ar prefixlen +An iSCSI initiator portal: an IPv4 or IPv6 address, optionally +followed by a literal slash and a prefix length. +Only initiators with an address matching one of the defined +addresses will be allowed to connect. If not defined, there will be no restrictions based on initiator address. -Otherwise, only initiators with addresses matching one of defined -ones will be allowed to connect. -This clause is mutually exclusive with auth-group; one cannot use +This clause is mutually exclusive with +.Sy auth-group ; +one cannot use both in a single target. -.It Ic portal-group Aq Ar name -Assigns previously defined portal group to the target. -Default portal group is "default", which makes the target available +.It Ic portal-group Ar name +Assign a previously defined portal group to the target. +The default portal group is +.Qq Ar default , +which makes the target available on TCP port 3260 on all configured IPv4 and IPv6 addresses. -.It Ic lun Aq Ar number -Opens a lun configuration section, defining LUN exported by a target. +.It Ic lun Ar number +Create a +.Sy lun +configuration context, defining a LUN exported by the parent target. .El -.Ss lun level -The following statements are available at the lun level: +.Ss lun Context .Bl -tag -width indent -.It Ic backend Ao Ar block | Ar ramdisk Ac -Specifies the CTL backend to use for a given LUN. +.It Ic backend Ar block No | Ar ramdisk +The CTL backend to use for a given LUN. Valid choices are -.Dq block +.Qq Ar block and -.Dq ramdisk ; +.Qq Ar ramdisk ; block is used for LUNs backed by files or disk device nodes; ramdisk is a bitsink device, used mostly for testing. The default backend is block. -.It Ic blocksize Aq Ar size -Specifies blocksize visible to the initiator. +.It Ic blocksize Ar size +The blocksize visible to the initiator. The default blocksize is 512. -.It Ic device-id Aq Ar string -Specifies SCSI Device Identification string presented to the initiator. -.It Ic option Ao Ar name Ac Aq Ar value -Specifies CTL-specific options passed to the kernel. -.It Ic path Aq Ar path -Specifies path to file or device node used to back the LUN. -.It Ic serial Aq Ar string -Specifies SCSI serial number presented to the initiator. -.It Ic size Aq Ar size -Specifies LUN size, in bytes. +.It Ic device-id Ar string +The SCSI Device Identification string presented to the initiator. +.It Ic option Ar name Ar value +The CTL-specific options passed to the kernel. +All CTL-specific options are documented in the +.Sx OPTIONS +section of +.Xr ctladm 8 . +.It Ic path Ar path +The path to the file or device node used to back the LUN. +.It Ic serial Ar string +The SCSI serial number presented to the initiator. +.It Ic size Ar size +The LUN size, in bytes. .El .Sh FILES .Bl -tag -width ".Pa /etc/ctl.conf" -compact @@ -234,6 +305,7 @@ pidfile /var/run/ctld.pid auth-group example2 { chap-mutual "user" "secret" "mutualuser" "mutualsecret" chap-mutual "user2" "secret2" "mutualuser" "mutualsecret" + initiator-portal 192.168.1.1/16 } portal-group example2 { diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index c1593c2439b4..e4c2eda0fcf7 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -561,8 +561,10 @@ portal_new(struct portal_group *pg) static void portal_delete(struct portal *portal) { + TAILQ_REMOVE(&portal->p_portal_group->pg_portals, portal, p_next); - freeaddrinfo(portal->p_ai); + if (portal->p_ai != NULL) + freeaddrinfo(portal->p_ai); free(portal->p_listen); free(portal); } @@ -633,8 +635,7 @@ portal_group_add_listen(struct portal_group *pg, const char *value, bool iser) arg = portal->p_listen; if (arg[0] == '\0') { log_warnx("empty listen address"); - free(portal->p_listen); - free(portal); + portal_delete(portal); return (1); } if (arg[0] == '[') { @@ -646,8 +647,7 @@ portal_group_add_listen(struct portal_group *pg, const char *value, bool iser) if (arg == NULL) { log_warnx("invalid listen address %s", portal->p_listen); - free(portal->p_listen); - free(portal); + portal_delete(portal); return (1); } if (arg[0] == '\0') { @@ -657,8 +657,7 @@ portal_group_add_listen(struct portal_group *pg, const char *value, bool iser) } else { log_warnx("invalid listen address %s", portal->p_listen); - free(portal->p_listen); - free(portal); + portal_delete(portal); return (1); } } else { @@ -691,8 +690,7 @@ portal_group_add_listen(struct portal_group *pg, const char *value, bool iser) if (error != 0) { log_warnx("getaddrinfo for %s failed: %s", portal->p_listen, gai_strerror(error)); - free(portal->p_listen); - free(portal); + portal_delete(portal); return (1); } @@ -1415,7 +1413,8 @@ conf_apply(struct conf *oldconf, struct conf *newconf) if (oldtarg != NULL) { oldlun = lun_find(oldtarg, newlun->l_lun); if (oldlun != NULL) { - if (newlun->l_size != oldlun->l_size) { + if (newlun->l_size != oldlun->l_size || + newlun->l_size == 0) { log_debugx("resizing lun %d, " "target %s, CTL lun %d", newlun->l_lun, @@ -1760,9 +1759,7 @@ main_loop(struct conf *conf, bool dont_fork) client_salen = sizeof(client_sa); kernel_accept(&connection_id, &portal_id, (struct sockaddr *)&client_sa, &client_salen); - if (client_salen < client_sa.ss_len) - log_errx(1, "salen %u < %u", - client_salen, client_sa.ss_len); + assert(client_salen >= client_sa.ss_len); log_debugx("incoming connection, id %d, portal id %d", connection_id, portal_id); @@ -1806,10 +1803,8 @@ main_loop(struct conf *conf, bool dont_fork) &client_salen); if (client_fd < 0) log_err(1, "accept"); - if (client_salen < client_sa.ss_len) - log_errx(1, "salen %u < %u", - client_salen, - client_sa.ss_len); + assert(client_salen >= client_sa.ss_len); + handle_connection(portal, client_fd, (struct sockaddr *)&client_sa, dont_fork); diff --git a/usr.sbin/ctld/login.c b/usr.sbin/ctld/login.c index ea4b05483db1..209582bed99e 100644 --- a/usr.sbin/ctld/login.c +++ b/usr.sbin/ctld/login.c @@ -806,6 +806,16 @@ login_negotiate(struct connection *conn, struct pdu *request) login_set_csg(response, BHSLR_STAGE_OPERATIONAL_NEGOTIATION); login_set_nsg(response, BHSLR_STAGE_FULL_FEATURE_PHASE); response_keys = keys_new(); + + if (skipped_security && + conn->conn_session_type == CONN_SESSION_TYPE_NORMAL) { + if (conn->conn_target->t_alias != NULL) + keys_add(response_keys, + "TargetAlias", conn->conn_target->t_alias); + keys_add_int(response_keys, "TargetPortalGroupTag", + conn->conn_portal->p_portal_group->pg_tag); + } + for (i = 0; i < KEYS_MAX; i++) { if (request_keys->keys_names[i] == NULL) break; @@ -836,8 +846,6 @@ login(struct connection *conn) struct auth_group *ag; const char *initiator_name, *initiator_alias, *session_type, *target_name, *auth_method; - char *portal_group_tag; - int rv; /* * Handle the initial Login Request - figure out required authentication @@ -1016,13 +1024,8 @@ login(struct connection *conn) if (conn->conn_target->t_alias != NULL) keys_add(response_keys, "TargetAlias", conn->conn_target->t_alias); - rv = asprintf(&portal_group_tag, "%d", + keys_add_int(response_keys, "TargetPortalGroupTag", conn->conn_portal->p_portal_group->pg_tag); - if (rv <= 0) - log_err(1, "asprintf"); - keys_add(response_keys, - "TargetPortalGroupTag", portal_group_tag); - free(portal_group_tag); } keys_save(response_keys, response); pdu_send(response); @@ -1069,16 +1072,11 @@ login(struct connection *conn) response_keys = keys_new(); keys_add(response_keys, "AuthMethod", "CHAP"); if (conn->conn_session_type == CONN_SESSION_TYPE_NORMAL) { - rv = asprintf(&portal_group_tag, "%d", - conn->conn_portal->p_portal_group->pg_tag); - if (rv <= 0) - log_err(1, "asprintf"); - keys_add(response_keys, - "TargetPortalGroupTag", portal_group_tag); - free(portal_group_tag); if (conn->conn_target->t_alias != NULL) keys_add(response_keys, "TargetAlias", conn->conn_target->t_alias); + keys_add_int(response_keys, "TargetPortalGroupTag", + conn->conn_portal->p_portal_group->pg_tag); } keys_save(response_keys, response); diff --git a/usr.sbin/fdread/fdutil.c b/usr.sbin/fdread/fdutil.c index c1f4d8f18dfb..c66b0c11bc00 100644 --- a/usr.sbin/fdread/fdutil.c +++ b/usr.sbin/fdread/fdutil.c @@ -92,6 +92,7 @@ static struct fd_type fd_types_auto[1] = static struct fd_type fd_types_288m[] = { +#ifndef PC98 #if 0 { FDF_3_2880 }, #endif @@ -102,30 +103,18 @@ static struct fd_type fd_types_288m[] = { { FDF_3_820 }, { FDF_3_800 }, { FDF_3_720 }, +#endif /* !PC98 */ { 0,0,0,0,0,0,0,0,0,0,0,0 } }; static struct fd_type fd_types_144m[] = { #ifdef PC98 -#if 0 - { FDF_3_1722 }, - { FDF_3_1476 }, -#endif { FDF_3_1440 }, { FDF_3_1200 }, -#if 0 - { FDF_3_820 }, - { FDF_3_800 }, -#endif { FDF_3_720 }, { FDF_3_360 }, { FDF_3_640 }, { FDF_3_1230 }, -#if 0 - { FDF_3_1280 }, - { FDF_3_1480 }, - { FDF_3_1640 }, -#endif { 0,0,0,0,0,0,0,0,0,0,0,0 } #else { FDF_3_1722 }, @@ -142,17 +131,10 @@ static struct fd_type fd_types_144m[] = { static struct fd_type fd_types_12m[] = { #ifdef PC98 { FDF_5_1200 }, -#if 0 - { FDF_5_820 }, - { FDF_5_800 }, -#endif { FDF_5_720 }, { FDF_5_360 }, { FDF_5_640 }, { FDF_5_1230 }, -#if 0 - { FDF_5_1280 }, -#endif { 0,0,0,0,0,0,0,0,0,0,0,0 } #else { FDF_5_1200 }, @@ -170,13 +152,17 @@ static struct fd_type fd_types_12m[] = { static struct fd_type fd_types_720k[] = { +#ifndef PC98 { FDF_3_720 }, +#endif { 0,0,0,0,0,0,0,0,0,0,0,0 } }; static struct fd_type fd_types_360k[] = { +#ifndef PC98 { FDF_5_360 }, +#endif { 0,0,0,0,0,0,0,0,0,0,0,0 } }; diff --git a/usr.sbin/hyperv/Makefile b/usr.sbin/hyperv/Makefile new file mode 100644 index 000000000000..c11b3417c191 --- /dev/null +++ b/usr.sbin/hyperv/Makefile @@ -0,0 +1,7 @@ +# $FreeBSD$ + +.include + +SUBDIR = tools + +.include diff --git a/usr.sbin/hyperv/Makefile.inc b/usr.sbin/hyperv/Makefile.inc new file mode 100644 index 000000000000..265f86d1ed55 --- /dev/null +++ b/usr.sbin/hyperv/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" diff --git a/usr.sbin/hyperv/tools/Makefile b/usr.sbin/hyperv/tools/Makefile new file mode 100644 index 000000000000..3cfc0013cf59 --- /dev/null +++ b/usr.sbin/hyperv/tools/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.include + +HV_KVP_DAEMON_DISTDIR?= ${.CURDIR}/../../../contrib/hyperv/tools +.PATH: ${HV_KVP_DAEMON_DISTDIR} + +PROG= hv_kvp_daemon +MAN= hv_kvp_daemon.8 + +CFLAGS+= -I${.CURDIR}/../../../sys/dev/hyperv/utilities + +.include diff --git a/usr.sbin/iscsid/iscsid.8 b/usr.sbin/iscsid/iscsid.8 index fbfc55d72c2c..851771804974 100644 --- a/usr.sbin/iscsid/iscsid.8 +++ b/usr.sbin/iscsid/iscsid.8 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 20, 2012 +.Dd September 12, 2014 .Dt ISCSID 8 .Os .Sh NAME @@ -49,12 +49,13 @@ as well as performing SendTargets discovery. Upon startup, the .Nm daemon opens the iSCSI initiator device file and waits for kernel requests. -It doesn't use any configuration file; all the information it needs it gets -from the kernel. +.Nm +does not use any configuration files. +All needed information is supplied by the kernel. .Pp When the .Nm -damon is not running, already established iSCSI connections continue +daemon is not running, already established iSCSI connections continue to work. However, establishing new connections, or recovering existing ones in case of connection error, is not possible. @@ -99,6 +100,7 @@ The .Nm utility exits 0 on success, and >0 if an error occurs. .Sh SEE ALSO +.Xr iscsi 4 , .Xr iscsictl 8 .Sh HISTORY The @@ -108,6 +110,6 @@ command appeared in .Sh AUTHORS The .Nm -was developed by +utility was developed by .An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org under sponsorship from the FreeBSD Foundation. diff --git a/usr.sbin/iscsid/login.c b/usr.sbin/iscsid/login.c index 3391f906d258..c0bef632292f 100644 --- a/usr.sbin/iscsid/login.c +++ b/usr.sbin/iscsid/login.c @@ -213,6 +213,7 @@ login_handle_redirection(struct connection *conn, struct pdu *response) log_debugx("received redirection to \"%s\"", target_address); kernel_modify(conn, target_address); + keys_delete(response_keys); } static struct pdu * @@ -574,7 +575,7 @@ login_negotiate(struct connection *conn) struct pdu *request, *response; struct keys *request_keys, *response_keys; struct iscsi_bhs_login_response *bhslr; - int i; + int i, nrequests = 0; log_debugx("beginning operational parameter negotiation"); request = login_new_request(conn, BHSLR_STAGE_OPERATIONAL_NEGOTIATION); @@ -628,19 +629,41 @@ login_negotiate(struct connection *conn) response_keys->keys_names[i], response_keys->keys_values[i]); } - bhslr = (struct iscsi_bhs_login_response *)response->pdu_bhs; - if ((bhslr->bhslr_flags & BHSLR_FLAGS_TRANSIT) == 0) - log_warnx("received final login response " - "without the \"T\" flag"); - else if (login_nsg(response) != BHSLR_STAGE_FULL_FEATURE_PHASE) + keys_delete(response_keys); + response_keys = NULL; + + for (;;) { + bhslr = (struct iscsi_bhs_login_response *)response->pdu_bhs; + if ((bhslr->bhslr_flags & BHSLR_FLAGS_TRANSIT) != 0) + break; + + nrequests++; + if (nrequests > 5) { + log_warnx("received login response " + "without the \"T\" flag too many times; giving up"); + break; + } + + log_debugx("received login response " + "without the \"T\" flag; sending another request"); + + pdu_delete(response); + + request = login_new_request(conn, + BHSLR_STAGE_OPERATIONAL_NEGOTIATION); + pdu_send(request); + pdu_delete(request); + + response = login_receive(conn); + } + + if (login_nsg(response) != BHSLR_STAGE_FULL_FEATURE_PHASE) log_warnx("received final login response with wrong NSG 0x%x", login_nsg(response)); + pdu_delete(response); log_debugx("operational parameter negotiation done; " "transitioning to Full Feature phase"); - - keys_delete(response_keys); - pdu_delete(response); } static void diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 9771498acb3d..06ea1b03b236 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -176,7 +176,7 @@ printjob(struct printer *pp) } if(setgid(getegid()) != 0) err(1, "setgid() failed"); printpid = getpid(); /* for use with lprm */ - setpgrp(0, printpid); + setpgid((pid_t)0, printpid); /* * At initial lpd startup, printjob may be called with various diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c index 92d5508f5d24..9fd87ae6ba5e 100644 --- a/usr.sbin/makefs/ffs.c +++ b/usr.sbin/makefs/ffs.c @@ -361,7 +361,8 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts) if (ffs_opts->avgfpdir == -1) ffs_opts->avgfpdir = AFPDIR; - if (roundup(fsopts->minsize, ffs_opts->bsize) > fsopts->maxsize) + if (fsopts->maxsize > 0 && + roundup(fsopts->minsize, ffs_opts->bsize) > fsopts->maxsize) errx(1, "`%s' minsize of %lld rounded up to ffs bsize of %d " "exceeds maxsize %lld. Lower bsize, or round the minimum " "and maximum sizes to bsize.", dir, diff --git a/usr.sbin/mfiutil/mfi_properties.c b/usr.sbin/mfiutil/mfi_properties.c index c9c9204d5004..b03d522c3b9b 100644 --- a/usr.sbin/mfiutil/mfi_properties.c +++ b/usr.sbin/mfiutil/mfi_properties.c @@ -68,7 +68,7 @@ mfi_ctrl_set_properties(int fd, struct mfi_ctrl_props *info) static int mfi_ctrl_rebuild_rate(int ac, char **av) { - int error, fd; + int error, fd; struct mfi_ctrl_props ctrl_props; if (ac > 2) { @@ -76,40 +76,40 @@ mfi_ctrl_rebuild_rate(int ac, char **av) return(-1); } - fd = mfi_open(mfi_unit, O_RDWR); - if (fd < 0) { - error = errno; - warn("mfi_open"); - return (error); - } + fd = mfi_open(mfi_unit, O_RDWR); + if (fd < 0) { + error = errno; + warn("mfi_open"); + return (error); + } error = mfi_ctrl_get_properties(fd, &ctrl_props); - if ( error < 0) { - error = errno; - warn("Failed to get controller properties"); - close(fd); - return (error); - } + if ( error < 0) { + error = errno; + warn("Failed to get controller properties"); + close(fd); + return (error); + } /* * User requested a change to the rebuild rate */ if (ac > 1) { ctrl_props.rebuild_rate = atoi(av[ac - 1]); error = mfi_ctrl_set_properties(fd, &ctrl_props); - if ( error < 0) { - error = errno; - warn("Failed to set controller properties"); - close(fd); - return (error); - } + if ( error < 0) { + error = errno; + warn("Failed to set controller properties"); + close(fd); + return (error); + } error = mfi_ctrl_get_properties(fd, &ctrl_props); - if ( error < 0) { - error = errno; - warn("Failed to get controller properties"); - close(fd); - return (error); - } + if ( error < 0) { + error = errno; + warn("Failed to get controller properties"); + close(fd); + return (error); + } } printf ("controller rebuild rate: %%%u \n", ctrl_props.rebuild_rate); @@ -120,7 +120,7 @@ MFI_COMMAND(ctrlprop, rebuild, mfi_ctrl_rebuild_rate); static int mfi_ctrl_alarm_enable(int ac, char **av) { - int error, fd; + int error, fd; struct mfi_ctrl_props ctrl_props; if (ac > 2) { @@ -128,40 +128,40 @@ mfi_ctrl_alarm_enable(int ac, char **av) return(-1); } - fd = mfi_open(mfi_unit, O_RDWR); - if (fd < 0) { - error = errno; - warn("mfi_open"); - return (error); - } + fd = mfi_open(mfi_unit, O_RDWR); + if (fd < 0) { + error = errno; + warn("mfi_open"); + return (error); + } error = mfi_ctrl_get_properties(fd, &ctrl_props); - if ( error < 0) { - error = errno; - warn("Failed to get controller properties"); - close(fd); - return (error); - } + if ( error < 0) { + error = errno; + warn("Failed to get controller properties"); + close(fd); + return (error); + } printf ("controller alarm was : %s\n", (ctrl_props.alarm_enable ? "enabled" : "disabled")); if (ac > 1) { ctrl_props.alarm_enable = atoi(av[ac - 1]); error = mfi_ctrl_set_properties(fd, &ctrl_props); - if ( error < 0) { - error = errno; - warn("Failed to set controller properties"); - close(fd); - return (error); - } + if ( error < 0) { + error = errno; + warn("Failed to set controller properties"); + close(fd); + return (error); + } error = mfi_ctrl_get_properties(fd, &ctrl_props); - if ( error < 0) { - error = errno; - warn("Failed to get controller properties"); - close(fd); - return (error); - } + if ( error < 0) { + error = errno; + warn("Failed to get controller properties"); + close(fd); + return (error); + } } printf ("controller alarm was : %s\n", (ctrl_props.alarm_enable ? "enabled" : "disabled")); diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile index e73815aaac35..1ceb52eeb6f5 100644 --- a/usr.sbin/mtree/Makefile +++ b/usr.sbin/mtree/Makefile @@ -17,6 +17,6 @@ LDADD= -lmd CLEANFILES+= fmtree.8 fmtree.8: mtree.8 - cp ${.ALLSRC} ${.TARGET} + cp -f ${.ALLSRC} ${.TARGET} .include diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8 index e6d79a468ef8..ba3db8a1f200 100644 --- a/usr.sbin/newsyslog/newsyslog.8 +++ b/usr.sbin/newsyslog/newsyslog.8 @@ -17,7 +17,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd May 19, 2014 +.Dd September 23, 2014 .Dt NEWSYSLOG 8 .Os .Sh NAME @@ -156,6 +156,7 @@ will create the .Dq rotated logfiles using the specified time format instead of the default sequential filenames. +The filename used will be kept until it is deleted. The time format is described in the .Xr strftime 3 manual page. diff --git a/usr.sbin/pw/Makefile b/usr.sbin/pw/Makefile index eae0b879aa5b..8c5acf901d1c 100644 --- a/usr.sbin/pw/Makefile +++ b/usr.sbin/pw/Makefile @@ -11,4 +11,10 @@ WARNS?= 2 DPADD= ${LIBCRYPT} ${LIBUTIL} LDADD= -lcrypt -lutil +.include + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile new file mode 100644 index 000000000000..577ea9323919 --- /dev/null +++ b/usr.sbin/pw/tests/Makefile @@ -0,0 +1,10 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/usr.sbin/pw + +ATF_TESTS_SH= pw_delete + +FILES= group helper_functions.shin master.passwd +FILESDIR= ${TESTSDIR} + +.include diff --git a/usr.sbin/pw/tests/group b/usr.sbin/pw/tests/group new file mode 100644 index 000000000000..620c588faa38 --- /dev/null +++ b/usr.sbin/pw/tests/group @@ -0,0 +1,3 @@ +# $FreeBSD$ +# +wheel:*:0:root diff --git a/usr.sbin/pw/tests/helper_functions.shin b/usr.sbin/pw/tests/helper_functions.shin new file mode 100755 index 000000000000..f87b1e7d9436 --- /dev/null +++ b/usr.sbin/pw/tests/helper_functions.shin @@ -0,0 +1,15 @@ +# $FreeBSD$ + +# Workdir to run tests in +TESTDIR=$(atf_get_srcdir) + +# Populate the files pw needs to use into $HOME/etc +populate_etc_skel() { + cp ${TESTDIR}/master.passwd ${HOME} || \ + atf_fail "Populating master.passwd in ${HOME}" + cp ${TESTDIR}/group ${HOME} || atf_fail "Populating group in ${HOME}" + + # Generate the passwd file + pwd_mkdb -p -d ${HOME} ${HOME}/master.passwd || \ + atf_fail "generate passwd from master.passwd" +} diff --git a/usr.sbin/pw/tests/master.passwd b/usr.sbin/pw/tests/master.passwd new file mode 100644 index 000000000000..f7dc837dabca --- /dev/null +++ b/usr.sbin/pw/tests/master.passwd @@ -0,0 +1,4 @@ +# $FreeBSD$ +# +root:*:0:0::0:0:Charlie &:/root:/bin/csh +toor:*:0:0::0:0:Bourne-again Superuser:/root: diff --git a/usr.sbin/pw/tests/pw_delete.sh b/usr.sbin/pw/tests/pw_delete.sh new file mode 100755 index 000000000000..06366294bd4b --- /dev/null +++ b/usr.sbin/pw/tests/pw_delete.sh @@ -0,0 +1,24 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + +# Test that a user can be deleted when another user is part of this +# user's default group and does not go into an infinate loop. +# PR: 191427 +atf_test_case rmuser_seperate_group cleanup +rmuser_seperate_group_head() { + atf_set "timeout" "30" +} +rmuser_seperate_group_body() { + populate_etc_skel + pw -V ${HOME} useradd test || atf_fail "Creating test user" + pw -V ${HOME} groupmod test -M 'test,root' || \ + atf_fail "Modifying the group" + pw -V ${HOME} userdel test || atf_fail "delete the user" +} + + +atf_init_test_cases() { + atf_add_test_case rmuser_seperate_group +} diff --git a/usr.sbin/unbound/local-setup/local-unbound-setup.sh b/usr.sbin/unbound/local-setup/local-unbound-setup.sh index 837cf9a19148..a16e6d05a656 100755 --- a/usr.sbin/unbound/local-setup/local-unbound-setup.sh +++ b/usr.sbin/unbound/local-setup/local-unbound-setup.sh @@ -178,7 +178,7 @@ gen_forward_conf() { echo "forward-zone:" echo " name: ." for forwarder ; do - if expr "${forwarder}" : "^[0-9:.]\{1,\}$" >/dev/null ; then + if expr "${forwarder}" : "^[0-9A-Fa-f:.]\{1,\}$" >/dev/null ; then echo " forward-addr: ${forwarder}" else echo " forward-host: ${forwarder}"

This file, and other release-related documents, @@ -18,7 +19,7 @@ contacting <questions@FreeBSD.org>.